【发布时间】:2014-02-24 22:24:45
【问题描述】:
我是 Fortran 的新手,我的文件名有问题,我在 simuln#.res 中有一堆数据(其中 1
character(len=11) :: theFileA
character(len=12) :: theFileB
character(len=:), allocatable :: fileplace
write(*,*) "the directory with the data sets, use quotations"
read(*,*) fileplace
fileLoop : do j=1,20
if (j .lt. 10) then
write(theFileA, '("simuln", I1,".res")' ) j
open(newunit= iin,file = fileplace//theFileA,status='old')
else
write(theFileB, '("simuln",I2,".res")') j
open(newunit= iin,file = fileplace//theFileB,status='old')
end if
does some stuff with the file
end do fileLoop
代码在我的 mac 上使用 gfortran 编译器进行编译,但是当我将路径放入包含文件的目录时,它会给出错误 simuln1.res does not exist(它确实如此,三次检查)。我已经尝试更改编辑描述符(并使真实(j)),但我仍然得到同样的东西。
谁能帮帮我?
【问题讨论】:
-
我建议在实际使用 Fortran 2003 时不要使用
fortran90标签。
标签: fortran gfortran fortran2003 do-loops