New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
iom.F90 in branches/2014/dev_r5134_UKMO4_CF_compliance/NEMOGCM/NEMO/OPA_SRC/IOM – NEMO

source: branches/2014/dev_r5134_UKMO4_CF_compliance/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90 @ 5199

Last change on this file since 5199 was 5199, checked in by hadcv, 9 years ago

Addition of standard_name entries and other changes.

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