Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The statement</p> <pre><code>READ(LIN,'(L3)') PRNTA </code></pre> <p>causes the program to read, from the unit attached to the channel with id <code>LIN</code>, a 3-character sequence which represents a logical value and assigns the value read to the variable <code>PRNTA</code>. From the fragments you've shown us the program will read <code>.F.</code> and set <code>PRNTA</code> to <code>.false.</code>.</p> <p><code>LIN</code> is set to the constant value 5, which usually means <code>stdin</code>. This use of <code>5</code> to denote <code>stdin</code> is not a <em>de jure</em> standard, it is more of a <em>de facto</em> standard.</p> <p>The straightforward way to read a parameter file into an MPI program is to ensure that only one process reads the file and then sends out the values to the other processes which need them.</p> <p>You seem to have written a program in which all processes try to read the same input file but, at run-time, the redirection you've used to pass <code>Modelfile.txt</code> is only working for one process (presumably the process with rank 0). The other processes are not getting an input file at all and are complaining, then bringing the program crashing down. The error message you show is typical of a Fortran program which doesn't find an input file at all when it tries to read.</p> <p>Far better to write code along the lines:</p> <pre><code>call mpi_init ... ... if (myrank==0) then open(...) inputfile read(...) parameters close(...) end if ... call mpi_bcast(parameters from 0 to all) ... </code></pre> <p>In general, don't expect the run-time environment for MPI processes to be identical copies of the run-time environment for a sequential program. I think that you are seeing evidence that your run-time directs the input only to the first process created when your program runs. Since <code>mpirun</code> is not standardised (though <code>mpiexec</code> is) I don't think you can rely on this run-time behaviour being the same for all MPI implementations. For portability and compatibility you're better off handling I/O explicitly within your program than using o/s features such as redirection.</p> <p>You could, rather than have process 0 read the parameters and distribute them to other processes, write your code such that each process reads the same file. If you do write your code this way take care to ensure that the processes aren't fighting over access to the I/O channels; having multiple processes trying to (nearly-)simultaneously read across a single input channel is a sure way to slow things down.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload