我需要一个文件来阅读并享受它的乐趣。 例如,我想在其中加入delta T, 我用:
function GetDeltaT (whereabout) result (DeltaT)
implicit none
character(16) , intent (in) :: whereabout
real(8) :: CurrentTime
Real(8):: DeltaT
open(20,file=whereabout,status='old',action='read')
read (20,*) DeltaT
read (20,*) CurrentTime
DeltaT=CurrentTime-DeltaT
close(20)
return
end function GetDeltaT
我的问题是这里的位置定义:有时我使用16个长度标题(例如AL026_pdcham.txt
)
但我也可以少用。但是当它不是16个字符长(例如AL03_pdcham.txt
)
我有这条警告信息:
Warning: Character length of actual argument shorter than of dummy argument 'whereabout' (15/16) |
并执行:
At line 46 of file C:\Users\LambourgA\Documents\stage\V1\ModularStructureRT V5\R
eadData.f90 (unit = 20, file = 'Ó3u')
Fortran runtime error: Invalid argument
Process returned 2 (0x2) execution time : 0.042 s
Press any key to continue.
我该如何解决这个问题?
答案 0 :(得分:3)
尝试替换
character(16) , intent (in) :: whereabout
带
character(len=*), intent (in) :: whereabout
现在回到Fortran教程,了解假定的类型参数。