Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29241 Discussions

Porblem/Bug for GET_ENVIRONMENT_VARIABLE with MPI

bpichon
Beginner
862 Views

Dear Fortran !!

In the following (a hello world kind) program, I try to read the processor's name where images are running.

Each process can read the processor's name with a EXECUTE_COMMAND_LINE("echo $HOSTNAME")

but with GET_ENVIRONMENT_VARIABLE(...), nothing is read (ios /=0)

Note that a single image works well  (mpiexec.hydra -genvuser ./Hello_world_mpi.exe  is Ok)

Executable is made with :

ifort -I/softs/intel/impi/5.0.1.035/intel64/include/ Hello_world_mpi.f90 -o Hello_world_mpi.exe -L/softs/intel/impi/5.0.1.035/intel64/l
ib/ -lmpifort -lmpi

We have ifort 15.0.0 and mpi 5.0 (as shown above)

We use mpiexec.hydra with OAR

Bernard

==========================   source code ==============================

Program WHERE_I_AM
   USE mpi
   USE ISO_FORTRAN_ENV, Only: Output => Output_unit
   Implicit None
   Integer :: nb_procs, rank, code, ios = 1
   Character(Len=20) :: env_name, env_value
   !
   Call MPI_INIT(code)
   Call MPI_COMM_SIZE ( MPI_COMM_WORLD , nb_procs , code )
   Call MPI_COMM_RANK ( MPI_COMM_WORLD , rank , code )
   !
   env_name = "HOSTNAME"
   !
   Call EXECUTE_COMMAND_LINE("echo $"//TRIM(env_name))
   !
   Call GET_ENVIRONMENT_VARIABLE(TRIM(env_name),env_value,status=ios)
   If ( ios /= 0 ) Then
      Write(Output,*) "I am the processor WITHOUT NAME number ", rank, " among ", nb_procs
   Else
      Write(Output,"(A,A,A,I2,A,I2)") "I am the processor with name ", TRIM(env_value), "   with rank ", rank, "  among ", nb_procs
   End If
   !
   call MPI_FINALIZE (code)
   STOP " Done !! "
   !
End Program WHERE_I_AM

=========================== an example of bad output ==================================

Note : Images are running on nodes n024, n024, n044 and n048 (4 nodes=

n044
n024
n044
 I am the processor WITHOUT NAME number           29  among           49
 I am the processor WITHOUT NAME number           37  among           49
 I am the processor WITHOUT NAME number           38  among           49
n048
n048
n048
n048
n048
n048
 I am the processor WITHOUT NAME number           26  among           49
 I am the processor WITHOUT NAME number           30  among           49
 I am the processor WITHOUT NAME number           44  among           49
 I am the processor WITHOUT NAME number           25  among           49
n024
 I am the processor WITHOUT NAME number           48  among           49
 I am the processor WITHOUT NAME number           46  among           49
 I am the processor WITHOUT NAME number           47  among           49
 I am the processor WITHOUT NAME number           45  among           49
n010
 I am the processor WITHOUT NAME number           43  among           49
n024
n024
 I am the processor WITHOUT NAME number           17  among           49
 I am the processor WITHOUT NAME number           18  among           49
 I am the processor WITHOUT NAME number           16  among           49
n024
 I am the processor WITHOUT NAME number           28  among           49
n024
 I am the processor WITHOUT NAME number           35  among           49
n024
 

 

0 Kudos
5 Replies
Steven_L_Intel1
Employee
862 Views

It would be helpful if you also wrote out the value of ios after the failed call.

0 Kudos
bpichon
Beginner
862 Views

ios = 1

0 Kudos
jimdempseyatthecove
Honored Contributor III
862 Views

Pick one of the processors with no name, for that processor, issue the command line to list the entire set of environment variables. It appears as if that host has no environment variable "HOSTNAME" that is findable with GET_ENVIRONMENT_VARIABLE.

It may be helpful to also pick one of the processors with name, and list all the environment variables too.

*** do this from your broken MPI test program ***

Something may show up. (e.g. case sensitive or space/tab in name). Before you claim "not supposed to be different", run the test to see if there is a difference. Then either fix the difference or grip about "not supposed to be different" to whomever you think will resolve your issue.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
862 Views

A value of 1 means that the environment variable doesn't exist.

0 Kudos
Steven_L_Intel1
Employee
862 Views

This would seem to be an MPICH variable. Intel MPI is MPICH2-compatible. See https://github.com/ParaStation/psmpi2/blob/master/mpich2/README.envvar for a list of the environment variables in MPICH2.

0 Kudos
Reply