Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
documentation:examples:sommevecvecparopenmp.f90 [2017/01/23 10:24] – ltaulell | documentation:examples:sommevecvecparopenmp.f90 [2020/08/25 15:58] – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ===== Langage Fortran 90, code parallèle (avec OpenMP) ===== | ||
+ | |||
+ | Le programme [[documentation: | ||
+ | |||
<code fortran ProgPAR_OpenMP.f90> | <code fortran ProgPAR_OpenMP.f90> | ||
- | PROGRAM | + | program |
- | INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS, | + | INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS, |
- | | + | |
- | C Fork a team of threads giving them their own copies of variables | + | ! Fork a team of threads giving them their own copies of variables |
!$OMP PARALLEL PRIVATE(NTHREADS, | !$OMP PARALLEL PRIVATE(NTHREADS, | ||
- | + | ||
- | + | ||
- | C Obtain thread number | + | ! Obtain thread number |
TID = OMP_GET_THREAD_NUM() | TID = OMP_GET_THREAD_NUM() | ||
PRINT *, 'Hello World from thread = ', TID | PRINT *, 'Hello World from thread = ', TID | ||
- | + | ||
- | C Only master thread does this | + | ! Only master thread does this |
IF (TID .EQ. 0) THEN | IF (TID .EQ. 0) THEN | ||
NTHREADS = OMP_GET_NUM_THREADS() | NTHREADS = OMP_GET_NUM_THREADS() | ||
PRINT *, ' | PRINT *, ' | ||
END IF | END IF | ||
- | + | ||
- | C All threads join master thread and disband | + | ! All threads join master thread and disband |
!$OMP END PARALLEL | !$OMP END PARALLEL | ||
- | END | + | end program |
</ | </ |