Ceci est une ancienne révision du document !
déplacer dans tutoriels
https://www.psmn.ens-lyon.fr/tikiwiki4/tiki-index.php?page=Pour%20compiler&bl=y
+ https://www.psmn.ens-lyon.fr/tikiwiki4/tiki-index.php?page=ExFortran90gnu&bl=y
+ https://www.psmn.ens-lyon.fr/tikiwiki4/tiki-index.php?page=ExCgnu&bl=y
Le programme SommeVecVec.f90 effectue la somme des deux vecteurs A et B. Le résultat est mis dans C.
$ source /usr/local/modeles/gnu-4.6.3 $ gfortran --version GNU Fortran (GCC) 4.6.3 $ gfortran -o SommeVecVec.f90.exe SommeVecVec.f90
Le fichier binaire (exécutable) SommeVecVec.f90.exe
a été généré.
$ ./SommeVecVec.f90.exe
Le résultat est affiché a l'écran :
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 Le vecteur somme : C = 10 10 10 10 10 10 10 10 10 10
Il y a un script de soumission (batch.csh) et un script d'exécution (batchrun.csh) ou batch.sh et batchrun.sh, pour le shell bash.
C'est le script de soumission qui doit être lancé et c'est lui qui appelle le script d'exécution.
batch.csh → batchrun.csh → binaire
$ ./batch.csh Your job 769504 ("batchrun.csh") has been submitted $ qstat job-ID prior name user state submit/start at queue slots ja-task-ID ----------------------------------------------------------------------------------------------------------------- 769504 0.00000 batchrun.csh cicaluga qw 06/12/2012 07:21:46
batchrun.csh.o769504
batchrun.csh.e769504
$ cat batchrun.csh.o769504 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 Le vecteur somme : C = 10 10 10 10 10 10 10 10 10 10
Le programme SommeVecVecPAR.f90 effectue la somme des deux vecteurs A et B. Le résultat est mis dans C. Chaque étape est effectuée sur 2 processus. Si le programme est exécuté sur plusieurs cœurs, seuls deux cœurs seront réellement utilisés.
$ source /usr/local/modeles/openmpi-1.4.5-gnu-4.6.3 $ mpif90 -showme gfortran -I/softs/openmpi-1.4.5-gcc-4.6.3/include -pthread -I/softs/openmpi-1.4.5-gcc-4.6.3/lib -L/softs/openmpi-1.4.5-gcc-4.6.3/lib -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -lrdmacm -libverbs -ldl -lnsl -lutil -lm $ mpif90 -o SommeVecVec.exe SommeVecVec.f90
Le fichier binaire (exécutable) SommeVecVec.exe
a été généré.
$ mpirun -np 2 ./SommeVecVec.exe
Le résultat est affiché a l'écran :
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
Il y a un script de soumission (batch.csh) et un script d'exécution (batchrun.csh).
C'est le script de soumission qui doit être lancé et c'est lui qui appelle le script d'exécution.
batch → batchrun → binaire
$ ./batch Your job 772030 ("batchrun") has been submitted
$ qstat job-ID prior name user state submit/start at queue slots ja-task-ID ----------------------------------------------------------------------------------------------------------------- 772030 0.00000 batchrun cicaluga qw 06/18/2012 07:41:51 2 $ qstat job-ID prior name user state submit/start at queue slots ja-task-ID ----------------------------------------------------------------------------------------------------------------- 772030 0.05000 batchrun cicaluga r 06/18/2012 07:42:16 r410B_ib_test@r410lin57.ens-ly 2
La sortie de l'écran (sortie standard) est redirigée dans le fichier batchrun.o772030
et la sortie erreur est redirigée dans le fichier batchrun.e772030
.
$ cat batchrun.o772030 /home/cicaluga/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