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