1

私は 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(これは絶対に行われ、トリプルチェックされます)。編集記述子を変更しようとしました (そして、real(j) を作成しようとしました) が、それでも同じ結果が得られます。誰でも私を助けることができますか?

4

1 に答える 1