Compilation and execution of a program (Fortran 90)

Fortran 90 language, parallel code (MPI)

The program SommeVecVecPAR.f90 performs the sum of the two vectors A and B. The result is put in C. Each step is performed on 2 processes. If the program runs on multiple cores, only two cores will actually be used.

Compilation of a program :

Definition of the environment : :

  • definition of the environment :
module avail
module load GCC/7.2.0/OpenMPI/3.0.0 
  • checking
mpifort -showme

gfortran .....

Compilation :

mpifort -o SommeVecVecPAR.exe SommeVecVecPAR.f90 

The binary file (executable) SommeVecVecPAR.exe has been generated.

Execution of the program:

Running on the build server:

mpirun -np 2 ./SommeVecVecPAR.exe

The result is displayed on the screen:

LES DEUX VECTEURS :
A =            1           2           3           4           5           6           7           8           9          10
B =            9           8           7           6           5           4           3           2           1           0

LES DEUX VECTEURS LOCAUX :
Je suis le proc            0 parmi            2  processus
A local ( proc            0  )  =            1           2           3           4           5
B local ( proc            0  )  =            9           8           7           6           5
Je suis le proc            1 parmi            2  processus
A local ( proc            1  )  =            6           7           8           9          10
B local ( proc            1  )  =            4           3           2           1           0
LE VECTEUR SOMME LOCAL : 
C local ( proc            1  )  =           10          10          10          10          10
C local ( proc            0  )  =           10          10          10          10          10
LE VECTEUR SOMME :
C =           10          10          10          10          10          10          10          10          10          10

Running on the cluster:

We use a submission script batch.sh to submit the job on compute clusters.

It is the submission script that configures the environment and then calls your binary (with its options, if any) on the execution node.

SGE → batch.sh → binaire

qsub batch.sh
Your job 336000 ("SommeVecVecPAR") has been submitted
qstat

job-ID  prior   name             user         state submit/start at     queue                          slots ja-task-ID 
-----------------------------------------------------------------------------------------------------------------
336000 0.00000 SommeVecVecPAR   Login     qw    02/14/2018 10:53:51                                    2        

qstat

job-ID  prior   name             user         state submit/start at     queue                          slots ja-task-ID 
-----------------------------------------------------------------------------------------------------------------
336000 0.05000 SommeVecVecPAR   Login     r     02/14/2018 10:54:16 r410B_ib_test@r410lin57.ens-ly     2 

The output of the screen (standard output) is redirected to the file SommeVecVecPAR.o336000 The error output (standard error) is redirected to the file SommeVecVecPAR.e336000.

cat SommeVecVecPAR.o336000

/home/ccalugar/Support/FormationPSMN/SommeVecVecPar
 LES DEUX VECTEURS :
 A =            1           2           3           4           5           6           7           8           9          10
 B =            9           8           7           6           5           4           3           2           1           0
 LES DEUX VECTEURS LOCAUX :
 Je suis le proc            0 parmi            2  processus
 A local ( proc            0  )  =            1           2           3           4           5
 B local ( proc            0  )  =            9           8           7           6           5
 LE VECTEUR SOMME LOCAL : 
 C local ( proc            0  )  =           10          10          10          10          10
LE VECTEUR SOMME :
 C =           10          10          10          10          10          10          10          10          10          10
 Je suis le proc            1 parmi            2  processus
 A local ( proc            1  )  =            6           7           8           9          10
 B local ( proc            1  )  =            4           3           2           1           0
 C local ( proc            1  )  =           10          10          10          10          10
en/documentation/tutorials/build/fortran_parallele.txt · Dernière modification: 2018/11/20 11:55 par cicaluga