陇原春风 发表于 2014-3-15 15:50:39

求助,函数传参

各位专家,大家好,新手向求教一个问题,请大家不吝赐教。
就是当我给一个函数传参时候,在函数调用之前,输出参数为正确值,但是到了函数里面该参数变得不可思议,从而导致参数计算失败。在群力讨论,大家说可能是参数类型不一致。可是在函数里面,没有再作参数的类型声明,应该不是这个问题吧。对了,我的编译器是cvf6.5,操作系统是win xp sp3。
下面这个问题代码块和输出结果
print*,'fre and theta =',fre,theta
    print*,'sm,sig,cl,st,poro,sv,cv=',sm,sig,cl,st,poro,sv,cv
c do 2010 clNo = 1,2,1
ccl = testCl(clNo)
slope1=sig/cl
   Zs = sig**2/cl
if(itype.eq.1) slope=1.414*sig/cl
   if(itype.eq.2) slope=sig/cl!这里不是矛盾吗?
print*,'sm in AIEM is:',sm
print*,'fre in AIEM is:',fre
cer=dcmplx(err,eri) !er指的是介电常数
ccall mois2dc(sm,fre,sv,cv,poro,st,er)!由土壤水分和频率计算介电常数,err和
call SM_DC(sm,fre,sv,cv,poro,st,er) 被调用的函数
函数内部:
SUBROUTINE SM_DC(sm,fre,sv,cv,poro,st,er)

! implicit real*4(a-h,o-z)
implicit byte(n)
integer i,j
! real*4 params(5),coe
! real*4 poro,st,sv,cv,sm,idcw,idcs,idcw_2,idcs_2
! complex*8 dcsoil,dcsoil_2
! complex*16 er
print*,"sm in Dobson is :",sm
print*,'fre in Dobson is:',fre




fcode 发表于 2014-3-15 15:57:37

主程序中 sm 和 fre 为双精度,在子程序中,也应该为双精度。没有再做声明是不对的,建议 Implicit None 并声明全部变量
页: [1]
查看完整版本: 求助,函数传参