[892] | 1 | ! |
---|
[1572] | 2 | !$Id$ |
---|
[892] | 3 | ! |
---|
| 4 | MODULE mod_phys_lmdz_mpi_data |
---|
| 5 | |
---|
| 6 | INTEGER,SAVE :: ii_begin |
---|
| 7 | INTEGER,SAVE :: ii_end |
---|
| 8 | INTEGER,SAVE :: jj_begin |
---|
| 9 | INTEGER,SAVE :: jj_end |
---|
| 10 | INTEGER,SAVE :: jj_nb |
---|
| 11 | INTEGER,SAVE :: ij_begin |
---|
| 12 | INTEGER,SAVE :: ij_end |
---|
| 13 | INTEGER,SAVE :: ij_nb |
---|
| 14 | INTEGER,SAVE :: klon_mpi_begin |
---|
| 15 | INTEGER,SAVE :: klon_mpi_end |
---|
| 16 | INTEGER,SAVE :: klon_mpi |
---|
| 17 | |
---|
| 18 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb |
---|
| 19 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin |
---|
| 20 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end |
---|
| 21 | |
---|
| 22 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin |
---|
| 23 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end |
---|
| 24 | |
---|
| 25 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb |
---|
| 26 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin |
---|
| 27 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end |
---|
| 28 | |
---|
| 29 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_nb |
---|
| 30 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin |
---|
| 31 | INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | INTEGER,SAVE :: mpi_rank |
---|
| 35 | INTEGER,SAVE :: mpi_size |
---|
[1543] | 36 | INTEGER,SAVE :: mpi_master |
---|
[892] | 37 | LOGICAL,SAVE :: is_mpi_root |
---|
| 38 | LOGICAL,SAVE :: is_using_mpi |
---|
| 39 | |
---|
| 40 | |
---|
[1572] | 41 | LOGICAL,SAVE :: is_north_pole_dyn |
---|
| 42 | LOGICAL,SAVE :: is_south_pole_dyn |
---|
[892] | 43 | INTEGER,SAVE :: COMM_LMDZ_PHY |
---|
[1543] | 44 | INTEGER,SAVE :: MPI_REAL_LMDZ ! MPI_REAL8 |
---|
[892] | 45 | |
---|
| 46 | CONTAINS |
---|
| 47 | |
---|
[1543] | 48 | SUBROUTINE init_phys_lmdz_mpi_data(nbp, nbp_lon, nbp_lat, communicator) |
---|
[892] | 49 | IMPLICIT NONE |
---|
[1543] | 50 | #ifdef CPP_MPI |
---|
| 51 | INCLUDE 'mpif.h' |
---|
| 52 | #endif |
---|
[1682] | 53 | INTEGER,INTENT(IN) :: nbp |
---|
| 54 | INTEGER,INTENT(IN) :: nbp_lon |
---|
| 55 | INTEGER,INTENT(IN) :: nbp_lat |
---|
| 56 | INTEGER,INTENT(IN) :: communicator |
---|
[892] | 57 | |
---|
[1543] | 58 | INTEGER,ALLOCATABLE :: distrib(:) |
---|
[892] | 59 | INTEGER :: ierr |
---|
| 60 | INTEGER :: klon_glo |
---|
| 61 | INTEGER :: i |
---|
| 62 | |
---|
| 63 | #ifdef CPP_MPI |
---|
| 64 | is_using_mpi=.TRUE. |
---|
| 65 | #else |
---|
| 66 | is_using_mpi=.FALSE. |
---|
| 67 | #endif |
---|
| 68 | |
---|
[1543] | 69 | if ((nbp_lon.eq.1).and.(nbp_lat.eq.1)) then ! running 1D column model |
---|
[892] | 70 | klon_glo=1 |
---|
| 71 | else |
---|
[1543] | 72 | ! The usual global physics grid: 1 point for each pole and nbp_lon points |
---|
| 73 | ! for all other latitudes |
---|
| 74 | klon_glo=nbp_lon*(nbp_lat-2)+2 |
---|
[892] | 75 | endif |
---|
| 76 | |
---|
[1543] | 77 | COMM_LMDZ_PHY=communicator |
---|
[892] | 78 | |
---|
| 79 | IF (is_using_mpi) THEN |
---|
| 80 | #ifdef CPP_MPI |
---|
[1543] | 81 | MPI_REAL_LMDZ=MPI_REAL8 |
---|
[892] | 82 | CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr) |
---|
| 83 | CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr) |
---|
| 84 | #endif |
---|
| 85 | ELSE |
---|
| 86 | mpi_size=1 |
---|
| 87 | mpi_rank=0 |
---|
| 88 | ENDIF |
---|
| 89 | |
---|
[1543] | 90 | ALLOCATE(distrib(0:mpi_size-1)) |
---|
| 91 | |
---|
| 92 | IF (is_using_mpi) THEN |
---|
| 93 | #ifdef CPP_MPI |
---|
| 94 | CALL MPI_ALLGATHER(nbp,1,MPI_INTEGER,distrib,1,MPI_INTEGER,COMM_LMDZ_PHY,ierr) |
---|
| 95 | #endif |
---|
| 96 | ELSE |
---|
| 97 | distrib(:)=nbp |
---|
| 98 | ENDIF |
---|
| 99 | |
---|
| 100 | |
---|
[892] | 101 | IF (mpi_rank == 0) THEN |
---|
[1543] | 102 | mpi_master = 0 |
---|
[892] | 103 | is_mpi_root = .true. |
---|
| 104 | ENDIF |
---|
| 105 | |
---|
| 106 | IF (mpi_rank == 0) THEN |
---|
[1572] | 107 | is_north_pole_dyn = .TRUE. |
---|
[892] | 108 | ELSE |
---|
[1572] | 109 | is_north_pole_dyn = .FALSE. |
---|
[892] | 110 | ENDIF |
---|
| 111 | |
---|
| 112 | IF (mpi_rank == mpi_size-1) THEN |
---|
[1572] | 113 | is_south_pole_dyn = .TRUE. |
---|
[892] | 114 | ELSE |
---|
[1572] | 115 | is_south_pole_dyn = .FALSE. |
---|
[892] | 116 | ENDIF |
---|
| 117 | |
---|
| 118 | ALLOCATE(jj_para_nb(0:mpi_size-1)) |
---|
| 119 | ALLOCATE(jj_para_begin(0:mpi_size-1)) |
---|
| 120 | ALLOCATE(jj_para_end(0:mpi_size-1)) |
---|
| 121 | |
---|
| 122 | ALLOCATE(ij_para_nb(0:mpi_size-1)) |
---|
| 123 | ALLOCATE(ij_para_begin(0:mpi_size-1)) |
---|
| 124 | ALLOCATE(ij_para_end(0:mpi_size-1)) |
---|
| 125 | |
---|
| 126 | ALLOCATE(ii_para_begin(0:mpi_size-1)) |
---|
| 127 | ALLOCATE(ii_para_end(0:mpi_size-1)) |
---|
| 128 | |
---|
| 129 | ALLOCATE(klon_mpi_para_nb(0:mpi_size-1)) |
---|
| 130 | ALLOCATE(klon_mpi_para_begin(0:mpi_size-1)) |
---|
| 131 | ALLOCATE(klon_mpi_para_end(0:mpi_size-1)) |
---|
| 132 | |
---|
| 133 | |
---|
[1543] | 134 | klon_mpi_para_nb(0:mpi_size-1)=distrib(0:mpi_size-1) |
---|
[892] | 135 | |
---|
| 136 | DO i=0,mpi_size-1 |
---|
| 137 | IF (i==0) THEN |
---|
| 138 | klon_mpi_para_begin(i)=1 |
---|
| 139 | ELSE |
---|
| 140 | klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1 |
---|
| 141 | ENDIF |
---|
| 142 | klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1 |
---|
| 143 | ENDDO |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | DO i=0,mpi_size-1 |
---|
| 147 | |
---|
| 148 | IF (i==0) THEN |
---|
| 149 | ij_para_begin(i) = 1 |
---|
| 150 | ELSE |
---|
[1543] | 151 | ij_para_begin(i) = klon_mpi_para_begin(i)+nbp_lon-1 |
---|
[892] | 152 | ENDIF |
---|
| 153 | |
---|
[1543] | 154 | jj_para_begin(i) = (ij_para_begin(i)-1)/nbp_lon + 1 |
---|
| 155 | ii_para_begin(i) = MOD(ij_para_begin(i)-1,nbp_lon) + 1 |
---|
[892] | 156 | |
---|
| 157 | |
---|
[1543] | 158 | ij_para_end(i) = klon_mpi_para_end(i)+nbp_lon-1 |
---|
| 159 | jj_para_end(i) = (ij_para_end(i)-1)/nbp_lon + 1 |
---|
| 160 | ii_para_end(i) = MOD(ij_para_end(i)-1,nbp_lon) + 1 |
---|
[892] | 161 | |
---|
| 162 | |
---|
| 163 | ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1 |
---|
| 164 | jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1 |
---|
| 165 | |
---|
| 166 | ENDDO |
---|
| 167 | |
---|
| 168 | ii_begin = ii_para_begin(mpi_rank) |
---|
| 169 | ii_end = ii_para_end(mpi_rank) |
---|
| 170 | jj_begin = jj_para_begin(mpi_rank) |
---|
| 171 | jj_end = jj_para_end(mpi_rank) |
---|
| 172 | jj_nb = jj_para_nb(mpi_rank) |
---|
| 173 | ij_begin = ij_para_begin(mpi_rank) |
---|
| 174 | ij_end = ij_para_end(mpi_rank) |
---|
| 175 | ij_nb = ij_para_nb(mpi_rank) |
---|
| 176 | klon_mpi_begin = klon_mpi_para_begin(mpi_rank) |
---|
| 177 | klon_mpi_end = klon_mpi_para_end(mpi_rank) |
---|
| 178 | klon_mpi = klon_mpi_para_nb(mpi_rank) |
---|
| 179 | |
---|
[1543] | 180 | CALL Print_module_data |
---|
[892] | 181 | |
---|
[1543] | 182 | END SUBROUTINE Init_phys_lmdz_mpi_data |
---|
[892] | 183 | |
---|
| 184 | SUBROUTINE print_module_data |
---|
[1682] | 185 | USE print_control_mod, ONLY: lunout |
---|
[892] | 186 | IMPLICIT NONE |
---|
| 187 | |
---|
| 188 | WRITE(lunout,*) 'ii_begin =', ii_begin |
---|
| 189 | WRITE(lunout,*) 'ii_end =', ii_end |
---|
| 190 | WRITE(lunout,*) 'jj_begin =',jj_begin |
---|
| 191 | WRITE(lunout,*) 'jj_end =', jj_end |
---|
| 192 | WRITE(lunout,*) 'jj_nb =', jj_nb |
---|
| 193 | WRITE(lunout,*) 'ij_begin =', ij_begin |
---|
| 194 | WRITE(lunout,*) 'ij_end =', ij_end |
---|
| 195 | WRITE(lunout,*) 'ij_nb =', ij_nb |
---|
| 196 | WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin |
---|
| 197 | WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end |
---|
| 198 | WRITE(lunout,*) 'klon_mpi =', klon_mpi |
---|
| 199 | WRITE(lunout,*) 'jj_para_nb =', jj_para_nb |
---|
| 200 | WRITE(lunout,*) 'jj_para_begin =', jj_para_begin |
---|
| 201 | WRITE(lunout,*) 'jj_para_end =', jj_para_end |
---|
| 202 | WRITE(lunout,*) 'ii_para_begin =', ii_para_begin |
---|
| 203 | WRITE(lunout,*) 'ii_para_end =', ii_para_end |
---|
| 204 | WRITE(lunout,*) 'ij_para_nb =', ij_para_nb |
---|
| 205 | WRITE(lunout,*) 'ij_para_begin =', ij_para_begin |
---|
| 206 | WRITE(lunout,*) 'ij_para_end =', ij_para_end |
---|
| 207 | WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb |
---|
| 208 | WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin |
---|
| 209 | WRITE(lunout,*) 'klon_mpi_para_end =', klon_mpi_para_end |
---|
| 210 | WRITE(lunout,*) 'mpi_rank =', mpi_rank |
---|
| 211 | WRITE(lunout,*) 'mpi_size =', mpi_size |
---|
[1543] | 212 | WRITE(lunout,*) 'mpi_master =', mpi_master |
---|
[892] | 213 | WRITE(lunout,*) 'is_mpi_root =', is_mpi_root |
---|
[1572] | 214 | WRITE(lunout,*) 'is_north_pole_dyn =', is_north_pole_dyn |
---|
| 215 | WRITE(lunout,*) 'is_south_pole_dyn =', is_south_pole_dyn |
---|
[892] | 216 | WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY |
---|
| 217 | |
---|
| 218 | END SUBROUTINE print_module_data |
---|
| 219 | |
---|
| 220 | END MODULE mod_phys_lmdz_mpi_data |
---|