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 trunk/NEMO/OPA_SRC/IOM – NEMO

source: trunk/NEMO/OPA_SRC/IOM/iom.F90 @ 719

Last change on this file since 719 was 719, checked in by ctlod, 17 years ago

get back to the nemo_v2_3 version for trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.7 KB
Line 
1MODULE iom
2   !!=====================================================================
3   !!                    ***  MODULE  iom ***
4   !! Input/Output manager :  Library to read input files
5   !!====================================================================
6   !! History :  9.0  ! 05 12  (J. Belier) Original code
7   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
8   !!--------------------------------------------------------------------
9   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
10
11   !!--------------------------------------------------------------------
12   !!   iom_open       : open a file read only
13   !!   iom_close      : close a file or all files opened by iom
14   !!   iom_get        : read a field (interfaced to several routines)
15   !!   iom_gettime    : read the time axis cdvar in the file
16   !!   iom_varid      : get the id of a variable in a file
17   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
18   !!--------------------------------------------------------------------
19   USE in_out_manager  ! I/O manager
20   USE dom_oce         ! ocean space and time domain
21   USE lbclnk          ! lateal boundary condition / mpp exchanges
22   USE iom_def         ! iom variables definitions
23   USE iom_ioipsl      ! NetCDF format with IOIPSL library
24   USE iom_nf90        ! NetCDF format with native NetCDF library
25   USE iom_rstdimg     ! restarts access direct format "dimg" style...
26
27   IMPLICIT NONE
28   PUBLIC   !   must be public to be able to access iom_def through iom
29   
30   PUBLIC iom_open, iom_close, iom_varid, iom_get, iom_gettime, iom_rstput
31
32   INTERFACE iom_get
33      MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d
34   END INTERFACE
35   INTERFACE iom_rstput
36      MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
37   END INTERFACE
38
39   !!----------------------------------------------------------------------
40   !!  OPA 9.0 , LOCEAN-IPSL (2006)
41   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/IOM/iom.F90,v 1.10 2007/06/29 14:10:50 opalod Exp $
42   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
43   !!----------------------------------------------------------------------
44
45CONTAINS
46
47   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop )
48      !!---------------------------------------------------------------------
49      !!                   ***  SUBROUTINE  iom_open  ***
50      !!
51      !! ** Purpose :  open an input file (return 0 if not found)
52      !!---------------------------------------------------------------------
53      CHARACTER(len=*), INTENT(in   )           ::   cdname   ! File name
54      INTEGER         , INTENT(  out)           ::   kiomid   ! iom identifier of the opened file
55      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
56      INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
57      INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90)
58      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
59
60      CHARACTER(LEN=100)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
61      CHARACTER(LEN=100)    ::   cltmpn    ! tempory name to store clname (in writting mode)
62      CHARACTER(LEN=10)     ::   clsuffix  ! ".nc" or ".dimg"
63      CHARACTER(LEN=15)     ::   clcpu     ! the cpu number (max jpmax_digits digits)
64      CHARACTER(LEN=100)    ::   clinfo    ! info character
65      LOGICAL               ::   llok      ! check the existence
66      LOGICAL               ::   llwrt     ! local definition of ldwrt
67      LOGICAL               ::   llstop    ! local definition of ldstop
68      INTEGER               ::   iolib     ! library do we use to open the file
69      INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
70      INTEGER               ::   iln, ils  ! lengths of character
71      INTEGER               ::   idom      ! type of domain
72      INTEGER               ::   istop     !
73      INTEGER, DIMENSION(2,5) ::   idompar ! domain parameters:
74      ! local number of points for x,y dimensions
75      ! position of first local point for x,y dimensions
76      ! position of last local point for x,y dimensions
77      ! start halo size for x,y dimensions
78      ! end halo size for x,y dimensions
79      !---------------------------------------------------------------------
80      ! Initializations and control
81      ! =============
82      clinfo = '                    iom_open ~~~  '
83      istop = nstop
84      ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0
85      ! (could be done when defining iom_file in f95 but not in f90)
86      IF( iom_init == 0 ) THEN
87         iom_file(:)%nfid = 0
88         iom_init = 1
89      ENDIF
90      ! do we read or write the file?
91      IF( PRESENT(ldwrt) ) THEN   ;   llwrt = ldwrt
92      ELSE                        ;   llwrt = .FALSE.
93      ENDIF
94      ! do we call ctl_stop if we try to open a non-existing file in read mode?
95      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
96      ELSE                         ;   llstop = .TRUE.
97      ENDIF
98      ! what library do we use to open the file?
99      IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib
100      ELSE                         ;   iolib = jpnf90
101      ENDIF
102      ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix)
103      ! =============
104      clname   = trim(cdname)
105#if defined key_agrif
106      if ( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
107#endif   
108      ! which suffix should we use?
109      SELECT CASE (iolib)
110      CASE (jpioipsl ) ;   clsuffix = '.nc'
111      CASE (jpnf90   ) ;   clsuffix = '.nc'
112      CASE (jprstdimg) ;   clsuffix = '.dimg'
113      CASE DEFAULT     ;   clsuffix = ''
114         CALL ctl_stop( TRIM(clinfo), 'accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
115      END SELECT
116      ! Add the suffix if needed
117      iln = LEN_TRIM(clname)
118      ils = LEN_TRIM(clsuffix)
119      IF( INDEX( TRIM(clname), TRIM(clsuffix), back = .TRUE. ) /= iln - ils + 1 ) clname = TRIM(clname)//TRIM(clsuffix)
120      cltmpn = clname   ! store this name
121      ! try to find if the file to be opened already exist
122      ! =============
123      INQUIRE( FILE = clname, EXIST = llok )
124      IF( .NOT.llok ) THEN
125         ! we try to add the cpu number to the name
126         IF( iolib == jprstdimg ) THEN   ;   WRITE(clcpu,*) narea
127         ELSE                            ;   WRITE(clcpu,*) narea-1
128         ENDIF
129         clcpu  = TRIM(ADJUSTL(clcpu))
130         iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.)
131         clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
132         icnt = 0
133         INQUIRE( FILE = clname, EXIST = llok ) 
134         ! we try different formats for the cpu number by adding 0
135         DO WHILE( .NOT.llok .AND. icnt < jpmax_digits )
136            clcpu  = "0"//trim(clcpu)
137            clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
138            INQUIRE( FILE = clname, EXIST = llok )
139            icnt = icnt + 1
140         END DO
141      ENDIF
142      IF( llwrt ) THEN
143         ! check the domain definition
144! JMM + SM: ugly patch before getting the new version of lib_mpp)
145!         idom = jpdom_local_noovlap   ! default definition
146         IF( jpni*jpnj == jpnij ) THEN   ;   idom = jpdom_local_noovlap   ! default definition
147         ELSE                            ;   idom = jpdom_local_full      ! default definition
148         ENDIF
149         IF( PRESENT(kdom) )   idom = kdom
150         ! create the domain informations
151         ! =============
152         SELECT CASE (idom)
153         CASE (jpdom_local_full)
154            idompar(:,1) = (/ jpi             , jpj              /)
155            idompar(:,2) = (/ nimpp           , njmpp            /)
156            idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1  /)
157            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
158            idompar(:,5) = (/ jpi - nlei      , jpj - nlej       /)
159         CASE (jpdom_local_noextra)
160            idompar(:,1) = (/ nlci            , nlcj             /)
161            idompar(:,2) = (/ nimpp           , njmpp            /)
162            idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /)
163            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
164            idompar(:,5) = (/ nlci - nlei     , nlcj - nlej      /)
165         CASE (jpdom_local_noovlap)
166            idompar(:,1) = (/ nlei  - nldi + 1, nlej  - nldj + 1 /)
167            idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /)
168            idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /)
169            idompar(:,4) = (/ 0               , 0                /)
170            idompar(:,5) = (/ 0               , 0                /)
171         CASE DEFAULT
172            CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' )
173         END SELECT
174      ENDIF
175      ! Open the NetCDF or RSTDIMG file
176      ! =============
177      ! do we have some free file identifier?
178      IF( MINVAL(iom_file(:)%nfid) /= 0 )   &
179         &   CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' )
180      ! if no file was found...
181      IF( .NOT. llok ) THEN
182         IF( .NOT. llwrt ) THEN   ! we are in read mode
183            IF( llstop ) THEN   ;   CALL ctl_stop( TRIM(clinfo), 'File '//TRIM(cltmpn)//'* not found' )
184            ELSE                ;   istop = nstop + 1   ! make sure that istop /= nstop so we don't open the file
185            ENDIF
186         ELSE                     ! we are in write mode so we
187            clname = cltmpn       ! get back the file name without the cpu number
188         ENDIF
189      ENDIF
190      IF( istop == nstop ) THEN   ! no error within this routine
191         SELECT CASE (iolib)
192         CASE (jpioipsl )   ;   CALL iom_ioipsl_open(  clname, kiomid, llwrt, llok, idompar )
193         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar )
194         CASE (jprstdimg)   ;   CALL iom_rstdimg_open( clname, kiomid, llwrt, llok, idompar )
195         CASE DEFAULT
196            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
197         END SELECT
198      ENDIF
199      !
200   END SUBROUTINE iom_open
201
202
203   SUBROUTINE iom_close( kiomid )
204      !!--------------------------------------------------------------------
205      !!                   ***  SUBROUTINE  iom_close  ***
206      !!
207      !! ** Purpose : close an input file, or all files opened by iom
208      !!--------------------------------------------------------------------
209      INTEGER, INTENT(in), OPTIONAL ::   kiomid   ! iom identifier of the file to be closed
210      !                                           ! No argument : all the files opened by iom are closed
211
212      INTEGER ::   jf         ! dummy loop indices
213      INTEGER ::   i_s, i_e   ! temporary integer
214      CHARACTER(LEN=100)    ::   clinfo    ! info character
215      !---------------------------------------------------------------------
216      !
217      clinfo = '                    iom_close ~~~  '
218      IF( PRESENT(kiomid) ) THEN
219         i_s = kiomid
220         i_e = kiomid
221      ELSE
222         i_s = 1
223         i_e = jpmax_files
224      ENDIF
225
226      IF( i_s > 0 ) THEN
227         DO jf = i_s, i_e
228            IF( iom_file(jf)%nfid > 0 ) THEN
229               SELECT CASE (iom_file(jf)%iolib)
230               CASE (jpioipsl )   ;   CALL iom_ioipsl_close(  jf )
231               CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
232               CASE (jprstdimg)   ;   CALL iom_rstdimg_close( jf )
233               CASE DEFAULT
234                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
235               END SELECT
236               iom_file(jf)%nfid       = 0   ! free the id
237               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(jf)%name)//' ok'
238            ELSEIF( PRESENT(kiomid) ) THEN
239               WRITE(ctmp1,*) '--->',  kiomid
240               CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 )
241            ENDIF
242         END DO
243      ENDIF
244      !   
245   END SUBROUTINE iom_close
246
247
248   FUNCTION iom_varid ( kiomid, cdvar, kdimsz ) 
249      !!-----------------------------------------------------------------------
250      !!                  ***  FUNCTION  iom_varid  ***
251      !!
252      !! ** Purpose : get the id of a variable in a file (return 0 if not found)
253      !!-----------------------------------------------------------------------
254      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
255      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
256      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
257      !
258      INTEGER                        ::   iom_varid, iiv, i_nvd
259      LOGICAL                        ::   ll_fnd
260      CHARACTER(LEN=100)             ::   clinfo                   ! info character
261      !!-----------------------------------------------------------------------
262      iom_varid = 0                         ! default definition
263      !
264      IF( kiomid > 0 ) THEN
265         clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
266         IF( iom_file(kiomid)%nfid == 0 ) THEN
267            CALL ctl_stop( trim(clinfo), 'the file is not open' )
268         ELSE
269            ll_fnd  = .FALSE.
270            iiv = 0
271            !
272            DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars )
273               iiv = iiv + 1
274               ll_fnd  = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) )
275            END DO
276            !
277            IF( .NOT.ll_fnd ) THEN
278               iiv = iiv + 1
279               IF( iiv <= jpmax_vars ) THEN
280                  SELECT CASE (iom_file(kiomid)%iolib)
281                  CASE (jpioipsl )   ;   iom_varid = iom_ioipsl_varid( kiomid, cdvar, iiv, kdimsz )
282                  CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid(   kiomid, cdvar, iiv, kdimsz )
283                  CASE (jprstdimg)   ;   iom_varid = 0   ! all variables are listed in iom_file
284                  CASE DEFAULT   
285                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
286                  END SELECT
287               ELSE
288                  CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
289                        &                         'increase the parameter jpmax_vars')
290               ENDIF
291            ELSE
292               iom_varid = iiv
293               IF( PRESENT(kdimsz) ) THEN
294                  i_nvd = iom_file(kiomid)%ndims(iiv)
295                  IF( i_nvd == size(kdimsz) ) THEN
296                     kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,iiv)
297                  ELSE
298                     WRITE(ctmp1,*) i_nvd, size(kdimsz)
299                     CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) )
300                  ENDIF
301               ENDIF
302            ENDIF
303         ENDIF
304      ENDIF
305      !
306   END FUNCTION iom_varid
307
308
309   !!----------------------------------------------------------------------
310   !!                   INTERFACE iom_get
311   !!----------------------------------------------------------------------
312   SUBROUTINE iom_g0d( kiomid, cdvar, pvar )
313      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
314      CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
315      REAL(wp)        , INTENT(  out)                 ::   pvar      ! read field
316      !
317      INTEGER               :: idvar   ! variable id
318      !
319      IF( kiomid > 0 ) THEN
320         idvar = iom_varid( kiomid, cdvar )
321         IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN
322            SELECT CASE (iom_file(kiomid)%iolib)
323            CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, pvar )
324            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar )
325            CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idvar, pvar )
326            CASE DEFAULT   
327               CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
328            END SELECT
329         ENDIF
330      ENDIF
331   END SUBROUTINE iom_g0d
332
333   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
334      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
335      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
336      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
337      REAL(wp)        , INTENT(  out), DIMENSION(:)           ::   pvar      ! read field
338      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
339      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading
340      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
341      !
342      IF( kiomid > 0 ) THEN
343         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   &
344              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
345      ENDIF
346   END SUBROUTINE iom_g1d
347
348   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
349      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
350      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
351      CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
352      REAL(wp)        , INTENT(  out), DIMENSION(:,:)           ::   pvar      ! read field
353      INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
354      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading
355      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
356      !
357      IF( kiomid > 0 ) THEN
358         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
359              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
360      ENDIF
361   END SUBROUTINE iom_g2d
362
363   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
364      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
365      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
366      CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
367      REAL(wp)        , INTENT(  out), DIMENSION(:,:,:)           ::   pvar      ! read field
368      INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
369      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading
370      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
371      !
372      IF( kiomid > 0 ) THEN
373         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
374              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
375      ENDIF
376   END SUBROUTINE iom_g3d
377   !!----------------------------------------------------------------------
378
379   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   &
380         &                  pv_r1d, pv_r2d, pv_r3d,   &
381         &                  ktime , kstart, kcount  )
382      !!-----------------------------------------------------------------------
383      !!                  ***  ROUTINE  iom_get_123d  ***
384      !!
385      !! ** Purpose : read a 1D/2D/3D variable
386      !!
387      !! ** Method : read ONE record at each CALL
388      !!-----------------------------------------------------------------------
389      INTEGER                    , INTENT(in   )           ::   kiomid     ! Identifier of the file
390      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
391      CHARACTER(len=*)           , INTENT(in   )           ::   cdvar      ! Name of the variable
392      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
393      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
394      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
395      INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime      ! record number
396      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis
397      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
398      !
399      INTEGER                        ::   jl          ! loop on number of dimension
400      INTEGER                        ::   idom        ! type of domain
401      INTEGER                        ::   idvar       ! id of the variable
402      INTEGER                        ::   inbdim      ! number of dimensions of the variable
403      INTEGER                        ::   idmspc      ! number of spatial dimensions
404      INTEGER                        ::   itime       ! record number
405      INTEGER                        ::   istop       ! temporary value of nstop
406      INTEGER                        ::   ix1, ix2, iy1, iy2   ! subdomain indexes
407      INTEGER                        ::   ji, jj      ! loop counters
408      INTEGER                        ::   irankpv       !
409      INTEGER                        ::   ind1, ind2  ! substring index
410      INTEGER, DIMENSION(jpmax_dims) ::   istart      ! starting point to read for each axis
411      INTEGER, DIMENSION(jpmax_dims) ::   icnt        ! number of value to read along each axis
412      INTEGER, DIMENSION(jpmax_dims) ::   idimsz      ! size of the dimensions of the variable
413      INTEGER, DIMENSION(jpmax_dims) ::   ishape      ! size of the dimensions of the variable
414      REAL(wp)                       ::   zscf, zofs  ! sacle_factor and add_offset
415      INTEGER                        ::   itmp        ! temporary integer
416      CHARACTER(LEN=100)             ::   clinfo      ! info character
417      CHARACTER(LEN=100)             ::   clname      ! file name
418      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      !
419      !---------------------------------------------------------------------
420      !
421      clname = iom_file(kiomid)%name   !   esier to read
422      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
423      ! local definition of the domain ?
424      idom = kdom
425      ! check kcount and kstart optionals parameters...
426      IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
427      IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
428      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown   ) CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown')
429
430      ! Search for the variable in the data base (eventually actualize data)
431      istop = nstop
432      idvar = iom_varid( kiomid, cdvar )
433      !
434      IF( idvar > 0 ) THEN
435         ! to write iom_file(kiomid)%dimsz in a shorter way !
436         idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
437         inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
438         idmspc = inbdim                                   ! number of spatial dimensions in the file
439         IF( iom_file(kiomid)%luld(idvar) )   idmspc = inbdim - 1
440         IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
441         !
442         ! update idom definition...
443         ! Identify the domain in case of jpdom_auto(glo/dta) definition
444         IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN           
445            IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
446            ELSE                               ;   idom = jpdom_data
447            ENDIF
448            ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
449            ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
450            IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
451         ENDIF
452         ! Identify the domain in case of jpdom_local definition
453         IF( idom == jpdom_local ) THEN
454            IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
455            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
456            ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
457            ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
458            ENDIF
459         ENDIF
460         !
461         ! check the consistency between input array and data rank in the file
462         !
463         ! initializations
464         itime = 1
465         IF( PRESENT(ktime) ) itime = ktime
466
467         irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) )
468         WRITE(clrankpv, fmt='(i1)') irankpv
469         WRITE(cldmspc , fmt='(i1)') idmspc
470         !
471         IF(     idmspc <  irankpv ) THEN
472            CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
473               &                         'it is impossible to read a '//clrankpv//'D array from this file...' )
474         ELSEIF( idmspc == irankpv ) THEN
475            IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
476               &   CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' )
477         ELSEIF( idmspc >  irankpv ) THEN
478               IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
479                  CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
480                        &         'As the size of the z dimension is 1 and as we try to read the first record, ',   &
481                        &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
482                  idmspc = idmspc - 1
483               ELSE
484                  CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
485                     &                         'we do not accept data with more than '//cldmspc//' spatial dimension',   &
486                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
487               ENDIF
488         ENDIF
489
490         !
491         ! definition of istart and icnt
492         !
493         icnt  (:) = 1
494         istart(:) = 1
495         istart(idmspc+1) = itime
496
497         IF(              PRESENT(kstart)       ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
498         ELSE
499            IF(           idom == jpdom_unknown ) THEN                                       ; icnt(1:idmspc) = idimsz(1:idmspc)
500            ELSE
501               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
502                  IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done bellow
503                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done bellow
504                  ENDIF
505                  ! we do not read the overlap                     -> we start to read at nldi, nldj
506! JMM + SM: ugly patch before getting the new version of lib_mpp)
507!                  IF( idom /= jpdom_local_noovlap )   istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
508                  IF( jpni*jpnj == jpnij .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
509                  ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej
510! JMM + SM: ugly patch before getting the new version of lib_mpp)
511!                  icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
512                  IF( jpni*jpnj == jpnij ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
513                  ELSE                            ;   icnt(1:2) = (/ nlci           , nlcj            /)
514                  ENDIF
515                  IF( PRESENT(pv_r3d) ) THEN
516                     IF( idom == jpdom_data ) THEN   ; icnt(3) = jpkdta
517                     ELSE                            ; icnt(3) = jpk
518                     ENDIF
519                  ENDIF
520               ENDIF
521            ENDIF
522         ENDIF
523
524         ! check that istart and icnt can be used with this file
525         !-
526         DO jl = 1, jpmax_dims
527            itmp = istart(jl)+icnt(jl)-1
528            IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN
529               WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp
530               WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)"         ) jl, idimsz(jl)
531               CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 )     
532            ENDIF
533         END DO
534
535         ! check that icnt matches the input array
536         !-     
537         IF( idom == jpdom_unknown ) THEN
538            IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d)
539            IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d)
540            IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d)
541            ctmp1 = 'd'
542         ELSE
543            IF( irankpv == 2 ) THEN
544! JMM + SM: ugly patch before getting the new version of lib_mpp)
545!               ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej  ))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej)'
546               IF( jpni*jpnj == jpnij ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
547               ELSE                          ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
548               ENDIF
549            ENDIF
550            IF( irankpv == 3 ) THEN 
551! JMM + SM: ugly patch before getting the new version of lib_mpp)
552!               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)'
553               IF( jpni*jpnj == jpnij ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
554               ELSE                          ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
555               ENDIF
556            ENDIF
557         ENDIF
558         
559         DO jl = 1, irankpv
560            WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
561            IF( ishape(jl) /= icnt(jl) )   CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) )
562         END DO
563
564      ENDIF
565
566      ! read the data
567      !-     
568      IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
569         !
570         ! find the right index of the array to be read
571! JMM + SM: ugly patch before getting the new version of lib_mpp)
572!         IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
573!         ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
574!         ENDIF
575         IF( jpni*jpnj == jpnij ) THEN
576            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
577            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
578            ENDIF
579         ELSE
580            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
581            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
582            ENDIF
583         ENDIF
584     
585         SELECT CASE (iom_file(kiomid)%iolib)
586         CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
587            &                                         pv_r1d, pv_r2d, pv_r3d )
588         CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
589            &                                         pv_r1d, pv_r2d, pv_r3d )
590         CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   &
591            &                                         pv_r1d, pv_r2d, pv_r3d )
592         CASE DEFAULT   
593            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
594         END SELECT
595
596         IF( istop == nstop ) THEN   ! no additional errors until this point...
597            IF(lwp) WRITE(numout,*) '           read '//TRIM(cdvar)//' in '//TRIM(iom_file(kiomid)%name)//' ok'
598           
599            !--- overlap areas and extra hallows (mpp)
600            IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
601               CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
602            ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
603               ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
604               IF( icnt(3) == jpk ) THEN
605                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
606               ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
607                  DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
608                  DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
609               ENDIF
610            ENDIF
611           
612            !--- Apply scale_factor and offset
613            zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
614            zofs = iom_file(kiomid)%ofs(idvar)      ! offset
615            IF(     PRESENT(pv_r1d) ) THEN
616               IF( zscf /= 1. )   pv_r1d(:) = pv_r1d(:) * zscf 
617               IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
618            ELSEIF( PRESENT(pv_r2d) ) THEN
619               !CDIR COLLAPSE
620               IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
621               !CDIR COLLAPSE
622               IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
623            ELSEIF( PRESENT(pv_r3d) ) THEN
624               !CDIR COLLAPSE
625               IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
626               !CDIR COLLAPSE
627               IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
628            ENDIF
629            !
630         ENDIF
631         !
632      ENDIF
633      !
634   END SUBROUTINE iom_get_123d
635
636
637   SUBROUTINE iom_gettime( kiomid, cdvar, ptime )
638      !!--------------------------------------------------------------------
639      !!                   ***  SUBROUTINE iom_gettime  ***
640      !!
641      !! ** Purpose : read the time axis cdvar in the file
642      !!--------------------------------------------------------------------
643      INTEGER               , INTENT(in   ) ::   kiomid   ! file Identifier
644      CHARACTER(len=*)      , INTENT(in   ) ::   cdvar    ! time axis name
645      REAL(wp), DIMENSION(:), INTENT(  out) ::   ptime    ! the time axis
646      !
647      INTEGER            ::   idvar    ! id of the variable
648      CHARACTER(LEN=100) ::   clinfo   ! info character
649      !---------------------------------------------------------------------
650      !
651      IF( kiomid > 0 ) THEN
652         clinfo = 'iom_gettime, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
653         idvar = iom_varid( kiomid, cdvar )
654         !
655         ptime(:) = 0. ! default definition
656         IF( idvar > 0 ) THEN
657            IF( iom_file(kiomid)%ndims(idvar) == 1 ) THEN
658               IF( iom_file(kiomid)%luld(idvar) ) THEN
659                  IF( iom_file(kiomid)%dimsz(1,idvar) == size(ptime) ) THEN
660                     SELECT CASE (iom_file(kiomid)%iolib)
661                     CASE (jpioipsl )   ;   CALL iom_ioipsl_gettime( kiomid, idvar, ptime )
662                     CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime )
663                     CASE (jprstdimg)   ;   CALL ctl_stop( TRIM(clinfo)//' case IO library == jprstdimg not coded...' )
664                     CASE DEFAULT   
665                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
666                     END SELECT
667                  ELSE
668                     WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar)
669                     CALL ctl_stop( trim(clinfo), trim(ctmp1) )
670                  ENDIF
671               ELSE
672                  CALL ctl_stop( trim(clinfo), 'variable dimension is not unlimited... use iom_get' )
673               ENDIF
674            ELSE
675               CALL ctl_stop( trim(clinfo), 'the variable has more than 1 dimension' )
676            ENDIF
677         ELSE
678            CALL ctl_stop( trim(clinfo), 'variable not found in '//iom_file(kiomid)%name )
679         ENDIF
680      ENDIF
681      !
682   END SUBROUTINE iom_gettime
683
684
685   !!----------------------------------------------------------------------
686   !!                   INTERFACE iom_rstput
687   !!----------------------------------------------------------------------
688   SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype )
689      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
690      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
691      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file
692      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
693      REAL(wp)        , INTENT(in)                         ::   pvar     ! written field
694      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
695      INTEGER :: ivid   ! variable id
696      IF( kiomid > 0 ) THEN
697         IF( iom_file(kiomid)%nfid > 0 ) THEN
698            ivid = iom_varid(kiomid, cdvar)
699            SELECT CASE (iom_file(kiomid)%iolib)
700            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
701            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
702            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar )
703            CASE DEFAULT     
704               CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
705            END SELECT
706         ENDIF
707      ENDIF
708   END SUBROUTINE iom_rp0d
709
710   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype )
711      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
712      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
713      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file
714      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
715      REAL(wp)        , INTENT(in), DIMENSION(        jpk) ::   pvar     ! written field
716      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
717      INTEGER :: ivid   ! variable id
718      IF( kiomid > 0 ) THEN
719         IF( iom_file(kiomid)%nfid > 0 ) THEN
720            ivid = iom_varid(kiomid, cdvar)
721            SELECT CASE (iom_file(kiomid)%iolib)
722            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
723            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
724            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar )
725            CASE DEFAULT     
726               CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
727            END SELECT
728         ENDIF
729      ENDIF
730   END SUBROUTINE iom_rp1d
731
732   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype )
733      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
734      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
735      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file
736      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
737      REAL(wp)        , INTENT(in), DIMENSION(jpi,jpj    ) ::   pvar     ! written field
738      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
739      INTEGER :: ivid   ! variable id
740      IF( kiomid > 0 ) THEN
741         IF( iom_file(kiomid)%nfid > 0 ) THEN
742            ivid = iom_varid(kiomid, cdvar)
743            SELECT CASE (iom_file(kiomid)%iolib)
744            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
745            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
746            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) 
747            CASE DEFAULT     
748               CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
749            END SELECT
750         ENDIF
751      ENDIF
752   END SUBROUTINE iom_rp2d
753
754   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype )
755      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
756      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
757      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file
758      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
759      REAL(wp)        , INTENT(in), DIMENSION(jpi,jpj,jpk) ::   pvar     ! written field
760      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
761      INTEGER :: ivid   ! variable id
762      IF( kiomid > 0 ) THEN
763         IF( iom_file(kiomid)%nfid > 0 ) THEN
764            ivid = iom_varid(kiomid, cdvar)
765            SELECT CASE (iom_file(kiomid)%iolib)
766            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
767            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
768            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar )
769            CASE DEFAULT     
770               CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' )
771            END SELECT
772         ENDIF
773      ENDIF
774   END SUBROUTINE iom_rp3d
775   !!----------------------------------------------------------------------
776
777
778   !!======================================================================
779END MODULE iom
Note: See TracBrowser for help on using the repository browser.