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