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