我对 Fortran 还很陌生,而且我的文件名有问题,我在 simuln#.res 中有一堆数据(其中 1<#<20),我有多个不同的目录,它们都具有相同的 simuln#.res名称,但它们具有不同的输入参数。代码如下所示:
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)),但我仍然得到同样的东西。谁能帮我?