小编Ner*_*ess的帖子

将Go-to语句从FORTRAN 77转换为Fortran 90

我正在处理一段旧的F77代码,并尝试将其转换为等效的F90代码。我在下面遇到了这些问题,有人可以建议我的转换正确吗?

Fortran 77代码:

Subroutine area(x,y,z,d)
do 15 j=1,10
if (a.gt.b) go to 20
15 CONTINUE
20 Statement 1
   Statement 2
   Statement 3
end subroutine
Run Code Online (Sandbox Code Playgroud)

我试图将其转换为F90,如下所示:

Subroutine area(x,y,z,d)
  dloop: do j=1,10
    if (a>b) then 
      statement 1
      statement 2
      statement 3
    else
      write(*,*) 'Exiting dloop'
      exit dloop
    end if
  end do dloop
end subroutine
Run Code Online (Sandbox Code Playgroud)

有人可以建议这种方法是否正确吗?在我的结果中,我没有得到我期望的结果。因此,我的逻辑可能存在问题。

fortran if-statement fortran77 fortran90 do-loops

2
推荐指数
1
解决办法
1357
查看次数

标签 统计

do-loops ×1

fortran ×1

fortran77 ×1

fortran90 ×1

if-statement ×1