Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 7349)
+++ branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 7351)
@@ -13,5 +13,4 @@
    !!----------------------------------------------------------------------
    USE par_oce       ! ocean parameter
-   USE lib_print     ! formated print library
    USE nc4interface  ! NetCDF4 interface
 
@@ -37,4 +36,5 @@
    INTEGER       ::   nn_itend         !: index of the last time step
    INTEGER       ::   nn_date0         !: initial calendar date aammjj
+   INTEGER       ::   nn_time0         !: initial time of day in hhmm
    INTEGER       ::   nn_leapy         !: Leap year calendar flag (0/1 or 30)
    INTEGER       ::   nn_istate        !: initial state output flag (0/1)
@@ -42,6 +42,4 @@
    INTEGER       ::   nn_stock         !: restart file frequency
    INTEGER, DIMENSION(10) :: nn_stocklist  !: restart dump times
-   LOGICAL       ::   ln_dimgnnn       !: type of dimgout. (F): 1 file for all proc
-                                                       !:                  (T): 1 file per proc
    LOGICAL       ::   ln_mskland       !: mask land points in NetCDF outputs (costly: + ~15%)
    LOGICAL       ::   ln_cfmeta        !: output additional data to netCDF files required for compliance with the CF metadata standard
@@ -99,4 +97,5 @@
    LOGICAL ::   ln_ctl       !: run control for debugging
    INTEGER ::   nn_timing    !: run control for timing
+   INTEGER ::   nn_diacfl    !: flag whether to create CFL diagnostics
    INTEGER ::   nn_print     !: level of print (0 no print)
    INTEGER ::   nn_ictls     !: Start i indice for the SUM control
Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7349)
+++ branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7351)
@@ -8,4 +8,5 @@
    !!            3.0  ! 2007-07  (D. Storkey) Changes to iom_gettime
    !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add C1D case  
+   !!            3.6  ! 2014-15  DIMG format removed
    !!--------------------------------------------------------------------
 
@@ -23,7 +24,5 @@
    USE lbclnk          ! lateal boundary condition / mpp exchanges
    USE iom_def         ! iom variables definitions
-   USE iom_ioipsl      ! NetCDF format with IOIPSL library
    USE iom_nf90        ! NetCDF format with native NetCDF library
-   USE iom_rstdimg     ! restarts access direct format "dimg" style...
    USE in_out_manager  ! I/O manager
    USE lib_mpp           ! MPP library
@@ -115,5 +114,5 @@
       CASE (30)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "D360")
       END SELECT
-      WRITE(cldate,"(i4.4,'-',i2.2,'-',i2.2,' 00:00:00')") nyear,nmonth,nday 
+      WRITE(cldate,"(i4.4,'-',i2.2,'-',i2.2,' ',i2.2,':',i2.2,':00')") nyear,nmonth,nday,nhour,nminute
       CALL xios_set_context_attr(TRIM(clname), start_date=cldate )
 
@@ -246,5 +245,5 @@
       CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
       CHARACTER(LEN=256)    ::   cltmpn    ! tempory name to store clname (in writting mode)
-      CHARACTER(LEN=10)     ::   clsuffix  ! ".nc" or ".dimg"
+      CHARACTER(LEN=10)     ::   clsuffix  ! ".nc" 
       CHARACTER(LEN=15)     ::   clcpu     ! the cpu number (max jpmax_digits digits)
       CHARACTER(LEN=256)    ::   clinfo    ! info character
@@ -309,9 +308,7 @@
       ! which suffix should we use?
       SELECT CASE (iolib)
-      CASE (jpioipsl ) ;   clsuffix = '.nc'
       CASE (jpnf90   ) ;   clsuffix = '.nc'
-      CASE (jprstdimg) ;   clsuffix = '.dimg'
       CASE DEFAULT     ;   clsuffix = ''
-         CALL ctl_stop( TRIM(clinfo), 'accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         CALL ctl_stop( TRIM(clinfo), 'accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
       END SELECT
       ! Add the suffix if needed
@@ -326,7 +323,6 @@
       IF( .NOT.llok ) THEN
          ! we try to add the cpu number to the name
-         IF( iolib == jprstdimg ) THEN   ;   WRITE(clcpu,*) narea
-         ELSE                            ;   WRITE(clcpu,*) narea-1
-         ENDIF
+         WRITE(clcpu,*) narea-1
+
          clcpu  = TRIM(ADJUSTL(clcpu))
          iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.)
@@ -375,5 +371,5 @@
          END SELECT
       ENDIF
-      ! Open the NetCDF or RSTDIMG file
+      ! Open the NetCDF file
       ! =============
       ! do we have some free file identifier?
@@ -399,9 +395,7 @@
       IF( istop == nstop ) THEN   ! no error within this routine
          SELECT CASE (iolib)
-         CASE (jpioipsl )   ;   CALL iom_ioipsl_open(  clname, kiomid, llwrt, llok, idompar )
          CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar )
-         CASE (jprstdimg)   ;   CALL iom_rstdimg_open( clname, kiomid, llwrt, llok, idompar )
          CASE DEFAULT
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
          END SELECT
       ENDIF
@@ -438,9 +432,7 @@
             IF( iom_file(jf)%nfid > 0 ) THEN
                SELECT CASE (iom_file(jf)%iolib)
-               CASE (jpioipsl )   ;   CALL iom_ioipsl_close(  jf )
                CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
-               CASE (jprstdimg)   ;   CALL iom_rstdimg_close( jf )
                CASE DEFAULT
-                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
                END SELECT
                iom_file(jf)%nfid       = 0          ! free the id 
@@ -497,9 +489,7 @@
                IF( iiv <= jpmax_vars ) THEN
                   SELECT CASE (iom_file(kiomid)%iolib)
-                  CASE (jpioipsl )   ;   iom_varid = iom_ioipsl_varid( kiomid, cdvar, iiv, kdimsz )
                   CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz, kndims )
-                  CASE (jprstdimg)   ;   iom_varid = -1   ! all variables are listed in iom_file
-                  CASE DEFAULT   
-                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                  CASE DEFAULT
+                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
                   END SELECT
                ELSE
@@ -559,9 +549,7 @@
                                  &                         'Use ncwa -a to suppress the unnecessary dimensions' )
             SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, pvar, itime )
             CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime )
-            CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idvar, pvar )
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_g0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
             END SELECT
          ENDIF
@@ -673,4 +661,5 @@
       CHARACTER(LEN=256)             ::   clname      ! file name
       CHARACTER(LEN=1)               ::   clrankpv, cldmspc      ! 
+      LOGICAL                        ::   ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension.
       !---------------------------------------------------------------------
       !
@@ -685,5 +674,6 @@
       IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
       IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
-      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown   ) CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown')
+      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND.  idom /= jpdom_autoglo_xy  ) &
+     &           CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown or kdom = jpdom_autoglo_xy')
 
       luse_jattr = .false.
@@ -694,11 +684,8 @@
       IF( luse_jattr ) THEN
          SELECT CASE (iom_file(kiomid)%iolib)
-         CASE (jpioipsl, jprstdimg )
-             CALL ctl_warn(trim(clinfo), 'lrowattr present and true but this only works with netcdf (jpnf90)')
-             luse_jattr = .false.
          CASE (jpnf90   )   
              ! Ok
          CASE DEFAULT    
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
          END SELECT
       ENDIF
@@ -718,4 +705,10 @@
          ! update idom definition...
          ! Identify the domain in case of jpdom_auto(glo/dta) definition
+         IF( idom == jpdom_autoglo_xy ) THEN
+            ll_depth_spec = .TRUE.
+            idom = jpdom_autoglo
+         ELSE
+            ll_depth_spec = .FALSE.
+         ENDIF
          IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
             IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
@@ -771,7 +764,7 @@
          istart(idmspc+1) = itime
 
-         IF(              PRESENT(kstart)       ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
+         IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
          ELSE
-            IF(           idom == jpdom_unknown ) THEN                                       ; icnt(1:idmspc) = idimsz(1:idmspc)
+            IF(           idom == jpdom_unknown ) THEN                                                ; icnt(1:idmspc) = idimsz(1:idmspc)
             ELSE 
                IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
@@ -796,6 +789,7 @@
                   ENDIF
                   IF( PRESENT(pv_r3d) ) THEN
-                     IF( idom == jpdom_data ) THEN   ; icnt(3) = jpkdta
-                     ELSE                            ; icnt(3) = jpk
+                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkdta
+                     ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3)
+                     ELSE                                                           ; icnt(3) = jpk
                      ENDIF
                   ENDIF
@@ -866,12 +860,8 @@
       
          SELECT CASE (iom_file(kiomid)%iolib)
-         CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
-            &                                         pv_r1d, pv_r2d, pv_r3d )
          CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
             &                                         pv_r1d, pv_r2d, pv_r3d )
-         CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   &
-            &                                         pv_r1d, pv_r2d, pv_r3d )
-         CASE DEFAULT    
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
          END SELECT
 
@@ -956,9 +946,7 @@
                   IF( iom_file(kiomid)%dimsz(1,idvar) <= size(ptime) ) THEN
                      SELECT CASE (iom_file(kiomid)%iolib)
-                     CASE (jpioipsl )   ;   CALL iom_ioipsl_gettime( kiomid, idvar, ptime, cdunits, cdcalendar )
                      CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
-                     CASE (jprstdimg)   ;   CALL ctl_stop( TRIM(clinfo)//' case IO library == jprstdimg not coded...' )
-                     CASE DEFAULT    
-                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                     CASE DEFAULT
+                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
                      END SELECT
                   ELSE
@@ -991,9 +979,7 @@
          IF( iom_file(kiomid)%nfid > 0 ) THEN
             SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL ctl_stop('iom_getatt: only nf90 available')
             CASE (jpnf90   )   ;   CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-            CASE (jprstdimg)   ;   CALL ctl_stop('iom_getatt: only nf90 available')
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_g0d_att: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_g0d_att: accepted IO library is only jpnf90' )
             END SELECT
          ENDIF
@@ -1017,9 +1003,7 @@
             ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
             SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
             CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar )
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
             END SELECT
          ENDIF
@@ -1039,9 +1023,7 @@
             ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
             SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
             CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar )
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp1d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
             END SELECT
          ENDIF
@@ -1061,9 +1043,7 @@
             ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
             SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
             CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) 
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp2d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
             END SELECT
          ENDIF
@@ -1083,9 +1063,7 @@
             ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
             SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
             CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar )
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp3d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
             END SELECT
          ENDIF
@@ -1645,5 +1623,5 @@
             idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@')
             DO WHILE ( idx /= 0 ) 
-               cldate = iom_sdate( fjulday - rdttra(1) / rday )
+               cldate = iom_sdate( fjulday - rdt / rday )
                clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+11:LEN_TRIM(clname))
                idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@')
@@ -1652,5 +1630,5 @@
             idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@')
             DO WHILE ( idx /= 0 ) 
-               cldate = iom_sdate( fjulday - rdttra(1) / rday, ldfull = .TRUE. )
+               cldate = iom_sdate( fjulday - rdt / rday, ldfull = .TRUE. )
                clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+15:LEN_TRIM(clname))
                idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@')
@@ -1659,5 +1637,5 @@
             idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@')
             DO WHILE ( idx /= 0 ) 
-               cldate = iom_sdate( fjulday + rdttra(1) / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE. )
+               cldate = iom_sdate( fjulday + rdt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE. )
                clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+9:LEN_TRIM(clname))
                idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@')
@@ -1666,5 +1644,5 @@
             idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@')
             DO WHILE ( idx /= 0 ) 
-               cldate = iom_sdate( fjulday + rdttra(1) / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE., ldfull = .TRUE. )
+               cldate = iom_sdate( fjulday + rdt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE., ldfull = .TRUE. )
                clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+13:LEN_TRIM(clname))
                idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@')
Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 7349)
+++ branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 7351)
@@ -9,5 +9,5 @@
    !!---------------------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
+   !! $Id$
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!---------------------------------------------------------------------------------
@@ -26,14 +26,10 @@
    INTEGER, PARAMETER, PUBLIC ::   jpdom_unknown       = 7   !: No dimension checking
    INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo       = 8   !: 
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 9   !: 
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo_xy    = 9   !: Automatically set horizontal dimensions only
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 10  !: 
 
-   INTEGER, PARAMETER, PUBLIC ::   jpioipsl    = 100      !: Use ioipsl (fliocom only) library
    INTEGER, PARAMETER, PUBLIC ::   jpnf90      = 101      !: Use nf90 library
-   INTEGER, PARAMETER, PUBLIC ::   jprstdimg   = 102      !: Use restart dimgs (fortran direct acces) library
-#if defined key_dimgout
-   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jprstdimg  !: restarts io library
-#else
+
    INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jpnf90     !: restarts io library
-#endif
 
    INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
@@ -54,7 +50,9 @@
       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 (jpioipsl, jpnf90 or jprstdimg)
+      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
       INTEGER                                   ::   iduld    !: id of the unlimited dimension
+      INTEGER                                   ::   lenuld   !: length of the unlimited dimension (number of records in file)
       INTEGER                                   ::   irec     !: writing record position  
       CHARACTER(LEN=32)                         ::   uldname  !: name of the unlimited dimension
Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_ioipsl.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_ioipsl.F90	(revision 7349)
+++ 	(revision )
@@ -1,439 +1,0 @@
-MODULE iom_ioipsl
-   !!=====================================================================
-   !!                    ***  MODULE  iom_ioipsl ***
-   !! Input/Output manager :  Library to read input files with IOIPSL (only fliocom module)
-   !!====================================================================
-   !! History :  9.0  ! 05 12  (J. Belier) Original code
-   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
-   !!             "   ! 07 07  (D. Storkey) Changes to iom_ioipsl_gettime
-   !!--------------------------------------------------------------------
-   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
-
-   !!--------------------------------------------------------------------
-   !!   iom_open       : open a file read only
-   !!   iom_close      : close a file or all files opened by iom
-   !!   iom_get        : read a field (interfaced to several routines)
-   !!   iom_gettime    : read the time axis kvid in the file
-   !!   iom_varid      : get the id of a variable in a file
-   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
-   !!--------------------------------------------------------------------
-   USE dom_oce         ! ocean space and time domain
-   USE iom_def         ! iom variables definitions
-   USE ioipsl          ! IOIPSL library
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! MPP library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC iom_ioipsl_open, iom_ioipsl_close, iom_ioipsl_varid, iom_ioipsl_get, iom_ioipsl_gettime, iom_ioipsl_rstput
-
-   INTERFACE iom_ioipsl_get
-      MODULE PROCEDURE iom_ioipsl_g0d, iom_ioipsl_g123d
-   END INTERFACE
-   INTERFACE iom_ioipsl_rstput
-      MODULE PROCEDURE iom_ioipsl_rp0123d
-   END INTERFACE
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-CONTAINS
-
-   SUBROUTINE iom_ioipsl_open( cdname, kiomid, ldwrt, ldok, kdompar )
-      !!---------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_open  ***
-      !!
-      !! ** Purpose :  open an input file with IOIPSL (only fliocom module)
-      !!---------------------------------------------------------------------
-      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
-      INTEGER                , INTENT(  out)           ::   kiomid      ! ioipsl identifier of the opened file
-      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
-      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
-      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
-
-      CHARACTER(LEN=100) ::   clinfo      ! info character
-      CHARACTER(LEN=10 ) ::   clstatus    ! status of opened file (REPLACE or NEW)
-      INTEGER            ::   iln         ! lengths of character
-      INTEGER            ::   istop       ! temporary storage of nstop
-      INTEGER            ::   ifliodom    ! model domain identifier (see flio_dom_set)
-      INTEGER            ::   ioipslid    ! ioipsl identifier of the opened file
-      INTEGER            ::   jl          ! loop variable
-      LOGICAL            ::   llclobber   ! local definition of ln_clobber
-      !---------------------------------------------------------------------
-
-      clinfo = '                    iom_ioipsl_open ~~~  '
-      istop = nstop
-      !
-      llclobber = ldwrt .AND. ln_clobber
-      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
-         !                 ! =============
-         IF( ldwrt ) THEN  ! ... in write mode
-            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in WRITE mode'
-            CALL flioopfd( TRIM(cdname), ioipslid, "WRITE" )
-         ELSE              ! ... in read mode
-            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
-            CALL flioopfd( TRIM(cdname), ioipslid )
-         ENDIF
-      ELSE                 ! the file does not exist
-         !                 ! =============
-         iln = INDEX( cdname, '.nc' )
-         IF( ldwrt ) THEN  ! the file should be open in write mode so we create it...
-            IF( llclobber ) THEN   ;   clstatus = 'REPLACE 64' 
-            ELSE                   ;   clstatus = 'NEW 64'
-            ENDIF
-            IF( jpnij > 1 ) THEN
-               ! define the domain position regarding to the global domain (mainly useful in mpp)
-               CALL flio_dom_set( jpnij, narea-1, (/1, 2/), (/jpiglo, jpjglo/)   &
-                  &             , kdompar(:,1), kdompar(:,2), kdompar(:,3), kdompar(:,4), kdompar(:,5)   &
-                  &             , 'BOX', ifliodom )        
-               ! Note that fliocrfd may change the value of cdname (add the cpu number...)
-               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//cdname(1:iln-1)//'... in WRITE mode'
-               CALL fliocrfd( cdname, (/'x'         , 'y'         , 'z', 't'/)   &
-                  &         , (/kdompar(1,1), kdompar(2,1), jpk, -1 /), ioipslid, ifliodom, mode = clstatus )
-            ELSE              ! the file should be open for read mode so it must exist...
-               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//cdname//' in WRITE mode'
-               CALL fliocrfd( cdname, (/'x'         , 'y'         , 'z', 't'/)   &
-                  &         , (/kdompar(1,1), kdompar(2,1), jpk, -1 /), ioipslid,           mode = clstatus )
-            ENDIF
-         ELSE              ! the file should be open for read mode so it must exist...
-            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
-         ENDIF
-      ENDIF
-      ! start to fill file informations
-      ! =============
-      IF( istop == nstop ) THEN   ! no error within this routine
-!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
-         kiomid = 0
-         DO jl = jpmax_files, 1, -1
-            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
-         ENDDO
-         iom_file(kiomid)%name   = TRIM(cdname)
-         iom_file(kiomid)%nfid   = ioipslid
-         iom_file(kiomid)%iolib  = jpioipsl
-         iom_file(kiomid)%nvars  = 0
-         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files
-         CALL flioinqf( ioipslid, id_uld = iom_file(kiomid)%iduld )
-         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
-      ELSE
-         kiomid = 0               ! return error flag
-      ENDIF
-      !
-   END SUBROUTINE iom_ioipsl_open
-
-
-   SUBROUTINE iom_ioipsl_close( kiomid )
-      !!--------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_ioipsl_close  ***
-      !!
-      !! ** Purpose : close an input file with IOIPSL (only fliocom module) 
-      !!--------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
-      !---------------------------------------------------------------------
-      !
-      CALL flioclo( iom_file(kiomid)%nfid )
-      !    
-   END SUBROUTINE iom_ioipsl_close
-
-
-   FUNCTION iom_ioipsl_varid ( kiomid, cdvar, kiv, kdimsz )  
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  iom_varid  ***
-      !!
-      !! ** Purpose : get the id of a variable in a file with IOIPSL (only fliocom module)
-      !!-----------------------------------------------------------------------
-      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
-      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
-      INTEGER              , INTENT(in   )           ::   kiv   ! 
-      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
-      !
-      INTEGER                        ::   iom_ioipsl_varid  ! iom variable Id
-      INTEGER                        ::   ioipslid          ! ioipsl file identifier
-      INTEGER                        ::   ji                ! dummy loop index
-      INTEGER                        ::   i_nvd             ! number of dimension of the variable
-      INTEGER, DIMENSION(jpmax_dims) ::   idimid            ! dimension ids of the variable
-      LOGICAL                        ::   ll_fnd            ! found test
-      CHARACTER(LEN=100)             ::   clinfo            ! info character
-      !!-----------------------------------------------------------------------
-      clinfo = 'iom_ioipsl_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
-      iom_ioipsl_varid = 0                  ! default definition
-      IF( PRESENT(kdimsz) ) kdimsz(:) = 0   ! default definition
-      ioipslid = iom_file(kiomid)%nfid      ! get back ioipsl file identifier 
-      CALL flioinqv( ioipslid, cdvar, ll_fnd, nb_dims = i_nvd )   ! does the variable exist in the file
-      IF( ll_fnd ) THEN
-         IF( i_nvd <= jpmax_dims ) THEN
-            iom_ioipsl_varid = kiv
-            iom_file(kiomid)%nvars       = kiv
-            iom_file(kiomid)%nvid(kiv)   = -1   ! variable id is not available in ioipsl
-            iom_file(kiomid)%cn_var(kiv) = TRIM(cdvar)
-            iom_file(kiomid)%ndims(kiv)  = i_nvd
-            iom_file(kiomid)%dimsz(:,kiv) = 0   ! reset dimsz in case previously used
-            CALL flioinqv( ioipslid, cdvar, ll_fnd,   &
-                  &           len_dims = iom_file(kiomid)%dimsz(1:i_nvd,kiv), &   ! dimensions size
-                  &           id_dims  = idimid(1:i_nvd) )                        ! dimensions ids
-            iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value
-            DO ji = 1, i_nvd                       ! find the unlimited dimension
-               IF( idimid(ji) == iom_file(kiomid)%iduld ) iom_file(kiomid)%luld(kiv) = .TRUE.
-            END DO
-            !---------- Deal with scale_factor and add_offset
-            CALL flioinqa( ioipslid, cdvar, 'scale_factor', ll_fnd )
-            IF( ll_fnd) THEN
-               CALL fliogeta( ioipslid, cdvar, 'scale_factor', iom_file(kiomid)%scf(kiv) )
-            ELSE
-               iom_file(kiomid)%scf(kiv) = 1.
-            END IF
-            CALL flioinqa( ioipslid, cdvar, 'add_offset', ll_fnd )
-            IF( ll_fnd ) THEN
-               CALL fliogeta( ioipslid, cdvar, 'add_offset', iom_file(kiomid)%ofs(kiv) )
-            ELSE
-               iom_file(kiomid)%ofs(kiv) = 0.
-            END IF
-            ! return the simension size
-            IF( PRESENT(kdimsz) ) THEN 
-               IF( i_nvd == SIZE(kdimsz) ) THEN
-                  kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,kiv)
-               ELSE
-                  WRITE(ctmp1,*) i_nvd, SIZE(kdimsz)
-                  CALL ctl_stop( TRIM(clinfo), 'error in kdimsz size'//TRIM(ctmp1) )
-               ENDIF
-            ENDIF
-         ELSE
-            CALL ctl_stop( TRIM(clinfo), 'Too many dimensions in the file '//iom_file(kiomid)%name,   &
-                  &                       'increase the parameter jpmax_vars')
-         ENDIF
-      ELSE  
-         iom_ioipsl_varid = -1   !   variable not found, return error code: -1
-      ENDIF
-      !
-   END FUNCTION iom_ioipsl_varid
-
-
-   SUBROUTINE iom_ioipsl_g0d( kiomid, kvid, pvar, kstart )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_ioipsl_g0d  ***
-      !!
-      !! ** Purpose : read a scalar with IOIPSL (only fliocom module)
-      !!-----------------------------------------------------------------------
-      INTEGER ,               INTENT(in   )            ::   kiomid    ! Identifier of the file
-      INTEGER ,               INTENT(in   )            ::   kvid      ! variable id
-      REAL(wp),               INTENT(  out)            ::   pvar      ! read field
-      INTEGER , DIMENSION(1), INTENT(in   ), OPTIONAL  ::   kstart    ! start position of the reading in each axis
-      !
-      CALL fliogetv( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), pvar, kstart )
-      ! 
-   END SUBROUTINE iom_ioipsl_g0d
-
-
-   SUBROUTINE iom_ioipsl_g123d( kiomid, kvid, knbdim, kstart, kcount, kx1, kx2, ky1, ky2,   &
-         &                      pv_r1d, pv_r2d, pv_r3d)
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_ioipsl_g123d  ***
-      !!
-      !! ** Purpose : read a 1D/2D/3D variable with IOIPSL (only fliocom module)
-      !!
-      !! ** Method : read ONE record at each CALL
-      !!-----------------------------------------------------------------------
-      INTEGER                    , INTENT(in   )           ::   kiomid     ! iom identifier of the file
-      INTEGER                    , INTENT(in   )           ::   kvid       ! Name of the variable
-      INTEGER                    , INTENT(in   )           ::   knbdim     ! number of dimensions of the variable
-      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kstart     ! start position of the reading in each axis 
-      INTEGER , DIMENSION(:)     , INTENT(in   )           ::   kcount     ! number of points to be read in each axis
-      INTEGER ,                    INTENT(in   )           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
-      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
-      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
-      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
-      !
-      INTEGER               ::   ioipslid   ! ioipsl file identifier
-      CHARACTER(LEN=100)    ::   clvn       ! variable name
-      !---------------------------------------------------------------------
-      clvn = TRIM(iom_file(kiomid)%cn_var(kvid))   ! get back variable name 
-      ioipslid = iom_file(kiomid)%nfid             ! get back IPIPSL file id
-      !
-      IF( PRESENT(pv_r1d) ) THEN
-         CALL fliogetv( ioipslid, clvn, pv_r1d(:                ), start = kstart(1:knbdim), count = kcount(1:knbdim) )
-      ELSEIF( PRESENT(pv_r2d) ) THEN
-         CALL fliogetv( ioipslid, clvn, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim), count = kcount(1:knbdim) )
-      ELSEIF( PRESENT(pv_r3d) ) THEN
-         CALL fliogetv( ioipslid, clvn, pv_r3d(kx1:kx2,ky1:ky2,:), start = kstart(1:knbdim), count = kcount(1:knbdim) )
-      ENDIF
-      !
-      !
-   END SUBROUTINE iom_ioipsl_g123d
-
-
-   SUBROUTINE iom_ioipsl_gettime( kiomid, kvid, ptime, cdunits, cdcalendar )
-      !!--------------------------------------------------------------------
-      !!                   ***  SUBROUTINE iom_gettime  ***
-      !!
-      !! ** Purpose : read the time axis kvid in the file with IOIPSL (only fliocom module)
-      !!--------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid     ! file Identifier
-      INTEGER                   , INTENT(in   ) ::   kvid       ! variable id
-      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   ptime      ! the time axis
-      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdunits    ! units attribute
-      CHARACTER(len=*), OPTIONAL, INTENT(  out) ::   cdcalendar ! calendar attribute
-      !---------------------------------------------------------------------
-      !
-      CALL fliogetv( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), ptime(:),   &
-            &         start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /) )
-      IF ( PRESENT(cdunits) ) THEN 
-         CALL fliogeta( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), "units", cdunits )
-      ENDIF
-      IF ( PRESENT(cdcalendar) ) THEN 
-         CALL fliogeta( iom_file(kiomid)%nfid, TRIM(iom_file(kiomid)%cn_var(kvid)), "calendar", cdcalendar )
-      ENDIF
-      !
-   END SUBROUTINE iom_ioipsl_gettime
-
-
-   SUBROUTINE iom_ioipsl_rp0123d( kt, kwrite, kiomid, cdvar , kvid  , ktype,   &
-         &                                 pv_r0d, pv_r1d, pv_r2d, pv_r3d )
-      !!--------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_ioipsl_rstput  ***
-      !!
-      !! ** Purpose : read the time axis cdvar in the file 
-      !!--------------------------------------------------------------------
-      INTEGER                     , INTENT(in)           ::   kt       ! ocean time-step
-      INTEGER                     , INTENT(in)           ::   kwrite   ! writing time-step
-      INTEGER                     , INTENT(in)           ::   kiomid   ! Identifier of the file 
-      CHARACTER(len=*)            , INTENT(in)           ::   cdvar    ! variable name
-      INTEGER                     , INTENT(in)           ::   kvid     ! variable id
-      INTEGER                     , INTENT(in), OPTIONAL ::   ktype    ! variable type (default R8)
-      REAL(wp)                    , INTENT(in), OPTIONAL ::   pv_r0d   ! written Od field
-      REAL(wp), DIMENSION(      :), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
-      REAL(wp), DIMENSION(:, :   ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
-      REAL(wp), DIMENSION(:, :, :), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
-      !
-      INTEGER               :: idims                ! number of dimension
-      INTEGER               :: idvar                ! variable id
-      INTEGER               :: itype                ! variable type
-      INTEGER               :: ix1, ix2, iy1, iy2   ! subdomain indexes
-      INTEGER, DIMENSION(4) :: idimsz               ! dimensions size  
-      INTEGER, DIMENSION(4) :: idimid               ! dimensions id
-      CHARACTER(LEN=100)    :: clinfo               ! info character
-      INTEGER               :: ioipslid             ! ioipsl file identifier
-      !---------------------------------------------------------------------
-      !
-      clinfo = '          iom_ioipsl_rp0123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
-      ioipslid = iom_file(kiomid)%nfid
-      !
-      ! define dimension variables if it is not already done
-      ! ==========================
-      IF( iom_file(kiomid)%nvars == 0 ) THEN
-         ! define the dimension variables if it is not already done
-         CALL fliodefv( ioipslid,'nav_lon', (/1,2/), v_t=flio_r4   , axis='X',   &
-               &                  long_name="Longitude", units="degrees_east" )
-         CALL fliodefv( ioipslid,'nav_lat', (/1,2/), v_t=flio_r4   , axis='Y',   &
-               &                  long_name="Latitude", units="degrees_north" )
-         CALL fliodefv( ioipslid,'nav_lev', (/3/)  , v_t=flio_i4   , axis='Z',   &
-               &                  long_name="Model levels",units="model_levels")
-         CALL fliodefv( ioipslid,'time_counter', (/4/), v_t=flio_r4, axis='T',   &
-               &                  long_name="Time axis", units='seconds since 0001-01-01 00:00:00' )
-         ! update informations structure related the dimension variable we just added...
-         iom_file(kiomid)%nvars       = 4
-         iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
-         iom_file(kiomid)%cn_var(1:3) = (/ 'nav_lon', 'nav_lat', 'nav_lev' /)
-         iom_file(kiomid)%cn_var(4)   = 'time_counter'
-         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)
-         ! trick: defined to 0 to say that dimension variables are defined but not yet written
-         iom_file(kiomid)%dimsz(1, 1) = 0   
-         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' define dimension variables done'
-      ENDIF
-
-      ! define the data if it is not already done
-      ! ===============
-      IF( kvid <= 0 ) THEN
-         ! variable definition
-         IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
-         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,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/)
-         ENDIF
-         IF( PRESENT(ktype) ) THEN   ! variable external type
-            SELECT CASE (ktype)
-            CASE (jp_r8)  ;   itype = flio_r8
-            CASE (jp_r4)  ;   itype = flio_r4
-            CASE (jp_i4)  ;   itype = flio_i4
-            CASE (jp_i2)  ;   itype = flio_i2
-            CASE (jp_i1)  ;   itype = flio_i1   !   fliocom does not handle i1 type of variable
-            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
-            END SELECT
-         ELSE
-            itype = flio_r8
-         ENDIF
-         IF( PRESENT(pv_r0d) ) THEN   ;   CALL fliodefv (ioipslid, TRIM(cdvar)                 , v_t = itype)
-         ELSE                         ;   CALL fliodefv (ioipslid, TRIM(cdvar), idimid(1:idims), v_t = itype)
-         ENDIF
-         ! update informations structure related the new variable we want to add...
-         idvar                          = iom_file(kiomid)%nvars + 1
-         iom_file(kiomid)%nvars         = idvar
-         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
-         iom_file(kiomid)%nvid(idvar)   = -1   ! netcdf variable id is not available in ioipsl
-         iom_file(kiomid)%scf(idvar)    = 1.
-         iom_file(kiomid)%ofs(idvar)    = 0.
-         iom_file(kiomid)%ndims(idvar)  = idims
-         IF( .NOT. PRESENT(pv_r0d) ) THEN
-            iom_file(kiomid)%luld(idvar) = .TRUE.
-            CALL flioinqf( ioipslid, ln_dim = idimsz )
-            iom_file(kiomid)%dimsz(1:idims-1,idvar) = idimsz(idimid(1:idims-1))
-         ELSE                               
-            iom_file(kiomid)%luld(idvar) = .FALSE.
-         ENDIF
-         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' defined ok'
-      ELSE
-         idvar = kvid
-      ENDIF
-
-      ! time step kwrite : write the variable
-      IF( kt == kwrite ) THEN
-         ! on what kind of domain must the data be written?
-         IF( PRESENT(pv_r2d) .OR. PRESENT(pv_r3d) ) THEN
-            idimsz(1:2) = iom_file(kiomid)%dimsz(1:2,idvar)
-            IF(     idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN
-               ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
-            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN
-               ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
-            ELSEIF( idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN
-               ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
-            ELSE 
-               CALL ctl_stop( 'iom_ioipsl_rp0123d: should have been an impossible case...' )
-            ENDIF
-
-            ! write dimension variables if it is not already done
-            ! =============
-            ! trick: is defined to 0 => dimension variable are defined but not yet written
-            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN
-               CALL flioputv( ioipslid, 'nav_lon'     , glamt(ix1:ix2, iy1:iy2) )
-               CALL flioputv( ioipslid, 'nav_lat'     , gphit(ix1:ix2, iy1:iy2) )
-               CALL flioputv( ioipslid, 'nav_lev'     , gdept_1d )
-               ! +++ WRONG VALUE: to be improved but not really useful...
-               CALL flioputv( ioipslid, 'time_counter', kt )
-               ! update the values of the variables dimensions size
-               CALL flioinqf( ioipslid, ln_dim = idimsz )
-               iom_file(kiomid)%dimsz(1:2, 1) = idimsz(1:2)
-               iom_file(kiomid)%dimsz(1:2, 2) = idimsz(1:2)
-               iom_file(kiomid)%dimsz(1, 3:4) = (/idimsz(3), 1/)
-               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done'
-            ENDIF
-         ENDIF
-
-         ! write the data
-         ! =============
-         IF(     PRESENT(pv_r0d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r0d                      )
-         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r1d(                  :) )
-         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r2d(ix1:ix2, iy1:iy2   ) )
-         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   CALL flioputv( ioipslid, cdvar, pv_r3d(ix1:ix2, iy1:iy2, :) )
-         ENDIF
-         ! add 1 to the size of the temporal dimension (not really useful...)
-         IF( iom_file(kiomid)%luld(idvar) )   iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar)    &
-               &                            = iom_file(kiomid)%dimsz(iom_file(kiomid)%ndims(idvar), idvar) + 1
-         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
-      ENDIF
-      !     
-   END SUBROUTINE iom_ioipsl_rp0123d
-
-
-   !!======================================================================
-END MODULE iom_ioipsl
Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 7349)
+++ branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 7351)
@@ -154,6 +154,7 @@
          CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
          IF ( iom_file(kiomid)%iduld .GE. 0 ) THEN
-           CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,   &
-        &                                               name = iom_file(kiomid)%uldname), clinfo)
+           CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,     & 
+        &                                               name = iom_file(kiomid)%uldname,  &
+        &                                               len  = iom_file(kiomid)%lenuld ), clinfo )
          ENDIF
          IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_rstdimg.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/iom_rstdimg.F90	(revision 7349)
+++ 	(revision )
@@ -1,504 +1,0 @@
-MODULE iom_rstdimg
-   !!=====================================================================
-   !!                    ***  MODULE  iom_rstdimg ***
-   !! Input/Output manager :  Library to read input rstdimg files
-   !!====================================================================
-   !! History :  9.0  ! 06 09  (S. Masson) Original code
-   !!--------------------------------------------------------------------
-
-   !!--------------------------------------------------------------------
-   !!   iom_open       : open a file read only
-   !!   iom_close      : close a file or all files opened by iom
-   !!   iom_get        : read a field (interfaced to several routines)
-   !!   iom_gettime    : read the time axis kvid in the file
-   !!   iom_varid      : get the id of a variable in a file
-   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
-   !!--------------------------------------------------------------------
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! MPP library
-   USE dom_oce         ! ocean space and time domain
-   USE lbclnk          ! lateal boundary condition / mpp exchanges
-   USE iom_def         ! iom variables definitions
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC iom_rstdimg_open, iom_rstdimg_close, iom_rstdimg_get, iom_rstdimg_rstput
-
-   INTERFACE iom_rstdimg_get
-      MODULE PROCEDURE iom_rstdimg_g0d, iom_rstdimg_g123d
-   END INTERFACE
-   INTERFACE iom_rstdimg_rstput
-      MODULE PROCEDURE iom_rstdimg_rp0d, iom_rstdimg_rp123d
-   END INTERFACE
-
-   INTEGER, PARAMETER ::   jpvnl          = 32   ! variable name length
-      
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-CONTAINS
-
-   SUBROUTINE iom_rstdimg_open( cdname, kiomid, ldwrt, ldok, kdompar )
-      !!---------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_open  ***
-      !!
-      !! ** Purpose :  open an input file read only (return 0 if not found)
-      !!---------------------------------------------------------------------
-      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name
-      INTEGER                , INTENT(  out)           ::   kiomid      ! iom identifier of the opened file
-      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
-      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
-      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
-
-      CHARACTER(LEN=100)                      ::   clinfo                     ! info character
-      CHARACTER(LEN=100)                      ::   cltmp                      ! temporary character
-      CHARACTER(LEN=10 )                      ::   clstatus                   ! status of opened file (REPLACE or NEW)
-      INTEGER                                 ::   jv                         ! loop counter
-      INTEGER                                 ::   istop                      ! temporary storage of nstop
-      INTEGER                                 ::   idrst                      ! logical unit of the restart file
-      INTEGER                                 ::   iln                        ! lengths of character
-      INTEGER                                 ::   irecl8                     ! record length
-      INTEGER                                 ::   ios                        ! IO status
-      INTEGER                                 ::   irhd                       ! record of the header infos
-      INTEGER                                 ::   ivnum                      ! number of variables
-      INTEGER                                 ::   ishft                      ! counter shift
-      INTEGER                                 ::   inx, iny, inz              ! x,y,z dimension of the variable
-      INTEGER                                 ::   in0d, in1d, in2d, in3d     ! number of 0/1/2/3D variables
-      INTEGER                                 ::   ipni, ipnj, ipnij, iarea   ! domain decomposition 
-      INTEGER                                 ::   iiglo, ijglo               ! domain global size 
-      INTEGER                                 ::   jl                         ! loop variable
-      LOGICAL                                 ::   llclobber                  ! local definition of ln_clobber
-      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d     ! name of 0/1/2/3D variables
-      REAL(wp),             DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d     ! value of 0d variables or record
-      !                                                                                   ! position for 1/2/3D variables
-      !---------------------------------------------------------------------
-      clinfo = '                    iom_rstdimg_open ~~~  '
-      istop = nstop      ! store the actual value of nstop
-      ios = 0            ! default definition
-      kiomid = 0         ! default definition
-      llclobber = ldwrt .AND. ln_clobber
-      ! get a free unit
-      idrst = get_unit()  ! get a free logical unit for the restart file
-!!$#if defined key_agrif 
-!!$      idrst = Agrif_Get_Unit()      
-!!$#endif 
-      ! Open the file...
-      ! =============
-      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file...
-         ! find the record length
-         OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
-            &       , RECL = 8, STATUS = 'old', ACTION = 'read', IOSTAT = ios, ERR = 987 )
-         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8
-         CLOSE( idrst )
-         ! Open the file with the appropriate record length and parameters
-         IF( ldwrt ) THEN  ! ... in readwrite mode
-            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READWRITE mode'
-            OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
-               &       , RECL = irecl8, STATUS = 'old', ACTION = 'readwrite', IOSTAT = ios, ERR = 987 )
-         ELSE              ! ... in read mode
-            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
-            OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   &
-               &       , RECL = irecl8, STATUS = 'old', ACTION = 'read'     , IOSTAT = ios, ERR = 987 )
-         ENDIF
-      ELSE                                       ! the file does not exist (or we overwrite it)
-         iln = INDEX( cdname, '.dimg' )
-         IF( ldwrt ) THEN  ! the file should be open in readwrite mode so we create it...
-            irecl8= MAX( kdompar(1,1) * kdompar(2,1) * wp, ( 8*jpnij + 15 ) * 4 )
-            IF( jpnij > 1 ) THEN
-               WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea, '.dimg'
-               cdname = TRIM(cltmp)
-            ENDIF
-            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in READWRITE mode'
-            
-            IF( llclobber ) THEN   ;   clstatus = 'REPLACE' 
-            ELSE                   ;   clstatus = 'NEW'
-            ENDIF
-            OPEN( idrst, FILE = TRIM(cdname), FORM = 'UNFORMATTED', ACCESS = 'DIRECT'   &
-               &       , RECL = irecl8, STATUS = TRIM(clstatus), ACTION = 'readwrite', IOSTAT = ios, ERR = 987 )
-         ELSE              ! the file should be open for read mode so it must exist...
-            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
-         ENDIF
-      ENDIF
-      ! Performs checks on the file
-      ! =============
-      IF( ldok .AND. .NOT. llclobber ) THEN      ! old file
-         READ( idrst, REC = 1   , IOSTAT = ios, ERR = 987 )              &
-              &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   &
-              &   ipni, ipnj, ipnij, iarea, iiglo, ijglo
-         READ( idrst, REC = irhd, IOSTAT = ios, ERR = 987 )                       &
-            &   clna0d(1:in0d), zval0d(1:in0d), clna1d(1:in1d), zval1d(1:in1d),   &
-            &   clna2d(1:in2d), zval2d(1:in2d), clna3d(1:in3d), zval3d(1:in3d)
-         clinfo = TRIM(clinfo)//' file '//TRIM(cdname)
-         IF( iiglo /= jpiglo       )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in global domain size in i direction' )
-         IF( ijglo /= jpjglo       )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in global domain size in j direction' )
-         IF( ldwrt ) THEN
-            IF( inx   /= kdompar(1,1) )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in local domain size in i direction' )
-            IF( iny   /= kdompar(2,1) )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in local domain size in j direction' )
-         ENDIF
-         IF( inz   /= jpk          )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in domain size in k direction' )
-         IF( ipni  /= jpni         )   CALL ctl_stop( TRIM(clinfo), 'Processor splitting changed along I' )
-         IF( ipnj  /= jpnj         )   CALL ctl_stop( TRIM(clinfo), 'Processor splitting changed along J' )
-         IF( ipnij /= jpnij        )   CALL ctl_stop( TRIM(clinfo), 'Total number of processors changed' )
-         IF( iarea /= narea        )   CALL ctl_stop( TRIM(clinfo), 'Mismatch in area numbering ...' )
-      ENDIF
-      ! fill file informations
-      ! =============
-      IF( istop == nstop ) THEN   ! no error within this routine
-!does not work with some compilers         kiomid = MINLOC(iom_file(:)%nfid, dim = 1)
-         kiomid = 0
-         DO jl = jpmax_files, 1, -1
-            IF( iom_file(jl)%nfid == 0 )   kiomid = jl
-         ENDDO
-         iom_file(kiomid)%name    = TRIM(cdname)
-         iom_file(kiomid)%nfid    = idrst
-         iom_file(kiomid)%iolib   = jprstdimg
-         iom_file(kiomid)%iduld   = -1
-         IF( ldok ) THEN      ! old file
-            ! read variables informations from the file header
-            IF(  TRIM(clna0d(1)) == 'no0d' )   in0d = 0
-            IF(  TRIM(clna1d(1)) == 'no1d' )   in1d = 0
-            IF(  TRIM(clna2d(1)) == 'no2d' )   in2d = 0
-            IF(  TRIM(clna3d(1)) == 'no3d' )   in3d = 0
-            ivnum = in0d + in1d + in2d + in3d
-            iom_file(kiomid)%nvars            = ivnum
-            iom_file(kiomid)%irec             = 2 + in1d + in2d + inz * in3d
-            iom_file(kiomid)%luld(   1:ivnum) = .FALSE.
-            iom_file(kiomid)%scf(    1:ivnum) = 1.
-            ! scalar variable
-            DO jv = 1, in0d
-               iom_file(kiomid)%cn_var(jv) = TRIM(clna0d(jv))
-               iom_file(kiomid)%nvid(  jv) = 1
-               iom_file(kiomid)%ndims( jv) = 0
-               iom_file(kiomid)%ofs(   jv) = zval0d(jv)   ! warning: trick... we use ofs to store the value
-            END DO
-            ! 1d variable
-            ishft = in0d
-            DO jv = 1, in1d
-               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna1d(jv))
-               iom_file(kiomid)%nvid(      ishft + jv) = zval1d(jv)
-               iom_file(kiomid)%ndims(     ishft + jv) = 1
-               iom_file(kiomid)%dimsz(1  , ishft + jv) = jpk
-               iom_file(kiomid)%ofs(       ishft + jv) = 0.
-            END DO
-            ! 2d variable
-            ishft = in0d + in1d
-            DO jv = 1, in2d
-               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna2d(jv))
-               iom_file(kiomid)%nvid(      ishft + jv) = zval2d(jv)
-               iom_file(kiomid)%ndims(     ishft + jv) = 2
-               iom_file(kiomid)%dimsz(1:2, ishft + jv) = (/ inx, iny /)
-               iom_file(kiomid)%ofs(       ishft + jv) = 0.
-            END DO
-            ! 3d variable
-            ishft = in0d + in1d + in2d 
-            DO jv = 1, in3d
-               iom_file(kiomid)%cn_var(    ishft + jv) = TRIM(clna3d(jv))
-               iom_file(kiomid)%nvid(      ishft + jv) = zval3d(jv)
-               iom_file(kiomid)%ndims(     ishft + jv) = 3
-               iom_file(kiomid)%dimsz(1:3, ishft + jv) = (/ inx, iny, jpk /)
-               iom_file(kiomid)%ofs(       ishft + jv) = 0.
-            END DO
-         ELSE                 ! new file
-            iom_file(kiomid)%nvars = 0
-            iom_file(kiomid)%irec  = 2
-            ! store file informations
-            WRITE( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, kdompar(:,1), jpk   ! store domain size
-         ENDIF
-      ENDIF
-987   CONTINUE
-      IF( ios /= 0 ) THEN
-         WRITE(ctmp1,*) '           iostat = ', ios
-         CALL ctl_stop( TRIM(clinfo), '   error in opening file '//TRIM(cdname), ctmp1 )
-      ENDIF
-      !
-   END SUBROUTINE iom_rstdimg_open
-
-
-   SUBROUTINE iom_rstdimg_close( kiomid )
-      !!--------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_rstdimg_close  ***
-      !!
-      !! ** Purpose : close an input file
-      !!--------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kiomid   ! iom identifier of the file to be closed
-      !
-      CHARACTER(LEN=100)                      ::   clinfo                     ! info character
-      INTEGER                                 ::   jv                         ! loop counter
-      INTEGER                                 ::   irecl8                     ! record length
-      INTEGER                                 ::   ios                        ! IO status
-      INTEGER                                 ::   irhd                       ! record of the header infos
-      INTEGER                                 ::   ivnum                      ! number of variables
-      INTEGER                                 ::   idrst                      ! file logical unit
-      INTEGER                                 ::   inx, iny, inz              ! x,y,z dimension of the variable
-      INTEGER                                 ::   in0d, in1d, in2d, in3d     ! number of 0/1/2/3D variables
-      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d    ! name of 0/1/2/3D variables
-      REAL(wp),          DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d    ! value of 0d variables or record
-      !                                                                               ! position for 1/2/3D variables
-      !---------------------------------------------------------------------
-      !
-      clinfo = '                    iom_rstdimg_close ~~~  '
-      idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
-      ! test if we can write in the file (test with INQUIRE gives alsways YES even with read only files...)
-      READ(  idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz   
-      WRITE( idrst, REC = 1, IOSTAT = ios            ) irecl8, inx, iny, inz   
-      ! We can write in the file => we update its header before closing
-      IF( ios == 0 ) THEN
-         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz   ! get back domain size
-         irhd = iom_file(kiomid)%irec
-         ivnum = iom_file(kiomid)%nvars
-         in0d = 0   ;   in1d = 0   ;   in2d = 0   ;   in3d = 0
-         DO jv = 1, ivnum   ! loop on each variable to get its name and value/record position
-            SELECT CASE (iom_file(kiomid)%ndims(jv))
-            CASE (0)   ! scalar variable
-               in0d = in0d + 1
-               clna0d(in0d) = TRIM(iom_file(kiomid)%cn_var(jv))
-               zval0d(in0d) = iom_file(kiomid)%ofs(jv)   ! warning: trick... we use ofs to store the value
-            CASE (1)   ! 1d variable
-               in1d = in1d + 1
-               clna1d(in1d) = TRIM(iom_file(kiomid)%cn_var(jv))
-               zval1d(in1d) = iom_file(kiomid)%nvid(jv)
-            CASE (2)   ! 2d variable
-               in2d = in2d + 1
-               clna2d(in2d) = TRIM(iom_file(kiomid)%cn_var(jv))
-               zval2d(in2d) = iom_file(kiomid)%nvid(jv)
-            CASE (3)   ! 3d variable
-               in3d = in3d + 1
-               clna3d(in3d) = TRIM(iom_file(kiomid)%cn_var(jv))
-               zval3d(in3d) = iom_file(kiomid)%nvid(jv)
-            CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo), 'Should not ne there...' )
-            END SELECT
-         END DO
-         ! force to have at least 1 variable in each list (not necessary (?), but safer...)
-         IF( in0d == 0 ) THEN   ;   in0d = 1   ;   clna0d(1) = 'no0d'   ;   zval0d(1) = -1.   ;   ENDIF
-         IF( in1d == 0 ) THEN   ;   in1d = 1   ;   clna1d(1) = 'no1d'   ;   zval1d(1) = -1.   ;   ENDIF
-         IF( in2d == 0 ) THEN   ;   in2d = 1   ;   clna2d(1) = 'no2d'   ;   zval2d(1) = -1.   ;   ENDIF
-         IF( in3d == 0 ) THEN   ;   in3d = 1   ;   clna3d(1) = 'no3d'   ;   zval3d(1) = -1.   ;   ENDIF
-         ! update the file header before closing it
-         WRITE( idrst, REC = 1, IOSTAT = ios, ERR = 987 )              &
-            &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   &
-            &   jpni, jpnj, jpnij, narea, jpiglo, jpjglo,              &
-            &   nlcit, nlcjt, nldit, nldjt, nleit, nlejt, nimppt, njmppt
-         IF( (ivnum * (jpvnl + wp)) > irecl8 ) THEN 
-            CALL ctl_stop( TRIM(clinfo),   &
-                 &   'Last record size is too big... You could reduce the value of jpvnl' )
-         ELSE 
-            WRITE( idrst, REC = irhd, IOSTAT = ios, ERR = 987 )                        &
-                 &   clna0d(1:in0d), zval0d(1:in0d), clna1d(1:in1d), zval1d(1:in1d),   &
-                 &   clna2d(1:in2d), zval2d(1:in2d), clna3d(1:in3d), zval3d(1:in3d)
-         ENDIF
-      ELSE
-         ios = 0   ! we cannot write in the file
-      ENDIF
-      !
-      CLOSE( idrst, IOSTAT = ios, ERR = 987 )
-987   CONTINUE
-      IF( ios /= 0 ) THEN
-         WRITE(ctmp1,*) '           iostat = ', ios
-         CALL ctl_stop( TRIM(clinfo),   &
-            &   '   error when updating the header of '//TRIM(iom_file(kiomid)%name), ctmp1 )
-      ENDIF
-      !    
-   END SUBROUTINE iom_rstdimg_close
-
-
-   SUBROUTINE iom_rstdimg_g0d( kiomid, kvid, pvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_rstdimg_g0d  ***
-      !!
-      !! ** Purpose : read a scalar with RSTDIMG
-      !!-----------------------------------------------------------------------
-      INTEGER,  INTENT(in   ) ::   kiomid    ! Identifier of the file
-      INTEGER,  INTENT(in   ) ::   kvid      ! variable id
-      REAL(wp), INTENT(  out) ::   pvar      ! read field
-      !---------------------------------------------------------------------
-      !
-      pvar = iom_file(kiomid)%ofs(kvid)   ! warning: trick... we use ofs to store the value
-      !
-   END SUBROUTINE iom_rstdimg_g0d
-
-
-   SUBROUTINE iom_rstdimg_rp0d( kiomid, cdvar, kvid, pv_r0d )
-      !!--------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_rstdimg_rstput  ***
-      !!
-      !! ** Purpose : write a scalar with RSTDIMG
-      !!--------------------------------------------------------------------
-      INTEGER                   , INTENT(in) ::   kiomid   ! Identifier of the file 
-      CHARACTER(len=*)          , INTENT(in) ::   cdvar    ! time axis name
-      INTEGER                   , INTENT(in) ::   kvid     ! variable id
-      REAL(wp)                  , INTENT(in) ::   pv_r0d   ! written 0d field
-      !
-      CHARACTER(LEN=100) ::   clinfo     ! info character
-      INTEGER            ::   idvar      ! variable id
-      !---------------------------------------------------------------------
-      !  
-      clinfo = '                    iom_rstdimg_rp0d ~~~  '
-      IF( kvid <= 0 ) THEN   !   new variable
-         idvar = iom_file(kiomid)%nvars + 1
-      ELSE                   !   the variable already exists in the file
-         idvar = kvid
-      ENDIF
-      IF( idvar <= jpmax_vars ) THEN
-         iom_file(kiomid)%nvars = idvar
-         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
-         iom_file(kiomid)%nvid(   idvar) = 1   ! useless, Od variables a strored in record 1
-         iom_file(kiomid)%ndims(  idvar) = 0
-         iom_file(kiomid)%luld(   idvar) = .FALSE.
-         iom_file(kiomid)%scf(    idvar) = 1.
-         iom_file(kiomid)%ofs(    idvar) = pv_r0d   ! warning: trick... we use ofs to store the value
-      ELSE
-         CALL ctl_stop( TRIM(clinfo), 'increase the value of jpmax_vars' )
-      ENDIF
-   END SUBROUTINE iom_rstdimg_rp0d
-
-
-   SUBROUTINE iom_rstdimg_g123d( kiomid, kdom  , kvid, kx1, kx2, ky1, ky2,   &
-         &                       pv_r1d, pv_r2d, pv_r3d )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_rstdimg_g123d  ***
-      !!
-      !! ** Purpose : read a 1D/2D/3D variable with RSTDIMG
-      !!
-      !! ** Method : read ONE record at each CALL
-      !!-----------------------------------------------------------------------
-      INTEGER                    , INTENT(in   )           ::   kiomid     ! iom identifier of the file
-      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
-      INTEGER                    , INTENT(in   )           ::   kvid       ! variable id
-      INTEGER ,                    INTENT(inout)           ::   kx1, kx2, ky1, ky2   ! subdomain indexes
-      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
-      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
-      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
-
-      CHARACTER(LEN=100) ::   clinfo               ! info character
-      INTEGER            ::   ios                  ! IO status
-      INTEGER            ::   jk                   ! loop counter
-      INTEGER            ::   idrst                ! logical unit of the restart file
-      !---------------------------------------------------------------------
-      clinfo = '                    iom_rstdimg_g123d ~~~  '
-      !
-      IF( kdom == jpdom_data .OR. kdom == jpdom_global ) THEN
-         CALL ctl_stop( TRIM(clinfo), TRIM(iom_file(kiomid)%cn_var(kvid))//': case not coded for rstdimg files' )
-      ELSE
-      !
-         idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
-         ! modify the subdomain indexes because we cannot directly extract the appropriate subdomaine
-         IF(     kdom == jpdom_local_full    ) THEN   ;   kx1 = 1   ;   kx2 = jpi    ;   ky1 = 1
-         ELSEIF( kdom == jpdom_local_noextra ) THEN   ;   kx1 = 1   ;   kx2 = nlci   ;   ky1 = 1
-         ENDIF
-         !
-         IF(     PRESENT(pv_r1d) ) THEN   ! read 1D variables
-            READ(    idrst, REC = iom_file(kiomid)%nvid(kvid)         , IOSTAT = ios, ERR = 987 )   pv_r1d(:)
-         ELSEIF( PRESENT(pv_r2d) ) THEN   ! read 2D variables
-            READ(    idrst, REC = iom_file(kiomid)%nvid(kvid)         , IOSTAT = ios, ERR = 987 )   pv_r2d(kx1:kx2, ky1:ky2    )
-         ELSEIF( PRESENT(pv_r3d) ) THEN   ! read 3D variables
-            DO jk = 1, iom_file(kiomid)%dimsz(3,kvid)   ! do loop on each level
-               READ( idrst, REC = iom_file(kiomid)%nvid(kvid) + jk - 1, IOSTAT = ios, ERR = 987 )   pv_r3d(kx1:kx2, ky1:ky2, jk)
-            END DO
-         ENDIF
-987      CONTINUE
-         IF( ios /= 0 ) THEN
-            WRITE(ctmp1,*) '           iostat = ', ios
-            CALL ctl_stop( TRIM(clinfo), '   IO error with file '//TRIM(iom_file(kiomid)%name), ctmp1 )
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE iom_rstdimg_g123d
-
-
-   SUBROUTINE iom_rstdimg_rp123d( kiomid, cdvar, kvid, pv_r1d, pv_r2d, pv_r3d )
-      !!--------------------------------------------------------------------
-      !!                   ***  SUBROUTINE  iom_rstdimg_rstput  ***
-      !!
-      !! ** Purpose : write a 2D/3D variable with RSTDIMG
-      !!--------------------------------------------------------------------
-      INTEGER                         , INTENT(in)           ::   kiomid   ! Identifier of the file 
-      CHARACTER(len=*)                , INTENT(in)           ::   cdvar    ! time axis name
-      INTEGER                         , INTENT(in)           ::   kvid     ! variable id
-      REAL(wp), DIMENSION(          :), INTENT(in), OPTIONAL ::   pv_r1d   ! written 1d field
-      REAL(wp), DIMENSION(:  ,:      ), INTENT(in), OPTIONAL ::   pv_r2d   ! written 2d field
-      REAL(wp), DIMENSION(:  ,:  ,:  ), INTENT(in), OPTIONAL ::   pv_r3d   ! written 3d field
-      !
-      CHARACTER(LEN=100)    ::   clinfo               ! info character
-      INTEGER               ::   irecl8               ! reacord length
-      INTEGER               ::   ios                  ! IO status
-      INTEGER               ::   idrst                ! reacord length
-      INTEGER               ::   inx, iny, inz        ! x,y,z dimension of the variable
-      INTEGER               ::   idvar                ! variable id
-      INTEGER               ::   istop                ! temporary storage of nstop
-      INTEGER               ::   irec                 ! record number
-      INTEGER               ::   ix1, ix2, iy1, iy2   ! subdomain indexes
-      INTEGER               ::   jk                   ! loop counter
-      !---------------------------------------------------------------------
-      !
-      clinfo = '          iom_rstdimg_rp123d, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
-      istop = nstop                   ! store the actual value of nstop
-      irec = iom_file(kiomid)%irec    ! get back the record number of the variable
-      idrst = iom_file(kiomid)%nfid   ! get back the logical unit of the restart file
-      IF( kvid <= 0 ) THEN   !   new variable
-         idvar = iom_file(kiomid)%nvars + 1
-      ELSE                   !   the variable already exists in the file
-         idvar = kvid
-      ENDIF
-      IF( idvar > jpmax_vars )   CALL ctl_stop( TRIM(clinfo), 'increase the value of jpmax_vars' )
-      IF( .NOT. PRESENT(pv_r1d) ) THEN
-         ! find which part of data must be written
-         READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8, inx, iny, inz
-         IF(     inx == (nlei - nldi + 1) .AND. iny == (nlej - nldj + 1) ) THEN
-            ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
-         ELSEIF( inx == nlci              .AND. iny == nlcj              ) THEN
-            ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
-         ELSEIF( inx == jpi               .AND. iny == jpj               ) THEN
-            ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
-         ELSE 
-            CALL ctl_stop( clinfo, 'should have been an impossible case...' )
-         ENDIF
-      ENDIF
-      IF( istop == nstop ) THEN
-         ! write the data
-         IF(     PRESENT(pv_r1d) ) THEN   ! 1D variable
-            WRITE( idrst, REC = irec            , IOSTAT = ios, ERR = 987 ) pv_r1d(:)
-         ELSEIF( PRESENT(pv_r2d) ) THEN   ! 2D variable
-            WRITE( idrst, REC = irec            , IOSTAT = ios, ERR = 987 ) pv_r2d(ix1:ix2, iy1:iy2    )
-         ELSEIF( PRESENT(pv_r3d) ) THEN   ! 3D variable
-            DO jk = 1, jpk   ! do loop on each level
-               WRITE( idrst, REC = irec + jk - 1, IOSTAT = ios, ERR = 987 ) pv_r3d(ix1:ix2, iy1:iy2, jk)
-            END DO
-         ENDIF
-         ! fill the file informations
-         iom_file(kiomid)%nvars = idvar
-         IF(     PRESENT(pv_r1d) ) THEN
-            iom_file(kiomid)%irec              = irec + 1
-            iom_file(kiomid)%ndims(     idvar) = 1
-            iom_file(kiomid)%dimsz(1  , idvar) = inz
-         ELSEIF( PRESENT(pv_r2d) ) THEN
-            iom_file(kiomid)%irec              = irec + 1
-            iom_file(kiomid)%ndims(     idvar) = 2
-            iom_file(kiomid)%dimsz(1:2, idvar) = (/ inx, iny /)
-         ELSEIF( PRESENT(pv_r3d) ) THEN
-            iom_file(kiomid)%irec              = irec + inz
-            iom_file(kiomid)%ndims(     idvar) = 3
-            iom_file(kiomid)%dimsz(1:3, idvar) = (/ inx, iny, inz /)
-         ENDIF
-         iom_file(kiomid)%cn_var(idvar) = TRIM(cdvar)
-         iom_file(kiomid)%nvid(  idvar) = irec
-         iom_file(kiomid)%luld(  idvar) = .FALSE.
-         iom_file(kiomid)%scf(   idvar) = 1.
-         iom_file(kiomid)%ofs(   idvar) = 0.
-      ENDIF
-987   CONTINUE
-      IF( ios /= 0 ) THEN
-         WRITE(ctmp1,*) '           iostat = ', ios
-         CALL ctl_stop( TRIM(clinfo), '   IO error with file '//TRIM(iom_file(kiomid)%name), ctmp1 )
-      ELSE
-         IF(lwp) WRITE(numout,*) TRIM(clinfo)//' written ok'
-      ENDIF
-      !     
-   END SUBROUTINE iom_rstdimg_rp123d
-
-
-   !!======================================================================
-END MODULE iom_rstdimg
Index: branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 7349)
+++ branches/2016/dev_INGV_UKMO_2016/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 7351)
@@ -27,5 +27,6 @@
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O module
-
+   USE diurnal_bulk
+   
    IMPLICIT NONE
    PRIVATE
@@ -37,5 +38,4 @@
 
    !! * Substitutions
-#  include "domzgr_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
@@ -95,6 +95,4 @@
                WRITE(numout,*)
                SELECT CASE ( jprstlib )
-               CASE ( jprstdimg )   ;   WRITE(numout,*)                            &
-                   '             open ocean restart binary file: ',TRIM(clpath)//clname
                CASE DEFAULT         ;   WRITE(numout,*)                            &
                    '             open ocean restart NetCDF file: ',TRIM(clpath)//clname
@@ -126,7 +124,7 @@
       !!----------------------------------------------------------------------
 
-                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       )   ! dynamics time step
-                     CALL iom_rstput( kt, nitrst, numrow, 'rdttra1', rdttra(1) )   ! surface tracer time step
-
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       )   ! dynamics and tracer time step
+
+      IF ( .NOT. ln_diurnal_only ) THEN
                      CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub        )     ! before fields
                      CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb        )
@@ -141,4 +139,20 @@
                      CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn      )
                      CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      )
+
+                  ! extra variable needed for the ice sheet coupling
+                  IF ( ln_iscpl ) THEN 
+                     CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask     ) ! need to extrapolate T/S
+                     CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask     ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask     ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask    ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:) )   ! need to compute temperature correction
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3u_n', e3u_n(:,:,:) )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3v_n', e3v_n(:,:,:) )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n(:,:,:) ) ! need to compute extrapolation if vvl
+                  END IF
+      ENDIF
+      
+      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst    )  
+
       IF( kt == nitrst ) THEN
          CALL iom_close( numrow )     ! close the restart file (only at last time step)
@@ -175,5 +189,4 @@
             SELECT CASE ( jprstlib )
             CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
-            CASE ( jprstdimg )   ;   WRITE(numout,*) 'rst_read : read oce binary restart file'
             END SELECT
             IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
@@ -183,10 +196,4 @@
          clpath = TRIM(cn_ocerst_indir)
          IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-         IF ( jprstlib == jprstdimg ) THEN
-           ! eventually read netcdf file (monobloc)  for restarting on different number of processors
-           ! if {cn_ocerst_in}.nc exists, then set jlibalt to jpnf90
-           INQUIRE( FILE = TRIM(cn_ocerst_indir)//'/'//TRIM(cn_ocerst_in)//'.nc', EXIST = llok )
-           IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
-         ENDIF
          CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
       ENDIF
@@ -202,7 +209,6 @@
       !! ** Method  :   Read in restart.nc file fields which are necessary for restart
       !!----------------------------------------------------------------------
-      REAL(wp) ::   zrdt, zrdttra1
+      REAL(wp) ::   zrdt
       INTEGER  ::   jk
-      LOGICAL  ::   llok
       !!----------------------------------------------------------------------
 
@@ -214,9 +220,15 @@
          IF( zrdt /= rdt )   neuler = 0
       ENDIF
-      IF( iom_varid( numror, 'rdttra1', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'rdttra1', zrdttra1 )
-         IF( zrdttra1 /= rdttra(1) )   neuler = 0
-      ENDIF
-      ! 
+
+      ! Diurnal DSST 
+      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst  ) 
+      IF ( ln_diurnal_only ) THEN 
+         IF(lwp) WRITE( numout, * ) &
+         &   "rst_read:- ln_diurnal_only set, setting rhop=rau0" 
+         rhop = rau0
+         CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,1,jp_tem) ) 
+         RETURN 
+      ENDIF  
+      
       IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
          CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub      )   ! before fields
@@ -237,5 +249,5 @@
          CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop    )   ! now    potential density
       ELSE
-         CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )   
+         CALL eos( tsn, rhd, rhop, gdept_n(:,:,:) )   
       ENDIF
       !
@@ -246,7 +258,7 @@
          sshb (:,:)     = sshn (:,:)
          !
-         IF( lk_vvl ) THEN
+         IF( .NOT.ln_linssh ) THEN
             DO jk = 1, jpk
-               fse3t_b(:,:,jk) = fse3t_n(:,:,jk)
+               e3t_b(:,:,jk) = e3t_n(:,:,jk)
             END DO
          ENDIF
