renlu617 发表于 2015-4-17 10:14:02

改程序中出现的问题

源程序很简单的依据:DO I=NLAYER,1,-1
我需要加些判定条件,大概改成这个意思:
IF(FDTNLAYER.GT.0.AND. FDTNLAYER .LT.NLAYER)THEN      DO I=NLAYER,FDTNLAYER,-1 IF(fDTNLAYER.EQ.NLAYER)THEN   不循环IF(TDTNLAYER.GT.0 .AND.TDTNLAYER.LT.NLAYER) then      DO I=TDTNLAYER,1,-1 IF(TDTNLAYER.EQ.NLAYER)THEN      DO 51 I = NLAYER,1, -1

改成一个这样的程序要怎么改呢?

fcode 发表于 2015-4-17 10:33:12

If (fdtnlayer>0 .And. fdtnlayer<nlayer) Then
   iBegin = nLayer
   iEnd   = fdtnLayer
   iStep= -1
Else If (fdtnlayer==nlayer) Then
   iBegin = 1
   iEnd   = 0 !// 结束小于开始,则不循环
   iStep= 1
Else If (tdtnlayer>0 .And. tdtnlayer<nlayer) Then
   iBegin =tdtnLayer
   iEnd   = 1
   iStep= -1
Else If (tdtnlayer==nlayer) Then
   iBegin = nLayer
   iEnd   = 1
   iStep= -1
End If
Do i = iBegin , iEnd , iStep
   ...
End Do

renlu617 发表于 2015-4-17 11:17:03

fcode 发表于 2015-4-17 10:33
If (fdtnlayer>0 .And. fdtnlayer0 .And. tdtnlayer

错误        1       error #8093: A do-variable within a DO body shall not appear in a variable definition context.           C:\B90Vdongtu\FOR\B90.FOR        510       

出现了好几个这样的错误,这是怎么回事呢?

renlu617 发表于 2015-4-17 11:28:21

就是会出现截图里面的情况,以前也没见过啊

fcode 发表于 2015-4-17 12:29:58

这需要代码才能判断。

Villain 发表于 2015-4-17 12:30:14

renlu617 发表于 2015-4-17 11:17
错误        1       error #8093: A do-variable within a DO body shall not appear in a variable definition cont ...

fcode 给你的是以f90的自由格式写的,而你用的后缀是FOR,编译器就是以f77的固定格式来编译,自然会抱错。

Villain 发表于 2015-4-17 12:32:13

renlu617 发表于 2015-4-17 11:28
就是会出现截图里面的情况,以前也没见过啊

f77的固定格式中,doenddo的格式是没有的。
页: [1]
查看完整版本: 改程序中出现的问题