[5099] | 1 | |
---|
[1897] | 2 | ! $Id: iophy.F90 5137 2024-07-28 20:25:12Z fhourdin $ |
---|
[5099] | 3 | |
---|
[1807] | 4 | MODULE iophy |
---|
[5123] | 5 | USE lmdz_abort_physic, ONLY: abort_physic |
---|
[1807] | 6 | |
---|
[5117] | 7 | ! abd REAL,PRIVATE,ALLOCATABLE,DIMENSION(:),save :: io_lat |
---|
| 8 | ! abd REAL,PRIVATE,ALLOCATABLE,DIMENSION(:),save :: io_lon |
---|
[1791] | 9 | REAL,ALLOCATABLE,DIMENSION(:),SAVE :: io_lat |
---|
| 10 | REAL,ALLOCATABLE,DIMENSION(:),SAVE :: io_lon |
---|
| 11 | INTEGER, SAVE :: phys_domain_id |
---|
| 12 | INTEGER, SAVE :: npstn |
---|
| 13 | INTEGER, ALLOCATABLE, DIMENSION(:), SAVE :: nptabij |
---|
| 14 | INTEGER, SAVE :: itau_iophy |
---|
[5103] | 15 | LOGICAL :: check_dim = .FALSE. |
---|
[1791] | 16 | |
---|
| 17 | !$OMP THREADPRIVATE(itau_iophy) |
---|
[1852] | 18 | |
---|
[629] | 19 | INTERFACE histwrite_phy |
---|
[2645] | 20 | MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy,histwrite2d_phy_old,histwrite3d_phy_old,histwrite2d_xios,histwrite3d_xios,histwrite0d_xios |
---|
[1852] | 21 | END INTERFACE |
---|
[629] | 22 | |
---|
[1539] | 23 | INTERFACE histbeg_phy_all |
---|
[1825] | 24 | MODULE PROCEDURE histbeg_phy,histbeg_phyxios,histbeg_phy_points |
---|
[1539] | 25 | END INTERFACE |
---|
[1001] | 26 | |
---|
[1539] | 27 | |
---|
[1797] | 28 | CONTAINS |
---|
[629] | 29 | |
---|
[1797] | 30 | ! ug Routine pour définir itau_iophy depuis phys_output_write_mod: |
---|
| 31 | SUBROUTINE set_itau_iophy(ito) |
---|
[3266] | 32 | IMPLICIT NONE |
---|
| 33 | INTEGER, INTENT(IN) :: ito |
---|
| 34 | itau_iophy = ito |
---|
[1797] | 35 | END SUBROUTINE |
---|
| 36 | |
---|
| 37 | SUBROUTINE init_iophy_new(rlat,rlon) |
---|
[3266] | 38 | |
---|
| 39 | USE dimphy, ONLY: klon |
---|
[5110] | 40 | USE lmdz_phys_para, ONLY: gather, bcast, & |
---|
[3266] | 41 | jj_nb, jj_begin, jj_end, ii_begin, ii_end, & |
---|
| 42 | mpi_size, mpi_rank, klon_mpi, & |
---|
[2429] | 43 | is_sequential, is_south_pole_dyn |
---|
[5110] | 44 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, klon_glo, grid_type, unstructured |
---|
[5112] | 45 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[3266] | 46 | USE ioipsl, ONLY: flio_dom_set |
---|
[5117] | 47 | USE lmdz_wxios, ONLY: wxios_domain_param, wxios_domain_param_unstructured, wxios_context_init, using_xios |
---|
[3266] | 48 | IMPLICIT NONE |
---|
[1797] | 49 | REAL,DIMENSION(klon),INTENT(IN) :: rlon |
---|
| 50 | REAL,DIMENSION(klon),INTENT(IN) :: rlat |
---|
[1001] | 51 | |
---|
[1797] | 52 | REAL,DIMENSION(klon_glo) :: rlat_glo |
---|
| 53 | REAL,DIMENSION(klon_glo) :: rlon_glo |
---|
[1001] | 54 | |
---|
| 55 | INTEGER,DIMENSION(2) :: ddid |
---|
| 56 | INTEGER,DIMENSION(2) :: dsg |
---|
| 57 | INTEGER,DIMENSION(2) :: dsl |
---|
| 58 | INTEGER,DIMENSION(2) :: dpf |
---|
| 59 | INTEGER,DIMENSION(2) :: dpl |
---|
| 60 | INTEGER,DIMENSION(2) :: dhs |
---|
| 61 | INTEGER,DIMENSION(2) :: dhe |
---|
| 62 | INTEGER :: i |
---|
[1852] | 63 | INTEGER :: data_ibegin, data_iend |
---|
[1001] | 64 | |
---|
[5117] | 65 | IF (using_xios) CALL wxios_context_init |
---|
[1001] | 66 | |
---|
[3435] | 67 | |
---|
| 68 | IF (grid_type==unstructured) THEN |
---|
| 69 | |
---|
| 70 | CALL wxios_domain_param_unstructured("dom_glo") |
---|
| 71 | |
---|
| 72 | ELSE |
---|
| 73 | |
---|
| 74 | CALL gather(rlat,rlat_glo) |
---|
| 75 | CALL bcast(rlat_glo) |
---|
| 76 | CALL gather(rlon,rlon_glo) |
---|
| 77 | CALL bcast(rlon_glo) |
---|
| 78 | |
---|
[1001] | 79 | !$OMP MASTER |
---|
[2350] | 80 | ALLOCATE(io_lat(nbp_lat)) |
---|
| 81 | IF (klon_glo == 1) THEN |
---|
| 82 | io_lat(1)=rlat_glo(1) |
---|
| 83 | ELSE |
---|
| 84 | io_lat(1)=rlat_glo(1) |
---|
| 85 | io_lat(nbp_lat)=rlat_glo(klon_glo) |
---|
[2344] | 86 | DO i=2,nbp_lat-1 |
---|
| 87 | io_lat(i)=rlat_glo(2+(i-2)*nbp_lon) |
---|
[1001] | 88 | ENDDO |
---|
| 89 | ENDIF |
---|
| 90 | |
---|
[2344] | 91 | ALLOCATE(io_lon(nbp_lon)) |
---|
| 92 | IF (klon_glo == 1) THEN |
---|
| 93 | io_lon(1)=rlon_glo(1) |
---|
| 94 | ELSE |
---|
| 95 | io_lon(1:nbp_lon)=rlon_glo(2:nbp_lon+1) |
---|
| 96 | ENDIF |
---|
| 97 | |
---|
[1852] | 98 | !! (I) dtnb : total number of domains |
---|
| 99 | !! (I) dnb : domain number |
---|
| 100 | !! (I) did(:) : distributed dimensions identifiers |
---|
| 101 | !! (up to 5 dimensions are supported) |
---|
| 102 | !! (I) dsg(:) : total number of points for each dimension |
---|
| 103 | !! (I) dsl(:) : local number of points for each dimension |
---|
| 104 | !! (I) dpf(:) : position of first local point for each dimension |
---|
| 105 | !! (I) dpl(:) : position of last local point for each dimension |
---|
| 106 | !! (I) dhs(:) : start halo size for each dimension |
---|
| 107 | !! (I) dhe(:) : end halo size for each dimension |
---|
| 108 | !! (C) cdnm : Model domain definition name. |
---|
| 109 | !! The names actually supported are : |
---|
| 110 | !! "BOX", "APPLE", "ORANGE". |
---|
| 111 | !! These names are case insensitive. |
---|
[1001] | 112 | |
---|
| 113 | ddid=(/ 1,2 /) |
---|
[2344] | 114 | dsg=(/ nbp_lon, nbp_lat /) |
---|
| 115 | dsl=(/ nbp_lon, jj_nb /) |
---|
[1001] | 116 | dpf=(/ 1,jj_begin /) |
---|
[2344] | 117 | dpl=(/ nbp_lon, jj_end /) |
---|
[1001] | 118 | dhs=(/ ii_begin-1,0 /) |
---|
[1797] | 119 | IF (mpi_rank==mpi_size-1) THEN |
---|
[1001] | 120 | dhe=(/0,0/) |
---|
[1797] | 121 | ELSE |
---|
[2344] | 122 | dhe=(/ nbp_lon-ii_end,0 /) |
---|
[1797] | 123 | ENDIF |
---|
[1852] | 124 | |
---|
[2097] | 125 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[1797] | 126 | CALL flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, & |
---|
[1001] | 127 | 'APPLE',phys_domain_id) |
---|
[1852] | 128 | #endif |
---|
[4619] | 129 | IF (using_xios) THEN |
---|
[3435] | 130 | ! Set values for the mask: |
---|
| 131 | IF (mpi_rank == 0) THEN |
---|
| 132 | data_ibegin = 0 |
---|
| 133 | ELSE |
---|
| 134 | data_ibegin = ii_begin - 1 |
---|
| 135 | END IF |
---|
[1852] | 136 | |
---|
[3435] | 137 | IF (mpi_rank == mpi_size-1) THEN |
---|
| 138 | data_iend = nbp_lon |
---|
| 139 | ELSE |
---|
| 140 | data_iend = ii_end + 1 |
---|
| 141 | END IF |
---|
[1852] | 142 | |
---|
[3435] | 143 | IF (prt_level>=10) THEN |
---|
[5116] | 144 | WRITE(lunout,*) "init_iophy_new: mpirank=",mpi_rank," iibegin=",ii_begin , " ii_end=",ii_end," jjbegin=",jj_begin," jj_nb=",jj_nb," jj_end=",jj_end |
---|
| 145 | WRITE(lunout,*) "init_iophy_new: mpirank=",mpi_rank," nbp_lon=",nbp_lon," nbp_lat=",nbp_lat |
---|
| 146 | WRITE(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend |
---|
| 147 | WRITE(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend |
---|
| 148 | WRITE(lunout,*) "init_iophy_new: mpirank=",mpi_rank," is_south_pole_dyn=",is_south_pole_dyn |
---|
[3435] | 149 | ENDIF |
---|
[1852] | 150 | |
---|
[3435] | 151 | ! Initialize the XIOS domain coreesponding to this process: |
---|
[4619] | 152 | ENDIF |
---|
[1001] | 153 | !$OMP END MASTER |
---|
[3435] | 154 | |
---|
[4619] | 155 | IF (using_xios) CALL wxios_domain_param("dom_glo") |
---|
[1001] | 156 | |
---|
[3435] | 157 | ENDIF |
---|
| 158 | |
---|
[1797] | 159 | END SUBROUTINE init_iophy_new |
---|
[1001] | 160 | |
---|
[3266] | 161 | |
---|
[1797] | 162 | SUBROUTINE init_iophy(lat,lon) |
---|
[3266] | 163 | |
---|
[5110] | 164 | USE lmdz_phys_para, ONLY: jj_begin, jj_end, ii_begin, ii_end, jj_nb, & |
---|
[3266] | 165 | mpi_size, mpi_rank |
---|
| 166 | USE ioipsl, ONLY: flio_dom_set |
---|
[5110] | 167 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[3266] | 168 | |
---|
| 169 | IMPLICIT NONE |
---|
| 170 | |
---|
[2344] | 171 | REAL,DIMENSION(nbp_lon),INTENT(IN) :: lon |
---|
| 172 | REAL,DIMENSION(nbp_lat),INTENT(IN) :: lat |
---|
[766] | 173 | |
---|
| 174 | INTEGER,DIMENSION(2) :: ddid |
---|
| 175 | INTEGER,DIMENSION(2) :: dsg |
---|
| 176 | INTEGER,DIMENSION(2) :: dsl |
---|
| 177 | INTEGER,DIMENSION(2) :: dpf |
---|
| 178 | INTEGER,DIMENSION(2) :: dpl |
---|
| 179 | INTEGER,DIMENSION(2) :: dhs |
---|
| 180 | INTEGER,DIMENSION(2) :: dhe |
---|
| 181 | |
---|
| 182 | !$OMP MASTER |
---|
[2854] | 183 | ALLOCATE(io_lat(nbp_lat)) |
---|
[629] | 184 | io_lat(:)=lat(:) |
---|
[2854] | 185 | ALLOCATE(io_lon(nbp_lon)) |
---|
[629] | 186 | io_lon(:)=lon(:) |
---|
[1331] | 187 | |
---|
[766] | 188 | ddid=(/ 1,2 /) |
---|
[2344] | 189 | dsg=(/ nbp_lon, nbp_lat /) |
---|
| 190 | dsl=(/ nbp_lon, jj_nb /) |
---|
[776] | 191 | dpf=(/ 1,jj_begin /) |
---|
[2344] | 192 | dpl=(/ nbp_lon, jj_end /) |
---|
[776] | 193 | dhs=(/ ii_begin-1,0 /) |
---|
[2854] | 194 | IF (mpi_rank==mpi_size-1) THEN |
---|
[766] | 195 | dhe=(/0,0/) |
---|
[2854] | 196 | ELSE |
---|
[2344] | 197 | dhe=(/ nbp_lon-ii_end,0 /) |
---|
[2854] | 198 | ENDIF |
---|
[766] | 199 | |
---|
[2097] | 200 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[5103] | 201 | CALL flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, & |
---|
[766] | 202 | 'APPLE',phys_domain_id) |
---|
[1852] | 203 | #endif |
---|
[766] | 204 | !$OMP END MASTER |
---|
| 205 | |
---|
[2854] | 206 | END SUBROUTINE init_iophy |
---|
[1825] | 207 | |
---|
| 208 | SUBROUTINE histbeg_phyxios(name,itau0,zjulian,dtime,ffreq,lev,nhori,nid_day) |
---|
[1897] | 209 | ! USE dimphy |
---|
[5110] | 210 | USE lmdz_phys_para, ONLY: is_sequential, is_using_mpi, is_mpi_root, & |
---|
[1897] | 211 | jj_begin, jj_end, jj_nb |
---|
[5110] | 212 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[2854] | 213 | USE ioipsl, ONLY: histbeg |
---|
[5117] | 214 | USE lmdz_wxios, ONLY: wxios_add_file, using_xios |
---|
[5137] | 215 | USE lmdz_clesphys |
---|
| 216 | |
---|
[1825] | 217 | IMPLICIT NONE |
---|
[5137] | 218 | |
---|
[3266] | 219 | CHARACTER*(*), INTENT(IN) :: name |
---|
| 220 | INTEGER, INTENT(IN) :: itau0 |
---|
| 221 | REAL,INTENT(IN) :: zjulian |
---|
| 222 | REAL,INTENT(IN) :: dtime |
---|
| 223 | CHARACTER(LEN=*), INTENT(IN) :: ffreq |
---|
| 224 | INTEGER,INTENT(IN) :: lev |
---|
| 225 | INTEGER,INTENT(OUT) :: nhori |
---|
| 226 | INTEGER,INTENT(OUT) :: nid_day |
---|
[1825] | 227 | |
---|
| 228 | !$OMP MASTER |
---|
[3266] | 229 | IF (is_sequential) THEN |
---|
| 230 | CALL histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), & |
---|
| 231 | 1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day) |
---|
| 232 | ELSE |
---|
| 233 | CALL histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), & |
---|
| 234 | 1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id) |
---|
| 235 | ENDIF |
---|
[1825] | 236 | |
---|
[4619] | 237 | IF (using_xios) THEN |
---|
| 238 | ! ug OMP en chantier... |
---|
| 239 | IF((.NOT. is_using_mpi) .OR. is_mpi_root) THEN |
---|
| 240 | ! ug Création du fichier |
---|
[5117] | 241 | IF (.NOT. ok_all_xml) THEN |
---|
[4619] | 242 | CALL wxios_add_file(name, ffreq, lev) |
---|
| 243 | ENDIF |
---|
[2854] | 244 | ENDIF |
---|
[3266] | 245 | ENDIF |
---|
[1825] | 246 | !$OMP END MASTER |
---|
[629] | 247 | |
---|
[1825] | 248 | END SUBROUTINE histbeg_phyxios |
---|
| 249 | |
---|
[1797] | 250 | SUBROUTINE histbeg_phy(name,itau0,zjulian,dtime,nhori,nid_day) |
---|
[1897] | 251 | |
---|
[5110] | 252 | USE lmdz_phys_para, ONLY: jj_begin, jj_end, jj_nb, is_sequential |
---|
| 253 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[2854] | 254 | USE ioipsl, ONLY: histbeg |
---|
[1897] | 255 | |
---|
[1797] | 256 | IMPLICIT NONE |
---|
[629] | 257 | |
---|
[2854] | 258 | CHARACTER*(*), INTENT(IN) :: name |
---|
| 259 | INTEGER, INTENT(IN) :: itau0 |
---|
[1797] | 260 | REAL,INTENT(IN) :: zjulian |
---|
| 261 | REAL,INTENT(IN) :: dtime |
---|
[2854] | 262 | INTEGER,INTENT(OUT) :: nhori |
---|
| 263 | INTEGER,INTENT(OUT) :: nid_day |
---|
[766] | 264 | |
---|
| 265 | !$OMP MASTER |
---|
[2097] | 266 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[2854] | 267 | IF (is_sequential) THEN |
---|
[3266] | 268 | CALL histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), & |
---|
[2344] | 269 | 1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day) |
---|
[2854] | 270 | ELSE |
---|
[3266] | 271 | CALL histbeg(name,nbp_lon,io_lon, jj_nb,io_lat(jj_begin:jj_end), & |
---|
[2344] | 272 | 1,nbp_lon,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id) |
---|
[2854] | 273 | ENDIF |
---|
[1852] | 274 | #endif |
---|
[766] | 275 | !$OMP END MASTER |
---|
[629] | 276 | |
---|
[1797] | 277 | END SUBROUTINE histbeg_phy |
---|
[1539] | 278 | |
---|
[1825] | 279 | |
---|
[1797] | 280 | SUBROUTINE histbeg_phy_points(rlon,rlat,pim,tabij,ipt,jpt, & |
---|
[1539] | 281 | plon,plat,plon_bounds,plat_bounds, & |
---|
| 282 | nname,itau0,zjulian,dtime,nnhori,nnid_day) |
---|
[2854] | 283 | USE dimphy, ONLY: klon |
---|
[5110] | 284 | USE lmdz_phys_para, ONLY: gather, bcast, & |
---|
[1897] | 285 | is_sequential, klon_mpi_begin, klon_mpi_end, & |
---|
| 286 | mpi_rank |
---|
[5110] | 287 | USE lmdz_grid_phy, ONLY: klon_glo, nbp_lon, nbp_lat, grid1dTo2d_glo |
---|
[2854] | 288 | USE ioipsl, ONLY: histbeg |
---|
[1897] | 289 | |
---|
[1797] | 290 | IMPLICIT NONE |
---|
[1539] | 291 | |
---|
[1797] | 292 | REAL,DIMENSION(klon),INTENT(IN) :: rlon |
---|
| 293 | REAL,DIMENSION(klon),INTENT(IN) :: rlat |
---|
[2854] | 294 | INTEGER, INTENT(IN) :: itau0 |
---|
[1797] | 295 | REAL,INTENT(IN) :: zjulian |
---|
| 296 | REAL,INTENT(IN) :: dtime |
---|
[2854] | 297 | INTEGER, INTENT(IN) :: pim |
---|
[5117] | 298 | INTEGER, INTENT(OUT) :: nnhori |
---|
[2854] | 299 | CHARACTER(len=20), INTENT(IN) :: nname |
---|
| 300 | INTEGER, INTENT(OUT) :: nnid_day |
---|
| 301 | INTEGER :: i |
---|
[1797] | 302 | REAL,DIMENSION(klon_glo) :: rlat_glo |
---|
| 303 | REAL,DIMENSION(klon_glo) :: rlon_glo |
---|
| 304 | INTEGER, DIMENSION(pim), INTENT(IN) :: tabij |
---|
| 305 | REAL,DIMENSION(pim), INTENT(IN) :: plat, plon |
---|
| 306 | INTEGER,DIMENSION(pim), INTENT(IN) :: ipt, jpt |
---|
[5117] | 307 | REAL,DIMENSION(pim,2), INTENT(OUT) :: plat_bounds, plon_bounds |
---|
[1539] | 308 | |
---|
| 309 | INTEGER, SAVE :: tabprocbeg, tabprocend |
---|
| 310 | !$OMP THREADPRIVATE(tabprocbeg, tabprocend) |
---|
| 311 | INTEGER :: ip |
---|
| 312 | INTEGER, PARAMETER :: nip=1 |
---|
| 313 | INTEGER :: npproc |
---|
[5117] | 314 | REAL, ALLOCATABLE, DIMENSION(:) :: npplat, npplon |
---|
| 315 | REAL, ALLOCATABLE, DIMENSION(:,:) :: npplat_bounds, npplon_bounds |
---|
[2344] | 316 | REAL, DIMENSION(nbp_lon,nbp_lat) :: zx_lon, zx_lat |
---|
[1539] | 317 | |
---|
| 318 | CALL gather(rlat,rlat_glo) |
---|
| 319 | CALL bcast(rlat_glo) |
---|
| 320 | CALL gather(rlon,rlon_glo) |
---|
| 321 | CALL bcast(rlon_glo) |
---|
| 322 | |
---|
| 323 | !$OMP MASTER |
---|
| 324 | DO i=1,pim |
---|
| 325 | |
---|
[5103] | 326 | ! PRINT*,'CFMIP_iophy i tabij lon lat',i,tabij(i),plon(i),plat(i) |
---|
[1539] | 327 | |
---|
| 328 | plon_bounds(i,1)=rlon_glo(tabij(i)-1) |
---|
| 329 | plon_bounds(i,2)=rlon_glo(tabij(i)+1) |
---|
[5082] | 330 | IF (plon_bounds(i,2)<=0..AND.plon_bounds(i,1)>=0.) THEN |
---|
| 331 | IF (rlon_glo(tabij(i))>=0.) THEN |
---|
[1539] | 332 | plon_bounds(i,2)=-1*plon_bounds(i,2) |
---|
[2854] | 333 | ENDIF |
---|
| 334 | ENDIF |
---|
[5082] | 335 | IF (plon_bounds(i,2)>=0..AND.plon_bounds(i,1)<=0.) THEN |
---|
| 336 | IF (rlon_glo(tabij(i))<=0.) THEN |
---|
[1539] | 337 | plon_bounds(i,2)=-1*plon_bounds(i,2) |
---|
[2854] | 338 | ENDIF |
---|
| 339 | ENDIF |
---|
[5099] | 340 | |
---|
[5082] | 341 | IF ( tabij(i)<=nbp_lon) THEN |
---|
[1539] | 342 | plat_bounds(i,1)=rlat_glo(tabij(i)) |
---|
| 343 | ELSE |
---|
[2344] | 344 | plat_bounds(i,1)=rlat_glo(tabij(i)-nbp_lon) |
---|
[1539] | 345 | ENDIF |
---|
[2344] | 346 | plat_bounds(i,2)=rlat_glo(tabij(i)+nbp_lon) |
---|
[5099] | 347 | |
---|
[5103] | 348 | ! PRINT*,'CFMIP_iophy point i lon lon_bds',i,plon_bounds(i,1),rlon_glo(tabij(i)),plon_bounds(i,2) |
---|
| 349 | ! PRINT*,'CFMIP_iophy point i lat lat_bds',i,plat_bounds(i,1),rlat_glo(tabij(i)),plat_bounds(i,2) |
---|
[5099] | 350 | |
---|
[1539] | 351 | ENDDO |
---|
[5117] | 352 | IF (is_sequential) THEN |
---|
[1539] | 353 | npstn=pim |
---|
| 354 | IF(.NOT. ALLOCATED(nptabij)) THEN |
---|
| 355 | ALLOCATE(nptabij(pim)) |
---|
| 356 | ENDIF |
---|
| 357 | DO i=1,pim |
---|
| 358 | nptabij(i)=tabij(i) |
---|
| 359 | ENDDO |
---|
| 360 | |
---|
[3435] | 361 | CALL grid1dTo2d_glo(rlon_glo,zx_lon) |
---|
[5082] | 362 | IF ((nbp_lon*nbp_lat)>1) THEN |
---|
[2344] | 363 | DO i = 1, nbp_lon |
---|
[1539] | 364 | zx_lon(i,1) = rlon_glo(i+1) |
---|
[2344] | 365 | zx_lon(i,nbp_lat) = rlon_glo(i+1) |
---|
[1539] | 366 | ENDDO |
---|
[2854] | 367 | ENDIF |
---|
[3435] | 368 | CALL grid1dTo2d_glo(rlat_glo,zx_lat) |
---|
[1539] | 369 | |
---|
| 370 | DO i=1,pim |
---|
[5103] | 371 | ! PRINT*,'CFMIP_iophy i tabij lon lat',i,tabij(i),plon(i),plat(i) |
---|
[1539] | 372 | |
---|
| 373 | plon_bounds(i,1)=zx_lon(ipt(i)-1,jpt(i)) |
---|
| 374 | plon_bounds(i,2)=zx_lon(ipt(i)+1,jpt(i)) |
---|
| 375 | |
---|
[5082] | 376 | IF (ipt(i)==1) THEN |
---|
[2344] | 377 | plon_bounds(i,1)=zx_lon(nbp_lon,jpt(i)) |
---|
[1539] | 378 | plon_bounds(i,2)=360.+zx_lon(ipt(i)+1,jpt(i)) |
---|
[2854] | 379 | ENDIF |
---|
[1539] | 380 | |
---|
[5082] | 381 | IF (ipt(i)==nbp_lon) THEN |
---|
[1539] | 382 | plon_bounds(i,2)=360.+zx_lon(1,jpt(i)) |
---|
[2854] | 383 | ENDIF |
---|
[1539] | 384 | |
---|
| 385 | plat_bounds(i,1)=zx_lat(ipt(i),jpt(i)-1) |
---|
| 386 | plat_bounds(i,2)=zx_lat(ipt(i),jpt(i)+1) |
---|
| 387 | |
---|
[5082] | 388 | IF (jpt(i)==1) THEN |
---|
[1539] | 389 | plat_bounds(i,1)=zx_lat(ipt(i),1)+0.001 |
---|
| 390 | plat_bounds(i,2)=zx_lat(ipt(i),1)-0.001 |
---|
[2854] | 391 | ENDIF |
---|
[1539] | 392 | |
---|
[5082] | 393 | IF (jpt(i)==nbp_lat) THEN |
---|
[2344] | 394 | plat_bounds(i,1)=zx_lat(ipt(i),nbp_lat)+0.001 |
---|
| 395 | plat_bounds(i,2)=zx_lat(ipt(i),nbp_lat)-0.001 |
---|
[2854] | 396 | ENDIF |
---|
[5099] | 397 | |
---|
[5103] | 398 | ! PRINT*,'CFMIP_iophy point i lon lon_bds',i,plon_bounds(i,1),rlon(tabij(i)),plon_bounds(i,2) |
---|
| 399 | ! PRINT*,'CFMIP_iophy point i lat lat_bds',i,plat_bounds(i,1),rlat(tabij(i)),plat_bounds(i,2) |
---|
[5099] | 400 | |
---|
[1539] | 401 | ENDDO |
---|
[1897] | 402 | |
---|
[2097] | 403 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[3266] | 404 | CALL histbeg(nname,pim,plon,plon_bounds, & |
---|
[1539] | 405 | plat,plat_bounds, & |
---|
| 406 | itau0, zjulian, dtime, nnhori, nnid_day) |
---|
[1852] | 407 | #endif |
---|
[2854] | 408 | ELSE |
---|
[1539] | 409 | npproc=0 |
---|
| 410 | DO ip=1, pim |
---|
| 411 | tabprocbeg=klon_mpi_begin |
---|
| 412 | tabprocend=klon_mpi_end |
---|
[5082] | 413 | IF(tabij(ip)>=tabprocbeg.AND.tabij(ip)<=tabprocend) THEN |
---|
[1539] | 414 | npproc=npproc+1 |
---|
| 415 | npstn=npproc |
---|
| 416 | ENDIF |
---|
| 417 | ENDDO |
---|
[5103] | 418 | ! PRINT*,'CFMIP_iophy mpi_rank npstn',mpi_rank,npstn |
---|
[1539] | 419 | IF(.NOT. ALLOCATED(nptabij)) THEN |
---|
| 420 | ALLOCATE(nptabij(npstn)) |
---|
| 421 | ALLOCATE(npplon(npstn), npplat(npstn)) |
---|
| 422 | ALLOCATE(npplon_bounds(npstn,2), npplat_bounds(npstn,2)) |
---|
| 423 | ENDIF |
---|
| 424 | npproc=0 |
---|
| 425 | DO ip=1, pim |
---|
[5082] | 426 | IF(tabij(ip)>=tabprocbeg.AND.tabij(ip)<=tabprocend) THEN |
---|
[1539] | 427 | npproc=npproc+1 |
---|
| 428 | nptabij(npproc)=tabij(ip) |
---|
[5103] | 429 | ! PRINT*,'mpi_rank npproc ip plon plat tabij=',mpi_rank,npproc,ip, & |
---|
[1539] | 430 | ! plon(ip),plat(ip),tabij(ip) |
---|
| 431 | npplon(npproc)=plon(ip) |
---|
| 432 | npplat(npproc)=plat(ip) |
---|
| 433 | npplon_bounds(npproc,1)=plon_bounds(ip,1) |
---|
| 434 | npplon_bounds(npproc,2)=plon_bounds(ip,2) |
---|
| 435 | npplat_bounds(npproc,1)=plat_bounds(ip,1) |
---|
| 436 | npplat_bounds(npproc,2)=plat_bounds(ip,2) |
---|
| 437 | !!! |
---|
| 438 | !!! print qui sert a reordonner les points stations selon l'ordre CFMIP |
---|
| 439 | !!! ne pas enlever |
---|
[5103] | 440 | PRINT*,'iophy_mpi rank ip lon lat',mpi_rank,ip,plon(ip),plat(ip) |
---|
[1539] | 441 | !!! |
---|
| 442 | ENDIF |
---|
| 443 | ENDDO |
---|
[2097] | 444 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[3266] | 445 | CALL histbeg(nname,npstn,npplon,npplon_bounds, & |
---|
[1539] | 446 | npplat,npplat_bounds, & |
---|
| 447 | itau0,zjulian,dtime,nnhori,nnid_day,phys_domain_id) |
---|
[1852] | 448 | #endif |
---|
[2854] | 449 | ENDIF |
---|
[1539] | 450 | !$OMP END MASTER |
---|
| 451 | |
---|
[2854] | 452 | END SUBROUTINE histbeg_phy_points |
---|
[1807] | 453 | |
---|
| 454 | |
---|
[5106] | 455 | SUBROUTINE histdef2d_old(iff,lpoint,flag_var,nomvar,titrevar,unitvar) |
---|
[1807] | 456 | |
---|
[2854] | 457 | USE ioipsl, ONLY: histdef |
---|
[5110] | 458 | USE lmdz_phys_para, ONLY: jj_nb, is_master |
---|
[2854] | 459 | USE phys_output_var_mod, ONLY: type_ecri, zoutm, zdtime_moy, lev_files, & |
---|
[2989] | 460 | nid_files, nhorim, swaero_diag, dryaod_diag, nfiles, & |
---|
| 461 | ok_4xCO2atm |
---|
[5110] | 462 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[5101] | 463 | USE aero_mod, ONLY: naero_tot, name_aero_tau |
---|
[5112] | 464 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5137] | 465 | USE lmdz_clesphys |
---|
[2854] | 466 | |
---|
[1807] | 467 | IMPLICIT NONE |
---|
| 468 | |
---|
| 469 | INTEGER :: iff |
---|
[2854] | 470 | INTEGER :: naero |
---|
[1807] | 471 | LOGICAL :: lpoint |
---|
| 472 | INTEGER, DIMENSION(nfiles) :: flag_var |
---|
[2854] | 473 | CHARACTER(LEN=20) :: nomvar |
---|
[1807] | 474 | CHARACTER(LEN=*) :: titrevar |
---|
| 475 | CHARACTER(LEN=*) :: unitvar |
---|
| 476 | |
---|
| 477 | REAL zstophym |
---|
| 478 | |
---|
| 479 | IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN |
---|
| 480 | zstophym=zoutm(iff) |
---|
| 481 | ELSE |
---|
| 482 | zstophym=zdtime_moy |
---|
| 483 | ENDIF |
---|
[3238] | 484 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histdef2d_old for ', nomvar |
---|
[1807] | 485 | ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def |
---|
| 486 | CALL conf_physoutputs(nomvar,flag_var) |
---|
| 487 | |
---|
| 488 | IF(.NOT.lpoint) THEN |
---|
| 489 | IF ( flag_var(iff)<=lev_files(iff) ) THEN |
---|
| 490 | CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, & |
---|
[2344] | 491 | nbp_lon,jj_nb,nhorim(iff), 1,1,1, -99, 32, & |
---|
[1807] | 492 | type_ecri(iff), zstophym,zoutm(iff)) |
---|
| 493 | ENDIF |
---|
| 494 | ELSE |
---|
| 495 | IF ( flag_var(iff)<=lev_files(iff) ) THEN |
---|
| 496 | CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, & |
---|
| 497 | npstn,1,nhorim(iff), 1,1,1, -99, 32, & |
---|
| 498 | type_ecri(iff), zstophym,zoutm(iff)) |
---|
| 499 | ENDIF |
---|
| 500 | ENDIF |
---|
| 501 | |
---|
| 502 | ! Set swaero_diag=true if at least one of the concerned variables are defined |
---|
[2854] | 503 | IF (nomvar=='topswad' .OR. nomvar=='topswad0' .OR. nomvar=='solswad' .OR. nomvar=='solswad0' .OR. & |
---|
| 504 | nomvar=='toplwad' .OR. nomvar=='toplwad0' .OR. nomvar=='sollwad' .OR. nomvar=='sollwad0' .OR. & |
---|
| 505 | nomvar=='topswai' .OR. nomvar=='solswai' ) THEN |
---|
| 506 | IF ( flag_var(iff)<=lev_files(iff) ) swaero_diag=.TRUE. |
---|
| 507 | ENDIF |
---|
[1807] | 508 | |
---|
[2854] | 509 | ! Set dryaod_diag=true if at least one of the concerned variables are defined |
---|
[2856] | 510 | IF (nomvar=='dryod550aer') THEN |
---|
| 511 | IF ( flag_var(iff)<=lev_files(iff) ) dryaod_diag=.TRUE. |
---|
| 512 | ENDIF |
---|
[2854] | 513 | DO naero = 1, naero_tot-1 |
---|
| 514 | IF (nomvar=='dryod550_'//name_aero_tau(naero)) THEN |
---|
| 515 | IF ( flag_var(iff)<=lev_files(iff) ) dryaod_diag=.TRUE. |
---|
| 516 | ENDIF |
---|
| 517 | ENDDO |
---|
[1807] | 518 | |
---|
[2989] | 519 | ! Set ok_4xCO2atm=true if at least one of the concerned variables are |
---|
| 520 | ! defined |
---|
| 521 | IF (nomvar=='rsut4co2'.OR.nomvar=='rlut4co2'.OR.nomvar=='rsutcs4co2' & |
---|
| 522 | .OR. nomvar=='rlutcs4co2'.OR.nomvar=='rsu4co2'.OR.nomvar=='rsucs4co2' & |
---|
| 523 | .OR.nomvar=='rsu4co2'.OR.nomvar=='rsucs4co2'.OR.nomvar=='rsd4co2'.OR. & |
---|
| 524 | nomvar=='rsdcs4co2'.OR.nomvar=='rlu4co2'.OR.nomvar=='rlucs4co2'.OR.& |
---|
| 525 | nomvar=='rld4co2'.OR.nomvar=='rldcs4co2') THEN |
---|
| 526 | IF ( flag_var(iff)<=lev_files(iff) ) ok_4xCO2atm=.TRUE. |
---|
| 527 | ENDIF |
---|
[2854] | 528 | END SUBROUTINE histdef2d_old |
---|
[1807] | 529 | |
---|
[5106] | 530 | SUBROUTINE histdef3d_old(iff,lpoint,flag_var,nomvar,titrevar,unitvar) |
---|
[1807] | 531 | |
---|
[2854] | 532 | USE ioipsl, ONLY: histdef |
---|
| 533 | USE dimphy, ONLY: klev |
---|
[5110] | 534 | USE lmdz_phys_para, ONLY: jj_nb, is_master |
---|
[2854] | 535 | USE phys_output_var_mod, ONLY: type_ecri, zoutm, lev_files, nid_files, & |
---|
[1897] | 536 | nhorim, zdtime_moy, levmin, levmax, & |
---|
| 537 | nvertm, nfiles |
---|
[5110] | 538 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[5112] | 539 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5137] | 540 | USE lmdz_clesphys |
---|
| 541 | |
---|
[1807] | 542 | IMPLICIT NONE |
---|
| 543 | |
---|
| 544 | INTEGER :: iff |
---|
| 545 | LOGICAL :: lpoint |
---|
| 546 | INTEGER, DIMENSION(nfiles) :: flag_var |
---|
| 547 | CHARACTER(LEN=20) :: nomvar |
---|
| 548 | CHARACTER(LEN=*) :: titrevar |
---|
| 549 | CHARACTER(LEN=*) :: unitvar |
---|
| 550 | |
---|
| 551 | REAL zstophym |
---|
| 552 | |
---|
| 553 | ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def |
---|
| 554 | CALL conf_physoutputs(nomvar,flag_var) |
---|
| 555 | |
---|
[3238] | 556 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histdef3d_old for ', nomvar |
---|
| 557 | |
---|
[1807] | 558 | IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN |
---|
| 559 | zstophym=zoutm(iff) |
---|
| 560 | ELSE |
---|
| 561 | zstophym=zdtime_moy |
---|
| 562 | ENDIF |
---|
| 563 | |
---|
| 564 | IF(.NOT.lpoint) THEN |
---|
| 565 | IF ( flag_var(iff)<=lev_files(iff) ) THEN |
---|
| 566 | CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, & |
---|
[2344] | 567 | nbp_lon, jj_nb, nhorim(iff), klev, levmin(iff), & |
---|
[1807] | 568 | levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), & |
---|
| 569 | zstophym, zoutm(iff)) |
---|
| 570 | ENDIF |
---|
| 571 | ELSE |
---|
| 572 | IF ( flag_var(iff)<=lev_files(iff) ) THEN |
---|
| 573 | CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, & |
---|
| 574 | npstn,1,nhorim(iff), klev, levmin(iff), & |
---|
| 575 | levmax(iff)-levmin(iff)+1, nvertm(iff), 32, & |
---|
| 576 | type_ecri(iff), zstophym,zoutm(iff)) |
---|
| 577 | ENDIF |
---|
| 578 | ENDIF |
---|
| 579 | END SUBROUTINE histdef3d_old |
---|
| 580 | |
---|
[5106] | 581 | SUBROUTINE histdef2d(iff,var) |
---|
[1807] | 582 | |
---|
[2854] | 583 | USE ioipsl, ONLY: histdef |
---|
[5110] | 584 | USE lmdz_phys_para, ONLY: jj_nb, is_master |
---|
[2854] | 585 | USE phys_output_var_mod, ONLY: ctrl_out, type_ecri_files, zoutm, zdtime_moy, & |
---|
[1897] | 586 | clef_stations, phys_out_filenames, lev_files, & |
---|
[3082] | 587 | nid_files, nhorim, swaerofree_diag, swaero_diag, dryaod_diag,& |
---|
[2989] | 588 | ok_4xCO2atm |
---|
[5112] | 589 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5110] | 590 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[5101] | 591 | USE aero_mod, ONLY: naero_tot, name_aero_tau |
---|
[5117] | 592 | USE lmdz_wxios, ONLY: wxios_add_field_to_file, using_xios |
---|
[5112] | 593 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5137] | 594 | USE lmdz_clesphys |
---|
[1807] | 595 | IMPLICIT NONE |
---|
| 596 | |
---|
| 597 | INTEGER :: iff |
---|
[2854] | 598 | INTEGER :: naero |
---|
[1807] | 599 | TYPE(ctrl_out) :: var |
---|
| 600 | |
---|
| 601 | REAL zstophym |
---|
| 602 | CHARACTER(LEN=20) :: typeecrit |
---|
| 603 | |
---|
[3238] | 604 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histdef2d for ', var%name |
---|
| 605 | |
---|
[1807] | 606 | ! ug On récupère le type écrit de la structure: |
---|
| 607 | ! Assez moche, à refaire si meilleure méthode... |
---|
| 608 | IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN |
---|
| 609 | typeecrit = 'once' |
---|
| 610 | ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN |
---|
| 611 | typeecrit = 't_min(X)' |
---|
| 612 | ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN |
---|
| 613 | typeecrit = 't_max(X)' |
---|
| 614 | ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN |
---|
| 615 | typeecrit = 'inst(X)' |
---|
| 616 | ELSE |
---|
| 617 | typeecrit = type_ecri_files(iff) |
---|
| 618 | ENDIF |
---|
| 619 | |
---|
| 620 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
| 621 | zstophym=zoutm(iff) |
---|
| 622 | ELSE |
---|
| 623 | zstophym=zdtime_moy |
---|
| 624 | ENDIF |
---|
| 625 | |
---|
| 626 | ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def |
---|
| 627 | CALL conf_physoutputs(var%name, var%flag) |
---|
| 628 | |
---|
| 629 | IF(.NOT.clef_stations(iff)) THEN |
---|
[1852] | 630 | |
---|
[4619] | 631 | IF (using_xios) THEN |
---|
[5117] | 632 | IF (.NOT. ok_all_xml) THEN |
---|
[4619] | 633 | IF ( var%flag(iff)<=lev_files(iff) ) THEN |
---|
| 634 | CALL wxios_add_field_to_file(var%name, 2, iff, phys_out_filenames(iff), & |
---|
| 635 | var%description, var%unit, var%flag(iff), typeecrit) |
---|
| 636 | IF (prt_level >= 10) THEN |
---|
[5103] | 637 | WRITE(lunout,*) 'histdef2d: CALL wxios_add_field_to_file var%name iff: ', & |
---|
[4619] | 638 | trim(var%name),iff |
---|
| 639 | ENDIF |
---|
[2114] | 640 | ENDIF |
---|
[2001] | 641 | ENDIF |
---|
| 642 | ENDIF |
---|
[2097] | 643 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[1825] | 644 | |
---|
[1807] | 645 | IF ( var%flag(iff)<=lev_files(iff) ) THEN |
---|
| 646 | CALL histdef (nid_files(iff), var%name, var%description, var%unit, & |
---|
[2344] | 647 | nbp_lon,jj_nb,nhorim(iff), 1,1,1, -99, 32, & |
---|
[1807] | 648 | typeecrit, zstophym,zoutm(iff)) |
---|
| 649 | ENDIF |
---|
| 650 | ELSE |
---|
| 651 | IF ( var%flag(iff)<=lev_files(iff)) THEN |
---|
| 652 | CALL histdef (nid_files(iff), var%name, var%description, var%unit, & |
---|
| 653 | npstn,1,nhorim(iff), 1,1,1, -99, 32, & |
---|
| 654 | typeecrit, zstophym,zoutm(iff)) |
---|
| 655 | ENDIF |
---|
[1852] | 656 | #endif |
---|
[1807] | 657 | ENDIF |
---|
| 658 | |
---|
[2854] | 659 | ! Set swaero_diag=true if at least one of the concerned variables are defined |
---|
[2529] | 660 | !--OB 30/05/2016 use wider set of variables |
---|
| 661 | IF ( var%name=='topswad' .OR. var%name=='topswad0' .OR. var%name=='solswad' .OR. var%name=='solswad0' .OR. & |
---|
| 662 | var%name=='topswai' .OR. var%name=='solswai' .OR. ( iflag_rrtm==1 .AND. ( & |
---|
| 663 | var%name=='toplwad' .OR. var%name=='toplwad0' .OR. var%name=='sollwad' .OR. var%name=='sollwad0' .OR. & |
---|
| 664 | var%name=='toplwai' .OR. var%name=='sollwai' ) ) ) THEN |
---|
[2854] | 665 | IF ( var%flag(iff)<=lev_files(iff) ) swaero_diag=.TRUE. |
---|
| 666 | ENDIF |
---|
| 667 | |
---|
[3082] | 668 | ! Set swaerofree_diag=true if at least one of the concerned variables are defined |
---|
[3106] | 669 | IF (var%name=='SWupTOAcleanclr' .OR. var%name=='SWupSFCcleanclr' .OR. var%name=='SWdnSFCcleanclr' .OR. & |
---|
[3107] | 670 | var%name=='LWupTOAcleanclr' .OR. var%name=='LWdnSFCcleanclr' ) THEN |
---|
[3082] | 671 | IF ( var%flag(iff)<=lev_files(iff) ) swaerofree_diag=.TRUE. |
---|
| 672 | ENDIF |
---|
| 673 | |
---|
[2854] | 674 | ! set dryaod_dry=true if at least one of the concerned variables are defined |
---|
| 675 | IF (var%name=='dryod550aer') THEN |
---|
| 676 | IF ( var%flag(iff)<=lev_files(iff) ) dryaod_diag=.TRUE. |
---|
| 677 | ENDIF |
---|
[5099] | 678 | |
---|
[2854] | 679 | DO naero = 1, naero_tot-1 |
---|
| 680 | IF (var%name=='dryod550_'//name_aero_tau(naero)) THEN |
---|
| 681 | IF ( var%flag(iff)<=lev_files(iff) ) dryaod_diag=.TRUE. |
---|
| 682 | ENDIF |
---|
| 683 | ENDDO |
---|
[2989] | 684 | ! Set ok_4xCO2atm=true if at least one of the concerned variables are |
---|
| 685 | ! defined |
---|
| 686 | IF (var%name=='rsut4co2'.OR.var%name=='rlut4co2'.OR.var%name=='rsutcs4co2' & |
---|
| 687 | .OR. var%name=='rlutcs4co2'.OR.var%name=='rsu4co2'.OR.var%name=='rsucs4co2' & |
---|
| 688 | .OR.var%name=='rsu4co2'.OR.var%name=='rsucs4co2'.OR.var%name=='rsd4co2'.OR. & |
---|
| 689 | var%name=='rsdcs4co2'.OR.var%name=='rlu4co2'.OR.var%name=='rlucs4co2'.OR.& |
---|
| 690 | var%name=='rld4co2'.OR.var%name=='rldcs4co2') THEN |
---|
| 691 | IF ( var%flag(iff)<=lev_files(iff) ) ok_4xCO2atm=.TRUE. |
---|
| 692 | ENDIF |
---|
[1807] | 693 | END SUBROUTINE histdef2d |
---|
[2001] | 694 | |
---|
[5106] | 695 | SUBROUTINE histdef3d(iff,var) |
---|
[1807] | 696 | |
---|
[2854] | 697 | USE ioipsl, ONLY: histdef |
---|
| 698 | USE dimphy, ONLY: klev |
---|
[5110] | 699 | USE lmdz_phys_para, ONLY: jj_nb, is_master |
---|
[2854] | 700 | USE phys_output_var_mod, ONLY: ctrl_out, type_ecri_files, zoutm, zdtime_moy, & |
---|
[1897] | 701 | clef_stations, phys_out_filenames, lev_files, & |
---|
[3266] | 702 | nid_files, nhorim, swaerofree_diag, levmin, & |
---|
[1897] | 703 | levmax, nvertm |
---|
[5112] | 704 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5110] | 705 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[5117] | 706 | USE lmdz_wxios, ONLY: wxios_add_field_to_file, using_xios |
---|
[5112] | 707 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5137] | 708 | USE lmdz_clesphys |
---|
| 709 | |
---|
[1807] | 710 | IMPLICIT NONE |
---|
| 711 | |
---|
| 712 | INTEGER :: iff |
---|
| 713 | TYPE(ctrl_out) :: var |
---|
| 714 | |
---|
| 715 | REAL zstophym |
---|
| 716 | CHARACTER(LEN=20) :: typeecrit |
---|
| 717 | |
---|
[3238] | 718 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histdef3d for ', var%name |
---|
| 719 | |
---|
[1807] | 720 | ! ug On récupère le type écrit de la structure: |
---|
| 721 | ! Assez moche, à refaire si meilleure méthode... |
---|
| 722 | IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN |
---|
| 723 | typeecrit = 'once' |
---|
| 724 | ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN |
---|
| 725 | typeecrit = 't_min(X)' |
---|
| 726 | ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN |
---|
| 727 | typeecrit = 't_max(X)' |
---|
| 728 | ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN |
---|
| 729 | typeecrit = 'inst(X)' |
---|
| 730 | ELSE |
---|
| 731 | typeecrit = type_ecri_files(iff) |
---|
| 732 | ENDIF |
---|
| 733 | |
---|
| 734 | ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def |
---|
| 735 | CALL conf_physoutputs(var%name,var%flag) |
---|
| 736 | |
---|
| 737 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
| 738 | zstophym=zoutm(iff) |
---|
| 739 | ELSE |
---|
| 740 | zstophym=zdtime_moy |
---|
| 741 | ENDIF |
---|
| 742 | |
---|
| 743 | IF(.NOT.clef_stations(iff)) THEN |
---|
[1852] | 744 | |
---|
[4619] | 745 | IF (using_xios) THEN |
---|
| 746 | |
---|
[5117] | 747 | IF (.NOT. ok_all_xml) THEN |
---|
[4619] | 748 | IF ( var%flag(iff)<=lev_files(iff) ) THEN |
---|
| 749 | CALL wxios_add_field_to_file(var%name, 3, iff, phys_out_filenames(iff), & |
---|
| 750 | var%description, var%unit, var%flag(iff), typeecrit) |
---|
| 751 | IF (prt_level >= 10) THEN |
---|
[5103] | 752 | WRITE(lunout,*) 'histdef3d: CALL wxios_add_field_to_file var%name iff: ', & |
---|
[4619] | 753 | trim(var%name),iff |
---|
| 754 | ENDIF |
---|
| 755 | ENDIF |
---|
| 756 | ENDIF |
---|
| 757 | ENDIF |
---|
[2097] | 758 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[1825] | 759 | |
---|
[1807] | 760 | IF ( var%flag(iff)<=lev_files(iff) ) THEN |
---|
| 761 | CALL histdef (nid_files(iff), var%name, var%description, var%unit, & |
---|
[2344] | 762 | nbp_lon, jj_nb, nhorim(iff), klev, levmin(iff), & |
---|
[1807] | 763 | levmax(iff)-levmin(iff)+1, nvertm(iff), 32, typeecrit, & |
---|
| 764 | zstophym, zoutm(iff)) |
---|
| 765 | ENDIF |
---|
| 766 | ELSE |
---|
| 767 | IF ( var%flag(iff)<=lev_files(iff)) THEN |
---|
| 768 | CALL histdef (nid_files(iff), var%name, var%description, var%unit, & |
---|
| 769 | npstn,1,nhorim(iff), klev, levmin(iff), & |
---|
| 770 | levmax(iff)-levmin(iff)+1, nvertm(iff), 32, & |
---|
| 771 | typeecrit, zstophym,zoutm(iff)) |
---|
| 772 | ENDIF |
---|
[1852] | 773 | #endif |
---|
[1807] | 774 | ENDIF |
---|
[3082] | 775 | |
---|
| 776 | ! Set swaerofree_diag=true if at least one of the concerned variables are defined |
---|
| 777 | IF (var%name=='rsucsaf' .OR. var%name=='rsdcsaf') THEN |
---|
| 778 | IF ( var%flag(iff)<=lev_files(iff) ) swaerofree_diag=.TRUE. |
---|
| 779 | ENDIF |
---|
| 780 | |
---|
[1807] | 781 | END SUBROUTINE histdef3d |
---|
| 782 | |
---|
| 783 | SUBROUTINE conf_physoutputs(nam_var,flag_var) |
---|
| 784 | !!! Lecture des noms et niveau de sortie des variables dans output.def |
---|
| 785 | ! en utilisant les routines getin de IOIPSL |
---|
[2854] | 786 | USE ioipsl, ONLY: getin |
---|
| 787 | USE phys_output_var_mod, ONLY: nfiles |
---|
[5112] | 788 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[1807] | 789 | IMPLICIT NONE |
---|
| 790 | |
---|
[4046] | 791 | CHARACTER(LEN=*), INTENT(INOUT) :: nam_var |
---|
| 792 | INTEGER, INTENT(INOUT) :: flag_var(nfiles) |
---|
[1807] | 793 | |
---|
| 794 | IF(prt_level>10) WRITE(lunout,*)'Avant getin: nam_var flag_var ',nam_var,flag_var(:) |
---|
| 795 | CALL getin('flag_'//nam_var,flag_var) |
---|
| 796 | CALL getin('name_'//nam_var,nam_var) |
---|
| 797 | IF(prt_level>10) WRITE(lunout,*)'Apres getin: nam_var flag_var ',nam_var,flag_var(:) |
---|
| 798 | |
---|
| 799 | END SUBROUTINE conf_physoutputs |
---|
| 800 | |
---|
[1539] | 801 | |
---|
[1791] | 802 | SUBROUTINE histwrite2d_phy_old(nid,lpoint,name,itau,field) |
---|
[3266] | 803 | |
---|
| 804 | USE dimphy, ONLY: klon |
---|
[5110] | 805 | USE lmdz_phys_para, ONLY: Gather_omp, grid1Dto2D_mpi, & |
---|
[3266] | 806 | is_sequential, klon_mpi_begin, klon_mpi_end, & |
---|
| 807 | jj_nb, klon_mpi, is_master |
---|
| 808 | USE ioipsl, ONLY: histwrite |
---|
[5112] | 809 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5110] | 810 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[3266] | 811 | |
---|
| 812 | IMPLICIT NONE |
---|
[629] | 813 | |
---|
[2854] | 814 | INTEGER,INTENT(IN) :: nid |
---|
| 815 | LOGICAL,INTENT(IN) :: lpoint |
---|
| 816 | CHARACTER*(*), INTENT(IN) :: name |
---|
| 817 | INTEGER, INTENT(IN) :: itau |
---|
[1797] | 818 | REAL,DIMENSION(:),INTENT(IN) :: field |
---|
| 819 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
---|
[5117] | 820 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index2d |
---|
[2344] | 821 | REAL :: Field2d(nbp_lon,jj_nb) |
---|
[1331] | 822 | |
---|
[2854] | 823 | INTEGER :: ip |
---|
| 824 | REAL,ALLOCATABLE,DIMENSION(:) :: fieldok |
---|
[1539] | 825 | |
---|
[2311] | 826 | IF (size(field)/=klon) CALL abort_physic('iophy::histwrite2d','Field first DIMENSION not equal to klon',1) |
---|
[3238] | 827 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite2d_phy_old for ', name |
---|
| 828 | |
---|
[776] | 829 | CALL Gather_omp(field,buffer_omp) |
---|
[766] | 830 | !$OMP MASTER |
---|
[1331] | 831 | CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
---|
[3266] | 832 | IF (.NOT.lpoint) THEN |
---|
[2344] | 833 | ALLOCATE(index2d(nbp_lon*jj_nb)) |
---|
| 834 | ALLOCATE(fieldok(nbp_lon*jj_nb)) |
---|
[5116] | 835 | IF (prt_level >= 10) WRITE(lunout,*)'Sending ',name,' to IOIPSL' |
---|
[2344] | 836 | CALL histwrite(nid,name,itau,Field2d,nbp_lon*jj_nb,index2d) |
---|
[5116] | 837 | IF (prt_level >= 10) WRITE(lunout,*)'Finished sending ',name,' to IOIPSL' |
---|
[2854] | 838 | ELSE |
---|
[1539] | 839 | ALLOCATE(fieldok(npstn)) |
---|
| 840 | ALLOCATE(index2d(npstn)) |
---|
| 841 | |
---|
[2854] | 842 | IF (is_sequential) THEN |
---|
[1539] | 843 | ! klon_mpi_begin=1 |
---|
| 844 | ! klon_mpi_end=klon |
---|
| 845 | DO ip=1, npstn |
---|
| 846 | fieldok(ip)=buffer_omp(nptabij(ip)) |
---|
| 847 | ENDDO |
---|
[2854] | 848 | ELSE |
---|
[1539] | 849 | DO ip=1, npstn |
---|
[5103] | 850 | ! PRINT*,'histwrite2d is_sequential npstn ip name nptabij',npstn,ip,name,nptabij(ip) |
---|
[5082] | 851 | IF(nptabij(ip)>=klon_mpi_begin.AND. & |
---|
| 852 | nptabij(ip)<=klon_mpi_end) THEN |
---|
[1539] | 853 | fieldok(ip)=buffer_omp(nptabij(ip)-klon_mpi_begin+1) |
---|
| 854 | ENDIF |
---|
| 855 | ENDDO |
---|
[2854] | 856 | ENDIF |
---|
[5116] | 857 | IF (prt_level >= 10) WRITE(lunout,*)'Sending ',name,' to IOIPSL' |
---|
[1539] | 858 | CALL histwrite(nid,name,itau,fieldok,npstn,index2d) |
---|
[5116] | 859 | IF (prt_level >= 10) WRITE(lunout,*)'Finished sending ',name,' to IOIPSL' |
---|
[5099] | 860 | |
---|
[2854] | 861 | ENDIF |
---|
| 862 | DEALLOCATE(index2d) |
---|
| 863 | DEALLOCATE(fieldok) |
---|
[1791] | 864 | !$OMP END MASTER |
---|
[1331] | 865 | |
---|
[1791] | 866 | |
---|
[2854] | 867 | END SUBROUTINE histwrite2d_phy_old |
---|
[1791] | 868 | |
---|
[1797] | 869 | SUBROUTINE histwrite3d_phy_old(nid,lpoint,name,itau,field) |
---|
[3266] | 870 | |
---|
| 871 | USE dimphy, ONLY: klon |
---|
[5110] | 872 | USE lmdz_phys_para, ONLY: Gather_omp, grid1Dto2D_mpi, & |
---|
[3266] | 873 | is_sequential, klon_mpi_begin, klon_mpi_end, & |
---|
| 874 | jj_nb, klon_mpi, is_master |
---|
[5110] | 875 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[3266] | 876 | USE ioipsl, ONLY: histwrite |
---|
[5112] | 877 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[3266] | 878 | |
---|
| 879 | IMPLICIT NONE |
---|
[629] | 880 | |
---|
[2854] | 881 | INTEGER,INTENT(IN) :: nid |
---|
| 882 | LOGICAL,INTENT(IN) :: lpoint |
---|
| 883 | CHARACTER*(*), INTENT(IN) :: name |
---|
| 884 | INTEGER, INTENT(IN) :: itau |
---|
[1797] | 885 | REAL,DIMENSION(:,:),INTENT(IN) :: field ! --> field(klon,:) |
---|
| 886 | REAL,DIMENSION(klon_mpi,size(field,2)) :: buffer_omp |
---|
[2344] | 887 | REAL :: Field3d(nbp_lon,jj_nb,size(field,2)) |
---|
[1539] | 888 | INTEGER :: ip, n, nlev |
---|
[1797] | 889 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
---|
[5117] | 890 | REAL,ALLOCATABLE, DIMENSION(:,:) :: fieldok |
---|
[1539] | 891 | |
---|
[3238] | 892 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite3d_phy_old for ', name |
---|
[1791] | 893 | |
---|
[2311] | 894 | IF (size(field,1)/=klon) CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1) |
---|
[1331] | 895 | nlev=size(field,2) |
---|
[1539] | 896 | |
---|
[776] | 897 | CALL Gather_omp(field,buffer_omp) |
---|
[766] | 898 | !$OMP MASTER |
---|
[1331] | 899 | CALL grid1Dto2D_mpi(buffer_omp,field3d) |
---|
[2854] | 900 | IF (.NOT.lpoint) THEN |
---|
[3266] | 901 | ALLOCATE(index3d(nbp_lon*jj_nb*nlev)) |
---|
| 902 | ALLOCATE(fieldok(nbp_lon*jj_nb,nlev)) |
---|
[5116] | 903 | IF (prt_level >= 10) WRITE(lunout,*)'Sending ',name,' to IOIPSL' |
---|
[3266] | 904 | CALL histwrite(nid,name,itau,Field3d,nbp_lon*jj_nb*nlev,index3d) |
---|
[5116] | 905 | IF (prt_level >= 10) WRITE(lunout,*)'Finished sending ',name,' to IOIPSL' |
---|
[3266] | 906 | ELSE |
---|
[1539] | 907 | nlev=size(field,2) |
---|
| 908 | ALLOCATE(index3d(npstn*nlev)) |
---|
| 909 | ALLOCATE(fieldok(npstn,nlev)) |
---|
| 910 | |
---|
[2854] | 911 | IF (is_sequential) THEN |
---|
[3266] | 912 | ! klon_mpi_begin=1 |
---|
| 913 | ! klon_mpi_end=klon |
---|
| 914 | DO n=1, nlev |
---|
| 915 | DO ip=1, npstn |
---|
| 916 | fieldok(ip,n)=buffer_omp(nptabij(ip),n) |
---|
| 917 | ENDDO |
---|
| 918 | ENDDO |
---|
[2854] | 919 | ELSE |
---|
[3266] | 920 | DO n=1, nlev |
---|
| 921 | DO ip=1, npstn |
---|
[5082] | 922 | IF(nptabij(ip)>=klon_mpi_begin.AND. & |
---|
| 923 | nptabij(ip)<=klon_mpi_end) THEN |
---|
[3266] | 924 | fieldok(ip,n)=buffer_omp(nptabij(ip)-klon_mpi_begin+1,n) |
---|
| 925 | ENDIF |
---|
| 926 | ENDDO |
---|
| 927 | ENDDO |
---|
[2854] | 928 | ENDIF |
---|
[5116] | 929 | IF (prt_level >= 10) WRITE(lunout,*)'Sending ',name,' to IOIPSL' |
---|
[1539] | 930 | CALL histwrite(nid,name,itau,fieldok,npstn*nlev,index3d) |
---|
[5116] | 931 | IF (prt_level >= 10) WRITE(lunout,*)'Finished sending ',name,' to IOIPSL' |
---|
[2854] | 932 | ENDIF |
---|
[3266] | 933 | DEALLOCATE(index3d) |
---|
| 934 | DEALLOCATE(fieldok) |
---|
[766] | 935 | !$OMP END MASTER |
---|
[1791] | 936 | |
---|
[2854] | 937 | END SUBROUTINE histwrite3d_phy_old |
---|
[1791] | 938 | |
---|
| 939 | |
---|
| 940 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
---|
| 941 | SUBROUTINE histwrite2d_phy(var,field, STD_iff) |
---|
[3266] | 942 | |
---|
[5110] | 943 | USE lmdz_phys_omp_transfert, ONLY: bcast_omp |
---|
[3003] | 944 | USE dimphy, ONLY: klon, klev |
---|
[5110] | 945 | USE lmdz_phys_para, ONLY: gather_omp, grid1dto2d_mpi, & |
---|
[1897] | 946 | jj_nb, klon_mpi, klon_mpi_begin, & |
---|
[3238] | 947 | klon_mpi_end, is_sequential, is_master |
---|
[2854] | 948 | USE ioipsl, ONLY: histwrite |
---|
| 949 | USE phys_output_var_mod, ONLY: ctrl_out, clef_files, lev_files, & |
---|
[1897] | 950 | nfiles, vars_defined, clef_stations, & |
---|
[3266] | 951 | nid_files, swaerofree_diag, swaero_diag, dryaod_diag, ok_4xCO2atm |
---|
[5112] | 952 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5110] | 953 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat |
---|
[4619] | 954 | USE lmdz_xios, ONLY: xios_send_field, xios_field_is_active, using_xios |
---|
[5112] | 955 | USE lmdz_print_control, ONLY: lunout, prt_level |
---|
[5137] | 956 | USE lmdz_clesphys |
---|
[1791] | 957 | |
---|
| 958 | IMPLICIT NONE |
---|
| 959 | |
---|
[3266] | 960 | TYPE(ctrl_out), INTENT(IN) :: var |
---|
| 961 | REAL, DIMENSION(:), INTENT(IN) :: field |
---|
| 962 | INTEGER, INTENT(IN), OPTIONAL :: STD_iff ! ug RUSTINE POUR LES STD LEVS..... |
---|
[1791] | 963 | |
---|
[3266] | 964 | INTEGER :: iff, iff_beg, iff_end |
---|
| 965 | LOGICAL, SAVE :: firstx |
---|
[2001] | 966 | !$OMP THREADPRIVATE(firstx) |
---|
| 967 | |
---|
[3266] | 968 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
---|
[5117] | 969 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index2d |
---|
[3266] | 970 | REAL :: Field2d(nbp_lon,jj_nb) |
---|
[1791] | 971 | |
---|
[3266] | 972 | INTEGER :: ip |
---|
| 973 | REAL, ALLOCATABLE, DIMENSION(:) :: fieldok |
---|
[5103] | 974 | logical, save :: is_active = .TRUE. |
---|
[1791] | 975 | |
---|
[3266] | 976 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite2d_phy for ',trim(var%name) |
---|
[3238] | 977 | |
---|
[3266] | 978 | IF (prt_level >= 10) THEN |
---|
| 979 | WRITE(lunout,*)'Begin histwrite2d_phy for ',trim(var%name) |
---|
| 980 | ENDIF |
---|
| 981 | |
---|
[1791] | 982 | ! ug RUSTINE POUR LES STD LEVS..... |
---|
[3266] | 983 | IF (PRESENT(STD_iff)) THEN |
---|
| 984 | iff_beg = STD_iff |
---|
| 985 | iff_end = STD_iff |
---|
| 986 | ELSE |
---|
| 987 | iff_beg = 1 |
---|
| 988 | iff_end = nfiles |
---|
| 989 | ENDIF |
---|
[1791] | 990 | |
---|
[1807] | 991 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
[2854] | 992 | IF (.NOT.vars_defined) THEN |
---|
[1821] | 993 | !$OMP MASTER |
---|
[1807] | 994 | !Si phase de définition.... on définit |
---|
[5117] | 995 | IF (.NOT. ok_all_xml) THEN |
---|
[2854] | 996 | IF (prt_level >= 10) THEN |
---|
[5117] | 997 | WRITE(lunout,*)"histwrite2d_phy: .NOT.vars_defined ; time to define ", & |
---|
[3435] | 998 | trim(var%name) |
---|
[2854] | 999 | ENDIF |
---|
[1807] | 1000 | DO iff=iff_beg, iff_end |
---|
| 1001 | IF (clef_files(iff)) THEN |
---|
| 1002 | CALL histdef2d(iff, var) |
---|
| 1003 | ENDIF |
---|
| 1004 | ENDDO |
---|
[2114] | 1005 | ENDIF |
---|
[1821] | 1006 | !$OMP END MASTER |
---|
[3266] | 1007 | !--broadcasting the flags that have been changed in histdef2d on OMP masters |
---|
| 1008 | CALL bcast_omp(swaero_diag) |
---|
| 1009 | CALL bcast_omp(swaerofree_diag) |
---|
| 1010 | CALL bcast_omp(dryaod_diag) |
---|
| 1011 | CALL bcast_omp(ok_4xCO2atm) |
---|
| 1012 | |
---|
[1807] | 1013 | ELSE |
---|
[4619] | 1014 | IF (using_xios) THEN |
---|
| 1015 | IF (ok_all_xml) THEN |
---|
| 1016 | !$omp barrier |
---|
| 1017 | !$omp master |
---|
[5103] | 1018 | is_active = xios_field_is_active(var%name, at_current_timestep_arg=.FALSE.) |
---|
[4619] | 1019 | !$omp end master |
---|
| 1020 | !$omp barrier |
---|
[5117] | 1021 | IF(.NOT. is_active) RETURN |
---|
[4619] | 1022 | ENDIF |
---|
[4103] | 1023 | ENDIF |
---|
[1807] | 1024 | |
---|
| 1025 | !Et sinon on.... écrit |
---|
[4260] | 1026 | IF (SIZE(field)/=klon .AND. SIZE(field)/=klev .AND. SIZE(field)/=klev+1) & |
---|
| 1027 | CALL abort_physic('iophy::histwrite2d_phy',& |
---|
| 1028 | 'Field first DIMENSION not equal to klon/klev',1) |
---|
[2854] | 1029 | IF (prt_level >= 10) THEn |
---|
[5117] | 1030 | WRITE (lunout,*)"histwrite2d_phy: .NOT.vars_defined ; time to gather and write ", trim(var%name) |
---|
[2854] | 1031 | ENDIF |
---|
[1897] | 1032 | |
---|
[3003] | 1033 | |
---|
[5116] | 1034 | IF (SIZE(field) == klon) THEN |
---|
[3003] | 1035 | CALL Gather_omp(field,buffer_omp) |
---|
| 1036 | ELSE |
---|
| 1037 | buffer_omp(:)=0. |
---|
| 1038 | ENDIF |
---|
[1791] | 1039 | !$OMP MASTER |
---|
[3435] | 1040 | IF (grid_type==regular_lonlat) CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
---|
[1897] | 1041 | |
---|
[1791] | 1042 | ! La boucle sur les fichiers: |
---|
[5103] | 1043 | firstx=.TRUE. |
---|
[2114] | 1044 | |
---|
| 1045 | IF (ok_all_xml) THEN |
---|
[4619] | 1046 | IF (using_xios) THEN |
---|
[2854] | 1047 | IF (prt_level >= 10) THEN |
---|
[5116] | 1048 | WRITE(lunout,*)'Dans iophy histwrite2D,var%name ', trim(var%name) |
---|
[2854] | 1049 | ENDIF |
---|
[3435] | 1050 | |
---|
| 1051 | IF (grid_type==regular_lonlat) THEN |
---|
[5116] | 1052 | IF (SIZE(field) == klon) THEN |
---|
[3003] | 1053 | CALL xios_send_field(var%name, Field2d) |
---|
[3435] | 1054 | ELSE |
---|
| 1055 | CALL xios_send_field(var%name, field) |
---|
| 1056 | ENDIF |
---|
| 1057 | ELSE IF (grid_type==unstructured) THEN |
---|
[5116] | 1058 | IF (SIZE(field) == klon) THEN |
---|
[3488] | 1059 | CALL xios_send_field(var%name, buffer_omp) |
---|
| 1060 | ELSE |
---|
| 1061 | CALL xios_send_field(var%name, field) |
---|
| 1062 | ENDIF |
---|
| 1063 | |
---|
[3435] | 1064 | ENDIF |
---|
[2854] | 1065 | IF (prt_level >= 10) THEN |
---|
[5116] | 1066 | WRITE(lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ',& |
---|
[3435] | 1067 | trim(var%name) |
---|
[2854] | 1068 | ENDIF |
---|
[4619] | 1069 | ELSE |
---|
| 1070 | CALL abort_physic ('iophy','cannot have ok_all_xml = .T. without CPP_XIOS defined' ,1) |
---|
| 1071 | ENDIF |
---|
[2114] | 1072 | ELSE |
---|
| 1073 | DO iff=iff_beg, iff_end |
---|
[1791] | 1074 | IF (var%flag(iff) <= lev_files(iff) .AND. clef_files(iff)) THEN |
---|
[2001] | 1075 | |
---|
[4619] | 1076 | IF (using_xios) THEN |
---|
| 1077 | IF (firstx) THEN |
---|
| 1078 | IF (prt_level >= 10) THEN |
---|
[5116] | 1079 | WRITE(lunout,*)'Dans iophy histwrite2D,iff,var%name ',& |
---|
[4619] | 1080 | iff,trim(var%name) |
---|
[5116] | 1081 | WRITE(lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, CALL xios_send_field" |
---|
[4619] | 1082 | ENDIF |
---|
| 1083 | IF (grid_type==regular_lonlat) THEN |
---|
[5116] | 1084 | IF (SIZE(field) == klon) THEN |
---|
[4619] | 1085 | CALL xios_send_field(var%name, Field2d) |
---|
| 1086 | ELSE |
---|
| 1087 | CALL xios_send_field(var%name, field) |
---|
| 1088 | ENDIF |
---|
| 1089 | ELSE IF (grid_type==unstructured) THEN |
---|
[5116] | 1090 | IF (SIZE(field) == klon) THEN |
---|
[4619] | 1091 | CALL xios_send_field(var%name, buffer_omp) |
---|
| 1092 | ELSE |
---|
[3435] | 1093 | CALL xios_send_field(var%name, field) |
---|
[4619] | 1094 | ENDIF |
---|
| 1095 | ENDIF |
---|
[3435] | 1096 | |
---|
[5103] | 1097 | firstx=.FALSE. |
---|
[4619] | 1098 | ENDIF |
---|
| 1099 | ENDIF |
---|
[2001] | 1100 | |
---|
[2854] | 1101 | IF (.NOT.clef_stations(iff)) THEN |
---|
[2344] | 1102 | ALLOCATE(index2d(nbp_lon*jj_nb)) |
---|
| 1103 | ALLOCATE(fieldok(nbp_lon*jj_nb)) |
---|
[2097] | 1104 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[2344] | 1105 | CALL histwrite(nid_files(iff),var%name,itau_iophy,Field2d,nbp_lon*jj_nb,index2d) |
---|
[1852] | 1106 | #endif |
---|
[4619] | 1107 | ! IF (using_xios) THEN |
---|
[2001] | 1108 | ! IF (iff == iff_beg) THEN |
---|
[3435] | 1109 | ! IF (prt_level >= 10) THEN |
---|
[5116] | 1110 | ! WRITE(lunout,*)"histwrite2d_phy: .NOT.clef_stations(iff) and iff==iff_beg, CALL xios_send_field" |
---|
[3435] | 1111 | ! ENDIF |
---|
[2002] | 1112 | ! CALL xios_send_field(var%name, Field2d) |
---|
[2001] | 1113 | ! ENDIF |
---|
[4619] | 1114 | ! ENDIF |
---|
[1791] | 1115 | ELSE |
---|
| 1116 | ALLOCATE(fieldok(npstn)) |
---|
| 1117 | ALLOCATE(index2d(npstn)) |
---|
| 1118 | |
---|
| 1119 | IF (is_sequential) THEN |
---|
[1897] | 1120 | DO ip=1, npstn |
---|
| 1121 | fieldok(ip)=buffer_omp(nptabij(ip)) |
---|
| 1122 | ENDDO |
---|
| 1123 | ELSE |
---|
[1791] | 1124 | DO ip=1, npstn |
---|
[5116] | 1125 | WRITE(lunout,*)'histwrite2d_phy is_sequential npstn ip namenptabij',npstn,ip,var%name,nptabij(ip) |
---|
[5082] | 1126 | IF(nptabij(ip)>=klon_mpi_begin.AND. & |
---|
| 1127 | nptabij(ip)<=klon_mpi_end) THEN |
---|
[1791] | 1128 | fieldok(ip)=buffer_omp(nptabij(ip)-klon_mpi_begin+1) |
---|
| 1129 | ENDIF |
---|
| 1130 | ENDDO |
---|
[1897] | 1131 | ENDIF ! of IF (is_sequential) |
---|
[2097] | 1132 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[3435] | 1133 | IF (prt_level >= 10) THEN |
---|
[5116] | 1134 | WRITE(lunout,*)"histwrite2d_phy: clef_stations(iff) and iff==iff_beg, CALL wxios_write_2D" |
---|
[2854] | 1135 | ENDIF |
---|
[1791] | 1136 | CALL histwrite(nid_files(iff),var%name,itau_iophy,fieldok,npstn,index2d) |
---|
[1852] | 1137 | #endif |
---|
[1897] | 1138 | ENDIF ! of IF(.NOT.clef_stations(iff)) |
---|
[1791] | 1139 | |
---|
[2854] | 1140 | DEALLOCATE(index2d) |
---|
| 1141 | DEALLOCATE(fieldok) |
---|
[1791] | 1142 | ENDIF !levfiles |
---|
[2114] | 1143 | ENDDO ! of DO iff=iff_beg, iff_end |
---|
| 1144 | ENDIF |
---|
[1791] | 1145 | !$OMP END MASTER |
---|
[1807] | 1146 | ENDIF ! vars_defined |
---|
[3266] | 1147 | |
---|
[1897] | 1148 | IF (prt_level >= 10) WRITE(lunout,*)'End histwrite2d_phy ',trim(var%name) |
---|
[3266] | 1149 | |
---|
[1791] | 1150 | END SUBROUTINE histwrite2d_phy |
---|
| 1151 | |
---|
| 1152 | |
---|
| 1153 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
---|
[1807] | 1154 | SUBROUTINE histwrite3d_phy(var, field, STD_iff) |
---|
[3266] | 1155 | |
---|
[5110] | 1156 | USE lmdz_phys_omp_transfert, ONLY: bcast_omp |
---|
[2854] | 1157 | USE dimphy, ONLY: klon, klev |
---|
[5110] | 1158 | USE lmdz_phys_para, ONLY: gather_omp, grid1dto2d_mpi, & |
---|
[1897] | 1159 | jj_nb, klon_mpi, klon_mpi_begin, & |
---|
[3238] | 1160 | klon_mpi_end, is_sequential, is_master |
---|
[2854] | 1161 | USE ioipsl, ONLY: histwrite |
---|
| 1162 | USE phys_output_var_mod, ONLY: ctrl_out, clef_files, lev_files, & |
---|
[1897] | 1163 | nfiles, vars_defined, clef_stations, & |
---|
[3266] | 1164 | nid_files, swaerofree_diag |
---|
[5110] | 1165 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, grid_type, regular_lonlat, unstructured |
---|
[4619] | 1166 | USE lmdz_xios, ONLY: xios_send_field, xios_field_is_active, using_xios |
---|
[5112] | 1167 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[5137] | 1168 | USE lmdz_clesphys |
---|
[1791] | 1169 | |
---|
| 1170 | IMPLICIT NONE |
---|
| 1171 | |
---|
[3266] | 1172 | TYPE(ctrl_out), INTENT(IN) :: var |
---|
| 1173 | REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:) |
---|
| 1174 | INTEGER, INTENT(IN), OPTIONAL :: STD_iff ! ug RUSTINE POUR LES STD LEVS..... |
---|
[1807] | 1175 | |
---|
[3266] | 1176 | INTEGER :: iff, iff_beg, iff_end |
---|
| 1177 | LOGICAL, SAVE :: firstx |
---|
[2001] | 1178 | !$OMP THREADPRIVATE(firstx) |
---|
[3266] | 1179 | REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp |
---|
| 1180 | REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2)) |
---|
| 1181 | INTEGER :: ip, n, nlev, nlevx |
---|
| 1182 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
---|
| 1183 | REAL,ALLOCATABLE, DIMENSION(:,:) :: fieldok |
---|
[5103] | 1184 | logical, save :: is_active = .TRUE. |
---|
[1791] | 1185 | |
---|
[3238] | 1186 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite3d_phy for ', trim(var%name) |
---|
| 1187 | |
---|
[5116] | 1188 | IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite3d ',var%name |
---|
[1791] | 1189 | |
---|
[1828] | 1190 | ! ug RUSTINE POUR LES STD LEVS..... |
---|
| 1191 | IF (PRESENT(STD_iff)) THEN |
---|
| 1192 | iff_beg = STD_iff |
---|
| 1193 | iff_end = STD_iff |
---|
| 1194 | ELSE |
---|
| 1195 | iff_beg = 1 |
---|
| 1196 | iff_end = nfiles |
---|
[2854] | 1197 | ENDIF |
---|
[1828] | 1198 | |
---|
[1807] | 1199 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
[3266] | 1200 | IF (.NOT.vars_defined) THEN |
---|
[1807] | 1201 | !Si phase de définition.... on définit |
---|
[1821] | 1202 | !$OMP MASTER |
---|
[1828] | 1203 | DO iff=iff_beg, iff_end |
---|
[1807] | 1204 | IF (clef_files(iff)) THEN |
---|
| 1205 | CALL histdef3d(iff, var) |
---|
| 1206 | ENDIF |
---|
| 1207 | ENDDO |
---|
[1821] | 1208 | !$OMP END MASTER |
---|
[3266] | 1209 | !--broadcasting the flag that have been changed in histdef3d on OMP masters |
---|
| 1210 | CALL bcast_omp(swaerofree_diag) |
---|
[1807] | 1211 | ELSE |
---|
[4619] | 1212 | IF (using_xios) THEN |
---|
| 1213 | IF (ok_all_xml) THEN |
---|
| 1214 | !$omp barrier |
---|
| 1215 | !$omp master |
---|
[5103] | 1216 | is_active = xios_field_is_active(var%name, at_current_timestep_arg=.FALSE.) |
---|
[4619] | 1217 | !$omp end master |
---|
| 1218 | !$omp barrier |
---|
[5117] | 1219 | IF(.NOT. is_active) RETURN |
---|
[4619] | 1220 | ENDIF |
---|
[4103] | 1221 | ENDIF |
---|
| 1222 | |
---|
[1807] | 1223 | !Et sinon on.... écrit |
---|
[4260] | 1224 | IF (SIZE(field,1)/=klon .AND. SIZE(field,1)/=klev & |
---|
| 1225 | .AND. SIZE(field,1)/=klev+1) & |
---|
| 1226 | CALL abort_physic('iophy::histwrite3d_phy', & |
---|
| 1227 | 'Field first DIMENSION not equal to klon/klev',1) |
---|
[3003] | 1228 | |
---|
[1807] | 1229 | nlev=SIZE(field,2) |
---|
[4228] | 1230 | nlevx=nlev |
---|
| 1231 | ! IF (nlev.EQ.klev+1) THEN |
---|
| 1232 | ! nlevx=klev |
---|
| 1233 | ! ELSE |
---|
| 1234 | ! nlevx=nlev |
---|
| 1235 | ! ENDIF |
---|
[1791] | 1236 | |
---|
[5116] | 1237 | IF (SIZE(field,1) == klon) THEN |
---|
[3003] | 1238 | CALL Gather_omp(field,buffer_omp) |
---|
| 1239 | ELSE |
---|
| 1240 | buffer_omp(:,:)=0. |
---|
| 1241 | ENDIF |
---|
[1791] | 1242 | !$OMP MASTER |
---|
[3435] | 1243 | IF (grid_type==regular_lonlat) CALL grid1Dto2D_mpi(buffer_omp,field3d) |
---|
[1791] | 1244 | |
---|
| 1245 | ! BOUCLE SUR LES FICHIERS |
---|
[5103] | 1246 | firstx=.TRUE. |
---|
[2114] | 1247 | |
---|
[3266] | 1248 | IF (ok_all_xml) THEN |
---|
[4619] | 1249 | IF (using_xios) THEN |
---|
[3435] | 1250 | IF (prt_level >= 10) THEN |
---|
[5116] | 1251 | WRITE(lunout,*)'Dans iophy histwrite3D,var%name ',& |
---|
[3435] | 1252 | trim(var%name) |
---|
| 1253 | ENDIF |
---|
| 1254 | IF (grid_type==regular_lonlat) THEN |
---|
[5116] | 1255 | IF (SIZE(field,1) == klon) THEN |
---|
[3435] | 1256 | CALL xios_send_field(var%name, Field3d(:,:,1:nlevx)) |
---|
| 1257 | ELSE |
---|
| 1258 | CALL xios_send_field(var%name, field) |
---|
| 1259 | ENDIF |
---|
| 1260 | ELSE IF (grid_type==unstructured) THEN |
---|
[5116] | 1261 | IF (SIZE(field,1) == klon) THEN |
---|
[3488] | 1262 | CALL xios_send_field(var%name, buffer_omp(:,1:nlevx)) |
---|
| 1263 | ELSE |
---|
| 1264 | CALL xios_send_field(var%name, field) |
---|
| 1265 | ENDIF |
---|
[3266] | 1266 | ENDIF |
---|
[3435] | 1267 | |
---|
[4619] | 1268 | ELSE |
---|
[2311] | 1269 | CALL abort_physic ('iophy','cannot have ok_all_xml = .T. without CPP_XIOS defined' ,1) |
---|
[4619] | 1270 | ENDIF |
---|
[3266] | 1271 | ELSE |
---|
[2114] | 1272 | |
---|
[3266] | 1273 | DO iff=iff_beg, iff_end |
---|
| 1274 | IF (var%flag(iff) <= lev_files(iff) .AND. clef_files(iff)) THEN |
---|
[4619] | 1275 | IF (using_xios) THEN |
---|
[2001] | 1276 | IF (firstx) THEN |
---|
[3435] | 1277 | IF (prt_level >= 10) THEN |
---|
[5116] | 1278 | WRITE(lunout,*)'Dans iophy, histwrite3D iff nlev klev firstx', & |
---|
[2001] | 1279 | iff,nlev,klev, firstx |
---|
[5116] | 1280 | WRITE(lunout,*)'histwrite3d_phy: CALL xios_send_field for ', & |
---|
[2001] | 1281 | trim(var%name), ' with iim jjm nlevx = ', & |
---|
[2344] | 1282 | nbp_lon,jj_nb,nlevx |
---|
[2854] | 1283 | ENDIF |
---|
[3435] | 1284 | IF (grid_type==regular_lonlat) THEN |
---|
[5116] | 1285 | IF (SIZE(field,1) == klon) THEN |
---|
[3435] | 1286 | CALL xios_send_field(var%name, Field3d(:,:,1:nlevx)) |
---|
| 1287 | ELSE |
---|
| 1288 | CALL xios_send_field(var%name, field) |
---|
| 1289 | ENDIF |
---|
| 1290 | ELSE IF (grid_type==unstructured) THEN |
---|
[5116] | 1291 | IF (SIZE(field,1) == klon) THEN |
---|
[3488] | 1292 | CALL xios_send_field(var%name, buffer_omp(:,1:nlevx)) |
---|
| 1293 | ELSE |
---|
| 1294 | CALL xios_send_field(var%name, field) |
---|
| 1295 | ENDIF |
---|
[3003] | 1296 | ENDIF |
---|
[3435] | 1297 | |
---|
[5103] | 1298 | firstx=.FALSE. |
---|
[2001] | 1299 | ENDIF |
---|
[4619] | 1300 | ENDIF |
---|
| 1301 | |
---|
| 1302 | IF (.NOT.clef_stations(iff)) THEN |
---|
| 1303 | ALLOCATE(index3d(nbp_lon*jj_nb*nlev)) |
---|
| 1304 | ALLOCATE(fieldok(nbp_lon*jj_nb,nlev)) |
---|
[1852] | 1305 | |
---|
[2097] | 1306 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[2344] | 1307 | CALL histwrite(nid_files(iff),var%name,itau_iophy,Field3d,nbp_lon*jj_nb*nlev,index3d) |
---|
[1852] | 1308 | #endif |
---|
[1825] | 1309 | |
---|
[4619] | 1310 | ! IF (using_xios) THEN |
---|
[2001] | 1311 | ! IF (iff == 1) THEN |
---|
[2002] | 1312 | ! CALL xios_send_field(var%name, Field3d(:,:,1:klev)) |
---|
[2001] | 1313 | ! ENDIF |
---|
[4619] | 1314 | ! ENDIF |
---|
[5099] | 1315 | |
---|
[3266] | 1316 | ELSE |
---|
[1791] | 1317 | nlev=size(field,2) |
---|
| 1318 | ALLOCATE(index3d(npstn*nlev)) |
---|
| 1319 | ALLOCATE(fieldok(npstn,nlev)) |
---|
| 1320 | |
---|
| 1321 | IF (is_sequential) THEN |
---|
| 1322 | DO n=1, nlev |
---|
| 1323 | DO ip=1, npstn |
---|
| 1324 | fieldok(ip,n)=buffer_omp(nptabij(ip),n) |
---|
| 1325 | ENDDO |
---|
| 1326 | ENDDO |
---|
| 1327 | ELSE |
---|
| 1328 | DO n=1, nlev |
---|
| 1329 | DO ip=1, npstn |
---|
[5082] | 1330 | IF(nptabij(ip)>=klon_mpi_begin.AND. & |
---|
| 1331 | nptabij(ip)<=klon_mpi_end) THEN |
---|
[1791] | 1332 | fieldok(ip,n)=buffer_omp(nptabij(ip)-klon_mpi_begin+1,n) |
---|
| 1333 | ENDIF |
---|
| 1334 | ENDDO |
---|
| 1335 | ENDDO |
---|
| 1336 | ENDIF |
---|
[2097] | 1337 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
[1791] | 1338 | CALL histwrite(nid_files(iff),var%name,itau_iophy,fieldok,npstn*nlev,index3d) |
---|
[1852] | 1339 | #endif |
---|
[3266] | 1340 | ENDIF |
---|
| 1341 | DEALLOCATE(index3d) |
---|
| 1342 | DEALLOCATE(fieldok) |
---|
| 1343 | ENDIF |
---|
[1791] | 1344 | ENDDO |
---|
[3266] | 1345 | ENDIF |
---|
[1791] | 1346 | !$OMP END MASTER |
---|
[1807] | 1347 | ENDIF ! vars_defined |
---|
[3266] | 1348 | |
---|
[5116] | 1349 | IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite3d ',var%name |
---|
[3266] | 1350 | |
---|
[1791] | 1351 | END SUBROUTINE histwrite3d_phy |
---|
| 1352 | |
---|
[1852] | 1353 | |
---|
| 1354 | ! VERSION DES HISTWRITE DEDIEES AU TOUT-XIOS-XML DEJA UTILISEE DANS PHYDEV |
---|
| 1355 | SUBROUTINE histwrite2d_xios(field_name,field) |
---|
[3266] | 1356 | |
---|
[3003] | 1357 | USE dimphy, ONLY: klon, klev |
---|
[5110] | 1358 | USE lmdz_phys_para, ONLY: gather_omp, grid1Dto2D_mpi, & |
---|
[1897] | 1359 | is_sequential, klon_mpi_begin, klon_mpi_end, & |
---|
[3238] | 1360 | jj_nb, klon_mpi, is_master |
---|
[5110] | 1361 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, grid_type, unstructured |
---|
[4619] | 1362 | USE lmdz_xios, ONLY: xios_send_field |
---|
[5112] | 1363 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[1852] | 1364 | |
---|
| 1365 | IMPLICIT NONE |
---|
| 1366 | |
---|
[3266] | 1367 | CHARACTER(LEN=*), INTENT(IN) :: field_name |
---|
| 1368 | REAL, DIMENSION(:), INTENT(IN) :: field |
---|
[1852] | 1369 | |
---|
[3266] | 1370 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
---|
[5117] | 1371 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index2d |
---|
[3266] | 1372 | REAL :: Field2d(nbp_lon,jj_nb) |
---|
[1852] | 1373 | |
---|
[3266] | 1374 | INTEGER :: ip |
---|
| 1375 | REAL, ALLOCATABLE, DIMENSION(:) :: fieldok |
---|
[1852] | 1376 | |
---|
[3266] | 1377 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite2d_xios for ', field_name |
---|
[3238] | 1378 | |
---|
[3266] | 1379 | IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite2d_xios ',field_name |
---|
[1852] | 1380 | |
---|
[3474] | 1381 | !Et sinon on.... écrit |
---|
| 1382 | IF (SIZE(field)/=klon .AND. SIZE(field)/=klev .AND. SIZE(field)/=klev+1) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon/klev',1) |
---|
[5116] | 1383 | IF (SIZE(field) == klev .OR. SIZE(field) == klev+1) THEN |
---|
[1852] | 1384 | !$OMP MASTER |
---|
[3488] | 1385 | |
---|
[3003] | 1386 | CALL xios_send_field(field_name,field) |
---|
| 1387 | !$OMP END MASTER |
---|
[3266] | 1388 | ELSE |
---|
[3003] | 1389 | CALL Gather_omp(field,buffer_omp) |
---|
| 1390 | !$OMP MASTER |
---|
[3435] | 1391 | |
---|
| 1392 | IF (grid_type==unstructured) THEN |
---|
| 1393 | |
---|
| 1394 | CALL xios_send_field(field_name, buffer_omp) |
---|
| 1395 | |
---|
| 1396 | ELSE |
---|
| 1397 | |
---|
[3003] | 1398 | CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
---|
[1852] | 1399 | |
---|
| 1400 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 1401 | !ATTENTION, STATIONS PAS GEREES ! |
---|
| 1402 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 1403 | !IF(.NOT.clef_stations(iff)) THEN |
---|
[3003] | 1404 | IF (.TRUE.) THEN |
---|
| 1405 | |
---|
| 1406 | CALL xios_send_field(field_name, Field2d) |
---|
| 1407 | |
---|
| 1408 | ELSE |
---|
| 1409 | ALLOCATE(fieldok(npstn)) |
---|
| 1410 | ALLOCATE(index2d(npstn)) |
---|
| 1411 | |
---|
| 1412 | IF (is_sequential) THEN |
---|
| 1413 | DO ip=1, npstn |
---|
| 1414 | fieldok(ip)=buffer_omp(nptabij(ip)) |
---|
| 1415 | ENDDO |
---|
| 1416 | ELSE |
---|
| 1417 | DO ip=1, npstn |
---|
| 1418 | PRINT*,'histwrite2d_xios is_sequential npstn ip namenptabij',npstn,ip,field_name,nptabij(ip) |
---|
[5082] | 1419 | IF(nptabij(ip)>=klon_mpi_begin.AND. & |
---|
| 1420 | nptabij(ip)<=klon_mpi_end) THEN |
---|
[3003] | 1421 | fieldok(ip)=buffer_omp(nptabij(ip)-klon_mpi_begin+1) |
---|
| 1422 | ENDIF |
---|
| 1423 | ENDDO |
---|
| 1424 | ENDIF |
---|
[3435] | 1425 | DEALLOCATE(index2d) |
---|
| 1426 | DEALLOCATE(fieldok) |
---|
[3003] | 1427 | |
---|
[3435] | 1428 | ENDIF |
---|
| 1429 | ENDIF |
---|
[1852] | 1430 | !$OMP END MASTER |
---|
[3266] | 1431 | ENDIF |
---|
[1852] | 1432 | |
---|
[1897] | 1433 | IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite2d_xios ',field_name |
---|
[1852] | 1434 | END SUBROUTINE histwrite2d_xios |
---|
| 1435 | |
---|
| 1436 | |
---|
| 1437 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
---|
| 1438 | SUBROUTINE histwrite3d_xios(field_name, field) |
---|
[3266] | 1439 | |
---|
[2854] | 1440 | USE dimphy, ONLY: klon, klev |
---|
[5110] | 1441 | USE lmdz_phys_para, ONLY: gather_omp, grid1Dto2D_mpi, & |
---|
[1897] | 1442 | is_sequential, klon_mpi_begin, klon_mpi_end, & |
---|
[3238] | 1443 | jj_nb, klon_mpi, is_master |
---|
[4619] | 1444 | USE lmdz_xios, ONLY: xios_send_field |
---|
[5110] | 1445 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, grid_type, unstructured |
---|
[5112] | 1446 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[1852] | 1447 | |
---|
| 1448 | IMPLICIT NONE |
---|
| 1449 | |
---|
[3266] | 1450 | CHARACTER(LEN=*), INTENT(IN) :: field_name |
---|
| 1451 | REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:) |
---|
[1852] | 1452 | |
---|
[3266] | 1453 | REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp |
---|
| 1454 | REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2)) |
---|
| 1455 | INTEGER :: ip, n, nlev |
---|
| 1456 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
---|
| 1457 | REAL,ALLOCATABLE, DIMENSION(:,:) :: fieldok |
---|
[1852] | 1458 | |
---|
[3266] | 1459 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite3d_xios for ', field_name |
---|
[1852] | 1460 | |
---|
[5116] | 1461 | IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite3d_xios ',field_name |
---|
[3238] | 1462 | |
---|
[3474] | 1463 | !Et on.... écrit |
---|
[5116] | 1464 | IF (SIZE(field,1)/=klon .AND. SIZE(field,1)/=klev .AND. SIZE(field,1)/=klev+1) THEN |
---|
| 1465 | WRITE(lunout,*)' histrwrite3d_xios ', field_name, SIZE(field) |
---|
[3474] | 1466 | CALL abort_physic('iophy::histwrite3d_xios','Field first DIMENSION not equal to klon/klev',1) |
---|
| 1467 | ENDIF |
---|
[3003] | 1468 | |
---|
[5116] | 1469 | IF (SIZE(field,1) == klev .OR. SIZE(field,1) == klev+1) THEN |
---|
[3003] | 1470 | !$OMP MASTER |
---|
| 1471 | CALL xios_send_field(field_name,field) |
---|
| 1472 | !$OMP END MASTER |
---|
[3266] | 1473 | ELSE |
---|
[3003] | 1474 | nlev=SIZE(field,2) |
---|
[1852] | 1475 | |
---|
| 1476 | |
---|
[3003] | 1477 | CALL Gather_omp(field,buffer_omp) |
---|
[1852] | 1478 | !$OMP MASTER |
---|
[3435] | 1479 | |
---|
| 1480 | IF (grid_type==unstructured) THEN |
---|
| 1481 | |
---|
| 1482 | CALL xios_send_field(field_name, buffer_omp(:,1:nlev)) |
---|
| 1483 | |
---|
| 1484 | ELSE |
---|
[3003] | 1485 | CALL grid1Dto2D_mpi(buffer_omp,field3d) |
---|
[1852] | 1486 | |
---|
| 1487 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 1488 | !ATTENTION, STATIONS PAS GEREES ! |
---|
| 1489 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 1490 | !IF (.NOT.clef_stations(iff)) THEN |
---|
[3003] | 1491 | IF(.TRUE.)THEN |
---|
[3435] | 1492 | |
---|
| 1493 | CALL xios_send_field(field_name, Field3d(:,:,1:nlev)) |
---|
[3003] | 1494 | |
---|
| 1495 | ELSE |
---|
| 1496 | nlev=size(field,2) |
---|
| 1497 | ALLOCATE(index3d(npstn*nlev)) |
---|
| 1498 | ALLOCATE(fieldok(npstn,nlev)) |
---|
| 1499 | |
---|
| 1500 | IF (is_sequential) THEN |
---|
| 1501 | DO n=1, nlev |
---|
| 1502 | DO ip=1, npstn |
---|
| 1503 | fieldok(ip,n)=buffer_omp(nptabij(ip),n) |
---|
| 1504 | ENDDO |
---|
[1852] | 1505 | ENDDO |
---|
[3003] | 1506 | ELSE |
---|
| 1507 | DO n=1, nlev |
---|
| 1508 | DO ip=1, npstn |
---|
[5082] | 1509 | IF(nptabij(ip)>=klon_mpi_begin.AND. & |
---|
| 1510 | nptabij(ip)<=klon_mpi_end) THEN |
---|
[3003] | 1511 | fieldok(ip,n)=buffer_omp(nptabij(ip)-klon_mpi_begin+1,n) |
---|
| 1512 | ENDIF |
---|
| 1513 | ENDDO |
---|
[1852] | 1514 | ENDDO |
---|
[3003] | 1515 | ENDIF |
---|
[3435] | 1516 | DEALLOCATE(index3d) |
---|
| 1517 | DEALLOCATE(fieldok) |
---|
[3003] | 1518 | ENDIF |
---|
[3435] | 1519 | ENDIF |
---|
[1852] | 1520 | !$OMP END MASTER |
---|
[3266] | 1521 | ENDIF |
---|
[1852] | 1522 | |
---|
[5116] | 1523 | IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite3d_xios ',field_name |
---|
[3266] | 1524 | |
---|
[1852] | 1525 | END SUBROUTINE histwrite3d_xios |
---|
[2645] | 1526 | |
---|
| 1527 | SUBROUTINE histwrite0d_xios(field_name, field) |
---|
[4619] | 1528 | USE lmdz_xios, ONLY: xios_send_field |
---|
[5110] | 1529 | USE lmdz_phys_para, ONLY: is_master |
---|
[5112] | 1530 | USE lmdz_print_control, ONLY: prt_level,lunout |
---|
[4848] | 1531 | USE phys_output_var_mod, ONLY: vars_defined |
---|
| 1532 | |
---|
[2645] | 1533 | IMPLICIT NONE |
---|
| 1534 | |
---|
[3266] | 1535 | CHARACTER(LEN=*), INTENT(IN) :: field_name |
---|
| 1536 | REAL, INTENT(IN) :: field ! --> scalar |
---|
[2645] | 1537 | |
---|
[3266] | 1538 | IF (check_dim .AND. is_master) WRITE(lunout,*)'histwrite0d_xios for ', field_name |
---|
[3238] | 1539 | |
---|
[4848] | 1540 | IF (vars_defined) THEN |
---|
[2645] | 1541 | !$OMP MASTER |
---|
[4848] | 1542 | CALL xios_send_field(field_name, field) |
---|
[2645] | 1543 | !$OMP END MASTER |
---|
[4848] | 1544 | ENDIF |
---|
[2645] | 1545 | |
---|
| 1546 | END SUBROUTINE histwrite0d_xios |
---|
[2660] | 1547 | |
---|
[3266] | 1548 | END MODULE iophy |
---|