[775] | 1 | ! |
---|
[2429] | 2 | ! $Id: mod_phys_lmdz_para.F90 4127 2022-04-20 09:01:09Z evignon $ |
---|
[775] | 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 |
---|
[2429] | 13 | |
---|
[775] | 14 | |
---|
[1327] | 15 | !$OMP THREADPRIVATE(klon_loc,is_master) |
---|
[775] | 16 | |
---|
| 17 | CONTAINS |
---|
| 18 | |
---|
[4127] | 19 | SUBROUTINE Init_phys_lmdz_para(nbp,nbp_lon,nbp_lat,nbp_lev,grid_type, nvertex,communicator) |
---|
[775] | 20 | IMPLICIT NONE |
---|
[2351] | 21 | INTEGER,INTENT(in) :: nbp |
---|
| 22 | INTEGER,INTENT(in) :: nbp_lon |
---|
| 23 | INTEGER,INTENT(in) :: nbp_lat |
---|
[4127] | 24 | INTEGER,INTENT(in) :: nbp_lev |
---|
[2351] | 25 | INTEGER,INTENT(in) :: communicator |
---|
[4127] | 26 | INTEGER,INTENT(IN) :: grid_type |
---|
| 27 | INTEGER,INTENT(IN) :: nvertex |
---|
[775] | 28 | |
---|
[4127] | 29 | CALL Init_phys_lmdz_mpi_data(nbp,nbp_lon,nbp_lat,nbp_lev, grid_type, nvertex,communicator) |
---|
[775] | 30 | !$OMP PARALLEL |
---|
| 31 | CALL Init_phys_lmdz_omp_data(klon_mpi) |
---|
| 32 | klon_loc=klon_omp |
---|
[1327] | 33 | IF (is_mpi_root .AND. is_omp_root) THEN |
---|
| 34 | is_master=.TRUE. |
---|
| 35 | ELSE |
---|
| 36 | is_master=.FALSE. |
---|
| 37 | ENDIF |
---|
[3465] | 38 | !ym CALL Test_transfert |
---|
[775] | 39 | !$OMP END PARALLEL |
---|
[1001] | 40 | IF (is_using_mpi .OR. is_using_omp) THEN |
---|
[775] | 41 | is_sequential=.FALSE. |
---|
| 42 | is_parallel=.TRUE. |
---|
| 43 | ELSE |
---|
| 44 | is_sequential=.TRUE. |
---|
| 45 | is_parallel=.FALSE. |
---|
| 46 | ENDIF |
---|
[2429] | 47 | |
---|
| 48 | |
---|
[1327] | 49 | |
---|
[775] | 50 | END SUBROUTINE Init_phys_lmdz_para |
---|
| 51 | |
---|
| 52 | SUBROUTINE Test_transfert |
---|
| 53 | USE mod_grid_phy_lmdz |
---|
[3435] | 54 | USE print_control_mod, ONLY: lunout |
---|
[775] | 55 | IMPLICIT NONE |
---|
[3435] | 56 | ! INCLUDE "iniprint.h" |
---|
[1575] | 57 | |
---|
[775] | 58 | REAL :: Test_Field1d_glo(klon_glo,nbp_lev) |
---|
| 59 | REAL :: tmp1d_glo(klon_glo,nbp_lev) |
---|
| 60 | REAL :: Test_Field2d_glo(nbp_lon,nbp_lat,nbp_lev) |
---|
| 61 | REAL :: tmp2d_glo(nbp_lon,nbp_lat,nbp_lev) |
---|
| 62 | REAL :: Test_Field1d_loc(klon_loc,nbp_lev) |
---|
| 63 | REAL :: Test_Field2d_loc(nbp_lon,jj_nb,nbp_lev) |
---|
| 64 | REAL :: CheckSum |
---|
| 65 | |
---|
| 66 | INTEGER :: i,l |
---|
| 67 | |
---|
| 68 | Test_Field1d_glo = 0. |
---|
| 69 | Test_Field2d_glo = 0. |
---|
| 70 | Test_Field1d_loc = 0. |
---|
| 71 | Test_Field2d_loc = 0. |
---|
| 72 | |
---|
| 73 | IF (is_mpi_root) THEN |
---|
| 74 | !$OMP MASTER |
---|
| 75 | DO l=1,nbp_lev |
---|
| 76 | DO i=1,klon_glo |
---|
| 77 | ! Test_Field1d_glo(i,l)=MOD(i,10)+10*(l-1) |
---|
| 78 | Test_Field1d_glo(i,l)=1 |
---|
| 79 | ENDDO |
---|
| 80 | ENDDO |
---|
| 81 | !$OMP END MASTER |
---|
| 82 | ENDIF |
---|
| 83 | |
---|
| 84 | CALL Scatter(Test_Field1d_glo,Test_Field1d_loc) |
---|
| 85 | CALL Gather(Test_Field1d_loc,tmp1d_glo) |
---|
| 86 | |
---|
| 87 | IF (is_mpi_root) THEN |
---|
| 88 | !$OMP MASTER |
---|
| 89 | Checksum=sum(Test_Field1d_glo-tmp1d_glo) |
---|
[1575] | 90 | WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
[775] | 91 | !$OMP END MASTER |
---|
| 92 | ENDIF |
---|
| 93 | |
---|
| 94 | CALL grid1dTo2d_glo(Test_Field1d_glo,Test_Field2d_glo) |
---|
| 95 | CALL scatter2D(Test_Field2d_glo,Test_Field1d_loc) |
---|
| 96 | CALL gather2d(Test_Field1d_loc,Test_Field2d_glo) |
---|
| 97 | CALL grid2dTo1d_glo(Test_Field2d_glo,tmp1d_glo) |
---|
| 98 | |
---|
| 99 | IF (is_mpi_root) THEN |
---|
| 100 | !$OMP MASTER |
---|
| 101 | Checksum=sum(Test_Field1d_glo-tmp1d_glo) |
---|
[1575] | 102 | WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
[775] | 103 | !$OMP END MASTER |
---|
| 104 | ENDIF |
---|
| 105 | |
---|
| 106 | CALL bcast(Test_Field1d_glo) |
---|
| 107 | CALL reduce_sum(Test_Field1d_glo,tmp1d_glo) |
---|
| 108 | |
---|
| 109 | IF (is_mpi_root) THEN |
---|
| 110 | !$OMP MASTER |
---|
| 111 | Checksum=sum(Test_Field1d_glo*omp_size*mpi_size-tmp1d_glo) |
---|
[1575] | 112 | WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
[775] | 113 | !$OMP END MASTER |
---|
| 114 | ENDIF |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | END SUBROUTINE Test_transfert |
---|
| 118 | |
---|
| 119 | END MODULE mod_phys_lmdz_para |
---|
| 120 | |
---|