[544] | 1 | MODULE iom |
---|
[9019] | 2 | !!====================================================================== |
---|
[544] | 3 | !! *** MODULE iom *** |
---|
| 4 | !! Input/Output manager : Library to read input files |
---|
[9019] | 5 | !!====================================================================== |
---|
[3764] | 6 | !! History : 2.0 ! 2005-12 (J. Belier) Original code |
---|
| 7 | !! 2.0 ! 2006-02 (S. Masson) Adaptation to NEMO |
---|
| 8 | !! 3.0 ! 2007-07 (D. Storkey) Changes to iom_gettime |
---|
| 9 | !! 3.4 ! 2012-12 (R. Bourdalle-Badie and G. Reffray) add C1D case |
---|
[6140] | 10 | !! 3.6 ! 2014-15 DIMG format removed |
---|
[7646] | 11 | !! 3.6 ! 2015-15 (J. Harle) Added procedure to read REAL attributes |
---|
[9019] | 12 | !! 4.0 ! 2017-11 (M. Andrejczuk) Extend IOM interface to write any 3D fields |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
[544] | 14 | |
---|
[9019] | 15 | !!---------------------------------------------------------------------- |
---|
[544] | 16 | !! iom_open : open a file read only |
---|
| 17 | !! iom_close : close a file or all files opened by iom |
---|
| 18 | !! iom_get : read a field (interfaced to several routines) |
---|
| 19 | !! iom_varid : get the id of a variable in a file |
---|
| 20 | !! iom_rstput : write a field in a restart file (interfaced to several routines) |
---|
[9019] | 21 | !!---------------------------------------------------------------------- |
---|
[544] | 22 | USE dom_oce ! ocean space and time domain |
---|
[3764] | 23 | USE c1d ! 1D vertical configuration |
---|
[3294] | 24 | USE flo_oce ! floats module declarations |
---|
[679] | 25 | USE lbclnk ! lateal boundary condition / mpp exchanges |
---|
[544] | 26 | USE iom_def ! iom variables definitions |
---|
| 27 | USE iom_nf90 ! NetCDF format with native NetCDF library |
---|
[2715] | 28 | USE in_out_manager ! I/O manager |
---|
| 29 | USE lib_mpp ! MPP library |
---|
[1412] | 30 | #if defined key_iomput |
---|
[12377] | 31 | USE sbc_oce , ONLY : nn_fsbc, ght_abl, ghw_abl, e3t_abl, e3w_abl, jpka, jpkam1 |
---|
[9019] | 32 | USE icb_oce , ONLY : nclasses, class_num ! !: iceberg classes |
---|
[9570] | 33 | #if defined key_si3 |
---|
[9019] | 34 | USE ice , ONLY : jpl |
---|
[4691] | 35 | #endif |
---|
[1725] | 36 | USE domngb ! ocean space and time domain |
---|
| 37 | USE phycst ! physical constants |
---|
| 38 | USE dianam ! build name of file |
---|
[3695] | 39 | USE xios |
---|
[1359] | 40 | # endif |
---|
[4148] | 41 | USE ioipsl, ONLY : ju2ymds ! for calendar |
---|
[4152] | 42 | USE crs ! Grid coarsening |
---|
[10222] | 43 | #if defined key_top |
---|
| 44 | USE trc, ONLY : profsed |
---|
| 45 | #endif |
---|
[9367] | 46 | USE lib_fortran |
---|
[12377] | 47 | USE diu_bulk, ONLY : ln_diurnal_only, ln_diurnal |
---|
[12950] | 48 | USE iom_nf90 |
---|
| 49 | USE netcdf |
---|
[1359] | 50 | |
---|
[544] | 51 | IMPLICIT NONE |
---|
[556] | 52 | PUBLIC ! must be public to be able to access iom_def through iom |
---|
[550] | 53 | |
---|
[1457] | 54 | #if defined key_iomput |
---|
[1725] | 55 | LOGICAL, PUBLIC, PARAMETER :: lk_iomput = .TRUE. !: iom_put flag |
---|
[1457] | 56 | #else |
---|
| 57 | LOGICAL, PUBLIC, PARAMETER :: lk_iomput = .FALSE. !: iom_put flag |
---|
| 58 | #endif |
---|
[12377] | 59 | PUBLIC iom_init, iom_init_closedef, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_get_var |
---|
[10522] | 60 | PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_getszuld, iom_rstput, iom_delay_rst, iom_put |
---|
[12377] | 61 | PUBLIC iom_use, iom_context_finalize, iom_update_file_name, iom_miss_val |
---|
[544] | 62 | |
---|
[752] | 63 | PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d |
---|
| 64 | PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_get_123d |
---|
[12276] | 65 | PRIVATE iom_p1d, iom_p2d, iom_p3d, iom_p4d |
---|
[1412] | 66 | #if defined key_iomput |
---|
[4148] | 67 | PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr |
---|
[12377] | 68 | PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_sdate |
---|
[13023] | 69 | PRIVATE iom_set_rst_context, iom_set_vars_active |
---|
[1359] | 70 | # endif |
---|
[12950] | 71 | PRIVATE iom_set_rstw_active |
---|
[752] | 72 | |
---|
[544] | 73 | INTERFACE iom_get |
---|
[550] | 74 | MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d |
---|
[544] | 75 | END INTERFACE |
---|
[2528] | 76 | INTERFACE iom_getatt |
---|
[10425] | 77 | MODULE PROCEDURE iom_g0d_iatt, iom_g1d_iatt, iom_g0d_ratt, iom_g1d_ratt, iom_g0d_catt |
---|
[2528] | 78 | END INTERFACE |
---|
[7646] | 79 | INTERFACE iom_putatt |
---|
[10425] | 80 | MODULE PROCEDURE iom_p0d_iatt, iom_p1d_iatt, iom_p0d_ratt, iom_p1d_ratt, iom_p0d_catt |
---|
[7646] | 81 | END INTERFACE |
---|
[544] | 82 | INTERFACE iom_rstput |
---|
[550] | 83 | MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d |
---|
[544] | 84 | END INTERFACE |
---|
[9802] | 85 | INTERFACE iom_put |
---|
[12276] | 86 | MODULE PROCEDURE iom_p0d, iom_p1d, iom_p2d, iom_p3d, iom_p4d |
---|
[9802] | 87 | END INTERFACE iom_put |
---|
| 88 | |
---|
[12377] | 89 | !! * Substitutions |
---|
| 90 | # include "do_loop_substitute.h90" |
---|
[544] | 91 | !!---------------------------------------------------------------------- |
---|
[9598] | 92 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
[1152] | 93 | !! $Id$ |
---|
[10068] | 94 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[544] | 95 | !!---------------------------------------------------------------------- |
---|
| 96 | CONTAINS |
---|
| 97 | |
---|
[12961] | 98 | SUBROUTINE iom_init( cdname, fname, idfp, ld_tmppatch, ld_closedef ) |
---|
[1359] | 99 | !!---------------------------------------------------------------------- |
---|
| 100 | !! *** ROUTINE *** |
---|
| 101 | !! |
---|
| 102 | !! ** Purpose : |
---|
| 103 | !! |
---|
| 104 | !!---------------------------------------------------------------------- |
---|
[9903] | 105 | CHARACTER(len=*), INTENT(in) :: cdname |
---|
[9367] | 106 | CHARACTER(len=*), OPTIONAL, INTENT(in) :: fname |
---|
[12961] | 107 | INTEGER , OPTIONAL, INTENT(in) :: idfp ! pointer to netcdf file for restart reading with XIOS |
---|
[9903] | 108 | LOGICAL , OPTIONAL, INTENT(in) :: ld_tmppatch |
---|
[12377] | 109 | LOGICAL , OPTIONAL, INTENT(in) :: ld_closedef |
---|
[1412] | 110 | #if defined key_iomput |
---|
[9019] | 111 | ! |
---|
[7646] | 112 | TYPE(xios_duration) :: dtime = xios_duration(0, 0, 0, 0, 0, 0) |
---|
| 113 | TYPE(xios_date) :: start_date |
---|
[9367] | 114 | CHARACTER(len=lc) :: clname |
---|
[12276] | 115 | INTEGER :: irefyear, irefmonth, irefday |
---|
[12597] | 116 | INTEGER :: ji |
---|
[12957] | 117 | LOGICAL :: llrst_context ! is context related to restart |
---|
[12961] | 118 | LOGICAL :: llrstr, llrstw |
---|
[12957] | 119 | INTEGER :: inum |
---|
[5415] | 120 | ! |
---|
[7646] | 121 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds |
---|
[12377] | 122 | REAL(wp), DIMENSION(2,jpkam1) :: za_bnds ! ABL vertical boundaries |
---|
[9903] | 123 | LOGICAL :: ll_tmppatch = .TRUE. !: seb: patch before we remove periodicity |
---|
| 124 | INTEGER :: nldi_save, nlei_save !: and close boundaries in output files |
---|
| 125 | INTEGER :: nldj_save, nlej_save !: |
---|
[12914] | 126 | LOGICAL :: ll_closedef |
---|
[1359] | 127 | !!---------------------------------------------------------------------- |
---|
[9019] | 128 | ! |
---|
[9802] | 129 | ! seb: patch before we remove periodicity and close boundaries in output files |
---|
[9903] | 130 | IF( PRESENT(ld_tmppatch) ) THEN ; ll_tmppatch = ld_tmppatch |
---|
| 131 | ELSE ; ll_tmppatch = .TRUE. |
---|
| 132 | ENDIF |
---|
| 133 | IF ( ll_tmppatch ) THEN |
---|
[9802] | 134 | nldi_save = nldi ; nlei_save = nlei |
---|
| 135 | nldj_save = nldj ; nlej_save = nlej |
---|
| 136 | IF( nimpp == 1 ) nldi = 1 |
---|
| 137 | IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi |
---|
| 138 | IF( njmpp == 1 ) nldj = 1 |
---|
| 139 | IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj |
---|
| 140 | ENDIF |
---|
[12914] | 141 | ! |
---|
| 142 | ll_closedef = .TRUE. |
---|
[12377] | 143 | IF ( PRESENT(ld_closedef) ) ll_closedef = ld_closedef |
---|
[9802] | 144 | ! |
---|
[7646] | 145 | ALLOCATE( zt_bnds(2,jpk), zw_bnds(2,jpk) ) |
---|
[9019] | 146 | ! |
---|
[12957] | 147 | IF(lwp) write(numout, *) 'TEST IOM_INIT: ', TRIM(cdname),' File: ', TRIM(fname) |
---|
| 148 | IF(lwp) CALL FLUSH(numout) |
---|
[4152] | 149 | clname = cdname |
---|
| 150 | IF( TRIM(Agrif_CFixed()) /= '0' ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname) |
---|
[9570] | 151 | CALL xios_context_initialize(TRIM(clname), mpi_comm_oce) |
---|
[4152] | 152 | CALL iom_swap( cdname ) |
---|
[1359] | 153 | |
---|
[12961] | 154 | llrstr = (TRIM(cdname) == TRIM(crxios_context)) .OR. (TRIM(cdname) == TRIM(crixios_context)) |
---|
| 155 | llrstr = llrstr .OR. (TRIM(cdname) == TRIM(crtxios_context)) |
---|
| 156 | llrstr = llrstr .OR. (TRIM(cdname) == TRIM(crsxios_context)) |
---|
| 157 | |
---|
| 158 | llrstw = (TRIM(cdname) == TRIM(cwxios_context)) .OR. (TRIM(cdname) == TRIM(cwixios_context)) |
---|
| 159 | llrstw = llrstw .OR. (TRIM(cdname) == TRIM(cwtxios_context)) |
---|
| 160 | llrstw = llrstw .OR. (TRIM(cdname) == TRIM(cwsxios_context)) |
---|
| 161 | |
---|
| 162 | llrst_context = llrstr .OR. llrstw |
---|
| 163 | |
---|
[7646] | 164 | ! Calendar type is now defined in xml file |
---|
[12276] | 165 | IF (.NOT.(xios_getvar('ref_year' ,irefyear ))) irefyear = 1900 |
---|
| 166 | IF (.NOT.(xios_getvar('ref_month',irefmonth))) irefmonth = 01 |
---|
| 167 | IF (.NOT.(xios_getvar('ref_day' ,irefday ))) irefday = 01 |
---|
| 168 | |
---|
[1725] | 169 | SELECT CASE ( nleapy ) ! Choose calendar for IOIPSL |
---|
[12276] | 170 | CASE ( 1) ; CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(irefyear,irefmonth,irefday,00,00,00), & |
---|
[7646] | 171 | & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) |
---|
[12276] | 172 | CASE ( 0) ; CALL xios_define_calendar( TYPE = "NoLeap" , time_origin = xios_date(irefyear,irefmonth,irefday,00,00,00), & |
---|
[7646] | 173 | & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) |
---|
[12276] | 174 | CASE (30) ; CALL xios_define_calendar( TYPE = "D360" , time_origin = xios_date(irefyear,irefmonth,irefday,00,00,00), & |
---|
[7646] | 175 | & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) |
---|
[1725] | 176 | END SELECT |
---|
[1359] | 177 | |
---|
| 178 | ! horizontal grid definition |
---|
[9367] | 179 | IF(.NOT.llrst_context) CALL set_scalar |
---|
[9019] | 180 | ! |
---|
[5407] | 181 | IF( TRIM(cdname) == TRIM(cxios_context) ) THEN |
---|
[9984] | 182 | CALL set_grid( "T", glamt, gphit, .FALSE., .FALSE. ) |
---|
| 183 | CALL set_grid( "U", glamu, gphiu, .FALSE., .FALSE. ) |
---|
| 184 | CALL set_grid( "V", glamv, gphiv, .FALSE., .FALSE. ) |
---|
| 185 | CALL set_grid( "W", glamt, gphit, .FALSE., .FALSE. ) |
---|
[5385] | 186 | CALL set_grid_znl( gphit ) |
---|
[5415] | 187 | ! |
---|
| 188 | IF( ln_cfmeta ) THEN ! Add additional grid metadata |
---|
[5836] | 189 | CALL iom_set_domain_attr("grid_T", area = e1e2t(nldi:nlei, nldj:nlej)) |
---|
| 190 | CALL iom_set_domain_attr("grid_U", area = e1e2u(nldi:nlei, nldj:nlej)) |
---|
| 191 | CALL iom_set_domain_attr("grid_V", area = e1e2v(nldi:nlei, nldj:nlej)) |
---|
| 192 | CALL iom_set_domain_attr("grid_W", area = e1e2t(nldi:nlei, nldj:nlej)) |
---|
[5415] | 193 | CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit ) |
---|
| 194 | CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu ) |
---|
| 195 | CALL set_grid_bounds( "V", glamu, gphiu, glamv, gphiv ) |
---|
| 196 | CALL set_grid_bounds( "W", glamf, gphif, glamt, gphit ) |
---|
| 197 | ENDIF |
---|
[4152] | 198 | ENDIF |
---|
[9019] | 199 | ! |
---|
[5407] | 200 | IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN |
---|
[4152] | 201 | CALL dom_grid_crs ! Save the parent grid information & Switch to coarse grid domain |
---|
| 202 | ! |
---|
[9984] | 203 | CALL set_grid( "T", glamt_crs, gphit_crs, .FALSE., .FALSE. ) |
---|
| 204 | CALL set_grid( "U", glamu_crs, gphiu_crs, .FALSE., .FALSE. ) |
---|
| 205 | CALL set_grid( "V", glamv_crs, gphiv_crs, .FALSE., .FALSE. ) |
---|
| 206 | CALL set_grid( "W", glamt_crs, gphit_crs, .FALSE., .FALSE. ) |
---|
[5385] | 207 | CALL set_grid_znl( gphit_crs ) |
---|
[4152] | 208 | ! |
---|
| 209 | CALL dom_grid_glo ! Return to parent grid domain |
---|
[5415] | 210 | ! |
---|
[9367] | 211 | IF( ln_cfmeta .AND. .NOT. llrst_context) THEN ! Add additional grid metadata |
---|
[5415] | 212 | CALL iom_set_domain_attr("grid_T", area = e1e2t_crs(nldi:nlei, nldj:nlej)) |
---|
| 213 | CALL iom_set_domain_attr("grid_U", area = e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej)) |
---|
| 214 | CALL iom_set_domain_attr("grid_V", area = e1v_crs(nldi:nlei, nldj:nlej) * e2v_crs(nldi:nlei, nldj:nlej)) |
---|
| 215 | CALL iom_set_domain_attr("grid_W", area = e1e2t_crs(nldi:nlei, nldj:nlej)) |
---|
| 216 | CALL set_grid_bounds( "T", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) |
---|
| 217 | CALL set_grid_bounds( "U", glamv_crs, gphiv_crs, glamu_crs, gphiu_crs ) |
---|
| 218 | CALL set_grid_bounds( "V", glamu_crs, gphiu_crs, glamv_crs, gphiv_crs ) |
---|
| 219 | CALL set_grid_bounds( "W", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) |
---|
| 220 | ENDIF |
---|
[4152] | 221 | ENDIF |
---|
[9019] | 222 | ! |
---|
[1359] | 223 | ! vertical grid definition |
---|
[9367] | 224 | IF(.NOT.llrst_context) THEN |
---|
[12377] | 225 | CALL iom_set_axis_attr( "deptht", paxis = gdept_1d ) |
---|
| 226 | CALL iom_set_axis_attr( "depthu", paxis = gdept_1d ) |
---|
| 227 | CALL iom_set_axis_attr( "depthv", paxis = gdept_1d ) |
---|
| 228 | CALL iom_set_axis_attr( "depthw", paxis = gdepw_1d ) |
---|
[9367] | 229 | |
---|
[12377] | 230 | ! ABL |
---|
| 231 | IF( .NOT. ALLOCATED(ght_abl) ) THEN ! force definition for xml files (xios) |
---|
| 232 | ALLOCATE( ght_abl(jpka), ghw_abl(jpka), e3t_abl(jpka), e3w_abl(jpka) ) ! default allocation needed by iom |
---|
| 233 | ght_abl(:) = -1._wp ; ghw_abl(:) = -1._wp |
---|
| 234 | e3t_abl(:) = -1._wp ; e3w_abl(:) = -1._wp |
---|
| 235 | ENDIF |
---|
| 236 | CALL iom_set_axis_attr( "ght_abl", ght_abl(2:jpka) ) |
---|
| 237 | CALL iom_set_axis_attr( "ghw_abl", ghw_abl(2:jpka) ) |
---|
| 238 | |
---|
[9367] | 239 | ! Add vertical grid bounds |
---|
[12597] | 240 | zt_bnds(2,: ) = gdept_1d(:) |
---|
| 241 | zt_bnds(1,2:jpk ) = gdept_1d(1:jpkm1) |
---|
| 242 | zt_bnds(1,1 ) = gdept_1d(1) - e3w_1d(1) |
---|
| 243 | zw_bnds(1,: ) = gdepw_1d(:) |
---|
| 244 | zw_bnds(2,1:jpkm1) = gdepw_1d(2:jpk) |
---|
| 245 | zw_bnds(2,jpk: ) = gdepw_1d(jpk) + e3t_1d(jpk) |
---|
[12377] | 246 | CALL iom_set_axis_attr( "deptht", bounds=zw_bnds ) |
---|
| 247 | CALL iom_set_axis_attr( "depthu", bounds=zw_bnds ) |
---|
| 248 | CALL iom_set_axis_attr( "depthv", bounds=zw_bnds ) |
---|
| 249 | CALL iom_set_axis_attr( "depthw", bounds=zt_bnds ) |
---|
| 250 | |
---|
| 251 | ! ABL |
---|
| 252 | za_bnds(1,:) = ghw_abl(1:jpkam1) |
---|
| 253 | za_bnds(2,:) = ghw_abl(2:jpka ) |
---|
| 254 | CALL iom_set_axis_attr( "ght_abl", bounds=za_bnds ) |
---|
| 255 | za_bnds(1,:) = ght_abl(2:jpka ) |
---|
| 256 | za_bnds(2,:) = ght_abl(2:jpka ) + e3w_abl(2:jpka) |
---|
| 257 | CALL iom_set_axis_attr( "ghw_abl", bounds=za_bnds ) |
---|
| 258 | |
---|
[9580] | 259 | CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,jpnfl) /) ) |
---|
[9570] | 260 | # if defined key_si3 |
---|
[9367] | 261 | CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) ) |
---|
| 262 | ! SIMIP diagnostics (4 main arctic straits) |
---|
| 263 | CALL iom_set_axis_attr( "nstrait", (/ (REAL(ji,wp), ji=1,4) /) ) |
---|
[9019] | 264 | # endif |
---|
[10222] | 265 | #if defined key_top |
---|
[10817] | 266 | IF( ALLOCATED(profsed) ) CALL iom_set_axis_attr( "profsed", paxis = profsed ) |
---|
[10222] | 267 | #endif |
---|
[9367] | 268 | CALL iom_set_axis_attr( "icbcla", class_num ) |
---|
[10817] | 269 | CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) ) ! strange syntaxe and idea... |
---|
[12276] | 270 | CALL iom_set_axis_attr( "iax_26C", (/ REAL(26,wp) /) ) ! strange syntaxe and idea... |
---|
[10817] | 271 | CALL iom_set_axis_attr( "iax_28C", (/ REAL(28,wp) /) ) ! strange syntaxe and idea... |
---|
[12276] | 272 | CALL iom_set_axis_attr( "basin" , (/ (REAL(ji,wp), ji=1,5) /) ) |
---|
[9367] | 273 | ENDIF |
---|
| 274 | ! |
---|
[1725] | 275 | ! automatic definitions of some of the xml attributs |
---|
[12957] | 276 | IF(lwp) write(numout, *) 'TEST IOM_INIT: ', TRIM(cdname), TRIM(cdname) == TRIM(crixios_context) |
---|
| 277 | IF(lwp) CALL FLUSH(numout) |
---|
[12961] | 278 | IF(llrstr) THEN |
---|
| 279 | IF(PRESENT(idfp)) THEN |
---|
| 280 | CALL iom_set_rst_context(.TRUE.) |
---|
| 281 | !set which fields will be read from restart file |
---|
[13023] | 282 | CALL iom_set_vars_active(fname, idfp) |
---|
[12957] | 283 | ELSE |
---|
[12961] | 284 | CALL ctl_stop( 'iom_init:', 'restart read with XIOS: missing pointer to NETCDF file' ) |
---|
[12957] | 285 | ENDIF |
---|
[12961] | 286 | ELSE IF(llrstw) THEN |
---|
[12950] | 287 | CALL iom_set_rstw_file(fname) |
---|
[9367] | 288 | ELSE |
---|
| 289 | CALL set_xmlatt |
---|
| 290 | ENDIF |
---|
[9019] | 291 | ! |
---|
[12377] | 292 | ! set time step length |
---|
[12489] | 293 | dtime%second = rn_Dt |
---|
[9019] | 294 | CALL xios_set_timestep( dtime ) |
---|
| 295 | ! |
---|
[12377] | 296 | ! conditional closure of context definition |
---|
| 297 | IF ( ll_closedef ) CALL iom_init_closedef |
---|
| 298 | ! |
---|
[7646] | 299 | DEALLOCATE( zt_bnds, zw_bnds ) |
---|
[9019] | 300 | ! |
---|
[9903] | 301 | IF ( ll_tmppatch ) THEN |
---|
[9802] | 302 | nldi = nldi_save ; nlei = nlei_save |
---|
| 303 | nldj = nldj_save ; nlej = nlej_save |
---|
| 304 | ENDIF |
---|
[1359] | 305 | #endif |
---|
[9019] | 306 | ! |
---|
[1359] | 307 | END SUBROUTINE iom_init |
---|
| 308 | |
---|
[12950] | 309 | SUBROUTINE iom_init_closedef(cdname) |
---|
[12377] | 310 | !!---------------------------------------------------------------------- |
---|
| 311 | !! *** SUBROUTINE iom_init_closedef *** |
---|
| 312 | !!---------------------------------------------------------------------- |
---|
| 313 | !! |
---|
| 314 | !! ** Purpose : Closure of context definition |
---|
| 315 | !! |
---|
| 316 | !!---------------------------------------------------------------------- |
---|
[12950] | 317 | CHARACTER(len=*), OPTIONAL, INTENT(IN) :: cdname |
---|
| 318 | #if defined key_iomput |
---|
[12957] | 319 | LOGICAL :: llrstw |
---|
| 320 | |
---|
| 321 | IF(lwp) write(numout, *) 'XIOS CLOSE definitions for: ', TRIM(cdname) |
---|
| 322 | llrstw = .FALSE. |
---|
[12961] | 323 | IF(PRESENT(cdname)) THEN |
---|
| 324 | llrstw = (TRIM(cdname) == TRIM(cwxios_context)) |
---|
| 325 | llrstw = llrstw .OR. (TRIM(cdname) == TRIM(cwixios_context)) |
---|
| 326 | llrstw = llrstw .OR. (TRIM(cdname) == TRIM(cwtxios_context)) |
---|
| 327 | llrstw = llrstw .OR. (TRIM(cdname) == TRIM(cwsxios_context)) |
---|
[12957] | 328 | ENDIF |
---|
| 329 | |
---|
| 330 | IF( llrstw ) THEN |
---|
[12950] | 331 | !set names of the fields in restart file IF using XIOS to write data |
---|
| 332 | CALL iom_set_rst_context(.FALSE.) |
---|
[12961] | 333 | CALL xios_close_context_definition() |
---|
| 334 | ELSE |
---|
| 335 | CALL xios_close_context_definition() |
---|
| 336 | CALL xios_update_calendar( 0 ) |
---|
[12950] | 337 | ENDIF |
---|
[12377] | 338 | #else |
---|
| 339 | IF( .FALSE. ) WRITE(numout,*) 'iom_init_closedef: should not see this' ! useless statement to avoid compilation warnings |
---|
| 340 | #endif |
---|
| 341 | |
---|
| 342 | END SUBROUTINE iom_init_closedef |
---|
| 343 | |
---|
[13023] | 344 | SUBROUTINE iom_set_vars_active(cdfname, idnum) |
---|
[9367] | 345 | !!--------------------------------------------------------------------- |
---|
[13023] | 346 | !! *** SUBROUTINE iom_set_vars_active *** |
---|
[9367] | 347 | !! |
---|
[13023] | 348 | !! ** Purpose : define filename in XIOS context for reading file, |
---|
| 349 | !! enable variables present in a file for reading with XIOS |
---|
| 350 | !! id of the file is assumed to be rrestart. |
---|
[9367] | 351 | !!--------------------------------------------------------------------- |
---|
| 352 | |
---|
[12957] | 353 | CHARACTER(len=*), INTENT(IN) :: cdfname |
---|
| 354 | INTEGER , INTENT(IN) :: idnum |
---|
[9535] | 355 | #if defined key_iomput |
---|
[12950] | 356 | INTEGER :: ndims, nvars, natts, unlimitedDimId, dimlen, xtype,mdims |
---|
| 357 | TYPE(xios_field) :: field_hdl |
---|
| 358 | TYPE(xios_file) :: file_hdl |
---|
| 359 | TYPE(xios_filegroup) :: filegroup_hdl |
---|
| 360 | INTEGER :: dimids(4), jv,i, idim |
---|
| 361 | CHARACTER(LEN=256) :: clinfo ! info character |
---|
| 362 | INTEGER, ALLOCATABLE :: indimlens(:) |
---|
| 363 | CHARACTER(LEN=nf90_max_name), ALLOCATABLE :: indimnames(:) |
---|
| 364 | CHARACTER(LEN=nf90_max_name) :: dimname, varname |
---|
| 365 | LOGICAL :: lmeta |
---|
[9367] | 366 | |
---|
[12950] | 367 | meta(1) = "nav_lat" |
---|
| 368 | meta(2) = "nav_lon" |
---|
| 369 | meta(3) = "nav_lev" |
---|
| 370 | meta(4) = "time_instant" |
---|
| 371 | meta(5) = "time_instant_bounds" |
---|
| 372 | meta(6) = "time_counter" |
---|
| 373 | meta(7) = "time_counter_bounds" |
---|
| 374 | meta(8) = "x" |
---|
| 375 | meta(9) = "y" |
---|
| 376 | meta(10) = "numcat" |
---|
| 377 | |
---|
[13023] | 378 | clinfo = ' iom_set_vars_active, file: '//TRIM(cdfname) |
---|
[12950] | 379 | |
---|
[12957] | 380 | IF(lwp) write(numout, *) TRIM(clinfo) |
---|
| 381 | IF(lwp) CALL FLUSH(numout) |
---|
[9367] | 382 | !set name of the restart file and enable available fields |
---|
| 383 | CALL xios_get_handle("file_definition", filegroup_hdl ) |
---|
| 384 | CALL xios_add_child(filegroup_hdl, file_hdl, 'rrestart') |
---|
[12957] | 385 | CALL xios_set_file_attr( "rrestart", name=trim(cdfname), type="one_file", & |
---|
[9367] | 386 | par_access="collective", enabled=.TRUE., mode="read", & |
---|
| 387 | output_freq=xios_timestep) |
---|
| 388 | |
---|
[12961] | 389 | CALL iom_nf90_check( nf90_inquire(idnum, ndims, nvars, natts ), clinfo ) |
---|
[12950] | 390 | ALLOCATE(indimlens(ndims), indimnames(ndims)) |
---|
[12961] | 391 | CALL iom_nf90_check( nf90_inquire(idnum, unlimitedDimId = unlimitedDimId ), clinfo ) |
---|
[9367] | 392 | |
---|
[12950] | 393 | DO idim = 1, ndims |
---|
[12961] | 394 | CALL iom_nf90_check( nf90_inquire_dimension(idnum, idim, dimname, dimlen ), clinfo ) |
---|
[12950] | 395 | indimlens(idim) = dimlen |
---|
| 396 | indimnames(idim) = dimname |
---|
| 397 | ENDDO |
---|
[9367] | 398 | |
---|
[12950] | 399 | DO jv =1, nvars |
---|
| 400 | lmeta = .FALSE. |
---|
[12961] | 401 | CALL iom_nf90_check( nf90_inquire_variable(idnum, jv, varname, xtype, ndims, dimids, natts ), clinfo ) |
---|
[12950] | 402 | DO i = 1, NMETA |
---|
| 403 | IF(TRIM(varname) == TRIM(meta(i))) THEN |
---|
| 404 | lmeta = .TRUE. |
---|
| 405 | ENDIF |
---|
| 406 | ENDDO |
---|
| 407 | IF(.NOT.lmeta) THEN |
---|
| 408 | CALL xios_add_child(file_hdl, field_hdl, TRIM(varname)) |
---|
| 409 | mdims = ndims |
---|
[9367] | 410 | |
---|
[12950] | 411 | IF(ANY(dimids(1:ndims) == unlimitedDimId)) THEN |
---|
| 412 | mdims = mdims - 1 |
---|
| 413 | ENDIF |
---|
[9367] | 414 | |
---|
[12950] | 415 | IF(mdims == 3) THEN |
---|
| 416 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), & |
---|
[13023] | 417 | domain_ref="grid_N", axis_ref=TRIM(iom_axis(indimlens(dimids(mdims)))), & |
---|
[12950] | 418 | prec = 8, operation = "instant") |
---|
| 419 | ELSEIF(mdims == 2) THEN |
---|
| 420 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), & |
---|
| 421 | domain_ref="grid_N", prec = 8, operation = "instant") |
---|
| 422 | ELSEIF(mdims == 1) THEN |
---|
| 423 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), & |
---|
[13023] | 424 | axis_ref=TRIM(iom_axis(indimlens(dimids(mdims)))), prec = 8, operation = "instant") |
---|
[12950] | 425 | ELSEIF(mdims == 0) THEN |
---|
| 426 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(varname), & |
---|
| 427 | scalar_ref = "grid_scalar", prec = 8, operation = "instant") |
---|
| 428 | ELSE |
---|
[13023] | 429 | WRITE(ctmp1,*) 'iom_set_vars_active: variable ', TRIM(varname) ,' incorrect number of dimensions' |
---|
| 430 | CALL ctl_stop( 'iom_set_vars_active:', ctmp1 ) |
---|
[12950] | 431 | ENDIF |
---|
| 432 | ENDIF |
---|
| 433 | ENDDO |
---|
| 434 | DEALLOCATE(indimlens, indimnames) |
---|
| 435 | #endif |
---|
[13023] | 436 | END SUBROUTINE iom_set_vars_active |
---|
[9367] | 437 | |
---|
[12950] | 438 | SUBROUTINE iom_set_rstw_file(cdrst_file) |
---|
[9367] | 439 | !!--------------------------------------------------------------------- |
---|
[12950] | 440 | !! *** SUBROUTINE iom_set_rstw_file *** |
---|
[9367] | 441 | !! |
---|
| 442 | !! ** Purpose : define file name in XIOS context for writing restart |
---|
| 443 | !!--------------------------------------------------------------------- |
---|
| 444 | CHARACTER(len=*) :: cdrst_file |
---|
| 445 | #if defined key_iomput |
---|
| 446 | TYPE(xios_file) :: file_hdl |
---|
| 447 | TYPE(xios_filegroup) :: filegroup_hdl |
---|
| 448 | INTEGER :: i |
---|
| 449 | CHARACTER(lc) :: clpath |
---|
| 450 | |
---|
| 451 | !set name of the restart file and enable available fields |
---|
| 452 | IF(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS write) to: ',cdrst_file |
---|
[12957] | 453 | IF(lwp) CALL FLUSH(numout) |
---|
[9367] | 454 | CALL xios_get_handle("file_definition", filegroup_hdl ) |
---|
| 455 | CALL xios_add_child(filegroup_hdl, file_hdl, 'wrestart') |
---|
| 456 | IF(nxioso.eq.1) THEN |
---|
| 457 | CALL xios_set_file_attr( "wrestart", type="one_file", enabled=.TRUE.,& |
---|
| 458 | mode="write", output_freq=xios_timestep) |
---|
| 459 | if(lwp) write(numout,*) 'OPEN ', trim(cdrst_file), ' in one_file mode' |
---|
| 460 | ELSE |
---|
| 461 | CALL xios_set_file_attr( "wrestart", type="multiple_file", enabled=.TRUE.,& |
---|
| 462 | mode="write", output_freq=xios_timestep) |
---|
| 463 | if(lwp) write(numout,*) 'OPEN ', trim(cdrst_file), ' in multiple_file mode' |
---|
| 464 | ENDIF |
---|
| 465 | CALL xios_set_file_attr( "wrestart", name=trim(cdrst_file)) |
---|
[12950] | 466 | #endif |
---|
| 467 | END SUBROUTINE iom_set_rstw_file |
---|
| 468 | |
---|
| 469 | |
---|
| 470 | SUBROUTINE iom_set_rstw_active(sdfield, rd0, rd1, rd2, rd3) |
---|
| 471 | !!--------------------------------------------------------------------- |
---|
| 472 | !! *** SUBROUTINE iom_set_rstw_active *** |
---|
| 473 | !! |
---|
| 474 | !! ** Purpose : define file name in XIOS context for writing restart |
---|
| 475 | !! enable variables present in restart file for writing |
---|
| 476 | !!--------------------------------------------------------------------- |
---|
| 477 | !sets enabled = .TRUE. for each field in restart file |
---|
| 478 | CHARACTER(len = *), INTENT(IN) :: sdfield |
---|
| 479 | REAL(wp), OPTIONAL, INTENT(IN) :: rd0 |
---|
| 480 | REAL(wp), OPTIONAL, INTENT(IN), DIMENSION(:) :: rd1 |
---|
| 481 | REAL(wp), OPTIONAL, INTENT(IN), DIMENSION(:, :) :: rd2 |
---|
| 482 | REAL(wp), OPTIONAL, INTENT(IN), DIMENSION(:, :, :) :: rd3 |
---|
| 483 | #if defined key_iomput |
---|
| 484 | TYPE(xios_field) :: field_hdl |
---|
| 485 | TYPE(xios_file) :: file_hdl |
---|
| 486 | INTEGER :: i |
---|
| 487 | CHARACTER(lc) :: clpath |
---|
| 488 | CHARACTER(len=1024) :: fname |
---|
| 489 | CHARACTER(len=lc) :: axis_ref |
---|
| 490 | |
---|
| 491 | CALL xios_get_handle("wrestart", file_hdl) |
---|
[9367] | 492 | !define fields for restart context |
---|
[12950] | 493 | CALL xios_add_child(file_hdl, field_hdl, TRIM(sdfield)) |
---|
| 494 | |
---|
| 495 | IF(PRESENT(rd3)) THEN |
---|
[12961] | 496 | IF(lwp) write(numout, *) TRIM(sdfield), ' 3D ', size(rd3,3) |
---|
| 497 | IF(lwp) CALL FLUSH(numout) |
---|
[12950] | 498 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(sdfield), & |
---|
| 499 | domain_ref="grid_N", axis_ref=TRIM(iom_axis(size(rd3, 3))), & |
---|
| 500 | prec = 8, operation = "instant") |
---|
| 501 | ENDIF |
---|
| 502 | |
---|
| 503 | IF(PRESENT(rd2)) THEN |
---|
[12961] | 504 | IF(lwp) write(numout, *) TRIM(sdfield), ' 2D' |
---|
| 505 | IF(lwp) CALL FLUSH(numout) |
---|
[12950] | 506 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(sdfield), & |
---|
| 507 | domain_ref="grid_N", prec = 8, operation = "instant") |
---|
| 508 | ENDIF |
---|
| 509 | |
---|
| 510 | IF(PRESENT(rd1)) THEN |
---|
[12961] | 511 | IF(lwp) write(numout, *) TRIM(sdfield), ' 1D ', size(rd1,1) |
---|
| 512 | IF(lwp) CALL FLUSH(numout) |
---|
[12950] | 513 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(sdfield), & |
---|
| 514 | axis_ref=TRIM(iom_axis(size(rd1, 1))), prec = 8, operation = "instant") |
---|
| 515 | ENDIF |
---|
| 516 | |
---|
| 517 | IF(PRESENT(rd0)) THEN |
---|
[12961] | 518 | IF(lwp) write(numout, *) TRIM(sdfield), ' 0D' |
---|
| 519 | IF(lwp) CALL FLUSH(numout) |
---|
[12950] | 520 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(sdfield), & |
---|
| 521 | scalar_ref = "grid_scalar", prec = 8, operation = "instant") |
---|
| 522 | ENDIF |
---|
[9367] | 523 | #endif |
---|
| 524 | END SUBROUTINE iom_set_rstw_active |
---|
| 525 | |
---|
[12950] | 526 | FUNCTION iom_axis(idlev) result(axis_ref) |
---|
| 527 | !!--------------------------------------------------------------------- |
---|
| 528 | !! *** FUNCTION iom_axis *** |
---|
| 529 | !! |
---|
| 530 | !! ** Purpose : Used for grid definition when XIOS is used to read/write |
---|
| 531 | !! restart. Returns axis corresponding to the number of levels |
---|
| 532 | !! given as an input variable. Axes are defined in routine |
---|
| 533 | !! iom_set_rst_context |
---|
| 534 | !!--------------------------------------------------------------------- |
---|
| 535 | INTEGER, INTENT(IN) :: idlev |
---|
| 536 | CHARACTER(len=lc) :: axis_ref |
---|
| 537 | CHARACTER(len=12) :: str |
---|
| 538 | IF(idlev == jpk) THEN |
---|
| 539 | axis_ref="nav_lev" |
---|
| 540 | #if defined key_si3 |
---|
| 541 | ELSEIF(idlev == jpl) THEN |
---|
| 542 | axis_ref="numcat" |
---|
| 543 | #endif |
---|
| 544 | ELSE |
---|
| 545 | write(str, *) idlev |
---|
| 546 | CALL ctl_stop( 'iom_axis', 'Definition for axis with '//TRIM(ADJUSTL(str))//' levels missing') |
---|
| 547 | ENDIF |
---|
| 548 | END FUNCTION iom_axis |
---|
| 549 | |
---|
[9984] | 550 | SUBROUTINE iom_set_rst_context(ld_rstr) |
---|
[9367] | 551 | !!--------------------------------------------------------------------- |
---|
[9535] | 552 | !! *** SUBROUTINE iom_set_rst_context *** |
---|
[9367] | 553 | !! |
---|
| 554 | !! ** Purpose : Define domain, axis and grid for restart (read/write) |
---|
| 555 | !! context |
---|
| 556 | !! |
---|
| 557 | !!--------------------------------------------------------------------- |
---|
[9984] | 558 | LOGICAL, INTENT(IN) :: ld_rstr |
---|
[12950] | 559 | INTEGER :: ji |
---|
[9367] | 560 | #if defined key_iomput |
---|
| 561 | TYPE(xios_domaingroup) :: domaingroup_hdl |
---|
| 562 | TYPE(xios_domain) :: domain_hdl |
---|
| 563 | TYPE(xios_axisgroup) :: axisgroup_hdl |
---|
| 564 | TYPE(xios_axis) :: axis_hdl |
---|
| 565 | TYPE(xios_scalar) :: scalar_hdl |
---|
| 566 | TYPE(xios_scalargroup) :: scalargroup_hdl |
---|
| 567 | |
---|
| 568 | CALL xios_get_handle("domain_definition",domaingroup_hdl) |
---|
| 569 | CALL xios_add_child(domaingroup_hdl, domain_hdl, "grid_N") |
---|
[9984] | 570 | CALL set_grid("N", glamt, gphit, .TRUE., ld_rstr) |
---|
[9367] | 571 | |
---|
| 572 | CALL xios_get_handle("axis_definition",axisgroup_hdl) |
---|
| 573 | CALL xios_add_child(axisgroup_hdl, axis_hdl, "nav_lev") |
---|
| 574 | !AGRIF fails to compile when unit= is in call to xios_set_axis_attr |
---|
| 575 | ! CALL xios_set_axis_attr( "nav_lev", long_name="Vertical levels", unit="m", positive="down") |
---|
| 576 | CALL xios_set_axis_attr( "nav_lev", long_name="Vertical levels in meters", positive="down") |
---|
| 577 | CALL iom_set_axis_attr( "nav_lev", paxis = gdept_1d ) |
---|
[12950] | 578 | #if defined key_si3 |
---|
| 579 | CALL xios_add_child(axisgroup_hdl, axis_hdl, "numcat") |
---|
| 580 | CALL iom_set_axis_attr( "numcat", (/ (REAL(ji,wp), ji=1,jpl) /) ) |
---|
| 581 | #endif |
---|
[9367] | 582 | |
---|
| 583 | CALL xios_get_handle("scalar_definition", scalargroup_hdl) |
---|
| 584 | CALL xios_add_child(scalargroup_hdl, scalar_hdl, "grid_scalar") |
---|
| 585 | #endif |
---|
| 586 | END SUBROUTINE iom_set_rst_context |
---|
| 587 | |
---|
[4152] | 588 | SUBROUTINE iom_swap( cdname ) |
---|
[1793] | 589 | !!--------------------------------------------------------------------- |
---|
| 590 | !! *** SUBROUTINE iom_swap *** |
---|
| 591 | !! |
---|
| 592 | !! ** Purpose : swap context between different agrif grid for xmlio_server |
---|
| 593 | !!--------------------------------------------------------------------- |
---|
[4152] | 594 | CHARACTER(len=*), INTENT(in) :: cdname |
---|
[1793] | 595 | #if defined key_iomput |
---|
[3695] | 596 | TYPE(xios_context) :: nemo_hdl |
---|
[4152] | 597 | IF( TRIM(Agrif_CFixed()) == '0' ) THEN |
---|
| 598 | CALL xios_get_handle(TRIM(cdname),nemo_hdl) |
---|
| 599 | ELSE |
---|
| 600 | CALL xios_get_handle(TRIM(Agrif_CFixed())//"_"//TRIM(cdname),nemo_hdl) |
---|
| 601 | ENDIF |
---|
| 602 | ! |
---|
| 603 | CALL xios_set_current_context(nemo_hdl) |
---|
[1793] | 604 | #endif |
---|
[4152] | 605 | ! |
---|
[1793] | 606 | END SUBROUTINE iom_swap |
---|
| 607 | |
---|
| 608 | |
---|
[12649] | 609 | SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev, cdcomp ) |
---|
[544] | 610 | !!--------------------------------------------------------------------- |
---|
| 611 | !! *** SUBROUTINE iom_open *** |
---|
| 612 | !! |
---|
| 613 | !! ** Purpose : open an input file (return 0 if not found) |
---|
| 614 | !!--------------------------------------------------------------------- |
---|
| 615 | CHARACTER(len=*), INTENT(in ) :: cdname ! File name |
---|
| 616 | INTEGER , INTENT( out) :: kiomid ! iom identifier of the opened file |
---|
| 617 | LOGICAL , INTENT(in ), OPTIONAL :: ldwrt ! open in write modeb (default = .FALSE.) |
---|
| 618 | INTEGER , INTENT(in ), OPTIONAL :: kdom ! Type of domain to be written (default = jpdom_local_noovlap) |
---|
[679] | 619 | LOGICAL , INTENT(in ), OPTIONAL :: ldstop ! stop if open to read a non-existing file (default = .TRUE.) |
---|
[1319] | 620 | LOGICAL , INTENT(in ), OPTIONAL :: ldiof ! Interp On the Fly, needed for AGRIF (default = .FALSE.) |
---|
[9019] | 621 | INTEGER , INTENT(in ), OPTIONAL :: kdlev ! number of vertical levels |
---|
[12649] | 622 | CHARACTER(len=3), INTENT(in ), OPTIONAL :: cdcomp ! name of component calling iom_nf90_open |
---|
[9019] | 623 | ! |
---|
[4148] | 624 | CHARACTER(LEN=256) :: clname ! the name of the file based on cdname [[+clcpu]+clcpu] |
---|
| 625 | CHARACTER(LEN=256) :: cltmpn ! tempory name to store clname (in writting mode) |
---|
[6140] | 626 | CHARACTER(LEN=10) :: clsuffix ! ".nc" |
---|
[550] | 627 | CHARACTER(LEN=15) :: clcpu ! the cpu number (max jpmax_digits digits) |
---|
[4148] | 628 | CHARACTER(LEN=256) :: clinfo ! info character |
---|
[544] | 629 | LOGICAL :: llok ! check the existence |
---|
[679] | 630 | LOGICAL :: llwrt ! local definition of ldwrt |
---|
[1200] | 631 | LOGICAL :: llnoov ! local definition to read overlap |
---|
[679] | 632 | LOGICAL :: llstop ! local definition of ldstop |
---|
[1319] | 633 | LOGICAL :: lliof ! local definition of ldiof |
---|
[544] | 634 | INTEGER :: icnt ! counter for digits in clcpu (max = jpmax_digits) |
---|
| 635 | INTEGER :: iln, ils ! lengths of character |
---|
| 636 | INTEGER :: idom ! type of domain |
---|
| 637 | INTEGER :: istop ! |
---|
| 638 | INTEGER, DIMENSION(2,5) :: idompar ! domain parameters: |
---|
| 639 | ! local number of points for x,y dimensions |
---|
| 640 | ! position of first local point for x,y dimensions |
---|
| 641 | ! position of last local point for x,y dimensions |
---|
| 642 | ! start halo size for x,y dimensions |
---|
| 643 | ! end halo size for x,y dimensions |
---|
| 644 | !--------------------------------------------------------------------- |
---|
| 645 | ! Initializations and control |
---|
| 646 | ! ============= |
---|
[1341] | 647 | kiomid = -1 |
---|
[544] | 648 | clinfo = ' iom_open ~~~ ' |
---|
| 649 | istop = nstop |
---|
| 650 | ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0 |
---|
| 651 | ! (could be done when defining iom_file in f95 but not in f90) |
---|
[1441] | 652 | IF( Agrif_Root() ) THEN |
---|
| 653 | IF( iom_open_init == 0 ) THEN |
---|
| 654 | iom_file(:)%nfid = 0 |
---|
| 655 | iom_open_init = 1 |
---|
| 656 | ENDIF |
---|
[1409] | 657 | ENDIF |
---|
[544] | 658 | ! do we read or write the file? |
---|
| 659 | IF( PRESENT(ldwrt) ) THEN ; llwrt = ldwrt |
---|
| 660 | ELSE ; llwrt = .FALSE. |
---|
| 661 | ENDIF |
---|
[679] | 662 | ! do we call ctl_stop if we try to open a non-existing file in read mode? |
---|
| 663 | IF( PRESENT(ldstop) ) THEN ; llstop = ldstop |
---|
| 664 | ELSE ; llstop = .TRUE. |
---|
| 665 | ENDIF |
---|
[1319] | 666 | ! are we using interpolation on the fly? |
---|
| 667 | IF( PRESENT(ldiof) ) THEN ; lliof = ldiof |
---|
| 668 | ELSE ; lliof = .FALSE. |
---|
| 669 | ENDIF |
---|
[1200] | 670 | ! do we read the overlap |
---|
| 671 | ! ugly patch SM+JMM+RB to overwrite global definition in some cases |
---|
[10016] | 672 | llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif |
---|
[544] | 673 | ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix) |
---|
| 674 | ! ============= |
---|
| 675 | clname = trim(cdname) |
---|
[1319] | 676 | IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN |
---|
[12377] | 677 | iln = INDEX(clname,'/') |
---|
[1200] | 678 | cltmpn = clname(1:iln) |
---|
| 679 | clname = clname(iln+1:LEN_TRIM(clname)) |
---|
| 680 | clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname) |
---|
| 681 | ENDIF |
---|
[544] | 682 | ! which suffix should we use? |
---|
[10425] | 683 | clsuffix = '.nc' |
---|
[544] | 684 | ! Add the suffix if needed |
---|
| 685 | iln = LEN_TRIM(clname) |
---|
| 686 | ils = LEN_TRIM(clsuffix) |
---|
[742] | 687 | IF( iln <= ils .OR. INDEX( TRIM(clname), TRIM(clsuffix), back = .TRUE. ) /= iln - ils + 1 ) & |
---|
| 688 | & clname = TRIM(clname)//TRIM(clsuffix) |
---|
[544] | 689 | cltmpn = clname ! store this name |
---|
| 690 | ! try to find if the file to be opened already exist |
---|
| 691 | ! ============= |
---|
| 692 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
| 693 | IF( .NOT.llok ) THEN |
---|
| 694 | ! we try to add the cpu number to the name |
---|
[6140] | 695 | WRITE(clcpu,*) narea-1 |
---|
| 696 | |
---|
[544] | 697 | clcpu = TRIM(ADJUSTL(clcpu)) |
---|
[679] | 698 | iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.) |
---|
[544] | 699 | clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix) |
---|
| 700 | icnt = 0 |
---|
| 701 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
| 702 | ! we try different formats for the cpu number by adding 0 |
---|
| 703 | DO WHILE( .NOT.llok .AND. icnt < jpmax_digits ) |
---|
| 704 | clcpu = "0"//trim(clcpu) |
---|
| 705 | clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix) |
---|
| 706 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
| 707 | icnt = icnt + 1 |
---|
| 708 | END DO |
---|
[9367] | 709 | ELSE |
---|
| 710 | lxios_sini = .TRUE. |
---|
[544] | 711 | ENDIF |
---|
[679] | 712 | IF( llwrt ) THEN |
---|
| 713 | ! check the domain definition |
---|
| 714 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
| 715 | ! idom = jpdom_local_noovlap ! default definition |
---|
[1200] | 716 | IF( llnoov ) THEN ; idom = jpdom_local_noovlap ! default definition |
---|
| 717 | ELSE ; idom = jpdom_local_full ! default definition |
---|
[679] | 718 | ENDIF |
---|
| 719 | IF( PRESENT(kdom) ) idom = kdom |
---|
| 720 | ! create the domain informations |
---|
| 721 | ! ============= |
---|
| 722 | SELECT CASE (idom) |
---|
| 723 | CASE (jpdom_local_full) |
---|
| 724 | idompar(:,1) = (/ jpi , jpj /) |
---|
| 725 | idompar(:,2) = (/ nimpp , njmpp /) |
---|
| 726 | idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1 /) |
---|
| 727 | idompar(:,4) = (/ nldi - 1 , nldj - 1 /) |
---|
| 728 | idompar(:,5) = (/ jpi - nlei , jpj - nlej /) |
---|
| 729 | CASE (jpdom_local_noextra) |
---|
| 730 | idompar(:,1) = (/ nlci , nlcj /) |
---|
| 731 | idompar(:,2) = (/ nimpp , njmpp /) |
---|
| 732 | idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /) |
---|
| 733 | idompar(:,4) = (/ nldi - 1 , nldj - 1 /) |
---|
| 734 | idompar(:,5) = (/ nlci - nlei , nlcj - nlej /) |
---|
| 735 | CASE (jpdom_local_noovlap) |
---|
| 736 | idompar(:,1) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
| 737 | idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /) |
---|
| 738 | idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /) |
---|
| 739 | idompar(:,4) = (/ 0 , 0 /) |
---|
| 740 | idompar(:,5) = (/ 0 , 0 /) |
---|
| 741 | CASE DEFAULT |
---|
| 742 | CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' ) |
---|
| 743 | END SELECT |
---|
| 744 | ENDIF |
---|
[6140] | 745 | ! Open the NetCDF file |
---|
[544] | 746 | ! ============= |
---|
| 747 | ! do we have some free file identifier? |
---|
| 748 | IF( MINVAL(iom_file(:)%nfid) /= 0 ) & |
---|
[679] | 749 | & CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' ) |
---|
| 750 | ! if no file was found... |
---|
| 751 | IF( .NOT. llok ) THEN |
---|
| 752 | IF( .NOT. llwrt ) THEN ! we are in read mode |
---|
| 753 | IF( llstop ) THEN ; CALL ctl_stop( TRIM(clinfo), 'File '//TRIM(cltmpn)//'* not found' ) |
---|
| 754 | ELSE ; istop = nstop + 1 ! make sure that istop /= nstop so we don't open the file |
---|
| 755 | ENDIF |
---|
| 756 | ELSE ! we are in write mode so we |
---|
| 757 | clname = cltmpn ! get back the file name without the cpu number |
---|
| 758 | ENDIF |
---|
[2586] | 759 | ELSE |
---|
| 760 | IF( llwrt .AND. .NOT. ln_clobber ) THEN ! we stop as we want to write in a new file |
---|
| 761 | CALL ctl_stop( TRIM(clinfo), 'We want to write in a new file but '//TRIM(clname)//' already exists...' ) |
---|
| 762 | istop = nstop + 1 ! make sure that istop /= nstop so we don't open the file |
---|
[4650] | 763 | ELSEIF( llwrt ) THEN ! the file exists and we are in write mode with permission to |
---|
| 764 | clname = cltmpn ! overwrite so get back the file name without the cpu number |
---|
[2586] | 765 | ENDIF |
---|
[679] | 766 | ENDIF |
---|
[544] | 767 | IF( istop == nstop ) THEN ! no error within this routine |
---|
[12649] | 768 | CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev, cdcomp = cdcomp ) |
---|
[544] | 769 | ENDIF |
---|
| 770 | ! |
---|
| 771 | END SUBROUTINE iom_open |
---|
| 772 | |
---|
| 773 | |
---|
| 774 | SUBROUTINE iom_close( kiomid ) |
---|
| 775 | !!-------------------------------------------------------------------- |
---|
| 776 | !! *** SUBROUTINE iom_close *** |
---|
| 777 | !! |
---|
| 778 | !! ** Purpose : close an input file, or all files opened by iom |
---|
| 779 | !!-------------------------------------------------------------------- |
---|
[1131] | 780 | INTEGER, INTENT(inout), OPTIONAL :: kiomid ! iom identifier of the file to be closed |
---|
| 781 | ! ! return 0 when file is properly closed |
---|
| 782 | ! ! No argument: all files opened by iom are closed |
---|
[544] | 783 | |
---|
| 784 | INTEGER :: jf ! dummy loop indices |
---|
| 785 | INTEGER :: i_s, i_e ! temporary integer |
---|
| 786 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
| 787 | !--------------------------------------------------------------------- |
---|
| 788 | ! |
---|
[12283] | 789 | IF( iom_open_init == 0 ) RETURN ! avoid to use iom_file(jf)%nfid that us not yet initialized |
---|
| 790 | ! |
---|
[544] | 791 | clinfo = ' iom_close ~~~ ' |
---|
| 792 | IF( PRESENT(kiomid) ) THEN |
---|
| 793 | i_s = kiomid |
---|
| 794 | i_e = kiomid |
---|
| 795 | ELSE |
---|
| 796 | i_s = 1 |
---|
| 797 | i_e = jpmax_files |
---|
| 798 | ENDIF |
---|
| 799 | |
---|
| 800 | IF( i_s > 0 ) THEN |
---|
| 801 | DO jf = i_s, i_e |
---|
| 802 | IF( iom_file(jf)%nfid > 0 ) THEN |
---|
[10425] | 803 | CALL iom_nf90_close( jf ) |
---|
[1131] | 804 | iom_file(jf)%nfid = 0 ! free the id |
---|
| 805 | IF( PRESENT(kiomid) ) kiomid = 0 ! return 0 as id to specify that the file was closed |
---|
[679] | 806 | IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(jf)%name)//' ok' |
---|
[544] | 807 | ELSEIF( PRESENT(kiomid) ) THEN |
---|
| 808 | WRITE(ctmp1,*) '--->', kiomid |
---|
| 809 | CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 ) |
---|
| 810 | ENDIF |
---|
| 811 | END DO |
---|
| 812 | ENDIF |
---|
| 813 | ! |
---|
| 814 | END SUBROUTINE iom_close |
---|
| 815 | |
---|
| 816 | |
---|
[11536] | 817 | FUNCTION iom_varid ( kiomid, cdvar, kdimsz, kndims, lduld, ldstop ) |
---|
[544] | 818 | !!----------------------------------------------------------------------- |
---|
| 819 | !! *** FUNCTION iom_varid *** |
---|
| 820 | !! |
---|
| 821 | !! ** Purpose : get the id of a variable in a file (return 0 if not found) |
---|
| 822 | !!----------------------------------------------------------------------- |
---|
| 823 | INTEGER , INTENT(in ) :: kiomid ! file Identifier |
---|
| 824 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! name of the variable |
---|
[9540] | 825 | INTEGER, DIMENSION(:), INTENT( out), OPTIONAL :: kdimsz ! size of each dimension |
---|
[11536] | 826 | INTEGER , INTENT( out), OPTIONAL :: kndims ! number of dimensions |
---|
| 827 | LOGICAL , INTENT( out), OPTIONAL :: lduld ! true if the last dimension is unlimited (time) |
---|
[745] | 828 | LOGICAL , INTENT(in ), OPTIONAL :: ldstop ! stop if looking for non-existing variable (default = .TRUE.) |
---|
[544] | 829 | ! |
---|
| 830 | INTEGER :: iom_varid, iiv, i_nvd |
---|
| 831 | LOGICAL :: ll_fnd |
---|
| 832 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
[745] | 833 | LOGICAL :: llstop ! local definition of ldstop |
---|
[544] | 834 | !!----------------------------------------------------------------------- |
---|
| 835 | iom_varid = 0 ! default definition |
---|
[745] | 836 | ! do we call ctl_stop if we look for non-existing variable? |
---|
| 837 | IF( PRESENT(ldstop) ) THEN ; llstop = ldstop |
---|
| 838 | ELSE ; llstop = .TRUE. |
---|
| 839 | ENDIF |
---|
[544] | 840 | ! |
---|
| 841 | IF( kiomid > 0 ) THEN |
---|
[679] | 842 | clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar) |
---|
[544] | 843 | IF( iom_file(kiomid)%nfid == 0 ) THEN |
---|
| 844 | CALL ctl_stop( trim(clinfo), 'the file is not open' ) |
---|
| 845 | ELSE |
---|
| 846 | ll_fnd = .FALSE. |
---|
| 847 | iiv = 0 |
---|
| 848 | ! |
---|
| 849 | DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars ) |
---|
| 850 | iiv = iiv + 1 |
---|
| 851 | ll_fnd = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) ) |
---|
| 852 | END DO |
---|
| 853 | ! |
---|
| 854 | IF( .NOT.ll_fnd ) THEN |
---|
| 855 | iiv = iiv + 1 |
---|
| 856 | IF( iiv <= jpmax_vars ) THEN |
---|
[11536] | 857 | iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz, kndims, lduld ) |
---|
[544] | 858 | ELSE |
---|
| 859 | CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name, & |
---|
[10425] | 860 | & 'increase the parameter jpmax_vars') |
---|
[544] | 861 | ENDIF |
---|
[745] | 862 | IF( llstop .AND. iom_varid == -1 ) CALL ctl_stop( TRIM(clinfo)//' not found' ) |
---|
[544] | 863 | ELSE |
---|
| 864 | iom_varid = iiv |
---|
| 865 | IF( PRESENT(kdimsz) ) THEN |
---|
| 866 | i_nvd = iom_file(kiomid)%ndims(iiv) |
---|
[9540] | 867 | IF( i_nvd <= size(kdimsz) ) THEN |
---|
| 868 | kdimsz(1:i_nvd) = iom_file(kiomid)%dimsz(1:i_nvd,iiv) |
---|
[544] | 869 | ELSE |
---|
| 870 | WRITE(ctmp1,*) i_nvd, size(kdimsz) |
---|
| 871 | CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) ) |
---|
| 872 | ENDIF |
---|
| 873 | ENDIF |
---|
[4205] | 874 | IF( PRESENT(kndims) ) kndims = iom_file(kiomid)%ndims(iiv) |
---|
[11536] | 875 | IF( PRESENT( lduld) ) lduld = iom_file(kiomid)%luld( iiv) |
---|
[544] | 876 | ENDIF |
---|
| 877 | ENDIF |
---|
| 878 | ENDIF |
---|
| 879 | ! |
---|
| 880 | END FUNCTION iom_varid |
---|
| 881 | |
---|
| 882 | |
---|
| 883 | !!---------------------------------------------------------------------- |
---|
| 884 | !! INTERFACE iom_get |
---|
| 885 | !!---------------------------------------------------------------------- |
---|
[9367] | 886 | SUBROUTINE iom_g0d( kiomid, cdvar, pvar, ktime, ldxios ) |
---|
[544] | 887 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 888 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
| 889 | REAL(wp) , INTENT( out) :: pvar ! read field |
---|
[4245] | 890 | INTEGER , INTENT(in ), OPTIONAL :: ktime ! record number |
---|
[9367] | 891 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! use xios to read restart |
---|
[544] | 892 | ! |
---|
[4245] | 893 | INTEGER :: idvar ! variable id |
---|
| 894 | INTEGER :: idmspc ! number of spatial dimensions |
---|
| 895 | INTEGER , DIMENSION(1) :: itime ! record number |
---|
| 896 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
| 897 | CHARACTER(LEN=100) :: clname ! file name |
---|
| 898 | CHARACTER(LEN=1) :: cldmspc ! |
---|
[9367] | 899 | LOGICAL :: llxios |
---|
[544] | 900 | ! |
---|
[9367] | 901 | llxios = .FALSE. |
---|
| 902 | IF( PRESENT(ldxios) ) llxios = ldxios |
---|
| 903 | |
---|
| 904 | IF(.NOT.llxios) THEN ! read data using default library |
---|
| 905 | itime = 1 |
---|
| 906 | IF( PRESENT(ktime) ) itime = ktime |
---|
| 907 | ! |
---|
| 908 | clname = iom_file(kiomid)%name |
---|
| 909 | clinfo = ' iom_g0d, file: '//trim(clname)//', var: '//trim(cdvar) |
---|
| 910 | ! |
---|
| 911 | IF( kiomid > 0 ) THEN |
---|
| 912 | idvar = iom_varid( kiomid, cdvar ) |
---|
| 913 | IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN |
---|
| 914 | idmspc = iom_file ( kiomid )%ndims( idvar ) |
---|
| 915 | IF( iom_file(kiomid)%luld(idvar) ) idmspc = idmspc - 1 |
---|
| 916 | WRITE(cldmspc , fmt='(i1)') idmspc |
---|
| 917 | IF( idmspc > 0 ) CALL ctl_stop( TRIM(clinfo), 'When reading to a 0D array, we do not accept data', & |
---|
| 918 | & 'with 1 or more spatial dimensions: '//cldmspc//' were found.' , & |
---|
| 919 | & 'Use ncwa -a to suppress the unnecessary dimensions' ) |
---|
[10425] | 920 | CALL iom_nf90_get( kiomid, idvar, pvar, itime ) |
---|
[9367] | 921 | ENDIF |
---|
[679] | 922 | ENDIF |
---|
[9367] | 923 | ELSE |
---|
[9535] | 924 | #if defined key_iomput |
---|
[9367] | 925 | IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar) |
---|
| 926 | CALL xios_recv_field( trim(cdvar), pvar) |
---|
[9535] | 927 | #else |
---|
[10425] | 928 | WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar) |
---|
| 929 | CALL ctl_stop( 'iom_g0d', ctmp1 ) |
---|
[9535] | 930 | #endif |
---|
[679] | 931 | ENDIF |
---|
[550] | 932 | END SUBROUTINE iom_g0d |
---|
[544] | 933 | |
---|
[9367] | 934 | SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, ldxios ) |
---|
[544] | 935 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 936 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
| 937 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
| 938 | REAL(wp) , INTENT( out), DIMENSION(:) :: pvar ! read field |
---|
| 939 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
| 940 | INTEGER , INTENT(in ), DIMENSION(1), OPTIONAL :: kstart ! start axis position of the reading |
---|
| 941 | INTEGER , INTENT(in ), DIMENSION(1), OPTIONAL :: kcount ! number of points in each axis |
---|
[9367] | 942 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! read data using XIOS |
---|
[544] | 943 | ! |
---|
[679] | 944 | IF( kiomid > 0 ) THEN |
---|
| 945 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r1d=pvar, & |
---|
[9367] | 946 | & ktime=ktime, kstart=kstart, kcount=kcount, & |
---|
| 947 | & ldxios=ldxios ) |
---|
[679] | 948 | ENDIF |
---|
[550] | 949 | END SUBROUTINE iom_g1d |
---|
[544] | 950 | |
---|
[9367] | 951 | SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios) |
---|
[544] | 952 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 953 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
| 954 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
| 955 | REAL(wp) , INTENT( out), DIMENSION(:,:) :: pvar ! read field |
---|
| 956 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
| 957 | INTEGER , INTENT(in ), DIMENSION(2) , OPTIONAL :: kstart ! start axis position of the reading |
---|
| 958 | INTEGER , INTENT(in ), DIMENSION(2) , OPTIONAL :: kcount ! number of points in each axis |
---|
[5118] | 959 | LOGICAL , INTENT(in ) , OPTIONAL :: lrowattr ! logical flag telling iom_get to |
---|
| 960 | ! look for and use a file attribute |
---|
| 961 | ! called open_ocean_jstart to set the start |
---|
| 962 | ! value for the 2nd dimension (netcdf only) |
---|
[9367] | 963 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! read data using XIOS |
---|
[544] | 964 | ! |
---|
[679] | 965 | IF( kiomid > 0 ) THEN |
---|
| 966 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r2d=pvar, & |
---|
[5118] | 967 | & ktime=ktime, kstart=kstart, kcount=kcount, & |
---|
[9367] | 968 | & lrowattr=lrowattr, ldxios=ldxios) |
---|
[679] | 969 | ENDIF |
---|
[550] | 970 | END SUBROUTINE iom_g2d |
---|
[544] | 971 | |
---|
[9367] | 972 | SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios ) |
---|
[544] | 973 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 974 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
| 975 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
| 976 | REAL(wp) , INTENT( out), DIMENSION(:,:,:) :: pvar ! read field |
---|
| 977 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
| 978 | INTEGER , INTENT(in ), DIMENSION(3) , OPTIONAL :: kstart ! start axis position of the reading |
---|
| 979 | INTEGER , INTENT(in ), DIMENSION(3) , OPTIONAL :: kcount ! number of points in each axis |
---|
[5118] | 980 | LOGICAL , INTENT(in ) , OPTIONAL :: lrowattr ! logical flag telling iom_get to |
---|
| 981 | ! look for and use a file attribute |
---|
| 982 | ! called open_ocean_jstart to set the start |
---|
| 983 | ! value for the 2nd dimension (netcdf only) |
---|
[9367] | 984 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! read data using XIOS |
---|
[544] | 985 | ! |
---|
[679] | 986 | IF( kiomid > 0 ) THEN |
---|
| 987 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r3d=pvar, & |
---|
[5118] | 988 | & ktime=ktime, kstart=kstart, kcount=kcount, & |
---|
[9367] | 989 | & lrowattr=lrowattr, ldxios=ldxios ) |
---|
[679] | 990 | ENDIF |
---|
[550] | 991 | END SUBROUTINE iom_g3d |
---|
[544] | 992 | !!---------------------------------------------------------------------- |
---|
| 993 | |
---|
| 994 | SUBROUTINE iom_get_123d( kiomid, kdom , cdvar , & |
---|
[679] | 995 | & pv_r1d, pv_r2d, pv_r3d, & |
---|
[5118] | 996 | & ktime , kstart, kcount, & |
---|
[9367] | 997 | & lrowattr, ldxios ) |
---|
[544] | 998 | !!----------------------------------------------------------------------- |
---|
| 999 | !! *** ROUTINE iom_get_123d *** |
---|
| 1000 | !! |
---|
| 1001 | !! ** Purpose : read a 1D/2D/3D variable |
---|
| 1002 | !! |
---|
| 1003 | !! ** Method : read ONE record at each CALL |
---|
| 1004 | !!----------------------------------------------------------------------- |
---|
| 1005 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1006 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
| 1007 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! Name of the variable |
---|
| 1008 | REAL(wp), DIMENSION(:) , INTENT( out), OPTIONAL :: pv_r1d ! read field (1D case) |
---|
| 1009 | REAL(wp), DIMENSION(:,:) , INTENT( out), OPTIONAL :: pv_r2d ! read field (2D case) |
---|
| 1010 | REAL(wp), DIMENSION(:,:,:) , INTENT( out), OPTIONAL :: pv_r3d ! read field (3D case) |
---|
| 1011 | INTEGER , INTENT(in ), OPTIONAL :: ktime ! record number |
---|
| 1012 | INTEGER , DIMENSION(:) , INTENT(in ), OPTIONAL :: kstart ! start position of the reading in each axis |
---|
| 1013 | INTEGER , DIMENSION(:) , INTENT(in ), OPTIONAL :: kcount ! number of points to be read in each axis |
---|
[5118] | 1014 | LOGICAL , INTENT(in ), OPTIONAL :: lrowattr ! logical flag telling iom_get to |
---|
[9367] | 1015 | ! look for and use a file attribute |
---|
| 1016 | ! called open_ocean_jstart to set the start |
---|
| 1017 | ! value for the 2nd dimension (netcdf only) |
---|
| 1018 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! use XIOS to read restart |
---|
[544] | 1019 | ! |
---|
[9367] | 1020 | LOGICAL :: llxios ! local definition for XIOS read |
---|
[1200] | 1021 | LOGICAL :: llnoov ! local definition to read overlap |
---|
[5118] | 1022 | LOGICAL :: luse_jattr ! local definition to read open_ocean_jstart file attribute |
---|
| 1023 | INTEGER :: jstartrow ! start point for 2nd dimension optionally set by file attribute |
---|
[544] | 1024 | INTEGER :: jl ! loop on number of dimension |
---|
| 1025 | INTEGER :: idom ! type of domain |
---|
| 1026 | INTEGER :: idvar ! id of the variable |
---|
| 1027 | INTEGER :: inbdim ! number of dimensions of the variable |
---|
| 1028 | INTEGER :: idmspc ! number of spatial dimensions |
---|
| 1029 | INTEGER :: itime ! record number |
---|
| 1030 | INTEGER :: istop ! temporary value of nstop |
---|
[679] | 1031 | INTEGER :: ix1, ix2, iy1, iy2 ! subdomain indexes |
---|
| 1032 | INTEGER :: ji, jj ! loop counters |
---|
[5118] | 1033 | INTEGER :: irankpv ! |
---|
[679] | 1034 | INTEGER :: ind1, ind2 ! substring index |
---|
[544] | 1035 | INTEGER, DIMENSION(jpmax_dims) :: istart ! starting point to read for each axis |
---|
| 1036 | INTEGER, DIMENSION(jpmax_dims) :: icnt ! number of value to read along each axis |
---|
| 1037 | INTEGER, DIMENSION(jpmax_dims) :: idimsz ! size of the dimensions of the variable |
---|
[679] | 1038 | INTEGER, DIMENSION(jpmax_dims) :: ishape ! size of the dimensions of the variable |
---|
[544] | 1039 | REAL(wp) :: zscf, zofs ! sacle_factor and add_offset |
---|
| 1040 | INTEGER :: itmp ! temporary integer |
---|
[4148] | 1041 | CHARACTER(LEN=256) :: clinfo ! info character |
---|
| 1042 | CHARACTER(LEN=256) :: clname ! file name |
---|
[679] | 1043 | CHARACTER(LEN=1) :: clrankpv, cldmspc ! |
---|
[6140] | 1044 | LOGICAL :: ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension. |
---|
[9019] | 1045 | INTEGER :: inlev ! number of levels for 3D data |
---|
[9367] | 1046 | REAL(wp) :: gma, gmi |
---|
[544] | 1047 | !--------------------------------------------------------------------- |
---|
| 1048 | ! |
---|
[9019] | 1049 | inlev = -1 |
---|
| 1050 | IF( PRESENT(pv_r3d) ) inlev = SIZE(pv_r3d, 3) |
---|
[9367] | 1051 | ! |
---|
| 1052 | llxios = .FALSE. |
---|
| 1053 | if(PRESENT(ldxios)) llxios = ldxios |
---|
| 1054 | idvar = iom_varid( kiomid, cdvar ) |
---|
[544] | 1055 | idom = kdom |
---|
[9367] | 1056 | ! |
---|
| 1057 | IF(.NOT.llxios) THEN |
---|
| 1058 | clname = iom_file(kiomid)%name ! esier to read |
---|
| 1059 | clinfo = ' iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar) |
---|
| 1060 | ! local definition of the domain ? |
---|
| 1061 | ! do we read the overlap |
---|
| 1062 | ! ugly patch SM+JMM+RB to overwrite global definition in some cases |
---|
| 1063 | llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif |
---|
| 1064 | ! check kcount and kstart optionals parameters... |
---|
| 1065 | IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present') |
---|
| 1066 | IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present') |
---|
| 1067 | IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND. idom /= jpdom_autoglo_xy ) & |
---|
| 1068 | & CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown or kdom = jpdom_autoglo_xy') |
---|
[544] | 1069 | |
---|
[9367] | 1070 | luse_jattr = .false. |
---|
| 1071 | IF( PRESENT(lrowattr) ) THEN |
---|
| 1072 | IF( lrowattr .AND. idom /= jpdom_data ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data') |
---|
| 1073 | IF( lrowattr .AND. idom == jpdom_data ) luse_jattr = .true. |
---|
[6140] | 1074 | ENDIF |
---|
[679] | 1075 | |
---|
[9367] | 1076 | ! Search for the variable in the data base (eventually actualize data) |
---|
| 1077 | istop = nstop |
---|
[544] | 1078 | ! |
---|
[9367] | 1079 | IF( idvar > 0 ) THEN |
---|
| 1080 | ! to write iom_file(kiomid)%dimsz in a shorter way ! |
---|
| 1081 | idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) |
---|
| 1082 | inbdim = iom_file(kiomid)%ndims(idvar) ! number of dimensions in the file |
---|
| 1083 | idmspc = inbdim ! number of spatial dimensions in the file |
---|
| 1084 | IF( iom_file(kiomid)%luld(idvar) ) idmspc = inbdim - 1 |
---|
| 1085 | IF( idmspc > 3 ) CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') |
---|
| 1086 | ! |
---|
| 1087 | ! update idom definition... |
---|
| 1088 | ! Identify the domain in case of jpdom_auto(glo/dta) definition |
---|
| 1089 | IF( idom == jpdom_autoglo_xy ) THEN |
---|
| 1090 | ll_depth_spec = .TRUE. |
---|
| 1091 | idom = jpdom_autoglo |
---|
| 1092 | ELSE |
---|
| 1093 | ll_depth_spec = .FALSE. |
---|
| 1094 | ENDIF |
---|
| 1095 | IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN |
---|
| 1096 | IF( idom == jpdom_autoglo ) THEN ; idom = jpdom_global |
---|
| 1097 | ELSE ; idom = jpdom_data |
---|
[544] | 1098 | ENDIF |
---|
[9367] | 1099 | ind1 = INDEX( clname, '_', back = .TRUE. ) + 1 |
---|
| 1100 | ind2 = INDEX( clname, '.', back = .TRUE. ) - 1 |
---|
| 1101 | IF( ind2 > ind1 ) THEN ; IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 ) idom = jpdom_local ; ENDIF |
---|
| 1102 | ENDIF |
---|
| 1103 | ! Identify the domain in case of jpdom_local definition |
---|
| 1104 | IF( idom == jpdom_local ) THEN |
---|
| 1105 | IF( idimsz(1) == jpi .AND. idimsz(2) == jpj ) THEN ; idom = jpdom_local_full |
---|
| 1106 | ELSEIF( idimsz(1) == nlci .AND. idimsz(2) == nlcj ) THEN ; idom = jpdom_local_noextra |
---|
| 1107 | ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN ; idom = jpdom_local_noovlap |
---|
| 1108 | ELSE ; CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' ) |
---|
| 1109 | ENDIF |
---|
| 1110 | ENDIF |
---|
| 1111 | ! |
---|
| 1112 | ! check the consistency between input array and data rank in the file |
---|
| 1113 | ! |
---|
| 1114 | ! initializations |
---|
| 1115 | itime = 1 |
---|
| 1116 | IF( PRESENT(ktime) ) itime = ktime |
---|
| 1117 | ! |
---|
| 1118 | irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) ) |
---|
| 1119 | WRITE(clrankpv, fmt='(i1)') irankpv |
---|
| 1120 | WRITE(cldmspc , fmt='(i1)') idmspc |
---|
| 1121 | ! |
---|
[12377] | 1122 | !!GS: we consider 2D data as 3D data with vertical dim size = 1 |
---|
| 1123 | !IF( idmspc < irankpv ) THEN |
---|
| 1124 | ! CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension', & |
---|
| 1125 | ! & 'it is impossible to read a '//clrankpv//'D array from this file...' ) |
---|
| 1126 | !ELSEIF( idmspc == irankpv ) THEN |
---|
| 1127 | IF( idmspc == irankpv ) THEN |
---|
[9367] | 1128 | IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown ) & |
---|
| 1129 | & CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' ) |
---|
| 1130 | ELSEIF( idmspc > irankpv ) THEN |
---|
| 1131 | IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN |
---|
| 1132 | CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...' , & |
---|
| 1133 | & 'As the size of the z dimension is 1 and as we try to read the first record, ', & |
---|
| 1134 | & 'we accept this case, even if there is a possible mix-up between z and time dimension' ) |
---|
| 1135 | idmspc = idmspc - 1 |
---|
| 1136 | ELSE |
---|
| 1137 | CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,' , & |
---|
| 1138 | & 'we do not accept data with '//cldmspc//' spatial dimensions', & |
---|
| 1139 | & 'Use ncwa -a to suppress the unnecessary dimensions' ) |
---|
| 1140 | ENDIF |
---|
| 1141 | ENDIF |
---|
| 1142 | ! |
---|
| 1143 | ! definition of istart and icnt |
---|
| 1144 | ! |
---|
| 1145 | icnt (:) = 1 |
---|
| 1146 | istart(:) = 1 |
---|
| 1147 | istart(idmspc+1) = itime |
---|
| 1148 | |
---|
| 1149 | IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN |
---|
| 1150 | istart(1:idmspc) = kstart(1:idmspc) |
---|
| 1151 | icnt (1:idmspc) = kcount(1:idmspc) |
---|
| 1152 | ELSE |
---|
| 1153 | IF(idom == jpdom_unknown ) THEN |
---|
| 1154 | icnt(1:idmspc) = idimsz(1:idmspc) |
---|
| 1155 | ELSE |
---|
| 1156 | IF( .NOT. PRESENT(pv_r1d) ) THEN ! not a 1D array |
---|
| 1157 | IF( idom == jpdom_data ) THEN |
---|
| 1158 | jstartrow = 1 |
---|
| 1159 | IF( luse_jattr ) THEN |
---|
| 1160 | CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found |
---|
| 1161 | jstartrow = MAX(1,jstartrow) |
---|
| 1162 | ENDIF |
---|
| 1163 | istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /) ! icnt(1:2) done below |
---|
| 1164 | ELSEIF( idom == jpdom_global ) THEN ; istart(1:2) = (/ nimpp , njmpp /) ! icnt(1:2) done below |
---|
[5118] | 1165 | ENDIF |
---|
[9367] | 1166 | ! we do not read the overlap -> we start to read at nldi, nldj |
---|
[679] | 1167 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
| 1168 | ! IF( idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
[9367] | 1169 | IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
[679] | 1170 | ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej |
---|
| 1171 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
| 1172 | ! icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
[9367] | 1173 | IF( llnoov ) THEN ; icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
| 1174 | ELSE ; icnt(1:2) = (/ nlci , nlcj /) |
---|
[544] | 1175 | ENDIF |
---|
[9367] | 1176 | IF( PRESENT(pv_r3d) ) THEN |
---|
| 1177 | IF( idom == jpdom_data ) THEN ; icnt(3) = inlev |
---|
| 1178 | ELSEIF( ll_depth_spec .AND. PRESENT(kstart) ) THEN ; istart(3) = kstart(3) ; icnt(3) = kcount(3) |
---|
| 1179 | ELSE ; icnt(3) = inlev |
---|
| 1180 | ENDIF |
---|
| 1181 | ENDIF |
---|
[544] | 1182 | ENDIF |
---|
| 1183 | ENDIF |
---|
[679] | 1184 | ENDIF |
---|
[544] | 1185 | |
---|
[9367] | 1186 | ! check that istart and icnt can be used with this file |
---|
| 1187 | !- |
---|
| 1188 | DO jl = 1, jpmax_dims |
---|
| 1189 | itmp = istart(jl)+icnt(jl)-1 |
---|
| 1190 | IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN |
---|
| 1191 | WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp |
---|
| 1192 | WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)" ) jl, idimsz(jl) |
---|
| 1193 | CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 ) |
---|
| 1194 | ENDIF |
---|
| 1195 | END DO |
---|
[544] | 1196 | |
---|
[9367] | 1197 | ! check that icnt matches the input array |
---|
| 1198 | !- |
---|
| 1199 | IF( idom == jpdom_unknown ) THEN |
---|
| 1200 | IF( irankpv == 1 ) ishape(1:1) = SHAPE(pv_r1d) |
---|
| 1201 | IF( irankpv == 2 ) ishape(1:2) = SHAPE(pv_r2d) |
---|
| 1202 | IF( irankpv == 3 ) ishape(1:3) = SHAPE(pv_r3d) |
---|
| 1203 | ctmp1 = 'd' |
---|
| 1204 | ELSE |
---|
| 1205 | IF( irankpv == 2 ) THEN |
---|
[679] | 1206 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
| 1207 | ! ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej )) ; ctmp1 = 'd(nldi:nlei,nldj:nlej)' |
---|
[9367] | 1208 | IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej )) ; ctmp1='d(nldi:nlei,nldj:nlej)' |
---|
| 1209 | ELSE ; ishape(1:2)=SHAPE(pv_r2d(1 :nlci,1 :nlcj )) ; ctmp1='d(1:nlci,1:nlcj)' |
---|
| 1210 | ENDIF |
---|
[544] | 1211 | ENDIF |
---|
[9367] | 1212 | IF( irankpv == 3 ) THEN |
---|
[679] | 1213 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
| 1214 | ! ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1 = 'd(nldi:nlei,nldj:nlej,:)' |
---|
[9367] | 1215 | IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)' |
---|
| 1216 | ELSE ; ishape(1:3)=SHAPE(pv_r3d(1 :nlci,1 :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)' |
---|
| 1217 | ENDIF |
---|
[544] | 1218 | ENDIF |
---|
[679] | 1219 | ENDIF |
---|
| 1220 | |
---|
[9367] | 1221 | DO jl = 1, irankpv |
---|
| 1222 | WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl) |
---|
| 1223 | IF( ishape(jl) /= icnt(jl) ) CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) ) |
---|
| 1224 | END DO |
---|
[679] | 1225 | |
---|
[9367] | 1226 | ENDIF |
---|
[544] | 1227 | |
---|
[9367] | 1228 | ! read the data |
---|
| 1229 | !- |
---|
| 1230 | IF( idvar > 0 .AND. istop == nstop ) THEN ! no additional errors until this point... |
---|
| 1231 | ! |
---|
[679] | 1232 | ! find the right index of the array to be read |
---|
| 1233 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
| 1234 | ! IF( idom /= jpdom_unknown ) THEN ; ix1 = nldi ; ix2 = nlei ; iy1 = nldj ; iy2 = nlej |
---|
| 1235 | ! ELSE ; ix1 = 1 ; ix2 = icnt(1) ; iy1 = 1 ; iy2 = icnt(2) |
---|
| 1236 | ! ENDIF |
---|
[9367] | 1237 | IF( llnoov ) THEN |
---|
| 1238 | IF( idom /= jpdom_unknown ) THEN ; ix1 = nldi ; ix2 = nlei ; iy1 = nldj ; iy2 = nlej |
---|
| 1239 | ELSE ; ix1 = 1 ; ix2 = icnt(1) ; iy1 = 1 ; iy2 = icnt(2) |
---|
| 1240 | ENDIF |
---|
| 1241 | ELSE |
---|
| 1242 | IF( idom /= jpdom_unknown ) THEN ; ix1 = 1 ; ix2 = nlci ; iy1 = 1 ; iy2 = nlcj |
---|
| 1243 | ELSE ; ix1 = 1 ; ix2 = icnt(1) ; iy1 = 1 ; iy2 = icnt(2) |
---|
| 1244 | ENDIF |
---|
[679] | 1245 | ENDIF |
---|
| 1246 | |
---|
[10425] | 1247 | CALL iom_nf90_get( kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d ) |
---|
[679] | 1248 | |
---|
[9367] | 1249 | IF( istop == nstop ) THEN ! no additional errors until this point... |
---|
| 1250 | IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i6,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name) |
---|
| 1251 | |
---|
| 1252 | !--- overlap areas and extra hallows (mpp) |
---|
| 1253 | IF( PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN |
---|
[11536] | 1254 | CALL lbc_lnk( 'iom', pv_r2d,'Z', -999., kfillmode = jpfillnothing ) |
---|
[9367] | 1255 | ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN |
---|
| 1256 | ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension |
---|
| 1257 | IF( icnt(3) == inlev ) THEN |
---|
[11536] | 1258 | CALL lbc_lnk( 'iom', pv_r3d,'Z', -999., kfillmode = jpfillnothing ) |
---|
[9367] | 1259 | ELSE ! put some arbitrary value (a call to lbc_lnk will be done later...) |
---|
| 1260 | DO jj = nlcj+1, jpj ; pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :) ; END DO |
---|
| 1261 | DO ji = nlci+1, jpi ; pv_r3d(ji , : , :) = pv_r3d(nlei , : , :) ; END DO |
---|
| 1262 | ENDIF |
---|
[679] | 1263 | ENDIF |
---|
[9367] | 1264 | ! |
---|
| 1265 | ELSE |
---|
| 1266 | ! return if istop == nstop is false |
---|
| 1267 | RETURN |
---|
[679] | 1268 | ENDIF |
---|
[9367] | 1269 | ELSE |
---|
| 1270 | ! return if statment idvar > 0 .AND. istop == nstop is false |
---|
| 1271 | RETURN |
---|
| 1272 | ENDIF |
---|
| 1273 | ! |
---|
| 1274 | ELSE ! read using XIOS. Only if KEY_IOMPUT is defined |
---|
| 1275 | #if defined key_iomput |
---|
| 1276 | !would be good to be able to check which context is active and swap only if current is not restart |
---|
| 1277 | IF( PRESENT(pv_r3d) ) THEN |
---|
[9535] | 1278 | pv_r3d(:, :, :) = 0. |
---|
[9367] | 1279 | if(lwp) write(numout,*) 'XIOS RST READ (3D): ',trim(cdvar) |
---|
| 1280 | CALL xios_recv_field( trim(cdvar), pv_r3d) |
---|
| 1281 | IF(idom /= jpdom_unknown ) then |
---|
[11536] | 1282 | CALL lbc_lnk( 'iom', pv_r3d,'Z', -999., kfillmode = jpfillnothing) |
---|
[679] | 1283 | ENDIF |
---|
[9367] | 1284 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
[9535] | 1285 | pv_r2d(:, :) = 0. |
---|
[9367] | 1286 | if(lwp) write(numout,*) 'XIOS RST READ (2D): ', trim(cdvar) |
---|
| 1287 | CALL xios_recv_field( trim(cdvar), pv_r2d) |
---|
| 1288 | IF(idom /= jpdom_unknown ) THEN |
---|
[11536] | 1289 | CALL lbc_lnk('iom', pv_r2d,'Z',-999., kfillmode = jpfillnothing) |
---|
[9367] | 1290 | ENDIF |
---|
| 1291 | ELSEIF( PRESENT(pv_r1d) ) THEN |
---|
[9535] | 1292 | pv_r1d(:) = 0. |
---|
[9367] | 1293 | if(lwp) write(numout,*) 'XIOS RST READ (1D): ', trim(cdvar) |
---|
| 1294 | CALL xios_recv_field( trim(cdvar), pv_r1d) |
---|
[544] | 1295 | ENDIF |
---|
[9367] | 1296 | #else |
---|
| 1297 | istop = istop + 1 |
---|
| 1298 | clinfo = 'Can not use XIOS in iom_get_123d, file: '//trim(clname)//', var:'//trim(cdvar) |
---|
| 1299 | #endif |
---|
[544] | 1300 | ENDIF |
---|
[9367] | 1301 | !some final adjustments |
---|
| 1302 | ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain |
---|
[10425] | 1303 | IF( lk_c1d .AND. PRESENT(pv_r2d) ) CALL lbc_lnk( 'iom', pv_r2d,'Z',1. ) |
---|
| 1304 | IF( lk_c1d .AND. PRESENT(pv_r3d) ) CALL lbc_lnk( 'iom', pv_r3d,'Z',1. ) |
---|
[9367] | 1305 | |
---|
| 1306 | !--- Apply scale_factor and offset |
---|
| 1307 | zscf = iom_file(kiomid)%scf(idvar) ! scale factor |
---|
| 1308 | zofs = iom_file(kiomid)%ofs(idvar) ! offset |
---|
| 1309 | IF( PRESENT(pv_r1d) ) THEN |
---|
| 1310 | IF( zscf /= 1. ) pv_r1d(:) = pv_r1d(:) * zscf |
---|
| 1311 | IF( zofs /= 0. ) pv_r1d(:) = pv_r1d(:) + zofs |
---|
| 1312 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
| 1313 | IF( zscf /= 1.) pv_r2d(:,:) = pv_r2d(:,:) * zscf |
---|
| 1314 | IF( zofs /= 0.) pv_r2d(:,:) = pv_r2d(:,:) + zofs |
---|
| 1315 | ELSEIF( PRESENT(pv_r3d) ) THEN |
---|
| 1316 | IF( zscf /= 1.) pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf |
---|
| 1317 | IF( zofs /= 0.) pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs |
---|
| 1318 | ENDIF |
---|
[544] | 1319 | ! |
---|
| 1320 | END SUBROUTINE iom_get_123d |
---|
| 1321 | |
---|
[12276] | 1322 | SUBROUTINE iom_get_var( cdname, z2d) |
---|
| 1323 | CHARACTER(LEN=*), INTENT(in ) :: cdname |
---|
| 1324 | REAL(wp), DIMENSION(jpi,jpj) :: z2d |
---|
| 1325 | #if defined key_iomput |
---|
| 1326 | IF( xios_field_is_active( cdname, at_current_timestep_arg = .TRUE. ) ) THEN |
---|
| 1327 | z2d(:,:) = 0._wp |
---|
| 1328 | CALL xios_recv_field( cdname, z2d) |
---|
| 1329 | ENDIF |
---|
| 1330 | #else |
---|
| 1331 | IF( .FALSE. ) WRITE(numout,*) cdname, z2d ! useless test to avoid compilation warnings |
---|
| 1332 | #endif |
---|
| 1333 | END SUBROUTINE iom_get_var |
---|
[544] | 1334 | |
---|
[12276] | 1335 | |
---|
[10522] | 1336 | FUNCTION iom_getszuld ( kiomid ) |
---|
| 1337 | !!----------------------------------------------------------------------- |
---|
| 1338 | !! *** FUNCTION iom_getszuld *** |
---|
[544] | 1339 | !! |
---|
[10522] | 1340 | !! ** Purpose : get the size of the unlimited dimension in a file |
---|
| 1341 | !! (return -1 if not found) |
---|
| 1342 | !!----------------------------------------------------------------------- |
---|
| 1343 | INTEGER, INTENT(in ) :: kiomid ! file Identifier |
---|
[544] | 1344 | ! |
---|
[10522] | 1345 | INTEGER :: iom_getszuld |
---|
| 1346 | !!----------------------------------------------------------------------- |
---|
| 1347 | iom_getszuld = -1 |
---|
[679] | 1348 | IF( kiomid > 0 ) THEN |
---|
[10523] | 1349 | IF( iom_file(kiomid)%iduld > 0 ) iom_getszuld = iom_file(kiomid)%lenuld |
---|
[544] | 1350 | ENDIF |
---|
[10522] | 1351 | END FUNCTION iom_getszuld |
---|
| 1352 | |
---|
[544] | 1353 | |
---|
| 1354 | !!---------------------------------------------------------------------- |
---|
[10425] | 1355 | !! INTERFACE iom_chkatt |
---|
[2528] | 1356 | !!---------------------------------------------------------------------- |
---|
[10425] | 1357 | SUBROUTINE iom_chkatt( kiomid, cdatt, llok, ksize, cdvar ) |
---|
[2528] | 1358 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1359 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
[10425] | 1360 | LOGICAL , INTENT( out) :: llok ! Error code |
---|
| 1361 | INTEGER , INTENT( out), OPTIONAL :: ksize ! Size of the attribute array |
---|
[7646] | 1362 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
[2528] | 1363 | ! |
---|
| 1364 | IF( kiomid > 0 ) THEN |
---|
[10425] | 1365 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_chkatt( kiomid, cdatt, llok, ksize=ksize, cdvar=cdvar ) |
---|
[2528] | 1366 | ENDIF |
---|
[10425] | 1367 | ! |
---|
| 1368 | END SUBROUTINE iom_chkatt |
---|
| 1369 | |
---|
| 1370 | !!---------------------------------------------------------------------- |
---|
| 1371 | !! INTERFACE iom_getatt |
---|
| 1372 | !!---------------------------------------------------------------------- |
---|
| 1373 | SUBROUTINE iom_g0d_iatt( kiomid, cdatt, katt0d, cdvar ) |
---|
| 1374 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1375 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1376 | INTEGER , INTENT( out) :: katt0d ! read field |
---|
| 1377 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
| 1378 | ! |
---|
| 1379 | IF( kiomid > 0 ) THEN |
---|
| 1380 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_getatt( kiomid, cdatt, katt0d = katt0d, cdvar=cdvar ) |
---|
| 1381 | ENDIF |
---|
[7646] | 1382 | END SUBROUTINE iom_g0d_iatt |
---|
[2528] | 1383 | |
---|
[10425] | 1384 | SUBROUTINE iom_g1d_iatt( kiomid, cdatt, katt1d, cdvar ) |
---|
| 1385 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1386 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1387 | INTEGER, DIMENSION(:) , INTENT( out) :: katt1d ! read field |
---|
| 1388 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
[7646] | 1389 | ! |
---|
| 1390 | IF( kiomid > 0 ) THEN |
---|
[10425] | 1391 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_getatt( kiomid, cdatt, katt1d = katt1d, cdvar=cdvar ) |
---|
[7646] | 1392 | ENDIF |
---|
[10425] | 1393 | END SUBROUTINE iom_g1d_iatt |
---|
| 1394 | |
---|
| 1395 | SUBROUTINE iom_g0d_ratt( kiomid, cdatt, patt0d, cdvar ) |
---|
| 1396 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1397 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1398 | REAL(wp) , INTENT( out) :: patt0d ! read field |
---|
| 1399 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
| 1400 | ! |
---|
| 1401 | IF( kiomid > 0 ) THEN |
---|
| 1402 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_getatt( kiomid, cdatt, patt0d = patt0d, cdvar=cdvar ) |
---|
| 1403 | ENDIF |
---|
[7646] | 1404 | END SUBROUTINE iom_g0d_ratt |
---|
[2528] | 1405 | |
---|
[10425] | 1406 | SUBROUTINE iom_g1d_ratt( kiomid, cdatt, patt1d, cdvar ) |
---|
| 1407 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1408 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1409 | REAL(wp), DIMENSION(:), INTENT( out) :: patt1d ! read field |
---|
| 1410 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
[7646] | 1411 | ! |
---|
| 1412 | IF( kiomid > 0 ) THEN |
---|
[10425] | 1413 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_getatt( kiomid, cdatt, patt1d = patt1d, cdvar=cdvar ) |
---|
[7646] | 1414 | ENDIF |
---|
[10425] | 1415 | END SUBROUTINE iom_g1d_ratt |
---|
| 1416 | |
---|
| 1417 | SUBROUTINE iom_g0d_catt( kiomid, cdatt, cdatt0d, cdvar ) |
---|
| 1418 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1419 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1420 | CHARACTER(len=*) , INTENT( out) :: cdatt0d ! read field |
---|
| 1421 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
| 1422 | ! |
---|
| 1423 | IF( kiomid > 0 ) THEN |
---|
| 1424 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_getatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar ) |
---|
| 1425 | ENDIF |
---|
[7646] | 1426 | END SUBROUTINE iom_g0d_catt |
---|
| 1427 | |
---|
[10425] | 1428 | |
---|
[2528] | 1429 | !!---------------------------------------------------------------------- |
---|
[7646] | 1430 | !! INTERFACE iom_putatt |
---|
| 1431 | !!---------------------------------------------------------------------- |
---|
[10425] | 1432 | SUBROUTINE iom_p0d_iatt( kiomid, cdatt, katt0d, cdvar ) |
---|
| 1433 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1434 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1435 | INTEGER , INTENT(in ) :: katt0d ! written field |
---|
| 1436 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
[7646] | 1437 | ! |
---|
| 1438 | IF( kiomid > 0 ) THEN |
---|
[10425] | 1439 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_putatt( kiomid, cdatt, katt0d = katt0d, cdvar=cdvar ) |
---|
[7646] | 1440 | ENDIF |
---|
| 1441 | END SUBROUTINE iom_p0d_iatt |
---|
| 1442 | |
---|
[10425] | 1443 | SUBROUTINE iom_p1d_iatt( kiomid, cdatt, katt1d, cdvar ) |
---|
| 1444 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1445 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1446 | INTEGER, DIMENSION(:) , INTENT(in ) :: katt1d ! written field |
---|
| 1447 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
[7646] | 1448 | ! |
---|
| 1449 | IF( kiomid > 0 ) THEN |
---|
[10425] | 1450 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_putatt( kiomid, cdatt, katt1d = katt1d, cdvar=cdvar ) |
---|
[7646] | 1451 | ENDIF |
---|
[10425] | 1452 | END SUBROUTINE iom_p1d_iatt |
---|
| 1453 | |
---|
| 1454 | SUBROUTINE iom_p0d_ratt( kiomid, cdatt, patt0d, cdvar ) |
---|
| 1455 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1456 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1457 | REAL(wp) , INTENT(in ) :: patt0d ! written field |
---|
| 1458 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
| 1459 | ! |
---|
| 1460 | IF( kiomid > 0 ) THEN |
---|
| 1461 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_putatt( kiomid, cdatt, patt0d = patt0d, cdvar=cdvar ) |
---|
| 1462 | ENDIF |
---|
[7646] | 1463 | END SUBROUTINE iom_p0d_ratt |
---|
| 1464 | |
---|
[10425] | 1465 | SUBROUTINE iom_p1d_ratt( kiomid, cdatt, patt1d, cdvar ) |
---|
| 1466 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1467 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1468 | REAL(wp), DIMENSION(:), INTENT(in ) :: patt1d ! written field |
---|
| 1469 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
[7646] | 1470 | ! |
---|
| 1471 | IF( kiomid > 0 ) THEN |
---|
[10425] | 1472 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_putatt( kiomid, cdatt, patt1d = patt1d, cdvar=cdvar ) |
---|
[7646] | 1473 | ENDIF |
---|
[10425] | 1474 | END SUBROUTINE iom_p1d_ratt |
---|
| 1475 | |
---|
| 1476 | SUBROUTINE iom_p0d_catt( kiomid, cdatt, cdatt0d, cdvar ) |
---|
| 1477 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
| 1478 | CHARACTER(len=*) , INTENT(in ) :: cdatt ! Name of the attribute |
---|
| 1479 | CHARACTER(len=*) , INTENT(in ) :: cdatt0d ! written field |
---|
| 1480 | CHARACTER(len=*) , INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
| 1481 | ! |
---|
| 1482 | IF( kiomid > 0 ) THEN |
---|
| 1483 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_nf90_putatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar ) |
---|
| 1484 | ENDIF |
---|
[7646] | 1485 | END SUBROUTINE iom_p0d_catt |
---|
| 1486 | |
---|
[10425] | 1487 | |
---|
[7646] | 1488 | !!---------------------------------------------------------------------- |
---|
[544] | 1489 | !! INTERFACE iom_rstput |
---|
| 1490 | !!---------------------------------------------------------------------- |
---|
[9367] | 1491 | SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios ) |
---|
[544] | 1492 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
| 1493 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
| 1494 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
| 1495 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
[556] | 1496 | REAL(wp) , INTENT(in) :: pvar ! written field |
---|
[544] | 1497 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
[9367] | 1498 | LOGICAL, OPTIONAL :: ldxios ! xios write flag |
---|
| 1499 | LOGICAL :: llx ! local xios write flag |
---|
[544] | 1500 | INTEGER :: ivid ! variable id |
---|
[9367] | 1501 | |
---|
| 1502 | llx = .FALSE. |
---|
| 1503 | IF(PRESENT(ldxios)) llx = ldxios |
---|
| 1504 | IF( llx ) THEN |
---|
| 1505 | #ifdef key_iomput |
---|
| 1506 | IF( kt == kwrite ) THEN |
---|
| 1507 | IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar) |
---|
| 1508 | CALL xios_send_field(trim(cdvar), pvar) |
---|
[12950] | 1509 | ELSE |
---|
| 1510 | IF(lwp) write(numout,*) 'RESTART: define (XIOS 0D) ',trim(cdvar) |
---|
| 1511 | CALL iom_set_rstw_active( trim(cdvar), rd0 = pvar ) |
---|
[9367] | 1512 | ENDIF |
---|
| 1513 | #endif |
---|
| 1514 | ELSE |
---|
| 1515 | IF( kiomid > 0 ) THEN |
---|
| 1516 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
| 1517 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
[10425] | 1518 | CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar ) |
---|
[9367] | 1519 | ENDIF |
---|
[679] | 1520 | ENDIF |
---|
| 1521 | ENDIF |
---|
[550] | 1522 | END SUBROUTINE iom_rp0d |
---|
[544] | 1523 | |
---|
[9367] | 1524 | SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios ) |
---|
[544] | 1525 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
| 1526 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
| 1527 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
| 1528 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
[2715] | 1529 | REAL(wp) , INTENT(in), DIMENSION( :) :: pvar ! written field |
---|
[544] | 1530 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
[9367] | 1531 | LOGICAL, OPTIONAL :: ldxios ! xios write flag |
---|
| 1532 | LOGICAL :: llx ! local xios write flag |
---|
[544] | 1533 | INTEGER :: ivid ! variable id |
---|
[9367] | 1534 | |
---|
| 1535 | llx = .FALSE. |
---|
| 1536 | IF(PRESENT(ldxios)) llx = ldxios |
---|
| 1537 | IF( llx ) THEN |
---|
| 1538 | #ifdef key_iomput |
---|
| 1539 | IF( kt == kwrite ) THEN |
---|
| 1540 | IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar) |
---|
| 1541 | CALL xios_send_field(trim(cdvar), pvar) |
---|
[12950] | 1542 | ELSE |
---|
| 1543 | IF(lwp) write(numout,*) 'RESTART: define (XIOS 1D) ',trim(cdvar) |
---|
| 1544 | CALL iom_set_rstw_active( trim(cdvar), rd1 = pvar ) |
---|
[9367] | 1545 | ENDIF |
---|
| 1546 | #endif |
---|
| 1547 | ELSE |
---|
| 1548 | IF( kiomid > 0 ) THEN |
---|
| 1549 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
| 1550 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
[10425] | 1551 | CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar ) |
---|
[9367] | 1552 | ENDIF |
---|
[679] | 1553 | ENDIF |
---|
| 1554 | ENDIF |
---|
[550] | 1555 | END SUBROUTINE iom_rp1d |
---|
[544] | 1556 | |
---|
[9367] | 1557 | SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios ) |
---|
[544] | 1558 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
| 1559 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
| 1560 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
| 1561 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
[2715] | 1562 | REAL(wp) , INTENT(in), DIMENSION(:, : ) :: pvar ! written field |
---|
[544] | 1563 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
[9367] | 1564 | LOGICAL, OPTIONAL :: ldxios ! xios write flag |
---|
| 1565 | LOGICAL :: llx |
---|
[544] | 1566 | INTEGER :: ivid ! variable id |
---|
[9367] | 1567 | |
---|
| 1568 | llx = .FALSE. |
---|
| 1569 | IF(PRESENT(ldxios)) llx = ldxios |
---|
| 1570 | IF( llx ) THEN |
---|
| 1571 | #ifdef key_iomput |
---|
| 1572 | IF( kt == kwrite ) THEN |
---|
| 1573 | IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar) |
---|
| 1574 | CALL xios_send_field(trim(cdvar), pvar) |
---|
[12950] | 1575 | ELSE |
---|
| 1576 | IF(lwp) write(numout,*) 'RESTART: define (XIOS 2D) ',trim(cdvar) |
---|
| 1577 | CALL iom_set_rstw_active( trim(cdvar), rd2 = pvar ) |
---|
[9367] | 1578 | ENDIF |
---|
| 1579 | #endif |
---|
| 1580 | ELSE |
---|
| 1581 | IF( kiomid > 0 ) THEN |
---|
| 1582 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
| 1583 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
[10425] | 1584 | CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar ) |
---|
[9367] | 1585 | ENDIF |
---|
[679] | 1586 | ENDIF |
---|
| 1587 | ENDIF |
---|
[550] | 1588 | END SUBROUTINE iom_rp2d |
---|
[544] | 1589 | |
---|
[9367] | 1590 | SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios ) |
---|
[544] | 1591 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
| 1592 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
| 1593 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
| 1594 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
[2715] | 1595 | REAL(wp) , INTENT(in), DIMENSION(:,:,:) :: pvar ! written field |
---|
[544] | 1596 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
[9367] | 1597 | LOGICAL, OPTIONAL :: ldxios ! xios write flag |
---|
| 1598 | LOGICAL :: llx ! local xios write flag |
---|
[544] | 1599 | INTEGER :: ivid ! variable id |
---|
[9367] | 1600 | |
---|
| 1601 | llx = .FALSE. |
---|
| 1602 | IF(PRESENT(ldxios)) llx = ldxios |
---|
| 1603 | IF( llx ) THEN |
---|
| 1604 | #ifdef key_iomput |
---|
| 1605 | IF( kt == kwrite ) THEN |
---|
| 1606 | IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar) |
---|
| 1607 | CALL xios_send_field(trim(cdvar), pvar) |
---|
[12950] | 1608 | ELSE |
---|
| 1609 | IF(lwp) write(numout,*) 'RESTART: define (XIOS 3D) ',trim(cdvar) |
---|
| 1610 | CALL iom_set_rstw_active( trim(cdvar), rd3 = pvar ) |
---|
[9367] | 1611 | ENDIF |
---|
| 1612 | #endif |
---|
| 1613 | ELSE |
---|
| 1614 | IF( kiomid > 0 ) THEN |
---|
| 1615 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
| 1616 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
[10425] | 1617 | CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar ) |
---|
[9367] | 1618 | ENDIF |
---|
[679] | 1619 | ENDIF |
---|
| 1620 | ENDIF |
---|
[550] | 1621 | END SUBROUTINE iom_rp3d |
---|
[1359] | 1622 | |
---|
| 1623 | |
---|
[10425] | 1624 | SUBROUTINE iom_delay_rst( cdaction, cdcpnt, kncid ) |
---|
| 1625 | !!--------------------------------------------------------------------- |
---|
| 1626 | !! Routine iom_delay_rst: used read/write restart related to mpp_delay |
---|
| 1627 | !! |
---|
| 1628 | !!--------------------------------------------------------------------- |
---|
| 1629 | CHARACTER(len=*), INTENT(in ) :: cdaction ! |
---|
| 1630 | CHARACTER(len=*), INTENT(in ) :: cdcpnt |
---|
| 1631 | INTEGER , INTENT(in ) :: kncid |
---|
| 1632 | ! |
---|
| 1633 | INTEGER :: ji |
---|
| 1634 | INTEGER :: indim |
---|
| 1635 | LOGICAL :: llattexist |
---|
| 1636 | REAL(wp), ALLOCATABLE, DIMENSION(:) :: zreal1d |
---|
| 1637 | !!--------------------------------------------------------------------- |
---|
| 1638 | ! |
---|
| 1639 | ! =================================== |
---|
| 1640 | IF( TRIM(cdaction) == 'READ' ) THEN ! read restart related to mpp_delay ! |
---|
| 1641 | ! =================================== |
---|
| 1642 | DO ji = 1, nbdelay |
---|
| 1643 | IF ( c_delaycpnt(ji) == cdcpnt ) THEN |
---|
| 1644 | CALL iom_chkatt( kncid, 'DELAY_'//c_delaylist(ji), llattexist, indim ) |
---|
| 1645 | IF( llattexist ) THEN |
---|
| 1646 | ALLOCATE( todelay(ji)%z1d(indim) ) |
---|
| 1647 | CALL iom_getatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) ) |
---|
| 1648 | ndelayid(ji) = 0 ! set to 0 to specify that the value was read in the restart |
---|
| 1649 | ENDIF |
---|
| 1650 | ENDIF |
---|
| 1651 | END DO |
---|
| 1652 | ! ==================================== |
---|
| 1653 | ELSE ! write restart related to mpp_delay ! |
---|
| 1654 | ! ==================================== |
---|
| 1655 | DO ji = 1, nbdelay ! save only ocean delayed global communication variables |
---|
| 1656 | IF ( c_delaycpnt(ji) == cdcpnt ) THEN |
---|
| 1657 | IF( ASSOCIATED(todelay(ji)%z1d) ) THEN |
---|
| 1658 | CALL mpp_delay_rcv(ji) ! make sure %z1d is received |
---|
| 1659 | CALL iom_putatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) ) |
---|
| 1660 | ENDIF |
---|
| 1661 | ENDIF |
---|
| 1662 | END DO |
---|
| 1663 | ! |
---|
| 1664 | ENDIF |
---|
| 1665 | |
---|
| 1666 | END SUBROUTINE iom_delay_rst |
---|
| 1667 | |
---|
| 1668 | |
---|
| 1669 | |
---|
[544] | 1670 | !!---------------------------------------------------------------------- |
---|
[1457] | 1671 | !! INTERFACE iom_put |
---|
[1359] | 1672 | !!---------------------------------------------------------------------- |
---|
[1738] | 1673 | SUBROUTINE iom_p0d( cdname, pfield0d ) |
---|
| 1674 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
| 1675 | REAL(wp) , INTENT(in) :: pfield0d |
---|
[11536] | 1676 | !! REAL(wp) , DIMENSION(jpi,jpj) :: zz ! masson |
---|
[1738] | 1677 | #if defined key_iomput |
---|
[11536] | 1678 | !!clem zz(:,:)=pfield0d |
---|
| 1679 | !!clem CALL xios_send_field(cdname, zz) |
---|
| 1680 | CALL xios_send_field(cdname, (/pfield0d/)) |
---|
[1738] | 1681 | #else |
---|
| 1682 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield0d ! useless test to avoid compilation warnings |
---|
| 1683 | #endif |
---|
| 1684 | END SUBROUTINE iom_p0d |
---|
| 1685 | |
---|
[3294] | 1686 | SUBROUTINE iom_p1d( cdname, pfield1d ) |
---|
| 1687 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
| 1688 | REAL(wp), DIMENSION(:), INTENT(in) :: pfield1d |
---|
| 1689 | #if defined key_iomput |
---|
[3695] | 1690 | CALL xios_send_field( cdname, RESHAPE( (/pfield1d/), (/1,1,SIZE(pfield1d)/) ) ) |
---|
[3294] | 1691 | #else |
---|
| 1692 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield1d ! useless test to avoid compilation warnings |
---|
| 1693 | #endif |
---|
| 1694 | END SUBROUTINE iom_p1d |
---|
| 1695 | |
---|
[1359] | 1696 | SUBROUTINE iom_p2d( cdname, pfield2d ) |
---|
| 1697 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
[2715] | 1698 | REAL(wp), DIMENSION(:,:), INTENT(in) :: pfield2d |
---|
[1412] | 1699 | #if defined key_iomput |
---|
[3695] | 1700 | CALL xios_send_field(cdname, pfield2d) |
---|
[1520] | 1701 | #else |
---|
| 1702 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield2d ! useless test to avoid compilation warnings |
---|
[1359] | 1703 | #endif |
---|
| 1704 | END SUBROUTINE iom_p2d |
---|
[544] | 1705 | |
---|
[1359] | 1706 | SUBROUTINE iom_p3d( cdname, pfield3d ) |
---|
| 1707 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
[2715] | 1708 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: pfield3d |
---|
[1412] | 1709 | #if defined key_iomput |
---|
[9019] | 1710 | CALL xios_send_field( cdname, pfield3d ) |
---|
[1520] | 1711 | #else |
---|
| 1712 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield3d ! useless test to avoid compilation warnings |
---|
[1359] | 1713 | #endif |
---|
| 1714 | END SUBROUTINE iom_p3d |
---|
[544] | 1715 | |
---|
[12276] | 1716 | SUBROUTINE iom_p4d( cdname, pfield4d ) |
---|
[12377] | 1717 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
[12276] | 1718 | REAL(wp), DIMENSION(:,:,:,:), INTENT(in) :: pfield4d |
---|
[1412] | 1719 | #if defined key_iomput |
---|
[12276] | 1720 | CALL xios_send_field(cdname, pfield4d) |
---|
| 1721 | #else |
---|
| 1722 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield4d ! useless test to avoid compilation warnings |
---|
| 1723 | #endif |
---|
| 1724 | END SUBROUTINE iom_p4d |
---|
| 1725 | |
---|
| 1726 | |
---|
| 1727 | #if defined key_iomput |
---|
[9019] | 1728 | !!---------------------------------------------------------------------- |
---|
[9802] | 1729 | !! 'key_iomput' XIOS interface |
---|
[9019] | 1730 | !!---------------------------------------------------------------------- |
---|
[1359] | 1731 | |
---|
[9930] | 1732 | SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, & |
---|
[5363] | 1733 | & data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask, & |
---|
[5415] | 1734 | & nvertex, bounds_lon, bounds_lat, area ) |
---|
[9019] | 1735 | !!---------------------------------------------------------------------- |
---|
| 1736 | !!---------------------------------------------------------------------- |
---|
| 1737 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
| 1738 | INTEGER , OPTIONAL, INTENT(in) :: ni_glo, nj_glo, ibegin, jbegin, ni, nj |
---|
| 1739 | INTEGER , OPTIONAL, INTENT(in) :: data_dim, data_ibegin, data_ni, data_jbegin, data_nj |
---|
[9930] | 1740 | INTEGER , OPTIONAL, INTENT(in) :: nvertex |
---|
[9019] | 1741 | REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) :: lonvalue, latvalue |
---|
| 1742 | REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) :: bounds_lon, bounds_lat, area |
---|
| 1743 | LOGICAL , DIMENSION(:) , OPTIONAL, INTENT(in) :: mask |
---|
| 1744 | !!---------------------------------------------------------------------- |
---|
| 1745 | ! |
---|
| 1746 | IF( xios_is_valid_domain (cdid) ) THEN |
---|
[4148] | 1747 | CALL xios_set_domain_attr ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & |
---|
| 1748 | & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & |
---|
[7646] | 1749 | & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & |
---|
| 1750 | & bounds_lat_1D=bounds_lat, area=area, type='curvilinear') |
---|
[9367] | 1751 | ENDIF |
---|
[9019] | 1752 | IF( xios_is_valid_domaingroup(cdid) ) THEN |
---|
[4148] | 1753 | CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & |
---|
| 1754 | & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & |
---|
[7646] | 1755 | & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & |
---|
| 1756 | & bounds_lat_1D=bounds_lat, area=area, type='curvilinear' ) |
---|
[3695] | 1757 | ENDIF |
---|
[9019] | 1758 | ! |
---|
[4148] | 1759 | CALL xios_solve_inheritance() |
---|
[9019] | 1760 | ! |
---|
[3695] | 1761 | END SUBROUTINE iom_set_domain_attr |
---|
| 1762 | |
---|
| 1763 | |
---|
[9019] | 1764 | SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj ) |
---|
| 1765 | !!---------------------------------------------------------------------- |
---|
| 1766 | !!---------------------------------------------------------------------- |
---|
[9930] | 1767 | CHARACTER(LEN=*), INTENT(in) :: cdid |
---|
| 1768 | INTEGER , INTENT(in) :: ibegin, jbegin, ni, nj |
---|
| 1769 | ! |
---|
| 1770 | TYPE(xios_gridgroup) :: gridgroup_hdl |
---|
| 1771 | TYPE(xios_grid) :: grid_hdl |
---|
| 1772 | TYPE(xios_domain) :: domain_hdl |
---|
| 1773 | TYPE(xios_axis) :: axis_hdl |
---|
| 1774 | CHARACTER(LEN=64) :: cldomrefid ! domain_ref name |
---|
| 1775 | CHARACTER(len=1) :: cl1 ! last character of this name |
---|
[9019] | 1776 | !!---------------------------------------------------------------------- |
---|
[9930] | 1777 | ! |
---|
| 1778 | IF( xios_is_valid_zoom_domain(cdid) ) THEN |
---|
| 1779 | ! define the zoom_domain attributs |
---|
| 1780 | CALL xios_set_zoom_domain_attr( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj ) |
---|
| 1781 | ! define a new 2D grid with this new domain |
---|
| 1782 | CALL xios_get_handle("grid_definition", gridgroup_hdl ) |
---|
| 1783 | CALL xios_add_child(gridgroup_hdl, grid_hdl, TRIM(cdid)//'_2D' ) ! add a new 2D grid to grid_definition |
---|
| 1784 | CALL xios_add_child(grid_hdl, domain_hdl, TRIM(cdid) ) ! add its domain |
---|
| 1785 | ! define a new 3D grid with this new domain |
---|
| 1786 | CALL xios_add_child(gridgroup_hdl, grid_hdl, TRIM(cdid)//'_3D' ) ! add a new 3D grid to grid_definition |
---|
| 1787 | CALL xios_add_child(grid_hdl, domain_hdl, TRIM(cdid) ) ! add its domain |
---|
| 1788 | ! vertical axis |
---|
| 1789 | cl1 = cdid(LEN_TRIM(cdid):) ! last letter of cdid |
---|
| 1790 | cl1 = CHAR(ICHAR(cl1)+32) ! from upper to lower case |
---|
| 1791 | CALL xios_add_child(grid_hdl, axis_hdl, 'depth'//cl1) ! add its axis |
---|
| 1792 | ENDIF |
---|
| 1793 | ! |
---|
[7646] | 1794 | END SUBROUTINE iom_set_zoom_domain_attr |
---|
| 1795 | |
---|
| 1796 | |
---|
[5415] | 1797 | SUBROUTINE iom_set_axis_attr( cdid, paxis, bounds ) |
---|
[9019] | 1798 | !!---------------------------------------------------------------------- |
---|
| 1799 | !!---------------------------------------------------------------------- |
---|
[4148] | 1800 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
[5415] | 1801 | REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) :: paxis |
---|
| 1802 | REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) :: bounds |
---|
[9019] | 1803 | !!---------------------------------------------------------------------- |
---|
| 1804 | IF( PRESENT(paxis) ) THEN |
---|
| 1805 | IF( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, n_glo=SIZE(paxis), value=paxis ) |
---|
| 1806 | IF( xios_is_valid_axisgroup(cdid) ) CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) |
---|
[5415] | 1807 | ENDIF |
---|
[9019] | 1808 | IF( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, bounds=bounds ) |
---|
| 1809 | IF( xios_is_valid_axisgroup(cdid) ) CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) |
---|
[4148] | 1810 | CALL xios_solve_inheritance() |
---|
[3737] | 1811 | END SUBROUTINE iom_set_axis_attr |
---|
| 1812 | |
---|
| 1813 | |
---|
[4148] | 1814 | SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset ) |
---|
[9019] | 1815 | !!---------------------------------------------------------------------- |
---|
| 1816 | !!---------------------------------------------------------------------- |
---|
| 1817 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
| 1818 | TYPE(xios_duration), OPTIONAL, INTENT(in) :: freq_op |
---|
| 1819 | TYPE(xios_duration), OPTIONAL, INTENT(in) :: freq_offset |
---|
| 1820 | !!---------------------------------------------------------------------- |
---|
| 1821 | IF( xios_is_valid_field (cdid) ) CALL xios_set_field_attr ( cdid, freq_op=freq_op, freq_offset=freq_offset ) |
---|
| 1822 | IF( xios_is_valid_fieldgroup(cdid) ) CALL xios_set_fieldgroup_attr( cdid, freq_op=freq_op, freq_offset=freq_offset ) |
---|
[4148] | 1823 | CALL xios_solve_inheritance() |
---|
[3695] | 1824 | END SUBROUTINE iom_set_field_attr |
---|
| 1825 | |
---|
| 1826 | |
---|
[4148] | 1827 | SUBROUTINE iom_set_file_attr( cdid, name, name_suffix ) |
---|
[9019] | 1828 | !!---------------------------------------------------------------------- |
---|
| 1829 | !!---------------------------------------------------------------------- |
---|
[4148] | 1830 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
[3695] | 1831 | CHARACTER(LEN=*),OPTIONAL , INTENT(in) :: name, name_suffix |
---|
[9019] | 1832 | !!---------------------------------------------------------------------- |
---|
| 1833 | IF( xios_is_valid_file (cdid) ) CALL xios_set_file_attr ( cdid, name=name, name_suffix=name_suffix ) |
---|
| 1834 | IF( xios_is_valid_filegroup(cdid) ) CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix ) |
---|
[4148] | 1835 | CALL xios_solve_inheritance() |
---|
[3771] | 1836 | END SUBROUTINE iom_set_file_attr |
---|
[3695] | 1837 | |
---|
| 1838 | |
---|
[4148] | 1839 | SUBROUTINE iom_get_file_attr( cdid, name, name_suffix, output_freq ) |
---|
[9019] | 1840 | !!---------------------------------------------------------------------- |
---|
| 1841 | !!---------------------------------------------------------------------- |
---|
[4148] | 1842 | CHARACTER(LEN=*) , INTENT(in ) :: cdid |
---|
[7646] | 1843 | CHARACTER(LEN=*),OPTIONAL , INTENT(out) :: name, name_suffix |
---|
| 1844 | TYPE(xios_duration), OPTIONAL , INTENT(out) :: output_freq |
---|
[4148] | 1845 | LOGICAL :: llexist1,llexist2,llexist3 |
---|
| 1846 | !--------------------------------------------------------------------- |
---|
| 1847 | IF( PRESENT( name ) ) name = '' ! default values |
---|
| 1848 | IF( PRESENT( name_suffix ) ) name_suffix = '' |
---|
[7646] | 1849 | IF( PRESENT( output_freq ) ) output_freq = xios_duration(0,0,0,0,0,0) |
---|
[9019] | 1850 | IF( xios_is_valid_file (cdid) ) THEN |
---|
[4148] | 1851 | CALL xios_solve_inheritance() |
---|
| 1852 | CALL xios_is_defined_file_attr ( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) |
---|
| 1853 | IF(llexist1) CALL xios_get_file_attr ( cdid, name = name ) |
---|
| 1854 | IF(llexist2) CALL xios_get_file_attr ( cdid, name_suffix = name_suffix ) |
---|
| 1855 | IF(llexist3) CALL xios_get_file_attr ( cdid, output_freq = output_freq ) |
---|
| 1856 | ENDIF |
---|
[9019] | 1857 | IF( xios_is_valid_filegroup(cdid) ) THEN |
---|
[4148] | 1858 | CALL xios_solve_inheritance() |
---|
| 1859 | CALL xios_is_defined_filegroup_attr( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) |
---|
| 1860 | IF(llexist1) CALL xios_get_filegroup_attr( cdid, name = name ) |
---|
| 1861 | IF(llexist2) CALL xios_get_filegroup_attr( cdid, name_suffix = name_suffix ) |
---|
| 1862 | IF(llexist3) CALL xios_get_filegroup_attr( cdid, output_freq = output_freq ) |
---|
| 1863 | ENDIF |
---|
| 1864 | END SUBROUTINE iom_get_file_attr |
---|
| 1865 | |
---|
| 1866 | |
---|
| 1867 | SUBROUTINE iom_set_grid_attr( cdid, mask ) |
---|
[9019] | 1868 | !!---------------------------------------------------------------------- |
---|
| 1869 | !!---------------------------------------------------------------------- |
---|
[4148] | 1870 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
[3771] | 1871 | LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) :: mask |
---|
[9019] | 1872 | !!---------------------------------------------------------------------- |
---|
| 1873 | IF( xios_is_valid_grid (cdid) ) CALL xios_set_grid_attr ( cdid, mask_3D=mask ) |
---|
| 1874 | IF( xios_is_valid_gridgroup(cdid) ) CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) |
---|
[4148] | 1875 | CALL xios_solve_inheritance() |
---|
[3771] | 1876 | END SUBROUTINE iom_set_grid_attr |
---|
[3695] | 1877 | |
---|
[4152] | 1878 | SUBROUTINE iom_setkt( kt, cdname ) |
---|
[9019] | 1879 | !!---------------------------------------------------------------------- |
---|
| 1880 | !!---------------------------------------------------------------------- |
---|
[4152] | 1881 | INTEGER , INTENT(in) :: kt |
---|
| 1882 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
[9019] | 1883 | !!---------------------------------------------------------------------- |
---|
[4152] | 1884 | CALL iom_swap( cdname ) ! swap to cdname context |
---|
| 1885 | CALL xios_update_calendar(kt) |
---|
[9019] | 1886 | IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) ) ! return back to nemo context |
---|
[4152] | 1887 | END SUBROUTINE iom_setkt |
---|
[3695] | 1888 | |
---|
[4152] | 1889 | SUBROUTINE iom_context_finalize( cdname ) |
---|
[9019] | 1890 | !!---------------------------------------------------------------------- |
---|
| 1891 | !!---------------------------------------------------------------------- |
---|
[4152] | 1892 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
[9367] | 1893 | CHARACTER(LEN=120) :: clname |
---|
[9019] | 1894 | !!---------------------------------------------------------------------- |
---|
[9367] | 1895 | clname = cdname |
---|
[12957] | 1896 | IF(lwp) write(numout, *) 'Finalize: ', TRIM(cdname) |
---|
[9367] | 1897 | IF( TRIM(Agrif_CFixed()) .NE. '0' ) clname = TRIM(Agrif_CFixed())//"_"//clname |
---|
| 1898 | IF( xios_is_valid_context(clname) ) THEN |
---|
[4990] | 1899 | CALL iom_swap( cdname ) ! swap to cdname context |
---|
| 1900 | CALL xios_context_finalize() ! finalize the context |
---|
[5407] | 1901 | IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) ) ! return back to nemo context |
---|
[4990] | 1902 | ENDIF |
---|
[9367] | 1903 | ! |
---|
[4152] | 1904 | END SUBROUTINE iom_context_finalize |
---|
| 1905 | |
---|
| 1906 | |
---|
[9984] | 1907 | SUBROUTINE set_grid( cdgrd, plon, plat, ldxios, ldrxios ) |
---|
[1359] | 1908 | !!---------------------------------------------------------------------- |
---|
[4148] | 1909 | !! *** ROUTINE set_grid *** |
---|
[1359] | 1910 | !! |
---|
[1725] | 1911 | !! ** Purpose : define horizontal grids |
---|
[1359] | 1912 | !!---------------------------------------------------------------------- |
---|
[3771] | 1913 | CHARACTER(LEN=1) , INTENT(in) :: cdgrd |
---|
[1359] | 1914 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plon |
---|
| 1915 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plat |
---|
[3771] | 1916 | ! |
---|
[9019] | 1917 | INTEGER :: ni, nj |
---|
[3771] | 1918 | REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmask |
---|
[9984] | 1919 | LOGICAL, INTENT(IN) :: ldxios, ldrxios |
---|
[9019] | 1920 | !!---------------------------------------------------------------------- |
---|
| 1921 | ! |
---|
| 1922 | ni = nlei-nldi+1 |
---|
| 1923 | nj = nlej-nldj+1 |
---|
| 1924 | ! |
---|
[7646] | 1925 | CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) |
---|
[3771] | 1926 | CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) |
---|
[9984] | 1927 | !don't define lon and lat for restart reading context. |
---|
| 1928 | IF ( .NOT.ldrxios ) & |
---|
| 1929 | CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)), & |
---|
[3771] | 1930 | & latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /))) |
---|
[9019] | 1931 | ! |
---|
[9367] | 1932 | IF ( ln_mskland .AND. (.NOT.ldxios) ) THEN |
---|
[3771] | 1933 | ! mask land points, keep values on coast line -> specific mask for U, V and W points |
---|
| 1934 | SELECT CASE ( cdgrd ) |
---|
| 1935 | CASE('T') ; zmask(:,:,:) = tmask(:,:,:) |
---|
[10425] | 1936 | CASE('U') ; zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:) ; CALL lbc_lnk( 'iom', zmask, 'U', 1. ) |
---|
| 1937 | CASE('V') ; zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:) ; CALL lbc_lnk( 'iom', zmask, 'V', 1. ) |
---|
[3771] | 1938 | CASE('W') ; zmask(:,:,2:jpk ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk) ; zmask(:,:,1) = tmask(:,:,1) |
---|
| 1939 | END SELECT |
---|
| 1940 | ! |
---|
[7646] | 1941 | CALL iom_set_domain_attr( "grid_"//cdgrd , mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,1),(/ni*nj /)) /= 0. ) |
---|
[4148] | 1942 | CALL iom_set_grid_attr ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. ) |
---|
[3771] | 1943 | ENDIF |
---|
[9019] | 1944 | ! |
---|
[1359] | 1945 | END SUBROUTINE set_grid |
---|
| 1946 | |
---|
[1725] | 1947 | |
---|
[5415] | 1948 | SUBROUTINE set_grid_bounds( cdgrd, plon_cnr, plat_cnr, plon_pnt, plat_pnt ) |
---|
[5363] | 1949 | !!---------------------------------------------------------------------- |
---|
| 1950 | !! *** ROUTINE set_grid_bounds *** |
---|
| 1951 | !! |
---|
| 1952 | !! ** Purpose : define horizontal grid corners |
---|
| 1953 | !! |
---|
| 1954 | !!---------------------------------------------------------------------- |
---|
[9019] | 1955 | CHARACTER(LEN=1) , INTENT(in) :: cdgrd |
---|
| 1956 | REAL(wp), DIMENSION(jpi,jpj) , INTENT(in) :: plon_cnr, plat_cnr ! Lat/lon coord. of a contiguous vertex of cell (i,j) |
---|
| 1957 | REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt ! Lat/lon coord. of the point of cell (i,j) |
---|
[5363] | 1958 | ! |
---|
[9019] | 1959 | INTEGER :: ji, jj, jn, ni, nj |
---|
[12377] | 1960 | INTEGER :: icnr, jcnr ! Offset such that the vertex coordinate (i+icnr,j+jcnr) |
---|
| 1961 | ! ! represents the bottom-left corner of cell (i,j) |
---|
[9019] | 1962 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: z_bnds ! Lat/lon coordinates of the vertices of cell (i,j) |
---|
| 1963 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_fld ! Working array to determine where to rotate cells |
---|
| 1964 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_rot ! Lat/lon working array for rotation of cells |
---|
| 1965 | !!---------------------------------------------------------------------- |
---|
[5415] | 1966 | ! |
---|
[9019] | 1967 | ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2) ) |
---|
[5363] | 1968 | ! |
---|
[5415] | 1969 | ! Offset of coordinate representing bottom-left corner |
---|
[5363] | 1970 | SELECT CASE ( TRIM(cdgrd) ) |
---|
[9019] | 1971 | CASE ('T', 'W') ; icnr = -1 ; jcnr = -1 |
---|
| 1972 | CASE ('U') ; icnr = 0 ; jcnr = -1 |
---|
| 1973 | CASE ('V') ; icnr = -1 ; jcnr = 0 |
---|
[5363] | 1974 | END SELECT |
---|
[9019] | 1975 | ! |
---|
| 1976 | ni = nlei-nldi+1 ! Dimensions of subdomain interior |
---|
| 1977 | nj = nlej-nldj+1 |
---|
| 1978 | ! |
---|
[5363] | 1979 | z_fld(:,:) = 1._wp |
---|
[10425] | 1980 | CALL lbc_lnk( 'iom', z_fld, cdgrd, -1. ) ! Working array for location of northfold |
---|
[9019] | 1981 | ! |
---|
[5363] | 1982 | ! Cell vertices that can be defined |
---|
| 1983 | DO jj = 2, jpjm1 |
---|
| 1984 | DO ji = 2, jpim1 |
---|
[5415] | 1985 | z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr, jj+jcnr ) ! Bottom-left |
---|
| 1986 | z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr ) ! Bottom-right |
---|
| 1987 | z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right |
---|
| 1988 | z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr, jj+jcnr+1) ! Top-left |
---|
| 1989 | z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr, jj+jcnr ) ! Bottom-left |
---|
| 1990 | z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr ) ! Bottom-right |
---|
| 1991 | z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right |
---|
| 1992 | z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr, jj+jcnr+1) ! Top-left |
---|
[5363] | 1993 | END DO |
---|
| 1994 | END DO |
---|
[9019] | 1995 | ! |
---|
[5363] | 1996 | ! Cell vertices on boundries |
---|
| 1997 | DO jn = 1, 4 |
---|
[11536] | 1998 | CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1., pfillval=999._wp ) |
---|
| 1999 | CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1., pfillval=999._wp ) |
---|
[5363] | 2000 | END DO |
---|
[9019] | 2001 | ! |
---|
[5415] | 2002 | ! Zero-size cells at closed boundaries if cell points provided, |
---|
| 2003 | ! otherwise they are closed cells with unrealistic bounds |
---|
| 2004 | IF( PRESENT(plon_pnt) .AND. PRESENT(plat_pnt) ) THEN |
---|
| 2005 | IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN |
---|
| 2006 | DO jn = 1, 4 ! (West or jpni = 1), closed E-W |
---|
| 2007 | z_bnds(jn,1,:,1) = plat_pnt(1,:) ; z_bnds(jn,1,:,2) = plon_pnt(1,:) |
---|
| 2008 | END DO |
---|
| 2009 | ENDIF |
---|
| 2010 | IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN |
---|
| 2011 | DO jn = 1, 4 ! (East or jpni = 1), closed E-W |
---|
| 2012 | z_bnds(jn,nlci,:,1) = plat_pnt(nlci,:) ; z_bnds(jn,nlci,:,2) = plon_pnt(nlci,:) |
---|
| 2013 | END DO |
---|
| 2014 | ENDIF |
---|
| 2015 | IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN |
---|
| 2016 | DO jn = 1, 4 ! South or (jpnj = 1, not symmetric) |
---|
| 2017 | z_bnds(jn,:,1,1) = plat_pnt(:,1) ; z_bnds(jn,:,1,2) = plon_pnt(:,1) |
---|
| 2018 | END DO |
---|
| 2019 | ENDIF |
---|
| 2020 | IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio < 3 ) THEN |
---|
| 2021 | DO jn = 1, 4 ! (North or jpnj = 1), no north fold |
---|
| 2022 | z_bnds(jn,:,nlcj,1) = plat_pnt(:,nlcj) ; z_bnds(jn,:,nlcj,2) = plon_pnt(:,nlcj) |
---|
| 2023 | END DO |
---|
| 2024 | ENDIF |
---|
[5363] | 2025 | ENDIF |
---|
[9019] | 2026 | ! |
---|
| 2027 | IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN ! Rotate cells at the north fold |
---|
[5363] | 2028 | DO jj = 1, jpj |
---|
| 2029 | DO ji = 1, jpi |
---|
| 2030 | IF( z_fld(ji,jj) == -1. ) THEN |
---|
| 2031 | z_rot(1,:) = z_bnds(3,ji,jj,:) ; z_rot(2,:) = z_bnds(4,ji,jj,:) |
---|
| 2032 | z_rot(3,:) = z_bnds(1,ji,jj,:) ; z_rot(4,:) = z_bnds(2,ji,jj,:) |
---|
| 2033 | z_bnds(:,ji,jj,:) = z_rot(:,:) |
---|
| 2034 | ENDIF |
---|
| 2035 | END DO |
---|
| 2036 | END DO |
---|
[9019] | 2037 | ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN ! Invert cells at the symmetric equator |
---|
[5363] | 2038 | DO ji = 1, jpi |
---|
| 2039 | z_rot(1:2,:) = z_bnds(3:4,ji,1,:) |
---|
| 2040 | z_rot(3:4,:) = z_bnds(1:2,ji,1,:) |
---|
| 2041 | z_bnds(:,ji,1,:) = z_rot(:,:) |
---|
| 2042 | END DO |
---|
| 2043 | ENDIF |
---|
[9019] | 2044 | ! |
---|
[5363] | 2045 | CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)), & |
---|
[9019] | 2046 | & bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) |
---|
| 2047 | ! |
---|
[5415] | 2048 | DEALLOCATE( z_bnds, z_fld, z_rot ) |
---|
[9019] | 2049 | ! |
---|
[5363] | 2050 | END SUBROUTINE set_grid_bounds |
---|
| 2051 | |
---|
| 2052 | |
---|
[5385] | 2053 | SUBROUTINE set_grid_znl( plat ) |
---|
| 2054 | !!---------------------------------------------------------------------- |
---|
| 2055 | !! *** ROUTINE set_grid_znl *** |
---|
| 2056 | !! |
---|
| 2057 | !! ** Purpose : define grids for zonal mean |
---|
| 2058 | !! |
---|
| 2059 | !!---------------------------------------------------------------------- |
---|
| 2060 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plat |
---|
| 2061 | ! |
---|
[9019] | 2062 | INTEGER :: ni, nj, ix, iy |
---|
[5385] | 2063 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zlon |
---|
[9019] | 2064 | !!---------------------------------------------------------------------- |
---|
| 2065 | ! |
---|
| 2066 | ni=nlei-nldi+1 ! define zonal mean domain (jpj*jpk) |
---|
| 2067 | nj=nlej-nldj+1 |
---|
| 2068 | ALLOCATE( zlon(ni*nj) ) ; zlon(:) = 0._wp |
---|
| 2069 | ! |
---|
[12276] | 2070 | ! CALL dom_ngb( -168.53, 65.03, ix, iy, 'T' ) ! i-line that passes through Bering Strait: Reference latitude (used in plots) |
---|
| 2071 | CALL dom_ngb( 180., 90., ix, iy, 'T' ) ! i-line that passes near the North Pole : Reference latitude (used in plots) |
---|
[7646] | 2072 | CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) |
---|
[5385] | 2073 | CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) |
---|
| 2074 | CALL iom_set_domain_attr("gznl", lonvalue = zlon, & |
---|
| 2075 | & latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /))) |
---|
[12276] | 2076 | CALL iom_set_zoom_domain_attr("ptr", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo) |
---|
[5385] | 2077 | ! |
---|
| 2078 | CALL iom_update_file_name('ptr') |
---|
| 2079 | ! |
---|
| 2080 | END SUBROUTINE set_grid_znl |
---|
| 2081 | |
---|
[9019] | 2082 | |
---|
[1738] | 2083 | SUBROUTINE set_scalar |
---|
| 2084 | !!---------------------------------------------------------------------- |
---|
[4148] | 2085 | !! *** ROUTINE set_scalar *** |
---|
[1738] | 2086 | !! |
---|
| 2087 | !! ** Purpose : define fake grids for scalar point |
---|
| 2088 | !! |
---|
| 2089 | !!---------------------------------------------------------------------- |
---|
[5426] | 2090 | REAL(wp), DIMENSION(1) :: zz = 1. |
---|
[1738] | 2091 | !!---------------------------------------------------------------------- |
---|
[9019] | 2092 | ! |
---|
[7646] | 2093 | CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea-1, jbegin=0, ni=1, nj=1) |
---|
[5426] | 2094 | CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) |
---|
[9019] | 2095 | ! |
---|
| 2096 | zz = REAL( narea, wp ) |
---|
[5426] | 2097 | CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz) |
---|
[9019] | 2098 | ! |
---|
[1738] | 2099 | END SUBROUTINE set_scalar |
---|
| 2100 | |
---|
| 2101 | |
---|
[1725] | 2102 | SUBROUTINE set_xmlatt |
---|
| 2103 | !!---------------------------------------------------------------------- |
---|
[4148] | 2104 | !! *** ROUTINE set_xmlatt *** |
---|
[1725] | 2105 | !! |
---|
| 2106 | !! ** Purpose : automatic definitions of some of the xml attributs... |
---|
| 2107 | !! |
---|
| 2108 | !!---------------------------------------------------------------------- |
---|
| 2109 | CHARACTER(len=1),DIMENSION( 3) :: clgrd ! suffix name |
---|
[4148] | 2110 | CHARACTER(len=256) :: clsuff ! suffix name |
---|
[1725] | 2111 | CHARACTER(len=1) :: cl1 ! 1 character |
---|
[5003] | 2112 | CHARACTER(len=2) :: cl2 ! 2 characters |
---|
| 2113 | CHARACTER(len=3) :: cl3 ! 3 characters |
---|
[4148] | 2114 | INTEGER :: ji, jg ! loop counters |
---|
[1725] | 2115 | INTEGER :: ix, iy ! i-,j- index |
---|
| 2116 | REAL(wp) ,DIMENSION(11) :: zlontao ! longitudes of tao moorings |
---|
| 2117 | REAL(wp) ,DIMENSION( 7) :: zlattao ! latitudes of tao moorings |
---|
| 2118 | REAL(wp) ,DIMENSION( 4) :: zlonrama ! longitudes of rama moorings |
---|
| 2119 | REAL(wp) ,DIMENSION(11) :: zlatrama ! latitudes of rama moorings |
---|
| 2120 | REAL(wp) ,DIMENSION( 3) :: zlonpira ! longitudes of pirata moorings |
---|
| 2121 | REAL(wp) ,DIMENSION( 9) :: zlatpira ! latitudes of pirata moorings |
---|
[7646] | 2122 | TYPE(xios_duration) :: f_op, f_of |
---|
[1725] | 2123 | !!---------------------------------------------------------------------- |
---|
| 2124 | ! |
---|
| 2125 | ! frequency of the call of iom_put (attribut: freq_op) |
---|
[9019] | 2126 | f_op%timestep = 1 ; f_of%timestep = 0 ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of) |
---|
| 2127 | f_op%timestep = 2 ; f_of%timestep = 0 ; CALL iom_set_field_attr('trendT_even' , freq_op=f_op, freq_offset=f_of) |
---|
| 2128 | f_op%timestep = 2 ; f_of%timestep = -1 ; CALL iom_set_field_attr('trendT_odd' , freq_op=f_op, freq_offset=f_of) |
---|
| 2129 | f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('SBC' , freq_op=f_op, freq_offset=f_of) |
---|
| 2130 | f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('SBC_scalar' , freq_op=f_op, freq_offset=f_of) |
---|
[12377] | 2131 | f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('ABL' , freq_op=f_op, freq_offset=f_of) |
---|
[7646] | 2132 | |
---|
[1725] | 2133 | ! output file names (attribut: name) |
---|
[4148] | 2134 | DO ji = 1, 9 |
---|
| 2135 | WRITE(cl1,'(i1)') ji |
---|
| 2136 | CALL iom_update_file_name('file'//cl1) |
---|
[1725] | 2137 | END DO |
---|
[4148] | 2138 | DO ji = 1, 99 |
---|
| 2139 | WRITE(cl2,'(i2.2)') ji |
---|
| 2140 | CALL iom_update_file_name('file'//cl2) |
---|
| 2141 | END DO |
---|
[5003] | 2142 | DO ji = 1, 999 |
---|
| 2143 | WRITE(cl3,'(i3.3)') ji |
---|
| 2144 | CALL iom_update_file_name('file'//cl3) |
---|
| 2145 | END DO |
---|
[1725] | 2146 | |
---|
| 2147 | ! Zooms... |
---|
| 2148 | clgrd = (/ 'T', 'U', 'W' /) |
---|
| 2149 | DO jg = 1, SIZE(clgrd) ! grid type |
---|
| 2150 | cl1 = clgrd(jg) |
---|
| 2151 | ! Equatorial section (attributs: jbegin, ni, name_suffix) |
---|
| 2152 | CALL dom_ngb( 0., 0., ix, iy, cl1 ) |
---|
[9930] | 2153 | CALL iom_set_zoom_domain_attr('Eq'//cl1, ibegin=0, jbegin=iy-1, ni=jpiglo, nj=1 ) |
---|
[4148] | 2154 | CALL iom_get_file_attr ('Eq'//cl1, name_suffix = clsuff ) |
---|
| 2155 | CALL iom_set_file_attr ('Eq'//cl1, name_suffix = TRIM(clsuff)//'_Eq') |
---|
| 2156 | CALL iom_update_file_name('Eq'//cl1) |
---|
[1725] | 2157 | END DO |
---|
| 2158 | ! TAO moorings (attributs: ibegin, jbegin, name_suffix) |
---|
| 2159 | zlontao = (/ 137.0, 147.0, 156.0, 165.0, -180.0, -170.0, -155.0, -140.0, -125.0, -110.0, -95.0 /) |
---|
| 2160 | zlattao = (/ -8.0, -5.0, -2.0, 0.0, 2.0, 5.0, 8.0 /) |
---|
| 2161 | CALL set_mooring( zlontao, zlattao ) |
---|
| 2162 | ! RAMA moorings (attributs: ibegin, jbegin, name_suffix) |
---|
| 2163 | zlonrama = (/ 55.0, 67.0, 80.5, 90.0 /) |
---|
| 2164 | zlatrama = (/ -16.0, -12.0, -8.0, -4.0, -1.5, 0.0, 1.5, 4.0, 8.0, 12.0, 15.0 /) |
---|
| 2165 | CALL set_mooring( zlonrama, zlatrama ) |
---|
| 2166 | ! PIRATA moorings (attributs: ibegin, jbegin, name_suffix) |
---|
| 2167 | zlonpira = (/ -38.0, -23.0, -10.0 /) |
---|
| 2168 | zlatpira = (/ -19.0, -14.0, -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /) |
---|
| 2169 | CALL set_mooring( zlonpira, zlatpira ) |
---|
[9019] | 2170 | ! |
---|
[1725] | 2171 | END SUBROUTINE set_xmlatt |
---|
| 2172 | |
---|
| 2173 | |
---|
[9019] | 2174 | SUBROUTINE set_mooring( plon, plat ) |
---|
[1725] | 2175 | !!---------------------------------------------------------------------- |
---|
[4148] | 2176 | !! *** ROUTINE set_mooring *** |
---|
[1725] | 2177 | !! |
---|
| 2178 | !! ** Purpose : automatic definitions of moorings xml attributs... |
---|
| 2179 | !! |
---|
| 2180 | !!---------------------------------------------------------------------- |
---|
[9019] | 2181 | REAL(wp), DIMENSION(:), INTENT(in) :: plon, plat ! longitudes/latitudes oft the mooring |
---|
[1725] | 2182 | ! |
---|
| 2183 | !!$ CHARACTER(len=1),DIMENSION(4) :: clgrd = (/ 'T', 'U', 'V', 'W' /) ! suffix name |
---|
| 2184 | CHARACTER(len=1),DIMENSION(1) :: clgrd = (/ 'T' /) ! suffix name |
---|
[4148] | 2185 | CHARACTER(len=256) :: clname ! file name |
---|
| 2186 | CHARACTER(len=256) :: clsuff ! suffix name |
---|
[1725] | 2187 | CHARACTER(len=1) :: cl1 ! 1 character |
---|
| 2188 | CHARACTER(len=6) :: clon,clat ! name of longitude, latitude |
---|
| 2189 | INTEGER :: ji, jj, jg ! loop counters |
---|
| 2190 | INTEGER :: ix, iy ! i-,j- index |
---|
| 2191 | REAL(wp) :: zlon, zlat |
---|
| 2192 | !!---------------------------------------------------------------------- |
---|
| 2193 | DO jg = 1, SIZE(clgrd) |
---|
| 2194 | cl1 = clgrd(jg) |
---|
| 2195 | DO ji = 1, SIZE(plon) |
---|
| 2196 | DO jj = 1, SIZE(plat) |
---|
| 2197 | zlon = plon(ji) |
---|
| 2198 | zlat = plat(jj) |
---|
| 2199 | ! modifications for RAMA moorings |
---|
| 2200 | IF( zlon == 67. .AND. zlat == 15. ) zlon = 65. |
---|
| 2201 | IF( zlon == 90. .AND. zlat <= -4. ) zlon = 95. |
---|
| 2202 | IF( zlon == 95. .AND. zlat == -4. ) zlat = -5. |
---|
| 2203 | ! modifications for PIRATA moorings |
---|
| 2204 | IF( zlon == -38. .AND. zlat == -19. ) zlon = -34. |
---|
| 2205 | IF( zlon == -38. .AND. zlat == -14. ) zlon = -32. |
---|
| 2206 | IF( zlon == -38. .AND. zlat == -8. ) zlon = -30. |
---|
| 2207 | IF( zlon == -38. .AND. zlat == 0. ) zlon = -35. |
---|
| 2208 | IF( zlon == -23. .AND. zlat == 20. ) zlat = 21. |
---|
| 2209 | IF( zlon == -10. .AND. zlat == -14. ) zlat = -10. |
---|
| 2210 | IF( zlon == -10. .AND. zlat == -8. ) zlat = -6. |
---|
| 2211 | IF( zlon == -10. .AND. zlat == 4. ) THEN ; zlon = 0. ; zlat = 0. ; ENDIF |
---|
| 2212 | CALL dom_ngb( zlon, zlat, ix, iy, cl1 ) |
---|
| 2213 | IF( zlon >= 0. ) THEN |
---|
| 2214 | IF( zlon == REAL(NINT(zlon), wp) ) THEN ; WRITE(clon, '(i3, a)') NINT( zlon), 'e' |
---|
| 2215 | ELSE ; WRITE(clon, '(f5.1,a)') zlon , 'e' |
---|
| 2216 | ENDIF |
---|
| 2217 | ELSE |
---|
| 2218 | IF( zlon == REAL(NINT(zlon), wp) ) THEN ; WRITE(clon, '(i3, a)') NINT(-zlon), 'w' |
---|
| 2219 | ELSE ; WRITE(clon, '(f5.1,a)') -zlon , 'w' |
---|
| 2220 | ENDIF |
---|
| 2221 | ENDIF |
---|
| 2222 | IF( zlat >= 0. ) THEN |
---|
| 2223 | IF( zlat == REAL(NINT(zlat), wp) ) THEN ; WRITE(clat, '(i2, a)') NINT( zlat), 'n' |
---|
| 2224 | ELSE ; WRITE(clat, '(f4.1,a)') zlat , 'n' |
---|
| 2225 | ENDIF |
---|
| 2226 | ELSE |
---|
| 2227 | IF( zlat == REAL(NINT(zlat), wp) ) THEN ; WRITE(clat, '(i2, a)') NINT(-zlat), 's' |
---|
| 2228 | ELSE ; WRITE(clat, '(f4.1,a)') -zlat , 's' |
---|
| 2229 | ENDIF |
---|
| 2230 | ENDIF |
---|
| 2231 | clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon)) |
---|
[9930] | 2232 | CALL iom_set_zoom_domain_attr(TRIM(clname)//cl1, ibegin= ix-1, jbegin= iy-1, ni=1, nj=1) |
---|
[7646] | 2233 | |
---|
[4148] | 2234 | CALL iom_get_file_attr (TRIM(clname)//cl1, name_suffix = clsuff ) |
---|
| 2235 | CALL iom_set_file_attr (TRIM(clname)//cl1, name_suffix = TRIM(clsuff)//'_'//TRIM(clname)) |
---|
| 2236 | CALL iom_update_file_name(TRIM(clname)//cl1) |
---|
[1725] | 2237 | END DO |
---|
| 2238 | END DO |
---|
| 2239 | END DO |
---|
| 2240 | |
---|
| 2241 | END SUBROUTINE set_mooring |
---|
| 2242 | |
---|
[4148] | 2243 | |
---|
| 2244 | SUBROUTINE iom_update_file_name( cdid ) |
---|
| 2245 | !!---------------------------------------------------------------------- |
---|
| 2246 | !! *** ROUTINE iom_update_file_name *** |
---|
| 2247 | !! |
---|
| 2248 | !! ** Purpose : |
---|
| 2249 | !! |
---|
| 2250 | !!---------------------------------------------------------------------- |
---|
| 2251 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
| 2252 | ! |
---|
| 2253 | CHARACTER(LEN=256) :: clname |
---|
| 2254 | CHARACTER(LEN=20) :: clfreq |
---|
| 2255 | CHARACTER(LEN=20) :: cldate |
---|
| 2256 | INTEGER :: idx |
---|
| 2257 | INTEGER :: jn |
---|
| 2258 | INTEGER :: itrlen |
---|
| 2259 | INTEGER :: iyear, imonth, iday, isec |
---|
| 2260 | REAL(wp) :: zsec |
---|
| 2261 | LOGICAL :: llexist |
---|
[7646] | 2262 | TYPE(xios_duration) :: output_freq |
---|
[4148] | 2263 | !!---------------------------------------------------------------------- |
---|
[9019] | 2264 | ! |
---|
| 2265 | DO jn = 1, 2 |
---|
| 2266 | ! |
---|
[7646] | 2267 | output_freq = xios_duration(0,0,0,0,0,0) |
---|
| 2268 | IF( jn == 1 ) CALL iom_get_file_attr( cdid, name = clname, output_freq = output_freq ) |
---|
[4148] | 2269 | IF( jn == 2 ) CALL iom_get_file_attr( cdid, name_suffix = clname ) |
---|
[9019] | 2270 | ! |
---|
[4148] | 2271 | IF ( TRIM(clname) /= '' ) THEN |
---|
[9019] | 2272 | ! |
---|
[4148] | 2273 | idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@') |
---|
| 2274 | DO WHILE ( idx /= 0 ) |
---|
| 2275 | clname = clname(1:idx-1)//TRIM(cexper)//clname(idx+9:LEN_TRIM(clname)) |
---|
| 2276 | idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@') |
---|
| 2277 | END DO |
---|
[9019] | 2278 | ! |
---|
[4148] | 2279 | idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') |
---|
| 2280 | DO WHILE ( idx /= 0 ) |
---|
[7646] | 2281 | IF ( output_freq%timestep /= 0) THEN |
---|
| 2282 | WRITE(clfreq,'(I18,A2)')INT(output_freq%timestep),'ts' |
---|
| 2283 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
[7764] | 2284 | ELSE IF ( output_freq%second /= 0 ) THEN |
---|
| 2285 | WRITE(clfreq,'(I19,A1)')INT(output_freq%second),'s' |
---|
| 2286 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
| 2287 | ELSE IF ( output_freq%minute /= 0 ) THEN |
---|
[7768] | 2288 | WRITE(clfreq,'(I18,A2)')INT(output_freq%minute),'mi' |
---|
[7764] | 2289 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
[7646] | 2290 | ELSE IF ( output_freq%hour /= 0 ) THEN |
---|
| 2291 | WRITE(clfreq,'(I19,A1)')INT(output_freq%hour),'h' |
---|
| 2292 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
| 2293 | ELSE IF ( output_freq%day /= 0 ) THEN |
---|
| 2294 | WRITE(clfreq,'(I19,A1)')INT(output_freq%day),'d' |
---|
| 2295 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
| 2296 | ELSE IF ( output_freq%month /= 0 ) THEN |
---|
| 2297 | WRITE(clfreq,'(I19,A1)')INT(output_freq%month),'m' |
---|
| 2298 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
| 2299 | ELSE IF ( output_freq%year /= 0 ) THEN |
---|
| 2300 | WRITE(clfreq,'(I19,A1)')INT(output_freq%year),'y' |
---|
| 2301 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
| 2302 | ELSE |
---|
[4148] | 2303 | CALL ctl_stop('error in the name of file id '//TRIM(cdid), & |
---|
| 2304 | & ' attribute output_freq is undefined -> cannot replace @freq@ in '//TRIM(clname) ) |
---|
[7646] | 2305 | ENDIF |
---|
| 2306 | clname = clname(1:idx-1)//TRIM(ADJUSTL(clfreq))//clname(idx+6:LEN_TRIM(clname)) |
---|
| 2307 | idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') |
---|
[4148] | 2308 | END DO |
---|
[9019] | 2309 | ! |
---|
[4148] | 2310 | idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@') |
---|
| 2311 | DO WHILE ( idx /= 0 ) |
---|
[12489] | 2312 | cldate = iom_sdate( fjulday - rn_Dt / rday ) |
---|
[4148] | 2313 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+11:LEN_TRIM(clname)) |
---|
| 2314 | idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@') |
---|
| 2315 | END DO |
---|
[9019] | 2316 | ! |
---|
[4148] | 2317 | idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@') |
---|
| 2318 | DO WHILE ( idx /= 0 ) |
---|
[12489] | 2319 | cldate = iom_sdate( fjulday - rn_Dt / rday, ldfull = .TRUE. ) |
---|
[4148] | 2320 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+15:LEN_TRIM(clname)) |
---|
| 2321 | idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@') |
---|
| 2322 | END DO |
---|
[9019] | 2323 | ! |
---|
[4148] | 2324 | idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') |
---|
| 2325 | DO WHILE ( idx /= 0 ) |
---|
[12489] | 2326 | cldate = iom_sdate( fjulday + rn_Dt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE. ) |
---|
[4148] | 2327 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+9:LEN_TRIM(clname)) |
---|
| 2328 | idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') |
---|
| 2329 | END DO |
---|
[9019] | 2330 | ! |
---|
[4148] | 2331 | idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') |
---|
| 2332 | DO WHILE ( idx /= 0 ) |
---|
[12489] | 2333 | cldate = iom_sdate( fjulday + rn_Dt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE., ldfull = .TRUE. ) |
---|
[4148] | 2334 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+13:LEN_TRIM(clname)) |
---|
| 2335 | idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') |
---|
| 2336 | END DO |
---|
[9019] | 2337 | ! |
---|
[12377] | 2338 | IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) |
---|
[4148] | 2339 | IF( jn == 1 ) CALL iom_set_file_attr( cdid, name = clname ) |
---|
| 2340 | IF( jn == 2 ) CALL iom_set_file_attr( cdid, name_suffix = clname ) |
---|
[9019] | 2341 | ! |
---|
[4148] | 2342 | ENDIF |
---|
[9019] | 2343 | ! |
---|
[4148] | 2344 | END DO |
---|
[9019] | 2345 | ! |
---|
[4148] | 2346 | END SUBROUTINE iom_update_file_name |
---|
| 2347 | |
---|
| 2348 | |
---|
| 2349 | FUNCTION iom_sdate( pjday, ld24, ldfull ) |
---|
| 2350 | !!---------------------------------------------------------------------- |
---|
| 2351 | !! *** ROUTINE iom_sdate *** |
---|
| 2352 | !! |
---|
| 2353 | !! ** Purpose : send back the date corresponding to the given julian day |
---|
| 2354 | !!---------------------------------------------------------------------- |
---|
[9019] | 2355 | REAL(wp), INTENT(in ) :: pjday ! julian day |
---|
| 2356 | LOGICAL , INTENT(in ), OPTIONAL :: ld24 ! true to force 24:00 instead of 00:00 |
---|
| 2357 | LOGICAL , INTENT(in ), OPTIONAL :: ldfull ! true to get the compleate date: yyyymmdd_hh:mm:ss |
---|
[4148] | 2358 | ! |
---|
| 2359 | CHARACTER(LEN=20) :: iom_sdate |
---|
| 2360 | CHARACTER(LEN=50) :: clfmt ! format used to write the date |
---|
| 2361 | INTEGER :: iyear, imonth, iday, ihour, iminute, isec |
---|
| 2362 | REAL(wp) :: zsec |
---|
| 2363 | LOGICAL :: ll24, llfull |
---|
[9019] | 2364 | !!---------------------------------------------------------------------- |
---|
[4148] | 2365 | ! |
---|
| 2366 | IF( PRESENT(ld24) ) THEN ; ll24 = ld24 |
---|
| 2367 | ELSE ; ll24 = .FALSE. |
---|
| 2368 | ENDIF |
---|
[9019] | 2369 | ! |
---|
[4148] | 2370 | IF( PRESENT(ldfull) ) THEN ; llfull = ldfull |
---|
| 2371 | ELSE ; llfull = .FALSE. |
---|
| 2372 | ENDIF |
---|
[9019] | 2373 | ! |
---|
[4148] | 2374 | CALL ju2ymds( pjday, iyear, imonth, iday, zsec ) |
---|
| 2375 | isec = NINT(zsec) |
---|
[9019] | 2376 | ! |
---|
[4148] | 2377 | IF ( ll24 .AND. isec == 0 ) THEN ! 00:00 of the next day -> move to 24:00 of the current day |
---|
| 2378 | CALL ju2ymds( pjday - 1., iyear, imonth, iday, zsec ) |
---|
| 2379 | isec = 86400 |
---|
| 2380 | ENDIF |
---|
[9019] | 2381 | ! |
---|
[4148] | 2382 | IF( iyear < 10000 ) THEN ; clfmt = "i4.4,2i2.2" ! format used to write the date |
---|
| 2383 | ELSE ; WRITE(clfmt, "('i',i1,',2i2.2')") INT(LOG10(REAL(iyear,wp))) + 1 |
---|
| 2384 | ENDIF |
---|
[9019] | 2385 | ! |
---|
[5656] | 2386 | !$AGRIF_DO_NOT_TREAT |
---|
[9019] | 2387 | ! needed in the conv |
---|
[4148] | 2388 | IF( llfull ) THEN |
---|
| 2389 | clfmt = TRIM(clfmt)//",'_',i2.2,':',i2.2,':',i2.2" |
---|
| 2390 | ihour = isec / 3600 |
---|
| 2391 | isec = MOD(isec, 3600) |
---|
| 2392 | iminute = isec / 60 |
---|
| 2393 | isec = MOD(isec, 60) |
---|
| 2394 | WRITE(iom_sdate, '('//TRIM(clfmt)//')') iyear, imonth, iday, ihour, iminute, isec ! date of the end of run |
---|
| 2395 | ELSE |
---|
| 2396 | WRITE(iom_sdate, '('//TRIM(clfmt)//')') iyear, imonth, iday ! date of the end of run |
---|
| 2397 | ENDIF |
---|
[5656] | 2398 | !$AGRIF_END_DO_NOT_TREAT |
---|
[9019] | 2399 | ! |
---|
[4148] | 2400 | END FUNCTION iom_sdate |
---|
| 2401 | |
---|
[1359] | 2402 | #else |
---|
[9019] | 2403 | !!---------------------------------------------------------------------- |
---|
| 2404 | !! NOT 'key_iomput' a few dummy routines |
---|
| 2405 | !!---------------------------------------------------------------------- |
---|
[4152] | 2406 | SUBROUTINE iom_setkt( kt, cdname ) |
---|
| 2407 | INTEGER , INTENT(in):: kt |
---|
| 2408 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
| 2409 | IF( .FALSE. ) WRITE(numout,*) kt, cdname ! useless test to avoid compilation warnings |
---|
[1359] | 2410 | END SUBROUTINE iom_setkt |
---|
| 2411 | |
---|
[4152] | 2412 | SUBROUTINE iom_context_finalize( cdname ) |
---|
| 2413 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
| 2414 | IF( .FALSE. ) WRITE(numout,*) cdname ! useless test to avoid compilation warnings |
---|
| 2415 | END SUBROUTINE iom_context_finalize |
---|
| 2416 | |
---|
[12377] | 2417 | SUBROUTINE iom_update_file_name( cdid ) |
---|
| 2418 | CHARACTER(LEN=*), INTENT(in) :: cdid |
---|
| 2419 | IF( .FALSE. ) WRITE(numout,*) cdid ! useless test to avoid compilation warnings |
---|
| 2420 | END SUBROUTINE iom_update_file_name |
---|
| 2421 | |
---|
[1359] | 2422 | #endif |
---|
[4689] | 2423 | |
---|
| 2424 | LOGICAL FUNCTION iom_use( cdname ) |
---|
| 2425 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
| 2426 | #if defined key_iomput |
---|
| 2427 | iom_use = xios_field_is_active( cdname ) |
---|
| 2428 | #else |
---|
| 2429 | iom_use = .FALSE. |
---|
| 2430 | #endif |
---|
| 2431 | END FUNCTION iom_use |
---|
[11536] | 2432 | |
---|
| 2433 | SUBROUTINE iom_miss_val( cdname, pmiss_val ) |
---|
| 2434 | CHARACTER(LEN=*), INTENT(in ) :: cdname |
---|
| 2435 | REAL(wp) , INTENT(out) :: pmiss_val |
---|
| 2436 | #if defined key_iomput |
---|
| 2437 | ! get missing value |
---|
| 2438 | CALL xios_get_field_attr( cdname, default_value = pmiss_val ) |
---|
| 2439 | #else |
---|
| 2440 | IF( .FALSE. ) WRITE(numout,*) cdname, pmiss_val ! useless test to avoid compilation warnings |
---|
[12377] | 2441 | IF( .FALSE. ) pmiss_val = 0._wp ! useless assignment to avoid compilation warnings |
---|
[11536] | 2442 | #endif |
---|
| 2443 | END SUBROUTINE iom_miss_val |
---|
| 2444 | |
---|
[544] | 2445 | !!====================================================================== |
---|
| 2446 | END MODULE iom |
---|