Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Error when checking if pointer is associated

$
0
0

0down votefavorite

 

I recently started to use procedure pointers and it all worked fine. Now however, I get a segmentation fault when checking if one of those pointer is associated ONLY when it is null (i.e. no error when said pointer is associated).

I built a MCVE but this example code runs fine in all conditions, so there's no point posting it here. I am then thinking the error might be somewhere else in the code. Here is my original code:

module mms
    !***************
    !some code
    !***************
    procedure(template_get_rho    ), pointer :: get_rho => null()
    interface
        function template_get_rho(x1, x2, time) result(rho)
            import :: dp
            implicit none
            real(dp), intent(in) :: time
            real(dp), dimension(0:), intent(in)   :: x1, x2
            real(dp), allocatable, dimension(:,:) :: rho
        end function
     end interface

    !***************
    !some code
    !***************

 contains
     subroutine initialize_mms
          select case(mms_case)
          case(1)
              !***************
              !some code, get_rho is NOT associated to anything
              !***************
          case(2)
              get_rho => prob2_get_rho
          end select

          !nullify(get_rho)    <------------------------ Error here when uncommented
          !get_rho => null()   <-------- No errors here

          if(associated(get_rho)) then  <------------------ Error here when get_rho set to null()
              rho(0:nx-1, 0:ny-1) = get_rho(x, y, time)
          end if
     end subroutine

    !************
    ! some code
    !************
end module mms

 

For case(2), the code runs with no error. However, when I try to nullify(get_rho), I get a seg fault when calling the nullify statement. When I point get_rho to the null() pointer or for case(1), the seg fault happens at the associated statement.

Any idea what I'm doing wrong? I am using mpiifort 4.1.3.048 with the following debug flags:

-fpp -check all -traceback -warn all -implicitnone -heap-arrays

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>