0

Trying to run a bit of code on a new cluster, however I am having some issues passing some data through mpirun into the fortran code. For note this bit of code has worked on previous clusters but something seems to be different with this cluster.

The cluster is running job submission through BSUB / LSF, I have tried compile the fortran code with ifort and gfortran versions of mpif90.

Specifically I have a job that needs to know its name. I pass this via a HEREDOC statement in the job submission script which looks like (note in the actual code it is an array job where each individual needs to be passed its unique identifier):

#!/bin/bash
#BSUB -q queuename
#BSUB -n 2
#BSUB -o jobname.job.o%J
#BSUB -J jobname.job
#BSUB -e jobname.job.e%J
#BSUB -W 1:00
cd /workingdirectory/
mpirun -lsf /workingdirectory/jobname.exe << EOD
jobname
EOD

Then the fortran script reads the stdin by:

      include 'mpif.h'
      integer num_procs,n_ranks,ierr
      character name*7
      call MPI_Init (ierr)
      call MPI_Comm_rank (MPI_COMM_WORLD,n_ranks,ierr)
      call MPI_Comm_size (MPI_COMM_WORLD,num_procs,ierr)
      if (n_ranks == 0) then
          read (*,'(a7)') name
          write(*,2000) name
      end if
 2000 format(a7)

However nothing ends up in the standard output and the code hangs indefinitely (well until the wall time runs out).

For note I have also tried entering the input into a file and passing it through the -i tag in BSUB:

#!/bin/bash
#BSUB -q queuename
#BSUB -n 2
#BSUB -i jobname.i
#BSUB -o jobname.job.o%J
#BSUB -J jobname.job
#BSUB -e jobname.job.e%J
#BSUB -W 1:00
cd /workingdirectory/
mpirun -lsf /workingdirectory/jobname.exe 

where jobname.i is:

jobname

And still no joy. The calculation can certainly access the storage as if I alter the fortran code to:

      include 'mpif.h'
      integer num_procs,n_ranks,ierr
      character name*7
      call MPI_Init (ierr)
      call MPI_Comm_rank (MPI_COMM_WORLD,n_ranks,ierr)
      call MPI_Comm_size (MPI_COMM_WORLD,num_procs,ierr)
      if (n_ranks == 0) then
          open (5,file='jobname.i',status='unknown')
          read (5,'(a7)') name
          write(*,2000) name
      end if
 2000 format(a7)

Then it works fine. Any suggestions?

David Duncan
  • 81
  • 1
  • 11
  • Which MPI library do you use? Why do you use << and not For OpenMPI see https://www.open-mpi.org/doc/v2.0/man1/mpirun.1.php#toc14 – Vladimir F Героям слава May 03 '17 at 16:03
  • It is a centrally managed system so to a large degree I'm using what they give me, but it looks like: IBM Platform MPI Community Edition – David Duncan May 03 '17 at 16:08
  • On your second question, I want to pass the text "jobname", rather than pass a file with the text "jobname" inside it. I believe if I used a < it would require a file, whereas << lets me pass text via a heredoc – David Duncan May 03 '17 at 16:17
  • I would look somewhere here https://www.ibm.com/support/knowledgecenter/en/SSFK3V_2.2.0/com.ibm.cluster.pe.v2r2.pe100.doc/am102_ureds.htm but try googling more, this was just the first quick find. – Vladimir F Героям слава May 03 '17 at 16:29
  • But command line arguments seem much better to me. – Vladimir F Героям слава May 03 '17 at 16:30
  • You mean pass "jobname" via a command line argument into mpirun to be called via $MPI_Init(argc, argv)$? Legacy is the main reason. The code was originally written to operate interactively and had a long list of parameters you had to enter (which was done via heredoc statements). It has been whittled down over the decades to just the jobname and when I generalised the code to utilise MPI I didn't feel the need to change it. I'm working on a workaround, but I really want to understand how to make it work with a heredoc statement. – David Duncan May 03 '17 at 16:56
  • I mesnt standard Fortran get_command_argument(), but it is not too qq – Vladimir F Героям слава May 03 '17 at 20:56

0 Answers0