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