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.
Changeset 10425 for NEMO/trunk/src/OCE/IOM – NEMO

Ignore:
Timestamp:
2018-12-19T22:54:16+01:00 (5 years ago)
Author:
smasson
Message:

trunk: merge back dev_r10164_HPC09_ESIWACE_PREP_MERGE@10424 into the trunk

Location:
NEMO/trunk/src/OCE/IOM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/src/OCE/IOM/in_out_manager.F90

    r10068 r10425  
    122122   INTEGER ::   numtime         =   -1      !: logical unit for timing 
    123123   INTEGER ::   numout          =    6      !: logical unit for output print; Set to stdout to ensure any 
     124   INTEGER ::   numnul          =   -1      !: logical unit for /dev/null 
    124125      !                                     !  early output can be collected; do not change 
    125126   INTEGER ::   numnam_ref      =   -1      !: logical unit for reference namelist 
  • NEMO/trunk/src/OCE/IOM/iom.F90

    r10361 r10425  
    5858#endif 
    5959   PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get 
    60    PUBLIC iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_put 
     60   PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_delay_rst, iom_put 
    6161   PUBLIC iom_use, iom_context_finalize 
    6262 
     
    7575   END INTERFACE 
    7676   INTERFACE iom_getatt 
    77       MODULE PROCEDURE iom_g0d_iatt, iom_g0d_ratt, iom_g0d_catt 
     77      MODULE PROCEDURE iom_g0d_iatt, iom_g1d_iatt, iom_g0d_ratt, iom_g1d_ratt, iom_g0d_catt 
    7878   END INTERFACE 
    7979   INTERFACE iom_putatt 
    80       MODULE PROCEDURE iom_p0d_iatt, iom_p0d_ratt, iom_p0d_catt 
     80      MODULE PROCEDURE iom_p0d_iatt, iom_p1d_iatt, iom_p0d_ratt, iom_p1d_ratt, iom_p0d_catt 
    8181   END INTERFACE 
    8282   INTERFACE iom_rstput 
     
    286286!Warn if variable is not in defined in rst_wfields 
    287287   IF(.NOT.llis_set) THEN 
    288       IF(lwp) THEN 
    289          write(numout,cform_err) 
    290          write(numout,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined'  
    291       ENDIF 
    292         nstop = nstop + 1 
     288      WRITE(ctmp1,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined'  
     289      CALL ctl_stop( 'iom_set_rstw_var_active:', ctmp1 ) 
    293290   ENDIF 
    294291#else 
     
    518515 
    519516        IF( i-1 > max_rst_fields) THEN 
    520         IF(lwp) write(numout,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small' 
    521         nstop = nstop + 1 
     517           WRITE(ctmp1,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small' 
     518           CALL ctl_stop( 'iom_set_rst_vars:', ctmp1 ) 
    522519        ENDIF 
    523520   END SUBROUTINE iom_set_rst_vars 
     
    634631 
    635632 
    636    SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof, kdlev ) 
     633   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev ) 
    637634      !!--------------------------------------------------------------------- 
    638635      !!                   ***  SUBROUTINE  iom_open  *** 
     
    644641      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.) 
    645642      INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap) 
    646       INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90)  
    647643      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.) 
    648644      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.) 
     
    659655      LOGICAL               ::   llstop    ! local definition of ldstop 
    660656      LOGICAL               ::   lliof     ! local definition of ldiof 
    661       INTEGER               ::   iolib     ! library do we use to open the file 
    662657      INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits) 
    663658      INTEGER               ::   iln, ils  ! lengths of character 
     
    692687      ELSE                         ;   llstop = .TRUE. 
    693688      ENDIF 
    694       ! what library do we use to open the file? 
    695       IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib 
    696       ELSE                         ;   iolib = jpnf90 
    697       ENDIF 
    698689      ! are we using interpolation on the fly? 
    699690      IF( PRESENT(ldiof) ) THEN   ;   lliof = ldiof 
     
    713704      ENDIF 
    714705      ! which suffix should we use? 
    715       SELECT CASE (iolib) 
    716       CASE (jpnf90   ) ;   clsuffix = '.nc' 
    717       CASE DEFAULT     ;   clsuffix = '' 
    718          CALL ctl_stop( TRIM(clinfo), 'accepted IO library is only jpnf90 (jpioipsl option has been removed) ' ) 
    719       END SELECT 
     706      clsuffix = '.nc' 
    720707      ! Add the suffix if needed 
    721708      iln = LEN_TRIM(clname) 
     
    802789      ENDIF 
    803790      IF( istop == nstop ) THEN   ! no error within this routine 
    804          SELECT CASE (iolib) 
    805          CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar, kdlev = kdlev ) 
    806          CASE DEFAULT 
    807             CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' ) 
    808          END SELECT 
     791         CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev ) 
    809792      ENDIF 
    810793      ! 
     
    839822         DO jf = i_s, i_e 
    840823            IF( iom_file(jf)%nfid > 0 ) THEN 
    841                SELECT CASE (iom_file(jf)%iolib) 
    842                CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf ) 
    843                CASE DEFAULT 
    844                   CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    845                END SELECT 
     824               CALL iom_nf90_close( jf ) 
    846825               iom_file(jf)%nfid       = 0          ! free the id  
    847826               IF( PRESENT(kiomid) )   kiomid = 0   ! return 0 as id to specify that the file was closed 
     
    896875               iiv = iiv + 1 
    897876               IF( iiv <= jpmax_vars ) THEN 
    898                   SELECT CASE (iom_file(kiomid)%iolib) 
    899                   CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz, kndims ) 
    900                   CASE DEFAULT 
    901                      CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    902                   END SELECT 
     877                  iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz, kndims ) 
    903878               ELSE 
    904879                  CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   & 
    905                         &                         'increase the parameter jpmax_vars') 
     880                        &                      'increase the parameter jpmax_vars') 
    906881               ENDIF 
    907882               IF( llstop .AND. iom_varid == -1 )   CALL ctl_stop( TRIM(clinfo)//' not found' )  
     
    962937                                    &                         'with 1 or more spatial dimensions: '//cldmspc//' were found.' , & 
    963938                                    &                         'Use ncwa -a to suppress the unnecessary dimensions' ) 
    964                SELECT CASE (iom_file(kiomid)%iolib) 
    965                CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime ) 
    966                CASE DEFAULT 
    967                   CALL ctl_stop( 'iom_g0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    968                END SELECT 
     939               CALL iom_nf90_get( kiomid, idvar, pvar, itime ) 
    969940            ENDIF 
    970941         ENDIF 
     
    976947         CALL iom_swap( TRIM(cxios_context) ) 
    977948#else 
    978          nstop = nstop + 1  
    979          clinfo = 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar) 
     949         WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar) 
     950         CALL ctl_stop( 'iom_g0d', ctmp1 ) 
    980951#endif 
    981952      ENDIF 
     
    11221093            IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data') 
    11231094            IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true. 
    1124          ENDIF 
    1125          IF( luse_jattr ) THEN 
    1126             SELECT CASE (iom_file(kiomid)%iolib) 
    1127             CASE (jpnf90   )    
    1128                 ! Ok 
    1129             CASE DEFAULT     
    1130                CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1131             END SELECT 
    11321095         ENDIF 
    11331096 
     
    13011264            ENDIF 
    13021265       
    1303             SELECT CASE (iom_file(kiomid)%iolib) 
    1304             CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   & 
    1305                &                                         pv_r1d, pv_r2d, pv_r3d ) 
    1306             CASE DEFAULT 
    1307                CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1308             END SELECT 
     1266            CALL iom_nf90_get( kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d ) 
    13091267 
    13101268            IF( istop == nstop ) THEN   ! no additional errors until this point... 
     
    13131271               !--- overlap areas and extra hallows (mpp) 
    13141272               IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN 
    1315                   CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' ) 
     1273                  CALL lbc_lnk( 'iom', pv_r2d,'Z',-999.,'no0' ) 
    13161274               ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN 
    13171275                  ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension 
    13181276                  IF( icnt(3) == inlev ) THEN 
    1319                      CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' ) 
     1277                     CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' ) 
    13201278                  ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...) 
    13211279                     DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO 
     
    13421300            CALL xios_recv_field( trim(cdvar), pv_r3d) 
    13431301            IF(idom /= jpdom_unknown ) then 
    1344                 CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' ) 
     1302                CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' ) 
    13451303            ENDIF 
    13461304         ELSEIF( PRESENT(pv_r2d) ) THEN 
     
    13491307            CALL xios_recv_field( trim(cdvar), pv_r2d) 
    13501308            IF(idom /= jpdom_unknown ) THEN 
    1351                 CALL lbc_lnk(pv_r2d,'Z',-999.,'no0') 
     1309                CALL lbc_lnk('iom', pv_r2d,'Z',-999.,'no0') 
    13521310            ENDIF 
    13531311         ELSEIF( PRESENT(pv_r1d) ) THEN 
     
    13641322!some final adjustments 
    13651323      ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain 
    1366       IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. ) 
    1367       IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. ) 
     1324      IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( 'iom', pv_r2d,'Z',1. ) 
     1325      IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( 'iom', pv_r3d,'Z',1. ) 
    13681326 
    13691327      !--- Apply scale_factor and offset 
     
    14221380               IF( iom_file(kiomid)%luld(idvar) ) THEN 
    14231381                  IF( iom_file(kiomid)%dimsz(1,idvar) <= size(ptime) ) THEN 
    1424                      SELECT CASE (iom_file(kiomid)%iolib) 
    1425                      CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar ) 
    1426                      CASE DEFAULT 
    1427                         CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1428                      END SELECT 
     1382                     CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar ) 
    14291383                  ELSE 
    14301384                     WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar) 
     
    14441398   END SUBROUTINE iom_gettime 
    14451399 
     1400   !!---------------------------------------------------------------------- 
     1401   !!                   INTERFACE iom_chkatt 
     1402   !!---------------------------------------------------------------------- 
     1403   SUBROUTINE iom_chkatt( kiomid, cdatt, llok, ksize, cdvar ) 
     1404      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
     1405      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
     1406      LOGICAL         , INTENT(  out)                 ::   llok      ! Error code 
     1407      INTEGER         , INTENT(  out), OPTIONAL       ::   ksize     ! Size of the attribute array 
     1408      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable 
     1409      ! 
     1410      IF( kiomid > 0 ) THEN 
     1411         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_chkatt( kiomid, cdatt, llok, ksize=ksize, cdvar=cdvar ) 
     1412      ENDIF 
     1413      ! 
     1414   END SUBROUTINE iom_chkatt 
    14461415 
    14471416   !!---------------------------------------------------------------------- 
    14481417   !!                   INTERFACE iom_getatt 
    14491418   !!---------------------------------------------------------------------- 
    1450    SUBROUTINE iom_g0d_iatt( kiomid, cdatt, pvar, cdvar ) 
    1451       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
    1452       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
    1453       INTEGER         , INTENT(  out)                 ::   pvar      ! read field 
    1454       CHARACTER(len=*), INTENT(in   ), OPTIONAL      ::   cdvar     ! Name of the variable 
     1419   SUBROUTINE iom_g0d_iatt( kiomid, cdatt, katt0d, cdvar ) 
     1420      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1421      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1422      INTEGER               , INTENT(  out)           ::   katt0d    ! read field 
     1423      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
    14551424      ! 
    14561425      IF( kiomid > 0 ) THEN 
    1457          IF( iom_file(kiomid)%nfid > 0 ) THEN 
    1458             SELECT CASE (iom_file(kiomid)%iolib) 
    1459             CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN 
    1460                                       CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) 
    1461                                    ELSE 
    1462                                       CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 
    1463                                    ENDIF 
    1464             CASE DEFAULT 
    1465                CALL ctl_stop( 'iom_g0d_iatt: accepted IO library is only jpnf90' ) 
    1466             END SELECT 
    1467          ENDIF 
     1426         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  katt0d =  katt0d, cdvar=cdvar ) 
    14681427      ENDIF 
    14691428   END SUBROUTINE iom_g0d_iatt 
    14701429 
    1471    SUBROUTINE iom_g0d_ratt( kiomid, cdatt, pvar, cdvar ) 
    1472       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
    1473       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
    1474       REAL(wp)        , INTENT(  out)                 ::   pvar      ! written field 
    1475       CHARACTER(len=*), INTENT(in   ), OPTIONAL      ::   cdvar     ! Name of the variable 
     1430   SUBROUTINE iom_g1d_iatt( kiomid, cdatt, katt1d, cdvar ) 
     1431      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1432      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1433      INTEGER, DIMENSION(:) , INTENT(  out)           ::   katt1d    ! read field 
     1434      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
    14761435      ! 
    14771436      IF( kiomid > 0 ) THEN 
    1478          IF( iom_file(kiomid)%nfid > 0 ) THEN 
    1479             SELECT CASE (iom_file(kiomid)%iolib) 
    1480             CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN 
    1481                                       CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) 
    1482                                    ELSE 
    1483                                       CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 
    1484                                    ENDIF 
    1485             CASE DEFAULT     
    1486                CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' ) 
    1487             END SELECT 
    1488          ENDIF 
     1437         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  katt1d =  katt1d, cdvar=cdvar ) 
     1438      ENDIF 
     1439   END SUBROUTINE iom_g1d_iatt 
     1440 
     1441   SUBROUTINE iom_g0d_ratt( kiomid, cdatt, patt0d, cdvar ) 
     1442      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1443      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1444      REAL(wp)              , INTENT(  out)           ::   patt0d    ! read field 
     1445      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
     1446      ! 
     1447      IF( kiomid > 0 ) THEN 
     1448         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  patt0d =  patt0d, cdvar=cdvar ) 
    14891449      ENDIF 
    14901450   END SUBROUTINE iom_g0d_ratt 
    14911451 
    1492    SUBROUTINE iom_g0d_catt( kiomid, cdatt, pvar, cdvar ) 
    1493       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
    1494       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
    1495       CHARACTER(len=*), INTENT(  out)                 ::   pvar      ! written field 
    1496       CHARACTER(len=*), INTENT(in   ), OPTIONAL      ::   cdvar     ! Name of the variable 
     1452   SUBROUTINE iom_g1d_ratt( kiomid, cdatt, patt1d, cdvar ) 
     1453      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1454      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1455      REAL(wp), DIMENSION(:), INTENT(  out)           ::   patt1d    ! read field 
     1456      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
    14971457      ! 
    14981458      IF( kiomid > 0 ) THEN 
    1499          IF( iom_file(kiomid)%nfid > 0 ) THEN 
    1500             SELECT CASE (iom_file(kiomid)%iolib) 
    1501             CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN 
    1502                                       CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) 
    1503                                    ELSE 
    1504                                       CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 
    1505                                    ENDIF 
    1506             CASE DEFAULT 
    1507                CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' ) 
    1508             END SELECT 
    1509          ENDIF 
     1459         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  patt1d =  patt1d, cdvar=cdvar ) 
     1460      ENDIF 
     1461   END SUBROUTINE iom_g1d_ratt 
     1462    
     1463   SUBROUTINE iom_g0d_catt( kiomid, cdatt, cdatt0d, cdvar ) 
     1464      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1465      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1466      CHARACTER(len=*)      , INTENT(  out)           ::   cdatt0d   ! read field 
     1467      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
     1468      ! 
     1469      IF( kiomid > 0 ) THEN 
     1470         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar ) 
    15101471      ENDIF 
    15111472   END SUBROUTINE iom_g0d_catt 
     1473 
    15121474 
    15131475   !!---------------------------------------------------------------------- 
    15141476   !!                   INTERFACE iom_putatt 
    15151477   !!---------------------------------------------------------------------- 
    1516    SUBROUTINE iom_p0d_iatt( kiomid, cdatt, pvar, cdvar ) 
    1517       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
    1518       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
    1519       INTEGER         , INTENT(in   )                 ::   pvar      ! write field 
    1520       CHARACTER(len=*), INTENT(in   ), OPTIONAL      ::   cdvar     ! Name of the variable 
     1478   SUBROUTINE iom_p0d_iatt( kiomid, cdatt, katt0d, cdvar ) 
     1479      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1480      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1481      INTEGER               , INTENT(in   )           ::   katt0d    ! written field 
     1482      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
    15211483      ! 
    15221484      IF( kiomid > 0 ) THEN 
    1523          IF( iom_file(kiomid)%nfid > 0 ) THEN 
    1524             SELECT CASE (iom_file(kiomid)%iolib) 
    1525             CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN 
    1526                                       CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) 
    1527                                    ELSE 
    1528                                       CALL iom_nf90_putatt( kiomid, cdatt, pvar ) 
    1529                                    ENDIF 
    1530             CASE DEFAULT 
    1531                CALL ctl_stop( 'iom_p0d_iatt: accepted IO library is only jpnf90' ) 
    1532             END SELECT 
    1533          ENDIF 
     1485         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  katt0d =  katt0d, cdvar=cdvar ) 
    15341486      ENDIF 
    15351487   END SUBROUTINE iom_p0d_iatt 
    15361488 
    1537    SUBROUTINE iom_p0d_ratt( kiomid, cdatt, pvar, cdvar ) 
    1538       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
    1539       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
    1540       REAL(wp)        , INTENT(in   )                 ::   pvar      ! write field 
    1541       CHARACTER(len=*), INTENT(in   ), OPTIONAL      ::   cdvar     ! Name of the variable 
     1489   SUBROUTINE iom_p1d_iatt( kiomid, cdatt, katt1d, cdvar ) 
     1490      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1491      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1492      INTEGER, DIMENSION(:) , INTENT(in   )           ::   katt1d    ! written field 
     1493      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
    15421494      ! 
    15431495      IF( kiomid > 0 ) THEN 
    1544          IF( iom_file(kiomid)%nfid > 0 ) THEN 
    1545             SELECT CASE (iom_file(kiomid)%iolib) 
    1546             CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN 
    1547                                       CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) 
    1548                                    ELSE 
    1549                                       CALL iom_nf90_putatt( kiomid, cdatt, pvar ) 
    1550                                    ENDIF 
    1551             CASE DEFAULT     
    1552                CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' ) 
    1553             END SELECT 
    1554          ENDIF 
     1496         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  katt1d =  katt1d, cdvar=cdvar ) 
     1497      ENDIF 
     1498   END SUBROUTINE iom_p1d_iatt 
     1499 
     1500   SUBROUTINE iom_p0d_ratt( kiomid, cdatt, patt0d, cdvar ) 
     1501      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1502      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1503      REAL(wp)              , INTENT(in   )           ::   patt0d    ! written field 
     1504      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
     1505      ! 
     1506      IF( kiomid > 0 ) THEN 
     1507         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  patt0d =  patt0d, cdvar=cdvar ) 
    15551508      ENDIF 
    15561509   END SUBROUTINE iom_p0d_ratt 
    15571510 
    1558    SUBROUTINE iom_p0d_catt( kiomid, cdatt, pvar, cdvar ) 
    1559       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file 
    1560       CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute 
    1561       CHARACTER(len=*), INTENT(in   )                 ::   pvar      ! write field 
    1562       CHARACTER(len=*), INTENT(in   ), OPTIONAL      ::   cdvar     ! Name of the variable 
     1511   SUBROUTINE iom_p1d_ratt( kiomid, cdatt, patt1d, cdvar ) 
     1512      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1513      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1514      REAL(wp), DIMENSION(:), INTENT(in   )           ::   patt1d    ! written field 
     1515      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
    15631516      ! 
    15641517      IF( kiomid > 0 ) THEN 
    1565          IF( iom_file(kiomid)%nfid > 0 ) THEN 
    1566             SELECT CASE (iom_file(kiomid)%iolib) 
    1567             CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN 
    1568                                       CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) 
    1569                                    ELSE 
    1570                                       CALL iom_nf90_putatt( kiomid, cdatt, pvar ) 
    1571                                    ENDIF 
    1572             CASE DEFAULT 
    1573                CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' ) 
    1574             END SELECT 
    1575          ENDIF 
     1518         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  patt1d =  patt1d, cdvar=cdvar ) 
     1519      ENDIF 
     1520   END SUBROUTINE iom_p1d_ratt 
     1521    
     1522   SUBROUTINE iom_p0d_catt( kiomid, cdatt, cdatt0d, cdvar ) 
     1523      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file 
     1524      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute 
     1525      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt0d   ! written field 
     1526      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable 
     1527      ! 
     1528      IF( kiomid > 0 ) THEN 
     1529         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar ) 
    15761530      ENDIF 
    15771531   END SUBROUTINE iom_p0d_catt 
     1532 
    15781533 
    15791534   !!---------------------------------------------------------------------- 
     
    16041559            IF( iom_file(kiomid)%nfid > 0 ) THEN 
    16051560               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
    1606                SELECT CASE (iom_file(kiomid)%iolib) 
    1607                CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar ) 
    1608                CASE DEFAULT      
    1609                   CALL ctl_stop( 'iom_rp0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1610                END SELECT 
     1561               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar ) 
    16111562            ENDIF 
    16121563         ENDIF 
     
    16381589            IF( iom_file(kiomid)%nfid > 0 ) THEN 
    16391590               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
    1640                SELECT CASE (iom_file(kiomid)%iolib) 
    1641                CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar ) 
    1642                CASE DEFAULT      
    1643                   CALL ctl_stop( 'iom_rp1d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1644                END SELECT 
     1591               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar ) 
    16451592            ENDIF 
    16461593         ENDIF 
     
    16721619            IF( iom_file(kiomid)%nfid > 0 ) THEN 
    16731620               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
    1674                SELECT CASE (iom_file(kiomid)%iolib) 
    1675                CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar ) 
    1676                CASE DEFAULT      
    1677                   CALL ctl_stop( 'iom_rp2d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1678                END SELECT 
     1621               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar ) 
    16791622            ENDIF 
    16801623         ENDIF 
     
    17061649            IF( iom_file(kiomid)%nfid > 0 ) THEN 
    17071650               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
    1708                SELECT CASE (iom_file(kiomid)%iolib) 
    1709                CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar ) 
    1710                CASE DEFAULT      
    1711                   CALL ctl_stop( 'iom_rp3d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) 
    1712                END SELECT 
     1651               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar ) 
    17131652            ENDIF 
    17141653         ENDIF 
     
    17161655   END SUBROUTINE iom_rp3d 
    17171656 
     1657 
     1658  SUBROUTINE iom_delay_rst( cdaction, cdcpnt, kncid ) 
     1659      !!--------------------------------------------------------------------- 
     1660      !!   Routine iom_delay_rst: used read/write restart related to mpp_delay 
     1661      !! 
     1662      !!--------------------------------------------------------------------- 
     1663      CHARACTER(len=*), INTENT(in   ) ::   cdaction        ! 
     1664      CHARACTER(len=*), INTENT(in   ) ::   cdcpnt 
     1665      INTEGER         , INTENT(in   ) ::   kncid 
     1666      ! 
     1667      INTEGER  :: ji 
     1668      INTEGER  :: indim 
     1669      LOGICAL  :: llattexist 
     1670      REAL(wp), ALLOCATABLE, DIMENSION(:) ::   zreal1d 
     1671      !!--------------------------------------------------------------------- 
     1672      ! 
     1673      !                                      =================================== 
     1674      IF( TRIM(cdaction) == 'READ' ) THEN   ! read restart related to mpp_delay ! 
     1675         !                                   =================================== 
     1676         DO ji = 1, nbdelay 
     1677            IF ( c_delaycpnt(ji) == cdcpnt ) THEN 
     1678               CALL iom_chkatt( kncid, 'DELAY_'//c_delaylist(ji), llattexist, indim ) 
     1679               IF( llattexist )  THEN 
     1680                  ALLOCATE( todelay(ji)%z1d(indim) ) 
     1681                  CALL iom_getatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) ) 
     1682                  ndelayid(ji) = 0   ! set to 0 to specify that the value was read in the restart 
     1683               ENDIF 
     1684           ENDIF 
     1685         END DO 
     1686         !                                   ==================================== 
     1687      ELSE                                  ! write restart related to mpp_delay ! 
     1688         !                                   ==================================== 
     1689         DO ji = 1, nbdelay   ! save only ocean delayed global communication variables 
     1690            IF ( c_delaycpnt(ji) == cdcpnt ) THEN 
     1691               IF( ASSOCIATED(todelay(ji)%z1d) ) THEN 
     1692                  CALL mpp_delay_rcv(ji)   ! make sure %z1d is received 
     1693                  CALL iom_putatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) ) 
     1694               ENDIF 
     1695            ENDIF 
     1696         END DO 
     1697         ! 
     1698      ENDIF 
     1699       
     1700   END SUBROUTINE iom_delay_rst 
     1701   
     1702    
    17181703 
    17191704   !!---------------------------------------------------------------------- 
     
    19711956         SELECT CASE ( cdgrd ) 
    19721957         CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:) 
    1973          CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. ) 
    1974          CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( zmask, 'V', 1. ) 
     1958         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( 'iom', zmask, 'U', 1. ) 
     1959         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( 'iom', zmask, 'V', 1. ) 
    19751960         CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1) 
    19761961         END SELECT 
     
    20152000      ! 
    20162001      z_fld(:,:) = 1._wp 
    2017       CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold 
     2002      CALL lbc_lnk( 'iom', z_fld, cdgrd, -1. )    ! Working array for location of northfold 
    20182003      ! 
    20192004      ! Cell vertices that can be defined 
     
    20332018      ! Cell vertices on boundries 
    20342019      DO jn = 1, 4 
    2035          CALL lbc_lnk( z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp ) 
    2036          CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp ) 
     2020         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp ) 
     2021         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp ) 
    20372022      END DO 
    20382023      ! 
  • NEMO/trunk/src/OCE/IOM/iom_def.F90

    r10068 r10425  
    2323   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo_xy    = 9   !: Automatically set horizontal dimensions only 
    2424   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 10  !:  
    25  
    26    INTEGER, PARAMETER, PUBLIC ::   jpnf90      = 101      !: Use nf90 library 
    27  
    28    INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jpnf90     !: restarts io library 
    2925 
    3026   INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8) 
     
    5551      CHARACTER(LEN=240)                        ::   name     !: name of the file 
    5652      INTEGER                                   ::   nfid     !: identifier of the file (0 if closed) 
    57       INTEGER                                   ::   iolib    !: library used to read the file (jpnf90 or new formats, 
    5853                                                              !: jpioipsl option has been removed) 
    5954      INTEGER                                   ::   nvars    !: number of identified varibles in the file 
  • NEMO/trunk/src/OCE/IOM/iom_nf90.F90

    r10068 r10425  
    3030 
    3131   PUBLIC iom_nf90_open  , iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput 
    32    PUBLIC iom_nf90_getatt, iom_nf90_putatt 
     32   PUBLIC iom_nf90_chkatt, iom_nf90_getatt, iom_nf90_putatt 
    3333 
    3434   INTERFACE iom_nf90_get 
    3535      MODULE PROCEDURE iom_nf90_g0d, iom_nf90_g123d 
    36    END INTERFACE 
    37    INTERFACE iom_nf90_getatt 
    38       MODULE PROCEDURE iom_nf90_giatt, iom_nf90_gratt, iom_nf90_gcatt 
    39    END INTERFACE 
    40    INTERFACE iom_nf90_putatt 
    41       MODULE PROCEDURE iom_nf90_piatt, iom_nf90_pratt, iom_nf90_pcatt 
    4236   END INTERFACE 
    4337   INTERFACE iom_nf90_rstput 
     
    129123               CALL iom_nf90_check(NF90_CREATE( TRIM(cdname), imode, if90id, chunksize = ichunk ), clinfo) 
    130124            ENDIF 
    131             CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                    ), clinfo) 
     125            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL,                   idmy ), clinfo) 
    132126            ! define dimensions 
    133             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x'      , kdompar(1,1)  , idmy ), clinfo) 
    134             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y'      , kdompar(2,1)  , idmy ), clinfo) 
    135             IF( PRESENT(kdlev) ) THEN 
    136                CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'numcat' , ilevels    , idmy ), clinfo) 
    137             ELSE 
    138                CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev', ilevels    , idmy ), clinfo) 
    139             ENDIF 
     127            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',   kdompar(1,1), idmy ), clinfo) 
     128            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',   kdompar(2,1), idmy ), clinfo) 
     129            CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',            jpk, idmy ), clinfo) 
    140130            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo) 
     131            IF( PRESENT(kdlev) )   & 
     132               CALL iom_nf90_check(NF90_DEF_DIM( if90id,    'numcat',          kdlev, idmy ), clinfo) 
    141133            ! global attributes 
    142134            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo) 
     
    165157         iom_file(kiomid)%name   = TRIM(cdname) 
    166158         iom_file(kiomid)%nfid   = if90id 
    167          iom_file(kiomid)%iolib  = jpnf90 
    168159         iom_file(kiomid)%nvars  = 0 
    169160         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode  
     
    329320   END SUBROUTINE iom_nf90_g123d 
    330321 
    331    !!---------------------------------------------------------------------- 
    332    !!                   INTERFACE iom_nf90_getatt 
    333    !!---------------------------------------------------------------------- 
    334  
    335    SUBROUTINE iom_nf90_giatt( kiomid, cdatt, pv_i0d, cdvar) 
    336       !!----------------------------------------------------------------------- 
    337       !!                  ***  ROUTINE  iom_nf90_giatt  *** 
    338       !! 
    339       !! ** Purpose : read an integer attribute with NF90 
     322 
     323   SUBROUTINE iom_nf90_chkatt( kiomid, cdatt, llok, ksize, cdvar ) 
     324      !!----------------------------------------------------------------------- 
     325      !!                  ***  ROUTINE  iom_nf90_chkatt  *** 
     326      !! 
     327      !! ** Purpose : check existence of attribute with NF90 
    340328      !!              (either a global attribute (default) or a variable 
    341329      !!               attribute if optional variable name is supplied (cdvar)) 
     
    343331      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    344332      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    345       INTEGER         , INTENT(  out) ::   pv_i0d   ! read field 
     333      LOGICAL         , INTENT(  out) ::   llok     ! error code 
     334      INTEGER         , INTENT(  out), OPTIONAL     & 
     335                      &               ::   ksize    ! attribute size 
    346336      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
    347337                      &               ::   cdvar    ! name of the variable 
     338      ! 
     339      INTEGER                         ::   if90id   ! temporary integer 
     340      INTEGER                         ::   isize    ! temporary integer 
     341      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     342      !--------------------------------------------------------------------- 
     343      ! 
     344      if90id = iom_file(kiomid)%nfid 
     345      IF( PRESENT(cdvar) ) THEN 
     346         ! check the variable exists in the file 
     347         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     348         IF( llok ) & 
     349            ! check the variable has the attribute required 
     350            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt, len=isize ) == nf90_noerr 
     351      ELSE 
     352         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt, len=isize ) == nf90_noerr 
     353      ENDIF 
     354      ! 
     355      IF( PRESENT(ksize) ) ksize = isize 
     356      ! 
     357      IF( .not. llok) & 
     358         CALL ctl_warn('iom_nf90_chkatt: no attribute '//cdatt//' found') 
     359      ! 
     360   END SUBROUTINE iom_nf90_chkatt 
     361 
     362 
     363   !!---------------------------------------------------------------------- 
     364   !!                   INTERFACE iom_nf90_getatt 
     365   !!---------------------------------------------------------------------- 
     366 
     367   SUBROUTINE iom_nf90_getatt( kiomid, cdatt, katt0d, katt1d, patt0d, patt1d, cdatt0d, cdvar) 
     368      !!----------------------------------------------------------------------- 
     369      !!                  ***  ROUTINE  iom_nf90_getatt  *** 
     370      !! 
     371      !! ** Purpose : read an attribute with NF90 
     372      !!              (either a global attribute (default) or a variable 
     373      !!               attribute if optional variable name is supplied (cdvar)) 
     374      !!----------------------------------------------------------------------- 
     375      INTEGER               , INTENT(in   )           ::   kiomid   ! Identifier of the file 
     376      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt    ! attribute name 
     377      INTEGER               , INTENT(  out), OPTIONAL ::   katt0d   ! read scalar integer 
     378      INTEGER, DIMENSION(:) , INTENT(  out), OPTIONAL ::   katt1d   ! read 1d array integer 
     379      REAL(wp)              , INTENT(  out), OPTIONAL ::   patt0d   ! read scalar  real 
     380      REAL(wp), DIMENSION(:), INTENT(  out), OPTIONAL ::   patt1d   ! read 1d array real 
     381      CHARACTER(len=*)      , INTENT(  out), OPTIONAL ::   cdatt0d  ! read character 
     382      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar    ! name of the variable 
    348383      ! 
    349384      INTEGER                         ::   if90id   ! temporary integer 
     
    361396            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
    362397         ELSE 
    363             CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
     398            CALL ctl_warn('iom_nf90_getatt: no variable '//TRIM(cdvar)//' found') 
    364399         ENDIF 
    365400      ELSE 
     
    369404      ! 
    370405      IF( llok) THEN 
    371          clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', giatt: '//TRIM(cdatt) 
    372          CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 
     406         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt) 
     407         IF(PRESENT( katt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  katt0d), clinfo) 
     408         IF(PRESENT( katt1d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  katt1d), clinfo) 
     409         IF(PRESENT( patt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  patt0d), clinfo) 
     410         IF(PRESENT( patt1d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  patt1d), clinfo) 
     411         IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values = cdatt0d), clinfo) 
    373412      ELSE 
    374          CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
    375          pv_i0d = -999 
    376       ENDIF 
    377       ! 
    378    END SUBROUTINE iom_nf90_giatt 
    379  
    380  
    381    SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar ) 
    382       !!----------------------------------------------------------------------- 
    383       !!                  ***  ROUTINE  iom_nf90_gratt  *** 
    384       !! 
    385       !! ** Purpose : read a real attribute with NF90 
     413         CALL ctl_warn('iom_nf90_getatt: no attribute '//TRIM(cdatt)//' found') 
     414         IF(PRESENT( katt0d))    katt0d    = -999 
     415         IF(PRESENT( katt1d))    katt1d(:) = -999 
     416         IF(PRESENT( patt0d))    patt0d    = -999._wp 
     417         IF(PRESENT( patt1d))    patt1d(:) = -999._wp 
     418         IF(PRESENT(cdatt0d))   cdatt0d    = '!' 
     419      ENDIF 
     420      ! 
     421   END SUBROUTINE iom_nf90_getatt 
     422 
     423 
     424   SUBROUTINE iom_nf90_putatt( kiomid, cdatt, katt0d, katt1d, patt0d, patt1d, cdatt0d, cdvar) 
     425      !!----------------------------------------------------------------------- 
     426      !!                  ***  ROUTINE  iom_nf90_putatt  *** 
     427      !! 
     428      !! ** Purpose : write an attribute with NF90 
    386429      !!              (either a global attribute (default) or a variable 
    387430      !!               attribute if optional variable name is supplied (cdvar)) 
    388431      !!----------------------------------------------------------------------- 
    389       INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    390       CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
    391       REAL(wp)                  , INTENT(  out) ::   pv_r0d   ! read field 
    392       CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
    393       ! 
    394       INTEGER            ::   if90id   ! temporary integer 
    395       INTEGER            ::   ivarid   ! NetCDF variable Id 
    396       LOGICAL            ::   llok     ! temporary logical 
    397       CHARACTER(LEN=100) ::   clinfo   ! info character 
     432      INTEGER               , INTENT(in   )           ::   kiomid   ! Identifier of the file 
     433      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt    ! attribute name 
     434      INTEGER               , INTENT(in   ), OPTIONAL ::   katt0d   ! read scalar integer 
     435      INTEGER, DIMENSION(:) , INTENT(in   ), OPTIONAL ::   katt1d   ! read 1d array integer 
     436      REAL(wp)              , INTENT(in   ), OPTIONAL ::   patt0d   ! read scalar  real 
     437      REAL(wp), DIMENSION(:), INTENT(in   ), OPTIONAL ::   patt1d   ! read 1d array real 
     438      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdatt0d  ! read character 
     439      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar    ! name of the variable 
     440      ! 
     441      INTEGER                         ::   if90id   ! temporary integer 
     442      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     443      INTEGER                         ::   isize    ! Attribute size 
     444      INTEGER                         ::   itype    ! Attribute type 
     445      LOGICAL                         ::   llok     ! temporary logical 
     446      LOGICAL                         ::   llatt     ! temporary logical 
     447      LOGICAL                         ::   lldata   ! temporary logical 
     448      CHARACTER(LEN=100)              ::   clinfo   ! info character 
    398449      !--------------------------------------------------------------------- 
    399450      ! 
    400451      if90id = iom_file(kiomid)%nfid 
    401452      IF( PRESENT(cdvar) ) THEN 
    402          ! check the variable exists in the file 
    403          llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
    404          IF( llok ) THEN 
    405             ! check the variable has the attribute required 
    406             llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
    407          ELSE 
    408             CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
     453         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! is the variable in the file? 
     454         IF( .NOT. llok ) THEN 
     455            CALL ctl_warn('iom_nf90_putatt: no variable '//TRIM(cdvar)//' found'   & 
     456               &        , '                 no attribute '//cdatt//' written' ) 
     457            RETURN 
    409458         ENDIF 
    410459      ELSE 
    411          llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
    412460         ivarid = NF90_GLOBAL 
    413461      ENDIF 
    414       ! 
    415       IF( llok) THEN 
    416          clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gratt: '//TRIM(cdatt) 
    417          CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 
    418       ELSE 
    419          CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
    420          pv_r0d = -999._wp 
    421       ENDIF 
    422       ! 
    423    END SUBROUTINE iom_nf90_gratt 
    424  
    425  
    426    SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar ) 
    427       !!----------------------------------------------------------------------- 
    428       !!                  ***  ROUTINE  iom_nf90_gcatt  *** 
    429       !! 
    430       !! ** Purpose : read a character attribute with NF90 
    431       !!              (either a global attribute (default) or a variable 
    432       !!               attribute if optional variable name is supplied (cdvar)) 
    433       !!----------------------------------------------------------------------- 
    434       INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    435       CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
    436       CHARACTER(len=*)          , INTENT(  out) ::   pv_c0d   ! read field 
    437       CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
    438       ! 
    439       INTEGER            ::   if90id   ! temporary integer 
    440       INTEGER            ::   ivarid   ! NetCDF variable Id 
    441       LOGICAL            ::   llok     ! temporary logical 
    442       CHARACTER(LEN=100) ::   clinfo   ! info character 
    443       !--------------------------------------------------------------------- 
    444       ! 
    445       if90id = iom_file(kiomid)%nfid 
    446       IF( PRESENT(cdvar) ) THEN 
    447          ! check the variable exists in the file 
    448          llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
    449          IF( llok ) THEN 
    450             ! check the variable has the attribute required 
    451             llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
    452          ELSE 
    453             CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
    454          ENDIF 
    455       ELSE 
    456          llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
    457          ivarid = NF90_GLOBAL 
    458       ENDIF 
    459 ! 
    460       IF( llok) THEN 
    461          clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gcatt: '//TRIM(cdatt) 
    462          CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo) 
    463       ELSE 
    464          CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
    465          pv_c0d = '!' 
    466       ENDIF 
    467       ! 
    468    END SUBROUTINE iom_nf90_gcatt 
    469  
    470  
    471    !!---------------------------------------------------------------------- 
    472    !!                   INTERFACE iom_nf90_putatt 
    473    !!---------------------------------------------------------------------- 
    474  
    475    SUBROUTINE iom_nf90_piatt( kiomid, cdatt, pv_i0d, cdvar) 
    476       !!----------------------------------------------------------------------- 
    477       !!                  ***  ROUTINE  iom_nf90_piatt  *** 
    478       !! 
    479       !! ** Purpose : write an integer attribute with NF90 
    480       !!              (either a global attribute (default) or a variable 
    481       !!               attribute if optional variable name is supplied (cdvar)) 
    482       !!----------------------------------------------------------------------- 
    483       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    484       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    485       INTEGER         , INTENT(in   ) ::   pv_i0d   ! write field 
    486       CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
    487                       &               ::   cdvar    ! name of the variable 
    488       ! 
    489       INTEGER                         ::   if90id   ! temporary integer 
    490       INTEGER                         ::   ivarid   ! NetCDF variable Id 
    491       LOGICAL                         ::   llok     ! temporary logical 
    492       LOGICAL                         ::   lenddef  ! temporary logical 
    493       CHARACTER(LEN=100)              ::   clinfo   ! info character 
    494       !--------------------------------------------------------------------- 
    495       ! 
    496       if90id = iom_file(kiomid)%nfid 
    497       lenddef = .false. 
    498       IF( PRESENT(cdvar) ) THEN 
    499          ! check the variable exists in the file 
    500          llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
    501          IF( .NOT. llok ) THEN 
    502             CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 
    503          ENDIF 
    504       ELSE 
    505          llok = .true. 
    506          ivarid = NF90_GLOBAL 
    507       ENDIF 
    508       ! 
    509       IF( llok) THEN 
    510          clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', piatt: '//TRIM(cdatt) 
    511          IF( iom_file(kiomid)%irec /= -1 ) THEN    
    512             ! trick: irec used to know if the file is in define mode or not 
    513             ! if it is not then temporarily put it into define mode 
    514             CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 
    515             lenddef = .true. 
    516          ENDIF 
     462      llatt = NF90_Inquire_attribute(if90id, ivarid, cdatt, len = isize, xtype = itype ) == nf90_noerr 
     463      ! 
     464      ! trick: irec used to know if the file is in define mode or not 
     465      lldata = iom_file(kiomid)%irec /= -1   ! default: go back in define mode if in data mode 
     466      IF( lldata .AND. llatt ) THEN          ! attribute already there. Do we really need to go back in define mode? 
     467         ! do we have the appropriate type? 
     468         IF(PRESENT( katt0d) .OR. PRESENT( katt1d))   llok = itype == NF90_INT 
     469         IF(PRESENT( patt0d) .OR. PRESENT( patt1d))   llok = itype == NF90_DOUBLE 
     470         IF(PRESENT(cdatt0d)                      )   llok = itype == NF90_CHAR 
     471         ! and do we have the appropriate size? 
     472         IF(PRESENT( katt0d))   llok = llok .AND. isize == 1 
     473         IF(PRESENT( katt1d))   llok = llok .AND. isize == SIZE(katt1d) 
     474         IF(PRESENT( patt0d))   llok = llok .AND. isize == 1 
     475         IF(PRESENT( patt1d))   llok = llok .AND. isize == SIZE(patt1d) 
     476         IF(PRESENT(cdatt0d))   llok = llok .AND. isize == LEN_TRIM(cdatt0d) 
    517477         ! 
    518          CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 
    519          ! 
    520          IF( lenddef ) THEN    
    521             ! file was in data mode on entry; put it back in that mode 
    522             CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 
    523          ENDIF 
    524       ELSE 
    525          CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 
    526       ENDIF 
    527       ! 
    528    END SUBROUTINE iom_nf90_piatt 
    529  
    530  
    531    SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar ) 
    532       !!----------------------------------------------------------------------- 
    533       !!                  ***  ROUTINE  iom_nf90_pratt  *** 
    534       !! 
    535       !! ** Purpose : write a real attribute with NF90 
    536       !!              (either a global attribute (default) or a variable 
    537       !!               attribute if optional variable name is supplied (cdvar)) 
    538       !!----------------------------------------------------------------------- 
    539       INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    540       CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
    541       REAL(wp)                  , INTENT(in   ) ::   pv_r0d   ! write field 
    542       CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
    543       ! 
    544       INTEGER            ::   if90id   ! temporary integer 
    545       INTEGER            ::   ivarid   ! NetCDF variable Id 
    546       LOGICAL            ::   llok     ! temporary logical 
    547       LOGICAL            ::   lenddef  ! temporary logical 
    548       CHARACTER(LEN=100) ::   clinfo   ! info character 
    549       !--------------------------------------------------------------------- 
    550       ! 
    551       if90id = iom_file(kiomid)%nfid 
    552       lenddef = .false. 
    553       IF( PRESENT(cdvar) ) THEN 
    554          ! check the variable exists in the file 
    555          llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
    556          IF( .NOT. llok ) THEN 
    557             CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 
    558          ENDIF 
    559       ELSE 
    560          llok = .true. 
    561          ivarid = NF90_GLOBAL 
    562       ENDIF 
    563       ! 
    564       IF( llok) THEN 
    565          clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pratt: '//TRIM(cdatt) 
    566          IF( iom_file(kiomid)%irec /= -1 ) THEN    
    567             ! trick: irec used to know if the file is in define mode or not 
    568             ! if it is not then temporarily put it into define mode 
    569             CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 
    570             lenddef = .true. 
    571          ENDIF 
    572          ! 
    573          CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 
    574          ! 
    575          IF( lenddef ) THEN    
    576             ! file was in data mode on entry; put it back in that mode 
    577             CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 
    578          ENDIF 
    579       ELSE 
    580          CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 
    581       ENDIF 
    582       ! 
    583    END SUBROUTINE iom_nf90_pratt 
    584  
    585  
    586    SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar ) 
    587       !!----------------------------------------------------------------------- 
    588       !!                  ***  ROUTINE  iom_nf90_pcatt  *** 
    589       !! 
    590       !! ** Purpose : write a character attribute with NF90 
    591       !!              (either a global attribute (default) or a variable 
    592       !!               attribute if optional variable name is supplied (cdvar)) 
    593       !!----------------------------------------------------------------------- 
    594       INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    595       CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
    596       CHARACTER(len=*)          , INTENT(in   ) ::   pv_c0d   ! write field 
    597       CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
    598       ! 
    599       INTEGER            ::   if90id   ! temporary integer 
    600       INTEGER            ::   ivarid   ! NetCDF variable Id 
    601       LOGICAL            ::   llok     ! temporary logical 
    602       LOGICAL            ::   lenddef  ! temporary logical 
    603       CHARACTER(LEN=100) ::   clinfo   ! info character 
    604       !--------------------------------------------------------------------- 
    605       ! 
    606       if90id = iom_file(kiomid)%nfid 
    607       lenddef = .false. 
    608       IF( PRESENT(cdvar) ) THEN 
    609          ! check the variable exists in the file 
    610          llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
    611          IF( .NOT. llok ) THEN 
    612             CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 
    613          ENDIF 
    614       ELSE 
    615          llok = .true. 
    616          ivarid = NF90_GLOBAL 
    617       ENDIF 
    618       ! 
    619       IF( llok) THEN 
    620          clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pcatt: '//TRIM(cdatt) 
    621          IF( iom_file(kiomid)%irec /= -1 ) THEN    
    622             ! trick: irec used to know if the file is in define mode or not 
    623             ! if it is not then temporarily put it into define mode 
    624             CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 
    625             lenddef = .true. 
    626          ENDIF 
    627          ! 
    628          CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo) 
    629          ! 
    630          IF( lenddef ) THEN    
    631             ! file was in data mode on entry; put it back in that mode 
    632             CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 
    633          ENDIF 
    634       ELSE 
    635          CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 
    636       ENDIF 
    637       ! 
    638    END SUBROUTINE iom_nf90_pcatt 
     478         lldata = .NOT. llok 
     479      ENDIF 
     480      ! 
     481      clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt) 
     482      IF(lldata)   CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ! leave data mode to define mode 
     483      ! 
     484      IF(PRESENT( katt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       katt0d) , clinfo) 
     485      IF(PRESENT( katt1d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       katt1d) , clinfo) 
     486      IF(PRESENT( patt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       patt0d) , clinfo) 
     487      IF(PRESENT( patt1d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       patt1d) , clinfo) 
     488      IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values = trim(cdatt0d)), clinfo) 
     489      ! 
     490      IF(lldata)   CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)   ! leave define mode to data mode 
     491      ! 
     492   END SUBROUTINE iom_nf90_putatt 
    639493 
    640494 
     
    693547      INTEGER, DIMENSION(4) :: idimid               ! dimensions id 
    694548      CHARACTER(LEN=256)    :: clinfo               ! info character 
    695       CHARACTER(LEN= 12), DIMENSION(4) :: cltmp     ! temporary character 
     549      CHARACTER(LEN= 12), DIMENSION(5) :: cltmp     ! temporary character 
    696550      INTEGER               :: if90id               ! nf90 file identifier 
    697551      INTEGER               :: idmy                 ! dummy variable 
     
    704558      !                                             ! when appropriate (currently chunking is applied to 4d fields only) 
    705559      INTEGER               :: idlv                 ! local variable 
     560      INTEGER               :: idim3                ! id of the third dimension 
    706561      !--------------------------------------------------------------------- 
    707562      ! 
     
    717572         ENDIF 
    718573         ! define the dimension variables if it is not already done 
    719          IF(iom_file(kiomid)%nlev == jpk ) THEN 
    720           cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /) 
    721          ELSE 
    722           cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'numcat      ', 'time_counter' /) 
    723          ENDIF 
     574         cltmp = (/ 'nav_lon', 'nav_lat', 'nav_lev', 'time_counter', 'numcat' /) 
    724575         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo) 
    725576         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo) 
     
    729580         iom_file(kiomid)%nvars       = 4 
    730581         iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /) 
    731          iom_file(kiomid)%cn_var(1:4) = cltmp 
    732          iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)   
     582         iom_file(kiomid)%cn_var(1:4) = cltmp(1:4) 
     583         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /) 
     584         IF( NF90_INQ_DIMID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN   ! add a 5th variable corresponding to the 5th dimension 
     585            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(5)), NF90_FLOAT , (/ 5 /), iom_file(kiomid)%nvid(5) ), clinfo) 
     586            iom_file(kiomid)%nvars     = 5 
     587            iom_file(kiomid)%luld(5)   = .FALSE. 
     588            iom_file(kiomid)%cn_var(5) = cltmp(5) 
     589            iom_file(kiomid)%ndims(5)  = 1 
     590         ENDIF 
    733591         ! trick: defined to 0 to say that dimension variables are defined but not yet written 
    734592         iom_file(kiomid)%dimsz(1, 1)  = 0    
     
    752610         ! variable definition 
    753611         IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0 
    754          ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/) 
     612         ELSEIF( PRESENT(pv_r1d) ) THEN 
     613            IF( SIZE(pv_r1d,1) == jpk ) THEN   ;   idim3 = 3 
     614            ELSE                               ;   idim3 = 5 
     615            ENDIF 
     616                                              idims = 2   ;   idimid(1:idims) = (/idim3,4/) 
    755617         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/) 
    756          ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/) 
     618         ELSEIF( PRESENT(pv_r3d) ) THEN 
     619            IF( SIZE(pv_r3d,3) == jpk ) THEN   ;   idim3 = 3 
     620            ELSE                               ;   idim3 = 5 
     621            ENDIF 
     622                                              idims = 4   ;   idimid(1:idims) = (/1,2,idim3,4/) 
    757623         ENDIF 
    758624         IF( PRESENT(ktype) ) THEN   ! variable external type 
    759625            SELECT CASE (ktype) 
    760             CASE (jp_r8)  ;   itype = NF90_DOUBLE 
    761             CASE (jp_r4)  ;   itype = NF90_FLOAT 
    762             CASE (jp_i4)  ;   itype = NF90_INT 
    763             CASE (jp_i2)  ;   itype = NF90_SHORT 
    764             CASE (jp_i1)  ;   itype = NF90_BYTE 
     626            CASE (jp_r8)   ;   itype = NF90_DOUBLE 
     627            CASE (jp_r4)   ;   itype = NF90_FLOAT 
     628            CASE (jp_i4)   ;   itype = NF90_INT 
     629            CASE (jp_i2)   ;   itype = NF90_SHORT 
     630            CASE (jp_i1)   ;   itype = NF90_BYTE 
    765631            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' ) 
    766632            END SELECT 
     
    834700               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lat'     , idmy )         , clinfo ) 
    835701               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo ) 
    836                IF(iom_file(kiomid)%nlev == jpk ) THEN  
    837                   !NEMO 
    838                   CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo ) 
    839                   CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo ) 
    840                ELSE 
    841                   CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'numcat'     , idmy ), clinfo) 
     702               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo ) 
     703               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo ) 
     704               IF( NF90_INQ_VARID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN 
    842705                  CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, (/ (idlv, idlv = 1,iom_file(kiomid)%nlev) /)), clinfo ) 
    843706               ENDIF 
  • NEMO/trunk/src/OCE/IOM/restart.F90

    r10068 r10425  
    2828   USE iom             ! I/O module 
    2929   USE diurnal_bulk 
     30   USE lib_mpp         ! distribued memory computing library 
    3031 
    3132   IMPLICIT NONE 
     
    9798               WRITE(numout,*) 
    9899               IF(.NOT.lwxios) THEN 
    99                   SELECT CASE ( jprstlib ) 
    100                   CASE DEFAULT         ;   WRITE(numout,*)                            & 
    101                       '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname) 
    102                   END SELECT 
     100                  WRITE(numout,*) '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname) 
    103101                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression' 
    104102                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt 
     
    109107            ! 
    110108            IF(.NOT.lwxios) THEN 
    111                CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib ) 
     109               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. ) 
    112110            ELSE 
    113111#if defined key_iomput 
     
    137135      !!                   ***  ROUTINE rstwrite  *** 
    138136      !!                      
    139       !! ** Purpose :   Write restart fields in the format corresponding to jprstlib 
     137      !! ** Purpose :   Write restart fields in NetCDF format 
    140138      !! 
    141139      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF 
     
    146144                     IF(lwxios) CALL iom_swap(      cwxios_context          ) 
    147145                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step 
     146                     CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables 
    148147 
    149148      IF ( .NOT. ln_diurnal_only ) THEN 
     
    197196      !!                   ***  ROUTINE rst_read_open  *** 
    198197      !!  
    199       !! ** Purpose :   Open read files for restart (format fixed by jprstlib ) 
     198      !! ** Purpose :   Open read files for NetCDF restart 
    200199      !!  
    201200      !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not 
    202201      !!                the file has already been opened 
    203202      !!---------------------------------------------------------------------- 
    204       INTEGER        ::   jlibalt = jprstlib 
    205203      LOGICAL        ::   llok 
    206204      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file 
     
    210208         IF(lwp) THEN                                             ! Contol prints 
    211209            WRITE(numout,*) 
    212             SELECT CASE ( jprstlib ) 
    213             CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file' 
    214             END SELECT 
     210            WRITE(numout,*) 'rst_read : read oce NetCDF restart file' 
    215211            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support' 
    216212            WRITE(numout,*) '~~~~~~~~' 
     
    219215         clpath = TRIM(cn_ocerst_indir) 
    220216         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' 
    221          CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt ) 
     217         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror ) 
    222218! are we using XIOS to read the data? Part above will have to modified once XIOS 
    223219! can handle checking if variable is in the restart file (there will be no need to open 
     
    246242      !!                   ***  ROUTINE rst_read  *** 
    247243      !!  
    248       !! ** Purpose :   Read files for restart (format fixed by jprstlib ) 
     244      !! ** Purpose :   Read files for NetCDF restart 
    249245      !!  
    250246      !! ** Method  :   Read in restart.nc file fields which are necessary for restart 
     
    263259      ENDIF 
    264260 
     261      CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables 
     262       
    265263      ! Diurnal DSST  
    266264      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios )  
Note: See TracChangeset for help on using the changeset viewer.