| 本帖最后由 tianrui 于 2022-5-20 22:21 编辑 
 大家好,我遇到了一个问题,我编写了一个函数,最后有一个判断语句,不符合则stop并write(*,"('j设置错误')"),然而程序会在write这里卡住,将function替换为subroutine即可成功输出,代码如下,请问是我书写语法问题还是function就是不能有write输出到屏幕?
 
 [Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode real function get_mapdata(i,j,tile)
……
  if(j>nCol.OR.j<1)then
write(*,"('j输入错误')")!程序运行在这里卡住
   stop
  else
   get_mapdata=a(j)
  end if
 return
END
 subroutine方法:
 
 [Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode subroutine get_mapdata(i,j,tile,h)
……
  if(j>nCol.OR.j<1)then
   write(*,"('j输入错误')")
   stop
  else
   h=a(j)
  end if
 return
END
 |