参数类型不匹配:将COMPLEX(8)传递给REAL(8)

时间:2018-02-24 12:49:12

标签: fortran gfortran type-mismatch

我正在尝试编译并运行博士论文中相对较旧的代码,您可以在this文档的附录C和D中找到完整的代码。 以下是代码中的必要部分:

来自wfMath.f90:

subroutine wfmath_gaussian(widthz,pz)
 use progvars
 implicit none
 real*8, intent(in) :: widthz ! the width of the wavepacket
 real*8, intent(in) :: pz ! momentum
 integer :: nR
 real*8 :: rvalue
 complex*16 :: cvalue
 ! complex*16 :: psi !!!ORIGINAL CODE LINE 23/02/2018. Saba
 complex*16, dimension(1) :: psi !!! psi is originally defined as a scalar. But wfmath_normalize(wf) takes a rank-1 tensor as
 !argument. So here I change the declaration of psi from a scalar to a rank-1 tensor contains only one element. 23/02/2018. Saba
 real*8 :: z2
 z2 = minz + deltaz
 do nR=1, nz
 rvalue = exp( -((z2-centerz)/widthz)**2 /2 )/ (2*pi*widthz) !!!ORIGINAL CODE LINE
 !rvalue = exp( -((z2-centerz)/1.0d0)**2 /2 )/ (2*pi*1.0d0)
 cvalue = cdexp( cmplx(0.0,1.0)*(pz*z2))
 psi(nR) = rvalue * cvalue
 z2 = z2 + deltaz ! next grid position in x-direction
 enddo
 call wfmath_normalize(psi)
end subroutine wfmath_gaussian
来自tdse.f90的

- 主要部分:

subroutine init
 use progvars
 use strings;
 use wfMath;
 use wfPot;
 !use tdseMethods;
 implicit none
 integer :: nloop
 real*8 :: widthz,pz

 select case (trim(molecule))
 case("H2")
 mass = 917.66d0; nz = 2048; deltaz = 0.05d0;
 case("D2")
 mass = 1835.241507d0; nz = 1024; deltaz = 0.05d0;
 case("N2")
 mass = 12846.69099d0; nz = 512; deltaz = 0.01d0;
 case("O2")
 mass = 14681.93206d0; nz =8192 ; deltaz = 0.005d0;
 case("Ar2")
 mass = 36447.94123d0; nz = 65536; deltaz = 0.002d0;
 end select

 maxt = 33072.80d0 !800fs ! maximum time
 deltat = 1.0d0 ! delta time
 widthz = 1.0d0 ! width of the gaussian
 minz = 0.05d0 ! minimum z in a.u.
 maxz = nz * deltaz ! maximum z in a.u.
 centerz = 2.1d0 ! center of the gaussian
 nt = NINT(maxt/deltat) ! time steps
 pz = 0.d0 ! not used currently

!_____________________________FFT Section____________________________________________
 deltafft = 20.d0* deltat !1.0d0*deltat ! time step for FFT
 nfft = NINT(maxt/deltafft) ! no of steps for FFT

!_________________________absorber parameters_______________________________________
 fadewidth = 10.d0 ! the width of the absorber in a.u.
 fadestrength = 0.01d0 ! the maximum heigth of the negative imaginary potential

!_________________________E FIELD section_____________________________________________
 Ewidth = 1446.2d0 !35fs ! width of the envelope
 Eo = 0.053 !E14 ! field amplitude
 Eomega = 0.057d0 !800nm ! laser frequency
! Eomega = 0.033d0 !1400nm ! laser frequency
 Ephi = 0.d0 ! carrier envelope phase
 Eto = 1000.d0 ! ecenter of the Gaussian envelope
 EoPed = 0.0755 !2E14
 EwidthPed = 826.638 !20fs
 EomegaPed = Eomega
 EphiPed = 0.d0
 EtoPed = 1000.d0
 EoPump = 0.053 !1E14 0.00285d0
 EwidthPump = Ewidth
 EomegaPump = 0.057d0
 EphiPump = 0.0d0
 EtoPump = 0.d0
 includeAbsorber = .true. ! switch for absorber
 includeField = .true. ! .false. ! switch for efield
 includePedestal = .false. ! switch for pedestal

 includeConstantPump = .true. ! .false. ! switch for efield
 useADK = .false. ! ADK switch
 calculatePowerSpectra = .true.
 calculateKERPowerSpectra = .true. !.false.

!_____________________________Printing & Plotting Filters__________________________________
 printFilter = nz
 maxFrequencyFilter = 500
 printInterval =100 !200
 ! print filter upper boundary check
 if(printFilter > nz) then
 printFilter = nz
 end if
 call allocateArrays();

 do nloop = 1,nz
 Z(nloop) = minz+ (nloop)* deltaz;

 P(nloop) = 2*pi*(nloop-(nz/2)-1)/(maxz-minz);

 E(nloop) = 27.2*(P(nloop)**2)/(4.d0*mass);
 end do

 ! call wfmath_gaussian(psiground,widthz,pz) !!! ORIGINAL CODE LINE
 call wfmath_gaussian(psiground,real(widthz),pz) ! Attempt to solve mismatch error. Does not work. Saba 24/02/2018
 ! call wfmath_gaussian(psiground,1.0d0,pz) ! Attempt to solve mismatch error. Does not work. Saba 23/02/2018
 ! call wfmath_gaussian(pz) ! Attempt to solve mismatch error. Does not work. Saba 23/02/2018

 call setabsorber_right(fadewidth, fadestrength)
 call printpsi(psiground,trim(concat(outputFolder,"psi_gausssian.dat")))

 call potentials_init(nz) !initialize potential arrays

 call read_potential();

end subroutine init

据我了解,根本没有不匹配。 widthz在代码的主要部分(子程序init)中声明为实数* 8,子程序wfmath_gaussian(...)期望widthz为实数* 8。我看不出这个不匹配错误发生在哪里?

使用的编译器:GNU Fortran 6.3.0

使用了编译行:$ gfortran tdse.f90

错误消息:

tdse.f90:159:118:

call wfmath_gaussian(psiground,real(widthz),pz) ! Attempt to solve mismatch error. Does not work. Saba 24/02/2018
                                                                                                                 (1)

Error: Type mismatch in argument 'widthz' at (1); passed COMPLEX(8) to REAL(8)

提前致谢...

0 个答案:

没有答案