我是 MPI 和 Fortran 77 菜鸟。我有一个 fortran 77 代码FKRPRO.f
,我想使用 OpenMPI 对其进行并行化。该代码需要大量参数,这些参数在运行时从一个单独的文件中输入。编译运行是这样的
gfortran -o FKRPRO FKRPRO.f
./FKRPRO < Modelfile.txt
代码中的等效行(不是我的代码)是
PARAMETER(LIN=5)
INTEGER ERROR
LOGICAL PRNTA
PRNTA=.FALSE.
READ(LIN,'(L3)') PRNTA
READ(LIN,21) M1,M2
21 FORMAT(11I5)
等等。有人可以向我解释一下是什么READ(LIN,'(L3)') PRNTA
意思。输入文件 Modelfile.txt 中的输入是这样的
.F.
0 64
and so on..
我将必要的 MPI 语句放入代码中。
INCLUDE 'MPIF.H'
...
CALL MPI_INIT(ERROR)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD,NPROCS,ERROR)
CALL MPI_COMM_RANK(MPI_COMM_WORLD,PRANK,ERROR)
...
CALL MPI_TYPE_FREE(NEWMATRIX,ERROR)
CALL MPI_FINALIZE(ERROR)
所有进程都无法读取输入文件。我已经编译并运行这样的代码
mpif77 -o bc3 FKRPROG5.f
mpirun -np 4 bc3 < Modelfile.txt
这是行不通的。我收到以下错误。只有第一个进程或 rank 0 可以读取文件。
At line 50 of file FKRPROG5.f (unit = 5, file = 'stdin')
Fortran runtime error: End of file
At line 50 of file FKRPROG5.f (unit = 5, file = 'stdin')
Fortran runtime error: End of file
At line 50 of file FKRPROG5.f (unit = 5, file = 'stdin')
Fortran runtime error: End of file
mpirun has exited due to process rank 3 with PID 866 on
node Avinash-rMBP.local exiting improperly. There are two reasons this could occur:
1. this process did not call "init" before exiting, but others in
the job did. This can cause a job to hang indefinitely while it waits
for all processes to call "init". By rule, if one process calls "init",
then ALL processes must call "init" prior to termination.
2. this process called "init", but exited without calling "finalize".
By rule, all processes that call "init" MUST call "finalize" prior to
exiting or it will be considered an "abnormal termination"
This may have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
第 50 行是READ(LIN,'(L3)') PRNTA
。有人请指出我哪里出错了 :( 那么,我怎样才能让所有进程从此输入文件 < Modelfile.txt 中读取??谢谢。