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