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 @ 742

Last change on this file since 742 was 742, checked in by smasson, 17 years ago

bugfix for short filenames in iom_open, see ticket:24

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