本帖最后由 McP 于 2015-5-17 21:06 编辑
函数子程序代码如下
[Fortran] 纯文本查看 复制代码 function ks(n,th,thwp,thj,c1,c2,c3,c4,d1,d2,d3,d4,dx1,dx2,dx3,dx4,t) result(kss)
implicit none
integer,intent(in)::n,dx1,dx2,dx3,dx4,t
real,intent(in)::th,thwp,thj,c1,c2,c3,c4,d1,d2,d3,d4
real::kss
first: if(th>thj) then kss=1.0 !此行报错为Error: Syntax error, found IDENTIFIER 'THEN' when expecting one of: THEN
else !此行报错为Error: An ELSE statement occurred without a corresponding IF THEN statement.
next: if(t>=0.and.t<dx1) then kss=c1*((th-thwp)/(thj-thwp))**d1 !此行报错为Error: Syntax error, found IDENTIFIER 'THEN' when expecting one of: THEN
elseif(t>=dx1.and.t<(dx1+dx2)) then kss=c2*((th-thwp)/(thj-thwp))**d2 !此行报错为Error: Syntax error, found IDENTIFIER 'THEN' when expecting one of: THEN
elseif(t>=(dx1+dx2).and.t<(dx1+dx2+dx3)) then kss=c3*((th-thwp)/(thj-thwp))**d3 !此行报错为Error: Syntax error, found IDENTIFIER 'THEN' when expecting one of: THEN
elseif(t>=(dx1+dx2+dx3).and.t<=(dx1+dx2+dx3+dx4)) then kss=c4*((th-thwp)/(thj-thwp))**d4 !此行报错为Error: Syntax error, found IDENTIFIER 'THEN' when expecting one of: THEN
else print*,'该时间超出计算范围' !此行报错为Error: Syntax error, found '*' when expecting one of: <END-OF-STATEMENT> ;
endif next !此行报错为Error: An ENDIF occurred without a corresponding IF THEN or ELSE statement.
endif first
end function
当然,一但把if结构改成if语句就没问题了,但希望弄清楚为什么会出现这么诡异的情况。望得闻圣音!
|