[775] | 1 | ! |
---|
| 2 | !$Header$ |
---|
| 3 | ! |
---|
| 4 | MODULE mod_phys_lmdz_para |
---|
| 5 | USE mod_phys_lmdz_transfert_para |
---|
| 6 | USE mod_phys_lmdz_mpi_data |
---|
| 7 | USE mod_phys_lmdz_omp_data |
---|
| 8 | |
---|
| 9 | INTEGER,SAVE :: klon_loc |
---|
| 10 | LOGICAL,SAVE :: is_sequential |
---|
| 11 | LOGICAL,SAVE :: is_parallel |
---|
[1327] | 12 | LOGICAL,SAVE :: is_master |
---|
[775] | 13 | |
---|
[1327] | 14 | !$OMP THREADPRIVATE(klon_loc,is_master) |
---|
[775] | 15 | |
---|
| 16 | CONTAINS |
---|
| 17 | |
---|
| 18 | SUBROUTINE Init_phys_lmdz_para(iim,jjp1,nb_proc,distrib) |
---|
| 19 | IMPLICIT NONE |
---|
| 20 | INTEGER,INTENT(in) :: iim |
---|
| 21 | INTEGER,INTENT(in) :: jjp1 |
---|
| 22 | INTEGER,INTENT(in) :: nb_proc |
---|
| 23 | INTEGER,INTENT(in) :: distrib(0:nb_proc-1) |
---|
| 24 | |
---|
| 25 | CALL Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib) |
---|
| 26 | !$OMP PARALLEL |
---|
| 27 | CALL Init_phys_lmdz_omp_data(klon_mpi) |
---|
| 28 | klon_loc=klon_omp |
---|
[1327] | 29 | IF (is_mpi_root .AND. is_omp_root) THEN |
---|
| 30 | is_master=.TRUE. |
---|
| 31 | ELSE |
---|
| 32 | is_master=.FALSE. |
---|
| 33 | ENDIF |
---|
[1864] | 34 | CALL Test_transfert |
---|
[775] | 35 | !$OMP END PARALLEL |
---|
[1001] | 36 | IF (is_using_mpi .OR. is_using_omp) THEN |
---|
[775] | 37 | is_sequential=.FALSE. |
---|
| 38 | is_parallel=.TRUE. |
---|
| 39 | ELSE |
---|
| 40 | is_sequential=.TRUE. |
---|
| 41 | is_parallel=.FALSE. |
---|
| 42 | ENDIF |
---|
[1327] | 43 | |
---|
[775] | 44 | END SUBROUTINE Init_phys_lmdz_para |
---|
| 45 | |
---|
| 46 | SUBROUTINE Test_transfert |
---|
| 47 | USE mod_grid_phy_lmdz |
---|
| 48 | IMPLICIT NONE |
---|
[1664] | 49 | INCLUDE "iniprint.h" |
---|
| 50 | |
---|
[775] | 51 | REAL :: Test_Field1d_glo(klon_glo,nbp_lev) |
---|
| 52 | REAL :: tmp1d_glo(klon_glo,nbp_lev) |
---|
| 53 | REAL :: Test_Field2d_glo(nbp_lon,nbp_lat,nbp_lev) |
---|
| 54 | REAL :: tmp2d_glo(nbp_lon,nbp_lat,nbp_lev) |
---|
| 55 | REAL :: Test_Field1d_loc(klon_loc,nbp_lev) |
---|
| 56 | REAL :: Test_Field2d_loc(nbp_lon,jj_nb,nbp_lev) |
---|
| 57 | REAL :: CheckSum |
---|
| 58 | |
---|
| 59 | INTEGER :: i,l |
---|
| 60 | |
---|
| 61 | Test_Field1d_glo = 0. |
---|
| 62 | Test_Field2d_glo = 0. |
---|
| 63 | Test_Field1d_loc = 0. |
---|
| 64 | Test_Field2d_loc = 0. |
---|
| 65 | |
---|
| 66 | IF (is_mpi_root) THEN |
---|
| 67 | !$OMP MASTER |
---|
| 68 | DO l=1,nbp_lev |
---|
| 69 | DO i=1,klon_glo |
---|
| 70 | ! Test_Field1d_glo(i,l)=MOD(i,10)+10*(l-1) |
---|
| 71 | Test_Field1d_glo(i,l)=1 |
---|
| 72 | ENDDO |
---|
| 73 | ENDDO |
---|
| 74 | !$OMP END MASTER |
---|
| 75 | ENDIF |
---|
| 76 | |
---|
| 77 | CALL Scatter(Test_Field1d_glo,Test_Field1d_loc) |
---|
| 78 | CALL Gather(Test_Field1d_loc,tmp1d_glo) |
---|
| 79 | |
---|
| 80 | IF (is_mpi_root) THEN |
---|
| 81 | !$OMP MASTER |
---|
| 82 | Checksum=sum(Test_Field1d_glo-tmp1d_glo) |
---|
[1664] | 83 | WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
[775] | 84 | !$OMP END MASTER |
---|
| 85 | ENDIF |
---|
| 86 | |
---|
| 87 | CALL grid1dTo2d_glo(Test_Field1d_glo,Test_Field2d_glo) |
---|
| 88 | CALL scatter2D(Test_Field2d_glo,Test_Field1d_loc) |
---|
| 89 | CALL gather2d(Test_Field1d_loc,Test_Field2d_glo) |
---|
| 90 | CALL grid2dTo1d_glo(Test_Field2d_glo,tmp1d_glo) |
---|
| 91 | |
---|
| 92 | IF (is_mpi_root) THEN |
---|
| 93 | !$OMP MASTER |
---|
| 94 | Checksum=sum(Test_Field1d_glo-tmp1d_glo) |
---|
[1664] | 95 | WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
[775] | 96 | !$OMP END MASTER |
---|
| 97 | ENDIF |
---|
| 98 | |
---|
| 99 | CALL bcast(Test_Field1d_glo) |
---|
| 100 | CALL reduce_sum(Test_Field1d_glo,tmp1d_glo) |
---|
| 101 | |
---|
| 102 | IF (is_mpi_root) THEN |
---|
| 103 | !$OMP MASTER |
---|
| 104 | Checksum=sum(Test_Field1d_glo*omp_size*mpi_size-tmp1d_glo) |
---|
[1664] | 105 | WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
[775] | 106 | !$OMP END MASTER |
---|
| 107 | ENDIF |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | END SUBROUTINE Test_transfert |
---|
| 111 | |
---|
| 112 | END MODULE mod_phys_lmdz_para |
---|
| 113 | |
---|