Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
documentation:examples:sommevecvecpar.f90 [2020/08/25 15:58] – modification externe 127.0.0.1documentation:examples:sommevecvecpar.f90 [2023/01/13 09:37] (Version actuelle) – supprimée ccalugar
Ligne 1: Ligne 1:
-<code fortran SommeVecVecPAR.f90> 
-program Somme 
-implicit none 
-include 'mpif.h' 
  
-integer, dimension( MPI_STATUS_SIZE ) :: statut 
-integer, parameter :: etiquette=100 
- 
-integer :: A(10),B(10),C(10),Aloc(5),Bloc(5),Cloc(5) 
-integer :: i 
-integer :: nb_procs,rang,code 
- 
-call MPI_INIT(code) 
- 
-call MPI_COMM_SIZE(MPI_COMM_WORLD,nb_procs,code) 
-call MPI_COMM_RANK(MPI_COMM_WORLD,rang,code) 
- 
-if (rang .eq. 0) then 
-   do i=1,10 
-     A(i) = i 
-     B(i) = 10 - i 
-   enddo 
- 
-   write ( *, * ) 'LES DEUX VECTEURS :' 
- 
-   write (*,*) 'A = ',(A(i),i=1,10) 
-   write (*,*) 'B = ',(B(i),i=1,10) 
-endif 
- 
-call MPI_BARRIER ( MPI_COMM_WORLD ,code) 
- 
-if (rang .eq. 0) then 
-  call MPI_SEND (A(1:5),5, MPI_INTEGER ,0,etiquette, MPI_COMM_WORLD,code) 
-  call MPI_SEND (A(6:10),5, MPI_INTEGER ,1,etiquette, MPI_COMM_WORLD,code) 
-  call MPI_SEND (B(1:5),5, MPI_INTEGER ,0,etiquette+1, MPI_COMM_WORLD,code) 
-  call MPI_SEND (B(6:10),5, MPI_INTEGER ,1,etiquette+1, MPI_COMM_WORLD,code) 
-endif 
- 
-call MPI_RECV (Aloc,5, MPI_INTEGER ,0,etiquette, MPI_COMM_WORLD,statut,code) 
-call MPI_RECV (Bloc,5, MPI_INTEGER ,0,etiquette+1, MPI_COMM_WORLD,statut,code) 
- 
-call MPI_BARRIER ( MPI_COMM_WORLD ,code) 
-if (rang .eq. 0) then 
-   write ( *, * ) 'LES DEUX VECTEURS LOCAUX :' 
-endif 
- 
- 
-print *,'Je suis le proc ',rang,'parmi ',nb_procs,' processus' 
-write (*,*) 'A local ( proc ',rang,' )  = ',(Aloc(i),i=1,5) 
-write (*,*) 'B local ( proc ',rang,' )  = ',(Bloc(i),i=1,5) 
- 
-call MPI_BARRIER ( MPI_COMM_WORLD ,code) 
-do i=1,5 
-      Cloc(i) = Aloc(i) + Bloc(i) 
-enddo 
- 
-if (rang .eq. 0) then 
-   write ( *, * ) 'LE VECTEUR SOMME LOCAL : ' 
-endif 
- 
-call MPI_BARRIER ( MPI_COMM_WORLD ,code) 
- 
-write (*,*) 'C local ( proc ',rang,' )  = ',(Cloc(i),i=1,5) 
- 
-call MPI_BARRIER ( MPI_COMM_WORLD ,code) 
- 
-call MPI_SEND (Cloc(1:5),5, MPI_INTEGER ,0,etiquette, MPI_COMM_WORLD,code) 
- 
-if (rang .eq. 0) then 
-  call MPI_RECV (C(1:5),5, MPI_INTEGER ,0,etiquette, MPI_COMM_WORLD,statut,code) 
-  call MPI_RECV (C(6:10),5, MPI_INTEGER ,1,etiquette, MPI_COMM_WORLD,statut,code) 
-endif 
- 
-if (rang .eq. 0) then 
-   write ( *, * ) 'LE VECTEUR SOMME :' 
-   write (*,*) 'C = ',(C(i),i=1,10) 
-endif 
- 
- 
-call MPI_FINALIZE(code) 
- 
-end program 
-</code> 
documentation/examples/sommevecvecpar.f90.1598371112.txt.gz · Dernière modification : 2020/08/25 15:58 de 127.0.0.1