Gfortran complex actual to real dummy argument

前端 未结 1 801
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 02:49

I am trying to use fftpack with gfortran, but I am getting errors that i think relate to that some routines are passed complex arrays when the dummy argument is declared as real

相关标签:
1条回答
  • 2021-01-25 03:23

    I encountered this problem when I refactored FFTPACK 5.1 from FORTRAN 77 to Fortran 2008. I performed a C-language style cast without copying as follows:

    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 )
    
    0 讨论(0)
提交回复
热议问题