Gfortran Complex for Real Dummy Argument

I'm trying to use fftpack with gfortran, but I'm getting errors that I think are related to complex arrays being passed to some procedures when the dummy argument is declared real.

I read a comment on the Intel fortran page so that the " validation check interface " can be disabled . Does anyone know if there is a similar option for gfortran?

I wouldn't have to edit fftpack ... (I think this is because the complex one in memory is represented by two reals and the array arguments are passed as references, but please correct me if I'm wrong :))

[for development and satisfying comments ...] So after downloading dfftpack from netlib and compiling as a standalone file (f77 I press) with all subroutines in the same file, I get a warning like in

   SUBROUTINE DFFTF (N,R,WSAVE)
   IMPLICIT DOUBLE PRECISION (A-H,O-Z)
   DIMENSION       R(1)       ,WSAVE(1)
   IF (N .EQ. 1) RETURN
   CALL RFFTF1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
   RETURN
   END

      

warring appears when called CALL RFFTF1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))

. The beginning of RFFTF1 looks like this ...

SUBROUTINE RFFTF1 (N,C,CH,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION       CH(*)      ,C(*)       ,WA(*)      ,IFAC(*)

      

and the compile warning outputs the actual argument WSAVE(2*N+1)

- to the dummy argument IFAC

: (output from the window lock log window:)

 mingw32-gfortran.exe -Jobj\Debug\  -Wall -g     -c
 C:\... \dfftpack.f -o obj\Debug\dfftpack.o
 C:\... \dfftpack.f:345.40:
 CALL RFFTB1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))                   
                                   1 Warning: Type mismatch in argument 
'ifac' at (1); passed REAL(8) to INTEGER(4)

      

I'm guessing this will produce an incorrect result .. (going from real to integer seems like it doesn't convert / round to the nearest integer, but something else. Does anyone know if it should be rounded in a call like NINT(WSAVE(2*N+1))

:?

+1


source to share


1 answer


I ran into this problem when I refactored FFTPACK 5.1 from FORTRAN 77 to Fortran 2008. I did the casting in C without copying like this:



use ISO_C_binding, only: c_f_pointer, c_loc

integer, parameter :: N = 42
complex, target    :: c(N) ! Also works for the allocatable attribute
real, pointer      :: r(:) => null()

! Pass memory address from complex array to real array
call c_f_pointer(c_loc(c), r, shape=[2*size(c)])

call procedure_expecting_real_arg(r, ....)

! Terminate association
nullify( r )

      

+1


source







All Articles