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