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