Index: NEMO/trunk/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/in_out_manager.F90	(revision 10361)
+++ NEMO/trunk/src/OCE/IOM/in_out_manager.F90	(revision 10425)
@@ -122,4 +122,5 @@
    INTEGER ::   numtime         =   -1      !: logical unit for timing
    INTEGER ::   numout          =    6      !: logical unit for output print; Set to stdout to ensure any
+   INTEGER ::   numnul          =   -1      !: logical unit for /dev/null
       !                                     !  early output can be collected; do not change
    INTEGER ::   numnam_ref      =   -1      !: logical unit for reference namelist
Index: NEMO/trunk/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/iom.F90	(revision 10361)
+++ NEMO/trunk/src/OCE/IOM/iom.F90	(revision 10425)
@@ -58,5 +58,5 @@
 #endif
    PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get
-   PUBLIC iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_put
+   PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_delay_rst, iom_put
    PUBLIC iom_use, iom_context_finalize
 
@@ -75,8 +75,8 @@
    END INTERFACE
    INTERFACE iom_getatt
-      MODULE PROCEDURE iom_g0d_iatt, iom_g0d_ratt, iom_g0d_catt
+      MODULE PROCEDURE iom_g0d_iatt, iom_g1d_iatt, iom_g0d_ratt, iom_g1d_ratt, iom_g0d_catt
    END INTERFACE
    INTERFACE iom_putatt
-      MODULE PROCEDURE iom_p0d_iatt, iom_p0d_ratt, iom_p0d_catt
+      MODULE PROCEDURE iom_p0d_iatt, iom_p1d_iatt, iom_p0d_ratt, iom_p1d_ratt, iom_p0d_catt
    END INTERFACE
    INTERFACE iom_rstput
@@ -286,9 +286,6 @@
 !Warn if variable is not in defined in rst_wfields
    IF(.NOT.llis_set) THEN
-      IF(lwp) THEN
-         write(numout,cform_err)
-         write(numout,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined' 
-      ENDIF
-        nstop = nstop + 1
+      WRITE(ctmp1,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined' 
+      CALL ctl_stop( 'iom_set_rstw_var_active:', ctmp1 )
    ENDIF
 #else
@@ -518,6 +515,6 @@
 
         IF( i-1 > max_rst_fields) THEN
-        IF(lwp) write(numout,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
-        nstop = nstop + 1
+           WRITE(ctmp1,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
+           CALL ctl_stop( 'iom_set_rst_vars:', ctmp1 )
         ENDIF
    END SUBROUTINE iom_set_rst_vars
@@ -634,5 +631,5 @@
 
 
-   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof, kdlev )
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -644,5 +641,4 @@
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
       INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
-      INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90) 
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
@@ -659,5 +655,4 @@
       LOGICAL               ::   llstop    ! local definition of ldstop
       LOGICAL               ::   lliof     ! local definition of ldiof
-      INTEGER               ::   iolib     ! library do we use to open the file
       INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
       INTEGER               ::   iln, ils  ! lengths of character
@@ -692,8 +687,4 @@
       ELSE                         ;   llstop = .TRUE.
       ENDIF
-      ! what library do we use to open the file?
-      IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib
-      ELSE                         ;   iolib = jpnf90
-      ENDIF
       ! are we using interpolation on the fly?
       IF( PRESENT(ldiof) ) THEN   ;   lliof = ldiof
@@ -713,9 +704,5 @@
       ENDIF
       ! which suffix should we use?
-      SELECT CASE (iolib)
-      CASE (jpnf90   ) ;   clsuffix = '.nc'
-      CASE DEFAULT     ;   clsuffix = ''
-         CALL ctl_stop( TRIM(clinfo), 'accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
-      END SELECT
+      clsuffix = '.nc'
       ! Add the suffix if needed
       iln = LEN_TRIM(clname)
@@ -802,9 +789,5 @@
       ENDIF
       IF( istop == nstop ) THEN   ! no error within this routine
-         SELECT CASE (iolib)
-         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar, kdlev = kdlev )
-         CASE DEFAULT
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
-         END SELECT
+         CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev )
       ENDIF
       !
@@ -839,9 +822,5 @@
          DO jf = i_s, i_e
             IF( iom_file(jf)%nfid > 0 ) THEN
-               SELECT CASE (iom_file(jf)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
-               CASE DEFAULT
-                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_close( jf )
                iom_file(jf)%nfid       = 0          ! free the id 
                IF( PRESENT(kiomid) )   kiomid = 0   ! return 0 as id to specify that the file was closed
@@ -896,12 +875,8 @@
                iiv = iiv + 1
                IF( iiv <= jpmax_vars ) THEN
-                  SELECT CASE (iom_file(kiomid)%iolib)
-                  CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz, kndims )
-                  CASE DEFAULT
-                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-                  END SELECT
+                  iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz, kndims )
                ELSE
                   CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
-                        &                         'increase the parameter jpmax_vars')
+                        &                      'increase the parameter jpmax_vars')
                ENDIF
                IF( llstop .AND. iom_varid == -1 )   CALL ctl_stop( TRIM(clinfo)//' not found' ) 
@@ -962,9 +937,5 @@
                                     &                         'with 1 or more spatial dimensions: '//cldmspc//' were found.' , &
                                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime )
-               CASE DEFAULT
-                  CALL ctl_stop( 'iom_g0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_get( kiomid, idvar, pvar, itime )
             ENDIF
          ENDIF
@@ -976,6 +947,6 @@
          CALL iom_swap( TRIM(cxios_context) )
 #else
-         nstop = nstop + 1 
-         clinfo = 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
+         WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
+         CALL ctl_stop( 'iom_g0d', ctmp1 )
 #endif
       ENDIF
@@ -1122,12 +1093,4 @@
             IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
             IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
-         ENDIF
-         IF( luse_jattr ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   
-                ! Ok
-            CASE DEFAULT    
-               CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-            END SELECT
          ENDIF
 
@@ -1301,10 +1264,5 @@
             ENDIF
       
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
-               &                                         pv_r1d, pv_r2d, pv_r3d )
-            CASE DEFAULT
-               CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-            END SELECT
+            CALL iom_nf90_get( kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d )
 
             IF( istop == nstop ) THEN   ! no additional errors until this point...
@@ -1313,9 +1271,9 @@
                !--- overlap areas and extra hallows (mpp)
                IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
-                  CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
+                  CALL lbc_lnk( 'iom', pv_r2d,'Z',-999.,'no0' )
                ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
                   ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
                   IF( icnt(3) == inlev ) THEN
-                     CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+                     CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' )
                   ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
                      DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
@@ -1342,5 +1300,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r3d)
             IF(idom /= jpdom_unknown ) then
-                CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+                CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' )
             ENDIF
          ELSEIF( PRESENT(pv_r2d) ) THEN
@@ -1349,5 +1307,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r2d)
             IF(idom /= jpdom_unknown ) THEN
-                CALL lbc_lnk(pv_r2d,'Z',-999.,'no0')
+                CALL lbc_lnk('iom', pv_r2d,'Z',-999.,'no0')
             ENDIF
          ELSEIF( PRESENT(pv_r1d) ) THEN
@@ -1364,6 +1322,6 @@
 !some final adjustments
       ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain
-      IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. )
-      IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. )
+      IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( 'iom', pv_r2d,'Z',1. )
+      IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( 'iom', pv_r3d,'Z',1. )
 
       !--- Apply scale_factor and offset
@@ -1422,9 +1380,5 @@
                IF( iom_file(kiomid)%luld(idvar) ) THEN
                   IF( iom_file(kiomid)%dimsz(1,idvar) <= size(ptime) ) THEN
-                     SELECT CASE (iom_file(kiomid)%iolib)
-                     CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
-                     CASE DEFAULT
-                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-                     END SELECT
+                     CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
                   ELSE
                      WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar)
@@ -1444,136 +1398,137 @@
    END SUBROUTINE iom_gettime
 
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_chkatt
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_chkatt( kiomid, cdatt, llok, ksize, cdvar )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
+      LOGICAL         , INTENT(  out)                 ::   llok      ! Error code
+      INTEGER         , INTENT(  out), OPTIONAL       ::   ksize     ! Size of the attribute array
+      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_chkatt( kiomid, cdatt, llok, ksize=ksize, cdvar=cdvar )
+      ENDIF
+      !
+   END SUBROUTINE iom_chkatt
 
    !!----------------------------------------------------------------------
    !!                   INTERFACE iom_getatt
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_g0d_iatt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      INTEGER         , INTENT(  out)                 ::   pvar      ! read field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_g0d_iatt( kiomid, cdatt, katt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER               , INTENT(  out)           ::   katt0d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_g0d_iatt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  katt0d =  katt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_g0d_iatt
 
-   SUBROUTINE iom_g0d_ratt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      REAL(wp)        , INTENT(  out)                 ::   pvar      ! written field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_g1d_iatt( kiomid, cdatt, katt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER, DIMENSION(:) , INTENT(  out)           ::   katt1d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  katt1d =  katt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_g1d_iatt
+
+   SUBROUTINE iom_g0d_ratt( kiomid, cdatt, patt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp)              , INTENT(  out)           ::   patt0d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  patt0d =  patt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_g0d_ratt
 
-   SUBROUTINE iom_g0d_catt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      CHARACTER(len=*), INTENT(  out)                 ::   pvar      ! written field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_g1d_ratt( kiomid, cdatt, patt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp), DIMENSION(:), INTENT(  out)           ::   patt1d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  patt1d =  patt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_g1d_ratt
+   
+   SUBROUTINE iom_g0d_catt( kiomid, cdatt, cdatt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      CHARACTER(len=*)      , INTENT(  out)           ::   cdatt0d   ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_g0d_catt
+
 
    !!----------------------------------------------------------------------
    !!                   INTERFACE iom_putatt
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_p0d_iatt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      INTEGER         , INTENT(in   )                 ::   pvar      ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_p0d_iatt( kiomid, cdatt, katt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER               , INTENT(in   )           ::   katt0d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_p0d_iatt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  katt0d =  katt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_p0d_iatt
 
-   SUBROUTINE iom_p0d_ratt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      REAL(wp)        , INTENT(in   )                 ::   pvar      ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_p1d_iatt( kiomid, cdatt, katt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER, DIMENSION(:) , INTENT(in   )           ::   katt1d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  katt1d =  katt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_p1d_iatt
+
+   SUBROUTINE iom_p0d_ratt( kiomid, cdatt, patt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp)              , INTENT(in   )           ::   patt0d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  patt0d =  patt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_p0d_ratt
 
-   SUBROUTINE iom_p0d_catt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      CHARACTER(len=*), INTENT(in   )                 ::   pvar      ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_p1d_ratt( kiomid, cdatt, patt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp), DIMENSION(:), INTENT(in   )           ::   patt1d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  patt1d =  patt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_p1d_ratt
+   
+   SUBROUTINE iom_p0d_catt( kiomid, cdatt, cdatt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt0d   ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_p0d_catt
+
 
    !!----------------------------------------------------------------------
@@ -1604,9 +1559,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
             ENDIF
          ENDIF
@@ -1638,9 +1589,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp1d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
             ENDIF
          ENDIF
@@ -1672,9 +1619,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp2d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
             ENDIF
          ENDIF
@@ -1706,9 +1649,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp3d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
             ENDIF
          ENDIF
@@ -1716,4 +1655,50 @@
    END SUBROUTINE iom_rp3d
 
+
+  SUBROUTINE iom_delay_rst( cdaction, cdcpnt, kncid )
+      !!---------------------------------------------------------------------
+      !!   Routine iom_delay_rst: used read/write restart related to mpp_delay
+      !!
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   ) ::   cdaction        !
+      CHARACTER(len=*), INTENT(in   ) ::   cdcpnt
+      INTEGER         , INTENT(in   ) ::   kncid
+      !
+      INTEGER  :: ji
+      INTEGER  :: indim
+      LOGICAL  :: llattexist
+      REAL(wp), ALLOCATABLE, DIMENSION(:) ::   zreal1d
+      !!---------------------------------------------------------------------
+      !
+      !                                      ===================================
+      IF( TRIM(cdaction) == 'READ' ) THEN   ! read restart related to mpp_delay !
+         !                                   ===================================
+         DO ji = 1, nbdelay
+            IF ( c_delaycpnt(ji) == cdcpnt ) THEN
+               CALL iom_chkatt( kncid, 'DELAY_'//c_delaylist(ji), llattexist, indim )
+               IF( llattexist )  THEN
+                  ALLOCATE( todelay(ji)%z1d(indim) )
+                  CALL iom_getatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) )
+                  ndelayid(ji) = 0   ! set to 0 to specify that the value was read in the restart
+               ENDIF
+           ENDIF
+         END DO
+         !                                   ====================================
+      ELSE                                  ! write restart related to mpp_delay !
+         !                                   ====================================
+         DO ji = 1, nbdelay   ! save only ocean delayed global communication variables
+            IF ( c_delaycpnt(ji) == cdcpnt ) THEN
+               IF( ASSOCIATED(todelay(ji)%z1d) ) THEN
+                  CALL mpp_delay_rcv(ji)   ! make sure %z1d is received
+                  CALL iom_putatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) )
+               ENDIF
+            ENDIF
+         END DO
+         !
+      ENDIF
+      
+   END SUBROUTINE iom_delay_rst
+  
+   
 
    !!----------------------------------------------------------------------
@@ -1971,6 +1956,6 @@
          SELECT CASE ( cdgrd )
          CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:)
-         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. )
-         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( zmask, 'V', 1. )
+         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( 'iom', zmask, 'U', 1. )
+         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( 'iom', zmask, 'V', 1. )
          CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1)
          END SELECT
@@ -2015,5 +2000,5 @@
       !
       z_fld(:,:) = 1._wp
-      CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold
+      CALL lbc_lnk( 'iom', z_fld, cdgrd, -1. )    ! Working array for location of northfold
       !
       ! Cell vertices that can be defined
@@ -2033,6 +2018,6 @@
       ! Cell vertices on boundries
       DO jn = 1, 4
-         CALL lbc_lnk( z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp )
-         CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp )
+         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp )
+         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp )
       END DO
       !
Index: NEMO/trunk/src/OCE/IOM/iom_def.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 10361)
+++ NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 10425)
@@ -23,8 +23,4 @@
    INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo_xy    = 9   !: Automatically set horizontal dimensions only
    INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 10  !: 
-
-   INTEGER, PARAMETER, PUBLIC ::   jpnf90      = 101      !: Use nf90 library
-
-   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jpnf90     !: restarts io library
 
    INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
@@ -55,5 +51,4 @@
       CHARACTER(LEN=240)                        ::   name     !: name of the file
       INTEGER                                   ::   nfid     !: identifier of the file (0 if closed)
-      INTEGER                                   ::   iolib    !: library used to read the file (jpnf90 or new formats,
                                                               !: jpioipsl option has been removed)
       INTEGER                                   ::   nvars    !: number of identified varibles in the file
Index: NEMO/trunk/src/OCE/IOM/iom_nf90.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 10361)
+++ NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 10425)
@@ -30,14 +30,8 @@
 
    PUBLIC iom_nf90_open  , iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput
-   PUBLIC iom_nf90_getatt, iom_nf90_putatt
+   PUBLIC iom_nf90_chkatt, iom_nf90_getatt, iom_nf90_putatt
 
    INTERFACE iom_nf90_get
       MODULE PROCEDURE iom_nf90_g0d, iom_nf90_g123d
-   END INTERFACE
-   INTERFACE iom_nf90_getatt
-      MODULE PROCEDURE iom_nf90_giatt, iom_nf90_gratt, iom_nf90_gcatt
-   END INTERFACE
-   INTERFACE iom_nf90_putatt
-      MODULE PROCEDURE iom_nf90_piatt, iom_nf90_pratt, iom_nf90_pcatt
    END INTERFACE
    INTERFACE iom_nf90_rstput
@@ -129,14 +123,12 @@
                CALL iom_nf90_check(NF90_CREATE( TRIM(cdname), imode, if90id, chunksize = ichunk ), clinfo)
             ENDIF
-            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                     ), clinfo)
+            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL,                   idmy ), clinfo)
             ! define dimensions
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x'      , kdompar(1,1)  , idmy ), clinfo)
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y'      , kdompar(2,1)  , idmy ), clinfo)
-            IF( PRESENT(kdlev) ) THEN
-               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'numcat' , ilevels    , idmy ), clinfo)
-            ELSE
-               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev', ilevels    , idmy ), clinfo)
-            ENDIF
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',   kdompar(1,1), idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',   kdompar(2,1), idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',            jpk, idmy ), clinfo)
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
+            IF( PRESENT(kdlev) )   &
+               CALL iom_nf90_check(NF90_DEF_DIM( if90id,    'numcat',          kdlev, idmy ), clinfo)
             ! global attributes
             CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
@@ -165,5 +157,4 @@
          iom_file(kiomid)%name   = TRIM(cdname)
          iom_file(kiomid)%nfid   = if90id
-         iom_file(kiomid)%iolib  = jpnf90
          iom_file(kiomid)%nvars  = 0
          iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
@@ -329,13 +320,10 @@
    END SUBROUTINE iom_nf90_g123d
 
-   !!----------------------------------------------------------------------
-   !!                   INTERFACE iom_nf90_getatt
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE iom_nf90_giatt( kiomid, cdatt, pv_i0d, cdvar)
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_giatt  ***
-      !!
-      !! ** Purpose : read an integer attribute with NF90
+
+   SUBROUTINE iom_nf90_chkatt( kiomid, cdatt, llok, ksize, cdvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_chkatt  ***
+      !!
+      !! ** Purpose : check existence of attribute with NF90
       !!              (either a global attribute (default) or a variable
       !!               attribute if optional variable name is supplied (cdvar))
@@ -343,7 +331,54 @@
       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file
       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name
-      INTEGER         , INTENT(  out) ::   pv_i0d   ! read field
+      LOGICAL         , INTENT(  out) ::   llok     ! error code
+      INTEGER         , INTENT(  out), OPTIONAL     &
+                      &               ::   ksize    ! attribute size
       CHARACTER(len=*), INTENT(in   ), OPTIONAL     &
                       &               ::   cdvar    ! name of the variable
+      !
+      INTEGER                         ::   if90id   ! temporary integer
+      INTEGER                         ::   isize    ! temporary integer
+      INTEGER                         ::   ivarid   ! NetCDF variable Id
+      !---------------------------------------------------------------------
+      !
+      if90id = iom_file(kiomid)%nfid
+      IF( PRESENT(cdvar) ) THEN
+         ! check the variable exists in the file
+         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
+         IF( llok ) &
+            ! check the variable has the attribute required
+            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt, len=isize ) == nf90_noerr
+      ELSE
+         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt, len=isize ) == nf90_noerr
+      ENDIF
+      !
+      IF( PRESENT(ksize) ) ksize = isize
+      !
+      IF( .not. llok) &
+         CALL ctl_warn('iom_nf90_chkatt: no attribute '//cdatt//' found')
+      !
+   END SUBROUTINE iom_nf90_chkatt
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_nf90_getatt
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE iom_nf90_getatt( kiomid, cdatt, katt0d, katt1d, patt0d, patt1d, cdatt0d, cdvar)
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_getatt  ***
+      !!
+      !! ** Purpose : read an attribute with NF90
+      !!              (either a global attribute (default) or a variable
+      !!               attribute if optional variable name is supplied (cdvar))
+      !!-----------------------------------------------------------------------
+      INTEGER               , INTENT(in   )           ::   kiomid   ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt    ! attribute name
+      INTEGER               , INTENT(  out), OPTIONAL ::   katt0d   ! read scalar integer
+      INTEGER, DIMENSION(:) , INTENT(  out), OPTIONAL ::   katt1d   ! read 1d array integer
+      REAL(wp)              , INTENT(  out), OPTIONAL ::   patt0d   ! read scalar  real
+      REAL(wp), DIMENSION(:), INTENT(  out), OPTIONAL ::   patt1d   ! read 1d array real
+      CHARACTER(len=*)      , INTENT(  out), OPTIONAL ::   cdatt0d  ! read character
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar    ! name of the variable
       !
       INTEGER                         ::   if90id   ! temporary integer
@@ -361,5 +396,5 @@
             llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr
          ELSE
-            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found')
+            CALL ctl_warn('iom_nf90_getatt: no variable '//TRIM(cdvar)//' found')
          ENDIF
       ELSE
@@ -369,272 +404,91 @@
       !
       IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', giatt: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo)
+         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
+         IF(PRESENT( katt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  katt0d), clinfo)
+         IF(PRESENT( katt1d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  katt1d), clinfo)
+         IF(PRESENT( patt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  patt0d), clinfo)
+         IF(PRESENT( patt1d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  patt1d), clinfo)
+         IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values = cdatt0d), clinfo)
       ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pv_i0d = -999
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_giatt
-
-
-   SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_gratt  ***
-      !!
-      !! ** Purpose : read a real attribute with NF90
+         CALL ctl_warn('iom_nf90_getatt: no attribute '//TRIM(cdatt)//' found')
+         IF(PRESENT( katt0d))    katt0d    = -999
+         IF(PRESENT( katt1d))    katt1d(:) = -999
+         IF(PRESENT( patt0d))    patt0d    = -999._wp
+         IF(PRESENT( patt1d))    patt1d(:) = -999._wp
+         IF(PRESENT(cdatt0d))   cdatt0d    = '!'
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_getatt
+
+
+   SUBROUTINE iom_nf90_putatt( kiomid, cdatt, katt0d, katt1d, patt0d, patt1d, cdatt0d, cdvar)
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_putatt  ***
+      !!
+      !! ** Purpose : write an attribute with NF90
       !!              (either a global attribute (default) or a variable
       !!               attribute if optional variable name is supplied (cdvar))
       !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      REAL(wp)                  , INTENT(  out) ::   pv_r0d   ! read field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
+      INTEGER               , INTENT(in   )           ::   kiomid   ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt    ! attribute name
+      INTEGER               , INTENT(in   ), OPTIONAL ::   katt0d   ! read scalar integer
+      INTEGER, DIMENSION(:) , INTENT(in   ), OPTIONAL ::   katt1d   ! read 1d array integer
+      REAL(wp)              , INTENT(in   ), OPTIONAL ::   patt0d   ! read scalar  real
+      REAL(wp), DIMENSION(:), INTENT(in   ), OPTIONAL ::   patt1d   ! read 1d array real
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdatt0d  ! read character
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar    ! name of the variable
+      !
+      INTEGER                         ::   if90id   ! temporary integer
+      INTEGER                         ::   ivarid   ! NetCDF variable Id
+      INTEGER                         ::   isize    ! Attribute size
+      INTEGER                         ::   itype    ! Attribute type
+      LOGICAL                         ::   llok     ! temporary logical
+      LOGICAL                         ::   llatt     ! temporary logical
+      LOGICAL                         ::   lldata   ! temporary logical
+      CHARACTER(LEN=100)              ::   clinfo   ! info character
       !---------------------------------------------------------------------
       !
       if90id = iom_file(kiomid)%nfid
       IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( llok ) THEN
-            ! check the variable has the attribute required
-            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr
-         ELSE
-            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found')
+         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! is the variable in the file?
+         IF( .NOT. llok ) THEN
+            CALL ctl_warn('iom_nf90_putatt: no variable '//TRIM(cdvar)//' found'   &
+               &        , '                 no attribute '//cdatt//' written' )
+            RETURN
          ENDIF
       ELSE
-         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr
          ivarid = NF90_GLOBAL
       ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gratt: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo)
-      ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pv_r0d = -999._wp
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_gratt
-
-
-   SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_gcatt  ***
-      !!
-      !! ** Purpose : read a character attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      CHARACTER(len=*)          , INTENT(  out) ::   pv_c0d   ! read field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( llok ) THEN
-            ! check the variable has the attribute required
-            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr
-         ELSE
-            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr
-         ivarid = NF90_GLOBAL
-      ENDIF
-!
-      IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gcatt: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo)
-      ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pv_c0d = '!'
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_gcatt
-
-
-   !!----------------------------------------------------------------------
-   !!                   INTERFACE iom_nf90_putatt
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE iom_nf90_piatt( kiomid, cdatt, pv_i0d, cdvar)
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_piatt  ***
-      !!
-      !! ** Purpose : write an integer attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name
-      INTEGER         , INTENT(in   ) ::   pv_i0d   ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL     &
-                      &               ::   cdvar    ! name of the variable
-      !
-      INTEGER                         ::   if90id   ! temporary integer
-      INTEGER                         ::   ivarid   ! NetCDF variable Id
-      LOGICAL                         ::   llok     ! temporary logical
-      LOGICAL                         ::   lenddef  ! temporary logical
-      CHARACTER(LEN=100)              ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      lenddef = .false.
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( .NOT. llok ) THEN
-            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = .true.
-         ivarid = NF90_GLOBAL
-      ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', piatt: '//TRIM(cdatt)
-         IF( iom_file(kiomid)%irec /= -1 ) THEN   
-            ! trick: irec used to know if the file is in define mode or not
-            ! if it is not then temporarily put it into define mode
-            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)
-            lenddef = .true.
-         ENDIF
+      llatt = NF90_Inquire_attribute(if90id, ivarid, cdatt, len = isize, xtype = itype ) == nf90_noerr
+      !
+      ! trick: irec used to know if the file is in define mode or not
+      lldata = iom_file(kiomid)%irec /= -1   ! default: go back in define mode if in data mode
+      IF( lldata .AND. llatt ) THEN          ! attribute already there. Do we really need to go back in define mode?
+         ! do we have the appropriate type?
+         IF(PRESENT( katt0d) .OR. PRESENT( katt1d))   llok = itype == NF90_INT
+         IF(PRESENT( patt0d) .OR. PRESENT( patt1d))   llok = itype == NF90_DOUBLE
+         IF(PRESENT(cdatt0d)                      )   llok = itype == NF90_CHAR
+         ! and do we have the appropriate size?
+         IF(PRESENT( katt0d))   llok = llok .AND. isize == 1
+         IF(PRESENT( katt1d))   llok = llok .AND. isize == SIZE(katt1d)
+         IF(PRESENT( patt0d))   llok = llok .AND. isize == 1
+         IF(PRESENT( patt1d))   llok = llok .AND. isize == SIZE(patt1d)
+         IF(PRESENT(cdatt0d))   llok = llok .AND. isize == LEN_TRIM(cdatt0d)
          !
-         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo)
-         !
-         IF( lenddef ) THEN   
-            ! file was in data mode on entry; put it back in that mode
-            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)
-         ENDIF
-      ELSE
-         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written')
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_piatt
-
-
-   SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_pratt  ***
-      !!
-      !! ** Purpose : write a real attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      REAL(wp)                  , INTENT(in   ) ::   pv_r0d   ! write field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      LOGICAL            ::   lenddef  ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      lenddef = .false.
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( .NOT. llok ) THEN
-            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = .true.
-         ivarid = NF90_GLOBAL
-      ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pratt: '//TRIM(cdatt)
-         IF( iom_file(kiomid)%irec /= -1 ) THEN   
-            ! trick: irec used to know if the file is in define mode or not
-            ! if it is not then temporarily put it into define mode
-            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)
-            lenddef = .true.
-         ENDIF
-         !
-         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo)
-         !
-         IF( lenddef ) THEN   
-            ! file was in data mode on entry; put it back in that mode
-            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)
-         ENDIF
-      ELSE
-         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written')
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_pratt
-
-
-   SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_pcatt  ***
-      !!
-      !! ** Purpose : write a character attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      CHARACTER(len=*)          , INTENT(in   ) ::   pv_c0d   ! write field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      LOGICAL            ::   lenddef  ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      lenddef = .false.
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( .NOT. llok ) THEN
-            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = .true.
-         ivarid = NF90_GLOBAL
-      ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pcatt: '//TRIM(cdatt)
-         IF( iom_file(kiomid)%irec /= -1 ) THEN   
-            ! trick: irec used to know if the file is in define mode or not
-            ! if it is not then temporarily put it into define mode
-            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)
-            lenddef = .true.
-         ENDIF
-         !
-         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo)
-         !
-         IF( lenddef ) THEN   
-            ! file was in data mode on entry; put it back in that mode
-            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)
-         ENDIF
-      ELSE
-         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written')
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_pcatt
+         lldata = .NOT. llok
+      ENDIF
+      !
+      clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
+      IF(lldata)   CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ! leave data mode to define mode
+      !
+      IF(PRESENT( katt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       katt0d) , clinfo)
+      IF(PRESENT( katt1d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       katt1d) , clinfo)
+      IF(PRESENT( patt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       patt0d) , clinfo)
+      IF(PRESENT( patt1d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       patt1d) , clinfo)
+      IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values = trim(cdatt0d)), clinfo)
+      !
+      IF(lldata)   CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)   ! leave define mode to data mode
+      !
+   END SUBROUTINE iom_nf90_putatt
 
 
@@ -693,5 +547,5 @@
       INTEGER, DIMENSION(4) :: idimid               ! dimensions id
       CHARACTER(LEN=256)    :: clinfo               ! info character
-      CHARACTER(LEN= 12), DIMENSION(4) :: cltmp     ! temporary character
+      CHARACTER(LEN= 12), DIMENSION(5) :: cltmp     ! temporary character
       INTEGER               :: if90id               ! nf90 file identifier
       INTEGER               :: idmy                 ! dummy variable
@@ -704,4 +558,5 @@
       !                                             ! when appropriate (currently chunking is applied to 4d fields only)
       INTEGER               :: idlv                 ! local variable
+      INTEGER               :: idim3                ! id of the third dimension
       !---------------------------------------------------------------------
       !
@@ -717,9 +572,5 @@
          ENDIF
          ! define the dimension variables if it is not already done
-         IF(iom_file(kiomid)%nlev == jpk ) THEN
-          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /)
-         ELSE
-          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'numcat      ', 'time_counter' /)
-         ENDIF
+         cltmp = (/ 'nav_lon', 'nav_lat', 'nav_lev', 'time_counter', 'numcat' /)
          CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo)
          CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo)
@@ -729,6 +580,13 @@
          iom_file(kiomid)%nvars       = 4
          iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
-         iom_file(kiomid)%cn_var(1:4) = cltmp
-         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)  
+         iom_file(kiomid)%cn_var(1:4) = cltmp(1:4)
+         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)
+         IF( NF90_INQ_DIMID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN   ! add a 5th variable corresponding to the 5th dimension
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(5)), NF90_FLOAT , (/ 5 /), iom_file(kiomid)%nvid(5) ), clinfo)
+            iom_file(kiomid)%nvars     = 5
+            iom_file(kiomid)%luld(5)   = .FALSE.
+            iom_file(kiomid)%cn_var(5) = cltmp(5)
+            iom_file(kiomid)%ndims(5)  = 1
+         ENDIF
          ! trick: defined to 0 to say that dimension variables are defined but not yet written
          iom_file(kiomid)%dimsz(1, 1)  = 0   
@@ -752,15 +610,23 @@
          ! variable definition
          IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
-         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/)
+         ELSEIF( PRESENT(pv_r1d) ) THEN
+            IF( SIZE(pv_r1d,1) == jpk ) THEN   ;   idim3 = 3
+            ELSE                               ;   idim3 = 5
+            ENDIF
+                                              idims = 2   ;   idimid(1:idims) = (/idim3,4/)
          ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
-         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
+         ELSEIF( PRESENT(pv_r3d) ) THEN
+            IF( SIZE(pv_r3d,3) == jpk ) THEN   ;   idim3 = 3
+            ELSE                               ;   idim3 = 5
+            ENDIF
+                                              idims = 4   ;   idimid(1:idims) = (/1,2,idim3,4/)
          ENDIF
          IF( PRESENT(ktype) ) THEN   ! variable external type
             SELECT CASE (ktype)
-            CASE (jp_r8)  ;   itype = NF90_DOUBLE
-            CASE (jp_r4)  ;   itype = NF90_FLOAT
-            CASE (jp_i4)  ;   itype = NF90_INT
-            CASE (jp_i2)  ;   itype = NF90_SHORT
-            CASE (jp_i1)  ;   itype = NF90_BYTE
+            CASE (jp_r8)   ;   itype = NF90_DOUBLE
+            CASE (jp_r4)   ;   itype = NF90_FLOAT
+            CASE (jp_i4)   ;   itype = NF90_INT
+            CASE (jp_i2)   ;   itype = NF90_SHORT
+            CASE (jp_i1)   ;   itype = NF90_BYTE
             CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
             END SELECT
@@ -834,10 +700,7 @@
                CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lat'     , idmy )         , clinfo )
                CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo )
-               IF(iom_file(kiomid)%nlev == jpk ) THEN 
-                  !NEMO
-                  CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo )
-                  CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo )
-               ELSE
-                  CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'numcat'     , idmy ), clinfo)
+               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo )
+               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo )
+               IF( NF90_INQ_VARID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN
                   CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, (/ (idlv, idlv = 1,iom_file(kiomid)%nlev) /)), clinfo )
                ENDIF
Index: NEMO/trunk/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/restart.F90	(revision 10361)
+++ NEMO/trunk/src/OCE/IOM/restart.F90	(revision 10425)
@@ -28,4 +28,5 @@
    USE iom             ! I/O module
    USE diurnal_bulk
+   USE lib_mpp         ! distribued memory computing library
 
    IMPLICIT NONE
@@ -97,8 +98,5 @@
                WRITE(numout,*)
                IF(.NOT.lwxios) THEN
-                  SELECT CASE ( jprstlib )
-                  CASE DEFAULT         ;   WRITE(numout,*)                            &
-                      '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
-                  END SELECT
+                  WRITE(numout,*) '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
                   IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
                   IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
@@ -109,5 +107,5 @@
             !
             IF(.NOT.lwxios) THEN
-               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. )
             ELSE
 #if defined key_iomput
@@ -137,5 +135,5 @@
       !!                   ***  ROUTINE rstwrite  ***
       !!                     
-      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
+      !! ** Purpose :   Write restart fields in NetCDF format
       !!
       !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
@@ -146,4 +144,5 @@
                      IF(lwxios) CALL iom_swap(      cwxios_context          )
                      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step
+                     CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
 
       IF ( .NOT. ln_diurnal_only ) THEN
@@ -197,10 +196,9 @@
       !!                   ***  ROUTINE rst_read_open  ***
       !! 
-      !! ** Purpose :   Open read files for restart (format fixed by jprstlib )
+      !! ** Purpose :   Open read files for NetCDF restart
       !! 
       !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not
       !!                the file has already been opened
       !!----------------------------------------------------------------------
-      INTEGER        ::   jlibalt = jprstlib
       LOGICAL        ::   llok
       CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file
@@ -210,7 +208,5 @@
          IF(lwp) THEN                                             ! Contol prints
             WRITE(numout,*)
-            SELECT CASE ( jprstlib )
-            CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
-            END SELECT
+            WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
             IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
             WRITE(numout,*) '~~~~~~~~'
@@ -219,5 +215,5 @@
          clpath = TRIM(cn_ocerst_indir)
          IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
+         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror )
 ! are we using XIOS to read the data? Part above will have to modified once XIOS
 ! can handle checking if variable is in the restart file (there will be no need to open
@@ -246,5 +242,5 @@
       !!                   ***  ROUTINE rst_read  ***
       !! 
-      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
+      !! ** Purpose :   Read files for NetCDF restart
       !! 
       !! ** Method  :   Read in restart.nc file fields which are necessary for restart
@@ -263,4 +259,6 @@
       ENDIF
 
+      CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
+      
       ! Diurnal DSST 
       IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios ) 
