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