[問題] 想不出錯在哪..

看板Fortran作者 (小柯)時間13年前 (2011/07/21 21:10), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
想了好久還是不曉得錯在哪,煩請各位替我解惑一下~~ 以下是我的程式碼 module spectrum use input use constant implicit none contains function J(w) implicit none real(kind=8) :: w real(kind=8) :: J J = 2*pi*eta*w*((w/wc)**(s-1))*exp(-(w/wc)) return end function function expo(w,i) !! exp(-iwt) implicit none real(kind=8) :: w integer(kind=8) :: i complex(kind=8) :: expo complex(kind=8), parameter :: k = (0.0,1.0) expo = exp(-1*i*k*w*dt) end function function g(i) implicit none real(kind=8) :: w integer(kind=8) i, counter complex(kind=8) g complex(kind=8) :: X0, X1, X2 X0 = J(0.0)*expo(0.0, i)+J(15.0)*expo(15.0, i) X1 = 0.0 X2 = 0.0 w = 0.0 do counter=1, nn w = counter*dw if(mod(counter,2)<0.001) then X2 = X2+J(w)*expo(w,i) else X1 = X1+J(w)*expo(w,i) end if end do g = dw*(X0+2*X2+4*X1) end function end module spectrum 其中use用到的部份是 module input implicit none integer,parameter :: n = 100, ni = 2*n, nn = 1000 !! the cutting number, the number of interval real(kind=8), parameter :: ti = 0.0 !! initial time real(kind=8), parameter :: tf = 10.0 !! final time real(kind=8) :: dt = (tf-ti)/n !! time interval real(kind=8) :: t real(kind=8) :: u_0 = 1.0 !! initial condition real(kind=8) :: w0 = 1.0 !! frequency of the cavity real(kind=8) :: eta = 0.02 !! coupling strength 0.02, 0.1, 0.3, 0.4, 0.6, 1.0 real(kind=8) :: s = 0.5 !! type of sprctral, 1.0 = ohmic, 0.5 = subohmic, 3.0 = superohmic real(kind=8) :: wc = 1.0 !! the cut-off frequency real(kind=8), parameter :: w_i = 0.0 real(kind=8), parameter :: w_f = 15.0 real(kind=8) :: dw = (w_f-w_i)/n !!frequency interval end module input 跟 module constant implicit none real, parameter :: pi = 3.1415926 real, parameter :: boltzmann = 1.38*1E-23 end module constant --------------------Configuration: IDERK4 - Win32 Debug-------------------- Compiling Fortran... E:\0Physichair\FORTRAN\IDERK4\spectrum.f90 E:\0Physichair\FORTRAN\IDERK4\spectrum.f90(37) : Error: The type of the actual argument differs from the type of the dummy argument. [0.0] X0 = J(0.0)*expo(0.0, i)+J(15.0)*expo(15.0, i) ----------^ E:\0Physichair\FORTRAN\IDERK4\spectrum.f90(37) : Error: The type of the actual argument differs from the type of the dummy argument. [0.0] X0 = J(0.0)*expo(0.0, i)+J(15.0)*expo(15.0, i) --------------------^ E:\0Physichair\FORTRAN\IDERK4\spectrum.f90(37) : Error: The type of the actual argument differs from the type of the dummy argument. [15.0] X0 = J(0.0)*expo(0.0, i)+J(15.0)*expo(15.0, i) ------------------------------^ E:\0Physichair\FORTRAN\IDERK4\spectrum.f90(37) : Error: The type of the actual argument differs from the type of the dummy argument. [15.0] X0 = J(0.0)*expo(0.0, i)+J(15.0)*expo(15.0, i) -----------------------------------------^ Error executing df.exe. spectrum.obj - 4 error(s), 0 warning(s) 我的問題是,明明已經宣告了要傳進J跟EXPO的參數是浮點 為什麼還是會出現這樣的錯誤訊息? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.91.242

07/21 21:18, , 1F
real(8)的話要用0.d0,15.d0等,或者用dble來轉
07/21 21:18, 1F

07/21 21:43, , 2F
哦哦~~~我改了以後真的可以跑了~!
07/21 21:43, 2F
文章代碼(AID): #1EA2LR_T (Fortran)
文章代碼(AID): #1EA2LR_T (Fortran)