Index: /codes/icosagcm/trunk/make_icosa
===================================================================
--- /codes/icosagcm/trunk/make_icosa	(revision 487)
+++ /codes/icosagcm/trunk/make_icosa	(revision 488)
@@ -18,4 +18,5 @@
 external_ioipsl="FALSE"
 external_physics="FALSE"
+no_io_defined="FALSE"
 
 CPP_KEY="CPP_NONE" 
@@ -63,5 +64,8 @@
       "-with_xios")
 	  with_xios_defined="TRUE" ; shift ;;
-
+  
+        "-no_io")
+	  no_io_defined="TRUE" ; shift ;;
+  
       "-external_ioipsl")
 	  external_ioipsl="TRUE" ; shift ;;
@@ -141,4 +145,10 @@
 fi
 
+if [[ "$no_io_defined" == "TRUE" ]]
+then
+  CPP_KEY="$CPP_KEY CPP_NO_IO"
+  with_xios_defined="FALSE"
+fi  
+
 if [[ "$with_xios_defined" == "TRUE" ]]
 then
@@ -164,10 +174,13 @@
 fi
 
-ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
-
+if [[ "$no_io_defined" == "FALSE" ]]
+then 
+  ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
+  COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR"
+fi
 
 rm -f config.fcm
 
-echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm
+echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
 echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
 echo "%CPP_KEY $CPP_KEY" >> config.fcm
Index: /codes/icosagcm/trunk/src/disvert.f90
===================================================================
--- /codes/icosagcm/trunk/src/disvert.f90	(revision 487)
+++ /codes/icosagcm/trunk/src/disvert.f90	(revision 488)
@@ -192,5 +192,7 @@
     INTEGER :: ncid,levid,ilevid,hyaiid,hybiid,hyamid,hybmid,P0id
     INTEGER :: l
-
+    
+    IF (no_io) RETURN
+    
 !$OMP BARRIER
 !$OMP MASTER    
Index: /codes/icosagcm/trunk/src/netcdf_mod.F90
===================================================================
--- /codes/icosagcm/trunk/src/netcdf_mod.F90	(revision 487)
+++ /codes/icosagcm/trunk/src/netcdf_mod.F90	(revision 488)
@@ -1,4 +1,9 @@
 MODULE netcdf_mod
+
+#ifndef CPP_NO_IO
+
   USE netcdf
+  LOGICAL,PARAMETER :: no_io = .FALSE.
+
 #ifndef CPP_NETCDF4
   INTEGER ::  NF90_NETCDF4
@@ -28,2 +33,203 @@
    END
 #endif
+
+
+#else
+
+  LOGICAL,PARAMETER :: no_io = .TRUE.
+
+  INTEGER ::  NF90_NETCDF4
+  INTEGER ::  NF90_MPIIO
+  INTEGER ::  NF90_CHUNKED
+  
+  INTEGER,EXTERNAL :: NF90_CREATE_PAR
+  INTEGER,EXTERNAL :: NF90_DEF_VAR_CHUNKING 
+  INTEGER,EXTERNAL :: NF90_CREATE
+  INTEGER,EXTERNAL ::  NF90_DEF_DIM
+  INTEGER,EXTERNAL :: NF90_PUT_ATT
+  INTEGER,EXTERNAL :: NF90_ENDDEF  
+  INTEGER,EXTERNAL :: NF90_CLOSE
+  INTEGER,EXTERNAL :: NF90_SYNC
+  INTEGER,EXTERNAL :: NF90_OPEN
+  INTEGER,EXTERNAL :: NF90_INQ_VARID
+  INTEGER,EXTERNAL :: NF90_GET_ATT
+  
+  INTEGER ::  NF90_NOWRITE  
+  INTEGER :: NF90_CLOBBER
+  INTEGER ::  NF90_UNLIMITED
+  INTEGER :: NF90_DOUBLE
+  INTEGER :: NF90_FLOAT
+  INTEGER :: NF90_GLOBAL
+  
+  INTERFACE nf90_put_var
+    MODULE PROCEDURE   nf90_put_var_int0, nf90_put_var_int1, nf90_put_var_int2, nf90_put_var_int3,&
+                                                 nf90_put_var_real0, nf90_put_var_real1, nf90_put_var_real2, nf90_put_var_real3
+  END INTERFACE nf90_put_var
+
+  INTERFACE nf90_get_var
+    MODULE PROCEDURE   nf90_get_var_int0, nf90_get_var_int1, nf90_get_var_int2, nf90_get_var_int3,&
+                                                 nf90_get_var_real0, nf90_get_var_real1, nf90_get_var_real2, nf90_get_var_real3
+  END INTERFACE nf90_get_var
+  
+ CONTAINS
+   
+   function nf90_def_var(ncid, name, xtype, dimids, varid)
+        integer,                         intent( in) :: ncid
+        character (len = *),             intent( in) :: name
+        integer,                         intent( in) :: xtype
+        integer, dimension(:), optional, intent( in) :: dimids
+        integer,                         intent(out) :: varid
+        integer                                      :: nf90_def_var
+    end function nf90_def_var
+    
+    
+    function nf90_put_var_int0(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( in) :: values
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_int0
+    end function nf90_put_var_int0
+
+    function nf90_put_var_int1(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( in) :: values(:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_int1
+    end function nf90_put_var_int1
+
+    function nf90_put_var_int2(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( in) :: values(:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_int2
+    end function nf90_put_var_int2
+
+    function nf90_put_var_int3(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( in) :: values(:,:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_int3
+    end function nf90_put_var_int3
+    
+    function nf90_put_var_real0(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( in) :: values
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_real0   
+   end function nf90_put_var_real0
+
+    function nf90_put_var_real1(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( in) :: values(:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_real1   
+   end function nf90_put_var_real1
+
+    function nf90_put_var_real2(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( in) :: values(:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_real2   
+   end function nf90_put_var_real2
+
+    function nf90_put_var_real3(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( in) :: values(:,:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_put_var_real3   
+   end function nf90_put_var_real3
+ 
+ 
+     function nf90_get_var_int0(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( out) :: values
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_int0
+    end function nf90_get_var_int0
+
+    function nf90_get_var_int1(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( out) :: values(:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_int1
+    end function nf90_get_var_int1
+
+    function nf90_get_var_int2(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( out) :: values(:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_int2
+    end function nf90_get_var_int2
+
+    function nf90_get_var_int3(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        integer,                          intent( out) :: values(:,:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_int3
+    end function nf90_get_var_int3
+    
+    function nf90_get_var_real0(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( out) :: values
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_real0   
+   end function nf90_get_var_real0
+
+    function nf90_get_var_real1(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( out) :: values(:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_real1   
+   end function nf90_get_var_real1
+
+    function nf90_get_var_real2(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( out) :: values(:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_real2   
+   end function nf90_get_var_real2
+
+    function nf90_get_var_real3(ncid, varid, values, start, count, stride, map)
+        integer,                         intent( in) :: ncid, varid
+        real,                              intent( out) :: values(:,:,:)
+        integer, dimension(:), optional, intent( in) :: start, count, stride, map
+        integer                                      :: nf90_get_var_real3   
+   end function nf90_get_var_real3
+  
+END MODULE netcdf_mod
+
+  SUBROUTINE NF90_CREATE_PAR
+  END
+  
+ SUBROUTINE NF90_DEF_VAR_CHUNKING 
+ END
+ 
+ SUBROUTINE NF90_CREATE
+ END
+ 
+ SUBROUTINE  NF90_DEF_DIM
+ END
+ 
+ SUBROUTINE NF90_PUT_ATT
+ END
+ 
+ SUBROUTINE NF90_ENDDEF 
+ END
+  
+ SUBROUTINE NF90_CLOSE
+ END
+ 
+ SUBROUTINE NF90_SYNC
+ END
+ 
+ SUBROUTINE NF90_OPEN
+ END
+ 
+ SUBROUTINE NF90_INQ_VARID
+ END
+ 
+ SUBROUTINE NF90_GET_ATT
+ END
+
+#endif
+
Index: /codes/icosagcm/trunk/src/restart.f90
===================================================================
--- /codes/icosagcm/trunk/src/restart.f90	(revision 487)
+++ /codes/icosagcm/trunk/src/restart.f90	(revision 488)
@@ -70,4 +70,6 @@
   REAL(rstd),ALLOCATABLE :: lon(:),lat(:),bounds_lon(:,:),bounds_lat(:,:)
    
+    IF (no_io) RETURN
+    
     restart_file_name="restart"
     CALL getin("restart_file_name",restart_file_name)
@@ -419,4 +421,7 @@
   REAL(rstd),ALLOCATABLE :: lon(:),lat(:),bounds_lon(:,:),bounds_lat(:,:)
   REAL(rstd) :: it_temp(1)
+  
+    IF (no_io) RETURN
+    
     start_file_name="start"
     CALL getin("start_file_name",start_file_name)
Index: /codes/icosagcm/trunk/src/time.f90
===================================================================
--- /codes/icosagcm/trunk/src/time.f90	(revision 487)
+++ /codes/icosagcm/trunk/src/time.f90	(revision 488)
@@ -105,9 +105,10 @@
   CHARACTER(LEN=255) :: time_frequency
 
+  IF (no_io) RETURN
   CALL getin("dt",dt)
 
 !$OMP BARRIER
 !$OMP MASTER  
-    IF (is_mpi_root) THEN 
+    IF (is_mpi_root ) THEN 
       status = NF90_CREATE('time_counter.nc', NF90_CLOBBER, ncid)
       status = NF90_DEF_DIM(ncid,'time_counter',NF90_UNLIMITED,timeid)
@@ -141,4 +142,6 @@
   REAL(rstd) ::time_array(1)
 
+  IF (no_io) RETURN
+
 !$OMP BARRIER
 !$OMP MASTER
@@ -160,4 +163,6 @@
   IMPLICIT NONE
     INTEGER :: status
+
+    IF (no_io) RETURN
     
 !$OMP BARRIER
Index: /codes/icosagcm/trunk/src/write_field.f90
===================================================================
--- /codes/icosagcm/trunk/src/write_field.f90	(revision 487)
+++ /codes/icosagcm/trunk/src/write_field.f90	(revision 488)
@@ -27,4 +27,5 @@
       use netcdf_mod
       CHARACTER(LEN=255) :: netcdf_prec
+      
       !$OMP CRITICAL
       netcdf_prec='float'
@@ -68,4 +69,5 @@
     USE dimensions
     USE mpipara
+    USE netcdf_mod
     IMPLICIT NONE  
      CHARACTER(LEN=*),INTENT(IN) :: name_in
@@ -76,5 +78,7 @@
       
       TYPE(t_field),POINTER :: field_glo(:)
-
+      
+      IF (no_io) RETURN
+      
 !$OMP BARRIER
 !$OMP MASTER      
@@ -1777,5 +1781,5 @@
    
    SUBROUTINE Close_files
-   USE netcdf
+   USE netcdf_mod
    IMPLICIT NONE
      INTEGER :: i,k,status
Index: des/icosagcm/trunk/tools/ioipsl/flincom.f90
===================================================================
--- /codes/icosagcm/trunk/tools/ioipsl/flincom.f90	(revision 487)
+++ 	(revision )
@@ -1,1939 +1,0 @@
-MODULE flincom
-!-
-!$Id: flincom.f90 427 2008-10-16 07:55:13Z bellier $
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!---------------------------------------------------------------------
-  USE netcdf
-!-
-  USE calendar,  ONLY : ju2ymds, ymds2ju, ioconf_calendar
-  USE errioipsl, ONLY : histerr
-  USE stringop,  ONLY : strlowercase
-!-
-  IMPLICIT NONE
-!-
-  PRIVATE
-  PUBLIC :: flinput, flincre, flinget, flinclo, &
-            flinopen, flininfo, flininspect, flinquery_var
-!-
-  INTERFACE flinopen
-!---------------------------------------------------------------------
-!- The "flinopen" routines will open an input file
-!-
-!- INPUT
-!-
-!- filename  : Name of the netCDF file to be opened
-!-
-!- iideb     : index i for zoom     !
-!- iilen     : length  of  zoom     !   for
-!- jjdeb     : index j for zoom     !   zoom
-!- jjlen     : length  of  zoom     !
-!-
-!- do_test   : A flag that enables the testing of the content
-!-             of the file against the input from the model
-!-
-!- INPUT if do_test=TRUE      OUTPUT else
-!-
-!- iim       : size in the x direction in the file (longitude)
-!- jjm       : size in the y direction
-!- llm       : number of levels
-!-             (llm = 0 means no axis to be expected)
-!- lon       : array of (iilen,jjlen) (zoom), or (iim,jjm) (no zoom),
-!-             that contains the longitude of each point
-!- lat       : same for latitude
-!- lev       : An array of llm for the latitude
-!-
-!- WARNING :
-!- In the case of do_test=FALSE it is for the user to check
-!- that the dimensions of lon lat and lev are correct when passed to
-!- flinopen. This can be done after the call when iim and jjm have
-!- been retrieved from the netCDF file. In F90 this problem will
-!- be solved with an internal assign
-!- IF iim, jjm, llm or ttm are parameters in the calling program and
-!- you use the option do_test=FALSE it will create a segmentation fault
-!-
-!-  OUTPUT
-!-
-!-  ttm       : size of time axis
-!-  itaus     : Time steps within this file
-!-  date0     : Julian date at which itau = 0
-!-  dt        : length of the time steps of the data
-!-  fid       : returned file ID which is later used to read the data
-!---------------------------------------------------------------------
-    MODULE PROCEDURE flinopen_zoom2d, flinopen_nozoom
-  END INTERFACE
-!-
-  INTERFACE flinput
-!---------------------------------------------------------------------
-!- The "flinput" routines will put a variable
-!- on the netCDF file created by flincre.
-!- If the sizes of the axis do not match the one of the IDs
-!- then a new axis is created.
-!- That is we loose the possibility of writting hyperslabs of data.
-!-
-!- Again here if iim = jjm = llm = ttm = 0
-!- then a global attribute is added to the file.
-!-
-!- INPUT
-!-
-!- fid      : Identification of the file in which we will write
-!- varname  : Name of variable to be written
-!- iim      : size in x of variable
-!- nlonid   : ID of x axis which could fit for this axis
-!- jjm      : size in y of variable
-!- nlatid   : ID of y axis which could fit for this axis
-!- llm      : size in z of variable
-!- zdimid   : ID of z axis which could fit for this axis
-!- ttm      : size in t of variable
-!- tdimid   : ID of t axis which could fit for this axis
-!-
-!- OUTPUT
-!-
-!- NONE
-!---------------------------------------------------------------------
-    MODULE PROCEDURE flinput_r4d, flinput_r3d, flinput_r2d, &
-                     flinput_r1d, flinput_scal
-  END INTERFACE
-!-
-  INTERFACE flinget
-    MODULE PROCEDURE flinget_r4d, flinget_r3d, flinget_r2d, &
-                     flinget_r1d, flinget_scal, &
-                     flinget_r4d_zoom2d, flinget_r3d_zoom2d, &
-                     flinget_r2d_zoom2d
-  END INTERFACE
-!-
-! This is the data we keep on each file we open
-!-
-  INTEGER, PARAMETER :: nbfile_max = 200
-  INTEGER, SAVE :: nbfiles = 0
-  INTEGER, SAVE :: ncids(nbfile_max), ncnbd(nbfile_max), &
-                   ncfunli(nbfile_max), ncnba(nbfile_max)
-  INTEGER, SAVE :: ncnbva(nbfile_max), ncdims(nbfile_max,4)
-  LOGICAL, SAVE :: ncfileopen(nbfile_max)=.FALSE.
-!-
-  INTEGER, SAVE :: cind_vid, cind_fid, cind_len
-  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: cindex
-!-
-  INTEGER,DIMENSION(4) :: w_sta, w_len, w_dim
-!-
-CONTAINS
-!-
-!===
-!-
-SUBROUTINE flincre &
-  (filename, iim1, jjm1, lon1, lat1, llm1, lev1, ttm1, itaus, &
-   time0, dt, fid_out, nlonid1, nlatid1, zdimid1, tdimid1)
-!---------------------------------------------------------------------
-!- This is a "low level" subroutine for opening netCDF files wich
-!- contain the major coordinate system of the model.
-!- Other coordinates needed for other variables
-!- will be added as they are needed.
-!-
-!- INPUT
-!-
-!- filename    : Name of the file to be created
-!- iim1, jjm1  : Horizontal size of the grid
-!-               which will be stored in the file
-!- lon1, lat1  : Horizontal grids
-!- llm1        : Size of the vertical grid
-!- lev1        : Vertical grid
-!- ttm1        : Size of time axis
-!- itaus       : time steps on the time axis
-!- time0       : Time in julian days at which itau = 0
-!- dt          : time step in seconds between itaus
-!-               (one step of itau)
-!-
-!- OUTPUT
-!-
-!- fid         : File identification
-!- nlonid1     : Identification of longitudinal axis
-!- nlatid1     : Identification of latitudinal axis
-!- zdimid1     : ID of vertical axis
-!- tdimid1     : ID of time axis
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  CHARACTER(LEN=*) :: filename
-  INTEGER :: iim1, jjm1, llm1, ttm1
-  REAL :: lon1(iim1,jjm1)
-  REAL :: lat1(iim1,jjm1)
-  REAL :: lev1(llm1)
-  INTEGER :: itaus(ttm1)
-  REAL :: time0
-  REAL :: dt
-  INTEGER :: fid_out, zdimid1, nlonid1, nlatid1, tdimid1
-!-
-! LOCAL
-!-
-  INTEGER :: iret, lll, fid
-  INTEGER :: lonid, latid, levid, timeid
-  INTEGER :: year, month, day
-  REAL :: sec
-  CHARACTER(LEN=250):: name
-!-
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  lll = LEN_TRIM(filename)
-  IF (filename(lll-2:lll) /= '.nc') THEN
-    name=filename(1:lll)//'.nc'
-  ELSE
-    name=filename(1:lll)
-  ENDIF
-!-
-  iret = NF90_CREATE (name, NF90_CLOBBER, fid)
-!-
-  iret = NF90_DEF_DIM (fid, 'x',     iim1, nlonid1)
-  iret = NF90_DEF_DIM (fid, 'y',     jjm1, nlatid1)
-  iret = NF90_DEF_DIM (fid, 'lev',   llm1, zdimid1)
-  iret = NF90_DEF_DIM (fid, 'tstep', ttm1, tdimid1)
-!-
-! Vertical axis
-!-
-  IF (check) WRITE(*,*) 'flincre Vertical axis'
-!-
-  iret = NF90_DEF_VAR (fid, 'lev', NF90_FLOAT, zdimid1, levid)
-  iret = NF90_PUT_ATT (fid, levid, 'units',     '-')
-  iret = NF90_PUT_ATT (fid, levid, 'title',     'levels')
-  iret = NF90_PUT_ATT (fid, levid, 'long_name', 'Sigma Levels')
-!-
-! Time axis
-!-
-  IF (check) WRITE(*,*) 'flincre time axis'
-!-
-  iret = NF90_DEF_VAR (fid, 'tstep', NF90_FLOAT, tdimid1, timeid)
-  iret = NF90_PUT_ATT (fid, timeid, 'units',     '-')
-  iret = NF90_PUT_ATT (fid, timeid, 'title',     'time')
-  iret = NF90_PUT_ATT (fid, timeid, 'long_name', 'time steps')
-!-
-! The longitude
-!-
-  IF (check) WRITE(*,*) 'flincre Longitude axis'
-!-
-  iret = NF90_DEF_VAR (fid, "nav_lon", NF90_FLOAT, &
-                       (/ nlonid1, nlatid1 /), lonid)
-  iret = NF90_PUT_ATT (fid, lonid, 'units', "degrees_east")
-  iret = NF90_PUT_ATT (fid, lonid, 'title', "Longitude")
-  iret = NF90_PUT_ATT (fid, lonid, 'nav_model', &
-                       "Lambert projection of PROMES")
-  iret = NF90_PUT_ATT (fid, lonid, 'valid_min', &
-                       REAL(MINVAL(lon1),KIND=4))
-  iret = NF90_PUT_ATT (fid, lonid, 'valid_max', &
-                       REAL(MAXVAL(lon1),KIND=4))
-!-
-! The Latitude
-!-
-  IF (check) WRITE(*,*) 'flincre Latitude axis'
-!-
-  iret = NF90_DEF_VAR (fid, "nav_lat", NF90_FLOAT, &
-                     (/ nlonid1, nlatid1 /), latid)
-  iret = NF90_PUT_ATT (fid, latid, 'units', "degrees_north")
-  iret = NF90_PUT_ATT (fid, latid, 'title', "Latitude")
-  iret = NF90_PUT_ATT (fid, latid, 'nav_model', &
-                       "Lambert projection of PROMES")
-  iret = NF90_PUT_ATT (fid, latid, 'valid_min', &
-                       REAL(MINVAL(lat1),KIND=4))
-  iret = NF90_PUT_ATT (fid, latid, 'valid_max', &
-                       REAL(MAXVAL(lat1),KIND=4))
-!-
-! The time coordinates
-!-
-  iret = NF90_PUT_ATT (fid, NF90_GLOBAL, 'delta_tstep_sec', &
-                       REAL(dt,KIND=4))
-!-
-  CALL ju2ymds (time0, year, month, day, sec)
-!-
-  iret = NF90_PUT_ATT (fid, NF90_GLOBAL, 'year0',  REAL(year,KIND=4))
-  iret = NF90_PUT_ATT (fid, NF90_GLOBAL, 'month0', REAL(month,KIND=4))
-  iret = NF90_PUT_ATT (fid, NF90_GLOBAL, 'day0',   REAL(day,KIND=4))
-  iret = NF90_PUT_ATT (fid, NF90_GLOBAL, 'sec0',   REAL(sec,KIND=4))
-!-
-  iret = NF90_ENDDEF (fid)
-!-
-  IF (check) WRITE(*,*) 'flincre Variable'
-!-
-  iret = NF90_PUT_VAR (fid, levid, lev1(1:llm1))
-!-
-  IF (check) WRITE(*,*) 'flincre Time Variable'
-!-
-  iret = NF90_PUT_VAR (fid, timeid, REAL(itaus(1:ttm1)))
-!-
-  IF (check) WRITE(*,*) 'flincre Longitude'
-!-
-  iret = NF90_PUT_VAR (fid, lonid, lon1(1:iim1,1:jjm1))
-!-
-  IF (check) WRITE(*,*) 'flincre Latitude'
-!-
-  iret = NF90_PUT_VAR (fid, latid, lat1(1:iim1,1:jjm1))
-!-
-! Keep all this information
-!-
-  nbfiles = nbfiles+1
-!-
-  IF (nbfiles > nbfile_max) THEN
-    CALL histerr (3,'flincre', &
-     'Too many files. Please increase nbfil_max', &
-     'in program flincom.F90.',' ')
-  ENDIF
-!-
-  ncids(nbfiles) = fid
-  ncnbd(nbfiles) = 4
-!-
-  ncdims(nbfiles,1:4) = (/ iim1, jjm1, llm1, ttm1 /)
-!-
-  ncfunli(nbfiles) = -1
-  ncnba(nbfiles)   =  4
-  ncnbva(nbfiles)  =  0
-  ncfileopen(nbfiles) = .TRUE.
-!-
-  fid_out = nbfiles
-!---------------------
-END SUBROUTINE flincre
-!-
-!===
-!-
-SUBROUTINE flinopen_zoom2d &
-  (filename, iideb, iilen, jjdeb, jjlen, do_test, &
-  iim, jjm, llm, lon, lat, lev, ttm, itaus, date0, dt, fid_out)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  CHARACTER(LEN=*) :: filename
-  LOGICAL :: do_test
-  INTEGER :: iim, jjm, llm, ttm, iideb, iilen, jjdeb, jjlen
-  REAL :: lon(iilen,jjlen), lat(iilen,jjlen), lev(llm)
-  INTEGER :: itaus(ttm)
-  REAL :: date0, dt
-  INTEGER :: fid_out
-!-
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (check) WRITE (*,*) ' iideb, iilen, jjdeb, jjlen, iim, jjm ', &
-                           iideb, iilen, jjdeb, jjlen, iim, jjm
-  IF (check) WRITE (*,*) ' lon ', lon(1,1), lon(iilen,jjlen)
-  IF (check) WRITE (*,*) ' lat ', lat(1,1), lat(iilen,jjlen)
-!-
-  CALL flinopen_work &
-    (filename, iideb, iilen, jjdeb, jjlen, do_test, &
-     iim, jjm, llm, lon, lat, lev, ttm, itaus, date0, dt, fid_out)
-!-----------------------------
-END SUBROUTINE flinopen_zoom2d
-!-
-!===
-!-
-SUBROUTINE flinopen_nozoom &
-  (filename, do_test, iim, jjm, llm, lon, lat, lev, ttm, &
-   itaus, date0, dt, fid_out)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  CHARACTER(LEN=*) :: filename
-  LOGICAL :: do_test
-  INTEGER :: iim, jjm, llm, ttm
-  REAL :: lon(iim,jjm), lat(iim,jjm), lev(llm)
-  INTEGER :: itaus(ttm)
-  REAL :: date0, dt
-  INTEGER :: fid_out
-!---------------------------------------------------------------------
-  CALL flinopen_work &
-    (filename, 1, iim, 1, jjm, do_test, &
-     iim, jjm, llm, lon, lat, lev, ttm, itaus, date0, dt, fid_out)
-!-------------------------
-END SUBROUTINE flinopen_nozoom
-!-
-!===
-!-
-SUBROUTINE flinopen_work &
-  (filename, iideb, iilen, jjdeb, jjlen, do_test, &
-   iim, jjm, llm, lon, lat, lev, ttm, itaus, date0, dt, fid_out)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  CHARACTER(LEN=*) :: filename
-  LOGICAL :: do_test
-  INTEGER :: iim, jjm, llm, ttm, iideb, iilen, jjdeb, jjlen
-  REAL :: lon(iilen,jjlen), lat(iilen,jjlen), lev(llm)
-  INTEGER :: itaus(ttm)
-  REAL :: date0, dt
-  INTEGER :: fid_out
-!-
-! LOCAL
-!-
-  REAL, PARAMETER :: eps = 1.e-4
-!-
-  INTEGER :: iret, vid, fid, nbdim, i, iilast, jjlast
-  INTEGER :: gdtt_id, old_id, iv, gdtmaf_id
-  CHARACTER(LEN=250) :: name
-  CHARACTER(LEN=80) :: units, calendar
-  INTEGER :: tmp_iim, tmp_jjm, tmp_llm, tmp_ttm
-  REAL :: x_first, x_last
-  INTEGER :: year, month, day
-  REAL :: r_year, r_month, r_day
-  INTEGER :: year0, month0, day0, hours0, minutes0, seci
-  REAL :: sec, sec0
-  CHARACTER :: strc
-!-
-  REAL,DIMENSION(:),ALLOCATABLE :: vec_tmp
-!-
-  LOGICAL :: open_file
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  iilast = iideb+iilen-1
-  jjlast = jjdeb+jjlen-1
-  IF (check) WRITE (*,*) &
-    ' flinopen_work zoom 2D information '// &
-    ' iideb, iilen, iilast, jjdeb, jjlen, jjlast ', &
-      iideb, iilen, iilast, jjdeb, jjlen, jjlast
-!-
-! 1.0 get all infos on the file
-!-
-! Either the fid_out has not been initialized (0 or very large)
-! then we have to open anyway. Else we only need to open the file
-! if it has not been opened before.
-!-
-  IF ( (fid_out < 1).OR.(fid_out > nbfile_max) ) THEN
-    open_file = .TRUE.
-  ELSE IF (.NOT.ncfileopen(fid_out)) THEN
-    open_file = .TRUE.
-  ELSE
-    open_file = .FALSE.
-  ENDIF
-!-
-  IF (open_file) THEN
-    CALL flininfo (filename,tmp_iim,tmp_jjm,tmp_llm,tmp_ttm,fid_out)
-  ELSE
-!-- The user has already opened the file
-!-- and we trust that he knows the dimensions
-    tmp_iim = iim
-    tmp_jjm = jjm
-    tmp_llm = llm
-    tmp_ttm = ttm
-  ENDIF
-!-
-  IF (check) &
-    WRITE(*,*) 'OUT OF flininfo :',tmp_iim,tmp_jjm,tmp_llm,tmp_ttm
-!-
-  fid = ncids(fid_out)
-!-
-! 2.0 get the sizes and names of the different coordinates
-!     and do a first set of verification.
-!-
-! 2.2 We test the axis if we have to.
-!-
-  IF (check) &
-    WRITE(*,*) 'flininfo 2.2 We test if we have to test : ',do_test
-!-
-  IF (do_test) THEN
-    IF      (iim /= tmp_iim) THEN
-      CALL histerr (3,'flinopen', &
-        'file '//filename//' does not have the ', &
-        'required dimension in x direction (longitude)',' ')
-    ELSE IF (jjm /= tmp_jjm) THEN
-      CALL histerr (3,'flinopen', &
-        'file '//filename//' does not have the ', &
-        'required dimension in y direction (latitude)',' ')
-    ELSE IF ( llm /= tmp_llm .AND. llm > 0 ) THEN
-      CALL histerr (3,'flinopen', &
-        'file '//filename//' does not have the ', &
-        'required dimension in the vertical',' ')
-    ENDIF
-  ELSE
-!---
-!-- 2.3 Else the sizes of the axes are returned to the user
-!---
-    IF (check) WRITE(*,*) 'flinopen 2.3 Else sizes are returned'
-!---
-    iim = tmp_iim
-    jjm = tmp_jjm
-    llm = tmp_llm
-  ENDIF
-!-
-  ttm = tmp_ttm
-!-
-! 3.0 Check if we are realy talking about the same coodinate system
-!     if not then we get the lon, lat and lev variables from the file
-!-
-  IF (check) WRITE(*,*) 'flinopen 3.0 we are realy talking'
-!-
-  IF (do_test) THEN
-!---
-    CALL flinfindcood (fid_out, 'lon', vid, nbdim)
-    iret = NF90_GET_VAR (fid, vid, x_first, start=(/ iideb, jjdeb /))
-    iret = NF90_GET_VAR (fid, vid, x_last, start=(/ iilast, jjlast /))
-!---
-    IF (check) &
-      WRITE(*,*) 'from file lon first and last, modulo 360. ', &
-        x_first, x_last, MODULO(x_first,360.), MODULO(x_last,360.)
-    IF (check) &
-      WRITE(*,*) 'from model lon first and last, modulo 360. ', &
-        lon(1,1),lon(iilen,jjlen), &
-        MODULO(lon(1,1),360.), MODULO(lon(iilen,jjlen),360.)
-    IF (    (ABS( MODULO(x_first,360.) &
-                 -MODULO(lon(1,1),360.)) > eps) &
-        .OR.(ABS( MODULO(x_last,360.) &
-                 -MODULO(lon(iilen ,jjlen),360.)) > eps ) ) THEN
-      CALL histerr (3,'flinopen', &
-        'file '//filename//' and the model do not', &
-        'share the same longitude coordinate', &
-        'Obtained by comparing the first and last values ')
-    ENDIF
-!---
-    CALL flinfindcood (fid_out, 'lat', vid, nbdim)
-    iret = NF90_GET_VAR (fid, vid, x_first, start=(/ iideb, jjdeb /))
-    iret = NF90_GET_VAR (fid, vid, x_last, start=(/ iilast, jjlast /))
-!---
-    IF (check) WRITE(*,*) &
-      'from file lat first and last ',x_first,x_last
-    IF (check) WRITE(*,*) &
-      'from model lat first and last ',lat(1,1),lat(iilen,jjlen)
-!---
-    IF (    (ABS(x_first-lat(1,1)) > eps) &
-        .OR.(ABS(x_last-lat(iilen,jjlen)) > eps) ) THEN
-      CALL histerr (3,'flinopen', &
-        'file '//filename//' and the model do not', &
-        'share the same latitude coordinate', &
-        'Obtained by comparing the first and last values ')
-    ENDIF
-!---
-    IF (llm > 0) THEN
-      CALL flinfindcood (fid_out, 'lev', vid, nbdim)
-      iret = NF90_GET_VAR (fid, vid, x_first, start=(/ 1 /))
-      iret = NF90_GET_VAR (fid, vid, x_last, start=(/ llm /))
-!-----
-      IF (check) WRITE(*,*) &
-        'from file lev first and last ',x_first ,x_last
-      IF (check) WRITE(*,*) &
-        'from model lev first and last ',lev(1),lev(llm)
-!-----
-      IF (    (ABS(x_first-lev(1)) > eps) &
-          .OR.(ABS(x_last-lev(llm)) > eps) ) THEN
-        CALL histerr (3,'flinopen', &
-          'file '//filename//' and the model do not', &
-          'share the same vertical coordinate', &
-          'Obtained by comparing the first and last values')
-      ENDIF
-    ENDIF
-!---
-  ELSE
-!---
-!-- 4.0 extracting the coordinates if we do not check
-!---
-    IF (check) WRITE(*,*) 'flinopen 4.0 extracting the coordinates'
-!---
-    CALL flinfindcood (fid_out, 'lon', vid, nbdim)
-    IF (nbdim == 2) THEN
-      iret = NF90_GET_VAR (fid, vid, lon, &
-               start=(/ iideb, jjdeb /), count=(/ iilen, jjlen /))
-    ELSE
-      ALLOCATE(vec_tmp(iilen))
-      iret = NF90_GET_VAR (fid, vid, vec_tmp, &
-               start=(/ iideb /), count=(/ iilen /))
-      DO i=1,jjlen
-        lon(:,i) = vec_tmp(:)
-      ENDDO
-      DEALLOCATE(vec_tmp)
-    ENDIF
-!---
-    CALL flinfindcood (fid_out, 'lat', vid, nbdim)
-    IF (nbdim == 2) THEN
-      iret = NF90_GET_VAR (fid, vid, lat, &
-               start=(/ iideb, jjdeb /), count=(/ iilen, jjlen /))
-    ELSE
-      ALLOCATE(vec_tmp(jjlen))
-      iret = NF90_GET_VAR (fid, vid, vec_tmp, &
-               start=(/ jjdeb /), count=(/ jjlen /))
-      DO i=1,iilen
-        lat(i,:) = vec_tmp(:)
-      ENDDO
-      DEALLOCATE(vec_tmp)
-    ENDIF
-!---
-    IF (llm > 0) THEN
-      CALL flinfindcood (fid_out, 'lev', vid, nbdim)
-      IF (nbdim == 1) THEN
-        iret = NF90_GET_VAR (fid, vid, lev, &
-                 start=(/ 1 /), count=(/ llm /))
-      ELSE
-        CALL histerr (3,'flinopen', &
-          'Can not handle vertical coordinates that have more',&
-          'than 1 dimension',' ')
-      ENDIF
-    ENDIF
-  ENDIF
-!-
-! 5.0 Get all the details for the time if possible needed
-!-
-  IF (check) WRITE(*,*) 'flinopen 5.0 Get time'
-!-
-  IF (ttm > 0) THEN
-!---
-!-- 5.1 Find the time axis. Prefered method is the 'timestep since'
-!---
-    gdtmaf_id = -1
-    gdtt_id = -1
-    old_id = -1
-    DO iv=1,ncnbva(fid_out)
-      name=''
-      iret = NF90_INQUIRE_VARIABLE (fid, iv, name=name)
-      units=''
-      iret = NF90_GET_ATT (fid, iv, 'units', units)
-      IF (INDEX(units,'seconds since') > 0) gdtmaf_id = iv
-      IF (INDEX(units,'timesteps since') > 0) gdtt_id = iv
-      IF (INDEX(name, 'tstep') > 0) old_id = iv
-    ENDDO
-!---
-    IF (gdtt_id > 0) THEN
-      vid = gdtt_id
-    ELSE IF (gdtmaf_id > 0) THEN
-      vid = gdtmaf_id
-    ELSE IF (old_id > 0) THEN
-      vid = old_id
-    ELSE
-      CALL histerr (3, 'flinopen', 'No time axis found',' ',' ')
-    ENDIF
-!---
-    ALLOCATE(vec_tmp(ttm))
-    iret = NF90_GET_VAR (fid,vid,vec_tmp,start=(/ 1 /),count=(/ ttm /))
-    itaus(1:ttm) = NINT(vec_tmp(1:ttm))
-    DEALLOCATE(vec_tmp)
-!---
-    IF (check) WRITE(*,*) 'flinopen 5.1 Times ',itaus
-!---
-!-- Getting all the details for the time axis
-!---
-!-- Find the calendar
-    calendar = ''
-    iret = NF90_GET_ATT (fid,gdtmaf_id,'calendar',calendar)
-    IF (iret == NF90_NOERR) THEN
-      CALL ioconf_calendar(calendar)
-    ENDIF
-!--
-    units = ''
-    iret = NF90_GET_ATT (fid,vid,'units',units)
-    IF (gdtt_id > 0) THEN
-      units = units(INDEX(units,'since')+6:LEN_TRIM(units))
-      READ (units,'(I4.4,5(a,I2.2))') &
-        year0, strc, month0, strc, day0, &
-               strc, hours0, strc, minutes0, strc, seci
-      sec0 = hours0*3600. + minutes0*60. + seci
-      CALL ymds2ju (year0, month0, day0, sec0, date0)
-      IF (check) &
-        WRITE(*,*) 'flinopen 5.1 gdtt_id year0 ... date0 ', &
-                   year0, month0, day0, sec0, date0
-!-----
-      iret = NF90_GET_ATT (fid, gdtt_id, 'tstep_sec', dt)
-    ELSE IF (gdtmaf_id > 0) THEN
-      units = units(INDEX(units,'since')+6:LEN_TRIM(units))
-      READ (units,'(I4.4,5(a,I2.2))') &
-        year0, strc, month0, strc, day0, &
-               strc, hours0, strc, minutes0, strc, seci
-      sec0 = hours0*3600. + minutes0*60. + seci
-      CALL ymds2ju (year0, month0, day0, sec0, date0)
-!-----
-      IF (check) &
-        WRITE(*,*) 'flinopen 5.1 gdtmaf_id year0 ... date0 ', &
-                   year0, month0, day0, sec0, date0
-    ELSE IF (old_id > 0) THEN
-      iret = NF90_GET_ATT (fid, NF90_GLOBAL, 'delta_tstep_sec', dt)
-      iret = NF90_GET_ATT (fid, NF90_GLOBAL, 'day0', r_day)
-      iret = NF90_GET_ATT (fid, NF90_GLOBAL, 'sec0', sec)
-      iret = NF90_GET_ATT (fid, NF90_GLOBAL, 'year0', r_year)
-      iret = NF90_GET_ATT (fid, NF90_GLOBAL, 'month0', r_month)
-!-----
-      day = INT(r_day)
-      month = INT(r_month)
-      year = INT(r_year)
-!-----
-      CALL ymds2ju (year, month, day, sec, date0)
-    ENDIF
-  ENDIF
-!-
-  IF (check) WRITE(*,*) 'flinopen 6.0 File opened', date0, dt
-!---------------------------
-END SUBROUTINE flinopen_work
-!-
-!===
-!-
-SUBROUTINE flininfo (filename, iim, jjm, llm, ttm, fid_out)
-!---------------------------------------------------------------------
-!- This subroutine allows to get some information.
-!- It is usualy done within flinopen but the user may want to call
-!- it before in order to allocate the space needed to extract the
-!- data from the file.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  CHARACTER(LEN=*) :: filename
-  INTEGER :: iim, jjm, llm, ttm, fid_out
-!-
-! LOCAL
-!-
-  INTEGER :: iret, fid, ndims, nvars, nb_atts, id_unlim
-  INTEGER :: iv, lll
-  INTEGER :: xid, yid, zid, tid
-  CHARACTER(LEN=80) :: name
-  CHARACTER(LEN=30) :: axname
-!-
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  lll = LEN_TRIM(filename)
-  IF (filename(lll-2:lll) /= '.nc') THEN
-    name = filename(1:lll)//'.nc'
-  ELSE
-    name = filename(1:lll)
-  ENDIF
-!-
-  iret = NF90_OPEN (name, NF90_NOWRITE, fid)
-  IF (iret /= NF90_NOERR) THEN
-    CALL histerr(3, 'flininfo','Could not open file :',TRIM(name),' ')
-  ENDIF
-!-
-  iret = NF90_INQUIRE (fid, nDimensions=ndims, nVariables=nvars, &
-                      nAttributes=nb_atts, unlimitedDimId=id_unlim)
-!-
-  xid = -1; iim = 0;
-  yid = -1; jjm = 0;
-  zid = -1; llm = 0;
-  tid = -1; ttm = 0;
-!-
-  DO iv=1,ndims
-!---
-    iret = NF90_INQUIRE_DIMENSION (fid, iv, name=axname, len=lll)
-    CALL strlowercase (axname)
-    axname = ADJUSTL(axname)
-!---
-    IF (check) WRITE(*,*) &
-      'flininfo - getting axname',iv,axname,lll
-!---
-    IF      (    (INDEX(axname,'x') == 1) &
-             .OR.(INDEX(axname,'lon') == 1) ) THEN
-      xid = iv; iim = lll;
-    ELSE IF (    (INDEX(axname,'y') == 1) &
-             .OR.(INDEX(axname,'lat') == 1) ) THEN
-      yid = iv; jjm = lll;
-    ELSE IF (    (INDEX(axname,'lev') == 1) &
-             .OR.(INDEX(axname,'plev') == 1) &
-             .OR.(INDEX(axname,'z') == 1) &
-             .OR.(INDEX(axname,'depth') == 1) ) THEN
-      zid = iv; llm = lll;
-    ELSE IF (    (INDEX(axname,'tstep') == 1) &
-             .OR.(INDEX(axname,'time_counter') == 1) ) THEN
-!---- For the time we certainly need to allow for other names
-      tid = iv; ttm = lll;
-    ELSE IF (ndims == 1) THEN
-!---- Nothing was found and ndims=1 then we have a vector of data
-      xid = 1; iim = lll;
-    ENDIF
-!---
-  ENDDO
-!-
-! Keep all this information
-!-
-  nbfiles = nbfiles+1
-!-
-  IF (nbfiles > nbfile_max) THEN
-    CALL histerr (3,'flininfo', &
-      'Too many files. Please increase nbfil_max', &
-      'in program flincom.F90.',' ')
-  ENDIF
-!-
-  ncids(nbfiles) = fid
-  ncnbd(nbfiles) = ndims
-!-
-  ncdims(nbfiles,1:4) = (/ iim, jjm, llm, ttm /)
-!-
-  ncfunli(nbfiles) = id_unlim
-  ncnba(nbfiles)   = nb_atts
-  ncnbva(nbfiles)  = nvars
-  ncfileopen(nbfiles) = .TRUE.
-!-
-  fid_out = nbfiles
-!----------------------
-END SUBROUTINE flininfo
-!-
-!===
-!-
-SUBROUTINE flinput_r1d &
-  (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, nlonid, jjm, nlatid, llm, zdimid, ttm, tdimid
-  REAL :: var(:)
-!-
-  INTEGER :: fid, ncvarid, ndim, iret
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (check) WRITE(*,*) &
-     "flinput_r1d : SIZE(var) = ",SIZE(var)
-!-
-  CALL flinput_mat &
-    (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid, &
-     fid,ncvarid,ndim)
-!-
-  iret = NF90_PUT_VAR (fid, ncvarid, var, &
-           start=w_sta(1:ndim), count=w_len(1:ndim))
-!-------------------------
-END SUBROUTINE flinput_r1d
-!-
-!===
-!-
-SUBROUTINE flinput_r2d &
-  (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, nlonid, jjm, nlatid, llm, zdimid, ttm, tdimid
-  REAL :: var(:,:)
-!-
-  INTEGER :: fid, ncvarid, ndim, iret
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (check) WRITE(*,*) &
-     "flinput_r2d : SIZE(var) = ",SIZE(var)
-!-
-  CALL flinput_mat &
-    (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid, &
-     fid,ncvarid,ndim)
-!-
-  iret = NF90_PUT_VAR (fid, ncvarid, var, &
-           start=w_sta(1:ndim), count=w_len(1:ndim))
-!-------------------------
-END SUBROUTINE flinput_r2d
-!-
-!===
-!-
-SUBROUTINE flinput_r3d &
-  (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, nlonid, jjm, nlatid, llm, zdimid, ttm, tdimid
-  REAL :: var(:,:,:)
-!-
-  INTEGER :: fid, ncvarid, ndim, iret
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (check) WRITE(*,*) &
-     "flinput_r3d : SIZE(var) = ",SIZE(var)
-!-
-  CALL flinput_mat &
-    (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid, &
-     fid,ncvarid,ndim)
-!-
-  iret = NF90_PUT_VAR (fid, ncvarid, var, &
-           start=w_sta(1:ndim), count=w_len(1:ndim))
-!-------------------------
-END SUBROUTINE flinput_r3d
-!-
-!===
-!-
-SUBROUTINE flinput_r4d &
-  (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, nlonid, jjm, nlatid, llm, zdimid, ttm, tdimid
-  REAL :: var(:,:,:,:)
-!-
-  INTEGER :: fid, ncvarid, ndim, iret
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (check) WRITE(*,*) &
-     "flinput_r4d : SIZE(var) = ",SIZE(var)
-!-
-  CALL flinput_mat &
-    (fid_in,varname,iim,nlonid,jjm,nlatid,llm,zdimid,ttm,tdimid, &
-     fid,ncvarid,ndim)
-!-
-  iret = NF90_PUT_VAR (fid, ncvarid, var, &
-           start=w_sta(1:ndim), count=w_len(1:ndim))
-!-------------------------
-END SUBROUTINE flinput_r4d
-!-
-!===
-!-
-SUBROUTINE flinput_mat &
-  (fid_in,varname,iim,nlonid,jjm,nlatid, &
-                  llm,zdimid,ttm,tdimid,fid,ncvarid,ndim)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, nlonid, jjm, nlatid, llm, zdimid, ttm, tdimid
-  INTEGER :: fid, ncvarid, ndim
-!-
-! LOCAL
-!-
-  INTEGER :: iret
-!---------------------------------------------------------------------
-  fid = ncids(fid_in)
-!-
-  w_sta(1:4) = (/      1,      1,  1,  1 /)
-  w_len(1:2) = (/    iim,    jjm /)
-  w_dim(1:2) = (/ nlonid, nlatid /)
-!-
-  IF ( (llm > 0).AND.(ttm > 0) ) THEN
-    ndim = 4
-    w_len(3:4) = (/    llm,    ttm /)
-    w_dim(3:4) = (/ zdimid, tdimid /)
-  ELSE IF (llm > 0) THEN
-    ndim = 3
-    w_dim(3) = zdimid
-    w_len(3) = llm
-  ELSE IF (ttm > 0) THEN
-    ndim = 3
-    w_dim(3) = tdimid
-    w_len(3) = ttm
-  ELSE
-    ndim = 2
-  ENDIF
-!-
-  iret = NF90_REDEF   (fid)
-  iret = NF90_DEF_VAR (fid,varname,NF90_FLOAT,w_dim(1:ndim),ncvarid)
-  iret = NF90_PUT_ATT (fid,ncvarid,'short_name',TRIM(varname))
-  iret = NF90_ENDDEF  (fid)
-!--------------------------
-END  SUBROUTINE flinput_mat
-!-
-!===
-!-
-SUBROUTINE flinput_scal &
-  (fid_in, varname, iim, nlonid, jjm, nlatid, &
-                    llm, zdimid, ttm, tdimid, var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, nlonid, jjm, nlatid, llm, zdimid, ttm, tdimid
-  REAL :: var
-!-
-! LOCAL
-!-
-  INTEGER :: fid, iret
-!---------------------------------------------------------------------
-  fid = ncids(fid_in)
-!-
-  iret = NF90_REDEF   (fid)
-  iret = NF90_PUT_ATT (fid, NF90_GLOBAL, varname, REAL(var,KIND=4))
-  iret = NF90_ENDDEF  (fid)
-!---------------------------
-END  SUBROUTINE flinput_scal
-!-
-!===
-!-
-SUBROUTINE flinget_r1d &
-  (fid_in,varname,iim,jjm,llm,ttm,itau_dep,itau_fin,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, jjm, llm, ttm, itau_dep, itau_fin
-  REAL :: var(:)
-!-
-  INTEGER :: jl, ji
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r1d : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r1d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,1,iim,1,jjm,buff_tmp)
-!-
-  jl=0
-  DO ji=1,SIZE(var,1)
-    jl=jl+1
-    var(ji) = buff_tmp(jl)
-  ENDDO
-!-------------------------
-END SUBROUTINE flinget_r1d
-!-
-!===
-!-
-SUBROUTINE flinget_r2d &
-  (fid_in,varname,iim,jjm,llm,ttm,itau_dep,itau_fin,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, jjm, llm, ttm, itau_dep, itau_fin
-  REAL :: var(:,:)
-!-
-  INTEGER :: jl, jj, ji
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r2d : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r2d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,1,iim,1,jjm,buff_tmp)
-!-
-  jl=0
-  DO jj=1,SIZE(var,2)
-    DO ji=1,SIZE(var,1)
-      jl=jl+1
-      var(ji,jj) = buff_tmp(jl)
-    ENDDO
-  ENDDO
-!-------------------------
-END SUBROUTINE flinget_r2d
-!-
-!===
-!-
-SUBROUTINE flinget_r2d_zoom2d &
-  (fid_in,varname,iim,jjm,llm,ttm, &
-   itau_dep,itau_fin,iideb,iilen,jjdeb,jjlen,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim,jjm,llm,ttm,itau_dep,itau_fin,iideb,jjdeb,iilen,jjlen
-  REAL :: var(:,:)
-!-
-  INTEGER :: jl, jj, ji
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r2d_zoom : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r2d_zoom : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,iideb,iilen,jjdeb,jjlen,buff_tmp)
-!-
-  jl=0
-  DO jj=1,SIZE(var,2)
-    DO ji=1,SIZE(var,1)
-      jl=jl+1
-      var(ji,jj) = buff_tmp(jl)
-    ENDDO
-  ENDDO
-!--------------------------------
-END SUBROUTINE flinget_r2d_zoom2d
-!-
-!===
-!-
-SUBROUTINE flinget_r3d &
-  (fid_in,varname,iim,jjm,llm,ttm,itau_dep,itau_fin,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, jjm, llm, ttm, itau_dep, itau_fin
-  REAL :: var(:,:,:)
-!-
-  INTEGER :: jl, jk, jj, ji
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r3d : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r3d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,1,iim,1,jjm,buff_tmp)
-!-
-  jl=0
-  DO jk=1,SIZE(var,3)
-    DO jj=1,SIZE(var,2)
-      DO ji=1,SIZE(var,1)
-        jl=jl+1
-        var(ji,jj,jk) = buff_tmp(jl)
-      ENDDO
-    ENDDO
-  ENDDO
-!-------------------------
-END SUBROUTINE flinget_r3d
-!-
-!===
-!-
-SUBROUTINE flinget_r3d_zoom2d &
-  (fid_in,varname,iim,jjm,llm,ttm, &
-   itau_dep,itau_fin,iideb,iilen,jjdeb,jjlen,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim,jjm,llm,ttm,itau_dep,itau_fin,iideb,jjdeb,iilen,jjlen
-  REAL :: var(:,:,:)
-!-
-  INTEGER :: jl, jk, jj, ji
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r3d_zoom : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r3d_zoom : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,iideb,iilen,jjdeb,jjlen,buff_tmp)
-!-
-  jl=0
-  DO jk=1,SIZE(var,3)
-    DO jj=1,SIZE(var,2)
-      DO ji=1,SIZE(var,1)
-        jl=jl+1
-        var(ji,jj,jk) = buff_tmp(jl)
-      ENDDO
-    ENDDO
-  ENDDO
-!--------------------------------
-END SUBROUTINE flinget_r3d_zoom2d
-!-
-!===
-!-
-SUBROUTINE flinget_r4d &
-  (fid_in,varname,iim,jjm,llm,ttm,itau_dep,itau_fin,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, jjm, llm, ttm, itau_dep, itau_fin
-  REAL :: var(:,:,:,:)
-!-
-  INTEGER :: jl, jk, jj, ji, jm
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r4d : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r4d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,1,iim,1,jjm,buff_tmp)
-!-
-  jl=0
-  DO jm=1,SIZE(var,4)
-    DO jk=1,SIZE(var,3)
-      DO jj=1,SIZE(var,2)
-        DO ji=1,SIZE(var,1)
-          jl=jl+1
-          var(ji,jj,jk,jm) = buff_tmp(jl)
-        ENDDO
-      ENDDO
-    ENDDO
-  ENDDO
-!-------------------------
-END SUBROUTINE flinget_r4d
-!-
-!===
-!-
-SUBROUTINE flinget_r4d_zoom2d &
-  (fid_in,varname,iim,jjm,llm,ttm, &
-   itau_dep,itau_fin,iideb,iilen,jjdeb,jjlen,var)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim,jjm,llm,ttm,itau_dep,itau_fin,iideb,jjdeb,iilen,jjlen
-  REAL :: var(:,:,:,:)
-!-
-  INTEGER :: jl, jk, jj, ji, jm
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (.NOT.ALLOCATED(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r4d_zoom : allocate buff_tmp for buff_sz = ",SIZE(var)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
-    IF (check) WRITE(*,*) &
-      "flinget_r4d_zoom : re-allocate buff_tmp for buff_sz = ",SIZE(var)
-    DEALLOCATE (buff_tmp)
-    ALLOCATE (buff_tmp(SIZE(var)))
-  ENDIF
-!-
-  CALL flinget_mat (fid_in,varname,iim,jjm,llm,ttm, &
-                    itau_dep,itau_fin,iideb,iilen,jjdeb,jjlen,buff_tmp)
-!-
-  jl=0
-  DO jm=1,SIZE(var,4)
-    DO jk=1,SIZE(var,3)
-      DO jj=1,SIZE(var,2)
-        DO ji=1,SIZE(var,1)
-          jl=jl+1
-          var(ji,jj,jk,jm) = buff_tmp(jl)
-        ENDDO
-      ENDDO
-    ENDDO
-  ENDDO
-!--------------------------------
-END SUBROUTINE flinget_r4d_zoom2d
-!-
-!===
-!-
-SUBROUTINE flinget_mat &
-  (fid_in, varname, iim, jjm, llm, ttm, itau_dep, &
-   itau_fin, iideb, iilen, jjdeb, jjlen, var)
-!---------------------------------------------------------------------
-!- This subroutine will read the variable named varname from
-!- the file previously opened by flinopen and identified by fid
-!-
-!- It is checked that the dimensions of the variable to be read
-!- correspond to what the user requested when he specified
-!- iim, jjm and llm. The only exception which is allowed is
-!- for compressed data where the horizontal grid is not expected
-!- to be iim x jjm.
-!-
-!- If variable is of size zero a global attribute is read.
-!- This global attribute will be of type real
-!-
-!- INPUT
-!-
-!- fid      : File ID returned by flinopen
-!- varname  : Name of the variable to be read from the file
-!- iim      : | These three variables give the size of the variables
-!- jjm      : | to be read. It will be verified that the variables
-!- llm      : | fits in there.
-!- ttm      : |
-!- itau_dep : Time step at which we will start to read
-!- itau_fin : Time step until which we are going to read
-!-            For the moment this is done on indexes
-!-            but it should be in the physical space.
-!-            If there is no time-axis in the file then use a
-!-            itau_fin < itau_dep, this will tell flinget not to
-!-            expect a time-axis in the file.
-!- iideb    : index i for zoom
-!- iilen    : length of zoom
-!- jjdeb    : index j for zoom
-!- jjlen    : length of zoom
-!-
-!- OUTPUT
-!-
-!- var      : array that will contain the data
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, jjm, llm, ttm
-  INTEGER :: itau_dep, itau_fin, iideb, iilen, jjdeb, jjlen
-  REAL :: var(:)
-!-
-! LOCAL
-!-
-  INTEGER :: iret, fid
-  INTEGER :: vid, cvid, clen
-  CHARACTER(LEN=70) :: str1
-  CHARACTER(LEN=250) :: att_n, tmp_n
-  CHARACTER(LEN=5) :: axs_l
-  INTEGER :: tmp_i
-  REAL,SAVE :: mis_v=0.
-  REAL :: tmp_r
-  INTEGER :: ndims, x_typ, nb_atts
-  INTEGER,DIMENSION(NF90_MAX_VAR_DIMS) :: dimids
-  INTEGER :: i, nvars, i2d, cnd
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: var_tmp
-  LOGICAL :: uncompress = .FALSE.
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  fid = ncids(fid_in)
-!-
-  IF (check) THEN
-    WRITE(*,*) &
-    'flinget_mat : fid_in, fid, varname :', fid_in, fid, TRIM(varname)
-    WRITE(*,*) &
-    'flinget_mat : iim, jjm, llm, ttm, itau_dep, itau_fin :', &
-    iim, jjm, llm, ttm, itau_dep, itau_fin
-    WRITE(*,*) &
-    'flinget_mat : iideb, iilen, jjdeb, jjlen :', &
-    iideb, iilen, jjdeb, jjlen
-  ENDIF
-!-
-  uncompress = .FALSE.
-!-
-! 1.0 We get first all the details on this variable from the file
-!-
-  nvars = ncnbva(fid_in)
-!-
-  vid = -1
-  iret = NF90_INQ_VARID (fid, varname, vid)
-!-
-  IF (vid < 0 .OR. iret /= NF90_NOERR) THEN
-    CALL histerr (3,'flinget', &
-      'Variable '//TRIM(varname)//' not found in file',' ',' ')
-  ENDIF
-!-
-  iret = NF90_INQUIRE_VARIABLE (fid, vid, &
-           ndims=ndims, dimids=dimids, nAtts=nb_atts)
-  IF (check) THEN
-    WRITE(*,*) &
-    'flinget_mat : fid, vid :', fid, vid
-    WRITE(*,*) &
-    'flinget_mat : ndims, dimids(1:ndims), nb_atts :', &
-    ndims, dimids(1:ndims), nb_atts
-  ENDIF
-!-
-  w_dim(:) = 0
-  DO i=1,ndims
-    iret  = NF90_INQUIRE_DIMENSION (fid, dimids(i), len=w_dim(i))
-  ENDDO
-  IF (check) WRITE(*,*) &
-    'flinget_mat : w_dim :', w_dim(1:ndims)
-!-
-  mis_v = 0.0; axs_l = ' ';
-!-
-  IF (nb_atts > 0) THEN
-    IF (check) THEN
-      WRITE(*,*) 'flinget_mat : attributes for variable :'
-    ENDIF
-  ENDIF
-  DO i=1,nb_atts
-    iret = NF90_INQ_ATTNAME (fid, vid, i, att_n)
-    iret = NF90_INQUIRE_ATTRIBUTE (fid, vid, att_n, xtype=x_typ)
-    CALL strlowercase (att_n)
-    IF      (    (x_typ == NF90_INT).OR.(x_typ == NF90_SHORT) &
-             .OR.(x_typ == NF90_BYTE) ) THEN
-      iret = NF90_GET_ATT (fid, vid, att_n, tmp_i)
-      IF (check) THEN
-        WRITE(*,*) '   ',TRIM(att_n),' : ',tmp_i
-      ENDIF
-    ELSE IF ( (x_typ == NF90_FLOAT).OR.(x_typ == NF90_DOUBLE) ) THEN
-      iret = NF90_GET_ATT (fid, vid, att_n, tmp_r)
-      IF (check) THEN
-        WRITE(*,*) '   ',TRIM(att_n),' : ',tmp_r
-      ENDIF
-      IF (index(att_n,'missing_value') > 0) THEN
-        mis_v = tmp_r
-      ENDIF
-    ELSE
-      tmp_n = ''
-      iret = NF90_GET_ATT (fid, vid, att_n, tmp_n)
-      IF (check) THEN
-        WRITE(*,*) '   ',TRIM(att_n),' : ',TRIM(tmp_n)
-      ENDIF
-      IF (index(att_n,'axis') > 0) THEN
-        axs_l = tmp_n
-      ENDIF
-    ENDIF
-  ENDDO
-!?
-!!!!!!!!!! We will need a verification on the type of the variable
-!?
-!-
-! 2.0 The dimensions are analysed to determine what is to be read
-!-
-! 2.1 the longitudes
-!-
-  IF ( w_dim(1) /= iim .OR. w_dim(2) /= jjm) THEN
-!---
-!-- There is a possibility that we have to deal with a compressed axis !
-!---
-    iret = NF90_INQUIRE_DIMENSION (fid, dimids(1), &
-             name=tmp_n, len=clen)
-    iret = NF90_INQ_VARID (fid, tmp_n, cvid)
-!---
-    IF (check) WRITE(*,*) &
-      'Dimname, iret , NF90_NOERR : ',TRIM(tmp_n),iret,NF90_NOERR
-!---
-!-- If we have an axis which has the same name
-!-- as the dimension we can see if it is compressed
-!---
-!-- TODO TODO for zoom2d
-!---
-    IF (iret == NF90_NOERR) THEN
-      iret = NF90_GET_ATT (fid, cvid, 'compress', str1)
-!-----
-      IF (iret == NF90_NOERR) THEN
-        iret = NF90_INQUIRE_VARIABLE (fid,cvid,xtype=x_typ,ndims=cnd)
-!-------
-        IF ( cnd /= 1 .AND. x_typ /= NF90_INT) THEN
-          CALL histerr (3,'flinget', &
-            'Variable '//TRIM(tmp_n)//' can not be a compressed axis', &
-            'Either it has too many dimensions'// &
-            ' or it is not of type integer', ' ')
-        ELSE
-!---------
-!-------- Let us see if we already have that index table
-!---------
-          IF (    (cind_len /= clen).OR.(cind_vid /= cvid) &
-              .OR.(cind_fid /= fid) ) THEN
-            IF (ALLOCATED(cindex))   DEALLOCATE(cindex)
-            ALLOCATE(cindex(clen))
-            cind_len = clen
-            cind_vid = cvid
-            cind_fid = fid
-            iret = NF90_GET_VAR (fid, cvid, cindex)
-          ENDIF
-!---------
-!-------- In any case we need to set the slab of data to be read
-!---------
-          uncompress = .TRUE.
-          w_sta(1) = 1
-          w_len(1) = clen
-          i2d = 1
-        ENDIF
-      ELSE
-        str1 = 'The horizontal dimensions of '//varname
-        CALL histerr (3,'flinget',str1, &
-          'is not compressed and does not'// &
-          ' correspond to the requested size',' ')
-      ENDIF
-    ELSE
-      IF (w_dim(1) /= iim) THEN
-        str1 = 'The longitude dimension of '//varname
-        CALL histerr (3,'flinget',str1, &
-          'in the file is not equal to the dimension', &
-          'that should be read')
-      ENDIF
-      IF (w_dim(2) /= jjm) THEN
-        str1 = 'The latitude dimension of '//varname
-        CALL histerr (3,'flinget',str1, &
-          'in the file is not equal to the dimension', &
-          'that should be read')
-      ENDIF
-    ENDIF
-  ELSE
-    w_sta(1:2) = (/ iideb, jjdeb /)
-    w_len(1:2) = (/ iilen, jjlen /)
-    i2d = 2
-  ENDIF
-!-
-! 2.3 Now the difficult part, the 3rd dimension which can be
-! time or levels.
-!-
-! Priority is given to the time axis if only three axes are present.
-!-
-  IF (ndims > i2d) THEN
-!---
-!-- 2.3.1 We have a vertical axis
-!---
-    IF (llm == 1 .AND. ndims == i2d+2 .OR. llm == w_dim(i2d+1)) THEN
-!-----
-      IF (w_dim(i2d+1) /= llm) THEN
-        CALL histerr (3,'flinget', &
-          'The vertical dimension of '//varname, &
-          'in the file is not equal to the dimension', &
-          'that should be read')
-      ELSE
-        w_sta(i2d+1) = 1
-        IF (llm > 0) THEN
-          w_len(i2d+1) = llm
-        ELSE
-          w_len(i2d+1) = w_sta(i2d+1)
-        ENDIF
-      ENDIF
-!-----
-      IF ((itau_fin-itau_dep) >= 0) THEN
-        IF      (ndims /= i2d+2) THEN
-          CALL histerr (3,'flinget', &
-            'You attempt to read a time slab', &
-            'but there is no time axis on this variable', varname)
-        ELSE IF ((itau_fin - itau_dep) <= w_dim(i2d+2)) THEN
-          w_sta(i2d+2) = itau_dep
-          w_len(i2d+2) = itau_fin-itau_dep+1
-        ELSE
-          CALL histerr (3,'flinget', &
-            'The time step you try to read is not', &
-            'in the file (1)', varname)
-        ENDIF
-      ELSE IF (ndims == i2d+2 .AND. w_dim(i2d+2) > 1) THEN
-        CALL histerr (3,'flinget', &
-          'There is a time axis in the file but no', &
-          'time step give in the call', varname)
-      ELSE
-        w_sta(i2d+2) = 1
-        w_len(i2d+2) = 1
-      ENDIF
-    ELSE
-!-----
-!---- 2.3.2 We do not have any vertical axis
-!-----
-      IF (ndims == i2d+2) THEN
-        CALL histerr (3,'flinget', &
-          'The file contains 4 dimensions', &
-          'but only 3 are requestes for variable ', varname)
-      ENDIF
-      IF ((itau_fin-itau_dep) >= 0) THEN
-        IF (ndims == i2d+1) THEN
-          IF ((itau_fin-itau_dep) < w_dim(i2d+1) ) THEN
-            w_sta(i2d+1) = itau_dep
-            w_len(i2d+1) = itau_fin-itau_dep+1
-          ELSE
-            CALL histerr (3,'flinget', &
-              'The time step you try to read is not', &
-              'in the file (2)', varname)
-          ENDIF
-        ELSE
-          CALL histerr (3,'flinget', &
-            'From your input you sould have 3 dimensions', &
-            'in the file but there are 4', varname)
-        ENDIF
-      ELSE
-        IF (ndims == i2d+1 .AND. w_dim(i2d+1) > 1) THEN
-          CALL histerr (3,'flinget', &
-            'There is a time axis in the file but no', &
-            'time step given in the call', varname)
-        ELSE
-          w_sta(i2d+1) = 1
-          w_len(i2d+1) = 1
-        ENDIF
-      ENDIF
-    ENDIF
-  ELSE
-!---
-!-- 2.3.3 We do not have any vertical axis
-!---
-    w_sta(i2d+1:i2d+2) = (/ 0, 0 /)
-    w_len(i2d+1:i2d+2) = (/ 0, 0 /)
-  ENDIF
-!-
-! 3.0 Reading the data
-!-
-  IF (check) WRITE(*,*) &
-    'flinget_mat 3.0 : ', uncompress, w_sta, w_len
-!---
-  IF (uncompress) THEN
-!---
-    IF (ALLOCATED(var_tmp)) THEN
-      IF (SIZE(var_tmp) < clen) THEN
-        DEALLOCATE(var_tmp)
-        ALLOCATE(var_tmp(clen))
-      ENDIF
-    ELSE
-      ALLOCATE(var_tmp(clen))
-    ENDIF
-!---
-    iret = NF90_GET_VAR (fid, vid, var_tmp, &
-             start=w_sta(:), count=w_len(:))
-!---
-    var(:) = mis_v
-    var(cindex(:)) = var_tmp(:)
-!---
-  ELSE
-    iret = NF90_GET_VAR (fid, vid, var, &
-             start=w_sta(:), count=w_len(:))
-  ENDIF
-!-
-  IF (check) WRITE(*,*) 'flinget_mat 3.1 : ',NF90_STRERROR (iret)
-!--------------------------
-END  SUBROUTINE flinget_mat
-!-
-!===
-!-
-SUBROUTINE flinget_scal &
-  (fid_in, varname, iim, jjm, llm, ttm, itau_dep, itau_fin, var)
-!---------------------------------------------------------------------
-!- This subroutine will read the variable named varname from
-!- the file previously opened by flinopen and identified by fid
-!-
-!- If variable is of size zero a global attribute is read. This
-!- global attribute will be of type real
-!-
-!- INPUT
-!-
-!- fid      : File ID returned by flinopen
-!- varname  : Name of the variable to be read from the file
-!- iim      : | These three variables give the size of the variables
-!- jjm      : | to be read. It will be verified that the variables
-!- llm      : | fits in there.
-!- ttm      : |
-!- itau_dep : Time step at which we will start to read
-!- itau_fin : Time step until which we are going to read
-!-           For the moment this is done on indeces but it should be
-!-           in the physical space
-!-           If there is no time-axis in the file then use a
-!-           itau_fin < itau_dep, this will tell flinget not to
-!-           expect a time-axis in the file.
-!-
-!- OUTPUT
-!-
-!- var      : scalar that will contain the data
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim, jjm, llm, ttm, itau_dep, itau_fin
-  REAL :: var
-!-
-! LOCAL
-!-
-  INTEGER :: iret, fid
-!-
-  LOGICAL :: check = .FALSE.
-!---------------------------------------------------------------------
-  IF (check) THEN
-    WRITE (*,*) 'flinget_scal in file with id ',fid_in
-  ENDIF
-!-
-  fid = ncids(fid_in)
-!-
-! 1.0 Reading a global attribute
-!-
-  iret = NF90_GET_ATT (fid, NF90_GLOBAL, varname, var)
-!---------------------------
-END  SUBROUTINE flinget_scal
-!-
-!===
-!-
-SUBROUTINE flinfindcood (fid_in, axtype, vid, ndim)
-!---------------------------------------------------------------------
-!- This subroutine explores the file in order to find
-!- the coordinate according to a number of rules
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! ARGUMENTS
-!-
-  INTEGER :: fid_in, vid, ndim
-  CHARACTER(LEN=3) :: axtype
-!-
-! LOCAL
-!-
-  INTEGER :: iv, iret, dimnb
-  CHARACTER(LEN=40) :: dimname, dimuni1, dimuni2, dimuni3
-  CHARACTER(LEN=80) :: str1
-  LOGICAL :: found_rule = .FALSE.
-!---------------------------------------------------------------------
-  vid = -1
-!-
-! Make sure all strings are invalid
-!-
-  dimname = '?-?'
-  dimuni1 = '?-?'
-  dimuni2 = '?-?'
-  dimuni3 = '?-?'
-!-
-! First rule : we look for the correct units
-! lon : east
-! lat : north
-! We make an exact check as it would be too easy to mistake
-! some units by just comparing the substrings.
-!-
-  SELECTCASE(axtype)
-  CASE ('lon')
-    dimuni1 = 'degree_e'
-    dimuni2 = 'degrees_e'
-    found_rule = .TRUE.
-  CASE('lat')
-    dimuni1 = 'degree_n'
-    dimuni2 = 'degrees_n'
-    found_rule = .TRUE.
-  CASE('lev')
-    dimuni1 = 'm'
-    dimuni2 = 'km'
-    dimuni3 = 'hpa'
-    found_rule = .TRUE.
-  CASE DEFAULT
-    found_rule = .FALSE.
-  END SELECT
-!-
-  IF (found_rule) THEN
-    iv = 0
-    DO WHILE ( (vid < 0).AND.(iv < ncnbva(fid_in)) )
-      iv = iv+1
-      str1 = ''
-      iret = NF90_GET_ATT (ncids(fid_in), iv, 'units', str1)
-      IF (iret == NF90_NOERR) THEN
-        CALL strlowercase (str1)
-        IF (    (INDEX(str1, TRIM(dimuni1)) == 1) &
-            .OR.(INDEX(str1, TRIM(dimuni2)) == 1) &
-            .OR.(INDEX(str1, TRIM(dimuni3)) == 1) ) THEN
-          vid = iv
-          iret = NF90_INQUIRE_VARIABLE (ncids(fid_in), iv, ndims=ndim)
-        ENDIF
-      ENDIF
-    ENDDO
-  ENDIF
-!-
-! Second rule : we find specific names :
-! lon : nav_lon
-! lat : nav_lat
-! Here we can check if we find the substring as the
-! names are more specific.
-!-
-  SELECTCASE(axtype)
-  CASE ('lon')
-    dimname = 'nav_lon lon longitude'
-    found_rule = .TRUE.
-  CASE('lat')
-    dimname = 'nav_lat lat latitude'
-    found_rule = .TRUE.
-  CASE('lev')
-    dimname = 'plev level depth deptht'
-    found_rule = .TRUE.
-  CASE DEFAULT
-    found_rule = .FALSE.
-  END SELECT
-!-
-  IF (found_rule) THEN
-    iv = 0
-    DO WHILE ( (vid < 0).AND.(iv < ncnbva(fid_in)) )
-      iv = iv+1
-      str1=''
-      iret = NF90_INQUIRE_VARIABLE (ncids(fid_in), iv, &
-                                    name=str1, ndims=ndim)
-      IF (INDEX(dimname,TRIM(str1)) >= 1) THEN
-        vid = iv
-      ENDIF
-    ENDDO
-  ENDIF
-!-
-! Third rule : we find a variable with the same name as the dimension
-! lon = 1
-! lat = 2
-! lev = 3
-!-
-  IF (vid < 0) THEN
-    SELECTCASE(axtype)
-    CASE ('lon')
-      dimnb = 1
-      found_rule = .TRUE.
-    CASE('lat')
-      dimnb = 2
-      found_rule = .TRUE.
-    CASE('lev')
-      dimnb = 3
-      found_rule = .TRUE.
-    CASE DEFAULT
-      found_rule = .FALSE.
-    END SELECT
-!---
-    IF (found_rule) THEN
-      iret = NF90_INQUIRE_DIMENSION (ncids(fid_in), dimnb, name=dimname)
-      iv = 0
-      DO WHILE ( (vid < 0).AND.(iv < ncnbva(fid_in)) )
-        iv = iv+1
-        str1=''
-        iret = NF90_INQUIRE_VARIABLE (ncids(fid_in), iv, &
-                                      name=str1, ndims=ndim)
-        IF (INDEX(dimname,TRIM(str1)) == 1) THEN
-          vid = iv
-        ENDIF
-      ENDDO
-    ENDIF
-  ENDIF
-!-
-! Stop the program if no coordinate was found
-!-
-  IF (vid < 0) THEN
-    CALL histerr (3,'flinfindcood', &
-           'No coordinate axis was found in the file', &
-           'The data in this file can not be used', axtype)
-  ENDIF
-!--------------------------
-END SUBROUTINE flinfindcood
-!-
-!===
-!-
-SUBROUTINE flinclo (fid_in)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-!-
-  INTEGER :: iret
-!---------------------------------------------------------------------
-  iret = NF90_CLOSE (ncids(fid_in))
-  ncfileopen(fid_in) = .FALSE.
-!---------------------
-END SUBROUTINE flinclo
-!-
-!===
-!-
-SUBROUTINE flinquery_var(fid_in, varname, exists)
-!---------------------------------------------------------------------
-!- Queries the existance of a variable in the file.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid_in
-  CHARACTER(LEN=*) varname
-  LOGICAL :: exists
-!-
-  INTEGER :: iret, fid, vid
-!---------------------------------------------------------------------
-  fid = ncids(fid_in)
-  vid = -1
-  iret = NF90_INQ_VARID (fid, varname, vid)
-!-
-  exists = ( (vid >= 0).AND.(iret == NF90_NOERR) )
-!---------------------------
-END SUBROUTINE flinquery_var
-!-
-!===
-!-
-SUBROUTINE flininspect (fid_in)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! fid : File id to inspect
-!-
-  INTEGER :: fid_in
-!-
-!- LOCAL
-!-
-  INTEGER :: iim, jjm, llm, ttm, fid_out
-  INTEGER :: iret, fid, ndims, nvars, nb_atts, id_unlim
-  INTEGER :: iv, in, lll
-  INTEGER :: xid, yid, zid, tid
-  INTEGER,DIMENSION(NF90_MAX_VAR_DIMS) :: idimid
-  CHARACTER(LEN=80) :: name
-  CHARACTER(LEN=30) :: axname
-!---------------------------------------------------------------------
-  fid = ncids(fid_in)
-!-
-  iret = NF90_INQUIRE (fid, nDimensions=ndims, nVariables=nvars, &
-                       nAttributes=nb_atts, unlimitedDimId=id_unlim)
-!-
-  WRITE (*,*) 'IOIPSL ID                   : ',fid_in
-  WRITE (*,*) 'NetCDF ID                   : ',fid
-  WRITE (*,*) 'Number of dimensions        : ',ndims
-  WRITE (*,*) 'Number of variables         : ',nvars
-  WRITE (*,*) 'Number of global attributes : ',nb_atts
-  WRITE (*,*) 'ID unlimited                : ',id_unlim
-!-
-  xid = -1; iim = 0;
-  yid = -1; jjm = 0;
-  zid = -1; llm = 0;
-  tid = -1; ttm = 0;
-!-
-  DO iv=1,ndims
-!---
-    iret = NF90_INQUIRE_DIMENSION (fid, iv, name=axname, len=lll)
-    CALL strlowercase (axname)
-    axname = ADJUSTL(axname)
-!---
-    WRITE (*,*) 'Dimension number : ',iv
-    WRITE (*,*) 'Dimension name   : ',TRIM(axname)
-!---
-    IF      (    (INDEX(axname,'x') == 1) &
-             .OR.(INDEX(axname,'lon') == 1)) THEN
-      xid = iv; iim = lll;
-      WRITE (*,*) 'Dimension X size   : ',iim
-    ELSE IF (    (INDEX(axname,'y') == 1) &
-             .OR.(INDEX(axname,'lat') == 1)) THEN
-      yid = iv; jjm = lll;
-      WRITE (*,*) 'Dimension Y size   : ',jjm
-    ELSE IF (    (INDEX(axname,'lev') == 1) &
-             .OR.(INDEX(axname,'plev') == 1) &
-             .OR.(INDEX(axname,'z') == 1) &
-             .OR.(INDEX(axname,'depth') == 1)) THEN
-      zid = iv; llm = lll;
-      WRITE (*,*) 'Dimension Z size   : ',llm
-    ELSE IF (    (INDEX(axname,'tstep') == 1) &
-             .OR.(INDEX(axname,'time_counter') == 1)) THEN
-!---- For the time we certainly need to allow for other names
-      tid = iv; ttm = lll;
-    ELSE IF (ndims == 1) THEN
-!---- Nothing was found and ndims=1 then we have a vector of data
-      xid = 1; iim = lll;
-    ENDIF
-!---
-  ENDDO
-!-
-! Keep all this information
-!-
-  nbfiles = nbfiles+1
-!-
-  IF (nbfiles > nbfile_max) THEN
-    CALL histerr(3,'flininspect', &
-      'Too many files. Please increase nbfil_max', &
-      'in program flincom.F90.',' ')
-  ENDIF
-!-
-  ncids(nbfiles) = fid
-  ncnbd(nbfiles) = ndims
-!-
-  ncdims(nbfiles,1:4) = (/ iim, jjm, llm, ttm /)
-!-
-  ncfunli(nbfiles) = id_unlim
-  ncnba(nbfiles)   = nb_atts
-  ncnbva(nbfiles)  = nvars
-  ncfileopen(nbfiles) = .TRUE.
-!-
-  fid_out = nbfiles
-!-
-  DO in=1,nvars
-    iret = NF90_INQUIRE_VARIABLE (fid, in, &
-             name=name, ndims=ndims, dimids=idimid, nAtts=nb_atts)
-    WRITE (*,*) 'Variable number  ------------ > ', in
-    WRITE (*,*) 'Variable name        : ', TRIM(name)
-    WRITE (*,*) 'Number of dimensions : ', ndims
-    WRITE (*,*) 'Dimensions ID''s     : ', idimid(1:ndims)
-    WRITE (*,*) 'Number of attributes : ', nb_atts
-  ENDDO
-!-------------------------
-END SUBROUTINE flininspect
-!-
-!===
-!-
-END MODULE flincom
Index: des/icosagcm/trunk/tools/ioipsl/fliocom.f90
===================================================================
--- /codes/icosagcm/trunk/tools/ioipsl/fliocom.f90	(revision 487)
+++ 	(revision )
@@ -1,5044 +1,0 @@
-MODULE fliocom
-!-
-!$Id: fliocom.f90 760 2009-10-26 14:10:32Z bellier $
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!---------------------------------------------------------------------
-USE netcdf
-!-
-USE defprec
-USE calendar,  ONLY : lock_calendar,ioget_calendar, &
- &                    ioconf_calendar,ju2ymds,ymds2ju
-USE errioipsl, ONLY : ipslerr,ipsldbg
-USE stringop,  ONLY : strlowercase
-!-
-IMPLICIT NONE
-!-
-PRIVATE
-!-
-PUBLIC :: &
- &  fliocrfd, fliopstc, fliodefv, flioputv, flioputa, &
- &  flioopfd, flioinqf, flioinqn, fliogstc, &
- &  flioinqv, fliogetv, flioinqa, fliogeta, &
- &  fliorenv, fliorena, fliodela, fliocpya, &
- &  flioqstc, fliosync, flioclo,  fliodmpf, &
- &  flio_dom_set,    flio_dom_unset, &
- &  flio_dom_defset, flio_dom_defunset, flio_dom_definq, &
- &  flio_dom_file,   flio_dom_att
-!-
-!!--------------------------------------------------------------------
-!! The following PUBLIC parameters (with "flio_" prefix)
-!! are used in the module "fliocom" :
-!!
-!! flio_max_files     : maximum number of simultaneously opened files
-!! flio_max_dims      : maximum number of dimensions for a file
-!! flio_max_var_dims  : maximum number of dimensions for a variable
-!!
-!! FLIO_DOM_NONE    : "named constant" for no_domain identifier
-!! FLIO_DOM_DEFAULT : "named constant" for default_domain identifier
-!!
-!! flio_i  : standard INTEGER external type
-!! flio_r  : standard REAL external type
-!! flio_c  : CHARACTER external type
-!! flio_i1 : INTEGER*1 external type
-!! flio_i2 : INTEGER*2 external type
-!! flio_i4 : INTEGER*4 external type
-!! flio_r4 : REAL*4 external type
-!! flio_r8 : REAL*8 external type
-!!--------------------------------------------------------------------
-  INTEGER,PARAMETER,PUBLIC :: &
- &  flio_max_files=100, flio_max_dims=10, flio_max_var_dims=5
-  INTEGER,PARAMETER,PUBLIC :: &
- &  flio_i = -1,        flio_r = -2,        flio_c =nf90_char, &
- &  flio_i1=nf90_int1,  flio_i2=nf90_int2,  flio_i4=nf90_int4, &
- &  flio_r4=nf90_real4, flio_r8=nf90_real8
-!-
-  INTEGER,PARAMETER,PUBLIC :: FLIO_DOM_NONE    =-1
-  INTEGER,PARAMETER,PUBLIC :: FLIO_DOM_DEFAULT = 0
-!-
-!!--------------------------------------------------------------------
-!! The "fliocrfd" routine creates a model file
-!! which contains the dimensions needed.
-!!
-!! SUBROUTINE fliocrfd (f_n,f_d_n,f_d_l,f_i,id_dom,mode,c_f_n)
-!!
-!! INPUT
-!!
-!! (C) f_n      : Name of the file to be created
-!! (C) f_d_n(:) : Array of (max nb_fd_mx) names of the dimensions
-!! (I) f_d_l(:) : Array of (max nb_fd_mx) lengths of the dimensions
-!!                For an unlimited dimension, enter a length of -1.
-!!                Actually, only one unlimited dimension is supported.
-!!
-!! OUTPUT
-!!
-!! (I) f_i  : Model file identifier
-!!
-!! Optional INPUT arguments
-!!
-!! (I) id_dom : Identifier of a domain defined by calling
-!!              "flio_dom_set". If this argument is present,
-!!              and not equal to FLIO_DOM_NONE, it will be
-!!              appended to the file name and
-!!              the attributes describing the related DOMAIN
-!!              will be put in the created file.
-!!              This argument can be equal to FLIO_DOM_DEFAULT
-!!              (see "flio_dom_defset").
-!! (C) mode   : Mode used to create the file.
-!!              Supported modes : REPLACE, REP, 32, 64, REP32, REP64.
-!!              If this argument is present with the value "REP[32/64]"
-!!              or the value "REPLACE", the file will be created
-!!              in mode "CLOBBER", else the file will be created
-!!              in mode "NOCLOBBER".
-!!              "32/64" defines the offset mode.
-!!              The default offset mode is 32 bits.
-!!
-!! Optional OUTPUT arguments
-!!
-!! (C) c_f_n : Name of the created file.
-!!             This name can be different of "f_n",
-!!             if a suffix is added to the original name
-!!             (".nc" or "DOMAIN_identifier.nc").
-!!             The length of "c_f_n" must be sufficient
-!!             to receive the created file name.
-!!
-!!- NOTES
-!!
-!! The names used to identify the spatio-temporal dimensions
-!! (dimension associated to a coordinate variable)
-!! are the following :
-!!
-!!  Axis       Names
-!!
-!!    x        'x[...]'  'lon[...]'
-!!    y        'y[...]'  'lat[...]'
-!!    z        'z[...]'  'lev[...]'  'plev[...]'   'depth[...]'
-!!    t        't'       'time'      'tstep[...]'  'time_counter[...]'
-!!
-!! Please, apply these rules so that coordinates are
-!! correctly defined.
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliopstc" routine defines the major coordinates system
-!! (spatio-temporal axis) of the model file (created by fliocrfd).
-!!
-!! SUBROUTINE fliopstc &
-!! & (f_i,x_axis,x_axis_2d,y_axis,y_axis_2d,z_axis, &
-!! &      t_axis,t_init,t_step,t_calendar)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!!
-!! Optional INPUT arguments
-!!
-!! (R) x_axis(:)      : longitudinal grids
-!! (R) x_axis_2d(:,:) : longitudinal grids
-!! (R) y_axis(:)      : latitudinal grids
-!! (R) y_axis_2d(:,:) : latitudinal grids
-!! (R) z_axis(:)      : vertical grid
-!! (I) t_axis(:)      : timesteps on the time axis
-!! (R) t_init         : date in julian days at the beginning
-!! (R) t_step         : timestep in seconds between t_axis steps
-!! (C) t_calendar     : calendar
-!!
-!! [x/y]_axis and [x/y]_axis_2d are mutually exclusive.
-!!
-!!- NOTES
-!!
-!! The variables corresponding to the spatio-temporal coordinates
-!! are created according to the following characteristics :
-!!
-!!- Longitude axis     x_axis / x_axis_2d
-!!   Variable name     'lon'  / 'nav_lon'
-!!   Attributes        Values
-!!   'axis'            "X"
-!!   'standard_name'   "longitude"
-!!   'units'           "degrees_east"
-!!   'valid_min'       MINVAL(x_axis/x_axis_2d)
-!!   'valid_max'       MAXVAL(x_axis/x_axis_2d)
-!!
-!!- Latitude axis      y_axis / y_axis_2d
-!!   Variable name     'lat'  / 'nav_lat'
-!!   Attributes        Values
-!!   'axis'            "Y"
-!!   'standard_name'   "latitude"
-!!   'units'           "degrees_north"
-!!   'valid_min'       MINVAL(y_axis/y_axis_2d)
-!!   'valid_max'       MAXVAL(y_axis/y_axis_2d)
-!!
-!!- Vertical axis      z_axis
-!!   Variable name     'lev'
-!!   Attributes        Values
-!!   'axis'            "Z"
-!!   'standard_name'   "model_level_number"
-!!   'units'           "sigma_level"
-!!   'long_name'       "Sigma Levels"
-!!   'valid_min'       MINVAL(z_axis)
-!!   'valid_max'       MAXVAL(z_axis)
-!!
-!!- Time axis          t_axis
-!!   Variable name     'time'
-!!   Attributes        Values
-!!   'axis'            "T"
-!!   'standard_name'   "time"
-!!   'long_name'       "time steps"
-!!  ['calendar'        user/default valued]
-!!   'units'           calculated
-!!
-!! If you are not satisfied, it is possible
-!! to rename variables ("fliorenv")
-!! or overload the values of attributes ("flioputa").
-!! Be careful : the new values you use must allow to read variables
-!! as coordinates.
-!!
-!! The dimensions associated to the coordinates variables
-!! are searched according to their names (see "fliocrfd")
-!!--------------------------------------------------------------------
-!-
-INTERFACE fliodefv
-!!--------------------------------------------------------------------
-!! The "fliodefv" routines define a variable in a model file.
-!!
-!! SUBROUTINE fliodefv &
-!! & (f_i,v_n,[v_d],v_t, &
-!! &  axis,standard_name,long_name,units,valid_min,valid_max)
-!!
-!! INPUT
-!!
-!! (I)  f_i  : Model file identifier
-!! (C)  v_n  : Name of variable to be defined
-!! (I) [v_d] :
-!!             "not present"
-!!                --> scalar variable
-!!             "array of one or several integers containing
-!!              the identifiers of the dimensions of the variable
-!!              (in the order specified to "fliocrfd"
-!!               or obtained from "flioopfd")"
-!!                --> multidimensioned variable
-!!
-!! Optional INPUT arguments
-!!
-!! (I) v_t : External type of the variable
-!!           "present"     --> see flio_..
-!!           "not present" --> type of standard real
-!! (C) axis,standard_name,long_name,units : Attributes
-!!     (axis should be used only for coordinates)
-!! (R) valid_min,valid_max : Attributes
-!!--------------------------------------------------------------------
-  MODULE PROCEDURE &
- &  fliodv_r0d,fliodv_rnd
-END INTERFACE
-!-
-INTERFACE flioputv
-!!--------------------------------------------------------------------
-!! The "flioputv" routines put a variable (defined by fliodefv)
-!! in a model file.
-!!
-!! SUBROUTINE flioputv (f_i,v_n,v_v,start,count)
-!!
-!! INPUT
-!!
-!! (I) f_i    : model file identifier
-!! (C) v_n    : name of the variable to be written
-!! (R/I) v_v  : scalar or array (up to flio_max_var_dims dimensions)
-!!              containing the (standard) real/integer values
-!!
-!! Optional INPUT arguments
-!!
-!! (I) start(:) : array of integers specifying the index
-!!                where the first data value will be written
-!! (I) count(:) : array of integers specifying the number of
-!!                indices that will be written along each dimension
-!!                (not present if v_v is a scalar)
-!!--------------------------------------------------------------------
-!?INTEGERS of KIND 1 are not supported on all computers
-  MODULE PROCEDURE &
- & fliopv_i40,fliopv_i41,fliopv_i42,fliopv_i43,fliopv_i44,fliopv_i45, &
- & fliopv_i20,fliopv_i21,fliopv_i22,fliopv_i23,fliopv_i24,fliopv_i25, &
-!& fliopv_i10,fliopv_i11,fliopv_i12,fliopv_i13,fliopv_i14,fliopv_i15, &
- & fliopv_r40,fliopv_r41,fliopv_r42,fliopv_r43,fliopv_r44,fliopv_r45, &
- & fliopv_r80,fliopv_r81,fliopv_r82,fliopv_r83,fliopv_r84,fliopv_r85
-END INTERFACE
-!-
-INTERFACE flioputa
-!!--------------------------------------------------------------------
-!! The "flioputa" routines put a value for an attribute
-!! in a model file.
-!! If this attribute does not exist, it will be created.
-!!
-!! SUBROUTINE flioputa (f_i,v_n,a_n,a_v)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!! (C) v_n  : Name of variable to which the attribute is assigned.
-!!            If this name is "?", the attribute will be global.
-!! (C) a_n  : Name of the attribute to be defined.
-!! ( ) a_v  : scalar or array of real (kind 4 or 8) or integer values,
-!!            or character string
-!!--------------------------------------------------------------------
-  MODULE PROCEDURE &
- &  fliopa_r4_0d,fliopa_r4_1d,fliopa_r8_0d,fliopa_r8_1d, &
- &  fliopa_i4_0d,fliopa_i4_1d,fliopa_tx_0d
-END INTERFACE
-!-
-!!--------------------------------------------------------------------
-!! The "flioopfd" routine opens an existing model file,
-!! and returns the dimensions used in the file and a file identifier.
-!! This information can be used to allocate the space needed
-!! to extract the data from the file.
-!!
-!! SUBROUTINE flioopfd (f_n,f_i,mode,nb_dim,nb_var,nb_gat)
-!!
-!! INPUT
-!!
-!! (C) f_n     : Name of the file to be opened
-!!
-!! OUTPUT
-!!
-!! (I) f_i      : Model file identifier
-!!
-!! Optional INPUT arguments
-!!
-!! (C) mode : Access mode to the file.
-!!            If this argument is present with the value "WRITE",
-!!            the file will be accessed in mode "READ-WRITE",
-!!            else the file will be accessed in mode "READ-ONLY".
-!!
-!! Optional OUTPUT arguments
-!!
-!! (I) nb_dim : number of dimensions
-!! (I) nb_var : number of variables
-!! (I) nb_gat : number of global attributes
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "flioinqf" routine returns information
-!! about an opened model file given its identifier.
-!!
-!! SUBROUTINE flioinqf &
-!! & (f_i,nb_dim,nb_var,nb_gat,id_uld,id_dim,ln_dim)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!!
-!! Optional OUTPUT arguments
-!!
-!! (I) nb_dim    : number of dimensions
-!! (I) nb_var    : number of variables
-!! (I) nb_gat    : number of global attributes
-!! (I) id_uld    : identifier of the unlimited dimension (0 if none)
-!! (I) id_dim(:) : identifiers of the dimensions
-!! (I) ln_dim(:) : lengths of the dimensions
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "flioinqn" routine returns the names
-!! of the entities encountered in an opened model file.
-!!
-!! SUBROUTINE flioinqn &
-!! & (f_i,cn_dim,cn_var,cn_gat,cn_uld, &
-!! &  id_start,id_count,iv_start,iv_count,ia_start,ia_count)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!!
-!! Optional OUTPUT arguments
-!!
-!! (C) cn_dim(:) : names of dimensions
-!! (C) cn_var(:) : names of variables
-!! (C) cn_gat(:) : names of global attributes
-!! (C) cn_uld    : names of the unlimited dimension
-!!
-!! Optional INPUT arguments
-!!
-!! (I) id_start,id_count,iv_start,iv_count,ia_start,ia_count
-!!
-!!  The prefix ( id       / iv      / ia              ) specifies
-!!         the (dimensions/variables/global attributes) entities
-!!
-!!  The suffix "start" specify the index from which
-!!  the first name will be retrieved (1 by default)
-!!
-!!  The suffix "count" specifies the number of names to be retrieved
-!!  (all by default)
-!!
-!!  If a requested entity is not available, a "?" will be returned.
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliogstc" routine extracts the major coordinates system
-!! (spatio-temporal axis) of the model file (opened by flioopfd).
-!!
-!! SUBROUTINE fliogstc &
-!! & (f_i,x_axis,x_axis_2d,y_axis,y_axis_2d,z_axis, &
-!! &      t_axis,t_init,t_step,t_calendar, &
-!! &      x_start,x_count,y_start,y_count, &
-!! &      z_start,z_count,t_start,t_count)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!!
-!! Optional OUTPUT arguments
-!!
-!! (R) x_axis(:)      : longitudinal grids
-!! (R) x_axis_2d(:,:) : longitudinal grids
-!! (R) y_axis(:)      : latitudinal grids
-!! (R) y_axis_2d(:,:) : latitudinal grids
-!! (R) z_axis(:)      : vertical grid
-!! (I) t_axis(:)      : timesteps on the time axis
-!! (R) t_init         : date in julian days at the beginning
-!! (R) t_step         : timestep in seconds between t_axis steps
-!! (C) t_calendar     : calendar attribute
-!!                      (the value is "not found" if the attribute
-!!                       is not present in the model file)
-!!
-!! [x/y]_axis and [x/y]_axis_2d are mutually exclusive.
-!!
-!! Optional INPUT arguments
-!!
-!! (I) x_start,x_count,y_start,y_count,z_start,z_count,t_start,t_count
-!!
-!!  The prefix (x/y/z/t) specifies the concerned direction.
-!!
-!!  The suffix "start" specify the index from which
-!!  the first data value will be read (1 by default)
-!!
-!!  The suffix "count" specifies the number of values to be read
-!!  (all by default)
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "flioinqv" routine returns information about a model
-!! variable given its name.
-!! This information can be used to allocate the space needed
-!! to extract the variable from the file.
-!!
-!! SUBROUTINE flioinqv &
-!! & (f_i,v_n,l_ex,nb_dims,len_dims,id_dims, &
-!! &  nb_atts,cn_atts,ia_start,ia_count)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!! (C) v_n  : Name of the variable
-!!
-!! OUTPUT
-!!
-!! (L) l_ex  : Existence of the variable
-!!
-!! Optional OUTPUT arguments
-!!
-!! (I) v_t          : External type of the variable (see flio_..)
-!! (I) nb_dims      : number of dimensions of the variable
-!! (I) len_dims(:)  : list of dimension lengths of the variable
-!! (I) id_dims(:)   : list of dimension identifiers of the variable
-!! (I) nb_atts      : number of attributes of the variable
-!! (C) cn_atts(:)   : names of the attributes
-!!
-!! Optional INPUT arguments
-!!
-!! (I) ia_start : index of the first attribute whose the name
-!!                will be retrieved (1 by default)
-!! (I) ia_count : number of names to be retrieved (all by default)
-!!
-!!  If a requested entity is not available, a "?" will be returned.
-!!--------------------------------------------------------------------
-!-
-INTERFACE fliogetv
-!!--------------------------------------------------------------------
-!! The "fliogetv" routines get a variable from a model file.
-!!
-!! SUBROUTINE fliogetv (f_i,v_n,v_v,start,count)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!! (C) v_n  : Name of the variable to be read
-!!
-!! OUTPUT
-!!
-!! (R/I) v_v  : scalar or array (up to flio_max_var_dims dimensions)
-!!              that will contain the (standard) real/integer values
-!!
-!! Optional INPUT arguments
-!!
-!! (I) start(:) : array of integers specifying the index
-!!                from which the first data value will be read
-!! (I) count(:) : array of integers specifying the number of
-!!                indices that will be read along each dimension
-!!                (not present if v_v is a scalar)
-!!--------------------------------------------------------------------
-!?INTEGERS of KIND 1 are not supported on all computers
-  MODULE PROCEDURE &
- & fliogv_i40,fliogv_i41,fliogv_i42,fliogv_i43,fliogv_i44,fliogv_i45, &
- & fliogv_i20,fliogv_i21,fliogv_i22,fliogv_i23,fliogv_i24,fliogv_i25, &
-!& fliogv_i10,fliogv_i11,fliogv_i12,fliogv_i13,fliogv_i14,fliogv_i15, &
- & fliogv_r40,fliogv_r41,fliogv_r42,fliogv_r43,fliogv_r44,fliogv_r45, &
- & fliogv_r80,fliogv_r81,fliogv_r82,fliogv_r83,fliogv_r84,fliogv_r85
-END INTERFACE
-!-
-!!--------------------------------------------------------------------
-!! The "flioinqa" routine returns information about an
-!! attribute of a variable given their names, in a model file.
-!! Information about a variable includes its existence,
-!! and the number of values currently stored in the attribute.
-!! For a string-valued attribute, this is the number of
-!! characters in the string.
-!! This information can be used to allocate the space needed
-!! to extract the attribute from the file.
-!!
-!! SUBROUTINE flioinqa (f_i,v_n,a_n,l_ex,a_t,a_l)
-!!
-!! INPUT
-!!
-!! (I) f_i : Model file identifier
-!! (C) v_n : Name of variable to which the attribute is assigned.
-!!           This name is "?" for a global attribute.
-!! (C) a_n : Name of the concerned attribute.
-!!
-!! OUTPUT
-!!
-!! (L) l_ex : existence of the variable
-!!
-!! Optional OUTPUT arguments
-!!
-!! (I) a_t : external type of the attribute
-!! (I) a_l : number of values of the attribute
-!!--------------------------------------------------------------------
-!-
-INTERFACE fliogeta
-!!--------------------------------------------------------------------
-!! The "fliogeta" routines get a value for an attribute
-!! in a model file.
-!!
-!! SUBROUTINE fliogeta (f_i,v_n,a_n,a_v)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!! (C) v_n  : Name of variable to which the attribute is assigned.
-!!            This name is "?" for a global attribute.
-!! (C) a_n  : Name of the attribute to be retrieved.
-!! ( ) a_v  : scalar or array of real (kind 4 or 8) or integer values,
-!!            or character string
-!!--------------------------------------------------------------------
-  MODULE PROCEDURE &
- &  flioga_r4_0d,flioga_r4_1d,flioga_r8_0d,flioga_r8_1d, &
- &  flioga_i4_0d,flioga_i4_1d,flioga_tx_0d
-END INTERFACE
-!-
-!!--------------------------------------------------------------------
-!! The "fliorenv" routine renames a variable, in a model file.
-!!
-!! SUBROUTINE fliorenv (f_i,v_o_n,v_n_n)
-!!
-!! INPUT
-!!
-!! (I) f_i    : Model file identifier
-!! (C) v_o_n  : Old name of the variable
-!! (C) v_n_n  : New name of the variable
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliorena" routine renames an attribute
-!! of a variable, in a model file.
-!!
-!! SUBROUTINE fliorena (f_i,v_n,a_o_n,a_n_n)
-!!
-!! INPUT
-!!
-!! (I) f_i    : Model file identifier
-!! (C) v_n    : Name of variable to which the attribute is assigned.
-!!              This name is "?" for a global attribute.
-!! (C) a_o_n  : Old name of the concerned attribute.
-!! (C) a_n_n  : New name of the concerned attribute.
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliodela" routine deletes an attribute in a model file.
-!!
-!! SUBROUTINE fliodela (f_i,v_n,a_n)
-!!
-!! INPUT
-!!
-!! (I) f_i  : Model file identifier
-!! (C) v_n  : Name of variable to which the attribute is assigned.
-!!            This name is "?" for a global attribute.
-!! (C) a_n  : Name of the concerned attribute.
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliocpya" routine copies an attribute
-!! from one open model file to another.
-!! It can also be used to copy an attribute from
-!! one variable to another within the same model file.
-!!
-!! SUBROUTINE fliocpya (f_i_i,v_n_i,a_n,f_i_o,v_n_o)
-!!
-!! INPUT
-!!
-!! (I) f_i_i : Identifier of the input  model file
-!! (C) v_n_i : Name of the input variable
-!!             This name is "?" for a global attribute.
-!! (C) a_n   : Name of the concerned attribute.
-!! (I) f_i_o : Identifier of the output model file
-!!             It can be the same as the input identifier.
-!! (C) v_n_o : Name of the output variable
-!!             This name is "?" for a global attribute.
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "flioqstc" routine search for a spatio-temporal coordinate
-!! in a model file and returns its name.
-!!
-!! SUBROUTINE flioqstc (f_i,c_type,l_ex,c_name)
-!!
-!! INPUT
-!!
-!! (I) f_i     : Model file identifier
-!! (C) c_type  : Type of the coordinate ("x"/"y"/"z"/"t")
-!!
-!! OUTPUT
-!!
-!! (L) l_ex    : existence of the coordinate
-!! (C) c_name  : name of the coordinate
-!!
-!!- NOTES
-!!
-!! The following rules are used for searching variables
-!! which are spatio-temporal coordinates (x/y/z/t).
-!!
-!!-- Rule 1 : we look for a variable with one dimension
-!!--          and which has the same name as its dimension
-!!
-!!-- Rule 2 : we look for a correct "axis" attribute
-!!
-!!  Axis       Axis attribute             Number of dimensions
-!!             (case insensitive)
-!!
-!!    x         X                         1/2
-!!    y         Y                         1/2
-!!    z         Z                         1
-!!    t         T                         1
-!!
-!!-- Rule 3 : we look for a correct "standard_name" attribute
-!!
-!!  Axis       Axis attribute          Number of dimensions
-!!             (case insensitive)
-!!
-!!    x         longitude              1/2
-!!    y         latitude               1/2
-!!    z         model_level_number     1
-!!    t         time                   1
-!!
-!!-- Rule 4 : we look for a specific name
-!!
-!!  Axis   Names
-!!
-!!    x    'nav_lon' 'lon'    'longitude'
-!!    y    'nav_lat' 'lat'    'latitude'
-!!    z    'depth'   'deptht' 'height'      'level'
-!!         'lev'     'plev'   'sigma_level' 'layer'
-!!    t    'time'    'tstep'  'timesteps'
-!!
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliosync" routine synchronise one or all opened model files,
-!! to minimize data loss in case of abnormal termination.
-!!
-!! SUBROUTINE fliosync (f_i)
-!!
-!! Optional INPUT arguments
-!!
-!! (I) f_i  : Model file identifier
-!!            If this argument is not present,
-!!            all the opened model files are synchronised.
-!---------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "flioclo" routine closes one or all opened model files
-!! and frees the space needed to keep information about the files
-!!
-!! SUBROUTINE flioclo (f_i)
-!!
-!! Optional INPUT arguments
-!!
-!! (I) f_i  : Model file identifier
-!!            If this argument is not present,
-!!            all the opened model files are closed.
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! The "fliodmpf" routine dumps a model file
-!! and prints the result on the standard output.
-!!
-!! SUBROUTINE fliodmpf (f_n)
-!!
-!! INPUT
-!!
-!! (C) f_n  : Name of the model file to be dumped
-!!--------------------------------------------------------------------
-!-
-!!--------------------------------------------------------------------
-!! This "flio_dom_set" sets up the domain activity of IOIPSL.
-!! It stores all the domain information and allows it to be stored
-!! in the model file and change the file names.
-!!
-!! This routine must be called by the user before opening
-!! the model file.
-!!
-!! SUBROUTINE flio_dom_set &
-!!  & (dtnb,dnb,did,dsg,dsl,dpf,dpl,dhs,dhe,cdnm,id_dom)
-!!
-!! INPUT
-!!
-!! (I) dtnb   : total number of domains
-!! (I) dnb    : domain number
-!! (I) did(:) : distributed dimensions identifiers
-!!              (up to 5 dimensions are supported)
-!! (I) dsg(:) : total number of points for each dimension
-!! (I) dsl(:) : local number of points for each dimension
-!! (I) dpf(:) : position of first local point for each dimension
-!! (I) dpl(:) : position of last local point for each dimension
-!! (I) dhs(:) : start halo size for each dimension
-!! (I) dhe(:) : end halo size for each dimension
-!! (C) cdnm   : Model domain definition name.
-!!              The names actually supported are :
-!!              "BOX", "APPLE", "ORANGE".
-!!              These names are case insensitive.
-!!
-!! OUTPUT argument
-!!
-!! (I) id_dom : Model domain identifier
-!!
-!!--------------------------------------------------------------------
-!!
-!!--------------------------------------------------------------------
-!! The "flio_dom_unset" routine unsets one or all set domains
-!! and frees the space needed to keep information about the domains
-!!
-!! This routine should be called by the user to free useless domains.
-!!
-!! SUBROUTINE flio_dom_unset (id_dom)
-!!
-!! Optional INPUT arguments
-!!
-!! (I) id_dom : Model domain identifier
-!!      >=1 & <= dom_max_nb : the domain is closed
-!!      not present         : all the set model domains are unset
-!!--------------------------------------------------------------------
-!!
-!!--------------------------------------------------------------------
-!! The "flio_dom_defset" sets
-!! the default domain identifier.
-!!
-!! SUBROUTINE flio_dom_defset (id_dom)
-!!
-!! INPUT argument
-!!
-!! (I) id_dom : Model default domain identifier
-!!     ( >=1 & <= dom_max_nb )
-!!     This identifier will be able to be taken by calling
-!!     "flio_dom_definq" and used to create model files
-!!     with the corresponding domain definitions
-!!--------------------------------------------------------------------
-!!
-!!--------------------------------------------------------------------
-!! The "flio_dom_defunset" routine unsets
-!! the default domain identifier.
-!!
-!! SUBROUTINE flio_dom_defunset ()
-!!
-!!--------------------------------------------------------------------
-!!
-!!--------------------------------------------------------------------
-!! The "flio_dom_definq" routine inquires about
-!! the default domain identifier.
-!! You should call this procedure to safeguard the current
-!! default domain identifier if you wish to use locally
-!! another default domain, in order to restore it.
-!!
-!! SUBROUTINE flio_dom_definq (id_dom)
-!!
-!! OUTPUT argument
-!!
-!! (I) id_dom : Model default domain identifier
-!!     IF no default domain identifier has been set,
-!!     the returned value is "FLIO_DOM_NONE".
-!!--------------------------------------------------------------------
-!-
-!---------------------------------------------------------------------
-! This is the data we keep concerning each file we open
-!---------------------------------------------------------------------
-!- For each file
-!- (I) nw_id(f_i)   : index to access at this file
-!- (I) nw_nd(f_i)   : number of dimensions
-!- (I) nw_nv(f_i)   : number of variables
-!- (I) nw_na(f_i)   : number of global attributes
-!- (I) nw_un(f_i)   : ID of the first unlimited dimension
-!- (L) lw_hm(f_i)   : for mode handling (.TRUE. define, .FALSE. data)
-!- (I) nw_di(:,f_i) : dimension IDs in the file "f_i"
-!- (I) nw_dl(:,f_i) : dimension lengths in the file "f_i"
-!- (I) nw_ai(:,f_i) : dimension Ids for the axis in the file "f_i"
-!---------------------------------------------------------------------
-  INTEGER,PARAMETER :: &
- &  nb_fi_mx=flio_max_files, &
- &  nb_fd_mx=flio_max_dims, &
- &  nb_vd_mx=flio_max_var_dims
-  INTEGER,PARAMETER :: nb_ax_mx=4
-!-
-  INTEGER,PARAMETER :: k_lon=1, k_lat=2, k_lev=3, k_tim=4
-!-
-  INTEGER,DIMENSION(nb_fi_mx),SAVE :: &
- &  nw_id=-1,nw_nd,nw_nv,nw_na,nw_un
-  LOGICAL,DIMENSION(nb_fi_mx),SAVE :: lw_hm
-  INTEGER,DIMENSION(nb_fd_mx,nb_fi_mx),SAVE :: nw_di=-1,nw_dl=-1
-  INTEGER,DIMENSION(nb_ax_mx,nb_fi_mx),SAVE :: nw_ai=-1
-!-
-! Maximum number of simultaneously defined domains
-  INTEGER,PARAMETER :: dom_max_nb=10
-!-
-! Maximum number of distributed dimensions for each domain
-  INTEGER,PARAMETER :: dom_max_dims=5
-!-
-! Default domain identifier
-  INTEGER,SAVE :: id_def_dom=FLIO_DOM_NONE
-!-
-! Supported domain definition names
-  INTEGER,PARAMETER :: n_dns=3, l_dns=7
-  CHARACTER(LEN=l_dns),DIMENSION(n_dns),SAVE :: &
- &  c_dns=(/ "box    ","apple  ","orange "/)
-!-
-! DOMAINS related variables
-  INTEGER,DIMENSION(1:dom_max_nb),SAVE :: &
- &  d_d_n=-1, d_n_t=0, d_n_c=0
-  INTEGER,DIMENSION(1:dom_max_dims,1:dom_max_nb),SAVE :: &
- &  d_d_i, d_s_g, d_s_l, d_p_f, d_p_l, d_h_s, d_h_e
-  CHARACTER(LEN=l_dns),DIMENSION(1:dom_max_nb),SAVE :: c_d_t
-!-
-!===
-CONTAINS
-!===
-!-
-!---------------------------------------------------------------------
-!- Public procedures
-!---------------------------------------------------------------------
-!-
-!===
-SUBROUTINE fliocrfd (f_n,f_d_n,f_d_l,f_i,id_dom,mode,c_f_n)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(IN) :: f_n
-  CHARACTER(LEN=*),DIMENSION(:),INTENT(IN) :: f_d_n
-  INTEGER,DIMENSION(:),INTENT(IN) :: f_d_l
-  INTEGER,INTENT(OUT) :: f_i
-  INTEGER,OPTIONAL,INTENT(IN) :: id_dom
-  CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: mode
-  CHARACTER(LEN=*),OPTIONAL,INTENT(OUT) :: c_f_n
-!-
-  INTEGER :: i_rc,f_e,idid,ii,m_c,n_u
-  CHARACTER(LEN=NF90_MAX_NAME) :: f_nw
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliocrfd - file name : ",TRIM(f_n)
-  ENDIF
-!-
-! Search for a free local identifier
-  f_i = flio_rid()
-  IF (f_i < 0) THEN
-    CALL ipslerr (3,'fliocrfd', &
- &   'Too many files.','Please increase nb_fi_mx', &
- &   'in module fliocom.f90.')
-  ENDIF
-!-
-! Update the name of the file
-  f_nw = f_n
-  CALL flio_dom_file (f_nw,id_dom)
-!-
-! Check the dimensions
-  IF (SIZE(f_d_l) /= SIZE(f_d_n)) THEN
-    CALL ipslerr (3,'fliocrfd', &
- &   'The number of names is not equal to the number of lengths', &
- &   'for the dimensions of the file',TRIM(f_nw))
-  ENDIF
-  IF (SIZE(f_d_l) > nb_fd_mx) THEN
-    CALL ipslerr (3,'fliocrfd', &
- &   'Too many dimensions','to create the file',TRIM(f_nw))
-  ENDIF
-!-
-! Check the mode
-  IF (PRESENT(mode)) THEN
-    SELECT CASE (TRIM(mode))
-    CASE('REPLACE','REP','REP64')
-      m_c = IOR(NF90_CLOBBER,NF90_64BIT_OFFSET)
-    CASE('REP32')
-      m_c = NF90_CLOBBER
-    CASE('32')
-      m_c = NF90_NOCLOBBER
-    CASE('64')
-      m_c = IOR(NF90_NOCLOBBER,NF90_64BIT_OFFSET)
-    CASE DEFAULT
-      m_c = IOR(NF90_NOCLOBBER,NF90_64BIT_OFFSET)
-    END SELECT
-  ELSE
-    m_c = IOR(NF90_NOCLOBBER,NF90_64BIT_OFFSET)
-  ENDIF
-!-
-! Create file (and enter the definition mode)
-  i_rc = NF90_CREATE(f_nw,m_c,f_e)
-  lw_hm(f_i) = .TRUE.
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (3,'fliocrfd', &
- &   'Could not create file :',TRIM(f_nw), &
- &   TRIM(NF90_STRERROR(i_rc))//' (Netcdf)')
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) '  fliocrfd, external model file-id : ',f_e
-  ENDIF
-!-
-! Create dimensions
-  n_u = 0
-  DO ii=1,SIZE(f_d_l)
-    IF (f_d_l(ii) == -1) THEN
-      IF (n_u == 0) THEN
-        i_rc = NF90_DEF_DIM(f_e,TRIM(f_d_n(ii)),NF90_UNLIMITED,idid)
-        n_u = n_u+1
-      ELSE
-        CALL ipslerr (3,'fliocrfd', &
- &       'Can not handle more than one unlimited dimension', &
- &       'for file :',TRIM(f_nw))
-      ENDIF
-    ELSE IF (f_d_l(ii) > 0) THEN
-      i_rc = NF90_DEF_DIM(f_e,TRIM(f_d_n(ii)),f_d_l(ii),idid)
-    ENDIF
-    IF ( ((f_d_l(ii) == -1).OR.(f_d_l(ii) > 0)) &
- &      .AND.(i_rc /= NF90_NOERR) ) THEN
-      CALL ipslerr (3,'fliocrfd', &
- &     'One dimension can not be defined', &
- &     'for the file :',TRIM(f_nw))
-    ENDIF
-  ENDDO
-!-
-! Define "Conventions" global attribute
-  i_rc = NF90_PUT_ATT(f_e,NF90_GLOBAL,'Conventions',"CF-1.1")
-!-
-! Add the DOMAIN attributes if needed
-  CALL flio_dom_att (f_e,id_dom)
-!-
-! Keep the file information
-  nw_id(f_i) = f_e
-  CALL flio_inf (f_e, &
- &  nb_dims=nw_nd(f_i),id_unlm=nw_un(f_i),nb_atts=nw_na(f_i), &
- &  nn_idm=nw_di(:,f_i),nn_ldm=nw_dl(:,f_i),nn_aid=nw_ai(:,f_i))
-!-
-! Return the created file name if needed
-  IF (PRESENT(c_f_n)) THEN
-    IF (LEN(c_f_n) >= LEN_TRIM(f_nw)) THEN
-      c_f_n = TRIM(f_nw)
-    ELSE
-      CALL ipslerr (3,'fliocrfd', &
- &     'the length of "c_f_n" is not sufficient to receive', &
- &     'the name of the created file :',TRIM(f_nw))
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) '<-fliocrfd'
-  ENDIF
-!----------------------
-END SUBROUTINE fliocrfd
-!===
-SUBROUTINE fliopstc &
- & (f_i,x_axis,x_axis_2d,y_axis,y_axis_2d,z_axis, &
- &      t_axis,t_init,t_step,t_calendar)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  REAL,DIMENSION(:),OPTIONAL,INTENT(IN)    :: x_axis,y_axis
-  REAL,DIMENSION(:,:),OPTIONAL,INTENT(IN)  :: x_axis_2d,y_axis_2d
-  REAL,DIMENSION(:),OPTIONAL,INTENT(IN)    :: z_axis
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: t_axis
-  CHARACTER(LEN=*),OPTIONAL,INTENT(IN)     :: t_calendar
-  REAL,OPTIONAL,INTENT(IN)                 :: t_init,t_step
-!-
-  INTEGER :: i_rc,f_e
-  INTEGER :: lonid,latid,levid,timeid
-  INTEGER :: j_yy,j_mo,j_dd,j_hh,j_mn,j_ss
-  REAL    :: dt,r_ss,v_min,v_max
-  INTEGER :: k,k_1,k_2
-  LOGICAL :: l_tmp
-  CHARACTER(LEN=20) :: c_tmp1
-  CHARACTER(LEN=40) :: c_tmp2
-  CHARACTER(LEN=80) :: c_tmp3
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliopstc"
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliopstc',f_i,f_e)
-!-
-! Validate the coherence of the arguments
-!-
-  IF (    (PRESENT(x_axis).AND.PRESENT(x_axis_2d)) &
- &    .OR.(PRESENT(y_axis).AND.PRESENT(y_axis_2d)) ) THEN
-    CALL ipslerr (3,'fliopstc', &
- &    'The [x/y]_axis arguments', &
- &    'are not coherent :',&
- &    'can not handle two [x/y]_axis')
-  ENDIF
-!-
-  IF (    PRESENT(x_axis).OR.PRESENT(x_axis_2d) &
- &    .OR.PRESENT(y_axis).OR.PRESENT(y_axis_2d) ) THEN
-    k_1=nw_ai(k_lon,f_i); k_2=nw_ai(k_lat,f_i);
-  ENDIF
-!-
-! Define the longitude axis
-!-
-  IF (PRESENT(x_axis).OR.PRESENT(x_axis_2d)) THEN
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Define the Longitude axis'
-    ENDIF
-!---
-    IF (PRESENT(x_axis)) THEN
-      IF (SIZE(x_axis) /= nw_dl(k_1,f_i)) THEN
-        CALL ipslerr (3,'fliopstc', &
- &       'Invalid x_axis dimension :', &
- &       'not equal to the dimension', &
- &       'defined at the creation of the file')
-      ENDIF
-    ELSE
-      IF (    (SIZE(x_axis_2d,DIM=1) /= nw_dl(k_1,f_i)) &
- &        .OR.(SIZE(x_axis_2d,DIM=2) /= nw_dl(k_2,f_i)) ) THEN
-        CALL ipslerr (3,'fliopstc', &
- &       'Invalid x_axis_2d dimensions :', &
- &       'not equal to the dimensions', &
- &       'defined at the creation of the file')
-      ENDIF
-    ENDIF
-!---
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    IF (PRESENT(x_axis)) THEN
-      i_rc = NF90_DEF_VAR(f_e,"lon",NF90_REAL4, &
- &                        nw_di(k_1,f_i),lonid)
-      v_min = MINVAL(x_axis)
-      v_max = MAXVAL(x_axis)
-    ELSE
-      i_rc = NF90_DEF_VAR(f_e,"nav_lon",NF90_REAL4, &
- &             nw_di((/k_1,k_2/),f_i),lonid)
-      v_min = MINVAL(x_axis_2d)
-      v_max = MAXVAL(x_axis_2d)
-    ENDIF
-    i_rc = NF90_PUT_ATT(f_e,lonid,"axis","X")
-    i_rc = NF90_PUT_ATT(f_e,lonid,'standard_name',"longitude")
-    i_rc = NF90_PUT_ATT(f_e,lonid,'units',"degrees_east")
-    i_rc = NF90_PUT_ATT(f_e,lonid,'valid_min',REAL(v_min,KIND=4))
-    i_rc = NF90_PUT_ATT(f_e,lonid,'valid_max',REAL(v_max,KIND=4))
-  ENDIF
-!-
-! Define the Latitude axis
-!-
-  IF (PRESENT(y_axis).OR.PRESENT(y_axis_2d)) THEN
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Define the Latitude axis'
-    ENDIF
-!---
-    IF (PRESENT(y_axis)) THEN
-      IF (SIZE(y_axis) /= nw_dl(k_2,f_i)) THEN
-        CALL ipslerr (3,'fliopstc', &
- &       'Invalid y_axis dimension :', &
- &       'not equal to the dimension', &
- &       'defined at the creation of the file')
-      ENDIF
-    ELSE
-      IF (    (SIZE(y_axis_2d,DIM=1) /= nw_dl(k_1,f_i)) &
- &        .OR.(SIZE(y_axis_2d,DIM=2) /= nw_dl(k_2,f_i)) ) THEN
-        CALL ipslerr (3,'fliopstc', &
- &       'Invalid y_axis_2d dimensions :', &
- &       'not equal to the dimensions', &
- &       'defined at the creation of the file')
-      ENDIF
-    ENDIF
-!---
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    IF (PRESENT(y_axis)) THEN
-      i_rc = NF90_DEF_VAR(f_e,"lat",NF90_REAL4, &
- &                        nw_di(k_2,f_i),latid)
-      v_min = MINVAL(y_axis)
-      v_max = MAXVAL(y_axis)
-    ELSE
-      i_rc = NF90_DEF_VAR(f_e,"nav_lat",NF90_REAL4, &
- &             nw_di((/k_1,k_2/),f_i),latid)
-      v_min = MINVAL(y_axis_2d)
-      v_max = MAXVAL(y_axis_2d)
-    ENDIF
-    i_rc = NF90_PUT_ATT(f_e,latid,"axis","Y")
-    i_rc = NF90_PUT_ATT(f_e,latid,'standard_name',"latitude")
-    i_rc = NF90_PUT_ATT(f_e,latid,'units',"degrees_north")
-    i_rc = NF90_PUT_ATT(f_e,latid,'valid_min',REAL(v_min,KIND=4))
-    i_rc = NF90_PUT_ATT(f_e,latid,'valid_max',REAL(v_max,KIND=4))
-  ENDIF
-!-
-! Define the Vertical axis
-!-
-  IF (PRESENT(z_axis)) THEN
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Define the Vertical axis'
-    ENDIF
-!---
-    k_1=nw_ai(k_lev,f_i);
-!---
-    IF (SIZE(z_axis) /= nw_dl(k_1,f_i)) THEN
-      CALL ipslerr (3,'fliopstc', &
- &     'Invalid z_axis dimension :', &
- &     'not equal to the dimension', &
- &     'defined at the creation of the file')
-    ENDIF
-!---
-    v_min = MINVAL(z_axis)
-    v_max = MAXVAL(z_axis)
-!---
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    i_rc = NF90_DEF_VAR(f_e,'lev',NF90_REAL4, &
- &                      nw_di(k_1,f_i),levid)
-    i_rc = NF90_PUT_ATT(f_e,levid,"axis","Z")
-    i_rc = NF90_PUT_ATT(f_e,levid,'standard_name','model_level_number')
-    i_rc = NF90_PUT_ATT(f_e,levid,'units','sigma_level')
-    i_rc = NF90_PUT_ATT(f_e,levid,'long_name','Sigma Levels')
-    i_rc = NF90_PUT_ATT(f_e,levid,'valid_min',REAL(v_min,KIND=4))
-    i_rc = NF90_PUT_ATT(f_e,levid,'valid_max',REAL(v_max,KIND=4))
-  ENDIF
-!-
-! Define the Time axis
-!-
-  IF (PRESENT(t_axis).AND.PRESENT(t_init).AND.PRESENT(t_step)) THEN
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Define the Time axis'
-    ENDIF
-!---
-    k_1=nw_ai(k_tim,f_i);
-!---
-    IF (     (nw_dl(k_1,f_i) /= 0) &
- &      .AND.(SIZE(t_axis) /= nw_dl(k_1,f_i)) ) THEN
-      CALL ipslerr (3,'fliopstc', &
- &     'Invalid t_axis dimension :', &
- &     'not equal to the dimension', &
- &     'defined at the creation of the file')
-    ENDIF
-!-- Retrieve the calendar date
-    CALL lock_calendar (old_status=l_tmp)
-    IF (PRESENT(t_calendar)) THEN
-      CALL ioget_calendar (c_tmp1)
-      CALL lock_calendar (new_status=.FALSE.)
-      CALL ioconf_calendar (TRIM(t_calendar))
-    ENDIF
-    CALL ju2ymds (t_init,j_yy,j_mo,j_dd,r_ss)
-    IF (PRESENT(t_calendar)) THEN
-      CALL lock_calendar (new_status=.FALSE.)
-      CALL ioconf_calendar (TRIM(c_tmp1))
-    ENDIF
-    CALL lock_calendar (new_status=l_tmp)
-!--
-    k=NINT(r_ss)
-    j_hh=k/3600
-    k=k-3600*j_hh
-    j_mn=k/60
-    j_ss=k-60*j_mn
-!-- Calculate the step unit
-    IF      (ABS(t_step) >= 604800.) THEN
-      dt = t_step/604800.
-      c_tmp2 = 'weeks'
-    ELSE IF (ABS(t_step) >= 86400.) THEN
-      dt = t_step/86400.
-      c_tmp2 = 'days'
-    ELSE IF (ABS(t_step) >=  3600.) THEN
-      dt = t_step/3600.
-      c_tmp2 = 'hours'
-    ELSE IF (ABS(t_step) >=    60.) THEN
-      dt = t_step/60.
-      c_tmp2 = 'minutes'
-    ELSE
-      dt = t_step
-      c_tmp2 = 'seconds'
-    ENDIF
-!---
-    c_tmp1 = ''
-    IF (ABS(dt-NINT(dt)) <= ABS(10.*EPSILON(dt))) THEN
-      IF (NINT(dt) /= 1) THEN
-        WRITE (UNIT=c_tmp1,FMT='(I15)') NINT(dt)
-      ENDIF
-    ELSE
-      IF (dt < 1.) THEN
-       WRITE (UNIT=c_tmp1,FMT='(F8.5)') dt
-      ELSE
-       WRITE (UNIT=c_tmp1,FMT='(F17.5)') dt
-      ENDIF
-      DO k=LEN_TRIM(c_tmp1),1,-1
-        IF (c_tmp1(k:k) /= '0') THEN
-          EXIT
-        ELSE
-          c_tmp1(k:k) = ' '
-        ENDIF
-      ENDDO
-    ENDIF
-    c_tmp2 = TRIM(c_tmp1)//' '//TRIM(c_tmp2)
-    WRITE (UNIT=c_tmp3, &
- &   FMT='(A,I4.4,"-",I2.2,"-",I2.2," ",I2.2,":",I2.2,":",I2.2)') &
- &    TRIM(ADJUSTL(c_tmp2))//' since ',j_yy,j_mo,j_dd,j_hh,j_mn,j_ss
-!---
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    i_rc = NF90_DEF_VAR(f_e,'time',NF90_REAL4, &
- &                      nw_di(k_1,f_i),timeid)
-    i_rc = NF90_PUT_ATT(f_e,timeid,"axis",'T')
-    i_rc = NF90_PUT_ATT(f_e,timeid,'standard_name','time')
-    i_rc = NF90_PUT_ATT(f_e,timeid,'long_name','time steps')
-    IF (PRESENT(t_calendar)) THEN
-      i_rc = NF90_PUT_ATT(f_e,timeid,'calendar',TRIM(t_calendar))
-    ENDIF
-    i_rc = NF90_PUT_ATT(f_e,timeid,'units',TRIM(c_tmp3))
-  ELSE IF (PRESENT(t_axis).OR.PRESENT(t_init).OR.PRESENT(t_step)) THEN
-    CALL ipslerr (3,'fliopstc', &
- &   'For time axis and coordinates', &
- &   'arguments t_axis AND t_init AND t_step', &
- &   'must be PRESENT')
-  ENDIF
-!-
-! Ensuring data mode
-!-
-    CALL flio_hdm (f_i,f_e,.FALSE.)
-!-
-! Create the longitude axis
-!-
-  IF (PRESENT(x_axis).OR.PRESENT(x_axis_2d)) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Create the Longitude axis'
-    ENDIF
-    IF (PRESENT(x_axis)) THEN
-      i_rc = NF90_PUT_VAR(f_e,lonid,x_axis(:))
-    ELSE
-      i_rc = NF90_PUT_VAR(f_e,lonid,x_axis_2d(:,:))
-    ENDIF
-  ENDIF
-!-
-! Create the Latitude axis
-!-
-  IF (PRESENT(y_axis).OR.PRESENT(y_axis_2d)) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Create the Latitude axis'
-    ENDIF
-    IF (PRESENT(y_axis)) THEN
-      i_rc = NF90_PUT_VAR(f_e,latid,y_axis(:))
-    ELSE
-      i_rc = NF90_PUT_VAR(f_e,latid,y_axis_2d(:,:))
-    ENDIF
-  ENDIF
-!-
-! Create the Vertical axis
-!-
-  IF (PRESENT(z_axis)) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Create the Vertical axis'
-    ENDIF
-    i_rc = NF90_PUT_VAR(f_e,levid,z_axis(:))
-  ENDIF
-!-
-! Create the Time axis
-!-
-  IF (PRESENT(t_axis)) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliopstc : Create the Time axis'
-    ENDIF
-    i_rc = NF90_PUT_VAR(f_e,timeid,REAL(t_axis(:)))
-  ENDIF
-!-
-! Keep all this information
-!-
-  CALL flio_inf (f_e,nb_vars=nw_nv(f_i),nb_atts=nw_na(f_i))
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliopstc"
-  ENDIF
-!----------------------
-END SUBROUTINE fliopstc
-!===
-SUBROUTINE fliodv_r0d &
- & (f_i,v_n,v_t, &
- &  axis,standard_name,long_name,units,valid_min,valid_max)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER,OPTIONAL,INTENT(IN) :: v_t
-  CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: &
- & axis,standard_name,long_name,units
-  REAL,OPTIONAL,INTENT(IN) :: valid_min,valid_max
-!---------------------------------------------------------------------
-  CALL flio_udv &
- &  (f_i,0,v_n,(/0/),v_t, &
- &   axis,standard_name,long_name,units,valid_min,valid_max)
-!------------------------
-END SUBROUTINE fliodv_r0d
-!===
-SUBROUTINE fliodv_rnd &
- & (f_i,v_n,v_d,v_t, &
- &  axis,standard_name,long_name,units,valid_min,valid_max)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER,DIMENSION(:),INTENT(IN) :: v_d
-  INTEGER,OPTIONAL,INTENT(IN) :: v_t
-  CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: &
- & axis,standard_name,long_name,units
-  REAL,OPTIONAL,INTENT(IN) :: valid_min,valid_max
-!---------------------------------------------------------------------
-  CALL flio_udv &
- &  (f_i,SIZE(v_d),v_n,v_d,v_t, &
- &   axis,standard_name,long_name,units,valid_min,valid_max)
-!------------------------
-END SUBROUTINE fliodv_rnd
-!===
-SUBROUTINE flio_udv &
- & (f_i,n_d,v_n,v_d,v_t, &
- &  axis,standard_name,long_name,units,valid_min,valid_max)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i,n_d
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER,DIMENSION(:),INTENT(IN) :: v_d
-  INTEGER,OPTIONAL,INTENT(IN) :: v_t
-  CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: &
- & axis,standard_name,long_name,units
-  REAL,OPTIONAL,INTENT(IN) :: valid_min,valid_max
-!-
-  INTEGER :: f_e,m_k,i_v,i_rc,ii,idd
-  INTEGER,DIMENSION(nb_vd_mx) :: a_i
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliodefv ",TRIM(v_n)," ",n_d,"D"
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliodefv',f_i,f_e)
-!-
-  IF (n_d > 0) THEN
-    IF (n_d > nb_vd_mx) THEN
-      CALL ipslerr (3,'fliodefv', &
- &     'Too many dimensions', &
- &     'required for the variable',TRIM(v_n))
-    ENDIF
-  ENDIF
-!-
-  DO ii=1,n_d
-    IF ( (v_d(ii) >= 1).AND.(v_d(ii) <= nb_fd_mx) ) THEN
-      idd = nw_di(v_d(ii),f_i)
-      IF (idd > 0) THEN
-        a_i(ii) = idd
-      ELSE
-        CALL ipslerr (3,'fliodefv', &
- &       'Invalid dimension identifier','(not defined)',' ')
-      ENDIF
-    ELSE
-      CALL ipslerr (3,'fliodefv', &
- &     'Invalid dimension identifier','(not supported)',' ')
-    ENDIF
-  ENDDO
-!-
-  i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-!---
-    IF (PRESENT(v_t)) THEN
-      IF      (v_t == flio_i) THEN
-        IF (i_std == i_8) THEN
-!-------- Not yet supported by NETCDF
-!-------- m_k = flio_i8
-          m_k = flio_i4
-        ELSE
-          m_k = flio_i4
-        ENDIF
-      ELSE IF (v_t == flio_r) THEN
-        IF (r_std == r_8) THEN
-          m_k = flio_r8
-        ELSE
-          m_k = flio_r4
-        ENDIF
-      ELSE
-        m_k = v_t
-      ENDIF
-    ELSE IF (r_std == r_8) THEN
-      m_k = flio_r8
-    ELSE
-      m_k = flio_r4
-    ENDIF
-    IF (n_d > 0) THEN
-      i_rc = NF90_DEF_VAR(f_e,v_n,m_k,a_i(1:n_d),i_v)
-    ELSE
-      i_rc = NF90_DEF_VAR(f_e,v_n,m_k,i_v)
-    ENDIF
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliodefv', &
- &      'Variable '//TRIM(v_n)//' not defined','Error :', &
- &      TRIM(NF90_STRERROR(i_rc)))
-    ENDIF
-    nw_nv(f_i) = nw_nv(f_i)+1
-!---
-    IF (PRESENT(axis)) THEN
-      i_rc = NF90_PUT_ATT(f_e,i_v,'axis',TRIM(axis))
-    ENDIF
-    IF (PRESENT(standard_name)) THEN
-      i_rc = NF90_PUT_ATT(f_e,i_v,'standard_name',TRIM(standard_name))
-    ENDIF
-    IF (PRESENT(long_name)) THEN
-      i_rc = NF90_PUT_ATT(f_e,i_v,'long_name',TRIM(long_name))
-    ENDIF
-    IF (PRESENT(units)) THEN
-      i_rc = NF90_PUT_ATT(f_e,i_v,'units',TRIM(units))
-    ENDIF
-    IF (PRESENT(valid_min)) THEN
-      i_rc = NF90_PUT_ATT(f_e,i_v,'valid_min',valid_min)
-    ENDIF
-    IF (PRESENT(valid_max)) THEN
-      i_rc = NF90_PUT_ATT(f_e,i_v,'valid_max',valid_max)
-    ENDIF
-!---
-  ELSE
-    CALL ipslerr (3,'fliodefv','Variable',TRIM(v_n),'already exist')
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliodefv"
-  ENDIF
-!----------------------
-END SUBROUTINE flio_udv
-!===
-SUBROUTINE fliopv_i40 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_40=v_v,start=start)
-!------------------------
-END SUBROUTINE fliopv_i40
-!===
-SUBROUTINE fliopv_i41 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_41=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i41
-!===
-SUBROUTINE fliopv_i42 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_42=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i42
-!===
-SUBROUTINE fliopv_i43 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_43=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i43
-!===
-SUBROUTINE fliopv_i44 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_44=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i44
-!===
-SUBROUTINE fliopv_i45 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_45=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i45
-!===
-SUBROUTINE fliopv_i20 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_20=v_v,start=start)
-!------------------------
-END SUBROUTINE fliopv_i20
-!===
-SUBROUTINE fliopv_i21 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_21=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i21
-!===
-SUBROUTINE fliopv_i22 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_22=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i22
-!===
-SUBROUTINE fliopv_i23 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_23=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i23
-!===
-SUBROUTINE fliopv_i24 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_24=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i24
-!===
-SUBROUTINE fliopv_i25 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,i_25=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_i25
-!===
-!?INTEGERS of KIND 1 are not supported on all computers
-!?SUBROUTINE fliopv_i10 (f_i,v_n,v_v,start)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),INTENT(IN) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!?!---------------------------------------------------------------------
-!?  CALL flio_upv (f_i,v_n,i_10=v_v,start=start)
-!?!------------------------
-!?END SUBROUTINE fliopv_i10
-!?!===
-!?SUBROUTINE fliopv_i11 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:),INTENT(IN) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_upv (f_i,v_n,i_11=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliopv_i11
-!?!===
-!?SUBROUTINE fliopv_i12 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:),INTENT(IN) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_upv (f_i,v_n,i_12=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliopv_i12
-!?!===
-!?SUBROUTINE fliopv_i13 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:,:),INTENT(IN) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_upv (f_i,v_n,i_13=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliopv_i13
-!?!===
-!?SUBROUTINE fliopv_i14 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:,:,:),INTENT(IN) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_upv (f_i,v_n,i_14=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliopv_i14
-!?!===
-!?SUBROUTINE fliopv_i15 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),INTENT(IN) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_upv (f_i,v_n,i_15=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliopv_i15
-!===
-SUBROUTINE fliopv_r40 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_40=v_v,start=start)
-!------------------------
-END SUBROUTINE fliopv_r40
-!===
-SUBROUTINE fliopv_r41 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_41=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r41
-!===
-SUBROUTINE fliopv_r42 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_42=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r42
-!===
-SUBROUTINE fliopv_r43 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_43=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r43
-!===
-SUBROUTINE fliopv_r44 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_44=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r44
-!===
-SUBROUTINE fliopv_r45 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_45=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r45
-!===
-SUBROUTINE fliopv_r80 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_80=v_v,start=start)
-!------------------------
-END SUBROUTINE fliopv_r80
-!===
-SUBROUTINE fliopv_r81 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_81=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r81
-!===
-SUBROUTINE fliopv_r82 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_82=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r82
-!===
-SUBROUTINE fliopv_r83 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_83=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r83
-!===
-SUBROUTINE fliopv_r84 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_84=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r84
-!===
-SUBROUTINE fliopv_r85 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),INTENT(IN) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_upv (f_i,v_n,r_85=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliopv_r85
-!===
-SUBROUTINE flio_upv &
- & (f_i,v_n, &
- &  i_40,i_41,i_42,i_43,i_44,i_45, &
- &  i_20,i_21,i_22,i_23,i_24,i_25, &
-!? &  i_10,i_11,i_12,i_13,i_14,i_15, &
- &  r_40,r_41,r_42,r_43,r_44,r_45, &
- &  r_80,r_81,r_82,r_83,r_84,r_85, &
- &  start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),INTENT(IN),OPTIONAL :: i_40
-  INTEGER(KIND=i_4),DIMENSION(:),INTENT(IN),OPTIONAL :: i_41
-  INTEGER(KIND=i_4),DIMENSION(:,:),INTENT(IN),OPTIONAL :: i_42
-  INTEGER(KIND=i_4),DIMENSION(:,:,:),INTENT(IN),OPTIONAL :: i_43
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:),INTENT(IN),OPTIONAL :: i_44
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),INTENT(IN),OPTIONAL :: i_45
-  INTEGER(KIND=i_2),INTENT(IN),OPTIONAL :: i_20
-  INTEGER(KIND=i_2),DIMENSION(:),INTENT(IN),OPTIONAL :: i_21
-  INTEGER(KIND=i_2),DIMENSION(:,:),INTENT(IN),OPTIONAL :: i_22
-  INTEGER(KIND=i_2),DIMENSION(:,:,:),INTENT(IN),OPTIONAL :: i_23
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:),INTENT(IN),OPTIONAL :: i_24
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),INTENT(IN),OPTIONAL :: i_25
-!?INTEGERS of KIND 1 are not supported on all computers
-!?INTEGER(KIND=i_1),INTENT(IN),OPTIONAL :: i_10
-!?INTEGER(KIND=i_1),DIMENSION(:),INTENT(IN),OPTIONAL :: i_11
-!?INTEGER(KIND=i_1),DIMENSION(:,:),INTENT(IN),OPTIONAL :: i_12
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:),INTENT(IN),OPTIONAL :: i_13
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:),INTENT(IN),OPTIONAL :: i_14
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),INTENT(IN),OPTIONAL :: i_15
-  REAL(KIND=r_4),INTENT(IN),OPTIONAL :: r_40
-  REAL(KIND=r_4),DIMENSION(:),INTENT(IN),OPTIONAL :: r_41
-  REAL(KIND=r_4),DIMENSION(:,:),INTENT(IN),OPTIONAL :: r_42
-  REAL(KIND=r_4),DIMENSION(:,:,:),INTENT(IN),OPTIONAL :: r_43
-  REAL(KIND=r_4),DIMENSION(:,:,:,:),INTENT(IN),OPTIONAL :: r_44
-  REAL(KIND=r_4),DIMENSION(:,:,:,:,:),INTENT(IN),OPTIONAL :: r_45
-  REAL(KIND=r_8),INTENT(IN),OPTIONAL :: r_80
-  REAL(KIND=r_8),DIMENSION(:),INTENT(IN),OPTIONAL :: r_81
-  REAL(KIND=r_8),DIMENSION(:,:),INTENT(IN),OPTIONAL :: r_82
-  REAL(KIND=r_8),DIMENSION(:,:,:),INTENT(IN),OPTIONAL :: r_83
-  REAL(KIND=r_8),DIMENSION(:,:,:,:),INTENT(IN),OPTIONAL :: r_84
-  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),INTENT(IN),OPTIONAL :: r_85
-  INTEGER,DIMENSION(:),INTENT(IN),OPTIONAL :: start,count
-!-
-  INTEGER :: f_e,i_v,i_rc
-  CHARACTER(LEN=5) :: cvr_d
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    IF      (PRESENT(i_40)) THEN; cvr_d = "I1 0D";
-    ELSE IF (PRESENT(i_41)) THEN; cvr_d = "I1 1D";
-    ELSE IF (PRESENT(i_42)) THEN; cvr_d = "I1 2D";
-    ELSE IF (PRESENT(i_43)) THEN; cvr_d = "I1 3D";
-    ELSE IF (PRESENT(i_44)) THEN; cvr_d = "I1 4D";
-    ELSE IF (PRESENT(i_45)) THEN; cvr_d = "I1 5D";
-    ELSE IF (PRESENT(i_20)) THEN; cvr_d = "I2 0D";
-    ELSE IF (PRESENT(i_21)) THEN; cvr_d = "I2 1D";
-    ELSE IF (PRESENT(i_22)) THEN; cvr_d = "I2 2D";
-    ELSE IF (PRESENT(i_23)) THEN; cvr_d = "I2 3D";
-    ELSE IF (PRESENT(i_24)) THEN; cvr_d = "I2 4D";
-    ELSE IF (PRESENT(i_25)) THEN; cvr_d = "I2 5D";
-!?  ELSE IF (PRESENT(i_10)) THEN; cvr_d = "I4 0D";
-!?  ELSE IF (PRESENT(i_11)) THEN; cvr_d = "I4 1D";
-!?  ELSE IF (PRESENT(i_12)) THEN; cvr_d = "I4 2D";
-!?  ELSE IF (PRESENT(i_13)) THEN; cvr_d = "I4 3D";
-!?  ELSE IF (PRESENT(i_14)) THEN; cvr_d = "I4 4D";
-!?  ELSE IF (PRESENT(i_15)) THEN; cvr_d = "I4 5D";
-    ELSE IF (PRESENT(r_40)) THEN; cvr_d = "R4 0D";
-    ELSE IF (PRESENT(r_41)) THEN; cvr_d = "R4 1D";
-    ELSE IF (PRESENT(r_42)) THEN; cvr_d = "R4 2D";
-    ELSE IF (PRESENT(r_43)) THEN; cvr_d = "R4 3D";
-    ELSE IF (PRESENT(r_44)) THEN; cvr_d = "R4 4D";
-    ELSE IF (PRESENT(r_45)) THEN; cvr_d = "R4 5D";
-    ELSE IF (PRESENT(r_80)) THEN; cvr_d = "R8 0D";
-    ELSE IF (PRESENT(r_81)) THEN; cvr_d = "R8 1D";
-    ELSE IF (PRESENT(r_82)) THEN; cvr_d = "R8 2D";
-    ELSE IF (PRESENT(r_83)) THEN; cvr_d = "R8 3D";
-    ELSE IF (PRESENT(r_84)) THEN; cvr_d = "R8 4D";
-    ELSE IF (PRESENT(r_85)) THEN; cvr_d = "R8 5D";
-    ENDIF
-    WRITE(*,*) "->flioputv ",TRIM(v_n)," ",TRIM(cvr_d)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('flioputv',f_i,f_e)
-!-
-! Ensuring data mode
-!-
-  CALL flio_hdm (f_i,f_e,.FALSE.)
-!-
-  i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-  IF (i_rc == NF90_NOERR) THEN
-    IF      (PRESENT(i_40)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_40,start=start)
-    ELSE IF (PRESENT(i_41)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_41,start=start,count=count)
-    ELSE IF (PRESENT(i_42)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_42,start=start,count=count)
-    ELSE IF (PRESENT(i_43)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_43,start=start,count=count)
-    ELSE IF (PRESENT(i_44)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_44,start=start,count=count)
-    ELSE IF (PRESENT(i_45)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_45,start=start,count=count)
-    ELSE IF (PRESENT(i_20)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_20,start=start)
-    ELSE IF (PRESENT(i_21)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_21,start=start,count=count)
-    ELSE IF (PRESENT(i_22)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_22,start=start,count=count)
-    ELSE IF (PRESENT(i_23)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_23,start=start,count=count)
-    ELSE IF (PRESENT(i_24)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_24,start=start,count=count)
-    ELSE IF (PRESENT(i_25)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,i_25,start=start,count=count)
-!?  ELSE IF (PRESENT(i_10)) THEN
-!?    i_rc = NF90_PUT_VAR(f_e,i_v,i_10,start=start)
-!?  ELSE IF (PRESENT(i_11)) THEN
-!?    i_rc = NF90_PUT_VAR(f_e,i_v,i_11,start=start,count=count)
-!?  ELSE IF (PRESENT(i_12)) THEN
-!?    i_rc = NF90_PUT_VAR(f_e,i_v,i_12,start=start,count=count)
-!?  ELSE IF (PRESENT(i_13)) THEN
-!?    i_rc = NF90_PUT_VAR(f_e,i_v,i_13,start=start,count=count)
-!?  ELSE IF (PRESENT(i_14)) THEN
-!?    i_rc = NF90_PUT_VAR(f_e,i_v,i_14,start=start,count=count)
-!?  ELSE IF (PRESENT(i_15)) THEN
-!?    i_rc = NF90_PUT_VAR(f_e,i_v,i_15,start=start,count=count)
-    ELSE IF (PRESENT(r_40)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_40,start=start)
-    ELSE IF (PRESENT(r_41)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_41,start=start,count=count)
-    ELSE IF (PRESENT(r_42)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_42,start=start,count=count)
-    ELSE IF (PRESENT(r_43)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_43,start=start,count=count)
-    ELSE IF (PRESENT(r_44)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_44,start=start,count=count)
-    ELSE IF (PRESENT(r_45)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_45,start=start,count=count)
-    ELSE IF (PRESENT(r_80)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_80,start=start)
-    ELSE IF (PRESENT(r_81)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_81,start=start,count=count)
-    ELSE IF (PRESENT(r_82)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_82,start=start,count=count)
-    ELSE IF (PRESENT(r_83)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_83,start=start,count=count)
-    ELSE IF (PRESENT(r_84)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_84,start=start,count=count)
-    ELSE IF (PRESENT(r_85)) THEN
-      i_rc = NF90_PUT_VAR(f_e,i_v,r_85,start=start,count=count)
-    ENDIF
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'flioputv', &
- &      'Variable '//TRIM(v_n)//' not put','Error :', &
- &      TRIM(NF90_STRERROR(i_rc)))
-    ENDIF
-  ELSE
-    CALL ipslerr (3,'flioputv','Variable',TRIM(v_n),'not defined')
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioputv"
-  ENDIF
-!----------------------
-END SUBROUTINE flio_upv
-!===
-SUBROUTINE fliopa_r4_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=4),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,1,v_n,a_n,avr4=(/a_v/))
-!--------------------------
-END SUBROUTINE fliopa_r4_0d
-!===
-SUBROUTINE fliopa_r4_1d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=4),DIMENSION(:),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,SIZE(a_v),v_n,a_n,avr4=a_v)
-!--------------------------
-END SUBROUTINE fliopa_r4_1d
-!===
-SUBROUTINE fliopa_r8_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=8),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,1,v_n,a_n,avr8=(/a_v/))
-!--------------------------
-END SUBROUTINE fliopa_r8_0d
-!===
-SUBROUTINE fliopa_r8_1d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=8),DIMENSION(:),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,SIZE(a_v),v_n,a_n,avr8=a_v)
-!--------------------------
-END SUBROUTINE fliopa_r8_1d
-!===
-SUBROUTINE fliopa_i4_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  INTEGER(KIND=4),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,1,v_n,a_n,avi4=(/a_v/))
-!--------------------------
-END SUBROUTINE fliopa_i4_0d
-!===
-SUBROUTINE fliopa_i4_1d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  INTEGER(KIND=4),DIMENSION(:),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,SIZE(a_v),v_n,a_n,avi4=a_v)
-!--------------------------
-END SUBROUTINE fliopa_i4_1d
-!===
-SUBROUTINE fliopa_tx_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  CHARACTER(LEN=*),INTENT(IN) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_upa (f_i,1,v_n,a_n,avtx=a_v)
-!--------------------------
-END SUBROUTINE fliopa_tx_0d
-!===
-SUBROUTINE flio_upa (f_i,l_a,v_n,a_n,avr4,avr8,avi4,avtx)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i,l_a
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=4),DIMENSION(:),OPTIONAL,INTENT(IN) :: avr4
-  REAL(KIND=8),DIMENSION(:),OPTIONAL,INTENT(IN) :: avr8
-  INTEGER(KIND=4),DIMENSION(:),OPTIONAL,INTENT(IN) :: avi4
-  CHARACTER(LEN=*),OPTIONAL,INTENT(IN) :: avtx
-!-
-  INTEGER :: f_e,i_v,i_a,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioputa ",TRIM(v_n)," ",TRIM(a_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('flioputa',f_i,f_e)
-!-
-  IF (TRIM(v_n) == '?') THEN
-    i_v = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'flioputa', &
-       'Variable :',TRIM(v_n),'not found')
-    ENDIF
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,i_v,a_n,attnum=i_a)
-  IF ( (i_v == NF90_GLOBAL).AND.(i_rc /= NF90_NOERR) ) THEN
-    nw_na(f_i) = nw_na(f_i)+1
-  ENDIF
-  CALL flio_hdm (f_i,f_e,.TRUE.)
-  IF      (PRESENT(avr4)) THEN
-    i_rc = NF90_PUT_ATT(f_e,i_v,a_n,avr4(1:l_a))
-  ELSE IF (PRESENT(avr8)) THEN
-    i_rc = NF90_PUT_ATT(f_e,i_v,a_n,avr8(1:l_a))
-  ELSE IF (PRESENT(avi4)) THEN
-    i_rc = NF90_PUT_ATT(f_e,i_v,a_n,avi4(1:l_a))
-  ELSE IF (PRESENT(avtx)) THEN
-    i_rc = NF90_PUT_ATT(f_e,i_v,a_n,TRIM(avtx))
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioputa"
-  ENDIF
-!----------------------
-END SUBROUTINE flio_upa
-!===
-SUBROUTINE flioopfd (f_n,f_i,mode,nb_dim,nb_var,nb_gat)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(IN) :: f_n
-  INTEGER,INTENT(OUT) :: f_i
-  CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: mode
-  INTEGER,OPTIONAL,INTENT(OUT) :: nb_dim,nb_var,nb_gat
-!-
-  INTEGER :: i_rc,f_e,m_c
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) '->flioopfd, file name : ',TRIM(f_n)
-  ENDIF
-!-
-! Search for a free local identifier
-!-
-  f_i = flio_rid()
-  IF (f_i < 0) THEN
-    CALL ipslerr (3,'flioopfd', &
-      'Too many files.','Please increase nb_fi_mx', &
-      'in module fliocom.f90.')
-  ENDIF
-!-
-! Check the mode
-!-
-  IF (PRESENT(mode)) THEN
-    IF (TRIM(MODE) == "WRITE") THEN
-      m_c = NF90_WRITE
-    ELSE
-      m_c = NF90_NOWRITE
-    ENDIF
-  ELSE
-    m_c = NF90_NOWRITE
-  ENDIF
-!-
-! Open the file.
-!-
-  i_rc = NF90_OPEN(TRIM(f_n),m_c,f_e)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (3,'flioopfd', &
- &   'Could not open file :',TRIM(f_n), &
- &   TRIM(NF90_STRERROR(i_rc))//' (Netcdf)')
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) '  flioopfd, model file-id : ',f_e
-  ENDIF
-!-
-! Retrieve and keep information about the file
-!-
-  nw_id(f_i) = f_e
-  lw_hm(f_i) = .FALSE.
-  CALL flio_inf (f_e, &
- &  nb_dims=nw_nd(f_i),nb_vars=nw_nv(f_i), &
- &  nb_atts=nw_na(f_i),id_unlm=nw_un(f_i), &
- &  nn_idm=nw_di(:,f_i),nn_ldm=nw_dl(:,f_i),nn_aid=nw_ai(:,f_i))
-!-
-! Return information to the user
-!-
-  IF (PRESENT(nb_dim)) THEN
-    nb_dim = nw_nd(f_i)
-  ENDIF
-  IF (PRESENT(nb_var)) THEN
-    nb_var = nw_nv(f_i)
-  ENDIF
-  IF (PRESENT(nb_gat)) THEN
-    nb_gat = nw_na(f_i)
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,'("   flioopfd - dimensions :",/,(5(1X,I10),:))') &
- &    nw_dl(:,f_i)
-    WRITE(*,*) "<-flioopfd"
-  ENDIF
-!----------------------
-END SUBROUTINE flioopfd
-!===
-SUBROUTINE flioinqf &
- & (f_i,nb_dim,nb_var,nb_gat,id_uld,id_dim,ln_dim)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  INTEGER,OPTIONAL,INTENT(OUT) :: nb_dim,nb_var,nb_gat,id_uld
-  INTEGER,OPTIONAL,INTENT(OUT),DIMENSION(:) :: id_dim,ln_dim
-!-
-  INTEGER :: lll
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioinqf"
-  ENDIF
-!-
-  IF ( (f_i < 1).OR.(f_i > nb_fi_mx) ) THEN
-    CALL ipslerr (2,'flioinqf', &
- &   'Invalid file identifier',' ',' ')
-  ELSE IF (nw_id(f_i) <= 0) THEN
-    CALL ipslerr (2,'flioinqf', &
- &   'Unable to inquire about the file :','probably','not opened')
-  ELSE
-    IF (PRESENT(nb_dim)) THEN
-      nb_dim = nw_nd(f_i)
-    ENDIF
-    IF (PRESENT(nb_var)) THEN
-      nb_var = nw_nv(f_i)
-    ENDIF
-    IF (PRESENT(nb_gat)) THEN
-      nb_gat = nw_na(f_i)
-    ENDIF
-    IF (PRESENT(id_uld)) THEN
-      id_uld = nw_un(f_i)
-    ENDIF
-    IF (PRESENT(id_dim)) THEN
-      lll = SIZE(id_dim)
-      IF (lll < nw_nd(f_i)) THEN
-        CALL ipslerr (2,'flioinqf', &
- &       'Only the first identifiers', &
- &       'of the dimensions','will be returned')
-      ENDIF
-      lll=MIN(SIZE(id_dim),nw_nd(f_i))
-      id_dim(1:lll) = nw_di(1:lll,f_i)
-    ENDIF
-    IF (PRESENT(ln_dim)) THEN
-      lll = SIZE(ln_dim)
-      IF (lll < nw_nd(f_i)) THEN
-        CALL ipslerr (2,'flioinqf', &
- &       'Only the first lengths', &
- &       'of the dimensions','will be returned')
-      ENDIF
-      lll=MIN(SIZE(ln_dim),nw_nd(f_i))
-      ln_dim(1:lll) = nw_dl(1:lll,f_i)
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioinqf"
-  ENDIF
-!----------------------
-END SUBROUTINE flioinqf
-!===
-SUBROUTINE flioinqn &
- & (f_i,cn_dim,cn_var,cn_gat,cn_uld, &
- &  id_start,id_count,iv_start,iv_count,ia_start,ia_count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL,INTENT(OUT) :: &
- & cn_dim,cn_var,cn_gat
-  CHARACTER(LEN=*),OPTIONAL,INTENT(OUT) :: &
- & cn_uld
-  INTEGER,OPTIONAL,INTENT(IN) :: &
- & id_start,id_count,iv_start,iv_count,ia_start,ia_count
-!-
-  INTEGER :: f_e,i_s,i_w,iws,iwc,i_rc
-  LOGICAL :: l_ok
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioinqn"
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('flioinqn',f_i,f_e)
-!-
-  IF (PRESENT(cn_dim)) THEN
-    l_ok = .TRUE.
-    i_s = SIZE(cn_dim)
-    DO i_w=1,i_s
-      cn_dim(i_w)(:) = '?'
-    ENDDO
-    IF (PRESENT(id_start)) THEN
-      iws = id_start
-    ELSE
-      iws = 1
-    ENDIF
-    IF (PRESENT(id_count)) THEN
-      iwc = id_count
-    ELSE
-      iwc = nw_nd(f_i)
-    ENDIF
-    IF (iws > nw_nd(f_i)) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The start index of requested dimensions', &
- &     'is greater than the number of dimensions', &
- &     'in the file')
-    ELSE IF (iws < 1) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The start index of requested dimensions', &
- &     'is invalid', &
- &     '( < 1 )')
-    ENDIF
-    IF ((iws+iwc-1) > nw_nd(f_i)) THEN
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of requested dimensions', &
- &     'is greater than the number of dimensions', &
- &     'in the file')
-    ENDIF
-    IF (iwc > i_s) THEN
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of dimensions to retrieve', &
- &     'is greater than the size of the array,', &
- &     'only the first dimensions of the file will be returned')
-    ELSE IF (iwc < 1) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of requested dimensions', &
- &     'is invalid', &
- &     '( < 1 )')
-    ENDIF
-    IF (l_ok) THEN
-      DO i_w=1,MIN(iwc,i_s,nw_nd(f_i)-iws+1)
-        i_rc = NF90_INQUIRE_DIMENSION(f_e,i_w+iws-1,name=cn_dim(i_w))
-      ENDDO
-    ENDIF
-  ENDIF
-!-
-  IF (PRESENT(cn_var)) THEN
-    l_ok = .TRUE.
-    i_s = SIZE(cn_var)
-    DO i_w=1,i_s
-      cn_var(i_w)(:) = '?'
-    ENDDO
-    IF (PRESENT(iv_start)) THEN
-      iws = iv_start
-    ELSE
-      iws = 1
-    ENDIF
-    IF (PRESENT(iv_count)) THEN
-      iwc = iv_count
-    ELSE
-      iwc = nw_nv(f_i)
-    ENDIF
-    IF (iws > nw_nv(f_i)) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The start index of requested variables', &
- &     'is greater than the number of variables', &
- &     'in the file')
-    ELSE IF (iws < 1) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The start index of requested variables', &
- &     'is invalid', &
- &     '( < 1 )')
-    ENDIF
-    IF ((iws+iwc-1) > nw_nv(f_i)) THEN
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of requested variables', &
- &     'is greater than the number of variables', &
- &     'in the file')
-    ENDIF
-    IF (iwc > i_s) THEN
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of variables to retrieve', &
- &     'is greater than the size of the array,', &
- &     'only the first variables of the file will be returned')
-    ELSE IF (iwc < 1) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of requested variables', &
- &     'is invalid', &
- &     '( < 1 )')
-    ENDIF
-    IF (l_ok) THEN
-      DO i_w=1,MIN(iwc,i_s,nw_nv(f_i)-iws+1)
-        i_rc = NF90_INQUIRE_VARIABLE(f_e,i_w+iws-1,name=cn_var(i_w))
-      ENDDO
-    ENDIF
-  ENDIF
-!-
-  IF (PRESENT(cn_gat)) THEN
-    l_ok = .TRUE.
-    i_s = SIZE(cn_gat)
-    DO i_w=1,i_s
-      cn_gat(i_w)(:) = '?'
-    ENDDO
-    IF (PRESENT(ia_start)) THEN
-      iws = ia_start
-    ELSE
-      iws = 1
-    ENDIF
-    IF (PRESENT(ia_count)) THEN
-      iwc = ia_count
-    ELSE
-      iwc = nw_na(f_i)
-    ENDIF
-    IF (iws > nw_na(f_i)) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The start index of requested global attributes', &
- &     'is greater than the number of global attributes', &
- &     'in the file')
-    ELSE IF (iws < 1) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The start index of requested global attributes', &
- &     'is invalid', &
- &     '( < 1 )')
-    ENDIF
-    IF ((iws+iwc-1) > nw_na(f_i)) THEN
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of requested global attributes', &
- &     'is greater than the number of global attributes', &
- &     'in the file')
-    ENDIF
-    IF (iwc > i_s) THEN
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of global attributes to retrieve', &
- &     'is greater than the size of the array,', &
- &     'only the first global attributes of the file will be returned')
-    ELSE IF (iwc < 1) THEN
-      l_ok = .FALSE.
-      CALL ipslerr (2,'flioinqn', &
- &     'The number of requested global attributes', &
- &     'is invalid', &
- &     '( < 1 )')
-    ENDIF
-    IF (l_ok) THEN
-      DO i_w=1,MIN(iwc,i_s,nw_na(f_i)-iws+1)
-        i_rc = NF90_INQ_ATTNAME(f_e, &
- &              NF90_GLOBAL,i_w+iws-1,name=cn_gat(i_w))
-      ENDDO
-    ENDIF
-  ENDIF
-!-
-  IF (PRESENT(cn_uld)) THEN
-    cn_uld = '?'
-    IF (nw_un(f_i) > 0) THEN
-      i_rc = NF90_INQUIRE_DIMENSION(f_e,nw_un(f_i),name=cn_uld)
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioinqn"
-  ENDIF
-!----------------------
-END SUBROUTINE flioinqn
-!===
-SUBROUTINE fliogstc &
- & (f_i,x_axis,x_axis_2d,y_axis,y_axis_2d,z_axis, &
- &      t_axis,t_init,t_step,t_calendar, &
- &      x_start,x_count,y_start,y_count, &
- &      z_start,z_count,t_start,t_count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  REAL,DIMENSION(:),OPTIONAL,INTENT(OUT)    :: x_axis,y_axis
-  REAL,DIMENSION(:,:),OPTIONAL,INTENT(OUT)  :: x_axis_2d,y_axis_2d
-  REAL,DIMENSION(:),OPTIONAL,INTENT(OUT)    :: z_axis
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(OUT) :: t_axis
-  REAL,OPTIONAL,INTENT(OUT)                 :: t_init,t_step
-  CHARACTER(LEN=*),OPTIONAL,INTENT(OUT)     :: t_calendar
-  INTEGER,OPTIONAL,INTENT(IN) :: &
- &  x_start,x_count,y_start,y_count,z_start,z_count,t_start,t_count
-!-
-  INTEGER :: i_rc,f_e,i_v,it_t,nbdim,kv
-  INTEGER :: m_x,i_x,l_x,m_y,i_y,l_y,m_z,i_z,l_z,m_t,i_t,l_t
-  CHARACTER(LEN=NF90_MAX_NAME) :: name
-  CHARACTER(LEN=80) :: units
-  CHARACTER(LEN=20) :: c_tmp
-  CHARACTER(LEN=1) :: c_1
-  REAL    :: r_yy,r_mo,r_dd,r_ss,dtv,dtn
-  INTEGER :: j_yy,j_mo,j_dd,j_hh,j_mn,j_ss
-  LOGICAL :: l_ok,l_tmp
-!-
-  REAL,DIMENSION(:),ALLOCATABLE :: v_tmp
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliogstc"
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliogstc',f_i,f_e)
-!-
-! Validate the coherence of the arguments
-!-
-  IF (    (PRESENT(x_axis).AND.PRESENT(x_axis_2d)) &
- &    .OR.(PRESENT(y_axis).AND.PRESENT(y_axis_2d)) ) THEN
-    CALL ipslerr (3,'fliogstc', &
- &    'The [x/y]_axis arguments', &
- &    'are not coherent :',&
- &    'can not handle two [x/y]_axis')
-  ENDIF
-!-
-! Retrieve spatio-temporal dimensions
-!-
-  IF (nw_ai(k_lon,f_i) > 0) THEN
-    m_x = nw_dl(nw_ai(k_lon,f_i),f_i);
-  ELSE
-    m_x = -1;
-  ENDIF
-  IF (nw_ai(k_lat,f_i) > 0) THEN
-    m_y = nw_dl(nw_ai(k_lat,f_i),f_i);
-  ELSE
-    m_y = -1;
-  ENDIF
-  IF (nw_ai(k_lev,f_i) > 0) THEN
-    m_z = nw_dl(nw_ai(k_lev,f_i),f_i);
-  ELSE
-    m_z = -1;
-  ENDIF
-  IF (nw_ai(k_tim,f_i) > 0) THEN
-    m_t = nw_dl(nw_ai(k_tim,f_i),f_i);
-  ELSE
-    m_t = -1;
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,'("   fliogstc - dimensions :",/,(5(1X,I10),:))') &
- &    m_x,m_y,m_z,m_t
-  ENDIF
-!-
-! Initialize the x-y indices
-!-
-  IF (    PRESENT(x_axis)    &
- &    .OR.PRESENT(x_axis_2d) &
- &    .OR.PRESENT(y_axis_2d) ) THEN
-    IF (PRESENT(x_start)) THEN
-      i_x = x_start
-    ELSE
-      i_x = 1
-    ENDIF
-    IF (PRESENT(x_count)) THEN
-      l_x = x_count
-    ELSE
-      l_x = m_x-i_x+1
-    ENDIF
-  ENDIF
-  IF (    PRESENT(y_axis)    &
- &    .OR.PRESENT(y_axis_2d) &
- &    .OR.PRESENT(x_axis_2d) ) THEN
-    IF (PRESENT(y_start)) THEN
-      i_y = y_start
-    ELSE
-      i_y = 1
-    ENDIF
-    IF (PRESENT(y_count)) THEN
-      l_y = y_count
-    ELSE
-      l_y = m_y-i_y+1
-    ENDIF
-  ENDIF
-  IF (PRESENT(x_axis)) THEN
-    IF (m_x <= 0) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'Requested x_axis', &
- &      'but the coordinate is not present','in the file')
-    ELSE IF ((i_x+l_x-1) > m_x) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'The requested size for the x_axis', &
- &      'is greater than the size of the coordinate','in the file')
-    ENDIF
-  ENDIF
-  IF (PRESENT(y_axis)) THEN
-    IF (m_y <= 0) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'Requested y_axis', &
- &      'but the coordinate is not present','in the file')
-    ELSE IF ((i_y+l_y-1) > m_y) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'The requested size for the y_axis', &
- &      'is greater than the size of the coordinate','in the file')
-    ENDIF
-  ENDIF
-  IF (PRESENT(x_axis_2d).OR.PRESENT(y_axis_2d) )THEN
-    IF ( (m_x <= 0).OR.(m_y <= 0) ) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'Requested [x/y]_axis_2d', &
- &      'but the coordinates are not iboth present','in the file')
-    ELSE IF ( ((i_x+l_x-1) > m_x).OR.((i_y+l_y-1) > m_y) ) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'The requested size for the [x/y]_axis_2d', &
- &      'is greater than the size of the coordinate','in the file')
-    ENDIF
-  ENDIF
-!-
-! Ensuring data mode
-!-
-  CALL flio_hdm (f_i,f_e,.FALSE.)
-!-
-! Extracting the x coordinate, if needed
-!-
-  IF (PRESENT(x_axis).OR.PRESENT(x_axis_2d)) THEN
-    CALL flio_qax (f_i,'x',i_v,nbdim)
-    IF (i_v > 0) THEN
-      IF      (nbdim == 1) THEN
-        IF (PRESENT(x_axis)) THEN
-          i_rc = NF90_GET_VAR(f_e,i_v,x_axis, &
- &                 start=(/i_x/),count=(/l_x/))
-        ELSE
-          ALLOCATE(v_tmp(l_x))
-          i_rc = NF90_GET_VAR(f_e,i_v,v_tmp, &
- &                 start=(/i_x/),count=(/l_x/))
-          DO kv=1,l_y
-            x_axis_2d(:,kv) = v_tmp(:)
-          ENDDO
-          DEALLOCATE(v_tmp)
-        ENDIF
-      ELSE IF (nbdim == 2) THEN
-        IF (PRESENT(x_axis)) THEN
-          l_ok = .TRUE.
-          IF (l_y > 1) THEN
-            ALLOCATE(v_tmp(l_y))
-            DO kv=i_x,i_x+l_x-1
-              i_rc = NF90_GET_VAR(f_e,i_v,v_tmp, &
- &                     start=(/kv,i_y/),count=(/1,l_y/))
-              IF (ANY(v_tmp(2:l_y) /= v_tmp(1))) THEN
-                l_ok = .FALSE.
-                EXIT
-              ENDIF
-            ENDDO
-            DEALLOCATE(v_tmp)
-          ENDIF
-          IF (l_ok) THEN
-            i_rc = NF90_GET_VAR(f_e,i_v,x_axis, &
- &                   start=(/i_x,i_y/),count=(/l_x,1/))
-          ELSE
-            CALL ipslerr (3,'fliogstc', &
- &            'Requested 1D x_axis', &
- &            'which have 2 not regular dimensions', &
- &            'in the file')
-          ENDIF
-        ELSE
-          i_rc = NF90_GET_VAR(f_e,i_v,x_axis_2d, &
- &                 start=(/i_x,i_y/),count=(/l_x,l_y/))
-        ENDIF
-      ELSE
-        CALL ipslerr (3,'fliogstc', &
- &        'Can not handle x_axis', &
- &        'that have more than 2 dimensions', &
- &        'in the file')
-      ENDIF
-    ELSE
-      CALL ipslerr (3,'fliogstc','No x_axis found','in the file',' ')
-    ENDIF
-  ENDIF
-!-
-! Extracting the y coordinate, if needed
-!-
-  IF (PRESENT(y_axis).OR.PRESENT(y_axis_2d)) THEN
-    CALL flio_qax (f_i,'y',i_v,nbdim)
-    IF (i_v > 0) THEN
-      IF      (nbdim == 1) THEN
-        IF (PRESENT(y_axis)) THEN
-          i_rc = NF90_GET_VAR(f_e,i_v,y_axis, &
- &                 start=(/i_y/),count=(/l_y/))
-        ELSE
-          ALLOCATE(v_tmp(l_y))
-          i_rc = NF90_GET_VAR(f_e,i_v,v_tmp, &
- &                 start=(/i_y/),count=(/l_y/))
-          DO kv=1,l_x
-            y_axis_2d(kv,:) = v_tmp(:)
-          ENDDO
-          DEALLOCATE(v_tmp)
-        ENDIF
-      ELSE IF (nbdim == 2) THEN
-        IF (PRESENT(y_axis)) THEN
-          l_ok = .TRUE.
-          IF (l_x > 1) THEN
-            ALLOCATE(v_tmp(l_x))
-            DO kv=i_y,i_y+l_y-1
-              i_rc = NF90_GET_VAR(f_e,i_v,v_tmp, &
- &                     start=(/i_x,kv/),count=(/l_x,1/))
-              IF (ANY(v_tmp(2:l_x) /= v_tmp(1))) THEN
-                l_ok = .FALSE.
-                EXIT
-              ENDIF
-            ENDDO
-            DEALLOCATE(v_tmp)
-          ENDIF
-          IF (l_ok) THEN
-            i_rc = NF90_GET_VAR(f_e,i_v,y_axis, &
- &                   start=(/i_x,i_y/),count=(/1,l_y/))
-          ELSE
-            CALL ipslerr (3,'fliogstc', &
- &            'Requested 1D y_axis', &
- &            'which have 2 not regular dimensions', &
- &            'in the file')
-          ENDIF
-        ELSE
-          i_rc = NF90_GET_VAR(f_e,i_v,y_axis_2d, &
- &                 start=(/i_x,i_y/),count=(/l_x,l_y/))
-        ENDIF
-      ELSE
-        CALL ipslerr (3,'fliogstc', &
- &        'Can not handle y axis', &
- &        'that have more than 2 dimensions', &
- &        'in the file')
-      ENDIF
-    ELSE
-      CALL ipslerr (3,'fliogstc','No y_axis found','in the file',' ')
-    ENDIF
-  ENDIF
-!-
-! Extracting the z coordinate, if needed
-!-
-  IF (PRESENT(z_axis)) THEN
-    IF (PRESENT(z_start)) THEN
-      i_z = z_start
-    ELSE
-      i_z = 1
-    ENDIF
-    IF (PRESENT(z_count)) THEN
-      l_z = z_count
-    ELSE
-      l_z = m_z-i_z+1
-    ENDIF
-    IF ((i_z+l_z-1) > m_z) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'The requested size for the z axis', &
- &      'is greater than the size of the coordinate',&
- &      'in the file')
-    ENDIF
-    CALL flio_qax (f_i,'z',i_v,nbdim)
-    IF (i_v > 0) THEN
-      IF (nbdim == 1) THEN
-        i_rc = NF90_GET_VAR(f_e,i_v,z_axis, &
- &               start=(/i_z/),count=(/l_z/))
-      ELSE
-        CALL ipslerr (3,'fliogstc', &
- &        'Can not handle z_axis', &
- &        'that have more than 1 dimension', &
- &        'in the file')
-      ENDIF
-    ELSE
-      CALL ipslerr (3,'fliogstc','No z_axis found','in the file',' ')
-    ENDIF
-  ENDIF
-!-
-! Extracting the t coordinate, if needed
-!-
-  IF (PRESENT(t_axis).OR.PRESENT(t_init).OR.PRESENT(t_step)) THEN
-    CALL flio_qax (f_i,'t',i_v,nbdim)
-    IF (i_v < 0) THEN
-      CALL ipslerr (3,'fliogstc','No t_axis found','in the file',' ')
-    ENDIF
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliogstc - get time details'
-    ENDIF
-!---
-!-- Get all the details for the time
-!-- Prefered method is '"time_steps" since'
-!---
-    name=''
-    i_rc = NF90_INQUIRE_VARIABLE(f_e,i_v,name=name)
-    units=''
-    i_rc = NF90_GET_ATT(f_e,i_v,'units',units)
-    IF      (INDEX(units,' since ') > 0) THEN
-      it_t = 1
-    ELSE IF (INDEX(name,'tstep') > 0) THEN
-      it_t = 2
-    ELSE
-      it_t = 0;
-    ENDIF
-  ENDIF
-!-
-! Extracting the t coordinate, if needed
-!-
-  IF (PRESENT(t_axis)) THEN
-    IF (PRESENT(t_start)) THEN
-      i_t = t_start
-    ELSE
-      i_t = 1
-    ENDIF
-    IF (PRESENT(t_count)) THEN
-      l_t = t_count
-    ELSE
-      l_t = m_t-i_t+1
-    ENDIF
-    IF ((i_t+l_t-1) > m_t) THEN
-      CALL ipslerr (3,'fliogstc', &
- &      'The requested size for the t axis', &
- &      'is greater than the size of the coordinate',&
- &      'in the file')
-    ENDIF
-    ALLOCATE(v_tmp(l_t))
-    i_rc = NF90_GET_VAR(f_e,i_v,v_tmp, &
- &           start=(/i_t/),count=(/l_t/))
-    t_axis(1:l_t) = NINT(v_tmp(1:l_t))
-    DEALLOCATE(v_tmp)
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliogstc - first time : ',t_axis(1:1)
-    ENDIF
-  ENDIF
-!-
-! Extracting the time at the beginning, if needed
-!-
-  IF (PRESENT(t_init)) THEN
-!-- Find the calendar
-    CALL lock_calendar (old_status=l_tmp)
-    CALL ioget_calendar (c_tmp)
-    units = ''
-    i_rc = NF90_GET_ATT(f_e,i_v,'calendar',units)
-    IF (i_rc == NF90_NOERR) THEN
-      CALL lock_calendar (new_status=.FALSE.)
-      CALL ioconf_calendar (TRIM(units))
-    ENDIF
-    IF (it_t == 1) THEN
-      units = ''
-      i_rc = NF90_GET_ATT(f_e,i_v,'units',units)
-      units = units(INDEX(units,' since ')+7:LEN_TRIM(units))
-      READ (units,'(I4.4,5(A,I2.2))') &
- &      j_yy,c_1,j_mo,c_1,j_dd,c_1,j_hh,c_1,j_mn,c_1,j_ss
-      r_ss = j_hh*3600.+j_mn*60.+j_ss
-      CALL ymds2ju (j_yy,j_mo,j_dd,r_ss,t_init)
-    ELSE IF (it_t == 2) THEN
-      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,'year0',r_yy)
-      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,'month0',r_mo)
-      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,'day0',r_dd)
-      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,'sec0',r_ss)
-      j_yy = NINT(r_yy); j_mo = NINT(r_mo); j_dd = NINT(r_dd);
-      CALL ymds2ju (j_yy,j_mo,j_dd,r_ss,t_init)
-    ELSE
-      t_init = 0.
-    ENDIF
-    CALL lock_calendar (new_status=.FALSE.)
-    CALL ioconf_calendar (TRIM(c_tmp))
-    CALL lock_calendar (new_status=l_tmp)
-    IF (l_dbg) THEN
-      WRITE(*,*) '  fliogstc - time_type : '
-      WRITE(*,*) it_t
-      WRITE(*,*) '  fliogstc - year month day second t_init : '
-      WRITE(*,*) j_yy,j_mo,j_dd,r_ss,t_init
-    ENDIF
-  ENDIF
-!-
-! Extracting the timestep in seconds, if needed
-!-
-  IF (PRESENT(t_step)) THEN
-    IF      (it_t == 1) THEN
-      units = ''
-      i_rc = NF90_GET_ATT(f_e,i_v,'units',units)
-      units = ADJUSTL(units(1:INDEX(units,' since ')-1))
-      dtn = 1.
-      IF      (INDEX(units,"week") /= 0) THEN
-        kv  = INDEX(units,"week")
-        dtv = 604800.
-      ELSE IF (INDEX(units,"day")  /= 0) THEN
-        kv  = INDEX(units,"day")
-        dtv = 86400.
-      ELSE IF (INDEX(units,"h")    /= 0) THEN
-        kv  = INDEX(units,"h")
-        dtv = 3600.
-      ELSE IF (INDEX(units,"min")  /= 0) THEN
-        kv  = INDEX(units,"min")
-        dtv = 60.
-      ELSE IF (INDEX(units,"sec")  /= 0) THEN
-        kv  = INDEX(units,"sec")
-        dtv = 1.
-      ELSE IF (INDEX(units,"timesteps") /= 0) THEN
-        kv  = INDEX(units,"timesteps")
-        i_rc = NF90_GET_ATT(f_e,i_v,'tstep_sec',dtv)
-        IF (i_rc /= NF90_NOERR) THEN
-          CALL ipslerr (3,'fliogstc','"timesteps" value', &
- &                        'not found','in the file')
-        ENDIF
-      ELSE
-        kv  = 1
-        dtv = 1.
-      ENDIF
-      IF (kv > 1) THEN
-        READ (unit=units(1:kv-1),FMT=*) dtn
-      ENDIF
-      t_step = dtn*dtv
-    ELSE IF (it_t == 2) THEN
-      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,'delta_tstep_sec',t_step)
-    ELSE
-      t_step = 1.
-    ENDIF
-  ENDIF
-!-
-! Extracting the calendar attribute, if needed
-!-
-  IF (PRESENT(t_calendar)) THEN
-    units = ''
-    i_rc = NF90_GET_ATT(f_e,i_v,'calendar',units)
-    IF (i_rc == NF90_NOERR) THEN
-      t_calendar = units
-    ELSE
-      t_calendar = "not found"
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliogstc"
-  ENDIF
-!----------------------
-END SUBROUTINE fliogstc
-!===
-SUBROUTINE flioinqv &
- & (f_i,v_n,l_ex,v_t,nb_dims,len_dims,id_dims, &
- &  nb_atts,cn_atts,ia_start,ia_count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  LOGICAL,INTENT(OUT) :: l_ex
-  INTEGER,OPTIONAL,INTENT(OUT) :: v_t,nb_dims,nb_atts
-  INTEGER,OPTIONAL,INTENT(OUT),DIMENSION(:) :: len_dims,id_dims
-  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL,INTENT(OUT) :: cn_atts
-  INTEGER,OPTIONAL,INTENT(IN) :: ia_start,ia_count
-!-
-  INTEGER :: f_e,i_v,n_w,i_s,i_w,iws,iwc,i_rc
-  LOGICAL :: l_ok
-  INTEGER,DIMENSION(NF90_MAX_VAR_DIMS) :: dim_ids
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioinqv ",TRIM(v_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('flioinqv',f_i,f_e)
-!-
-  i_v = -1
-  i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-!-
-  l_ex = ( (i_v >= 0).AND.(i_rc == NF90_NOERR) )
-!-
-  IF (l_ex) THEN
-    IF (PRESENT(v_t)) THEN
-      i_rc = NF90_INQUIRE_VARIABLE(f_e,i_v,xtype=v_t)
-    ENDIF
-    n_w = -1
-    IF (PRESENT(nb_dims).OR.PRESENT(len_dims)) THEN
-      i_rc = NF90_INQUIRE_VARIABLE(f_e,i_v, &
- &             ndims=n_w,dimids=dim_ids)
-      IF (PRESENT(nb_dims)) THEN
-        nb_dims = n_w
-      ENDIF
-      IF (PRESENT(len_dims)) THEN
-        i_s = SIZE(len_dims)
-        len_dims(:) = -1
-        IF (i_s < n_w) THEN
-          CALL ipslerr (2,'flioinqv', &
- &         'Only the first dimensions of the variable', &
- &         TRIM(v_n),'will be returned')
-        ENDIF
-        DO i_w=1,MIN(n_w,i_s)
-          i_rc = NF90_INQUIRE_DIMENSION(f_e,dim_ids(i_w), &
- &                                      len=len_dims(i_w))
-        ENDDO
-      ENDIF
-      IF (PRESENT(id_dims)) THEN
-        i_s = SIZE(id_dims)
-        id_dims(:) = -1
-        IF (i_s < n_w) THEN
-          CALL ipslerr (2,'flioinqv', &
- &         'The number of dimensions to retrieve', &
- &         'is greater than the size of the array,', &
- &         'only the first dimensions of "' &
- &           //TRIM(v_n)//'" will be returned')
-        ENDIF
-        i_w = MIN(n_w,i_s)
-        id_dims(1:i_w) = dim_ids(1:i_w)
-      ENDIF
-    ENDIF
-    IF (PRESENT(nb_atts).OR.PRESENT(cn_atts)) THEN
-      i_rc = NF90_INQUIRE_VARIABLE(f_e,i_v,nAtts=n_w)
-      IF (PRESENT(nb_atts)) THEN
-        nb_atts = n_w
-      ENDIF
-      IF (PRESENT(cn_atts)) THEN
-        l_ok = .TRUE.
-        i_s = SIZE(cn_atts)
-        DO i_w=1,i_s
-          cn_atts(i_w)(:) = '?'
-        ENDDO
-        IF (PRESENT(ia_start)) THEN
-          iws = ia_start
-        ELSE
-          iws = 1
-        ENDIF
-        IF (PRESENT(ia_count)) THEN
-          iwc = ia_count
-        ELSE
-          iwc = n_w
-        ENDIF
-        IF (iws > n_w) THEN
-          l_ok = .FALSE.
-          CALL ipslerr (2,'flioinqv', &
- &         'The start index of requested attributes', &
- &         'is greater than the number of attributes of', &
- &         '"'//TRIM(v_n)//'"')
-        ELSE IF (iws < 1) THEN
-          l_ok = .FALSE.
-          CALL ipslerr (2,'flioinqv', &
- &         'The start index of requested attributes', &
- &         'is invalid ( < 1 ) for', &
- &         '"'//TRIM(v_n)//'"')
-        ENDIF
-        IF ((iws+iwc-1) > n_w) THEN
-          CALL ipslerr (2,'flioinqv', &
- &         'The number of requested attributes', &
- &         'is greater than the number of attributes of', &
- &         '"'//TRIM(v_n)//'"')
-        ENDIF
-        IF (iwc > i_s) THEN
-          CALL ipslerr (2,'flioinqv', &
- &         'The number of attributes to retrieve', &
- &         'is greater than the size of the array,', &
- &         'only the first attributes of "' &
- &           //TRIM(v_n)//'" will be returned')
-        ELSE IF (iwc < 1) THEN
-          l_ok = .FALSE.
-          CALL ipslerr (2,'flioinqv', &
- &         'The number of requested attributes', &
- &         'is invalid ( < 1 ) for', &
- &         '"'//TRIM(v_n)//'"')
-        ENDIF
-        IF (l_ok) THEN
-          DO i_w=1,MIN(iwc,i_s,n_w-iws+1)
-            i_rc = NF90_INQ_ATTNAME(f_e, &
- &                  i_v,i_w+iws-1,name=cn_atts(i_w))
-          ENDDO
-        ENDIF
-      ENDIF
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioinqv"
-  ENDIF
-!----------------------
-END SUBROUTINE flioinqv
-!===
-SUBROUTINE fliogv_i40 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_40=v_v,start=start)
-!------------------------
-END SUBROUTINE fliogv_i40
-!===
-SUBROUTINE fliogv_i41 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_41=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i41
-!===
-SUBROUTINE fliogv_i42 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_42=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i42
-!===
-SUBROUTINE fliogv_i43 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_43=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i43
-!===
-SUBROUTINE fliogv_i44 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_44=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i44
-!===
-SUBROUTINE fliogv_i45 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_45=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i45
-!===
-SUBROUTINE fliogv_i20 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_20=v_v,start=start)
-!------------------------
-END SUBROUTINE fliogv_i20
-!===
-SUBROUTINE fliogv_i21 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_21=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i21
-!===
-SUBROUTINE fliogv_i22 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_22=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i22
-!===
-SUBROUTINE fliogv_i23 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_23=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i23
-!===
-SUBROUTINE fliogv_i24 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_24=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i24
-!===
-SUBROUTINE fliogv_i25 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,i_25=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_i25
-!===
-!?INTEGERS of KIND 1 are not supported on all computers
-!?SUBROUTINE fliogv_i10 (f_i,v_n,v_v,start)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),INTENT(OUT) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!?!---------------------------------------------------------------------
-!?  CALL flio_ugv (f_i,v_n,i_10=v_v,start=start)
-!?!------------------------
-!?END SUBROUTINE fliogv_i10
-!?!===
-!?SUBROUTINE fliogv_i11 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:),INTENT(OUT) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_ugv (f_i,v_n,i_11=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliogv_i11
-!?!===
-!?SUBROUTINE fliogv_i12 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:),INTENT(OUT) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_ugv (f_i,v_n,i_12=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliogv_i12
-!?!===
-!?SUBROUTINE fliogv_i13 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:,:),INTENT(OUT) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_ugv (f_i,v_n,i_13=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliogv_i13
-!?!===
-!?SUBROUTINE fliogv_i14 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:,:,:),INTENT(OUT) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_ugv (f_i,v_n,i_14=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliogv_i14
-!?!===
-!?SUBROUTINE fliogv_i15 (f_i,v_n,v_v,start,count)
-!?!---------------------------------------------------------------------
-!?  IMPLICIT NONE
-!?!-
-!?  INTEGER,INTENT(IN) :: f_i
-!?  CHARACTER(LEN=*),INTENT(IN) :: v_n
-!?  INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),INTENT(OUT) :: v_v
-!?  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!?!---------------------------------------------------------------------
-!?  CALL flio_ugv (f_i,v_n,i_15=v_v,start=start,count=count)
-!?!------------------------
-!?END SUBROUTINE fliogv_i15
-!===
-SUBROUTINE fliogv_r40 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_40=v_v,start=start)
-!------------------------
-END SUBROUTINE fliogv_r40
-!===
-SUBROUTINE fliogv_r41 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_41=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r41
-!===
-SUBROUTINE fliogv_r42 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_42=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r42
-!===
-SUBROUTINE fliogv_r43 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_43=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r43
-!===
-SUBROUTINE fliogv_r44 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_44=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r44
-!===
-SUBROUTINE fliogv_r45 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_4),DIMENSION(:,:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_45=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r45
-!===
-SUBROUTINE fliogv_r80 (f_i,v_n,v_v,start)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_80=v_v,start=start)
-!------------------------
-END SUBROUTINE fliogv_r80
-!===
-SUBROUTINE fliogv_r81 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_81=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r81
-!===
-SUBROUTINE fliogv_r82 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_82=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r82
-!===
-SUBROUTINE fliogv_r83 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_83=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r83
-!===
-SUBROUTINE fliogv_r84 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_84=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r84
-!===
-SUBROUTINE fliogv_r85 (f_i,v_n,v_v,start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),INTENT(OUT) :: v_v
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(IN) :: start,count
-!---------------------------------------------------------------------
-  CALL flio_ugv (f_i,v_n,r_85=v_v,start=start,count=count)
-!------------------------
-END SUBROUTINE fliogv_r85
-!===
-SUBROUTINE flio_ugv &
- & (f_i,v_n, &
- &  i_40,i_41,i_42,i_43,i_44,i_45, &
- &  i_20,i_21,i_22,i_23,i_24,i_25, &
-!? &  i_10,i_11,i_12,i_13,i_14,i_15, &
- &  r_40,r_41,r_42,r_43,r_44,r_45, &
- &  r_80,r_81,r_82,r_83,r_84,r_85, &
- &  start,count)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n
-  INTEGER(KIND=i_4),INTENT(OUT),OPTIONAL :: i_40
-  INTEGER(KIND=i_4),DIMENSION(:),INTENT(OUT),OPTIONAL :: i_41
-  INTEGER(KIND=i_4),DIMENSION(:,:),INTENT(OUT),OPTIONAL :: i_42
-  INTEGER(KIND=i_4),DIMENSION(:,:,:),INTENT(OUT),OPTIONAL :: i_43
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:),INTENT(OUT),OPTIONAL :: i_44
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),INTENT(OUT),OPTIONAL :: i_45
-  INTEGER(KIND=i_2),INTENT(OUT),OPTIONAL :: i_20
-  INTEGER(KIND=i_2),DIMENSION(:),INTENT(OUT),OPTIONAL :: i_21
-  INTEGER(KIND=i_2),DIMENSION(:,:),INTENT(OUT),OPTIONAL :: i_22
-  INTEGER(KIND=i_2),DIMENSION(:,:,:),INTENT(OUT),OPTIONAL :: i_23
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:),INTENT(OUT),OPTIONAL :: i_24
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),INTENT(OUT),OPTIONAL :: i_25
-!?INTEGERS of KIND 1 are not supported on all computers
-!?INTEGER(KIND=i_1),INTENT(OUT),OPTIONAL :: i_10
-!?INTEGER(KIND=i_1),DIMENSION(:),INTENT(OUT),OPTIONAL :: i_11
-!?INTEGER(KIND=i_1),DIMENSION(:,:),INTENT(OUT),OPTIONAL :: i_12
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:),INTENT(OUT),OPTIONAL :: i_13
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:),INTENT(OUT),OPTIONAL :: i_14
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),INTENT(OUT),OPTIONAL :: i_15
-  REAL(KIND=r_4),INTENT(OUT),OPTIONAL :: r_40
-  REAL(KIND=r_4),DIMENSION(:),INTENT(OUT),OPTIONAL :: r_41
-  REAL(KIND=r_4),DIMENSION(:,:),INTENT(OUT),OPTIONAL :: r_42
-  REAL(KIND=r_4),DIMENSION(:,:,:),INTENT(OUT),OPTIONAL :: r_43
-  REAL(KIND=r_4),DIMENSION(:,:,:,:),INTENT(OUT),OPTIONAL :: r_44
-  REAL(KIND=r_4),DIMENSION(:,:,:,:,:),INTENT(OUT),OPTIONAL :: r_45
-  REAL(KIND=r_8),INTENT(OUT),OPTIONAL :: r_80
-  REAL(KIND=r_8),DIMENSION(:),INTENT(OUT),OPTIONAL :: r_81
-  REAL(KIND=r_8),DIMENSION(:,:),INTENT(OUT),OPTIONAL :: r_82
-  REAL(KIND=r_8),DIMENSION(:,:,:),INTENT(OUT),OPTIONAL :: r_83
-  REAL(KIND=r_8),DIMENSION(:,:,:,:),INTENT(OUT),OPTIONAL :: r_84
-  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),INTENT(OUT),OPTIONAL :: r_85
-  INTEGER,DIMENSION(:),INTENT(IN),OPTIONAL :: start,count
-!-
-  INTEGER :: f_e,i_v,i_rc
-  CHARACTER(LEN=5) :: cvr_d
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    IF      (PRESENT(i_40)) THEN; cvr_d = "I1 0D";
-    ELSE IF (PRESENT(i_41)) THEN; cvr_d = "I1 1D";
-    ELSE IF (PRESENT(i_42)) THEN; cvr_d = "I1 2D";
-    ELSE IF (PRESENT(i_43)) THEN; cvr_d = "I1 3D";
-    ELSE IF (PRESENT(i_44)) THEN; cvr_d = "I1 4D";
-    ELSE IF (PRESENT(i_45)) THEN; cvr_d = "I1 5D";
-    ELSE IF (PRESENT(i_20)) THEN; cvr_d = "I2 0D";
-    ELSE IF (PRESENT(i_21)) THEN; cvr_d = "I2 1D";
-    ELSE IF (PRESENT(i_22)) THEN; cvr_d = "I2 2D";
-    ELSE IF (PRESENT(i_23)) THEN; cvr_d = "I2 3D";
-    ELSE IF (PRESENT(i_24)) THEN; cvr_d = "I2 4D";
-    ELSE IF (PRESENT(i_25)) THEN; cvr_d = "I2 5D";
-!?  ELSE IF (PRESENT(i_10)) THEN; cvr_d = "I4 0D";
-!?  ELSE IF (PRESENT(i_11)) THEN; cvr_d = "I4 1D";
-!?  ELSE IF (PRESENT(i_12)) THEN; cvr_d = "I4 2D";
-!?  ELSE IF (PRESENT(i_13)) THEN; cvr_d = "I4 3D";
-!?  ELSE IF (PRESENT(i_14)) THEN; cvr_d = "I4 4D";
-!?  ELSE IF (PRESENT(i_15)) THEN; cvr_d = "I4 5D";
-    ELSE IF (PRESENT(r_40)) THEN; cvr_d = "R4 0D";
-    ELSE IF (PRESENT(r_41)) THEN; cvr_d = "R4 1D";
-    ELSE IF (PRESENT(r_42)) THEN; cvr_d = "R4 2D";
-    ELSE IF (PRESENT(r_43)) THEN; cvr_d = "R4 3D";
-    ELSE IF (PRESENT(r_44)) THEN; cvr_d = "R4 4D";
-    ELSE IF (PRESENT(r_45)) THEN; cvr_d = "R4 5D";
-    ELSE IF (PRESENT(r_80)) THEN; cvr_d = "R8 0D";
-    ELSE IF (PRESENT(r_81)) THEN; cvr_d = "R8 1D";
-    ELSE IF (PRESENT(r_82)) THEN; cvr_d = "R8 2D";
-    ELSE IF (PRESENT(r_83)) THEN; cvr_d = "R8 3D";
-    ELSE IF (PRESENT(r_84)) THEN; cvr_d = "R8 4D";
-    ELSE IF (PRESENT(r_85)) THEN; cvr_d = "R8 5D";
-    ENDIF
-    WRITE(*,*) "->fliogetv ",TRIM(v_n)," ",TRIM(cvr_d)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliogetv',f_i,f_e)
-!-
-! Ensuring data mode
-!-
-  CALL flio_hdm (f_i,f_e,.FALSE.)
-!-
-  i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-  IF (i_rc == NF90_NOERR) THEN
-    IF      (PRESENT(i_40)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_40,start=start)
-    ELSE IF (PRESENT(i_41)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_41,start=start,count=count)
-    ELSE IF (PRESENT(i_42)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_42,start=start,count=count)
-    ELSE IF (PRESENT(i_43)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_43,start=start,count=count)
-    ELSE IF (PRESENT(i_44)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_44,start=start,count=count)
-    ELSE IF (PRESENT(i_45)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_45,start=start,count=count)
-    ELSE IF (PRESENT(i_20)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_20,start=start)
-    ELSE IF (PRESENT(i_21)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_21,start=start,count=count)
-    ELSE IF (PRESENT(i_22)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_22,start=start,count=count)
-    ELSE IF (PRESENT(i_23)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_23,start=start,count=count)
-    ELSE IF (PRESENT(i_24)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_24,start=start,count=count)
-    ELSE IF (PRESENT(i_25)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,i_25,start=start,count=count)
-!?  ELSE IF (PRESENT(i_10)) THEN
-!?    i_rc = NF90_GET_VAR(f_e,i_v,i_10,start=start)
-!?  ELSE IF (PRESENT(i_11)) THEN
-!?    i_rc = NF90_GET_VAR(f_e,i_v,i_11,start=start,count=count)
-!?  ELSE IF (PRESENT(i_12)) THEN
-!?    i_rc = NF90_GET_VAR(f_e,i_v,i_12,start=start,count=count)
-!?  ELSE IF (PRESENT(i_13)) THEN
-!?    i_rc = NF90_GET_VAR(f_e,i_v,i_13,start=start,count=count)
-!?  ELSE IF (PRESENT(i_14)) THEN
-!?    i_rc = NF90_GET_VAR(f_e,i_v,i_14,start=start,count=count)
-!?  ELSE IF (PRESENT(i_15)) THEN
-!?    i_rc = NF90_GET_VAR(f_e,i_v,i_15,start=start,count=count)
-    ELSE IF (PRESENT(r_40)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_40,start=start)
-    ELSE IF (PRESENT(r_41)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_41,start=start,count=count)
-    ELSE IF (PRESENT(r_42)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_42,start=start,count=count)
-    ELSE IF (PRESENT(r_43)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_43,start=start,count=count)
-    ELSE IF (PRESENT(r_44)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_44,start=start,count=count)
-    ELSE IF (PRESENT(r_45)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_45,start=start,count=count)
-    ELSE IF (PRESENT(r_80)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_80,start=start)
-    ELSE IF (PRESENT(r_81)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_81,start=start,count=count)
-    ELSE IF (PRESENT(r_82)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_82,start=start,count=count)
-    ELSE IF (PRESENT(r_83)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_83,start=start,count=count)
-    ELSE IF (PRESENT(r_84)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_84,start=start,count=count)
-    ELSE IF (PRESENT(r_85)) THEN
-      i_rc = NF90_GET_VAR(f_e,i_v,r_85,start=start,count=count)
-    ENDIF
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliogetv', &
- &      'Variable '//TRIM(v_n)//' not get','Error :', &
- &      TRIM(NF90_STRERROR(i_rc)))
-    ENDIF
-  ELSE
-    CALL ipslerr (3,'fliogetv','Variable',TRIM(v_n),'not found')
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliogetv"
-  ENDIF
-!----------------------
-END SUBROUTINE flio_ugv
-!===
-SUBROUTINE flioinqa (f_i,v_n,a_n,l_ex,a_t,a_l)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  LOGICAL,INTENT(OUT) :: l_ex
-  INTEGER,OPTIONAL,INTENT(OUT) :: a_t,a_l
-!-
-  INTEGER :: i_rc,f_e,i_v,t_ea,l_ea
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioinqa ",TRIM(v_n),"-",TRIM(a_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('flioinqa',f_i,f_e)
-!-
-  IF (TRIM(v_n) == '?') THEN
-    i_v = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'flioinqa', &
-       'Variable :',TRIM(v_n),'not found')
-    ENDIF
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,i_v,a_n,xtype=t_ea,len=l_ea)
-!-
-  l_ex = (i_rc == NF90_NOERR)
-!-
-  IF (l_ex) THEN
-    IF (PRESENT(a_t)) THEN
-      a_t = t_ea
-    ENDIF
-    IF (PRESENT(a_l)) THEN
-      a_l = l_ea
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioinqa"
-  ENDIF
-!----------------------
-END SUBROUTINE flioinqa
-!===
-SUBROUTINE flioga_r4_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=4),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avr_4_0=a_v)
-!---------------------------
-END SUBROUTINE flioga_r4_0d
-!===
-SUBROUTINE flioga_r4_1d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=4),DIMENSION(:),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avr_4_1=a_v)
-!--------------------------
-END SUBROUTINE flioga_r4_1d
-!===
-SUBROUTINE flioga_r8_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=8),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avr_8_0=a_v)
-!---------------------------
-END SUBROUTINE flioga_r8_0d
-!===
-SUBROUTINE flioga_r8_1d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=8),DIMENSION(:),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avr_8_1=a_v)
-!--------------------------
-END SUBROUTINE flioga_r8_1d
-!===
-SUBROUTINE flioga_i4_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  INTEGER(KIND=4),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avi_4_0=a_v)
-!---------------------------
-END SUBROUTINE flioga_i4_0d
-!===
-SUBROUTINE flioga_i4_1d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  INTEGER(KIND=4),DIMENSION(:),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avi_4_1=a_v)
-!--------------------------
-END SUBROUTINE flioga_i4_1d
-!===
-SUBROUTINE flioga_tx_0d (f_i,v_n,a_n,a_v)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  CHARACTER(LEN=*),INTENT(OUT) :: a_v
-!---------------------------------------------------------------------
-  CALL flio_uga (f_i,v_n,a_n,avtx=a_v)
-!---------------------------
-END SUBROUTINE flioga_tx_0d
-!===
-SUBROUTINE flio_uga &
- & (f_i,v_n,a_n, &
- &  avr_4_0,avr_4_1,avr_8_0,avr_8_1,avi_4_0,avi_4_1,avtx)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-  REAL(KIND=4),OPTIONAL,INTENT(OUT) :: avr_4_0
-  REAL(KIND=4),DIMENSION(:),OPTIONAL,INTENT(OUT) :: avr_4_1
-  REAL(KIND=8),OPTIONAL,INTENT(OUT) :: avr_8_0
-  REAL(KIND=8),DIMENSION(:),OPTIONAL,INTENT(OUT) :: avr_8_1
-  INTEGER(KIND=4),OPTIONAL,INTENT(OUT) :: avi_4_0
-  INTEGER(KIND=4),DIMENSION(:),OPTIONAL,INTENT(OUT) :: avi_4_1
-  CHARACTER(LEN=*),OPTIONAL,INTENT(OUT) :: avtx
-!-
-  INTEGER :: f_e,l_ua,i_v,t_ea,l_ea,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliogeta ",TRIM(v_n)," ",TRIM(a_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliogeta',f_i,f_e)
-!-
-  IF (TRIM(v_n) == '?') THEN
-    i_v = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliogeta', &
-       'Variable :',TRIM(v_n),'not found')
-    ENDIF
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,i_v,a_n,xtype=t_ea,len=l_ea)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (3,'fliogeta', &
- &   'Attribute :',TRIM(a_n),'not found')
-  ENDIF
-!-
-  IF ( (.NOT.PRESENT(avtx).AND.(t_ea == NF90_CHAR)) &
- &      .OR.(PRESENT(avtx).AND.(t_ea /= NF90_CHAR)) ) THEN
-    CALL ipslerr (3,'fliogeta', &
- &   'The external type of the attribute :',TRIM(a_n), &
- &   'is not compatible with the type of the argument')
-  ENDIF
-!-
-  IF      (PRESENT(avr_4_1)) THEN
-    l_ua = SIZE(avr_4_1)
-  ELSE IF (PRESENT(avr_8_1)) THEN
-    l_ua = SIZE(avr_8_1)
-  ELSE IF (PRESENT(avi_4_1)) THEN
-    l_ua = SIZE(avi_4_1)
-  ELSE IF (PRESENT(avtx)) THEN
-    l_ua = LEN(avtx)
-  ELSE
-    l_ua = 1
-  ENDIF
-!-
-  IF (l_ua < l_ea) THEN
-    CALL ipslerr (3,'fliogeta', &
-     'Insufficient size of the argument', &
- &   'to receive the values of the attribute :',TRIM(a_n))
-  ENDIF
-!-
-  IF      (PRESENT(avr_4_0)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avr_4_0)
-  ELSE IF (PRESENT(avr_4_1)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avr_4_1(1:l_ea))
-  ELSE IF (PRESENT(avr_8_0)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avr_8_0)
-  ELSE IF (PRESENT(avr_8_1)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avr_8_1(1:l_ea))
-  ELSE IF (PRESENT(avi_4_0)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avi_4_0)
-  ELSE IF (PRESENT(avi_4_1)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avi_4_1(1:l_ea))
-  ELSE IF (PRESENT(avtx)) THEN
-    i_rc = NF90_GET_ATT(f_e,i_v,a_n,avtx)
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliogeta"
-  ENDIF
-!----------------------
-END SUBROUTINE flio_uga
-!===
-SUBROUTINE fliorenv (f_i,v_o_n,v_n_n)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_o_n,v_n_n
-!-
-  INTEGER :: f_e,i_v,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) &
- &    "->fliorenv ",TRIM(v_o_n),"->",TRIM(v_n_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliorenv',f_i,f_e)
-!-
-  i_rc = NF90_INQ_VARID(f_e,v_o_n,i_v)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (2,'fliorenv', &
-     'Variable :',TRIM(v_o_n),'not found')
-  ELSE
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    i_rc = NF90_RENAME_VAR(f_e,i_v,v_n_n)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (2,'fliorenv', &
-       'Variable :',TRIM(v_o_n),'can not be renamed')
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliorenv"
-  ENDIF
-!----------------------
-END SUBROUTINE fliorenv
-!===
-SUBROUTINE fliorena (f_i,v_n,a_o_n,a_n_n)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_o_n,a_n_n
-!-
-  INTEGER :: f_e,i_v,i_a,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) &
- &    "->fliorena ",TRIM(v_n),"-",TRIM(a_o_n),"->",TRIM(a_n_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliorena',f_i,f_e)
-!-
-  IF (TRIM(v_n) == '?') THEN
-    i_v = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliorena', &
-       'Variable :',TRIM(v_n),'not found')
-    ENDIF
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,i_v,a_o_n,attnum=i_a)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (2,'fliorena', &
-     'Attribute :',TRIM(a_o_n),'not found')
-  ELSE
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    i_rc = NF90_RENAME_ATT(f_e,i_v,a_o_n,a_n_n)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (2,'fliorena', &
-       'Attribute :',TRIM(a_o_n),'can not be renamed')
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliorena"
-  ENDIF
-!----------------------
-END SUBROUTINE fliorena
-!===
-SUBROUTINE fliodela (f_i,v_n,a_n)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: v_n,a_n
-!-
-  INTEGER :: f_e,i_v,i_a,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliodela ",TRIM(v_n),"-",TRIM(a_n)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliodela',f_i,f_e)
-!-
-  IF (TRIM(v_n) == '?') THEN
-    i_v = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e,v_n,i_v)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliodela', &
- &     'Variable :',TRIM(v_n),'not found')
-    ENDIF
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,i_v,a_n,attnum=i_a)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (2,'fliodela', &
- &   'Attribute :',TRIM(a_n),'not found')
-  ELSE
-    IF (i_v == NF90_GLOBAL) THEN
-      nw_na(f_i) = nw_na(f_i)-1
-    ENDIF
-    CALL flio_hdm (f_i,f_e,.TRUE.)
-    i_rc = NF90_DEL_ATT(f_e,i_v,a_n)
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliodela"
-  ENDIF
-!----------------------
-END SUBROUTINE fliodela
-!===
-SUBROUTINE fliocpya (f_i_i,v_n_i,a_n,f_i_o,v_n_o)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i_i,f_i_o
-  CHARACTER(LEN=*),INTENT(IN) :: v_n_i,a_n,v_n_o
-!-
-  INTEGER :: f_e_i,f_e_o,i_v_i,i_v_o,i_a,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliocpya - file",f_i_i,"-",TRIM(v_n_i),"-",TRIM(a_n)
-    WRITE(*,*) "  copied to file ",f_i_o,"-",TRIM(v_n_o)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('fliocpya',f_i_i,f_e_i)
-  CALL flio_qvid ('fliocpya',f_i_o,f_e_o)
-!-
-  IF (TRIM(v_n_i) == '?') THEN
-    i_v_i = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e_i,v_n_i,i_v_i)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliocpya', &
- &     'Variable :',TRIM(v_n_i),'not found')
-    ENDIF
-  ENDIF
-!-
-  IF (TRIM(v_n_o) == '?') THEN
-    i_v_o = NF90_GLOBAL
-  ELSE
-    i_rc = NF90_INQ_VARID(f_e_o,v_n_o,i_v_o)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliocpya', &
- &     'Variable :',TRIM(v_n_o),'not found')
-    ENDIF
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE_ATTRIBUTE(f_e_i,i_v_i,a_n,attnum=i_a)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (3,'fliocpya', &
-     'Attribute :',TRIM(a_n),'not found')
-  ELSE
-    i_rc = NF90_INQUIRE_ATTRIBUTE(f_e_o,i_v_o,a_n,attnum=i_a)
-    IF ( (i_v_o == NF90_GLOBAL).AND.(i_rc /= NF90_NOERR) ) THEN
-      nw_na(f_i_o) = nw_na(f_i_o)+1
-    ENDIF
-    CALL flio_hdm (f_i_o,f_e_o,.TRUE.)
-    i_rc = NF90_COPY_ATT(f_e_i,i_v_i,a_n,f_e_o,i_v_o)
-    IF (i_rc /= NF90_NOERR) THEN
-      CALL ipslerr (3,'fliocpya', &
- &      'Attribute '//TRIM(a_n)//' not copied','Error :', &
- &      TRIM(NF90_STRERROR(i_rc)))
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliocpya"
-  ENDIF
-!----------------------
-END SUBROUTINE fliocpya
-!===
-SUBROUTINE flioqstc (f_i,c_type,l_ex,c_name)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i
-  CHARACTER(LEN=*),INTENT(IN) :: c_type
-  LOGICAL,INTENT(OUT) :: l_ex
-  CHARACTER(LEN=*),INTENT(OUT) :: c_name
-!-
-  CHARACTER(LEN=1) :: c_ax
-  INTEGER :: f_e,idc,ndc,i_rc
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioqstc ",TRIM(c_type)
-  ENDIF
-!-
-! Retrieve the external file index
-  CALL flio_qvid ('flioqstc',f_i,f_e)
-!-
-  c_ax = TRIM(c_type)
-  IF (    (LEN_TRIM(c_type) == 1) &
- &    .AND.(    (c_ax == 'x').OR.(c_ax == 'y') &
- &          .OR.(c_ax == 'z').OR.(c_ax == 't')) ) THEN
-    CALL flio_qax (f_i,c_ax,idc,ndc)
-    l_ex = (idc > 0)
-    IF (l_ex) THEN
-      i_rc = NF90_INQUIRE_VARIABLE(f_e,idc,name=c_name)
-    ENDIF
-  ELSE
-    l_ex = .FALSE.
-    CALL ipslerr (2,'flioqstc', &
- &   'The name of the coordinate,',TRIM(c_type),'is not valid')
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioqstc"
-  ENDIF
-!----------------------
-END SUBROUTINE flioqstc
-!===
-SUBROUTINE fliosync (f_i)
-!---------------------------------------------------------------------
-  INTEGER,INTENT(in),OPTIONAL :: f_i
-!-
-  INTEGER :: i_f,f_e,i_rc,i_s,i_e
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->fliosync"
-  ENDIF
-!-
-  IF (PRESENT(f_i)) THEN
-    IF ( (f_i >= 1).AND.(f_i <= nb_fi_mx) ) THEN
-      i_s = f_i
-      i_e = f_i
-    ELSE
-      i_s = 1
-      i_e = 0
-      CALL ipslerr (2,'fliosync', &
- &     'Invalid file identifier',' ',' ')
-    ENDIF
-  ELSE
-    i_s = 1
-    i_e = nb_fi_mx
-  ENDIF
-!-
-! Ensuring data mode
-!-
-  CALL flio_hdm (f_i,f_e,.FALSE.)
-!-
-  DO i_f=i_s,i_e
-    f_e = nw_id(i_f)
-    IF (f_e > 0) THEN
-      IF (l_dbg) THEN
-        WRITE(*,*) '  fliosync - synchronising file number ',i_f
-      ENDIF
-      i_rc = NF90_SYNC(f_e)
-    ELSE IF (PRESENT(f_i)) THEN
-      CALL ipslerr (2,'fliosync', &
- &     'Unable to synchronise the file :','probably','not opened')
-    ENDIF
-  ENDDO
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-fliosync"
-  ENDIF
-!----------------------
-END SUBROUTINE fliosync
-!===
-SUBROUTINE flioclo (f_i)
-!---------------------------------------------------------------------
-  INTEGER,INTENT(in),OPTIONAL :: f_i
-!-
-  INTEGER :: i_f,f_e,i_rc,i_s,i_e
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flioclo"
-  ENDIF
-!-
-  IF (PRESENT(f_i)) THEN
-    IF ( (f_i >= 1).AND.(f_i <= nb_fi_mx) ) THEN
-      i_s = f_i
-      i_e = f_i
-    ELSE
-      i_s = 1
-      i_e = 0
-      CALL ipslerr (2,'flioclo', &
- &     'Invalid file identifier',' ',' ')
-    ENDIF
-  ELSE
-    i_s = 1
-    i_e = nb_fi_mx
-  ENDIF
-!-
-  DO i_f=i_s,i_e
-    f_e = nw_id(i_f)
-    IF (f_e > 0) THEN
-      IF (l_dbg) THEN
-        WRITE(*,*) '  flioclo - closing file number ',i_f
-      ENDIF
-      i_rc = NF90_CLOSE(f_e)
-      nw_id(i_f) = -1
-    ELSE IF (PRESENT(f_i)) THEN
-      CALL ipslerr (2,'flioclo', &
- &     'Unable to close the file :','probably','not opened')
-    ENDIF
-  ENDDO
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flioclo"
-  ENDIF
-!---------------------
-END SUBROUTINE flioclo
-!===
-SUBROUTINE fliodmpf (f_n)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(IN) :: f_n
-!-
-  INTEGER :: f_e,n_dims,n_vars,n_atts,i_unlm
-  INTEGER :: i_rc,i_n,k_n,t_ea,l_ea
-  INTEGER :: tmp_i
-  REAL    :: tmp_r
-  INTEGER,DIMENSION(:),ALLOCATABLE :: tma_i
-  REAL,DIMENSION(:),ALLOCATABLE    :: tma_r
-  CHARACTER(LEN=256) :: tmp_c
-  INTEGER,DIMENSION(nb_fd_mx) :: n_idim,n_ldim
-  INTEGER,DIMENSION(nb_ax_mx) :: n_ai
-  CHARACTER(LEN=NF90_MAX_NAME),DIMENSION(nb_fd_mx) :: c_ndim
-  INTEGER,DIMENSION(NF90_MAX_VAR_DIMS) :: idimid
-  CHARACTER(LEN=NF90_MAX_NAME) :: c_name
-!---------------------------------------------------------------------
-  i_rc = NF90_OPEN(TRIM(f_n),NF90_NOWRITE,f_e)
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (3,'fliodmpf', &
- &   'Could not open file :',TRIM(f_n), &
- &   TRIM(NF90_STRERROR(i_rc))//' (Netcdf)')
-  ENDIF
-!-
-  WRITE (*,*) "---"
-  WRITE (*,*) "--- File '",TRIM(f_n),"'"
-  WRITE (*,*) "---"
-!-
-  CALL flio_inf &
- &  (f_e,nb_dims=n_dims,nb_vars=n_vars, &
- &       nb_atts=n_atts,id_unlm=i_unlm, &
- &       nn_idm=n_idim,nn_ldm=n_ldim,cc_ndm=c_ndim,nn_aid=n_ai)
-!-
-  WRITE (*,*) 'External model identifier   : ',f_e
-  WRITE (*,*) 'Number of dimensions        : ',n_dims
-  WRITE (*,*) 'Number of variables         : ',n_vars
-  WRITE (*,*) 'ID unlimited                : ',i_unlm
-!-
-  WRITE (*,*) "---"
-  WRITE (*,*) 'Presumed axis dimensions identifiers :'
-  IF (n_ai(k_lon) > 0) THEN
-    WRITE (*,*) 'x axis : ',n_ai(k_lon)
-  ELSE
-    WRITE (*,*) 'x axis : NONE'
-  ENDIF
-  IF (n_ai(k_lat) > 0) THEN
-    WRITE (*,*) 'y axis : ',n_ai(k_lat)
-  ELSE
-    WRITE (*,*) 'y axis : NONE'
-  ENDIF
-  IF (n_ai(k_lev) > 0) THEN
-    WRITE (*,*) 'z axis : ',n_ai(k_lev)
-  ELSE
-    WRITE (*,*) 'z axis : NONE'
-  ENDIF
-  IF (n_ai(k_tim) > 0) THEN
-    WRITE (*,*) 't axis : ',n_ai(k_tim)
-  ELSE
-    WRITE (*,*) 't axis : NONE'
-  ENDIF
-!-
-  WRITE (*,*) "---"
-  WRITE (*,*) 'Number of global attributes : ',n_atts
-  DO k_n=1,n_atts
-    i_rc = NF90_INQ_ATTNAME(f_e,NF90_GLOBAL,k_n,c_name)
-    i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,NF90_GLOBAL,c_name, &
- &                                xtype=t_ea,len=l_ea)
-    IF      (    (t_ea == NF90_INT4).OR.(t_ea == NF90_INT2) &
-             .OR.(t_ea == NF90_INT1) ) THEN
-      IF (l_ea > 1) THEN
-        ALLOCATE(tma_i(l_ea))
-        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tma_i)
-        WRITE (*,'("    ",A," :",/,(5(1X,I10),:))') &
- &        TRIM(c_name),tma_i(1:l_ea)
-        DEALLOCATE(tma_i)
-      ELSE
-        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tmp_i)
-        WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_i
-      ENDIF
-    ELSE IF ( (t_ea == NF90_REAL4).OR.(t_ea == NF90_REAL8) ) THEN
-      IF (l_ea > 1) THEN
-        ALLOCATE(tma_r(l_ea))
-        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tma_r)
-        WRITE (*,'("    ",A," :",/,(5(1X,1PE11.3),:))') &
- &        TRIM(c_name),tma_r(1:l_ea)
-        DEALLOCATE(tma_r)
-      ELSE
-        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tmp_r)
-        WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_r
-      ENDIF
-    ELSE
-      tmp_c = ''
-      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tmp_c)
-      WRITE(*,*) '   ',TRIM(c_name),' : "',TRIM(tmp_c),'"'
-    ENDIF
-  ENDDO
-!-
-  DO i_n=1,nb_fd_mx
-    IF (n_idim(i_n) > 0) THEN
-      WRITE (*,*) "---"
-      WRITE (*,*) 'Dimension id   : ',n_idim(i_n)
-      WRITE (*,*) 'Dimension name : ',TRIM(c_ndim(i_n))
-      WRITE (*,*) 'Dimension size : ',n_ldim(i_n)
-    ENDIF
-  ENDDO
-!-
-  DO i_n=1,n_vars
-    i_rc = NF90_INQUIRE_VARIABLE(f_e,i_n, &
- &           name=c_name,ndims=n_dims,dimids=idimid,nAtts=n_atts)
-    WRITE (*,*) "---"
-    WRITE (*,*) "Variable name        : ",TRIM(c_name)
-    WRITE (*,*) "Variable identifier  : ",i_n
-    WRITE (*,*) "Number of dimensions : ",n_dims
-    IF (n_dims > 0) THEN
-      WRITE (*,*) "Dimensions ID's      : ",idimid(1:n_dims)
-    ENDIF
-    WRITE (*,*) "Number of attributes : ",n_atts
-    DO k_n=1,n_atts
-      i_rc = NF90_INQ_ATTNAME(f_e,i_n,k_n,c_name)
-      i_rc = NF90_INQUIRE_ATTRIBUTE(f_e,i_n,c_name, &
- &                                  xtype=t_ea,len=l_ea)
-      IF      (    (t_ea == NF90_INT4).OR.(t_ea == NF90_INT2) &
- &             .OR.(t_ea == NF90_INT1) ) THEN
-        IF (l_ea > 1) THEN
-          ALLOCATE(tma_i(l_ea))
-          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tma_i)
-          WRITE (*,'("    ",A," :",/,(5(1X,I10),:))') &
- &              TRIM(c_name),tma_i(1:l_ea)
-          DEALLOCATE(tma_i)
-        ELSE
-          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tmp_i)
-          WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_i
-        ENDIF
-      ELSE IF ( (t_ea == NF90_REAL4).OR.(t_ea == NF90_REAL8) ) THEN
-        IF (l_ea > 1) THEN
-          ALLOCATE(tma_r(l_ea))
-          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tma_r)
-          WRITE (*,'("    ",A," :",/,(5(1X,1PE11.3),:))') &
- &          TRIM(c_name),tma_r(1:l_ea)
-          DEALLOCATE(tma_r)
-        ELSE
-          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tmp_r)
-          WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_r
-        ENDIF
-      ELSE
-        tmp_c = ''
-        i_rc = NF90_GET_ATT(f_e,i_n,c_name,tmp_c)
-        WRITE(*,*) '   ',TRIM(c_name),' : "',TRIM(tmp_c),'"'
-      ENDIF
-    ENDDO
-  ENDDO
-  WRITE (*,*) "---"
-!-
-  i_rc = NF90_CLOSE(f_e)
-!----------------------
-END SUBROUTINE fliodmpf
-!===
-SUBROUTINE flio_dom_set &
- & (dtnb,dnb,did,dsg,dsl,dpf,dpl,dhs,dhe,cdnm,id_dom)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: dtnb,dnb
-  INTEGER,DIMENSION(:),INTENT(IN) :: did,dsg,dsl,dpf,dpl,dhs,dhe
-  CHARACTER(LEN=*),INTENT(IN) :: cdnm
-  INTEGER,INTENT(OUT) :: id_dom
-!-
-  INTEGER :: k_w,i_w,i_s
-  CHARACTER(LEN=l_dns) :: cd_p,cd_w
-!---------------------------------------------------------------------
-  k_w = flio_dom_rid()
-  IF (k_w < 0) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'too many domains simultaneously defined', &
- &   'please unset useless domains', &
- &   'by calling flio_dom_unset')
-  ENDIF
-  id_dom = k_w
-!-
-  d_n_t(k_w) = dtnb
-  d_n_c(k_w) = dnb
-!-
-  i_s = SIZE(did)
-  IF (i_s > dom_max_dims) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'too many distributed dimensions', &
- &   'simultaneously defined',' ')
-  ENDIF
-  d_d_n(k_w) = i_s
-  d_d_i(1:i_s,k_w) = did(1:i_s)
-!-
-  i_w = SIZE(dsg)
-  IF (i_w /= i_s) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'the size of the DOMAIN_size_global array', &
- &   'is not equal to the size', &
- &   'of the distributed dimensions array')
-  ENDIF
-  d_s_g(1:i_w,k_w) = dsg(1:i_w)
-!-
-  i_w = SIZE(dsl)
-  IF (i_w /= i_s) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'the size of the DOMAIN_size_local array', &
- &   'is not equal to the size', &
- &   'of the distributed dimensions array')
-  ENDIF
-  d_s_l(1:i_w,k_w) = dsl(1:i_w)
-!-
-  i_w = SIZE(dpf)
-  IF (i_w /= i_s) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'the size of the DOMAIN_position_first array', &
- &   'is not equal to the size', &
- &   'of the distributed dimensions array')
-  ENDIF
-  d_p_f(1:i_w,k_w) = dpf(1:i_w)
-!-
-  i_w = SIZE(dpl)
-  IF (i_w /= i_s) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'the size of the DOMAIN_position_last array', &
- &   'is not equal to the size', &
- &   'of the distributed dimensions array')
-  ENDIF
-  d_p_l(1:i_w,k_w) = dpl(1:i_w)
-!-
-  i_w = SIZE(dhs)
-  IF (i_w /= i_s) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'the size of the DOMAIN_halo_size_start array', &
- &   'is not equal to the size', &
- &   'of the distributed dimensions array')
-  ENDIF
-  d_h_s(1:i_w,k_w) = dhs(1:i_w)
-!-
-  i_w = SIZE(dhe)
-  IF (i_w /= i_s) THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'the size of the DOMAIN_halo_size_end array', &
- &   'is not equal to the size', &
- &   'of the distributed dimensions array')
-  ENDIF
-  d_h_e(1:i_w,k_w) = dhe(1:i_w)
-!-
-  cd_p = "unknown"
-  cd_w = cdnm; CALL strlowercase (cd_w)
-  DO i_w=1,n_dns
-    IF (TRIM(cd_w) == TRIM(c_dns(i_w))) THEN
-      cd_p = cd_w; EXIT;
-    ENDIF
-  ENDDO
-  IF (TRIM(cd_p) == "unknown") THEN
-    CALL ipslerr (3,'flio_dom_set', &
- &   'DOMAIN_type "'//TRIM(cdnm)//'"', &
- &   'is actually not supported', &
- &   'please use one of the supported names')
-  ENDIF
-  c_d_t(k_w) = cd_p
-!--------------------------
-END SUBROUTINE flio_dom_set
-!===
-SUBROUTINE flio_dom_unset (id_dom)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN),OPTIONAL :: id_dom
-!-
-  INTEGER :: i_w
-!---------------------------------------------------------------------
-  IF (PRESENT(id_dom)) THEN
-    IF ( (id_dom >= 1).AND.(id_dom <= dom_max_nb) ) THEN
-      IF (d_d_n(id_dom) > 0) THEN
-        d_d_n(id_dom) = -1
-      ELSE
-        CALL ipslerr (2,'flio_dom_unset', &
- &       'The domain is not set',' ',' ')
-      ENDIF
-    ELSE
-      CALL ipslerr (2,'flio_dom_unset', &
- &     'Invalid file identifier',' ',' ')
-    ENDIF
-  ELSE
-    DO i_w=1,dom_max_nb
-      d_d_n(id_dom) = -1
-    ENDDO
-  ENDIF
-!----------------------------
-END SUBROUTINE flio_dom_unset
-!===
-SUBROUTINE flio_dom_defset (id_dom)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: id_dom
-!---------------------------------------------------------------------
-  IF ( (id_dom >= 1).AND.(id_dom <= dom_max_nb) ) THEN
-    id_def_dom = id_dom
-  ELSE
-    CALL ipslerr (3,'flio_dom_defset', &
- &   'Invalid domain identifier',' ',' ')
-  ENDIF
-!-----------------------------
-END SUBROUTINE flio_dom_defset
-!===
-SUBROUTINE flio_dom_defunset ()
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!---------------------------------------------------------------------
-  id_def_dom = FLIO_DOM_NONE
-!-------------------------------
-END SUBROUTINE flio_dom_defunset
-!===
-SUBROUTINE flio_dom_definq (id_dom)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(OUT) :: id_dom
-!---------------------------------------------------------------------
-  id_dom = id_def_dom
-!-----------------------------
-END SUBROUTINE flio_dom_definq
-!===
-!-
-!---------------------------------------------------------------------
-!- Semi-public procedures
-!---------------------------------------------------------------------
-!-
-!===
-SUBROUTINE flio_dom_file (f_n,id_dom)
-!---------------------------------------------------------------------
-!- Update the model file name to include the ".nc" suffix and
-!- the DOMAIN number on which this copy of IOIPSL runs, if needed.
-!- This routine is called by IOIPSL and not by user anyway.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(INOUT) :: f_n
-  INTEGER,OPTIONAL,INTENT(IN) :: id_dom
-!-
-  INTEGER :: il,iw
-  CHARACTER(LEN=4) :: str
-!---------------------------------------------------------------------
-!-
-! Add the ".nc" suffix if needed
-  il = LEN_TRIM(f_n)
-  IF (f_n(il-2:il) /= '.nc') THEN
-    f_n = f_n(1:il)//'.nc'
-  ENDIF
-!-
-! Add the DOMAIN identifier if needed
-  IF (PRESENT(id_dom)) THEN
-    IF (id_dom == FLIO_DOM_DEFAULT) THEN
-      CALL flio_dom_definq (iw)
-    ELSE
-      iw = id_dom
-    ENDIF
-    IF (iw /= FLIO_DOM_NONE) THEN
-      IF ( (id_dom >= 1).AND.(id_dom <= dom_max_nb) ) THEN
-        IF (d_d_n(iw) > 0) THEN
-          WRITE(str,'(I4.4)') d_n_c(iw)
-          il = INDEX(f_n,'.nc')
-          f_n = f_n(1:il-1)//'_'//str//'.nc'
-        ELSE
-          CALL ipslerr (3,'flio_dom_file', &
- &         'The domain has not been defined', &
- &         'please call flio_dom_set', &
- &         'before calling flio_dom_file')
-        ENDIF
-      ELSE
-        CALL ipslerr (3,'flio_dom_file', &
- &       'Invalid domain identifier',' ',' ')
-      ENDIF
-    ENDIF
-  ENDIF
-!---------------------------
-END SUBROUTINE flio_dom_file
-!===
-SUBROUTINE flio_dom_att (f_e,id_dom)
-!---------------------------------------------------------------------
-!- Add the DOMAIN attributes to the NETCDF file.
-!- This routine is called by IOIPSL and not by user anyway.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(in) :: f_e
-  INTEGER,OPTIONAL,INTENT(IN) :: id_dom
-!-
-  INTEGER :: iw,i_rc,i_n
-  CHARACTER(LEN=15) :: c_ddim
-  INTEGER :: n_idim
-  CHARACTER(LEN=NF90_MAX_NAME) :: c_ndim
-!---------------------------------------------------------------------
-  IF (PRESENT(id_dom)) THEN
-    IF (id_dom == FLIO_DOM_DEFAULT) THEN
-      CALL flio_dom_definq (iw)
-    ELSE
-      iw = id_dom
-    ENDIF
-    IF (iw /= FLIO_DOM_NONE) THEN
-      IF ( (id_dom >= 1).AND.(id_dom <= dom_max_nb) ) THEN
-        IF (d_d_n(iw) > 0) THEN
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_number_total',d_n_t(iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_number',d_n_c(iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_dimensions_ids',d_d_i(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_size_global',d_s_g(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_size_local',d_s_l(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_position_first',d_p_f(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_position_last',d_p_l(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_halo_size_start',d_h_s(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_halo_size_end',d_h_e(1:d_d_n(iw),iw))
-          i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL, &
- &          'DOMAIN_type',TRIM(c_d_t(iw)))
-          i_rc = NF90_INQUIRE (f_e,nDimensions=n_idim)
-          DO i_n=1,n_idim
-            i_rc = NF90_INQUIRE_DIMENSION (f_e,i_n,name=c_ndim)
-            WRITE (UNIT=c_ddim,FMT='("DOMAIN_DIM_N",I3.3)') i_n
-            i_rc = NF90_PUT_ATT (f_e,NF90_GLOBAL,c_ddim,TRIM(c_ndim))
-          ENDDO
-        ELSE
-          CALL ipslerr (3,'flio_dom_att', &
- &         'The domain has not been defined', &
- &         'please call flio_dom_set', &
- &         'before calling flio_dom_att')
-        ENDIF
-      ELSE
-        CALL ipslerr (3,'flio_dom_att', &
- &       'Invalid domain identifier',' ',' ')
-      ENDIF
-    ENDIF
-  ENDIF
-!--------------------------
-END SUBROUTINE flio_dom_att
-!===
-!-
-!---------------------------------------------------------------------
-!- Local procedures
-!---------------------------------------------------------------------
-!-
-!===
-INTEGER FUNCTION flio_rid()
-!---------------------------------------------------------------------
-!- returns a free index in nw_id(:)
-!---------------------------------------------------------------------
-  INTEGER,DIMENSION(1:1) :: nfi
-!-
-  IF (ANY(nw_id < 0)) THEN
-    nfi = MINLOC(nw_id,MASK=nw_id < 0)
-    flio_rid = nfi(1)
-  ELSE
-    flio_rid = -1
-  ENDIF
-!--------------------
-END FUNCTION flio_rid
-!===
-INTEGER FUNCTION flio_dom_rid()
-!---------------------------------------------------------------------
-!- returns a free index in d_d_n(:)
-!---------------------------------------------------------------------
-  INTEGER,DIMENSION(1:1) :: nd
-!---------------------------------------------------------------------
-  IF (ANY(d_d_n < 0)) THEN
-    nd = MINLOC(d_d_n,MASK=d_d_n < 0)
-    flio_dom_rid = nd(1)
-  ELSE
-    flio_dom_rid = -1
-  ENDIF
-!------------------------
-END FUNCTION flio_dom_rid
-!===
-INTEGER FUNCTION flio_qid(iid)
-!---------------------------------------------------------------------
-!- returns the external index associated with the internal index "iid"
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: iid
-!---------------------------------------------------------------------
-  IF ( (iid >= 1).AND.(iid <= nb_fi_mx) ) THEN
-    flio_qid = nw_id(iid)
-  ELSE
-    flio_qid = -1
-  ENDIF
-!--------------------
-END FUNCTION flio_qid
-!===
-SUBROUTINE flio_qvid (cpg,iid,ixd)
-!---------------------------------------------------------------------
-!- This subroutine, called by the procedure "cpg",
-!- validates and returns the external file index "ixd"
-!- associated with the internal file index "iid"
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(IN) :: cpg
-  INTEGER,INTENT(IN)  :: iid
-  INTEGER,INTENT(OUT) :: ixd
-!-
-  CHARACTER(LEN=20) :: c_t
-!---------------------------------------------------------------------
-  ixd = flio_qid(iid)
-  IF (ixd < 0) THEN
-    WRITE (UNIT=c_t,FMT='(I15)') iid
-    CALL ipslerr (3,TRIM(cpg), &
- &    'Invalid internal file index :',TRIM(ADJUSTL(c_t)),' ')
-  ENDIF
-!-----------------------
-END SUBROUTINE flio_qvid
-!===
-SUBROUTINE flio_hdm (f_i,f_e,lk_hm)
-!---------------------------------------------------------------------
-!- This subroutine handles the "define/data mode" of NETCDF.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_i,f_e
-  LOGICAL,INTENT(IN) :: lk_hm
-!-
-  INTEGER :: i_rc
-!---------------------------------------------------------------------
-  i_rc = NF90_NOERR
-!-
-  IF      ( (.NOT.lw_hm(f_i)).AND.(lk_hm) ) THEN
-    i_rc = NF90_REDEF(f_e)
-    lw_hm(f_i) = .TRUE.
-  ELSE IF ( (lw_hm(f_i)).AND.(.NOT.lk_hm) ) THEN
-    i_rc = NF90_ENDDEF(f_e)
-    lw_hm(f_i) = .FALSE.
-  ENDIF
-!-
-  IF (i_rc /= NF90_NOERR) THEN
-    CALL ipslerr (3,'flio_hdm', &
- &    'Internal error ','in define/data mode :', &
- &    TRIM(NF90_STRERROR(i_rc)))
-  ENDIF
-!----------------------
-END SUBROUTINE flio_hdm
-!===
-SUBROUTINE flio_inf (f_e, &
- & nb_dims,nb_vars,nb_atts,id_unlm,nn_idm,nn_ldm,nn_aid,cc_ndm)
-!---------------------------------------------------------------------
-!- This subroutine allows to get some information concerning
-!- the model file whose the external identifier is "f_e".
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: f_e
-  INTEGER,OPTIONAL,INTENT(OUT) :: nb_dims,nb_vars,nb_atts,id_unlm
-  INTEGER,DIMENSION(:),OPTIONAL,INTENT(OUT) :: nn_idm,nn_ldm,nn_aid
-  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL,INTENT(OUT) :: cc_ndm
-!-
-  INTEGER :: nm_dims,nm_vars,nm_atts,nm_unlm,ml
-  INTEGER :: i_rc,kv
-  CHARACTER(LEN=NF90_MAX_NAME) :: f_d_n
-!-
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "->flio_inf"
-  ENDIF
-!-
-  i_rc = NF90_INQUIRE(f_e,nDimensions=nm_dims,nVariables=nm_vars, &
- &                    nAttributes=nm_atts,unlimitedDimId=nm_unlm)
-!-
-  IF (PRESENT(nb_dims))  nb_dims = nm_dims;
-  IF (PRESENT(nb_vars))  nb_vars = nm_vars;
-  IF (PRESENT(nb_atts))  nb_atts = nm_atts;
-  IF (PRESENT(id_unlm))  id_unlm = nm_unlm;
-!-
-  IF (PRESENT(nn_idm))  nn_idm(:) =  -1;
-  IF (PRESENT(nn_ldm))  nn_ldm(:) =   0;
-  IF (PRESENT(cc_ndm))  cc_ndm(:) = ' ';
-  IF (PRESENT(nn_aid))  nn_aid(:) =  -1;
-!-
-  DO kv=1,nm_dims
-!---
-    i_rc = NF90_INQUIRE_DIMENSION(f_e,kv,name=f_d_n,len=ml)
-    CALL strlowercase (f_d_n)
-    f_d_n = ADJUSTL(f_d_n)
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) "  flio_inf ",kv,ml," ",TRIM(f_d_n)
-    ENDIF
-!---
-    IF (PRESENT(nn_idm))  nn_idm(kv)=kv;
-    IF (PRESENT(nn_ldm))  nn_ldm(kv)=ml;
-    IF (PRESENT(cc_ndm))  cc_ndm(kv)=TRIM(f_d_n);
-!---
-    IF      (    (INDEX(f_d_n,'x') == 1)   &
- &           .OR.(INDEX(f_d_n,'lon') == 1) ) THEN
-      IF (PRESENT(nn_aid)) THEN
-        IF (nn_aid(k_lon) < 0) THEN
-          nn_aid(k_lon)=kv;
-        ENDIF
-      ENDIF
-    ELSE IF (    (INDEX(f_d_n,'y') == 1)   &
- &           .OR.(INDEX(f_d_n,'lat') == 1) ) THEN
-      IF (PRESENT(nn_aid)) THEN
-        IF (nn_aid(k_lat) < 0) THEN
-          nn_aid(k_lat)=kv;
-        ENDIF
-      ENDIF
-    ELSE IF (    (INDEX(f_d_n,'z') == 1)     &
- &           .OR.(INDEX(f_d_n,'lev') == 1)   &
- &           .OR.(INDEX(f_d_n,'plev') == 1)  &
- &           .OR.(INDEX(f_d_n,'depth') == 1) ) THEN
-      IF (PRESENT(nn_aid)) THEN
-        IF (nn_aid(k_lev) < 0) THEN
-          nn_aid(k_lev)=kv;
-        ENDIF
-      ENDIF
-    ELSE IF (    (TRIM(f_d_n) == 't')         &
- &           .OR.(TRIM(f_d_n) == 'time')      &
- &           .OR.(INDEX(f_d_n,'tstep') == 1)  &
- &           .OR.(INDEX(f_d_n,'time_counter') == 1) ) THEN
-!---- For the time we certainly need to allow for other names
-      IF (PRESENT(nn_aid)) THEN
-        IF (nn_aid(k_tim) < 0) THEN
-          nn_aid(k_tim)=kv;
-        ENDIF
-      ENDIF
-    ENDIF
-!---
-  ENDDO
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "<-flio_inf"
-  ENDIF
-!----------------------
-END SUBROUTINE flio_inf
-!===
-SUBROUTINE flio_qax (f_i,axtype,i_v,nbd)
-!---------------------------------------------------------------------
-!- This subroutine explores the file in order to find
-!- an axis (x/y/z/t) according to a number of rules
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: f_i,i_v,nbd
-  CHARACTER(LEN=*) :: axtype
-!-
-  INTEGER :: kv,k,n_r,l_d,n_d,i_rc,dimnb
-  CHARACTER(LEN=1)  :: c_ax
-  CHARACTER(LEN=9)  :: c_sn
-  CHARACTER(LEN=15),DIMENSION(10) :: c_r
-  CHARACTER(LEN=40) :: c_t1,c_t2
-!---------------------------------------------------------------------
-  i_v = -1; nbd = -1;
-!---
-!- Keep the name of the axis
-!---
-  c_ax = TRIM(axtype)
-!-
-! Validate axis type
-!-
-  IF (    (LEN_TRIM(axtype) == 1) &
- &    .AND.(    (c_ax == 'x').OR.(c_ax == 'y') &
- &          .OR.(c_ax == 'z').OR.(c_ax == 't')) ) THEN
-!---
-!-- Define the maximum number of dimensions for the coordinate
-!---
-      SELECT CASE (c_ax)
-      CASE('x')
-        l_d = 2
-        c_sn = 'longitude'
-      CASE('y')
-        l_d = 2
-        c_sn = 'latitude'
-      CASE('z')
-        l_d = 1
-        c_sn = 'model_level_number'
-      CASE('t')
-        l_d = 1
-        c_sn = 'time'
-      END SELECT
-!---
-!-- Rule 1 : we look for a variable with one dimension
-!--          and which has the same name as its dimension (NUG)
-!---
-    IF (i_v < 0) THEN
-      SELECT CASE (c_ax)
-      CASE('x')
-        k = nw_ai(k_lon,f_i)
-      CASE('y')
-        k = nw_ai(k_lat,f_i)
-      CASE('z')
-        k = nw_ai(k_lev,f_i)
-      CASE('t')
-        k = nw_ai(k_tim,f_i)
-      END SELECT
-      IF ( (k >= 1).AND.(k <= nb_ax_mx) ) THEN
-        dimnb = nw_di(k,f_i)
-      ELSE
-        dimnb = -1
-      ENDIF
-!-----
-      i_rc = NF90_INQUIRE_DIMENSION(nw_id(f_i),dimnb,name=c_t1)
-      IF (i_rc == NF90_NOERR) THEN
-        CALL strlowercase (c_t1)
-        L_R1: DO kv=1,nw_nv(f_i)
-          i_rc = NF90_INQUIRE_VARIABLE &
- &                 (nw_id(f_i),kv,name=c_t2,ndims=n_d)
-          IF (n_d == 1) THEN
-            CALL strlowercase (c_t2)
-            IF (TRIM(c_t1) == TRIM(c_t2)) THEN
-              i_v = kv; nbd = n_d;
-              EXIT L_R1
-            ENDIF
-          ENDIF
-        ENDDO L_R1
-      ENDIF
-    ENDIF
-!---
-!-- Rule 2 : we look for a correct "axis" attribute (CF)
-!---
-    IF (i_v < 0) THEN
-      L_R2: DO kv=1,nw_nv(f_i)
-        i_rc = NF90_GET_ATT(nw_id(f_i),kv,'axis',c_t1)
-        IF (i_rc == NF90_NOERR) THEN
-          CALL strlowercase (c_t1)
-          IF (TRIM(c_t1) == c_ax) THEN
-            i_rc = NF90_INQUIRE_VARIABLE(nw_id(f_i),kv,ndims=n_d)
-            IF (n_d <= l_d) THEN
-              i_v = kv; nbd = n_d;
-              EXIT L_R2
-            ENDIF
-          ENDIF
-        ENDIF
-      ENDDO L_R2
-    ENDIF
-!---
-!-- Rule 3 : we look for a correct "standard_name" attribute (CF)
-!---
-    IF (i_v < 0) THEN
-      L_R3: DO kv=1,nw_nv(f_i)
-        i_rc = NF90_GET_ATT(nw_id(f_i),kv,'standard_name',c_t1)
-        IF (i_rc == NF90_NOERR) THEN
-          CALL strlowercase (c_t1)
-          IF (TRIM(c_t1) == TRIM(c_sn)) THEN
-            i_rc = NF90_INQUIRE_VARIABLE(nw_id(f_i),kv,ndims=n_d)
-            IF (n_d <= l_d) THEN
-              i_v = kv; nbd = n_d;
-              EXIT L_R3
-            ENDIF
-          ENDIF
-        ENDIF
-      ENDDO L_R3
-    ENDIF
-!---
-!-- Rule 4 : we look for a specific name (IOIPSL)
-!---
-    IF (i_v < 0) THEN
-      SELECT CASE (c_ax)
-      CASE('x')
-        n_r = 3
-        c_r(1)='nav_lon'; c_r(2)='lon'; c_r(3)='longitude';
-      CASE('y')
-        n_r = 3
-        c_r(1)='nav_lat'; c_r(2)='lat'; c_r(3)='latitude';
-      CASE('z')
-        n_r = 8
-        c_r(1)='depth'; c_r(2)='deptht'; c_r(3)='height';
-        c_r(4)='level'; c_r(5)='lev'; c_r(6)='plev';
-        c_r(7)='sigma_level'; c_r(8)='layer';
-      CASE('t')
-        n_r = 3
-        c_r(1)='time'; c_r(2)='tstep'; c_r(3)='timesteps';
-      END SELECT
-!-----
-      L_R4: DO kv=1,nw_nv(f_i)
-        i_rc = NF90_INQUIRE_VARIABLE &
- &               (nw_id(f_i),kv,name=c_t1,ndims=n_d)
-        IF (i_rc == NF90_NOERR) THEN
-          CALL strlowercase (c_t1)
-          IF (n_d <= l_d) THEN
-            DO k=1,n_r
-              IF (TRIM(c_t1) == TRIM(c_r(k))) THEN
-                i_v = kv; nbd = n_d;
-                EXIT L_R4
-              ENDIF
-            ENDDO
-          ENDIF
-        ENDIF
-      ENDDO L_R4
-    ENDIF
-!---
-  ENDIF
-!----------------------
-END SUBROUTINE flio_qax
-!-
-!===
-!-
-END MODULE fliocom
Index: des/icosagcm/trunk/tools/ioipsl/histcom.f90
===================================================================
--- /codes/icosagcm/trunk/tools/ioipsl/histcom.f90	(revision 487)
+++ 	(revision )
@@ -1,2573 +1,0 @@
-MODULE histcom
-!-
-!$Id: histcom.f90 760 2009-10-26 14:10:32Z bellier $
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!-
-  USE netcdf
-!-
-  USE stringop, ONLY : nocomma,cmpblank,findpos,find_str,strlowercase
-  USE mathelp,  ONLY : mathop,moycum,buildop
-  USE fliocom,  ONLY : flio_dom_file,flio_dom_att
-  USE calendar
-  USE errioipsl, ONLY : ipslerr,ipsldbg
-!-
-  IMPLICIT NONE
-!-
-  PRIVATE
-  PUBLIC :: histbeg,histdef,histhori,histvert,histend, &
- &          histwrite,histclo,histsync,ioconf_modname
-!---------------------------------------------------------------------
-!- Some confusing vocabulary in this code !
-!- =========================================
-!-
-!- A REGULAR grid is a grid which is i,j indexes
-!- and thus it is stored in a 2D matrix.
-!- This is opposed to a IRREGULAR grid which is only in a vector
-!- and where we do not know which neighbors we have.
-!- As a consequence we need the bounds for each grid-cell.
-!-
-!- A RECTILINEAR grid is a special case of a regular grid
-!- in which all longitudes for i constant are equal
-!- and all latitudes for j constant.
-!- In other words we do not need the full 2D matrix
-!- to describe the grid, just two vectors.
-!---------------------------------------------------------------------
-!-
-  INTERFACE histbeg
-    MODULE PROCEDURE histbeg_totreg,histbeg_regular,histbeg_irregular
-  END INTERFACE
-!-
-  INTERFACE histhori
-    MODULE PROCEDURE histhori_regular,histhori_irregular
-  END INTERFACE
-!-
-  INTERFACE histwrite
-!---------------------------------------------------------------------
-!- The "histwrite" routines will give the data to the I/O system.
-!- It will trigger the operations to be performed,
-!- and the writting to the file if needed
-!-
-!- We test for the work to be done at this time here so that at a
-!- later stage we can call different operation and write subroutine
-!- for the REAL and INTEGER interfaces
-!-
-!- INPUT
-!- pfileid  : The ID of the file on which this variable is to be,
-!-            written. The variable should have been defined in
-!-            this file before.
-!- pvarname : The short name of the variable
-!- pitau    : Current timestep
-!- pdata    : The variable, I mean the real data !
-!- nbindex  : The number of indexes provided. If it is equal to
-!-            the size of the full field as provided in histdef
-!-            then nothing is done.
-!- nindex   : The indices used to expand the variable (pdata)
-!-            onto the full field.
-!---------------------------------------------------------------------
-!- histwrite - we have to prepare different type of fields :
-!-             real and integer, 1,2 or 3D
-    MODULE PROCEDURE histwrite_r1d,histwrite_r2d,histwrite_r3d
-  END INTERFACE
-!-
-! Fixed parameter
-!-
-  INTEGER,PARAMETER :: nb_files_max=20,nb_var_max=400, &
- &                     nb_hax_max=5,nb_zax_max=10,nbopp_max=10
-  REAL,PARAMETER :: missing_val=nf90_fill_real
-  INTEGER,PARAMETER,PUBLIC :: &
- &  hist_r4=nf90_real4, hist_r8=nf90_real8
-!-
-! Variable derived type
-!-
-TYPE T_D_V
-  INTEGER :: ncvid
-  INTEGER :: nbopp
-  CHARACTER(LEN=20) :: v_name,unit_name
-  CHARACTER(LEN=80) :: title,fullop
-  CHARACTER(LEN=7)  :: topp
-  CHARACTER(LEN=7),DIMENSION(nbopp_max) :: sopps
-  REAL,DIMENSION(nbopp_max) :: scal
-!-External type (for R4/R8)
-  INTEGER :: v_typ
-!-Sizes of the associated grid and zommed area
-  INTEGER,DIMENSION(3) :: scsize,zorig,zsize
-!-Sizes for the data as it goes through the various math operations
-  INTEGER,DIMENSION(3) :: datasz_in = -1
-  INTEGER :: datasz_max = -1
-!-
-  INTEGER :: h_axid,z_axid,t_axid
-!-
-  REAL,DIMENSION(2) :: hist_minmax
-  LOGICAL :: hist_calc_rng=.FALSE.,hist_wrt_rng=.FALSE.
-!-Book keeping of the axes
-  INTEGER :: tdimid,tax_last
-  CHARACTER(LEN=40) :: tax_name
-!-
-  REAL :: freq_opp,freq_wrt
-  INTEGER :: &
- &  last_opp,last_wrt,last_opp_chk,last_wrt_chk,nb_opp,nb_wrt,point
-!- For future optimization
-!#  REAL,ALLOCATABLE,DIMENSION(:) :: V_1_D
-!#  REAL,ALLOCATABLE,DIMENSION(:,:) :: V_2_D
-!#  REAL,ALLOCATABLE,DIMENSION(:,:,:) :: V_3_D
-END TYPE T_D_V
-!-
-! File derived type
-!-
-TYPE :: T_D_F
-!-NETCDF IDs for file
-  INTEGER :: ncfid
-!-Time variables
-  INTEGER :: itau0=0
-  REAL :: date0,deltat
-!-Counter of elements (variables, time-horizontal-vertical axis
-  INTEGER :: n_var=0,n_tax=0,n_hax=0,n_zax=0
-!-NETCDF dimension IDs for time-longitude-latitude
-  INTEGER :: tid,xid,yid
-!-General definitions in the NETCDF file
-  INTEGER,DIMENSION(2) :: full_size=0,slab_ori,slab_sz
-!-The horizontal axes
-  CHARACTER(LEN=25),DIMENSION(nb_hax_max,2) :: hax_name
-!-The vertical axes
-  INTEGER,DIMENSION(nb_zax_max) :: zax_size,zax_ids
-  CHARACTER(LEN=20),DIMENSION(nb_zax_max) :: zax_name
-!-
-  LOGICAL :: regular=.TRUE.
-!-DOMAIN ID
-  INTEGER :: dom_id_svg=-1
-!-
-  TYPE(T_D_V),DIMENSION(nb_var_max) :: W_V
-END TYPE T_D_F
-!-
-TYPE(T_D_F),DIMENSION(nb_files_max),SAVE :: W_F
-!-
-! Counter of elements
-!-
-  INTEGER,SAVE :: nb_files=0
-!-
-! Book keeping for the buffers
-!-
-  INTEGER,SAVE :: buff_pos=0
-  REAL,ALLOCATABLE,DIMENSION(:),SAVE :: buffer
-!-
-! A list of functions which require special action
-! (Needs to be updated when functions are added
-!  but they are well located here)
-!-
-  CHARACTER(LEN=30),SAVE :: fuchnbout = 'scatter, fill'
-!- Some configurable variables with locks
-  CHARACTER(LEN=80),SAVE :: model_name='An IPSL model'
-  LOGICAL,SAVE :: lock_modname=.FALSE.
-!-
-!===
-CONTAINS
-!===
-!-
-SUBROUTINE histbeg_totreg                 &
- & (pfilename,pim,plon,pjm,plat,          &
- &  par_orix,par_szx,par_oriy,par_szy,    &
- &  pitau0,pdate0,pdeltat,phoriid,pfileid,domain_id,nb_bits)
-!---------------------------------------------------------------------
-!- This is just an interface for histbeg_regular in case when
-!- the user provides plon and plat as vectors.
-!- Obviously this can only be used for very regular grids.
-!-
-!- INPUT
-!-
-!- pfilename : Name of the netcdf file to be created
-!- pim       : Size of arrays in longitude direction
-!- plon      : Coordinates of points in longitude
-!- pjm       : Size of arrays in latitude direction
-!- plat      : Coordinates of points in latitude
-!-
-!- The next 4 arguments allow to define a horizontal zoom
-!- for this file. It is assumed that all variables to come
-!- have the same index space. This can not be assumed for
-!- the z axis and thus we define the zoom in histdef.
-!-
-!- par_orix  : Origin of the slab of data within the X axis (pim)
-!- par_szx   : Size of the slab of data in X
-!- par_oriy  : Origin of the slab of data within the Y axis (pjm)
-!- par_szy   : Size of the slab of data in Y
-!-
-!- pitau0    : time step at which the history tape starts
-!- pdate0    : The Julian date at which the itau was equal to 0
-!- pdeltat   : Time step, in seconds, of the counter itau
-!-             used in histwrite for instance
-!-
-!- OUTPUT
-!-
-!- phoriid   : ID of the horizontal grid
-!- pfileid   : ID of the netcdf file
-!-
-!- Optional INPUT arguments
-!-
-!- domain_id       : Domain identifier
-!-
-!- TO DO
-!-
-!- This package should be written in f90
-!- and use the following features :
-!-    - structures for the meta-data of the files and variables
-!-    - memory allocation as needed
-!-    - Pointers
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: pfilename
-  INTEGER,INTENT(IN) :: pim,pjm
-  REAL,DIMENSION(pim),INTENT(IN) :: plon
-  REAL,DIMENSION(pjm),INTENT(IN) :: plat
-  INTEGER,INTENT(IN):: par_orix,par_szx,par_oriy,par_szy
-  INTEGER,INTENT(IN) :: pitau0
-  REAL,INTENT(IN) :: pdate0,pdeltat
-  INTEGER,INTENT(OUT) :: pfileid,phoriid
-  INTEGER,INTENT(IN),OPTIONAL :: domain_id,nb_bits
-!-
-  REAL,ALLOCATABLE,DIMENSION(:,:) :: lon_tmp,lat_tmp
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_totreg"
-!-
-  ALLOCATE(lon_tmp(pim,pjm),lat_tmp(pim,pjm))
-!-
-  lon_tmp(:,:) = SPREAD(plon(:),2,pjm)
-  lat_tmp(:,:) = SPREAD(plat(:),1,pim)
-!-
-  CALL histbeg_regular &
- &  (pfilename,pim,lon_tmp,pjm,lat_tmp, &
- &   par_orix,par_szx,par_oriy,par_szy, &
- &   pitau0,pdate0,pdeltat,phoriid,pfileid, &
- &   .TRUE.,domain_id,nb_bits)
-!-
-  DEALLOCATE(lon_tmp,lat_tmp)
-!----------------------------
-END SUBROUTINE histbeg_totreg
-!===
-SUBROUTINE histbeg_regular &
- & (pfilename,pim,plon,pjm,plat,           &
- &  par_orix,par_szx,par_oriy,par_szy,     &
- &  pitau0,pdate0,pdeltat,phoriid,pfileid, &
- &  opt_rectilinear,domain_id,nb_bits)
-!---------------------------------------------------------------------
-!- This subroutine initializes a netcdf file and returns the ID.
-!- It will set up the geographical space on which the data will be
-!- stored and offers the possibility of seting a zoom.
-!- It also gets the global parameters into the I/O subsystem.
-!-
-!- INPUT
-!-
-!- pfilename : Name of the netcdf file to be created
-!- pim       : Size of arrays in longitude direction
-!- plon      : Coordinates of points in longitude
-!- pjm       : Size of arrays in latitude direction
-!- plat      : Coordinates of points in latitude
-!-
-!- The next 4 arguments allow to define a horizontal zoom
-!- for this file. It is assumed that all variables to come
-!- have the same index space. This can not be assumed for
-!- the z axis and thus we define the zoom in histdef.
-!-
-!- par_orix  : Origin of the slab of data within the X axis (pim)
-!- par_szx   : Size of the slab of data in X
-!- par_oriy  : Origin of the slab of data within the Y axis (pjm)
-!- par_szy   : Size of the slab of data in Y
-!-
-!- pitau0    : time step at which the history tape starts
-!- pdate0    : The Julian date at which the itau was equal to 0
-!- pdeltat   : Time step, in seconds, of the counter itau
-!-             used in histwrite for instance
-!-
-!- OUTPUT
-!-
-!- phoriid   : ID of the horizontal grid
-!- pfileid   : ID of the netcdf file
-!-
-!- Optional INPUT arguments
-!-
-!- opt_rectilinear : If true we know the grid is rectilinear
-!- domain_id       : Domain identifier
-!-
-!- TO DO
-!-
-!- This package should be written in F90 and use the following
-!- feature :
-!-   - structures for the meta-data of the files and variables
-!-   - memory allocation as needed
-!-   - Pointers
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: pfilename
-  INTEGER,INTENT(IN) :: pim,pjm
-  REAL,DIMENSION(pim,pjm),INTENT(IN) :: plon,plat
-  INTEGER,INTENT(IN):: par_orix,par_szx,par_oriy,par_szy
-  INTEGER,INTENT(IN) :: pitau0
-  REAL,INTENT(IN) :: pdate0,pdeltat
-  INTEGER,INTENT(OUT) :: pfileid,phoriid
-  LOGICAL,INTENT(IN),OPTIONAL :: opt_rectilinear
-  INTEGER,INTENT(IN),OPTIONAL :: domain_id,nb_bits
-!-
-  INTEGER :: nfid,iret,m_c
-  CHARACTER(LEN=120) :: file
-  CHARACTER(LEN=30) :: timenow
-  LOGICAL :: rectilinear
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_regular 0.0"
-!-
-  nb_files = nb_files+1
-  IF (nb_files > nb_files_max) THEN
-    CALL ipslerr (3,"histbeg", &
-   &  'Table of files too small. You should increase nb_files_max', &
-   &  'in histcom.f90 in order to accomodate all these files',' ')
-  ENDIF
-  pfileid  = nb_files
-!-
-! 1.0 Transfering into the common for future use
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_regular 1.0"
-!-
-  W_F(pfileid)%itau0  = pitau0
-  W_F(pfileid)%date0  = pdate0
-  W_F(pfileid)%deltat = pdeltat
-!-
-  IF (PRESENT(opt_rectilinear)) THEN
-    rectilinear = opt_rectilinear
-  ELSE
-    rectilinear = .FALSE.
-  ENDIF
-!-
-! 2.0 Initializes all variables for this file
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_regular 2.0"
-!-
-  W_F(pfileid)%n_var = 0
-  W_F(pfileid)%n_tax = 0
-  W_F(pfileid)%n_hax = 0
-  W_F(pfileid)%n_zax = 0
-!-
-  W_F(pfileid)%slab_ori(1:2) = (/ par_orix,par_oriy /)
-  W_F(pfileid)%slab_sz(1:2)  = (/ par_szx, par_szy  /)
-!-
-! 3.0 Opening netcdf file and defining dimensions
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_regular 3.0"
-!-
-! Add DOMAIN number and ".nc" suffix in file name if needed
-!-
-  file = pfilename
-  CALL flio_dom_file (file,domain_id)
-!-
-! Check the mode
-  IF (PRESENT(nb_bits)) THEN
-    SELECT CASE (nb_bits)
-    CASE(32)
-      m_c = NF90_CLOBBER
-    CASE(64)
-      m_c = IOR(NF90_CLOBBER,NF90_64BIT_OFFSET)
-    CASE DEFAULT
-      CALL ipslerr (3,"histbeg", &
- &      'Invalid argument nb_bits for file :',TRIM(file), &
- &      'Supported values are 32 or 64')
-    END SELECT
-  ELSE
-    m_c = IOR(NF90_CLOBBER,NF90_64BIT_OFFSET)
-  ENDIF
-!-
-! Create file
-  iret = NF90_CREATE (file,m_c,nfid)
-!-
-  IF (rectilinear) THEN
-    iret = NF90_DEF_DIM (nfid,'lon',par_szx,W_F(pfileid)%xid)
-    iret = NF90_DEF_DIM (nfid,'lat',par_szy,W_F(pfileid)%yid)
-  ELSE
-    iret = NF90_DEF_DIM (nfid,'x',par_szx,W_F(pfileid)%xid)
-    iret = NF90_DEF_DIM (nfid,'y',par_szy,W_F(pfileid)%yid)
-  ENDIF
-!-
-! 4.0 Declaring the geographical coordinates and other attributes
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_regular 4.0"
-!-
-! 4.3 Global attributes
-!-
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'Conventions','CF-1.1')
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'file_name',TRIM(file))
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'production',TRIM(model_name))
-  lock_modname = .TRUE.
-  CALL ioget_timestamp (timenow)
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'TimeStamp',TRIM(timenow))
-!-
-! 5.0 Saving some important information on this file in the common
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_regular 5.0"
-!-
-  IF (PRESENT(domain_id)) THEN
-    W_F(pfileid)%dom_id_svg = domain_id
-  ENDIF
-  W_F(pfileid)%ncfid = nfid
-  W_F(pfileid)%full_size(1:2) = (/ pim,pjm /)
-!-
-! 6.0 storing the geographical coordinates
-!-
-  W_F(pfileid)%regular=.TRUE.
-!-
-  CALL histhori_regular (pfileid,pim,plon,pjm,plat, &
- &  ' ','Default grid',phoriid,rectilinear)
-!-----------------------------
-END SUBROUTINE histbeg_regular
-!===
-SUBROUTINE histbeg_irregular &
- &  (pfilename,pim,plon,plon_bounds,plat,plat_bounds,   &
- &   pitau0,pdate0,pdeltat,phoriid,pfileid,domain_id,nb_bits)
-!---------------------------------------------------------------------
-!- This subroutine initializes a netcdf file and returns the ID.
-!- This version is for totaly irregular grids. In this case all
-!- all the data comes in as vectors and for the grid we have
-!- the coordinates of the 4 corners.
-!- It also gets the global parameters into the I/O subsystem.
-!-
-!- INPUT
-!-
-!- pfilename   : Name of the netcdf file to be created
-!- pim         : Size of arrays in longitude direction
-!- plon        : Coordinates of points in longitude
-!- plon_bounds : The 2 corners of the grid in longitude
-!- plat        : Coordinates of points in latitude
-!- plat_bounds : The 2 corners of the grid in latitude
-!-
-!- pitau0    : time step at which the history tape starts
-!- pdate0    : The Julian date at which the itau was equal to 0
-!- pdeltat   : Time step, in seconds, of the counter itau
-!-             used in histwrite for instance
-!-
-!- OUTPUT
-!-
-!- phoriid   : ID of the horizontal grid
-!- pfileid   : ID of the netcdf file
-!-
-!- Optional INPUT arguments
-!-
-!- domain_id       : Domain identifier
-!-
-!- TO DO
-!-
-!- This package should be written in F90 and use the following
-!- feature :
-!-   - structures for the meta-data of the files and variables
-!-   - memory allocation as needed
-!-   - Pointers
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: pfilename
-  INTEGER,INTENT(IN) :: pim
-  REAL,DIMENSION(pim),INTENT(IN) :: plon,plat
-  REAL,DIMENSION(:,:),INTENT(IN) :: plon_bounds,plat_bounds
-  INTEGER,INTENT(IN) :: pitau0
-  REAL,INTENT(IN) :: pdate0,pdeltat
-  INTEGER,INTENT(OUT) :: pfileid,phoriid
-  INTEGER,INTENT(IN),OPTIONAL :: domain_id,nb_bits
-!-
-  INTEGER :: nfid,iret,m_c
-  CHARACTER(LEN=120) :: file
-  CHARACTER(LEN=30) :: timenow
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_irregular 0.0"
-!-
-  nb_files = nb_files+1
-  IF (nb_files > nb_files_max) THEN
-    CALL ipslerr (3,"histbeg", &
- &    'Table of files too small. You should increase nb_files_max', &
- &    'in histcom.f90 in order to accomodate all these files',' ')
-  ENDIF
-  pfileid  = nb_files
-!-
-! 1.0 Transfering into the common for future use
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_irregular 1.0"
-!-
-  W_F(pfileid)%itau0  = pitau0
-  W_F(pfileid)%date0  = pdate0
-  W_F(pfileid)%deltat = pdeltat
-!-
-! 2.0 Initializes all variables for this file
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_irregular 2.0"
-!-
-  W_F(pfileid)%n_var = 0
-  W_F(pfileid)%n_tax = 0
-  W_F(pfileid)%n_hax = 0
-  W_F(pfileid)%n_zax = 0
-!-
-  W_F(pfileid)%slab_ori(1:2) = (/ 1,1 /)
-  W_F(pfileid)%slab_sz(1:2)  = (/ pim,1 /)
-!-
-! 3.0 Opening netcdf file and defining dimensions
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_irregular 3.0"
-!-
-! Add DOMAIN number and ".nc" suffix in file name if needed
-!-
-  file  = pfilename
-  CALL flio_dom_file (file,domain_id)
-!-
-! Check the mode
-  IF (PRESENT(nb_bits)) THEN
-    SELECT CASE (nb_bits)
-    CASE(32)
-      m_c = NF90_CLOBBER
-    CASE(64)
-      m_c = IOR(NF90_CLOBBER,NF90_64BIT_OFFSET)
-    CASE DEFAULT
-      CALL ipslerr (3,"histbeg", &
- &      'Invalid argument nb_bits for file :',TRIM(file), &
- &      'Supported values are 32 or 64')
-    END SELECT
-  ELSE
-    m_c = IOR(NF90_CLOBBER,NF90_64BIT_OFFSET)
-  ENDIF
-!-
-! Create file
-  iret = NF90_CREATE (file,m_c,nfid)
-!-
-  iret = NF90_DEF_DIM (nfid,'x',pim,W_F(pfileid)%xid)
-  W_F(pfileid)%yid = 0
-!-
-! 4.0 Declaring the geographical coordinates and other attributes
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_irregular 4.0"
-!-
-! 4.3 Global attributes
-!-
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'Conventions','CF-1.1')
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'file_name',TRIM(file))
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'production',TRIM(model_name))
-  lock_modname = .TRUE.
-  CALL ioget_timestamp (timenow)
-  iret = NF90_PUT_ATT (nfid,NF90_GLOBAL,'TimeStamp',TRIM(timenow))
-!-
-! 5.0 Saving some important information on this file in the common
-!-
-  IF (l_dbg) WRITE(*,*) "histbeg_irregular 5.0"
-!-
-  IF (PRESENT(domain_id)) THEN
-    W_F(pfileid)%dom_id_svg = domain_id
-  ENDIF
-  W_F(pfileid)%ncfid = nfid
-  W_F(pfileid)%full_size(1:2) = (/ pim,1 /)
-!-
-! 6.0 storing the geographical coordinates
-!-
-  W_F(pfileid)%regular=.FALSE.
-!-
-  CALL histhori_irregular &
- &  (pfileid,pim,plon,plon_bounds,plat,plat_bounds, &
- &   ' ','Default grid',phoriid)
-!-------------------------------
-END SUBROUTINE histbeg_irregular
-!===
-SUBROUTINE histhori_regular &
- &  (pfileid,pim,plon,pjm,plat,phname,phtitle,phid,opt_rectilinear)
-!---------------------------------------------------------------------
-!- This subroutine is made to declare a new horizontale grid.
-!- It has to have the same number of points as
-!- the original and thus in this routine we will only
-!- add two variable (longitude and latitude).
-!- Any variable in the file can thus point to this pair
-!- through an attribute. This routine is very usefull
-!- to allow staggered grids.
-!-
-!- INPUT
-!-
-!- pfileid : The id of the file to which the grid should be added
-!- pim     : Size in the longitude direction
-!- plon    : The longitudes
-!- pjm     : Size in the latitude direction
-!- plat    : The latitudes
-!- phname  : The name of grid
-!- phtitle : The title of the grid
-!-
-!- OUTPUT
-!-
-!- phid    : Id of the created grid
-!-
-!- OPTIONAL
-!-
-!- opt_rectilinear : If true we know the grid is rectilinear.
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pim,pjm
-  REAL,INTENT(IN),DIMENSION(pim,pjm) :: plon,plat
-  CHARACTER(LEN=*),INTENT(IN) :: phname,phtitle
-  INTEGER,INTENT(OUT) :: phid
-  LOGICAL,INTENT(IN),OPTIONAL :: opt_rectilinear
-!-
-  CHARACTER(LEN=25) :: lon_name,lat_name
-  CHARACTER(LEN=80) :: tmp_title,tmp_name
-  INTEGER :: ndim
-  INTEGER,DIMENSION(2) :: dims
-  INTEGER :: nlonid,nlatid
-  INTEGER :: orix,oriy,par_szx,par_szy
-  INTEGER :: iret,nfid
-  LOGICAL :: rectilinear
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Check that all fits in the buffers
-!-
-  IF (    (pim /= W_F(pfileid)%full_size(1)) &
- &    .OR.(pjm /= W_F(pfileid)%full_size(2)) ) THEN
-    CALL ipslerr (3,"histhori", &
- &   'The new horizontal grid does not have the same size', &
- &   'as the one provided to histbeg. This is not yet ', &
- &   'possible in the hist package.')
-  ENDIF
-!-
-  IF (PRESENT(opt_rectilinear)) THEN
-    rectilinear = opt_rectilinear
-  ELSE
-    rectilinear = .FALSE.
-  ENDIF
-!-
-! 1.1 Create all the variables needed
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_regular 1.0"
-!-
-  nfid = W_F(pfileid)%ncfid
-!-
-  ndim = 2
-  dims(1:2) = (/ W_F(pfileid)%xid,W_F(pfileid)%yid /)
-!-
-  tmp_name = phname
-  IF (rectilinear) THEN
-    IF (W_F(pfileid)%n_hax == 0) THEN
-      lon_name = 'lon'
-      lat_name = 'lat'
-    ELSE
-      lon_name = 'lon_'//TRIM(tmp_name)
-      lat_name = 'lat_'//TRIM(tmp_name)
-    ENDIF
-  ELSE
-    IF (W_F(pfileid)%n_hax == 0) THEN
-      lon_name = 'nav_lon'
-      lat_name = 'nav_lat'
-    ELSE
-      lon_name = 'nav_lon_'//TRIM(tmp_name)
-      lat_name = 'nav_lat_'//TRIM(tmp_name)
-    ENDIF
-  ENDIF
-!-
-! 1.2 Save the informations
-!-
-  phid = W_F(pfileid)%n_hax+1
-  W_F(pfileid)%n_hax = phid
-  W_F(pfileid)%hax_name(phid,1:2) = (/ lon_name,lat_name /)
-  tmp_title = phtitle
-!-
-! 2.0 Longitude
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_regular 2.0"
-!-
-  IF (rectilinear) THEN
-    ndim = 1
-    dims(1:1) = (/ W_F(pfileid)%xid /)
-  ENDIF
-  iret = NF90_DEF_VAR (nfid,lon_name,NF90_FLOAT,dims(1:ndim),nlonid)
-  IF (rectilinear) THEN
-    iret = NF90_PUT_ATT (nfid,nlonid,'axis',"X")
-  ENDIF
-  iret = NF90_PUT_ATT (nfid,nlonid,'standard_name',"longitude")
-  iret = NF90_PUT_ATT (nfid,nlonid,'units',"degrees_east")
-  iret = NF90_PUT_ATT (nfid,nlonid,'valid_min', &
- &                     REAL(MINVAL(plon),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlonid,'valid_max', &
- &                     REAL(MAXVAL(plon),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlonid,'long_name',"Longitude")
-  iret = NF90_PUT_ATT (nfid,nlonid,'nav_model',TRIM(tmp_title))
-!-
-! 3.0 Latitude
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_regular 3.0"
-!-
-  IF (rectilinear) THEN
-    ndim = 1
-    dims(1:1) = (/ W_F(pfileid)%yid /)
-  ENDIF
-  iret = NF90_DEF_VAR (nfid,lat_name,NF90_FLOAT,dims(1:ndim),nlatid)
-  IF (rectilinear) THEN
-    iret = NF90_PUT_ATT (nfid,nlatid,'axis',"Y")
-  ENDIF
-  iret = NF90_PUT_ATT (nfid,nlatid,'standard_name',"latitude")
-  iret = NF90_PUT_ATT (nfid,nlatid,'units',"degrees_north")
-  iret = NF90_PUT_ATT (nfid,nlatid,'valid_min', &
- &                     REAL(MINVAL(plat),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlatid,'valid_max', &
- &                     REAL(MAXVAL(plat),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlatid,'long_name',"Latitude")
-  iret = NF90_PUT_ATT (nfid,nlatid,'nav_model',TRIM(tmp_title))
-!-
-  iret = NF90_ENDDEF (nfid)
-!-
-! 4.0 storing the geographical coordinates
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_regular 4.0"
-!-
-  orix = W_F(pfileid)%slab_ori(1)
-  oriy = W_F(pfileid)%slab_ori(2)
-  par_szx = W_F(pfileid)%slab_sz(1)
-  par_szy = W_F(pfileid)%slab_sz(2)
-!-
-! Transfer the longitude
-!-
-  IF (rectilinear) THEN
-    iret = NF90_PUT_VAR (nfid,nlonid,plon(orix:orix+par_szx-1,1))
-  ELSE
-    iret = NF90_PUT_VAR (nfid,nlonid, &
- &           plon(orix:orix+par_szx-1,oriy:oriy+par_szy-1))
-  ENDIF
-!-
-! Transfer the latitude
-!-
-  IF (rectilinear) THEN
-    iret = NF90_PUT_VAR (nfid,nlatid,plat(1,oriy:oriy+par_szy-1))
-  ELSE
-    iret = NF90_PUT_VAR (nfid,nlatid, &
- &           plat(orix:orix+par_szx-1,oriy:oriy+par_szy-1))
-  ENDIF
-!-
-  iret = NF90_REDEF (nfid)
-!------------------------------
-END SUBROUTINE histhori_regular
-!===
-SUBROUTINE histhori_irregular &
- &  (pfileid,pim,plon,plon_bounds,plat,plat_bounds, &
- &   phname,phtitle,phid)
-!---------------------------------------------------------------------
-!- This subroutine is made to declare a new horizontale grid.
-!- It has to have the same number of points as
-!- the original and thus in this routine we will only
-!- add two variable (longitude and latitude).
-!- Any variable in the file can thus point to this pair
-!- through an attribute. This routine is very usefull
-!- to allow staggered grids.
-!-
-!- INPUT
-!-
-!- pfileid     : The id of the file to which the grid should be added
-!- pim         : Size in the longitude direction
-!- plon        : The longitudes
-!- plon_bounds : The boundaries of the grid in longitude
-!- plat        : The latitudes
-!- plat_bounds : Boundaries of the grid in latitude
-!- phname      : The name of grid
-!- phtitle     : The title of the grid
-!-
-!- OUTPUT
-!-
-!- phid    : Id of the created grid
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pim
-  REAL,DIMENSION(pim),INTENT(IN) :: plon,plat
-  REAL,DIMENSION(:,:),INTENT(IN) :: plon_bounds,plat_bounds
-  CHARACTER(LEN=*),INTENT(IN) :: phname,phtitle
-  INTEGER,INTENT(OUT) :: phid
-!-
-  CHARACTER(LEN=25) :: lon_name,lat_name
-  CHARACTER(LEN=30) :: lonbound_name,latbound_name
-  CHARACTER(LEN=80) :: tmp_title,tmp_name,longname
-  INTEGER :: ndim,dims(2)
-  INTEGER :: ndimb,dimsb(2)
-  INTEGER :: nbbounds
-  INTEGER :: nlonid,nlatid,nlonidb,nlatidb
-  INTEGER :: iret,nfid,twoid
-  LOGICAL :: transp = .FALSE.
-  REAL,ALLOCATABLE,DIMENSION(:,:) :: bounds_trans
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Check that all fits in the buffers
-!-
-  IF (    (pim /= W_F(pfileid)%full_size(1)) &
- &    .OR.(W_F(pfileid)%full_size(2) /= 1) ) THEN
-    CALL ipslerr (3,"histhori", &
- &   'The new horizontal grid does not have the same size', &
- &   'as the one provided to histbeg. This is not yet ', &
- &   'possible in the hist package.')
-  ENDIF
-!-
-! 1.1 Create all the variables needed
-!-
-  IF (l_dbg) WRITE(*,*) 'histhori_irregular 1.0'
-!-
-  nfid = W_F(pfileid)%ncfid
-!-
-  IF     (SIZE(plon_bounds,DIM=1) == pim) THEN
-    nbbounds = SIZE(plon_bounds,DIM=2)
-    transp = .TRUE.
-  ELSEIF (SIZE(plon_bounds,DIM=2) == pim) THEN
-    nbbounds = SIZE(plon_bounds,DIM=1)
-    transp = .FALSE.
-  ELSE
-    CALL ipslerr (3,"histhori", &
-   &  'The boundary variable does not have any axis corresponding', &
-   &  'to the size of the longitude or latitude variable', &
-   &  '.')
-  ENDIF
-!-
-  ALLOCATE(bounds_trans(nbbounds,pim))
-!-
-  iret = NF90_DEF_DIM (nfid,'nbnd',nbbounds,twoid)
-  ndim = 1
-  dims(1) = W_F(pfileid)%xid
-  ndimb = 2
-  dimsb(1:2) = (/ twoid,W_F(pfileid)%xid /)
-!-
-  tmp_name = phname
-  IF (W_F(pfileid)%n_hax == 0) THEN
-    lon_name = 'nav_lon'
-    lat_name = 'nav_lat'
-  ELSE
-    lon_name = 'nav_lon_'//TRIM(tmp_name)
-    lat_name = 'nav_lat_'//TRIM(tmp_name)
-  ENDIF
-  lonbound_name = TRIM(lon_name)//'_bounds'
-  latbound_name = TRIM(lat_name)//'_bounds'
-!-
-! 1.2 Save the informations
-!-
-  phid = W_F(pfileid)%n_hax+1
-  W_F(pfileid)%n_hax = phid
-  W_F(pfileid)%hax_name(phid,1:2) = (/ lon_name,lat_name /)
-  tmp_title = phtitle
-!-
-! 2.0 Longitude
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_irregular 2.0"
-!-
-  iret = NF90_DEF_VAR (nfid,lon_name,NF90_FLOAT,dims(1:ndim),nlonid)
-  iret = NF90_PUT_ATT (nfid,nlonid,'standard_name',"longitude")
-  iret = NF90_PUT_ATT (nfid,nlonid,'units',"degrees_east")
-  iret = NF90_PUT_ATT (nfid,nlonid,'valid_min', &
- &                     REAL(MINVAL(plon),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlonid,'valid_max', &
- &                     REAL(MAXVAL(plon),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlonid,'long_name',"Longitude")
-  iret = NF90_PUT_ATT (nfid,nlonid,'nav_model',TRIM(tmp_title))
-!-
-! 2.1 Longitude bounds
-!-
-  iret = NF90_PUT_ATT (nfid,nlonid,'bounds',TRIM(lonbound_name))
-  iret = NF90_DEF_VAR (nfid,lonbound_name,NF90_FLOAT, &
- &                     dimsb(1:ndimb),nlonidb)
-  longname = 'Boundaries for coordinate variable '//TRIM(lon_name)
-  iret = NF90_PUT_ATT (nfid,nlonidb,'long_name',TRIM(longname))
-!-
-! 3.0 Latitude
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_irregular 3.0"
-!-
-  iret = NF90_DEF_VAR (nfid,lat_name,NF90_FLOAT,dims(1:ndim),nlatid)
-  iret = NF90_PUT_ATT (nfid,nlatid,'standard_name',"latitude")
-  iret = NF90_PUT_ATT (nfid,nlatid,'units',"degrees_north")
-  iret = NF90_PUT_ATT (nfid,nlatid,'valid_min', &
- &                     REAL(MINVAL(plat),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlatid,'valid_max', &
- &                     REAL(MAXVAL(plat),KIND=4))
-  iret = NF90_PUT_ATT (nfid,nlatid,'long_name',"Latitude")
-  iret = NF90_PUT_ATT (nfid,nlatid,'nav_model',TRIM(tmp_title))
-!-
-! 3.1 Latitude bounds
-!-
-  iret = NF90_PUT_ATT (nfid,nlatid,'bounds',TRIM(latbound_name))
-  iret = NF90_DEF_VAR (nfid,latbound_name,NF90_FLOAT, &
- &                     dimsb(1:ndimb),nlatidb)
-  longname = 'Boundaries for coordinate variable '//TRIM(lat_name)
-  iret = NF90_PUT_ATT (nfid,nlatidb,'long_name',TRIM(longname))
-!-
-  iret = NF90_ENDDEF (nfid)
-!-
-! 4.0 storing the geographical coordinates
-!-
-  IF (l_dbg) WRITE(*,*) "histhori_irregular 4.0"
-!-
-! 4.1 Write the longitude
-!-
-  iret = NF90_PUT_VAR (nfid,nlonid,plon(1:pim))
-!-
-! 4.2 Write the longitude bounds
-!-
-  IF (transp) THEN
-    bounds_trans = TRANSPOSE(plon_bounds)
-  ELSE
-    bounds_trans = plon_bounds
-  ENDIF
-  iret = NF90_PUT_VAR (nfid,nlonidb,bounds_trans(1:nbbounds,1:pim))
-!-
-! 4.3 Write the latitude
-!-
-  iret = NF90_PUT_VAR (nfid,nlatid,plat(1:pim))
-!-
-! 4.4 Write the latitude bounds
-!-
-  IF (transp) THEN
-    bounds_trans = TRANSPOSE(plat_bounds)
-  ELSE
-    bounds_trans = plat_bounds
-  ENDIF
-  iret = NF90_PUT_VAR (nfid,nlatidb,bounds_trans(1:nbbounds,1:pim))
-!-
-  DEALLOCATE(bounds_trans)
-!-
-  iret = NF90_REDEF (nfid)
-!--------------------------------
-END SUBROUTINE histhori_irregular
-!===
-SUBROUTINE histvert (pfileid,pzaxname,pzaxtitle,pzaxunit, &
- &                   pzsize,pzvalues,pzaxid,pdirect)
-!---------------------------------------------------------------------
-!- This subroutine defines a vertical axis and returns it s id.
-!- It gives the user the possibility to the user to define many
-!- different vertical axes. For each variable defined with histdef a
-!- vertical axis can be specified with by it s ID.
-!-
-!- INPUT
-!-
-!- pfileid  : ID of the file the variable should be archived in
-!- pzaxname : Name of the vertical axis
-!- pzaxtitle: title of the vertical axis
-!- pzaxunit : Units of the vertical axis (no units if blank string)
-!- pzsize   : size of the vertical axis
-!- pzvalues : Coordinate values of the vetical axis
-!-
-!- pdirect  : is an optional argument which allows to specify the
-!-            the positive direction of the axis : up or down.
-!- OUTPUT
-!-
-!- pzaxid   : Returns the ID of the axis.
-!-            Note that this is not the netCDF ID !
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pzsize
-  CHARACTER(LEN=*),INTENT(IN) :: pzaxname,pzaxunit,pzaxtitle
-  REAL,INTENT(IN) :: pzvalues(pzsize)
-  INTEGER,INTENT(OUT) :: pzaxid
-  CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: pdirect
-!-
-  INTEGER :: pos,iv,zdimid,zaxid_tmp
-  CHARACTER(LEN=70) :: str71
-  CHARACTER(LEN=80) :: str80
-  CHARACTER(LEN=20) :: direction
-  INTEGER :: iret,leng,nfid
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Verifications :
-!    Do we have enough space for an extra axis ?
-!    Is the name already in use ?
-!-
-  IF (l_dbg) WRITE(*,*) "histvert : 1.0 Verifications", &
- &                      pzaxname,'---',pzaxunit,'---',pzaxtitle
-!-
-! - Direction of axis. Can we get if from the user.
-!   If not we put unknown.
-!-
-  IF (PRESENT(pdirect)) THEN
-    direction = TRIM(pdirect)
-    CALL strlowercase (direction)
-  ELSE
-    direction = 'unknown'
-  ENDIF
-!-
-! Check the consistency of the attribute
-!-
-  IF (     (direction /= 'unknown') &
- &    .AND.(direction /= 'up')      &
- &    .AND.(direction /= 'down')   ) THEN
-    direction = 'unknown'
-    str80 = 'The specified axis was : '//TRIM(direction)
-    CALL ipslerr (2,"histvert",&
-   & "The specified direction for the vertical axis is not possible.",&
-   & "it is replaced by : unknown",str80)
-  ENDIF
-!-
-  IF (W_F(pfileid)%n_zax+1 > nb_zax_max) THEN
-    CALL ipslerr (3,"histvert", &
-   &  'Table of vertical axes too small. You should increase ',&
-   &  'nb_zax_max in histcom.f90 in order to accomodate all ', &
-   &  'these variables ')
-  ENDIF
-!-
-  iv = W_F(pfileid)%n_zax
-  IF (iv > 1) THEN
-    CALL find_str (W_F(pfileid)%zax_name(1:iv-1),pzaxname,pos)
-  ELSE
-    pos = 0
-  ENDIF
-!-
-  IF (pos > 0) THEN
-    WRITE(str71,'("Check variable ",A," in file",I3)') &
- &    TRIM(pzaxname),pfileid
-    CALL ipslerr (3,"histvert", &
- &    "Vertical axis already exists",TRIM(str71), &
- &    "Can also be a wrong file ID in another declaration")
-  ENDIF
-!-
-  iv = W_F(pfileid)%n_zax+1
-!-
-! 2.0 Add the information to the file
-!-
-  IF (l_dbg) &
- &  WRITE(*,*) "histvert : 2.0 Add the information to the file"
-!-
-  nfid = W_F(pfileid)%ncfid
-!-
-  leng = MIN(LEN_TRIM(pzaxname),20)
-  iret = NF90_DEF_DIM (nfid,pzaxname(1:leng),pzsize,zaxid_tmp)
-  iret = NF90_DEF_VAR (nfid,pzaxname(1:leng),NF90_FLOAT, &
- &                     zaxid_tmp,zdimid)
-  iret = NF90_PUT_ATT (nfid,zdimid,'axis',"Z")
-  iret = NF90_PUT_ATT (nfid,zdimid,'standard_name',"model_level_number")
-  leng = MIN(LEN_TRIM(pzaxunit),20)
-  IF (leng > 0) THEN
-    iret = NF90_PUT_ATT (nfid,zdimid,'units',pzaxunit(1:leng))
-  ENDIF
-  iret = NF90_PUT_ATT (nfid,zdimid,'positive',TRIM(direction))
-  iret = NF90_PUT_ATT (nfid,zdimid,'valid_min', &
- &                     REAL(MINVAL(pzvalues(1:pzsize)),KIND=4))
-  iret = NF90_PUT_ATT (nfid,zdimid,'valid_max', &
- &                     REAL(MAXVAL(pzvalues(1:pzsize)),KIND=4))
-  leng = MIN(LEN_TRIM(pzaxname),20)
-  iret = NF90_PUT_ATT (nfid,zdimid,'title',pzaxname(1:leng))
-  leng = MIN(LEN_TRIM(pzaxtitle),80)
-  iret = NF90_PUT_ATT (nfid,zdimid,'long_name',pzaxtitle(1:leng))
-!-
-  iret = NF90_ENDDEF (nfid)
-!-
-  iret = NF90_PUT_VAR (nfid,zdimid,pzvalues(1:pzsize))
-!-
-  iret = NF90_REDEF (nfid)
-!-
-!- 3.0 add the information to the common
-!-
-  IF (l_dbg) &
-  &  WRITE(*,*) "histvert : 3.0 add the information to the common"
-!-
-  W_F(pfileid)%n_zax = iv
-  W_F(pfileid)%zax_size(iv) = pzsize
-  W_F(pfileid)%zax_name(iv) = pzaxname
-  W_F(pfileid)%zax_ids(iv) = zaxid_tmp
-  pzaxid = iv
-!----------------------
-END SUBROUTINE histvert
-!===
-SUBROUTINE histdef (pfileid,pvarname,ptitle,punit, &
- &                  pxsize,pysize,phoriid,pzsize,  &
- &                  par_oriz,par_szz,pzid,         &
- &                  pnbbyt,popp,pfreq_opp,pfreq_wrt,var_range)
-!---------------------------------------------------------------------
-!- With this subroutine each variable to be archived on the history
-!- tape should be declared.
-!-
-!- It gives the user the choise of operation
-!- to be performed on the variables, the frequency of this operation
-!- and finaly the frequency of the archiving.
-!-
-!- INPUT
-!-
-!- pfileid  : ID of the file the variable should be archived in
-!- pvarname : Name of the variable, short and easy to remember
-!- ptitle   : Full name of the variable
-!- punit    : Units of the variable (no units if blank string)
-!-
-!- The next 3 arguments give the size of that data
-!- that will be passed to histwrite. The zoom will be
-!- done there with the horizontal information obtained
-!- in histbeg and the vertical information to follow.
-!-
-!- pxsize   : Size in X direction (size of the data that will be
-!-            given to histwrite)
-!- pysize   : Size in Y direction
-!- phoriid  : ID of the horizontal axis
-!-
-!- The next two arguments give the vertical zoom to use.
-!-
-!- pzsize   : Size in Z direction (If 1 then no axis is declared
-!-            for this variable and pzid is not used)
-!- par_oriz : Off set of the zoom
-!- par_szz  : Size of the zoom
-!-
-!- pzid     : ID of the vertical axis to use. It has to have
-!-            the size of the zoom.
-!- pnbbyt   : External netCDF type (hist_r4/hist_r8)
-!- popp     : Operation to be performed. The following options
-!-            exist today :
-!- inst : keeps instantaneous values for writting
-!- ave  : Computes the average from call between writes
-!- pfreq_opp: Frequency of this operation (in seconds)
-!- pfreq_wrt: Frequency at which the variable should be
-!-            written (in seconds)
-!- var_range: Range of the variable.
-!-            If the minimum is greater than the maximum,
-!-            the values will be calculated.
-!-
-!- VERSION
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pxsize,pysize,pzsize,pzid
-  INTEGER,INTENT(IN) :: par_oriz,par_szz,pnbbyt,phoriid
-  CHARACTER(LEN=*),INTENT(IN) :: pvarname,punit,popp,ptitle
-  REAL,INTENT(IN) :: pfreq_opp,pfreq_wrt
-  REAL,DIMENSION(2),OPTIONAL,INTENT(IN) :: var_range
-!-
-  INTEGER :: iv,i
-  CHARACTER(LEN=70) :: str70,str71,str72
-  CHARACTER(LEN=20) :: tmp_name
-  CHARACTER(LEN=40) :: str40
-  CHARACTER(LEN=10) :: str10
-  CHARACTER(LEN=80) :: tmp_str80
-  CHARACTER(LEN=7) :: tmp_topp,tmp_sopp(nbopp_max)
-  CHARACTER(LEN=120) :: ex_topps
-  REAL :: tmp_scal(nbopp_max),un_an,un_jour,test_fopp,test_fwrt
-  INTEGER :: pos,buff_sz
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  ex_topps = 'ave, inst, t_min, t_max, t_sum, once, never, l_max, l_min'
-!-
-  W_F(pfileid)%n_var = W_F(pfileid)%n_var+1
-  iv = W_F(pfileid)%n_var
-!-
-  IF (iv > nb_var_max) THEN
-    CALL ipslerr (3,"histdef", &
-   &  'Table of variables too small. You should increase nb_var_max',&
-   &  'in histcom.f90 in order to accomodate all these variables', &
-   &  ' ')
-  ENDIF
-!-
-! 1.0 Transfer informations on the variable to the common
-!     and verify that it does not already exist
-!-
-  IF (l_dbg) WRITE(*,*) "histdef : 1.0"
-!-
-  IF (iv > 1) THEN
-    CALL find_str (W_F(pfileid)%W_V(1:iv-1)%v_name,pvarname,pos)
-  ELSE
-    pos = 0
-  ENDIF
-!-
-  IF (pos > 0) THEN
-    str70 = "Variable already exists"
-    WRITE(str71,'("Check variable  ",a," in file",I3)') &
- &    TRIM(pvarname),pfileid
-    str72 = "Can also be a wrong file ID in another declaration"
-    CALL ipslerr (3,"histdef",str70,str71,str72)
-  ENDIF
-!-
-  W_F(pfileid)%W_V(iv)%v_name = pvarname
-  W_F(pfileid)%W_V(iv)%title = ptitle
-  W_F(pfileid)%W_V(iv)%unit_name = punit
-  tmp_name = W_F(pfileid)%W_V(iv)%v_name
-!-
-! 1.1 decode the operations
-!-
-  W_F(pfileid)%W_V(iv)%fullop = popp
-  tmp_str80 = popp
-  CALL buildop &
- &  (tmp_str80,ex_topps,tmp_topp,nbopp_max,missing_val, &
- &   tmp_sopp,tmp_scal,W_F(pfileid)%W_V(iv)%nbopp)
-!-
-  W_F(pfileid)%W_V(iv)%topp = tmp_topp
-  DO i=1,W_F(pfileid)%W_V(iv)%nbopp
-    W_F(pfileid)%W_V(iv)%sopps(i) = tmp_sopp(i)
-    W_F(pfileid)%W_V(iv)%scal(i) = tmp_scal(i)
-  ENDDO
-!-
-! 1.2 If we have an even number of operations
-!     then we need to add identity
-!-
-  IF (    2*INT(W_F(pfileid)%W_V(iv)%nbopp/2.0) &
- &     == W_F(pfileid)%W_V(iv)%nbopp) THEN
-    W_F(pfileid)%W_V(iv)%nbopp = W_F(pfileid)%W_V(iv)%nbopp+1
-    W_F(pfileid)%W_V(iv)%sopps(W_F(pfileid)%W_V(iv)%nbopp) = 'ident'
-    W_F(pfileid)%W_V(iv)%scal(W_F(pfileid)%W_V(iv)%nbopp) = missing_val
-  ENDIF
-!-
-! 1.3 External type of the variable
-!-
-  IF (pnbbyt == hist_r8) THEN
-    W_F(pfileid)%W_V(iv)%v_typ = hist_r8
-  ELSE
-    W_F(pfileid)%W_V(iv)%v_typ = hist_r4
-  ENDIF
-!-
-! 2.0 Put the size of the variable in the common and check
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "histdef : 2.0",pfileid,iv,W_F(pfileid)%W_V(iv)%nbopp, &
- &    W_F(pfileid)%W_V(iv)%sopps(1:W_F(pfileid)%W_V(iv)%nbopp), &
- &    W_F(pfileid)%W_V(iv)%scal(1:W_F(pfileid)%W_V(iv)%nbopp)
-  ENDIF
-!-
-  W_F(pfileid)%W_V(iv)%scsize(1:3) = (/ pxsize,pysize,pzsize /)
-  W_F(pfileid)%W_V(iv)%zorig(1:3) = &
- &  (/ W_F(pfileid)%slab_ori(1),W_F(pfileid)%slab_ori(2),par_oriz /)
-  W_F(pfileid)%W_V(iv)%zsize(1:3) = &
- &  (/ W_F(pfileid)%slab_sz(1),W_F(pfileid)%slab_sz(2),par_szz /)
-!-
-! Is the size of the full array the same as that of the coordinates ?
-!-
-  IF (    (pxsize > W_F(pfileid)%full_size(1)) &
- &    .OR.(pysize > W_F(pfileid)%full_size(2)) ) THEN
-!-
-    str70 = "The size of the variable is different "// &
- &          "from the one of the coordinates"
-    WRITE(str71,'("Size of coordinates :",2I4)') &
- &   W_F(pfileid)%full_size(1),W_F(pfileid)%full_size(2)
-    WRITE(str72,'("Size declared for variable ",a," :",2I4)') &
- &   TRIM(tmp_name),pxsize,pysize
-    CALL ipslerr (3,"histdef",str70,str71,str72)
-  ENDIF
-!-
-! Is the size of the zoom smaller than the coordinates ?
-!-
-  IF (    (W_F(pfileid)%full_size(1) < W_F(pfileid)%slab_sz(1)) &
- &    .OR.(W_F(pfileid)%full_size(2) < W_F(pfileid)%slab_sz(2)) ) THEN
-    str70 = &
- &   "Size of variable should be greater or equal to those of the zoom"
-    WRITE(str71,'("Size of XY zoom :",2I4)') &
- &   W_F(pfileid)%slab_sz(1),W_F(pfileid)%slab_sz(2)
-    WRITE(str72,'("Size declared for variable ",A," :",2I4)') &
- &   TRIM(tmp_name),pxsize,pysize
-    CALL ipslerr (3,"histdef",str70,str71,str72)
-  ENDIF
-!-
-! 2.1 We store the horizontal grid information with minimal
-!     and a fall back onto the default grid
-!-
-  IF ( (phoriid > 0).AND.(phoriid <= W_F(pfileid)%n_hax) ) THEN
-    W_F(pfileid)%W_V(iv)%h_axid = phoriid
-  ELSE
-    W_F(pfileid)%W_V(iv)%h_axid = 1
-    CALL ipslerr (2,"histdef", &
-   &  'We use the default grid for variable as an invalide',&
-   &  'ID was provided for variable : ',TRIM(pvarname))
-  ENDIF
-!-
-! 2.2 Check the vertical coordinates if needed
-!-
-  IF (par_szz > 1) THEN
-!-
-!-- Does the vertical coordinate exist ?
-!-
-    IF (pzid > W_F(pfileid)%n_zax) THEN
-      WRITE(str70, &
- &    '("The vertical coordinate chosen for variable ",a)') &
- &     TRIM(tmp_name)
-      str71 = " Does not exist."
-      CALL ipslerr (3,"histdef",str70,str71," ")
-    ENDIF
-!-
-!-- Is the vertical size of the variable equal to that of the axis ?
-!-
-    IF (par_szz /= W_F(pfileid)%zax_size(pzid)) THEN
-      str70 = "The size of the zoom does not correspond "// &
- &            "to the size of the chosen vertical axis"
-      WRITE(str71,'("Size of zoom in z :",I4)') par_szz
-      WRITE(str72,'("Size declared for axis ",A," :",I4)') &
- &     TRIM(W_F(pfileid)%zax_name(pzid)),W_F(pfileid)%zax_size(pzid)
-      CALL ipslerr (3,"histdef",str70,str71,str72)
-    ENDIF
-!-
-!-- Is the zoom smaller that the total size of the variable ?
-!-
-    IF (pzsize < par_szz) THEN
-      str70 = "The vertical size of variable "// &
- &            "is smaller than that of the zoom."
-      WRITE(str71,'("Declared vertical size of data :",I5)') pzsize
-      WRITE(str72,'("Size of zoom for variable ",a," = ",I5)') &
- &     TRIM(tmp_name),par_szz
-      CALL ipslerr (3,"histdef",str70,str71,str72)
-    ENDIF
-    W_F(pfileid)%W_V(iv)%z_axid = pzid
-  ELSE
-    W_F(pfileid)%W_V(iv)%z_axid = -99
-  ENDIF
-!-
-! 3.0 Determine the position of the variable in the buffer
-!     If it is instantaneous output then we do not use the buffer
-!-
-  IF (l_dbg) WRITE(*,*) "histdef : 3.0"
-!-
-! 3.1 We get the size of the arrays histwrite will get and check
-!     that they fit into the tmp_buffer
-!-
-  buff_sz = W_F(pfileid)%W_V(iv)%zsize(1) &
- &         *W_F(pfileid)%W_V(iv)%zsize(2) &
- &         *W_F(pfileid)%W_V(iv)%zsize(3)
-!-
-! 3.2 move the pointer of the buffer array for operation
-!     which need bufferisation
-!-
-  IF (     (TRIM(tmp_topp) /= "inst") &
- &    .AND.(TRIM(tmp_topp) /= "once") &
- &    .AND.(TRIM(tmp_topp) /= "never") )THEN
-    W_F(pfileid)%W_V(iv)%point = buff_pos+1
-    buff_pos = buff_pos+buff_sz
-    IF (l_dbg) THEN
-      WRITE(*,*) "histdef : 3.2 bufpos for iv = ",iv, &
- &      " pfileid = ",pfileid," is = ",W_F(pfileid)%W_V(iv)%point
-    ENDIF
-  ENDIF
-!-
-! 4.0 Transfer the frequency of the operations and check
-!     for validity. We have to pay attention to negative values
-!     of the frequency which indicate monthly time-steps.
-!     The strategy is to bring it back to seconds for the tests
-!-
-  IF (l_dbg) WRITE(*,*) "histdef : 4.0"
-!-
-  W_F(pfileid)%W_V(iv)%freq_opp = pfreq_opp
-  W_F(pfileid)%W_V(iv)%freq_wrt = pfreq_wrt
-!-
-  CALL ioget_calendar(un_an,un_jour)
-  IF (pfreq_opp < 0) THEN
-    CALL ioget_calendar(un_an)
-    test_fopp = pfreq_opp*(-1.)*un_an/12.*un_jour
-  ELSE
-    test_fopp = pfreq_opp
-  ENDIF
-  IF (pfreq_wrt < 0) THEN
-    CALL ioget_calendar(un_an)
-    test_fwrt = pfreq_wrt*(-1.)*un_an/12.*un_jour
-  ELSE
-    test_fwrt = pfreq_wrt
-  ENDIF
-!-
-! 4.1 Frequency of operations and output should be larger than deltat !
-!-
-  IF (test_fopp < W_F(pfileid)%deltat) THEN
-    str70 = 'Frequency of operations should be larger than deltat'
-    WRITE(str71,'("It is not the case for variable ",a," :",F10.4)') &
- &   TRIM(tmp_name),pfreq_opp
-    str72 = "PATCH : frequency set to deltat"
-!-
-    CALL ipslerr (2,"histdef",str70,str71,str72)
-!-
-    W_F(pfileid)%W_V(iv)%freq_opp = W_F(pfileid)%deltat
-  ENDIF
-!-
-  IF (test_fwrt < W_F(pfileid)%deltat) THEN
-    str70 = 'Frequency of output should be larger than deltat'
-    WRITE(str71,'("It is not the case for variable ",a," :",F10.4)') &
- &   TRIM(tmp_name),pfreq_wrt
-    str72 = "PATCH : frequency set to deltat"
-!-
-    CALL ipslerr (2,"histdef",str70,str71,str72)
-!-
-    W_F(pfileid)%W_V(iv)%freq_wrt = W_F(pfileid)%deltat
-  ENDIF
-!-
-! 4.2 First the existence of the operation is tested and then
-!     its compaticility with the choice of frequencies
-!-
-  IF (TRIM(tmp_topp) == "inst") THEN
-    IF (test_fopp /= test_fwrt) THEN
-      str70 = 'For instantaneous output the frequency '// &
- &            'of operations and output'
-      WRITE(str71, &
- &     '("should be the same, this was not case for variable ",a)') &
- &      TRIM(tmp_name)
-      str72 = "PATCH : The smalest frequency of both is used"
-      CALL ipslerr (2,"histdef",str70,str71,str72)
-      IF (test_fopp < test_fwrt) THEN
-        W_F(pfileid)%W_V(iv)%freq_opp = pfreq_opp
-        W_F(pfileid)%W_V(iv)%freq_wrt = pfreq_opp
-      ELSE
-        W_F(pfileid)%W_V(iv)%freq_opp = pfreq_wrt
-        W_F(pfileid)%W_V(iv)%freq_wrt = pfreq_wrt
-      ENDIF
-    ENDIF
-  ELSE IF (INDEX(ex_topps,TRIM(tmp_topp)) > 0) THEN
-    IF (test_fopp > test_fwrt) THEN
-      str70 = 'For averages the frequency of operations '// &
-&             'should be smaller or equal'
-      WRITE(str71, &
- &     '("to that of output. It is not the case for variable ",a)') &
- &     TRIM(tmp_name)
-      str72 = 'PATCH : The output frequency is used for both'
-      CALL ipslerr (2,"histdef",str70,str71,str72)
-      W_F(pfileid)%W_V(iv)%freq_opp = pfreq_wrt
-    ENDIF
-  ELSE
-    WRITE (str70,'("Operation on variable ",a," is unknown")') &
-&    TRIM(tmp_name)
-    WRITE (str71,'("operation requested is :",a)') tmp_topp
-    WRITE (str72,'("File ID :",I3)') pfileid
-    CALL ipslerr (3,"histdef",str70,str71,str72)
-  ENDIF
-!-
-! 5.0 Initialize other variables of the common
-!-
-  IF (l_dbg) WRITE(*,*) "histdef : 5.0"
-!-
-  W_F(pfileid)%W_V(iv)%hist_wrt_rng = (PRESENT(var_range))
-  IF (W_F(pfileid)%W_V(iv)%hist_wrt_rng) THEN
-    W_F(pfileid)%W_V(iv)%hist_calc_rng = (var_range(1) > var_range(2))
-    IF (W_F(pfileid)%W_V(iv)%hist_calc_rng) THEN
-      W_F(pfileid)%W_V(iv)%hist_minmax(1:2) = &
- &      (/ ABS(missing_val),-ABS(missing_val) /)
-    ELSE
-      W_F(pfileid)%W_V(iv)%hist_minmax(1:2) = var_range(1:2)
-    ENDIF
-  ENDIF
-!-
-! - freq_opp(pfileid,iv)/2./deltat(pfileid)
-  W_F(pfileid)%W_V(iv)%last_opp = W_F(pfileid)%itau0
-! - freq_wrt(pfileid,iv)/2./deltat(pfileid)
-  W_F(pfileid)%W_V(iv)%last_wrt = W_F(pfileid)%itau0
-! - freq_opp(pfileid,iv)/2./deltat(pfileid)
-  W_F(pfileid)%W_V(iv)%last_opp_chk = W_F(pfileid)%itau0
-! - freq_wrt(pfileid,iv)/2./deltat(pfileid)
-  W_F(pfileid)%W_V(iv)%last_wrt_chk = W_F(pfileid)%itau0
-  W_F(pfileid)%W_V(iv)%nb_opp = 0
-  W_F(pfileid)%W_V(iv)%nb_wrt = 0
-!-
-! 6.0 Get the time axis for this variable
-!-
-  IF (l_dbg) WRITE(*,*) "histdef : 6.0"
-!-
-  IF (W_F(pfileid)%W_V(iv)%freq_wrt > 0) THEN
-    WRITE(str10,'(I8.8)') INT(W_F(pfileid)%W_V(iv)%freq_wrt)
-    str40 = TRIM(tmp_topp)//"_"//TRIM(str10)
-  ELSE
-    WRITE(str10,'(I2.2,"month")') ABS(INT(W_F(pfileid)%W_V(iv)%freq_wrt))
-    str40 = TRIM(tmp_topp)//"_"//TRIM(str10)
-  ENDIF
-  CALL find_str (W_F(pfileid)%W_V(1:W_F(pfileid)%n_tax)%tax_name,str40,pos)
-!-
-! No time axis for once, l_max, l_min or never operation
-!-
-  IF (     (TRIM(tmp_topp) /= 'once')  &
- &    .AND.(TRIM(tmp_topp) /= 'never') &
- &    .AND.(TRIM(tmp_topp) /= 'l_max') &
- &    .AND.(TRIM(tmp_topp) /= 'l_min') ) THEN
-    IF (pos < 0) THEN
-      W_F(pfileid)%n_tax = W_F(pfileid)%n_tax+1
-      W_F(pfileid)%W_V(W_F(pfileid)%n_tax)%tax_name = str40
-      W_F(pfileid)%W_V(W_F(pfileid)%n_tax)%tax_last = 0
-      W_F(pfileid)%W_V(iv)%t_axid = W_F(pfileid)%n_tax
-    ELSE
-      W_F(pfileid)%W_V(iv)%t_axid = pos
-    ENDIF
-  ELSE
-    IF (l_dbg)   WRITE(*,*) "histdef : 7.0 ",TRIM(tmp_topp),'----'
-    W_F(pfileid)%W_V(iv)%t_axid = -99
-  ENDIF
-!-
-! 7.0 prepare frequence of writing and operation
-!     for never or once operation
-!-
-  IF (    (TRIM(tmp_topp) == 'once')  &
- &    .OR.(TRIM(tmp_topp) == 'never') ) THEN
-    W_F(pfileid)%W_V(iv)%freq_opp = 0.
-    W_F(pfileid)%W_V(iv)%freq_wrt = 0.
-  ENDIF
-!---------------------
-END SUBROUTINE histdef
-!===
-SUBROUTINE histend (pfileid)
-!---------------------------------------------------------------------
-!- This subroutine end the decalaration of variables and sets the
-!- time axes in the netcdf file and puts it into the write mode.
-!-
-!- INPUT
-!-
-!- pfileid : ID of the file to be worked on
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid
-!-
-  INTEGER :: nfid,nvid,iret,ndim,iv,itx,ziv,itax,dim_cnt
-  INTEGER,DIMENSION(4) :: dims
-  INTEGER :: year,month,day,hours,minutes
-  REAL :: sec
-  REAL :: rtime0
-  CHARACTER(LEN=30) :: str30
-  CHARACTER(LEN=120) :: assoc
-  CHARACTER(LEN=70) :: str70
-  CHARACTER(LEN=3),DIMENSION(12) :: cal =   &
- &  (/ 'JAN','FEB','MAR','APR','MAY','JUN', &
- &     'JUL','AUG','SEP','OCT','NOV','DEC' /)
-  CHARACTER(LEN=7) :: tmp_opp
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  nfid = W_F(pfileid)%ncfid
-!-
-! 1.0 Create the time axes
-!-
-  IF (l_dbg) WRITE(*,*) "histend : 1.0"
-!---
-  iret = NF90_DEF_DIM (nfid,'time_counter', &
- &                     NF90_UNLIMITED,W_F(pfileid)%tid)
-!-
-! 1.1 Define all the time axes needed for this file
-!-
-  DO itx=1,W_F(pfileid)%n_tax
-    dims(1) = W_F(pfileid)%tid
-    IF (W_F(pfileid)%n_tax > 1) THEN
-      str30 = "t_"//W_F(pfileid)%W_V(itx)%tax_name
-    ELSE
-      str30 = "time_counter"
-    ENDIF
-    iret = NF90_DEF_VAR (nfid,str30,NF90_DOUBLE, &
- &           dims(1),W_F(pfileid)%W_V(itx)%tdimid)
-    IF (W_F(pfileid)%n_tax <= 1) THEN
-      iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid,'axis',"T")
-    ENDIF
-    iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid, &
- &           'standard_name',"time")
-!---
-!   To transform the current itau into a real date and take it
-!   as the origin of the file requires the time counter to change.
-!   Thus it is an operation the user has to ask for.
-!   This function should thus only be re-instated
-!   if there is a ioconf routine to control it.
-!---
-!-- rtime0 = itau2date(itau0(pfileid),date0(pfileid),deltat(pfileid))
-    rtime0 = W_F(pfileid)%date0
-!-
-    CALL ju2ymds(rtime0,year,month,day,sec)
-!---
-!   Catch any error induced by a change in calendar !
-!---
-    IF (year < 0) THEN
-      year = 2000+year
-    ENDIF
-!-
-    hours = INT(sec/(60.*60.))
-    minutes = INT((sec-hours*60.*60.)/60.)
-    sec = sec-(hours*60.*60.+minutes*60.)
-!-
-    WRITE (UNIT=str70, &
- &   FMT='(A,I4.4,"-",I2.2,"-",I2.2," ",I2.2,":",I2.2,":",I2.2)') &
- &    'seconds since ',year,month,day,hours,minutes,INT(sec)
-    iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid, &
- &           'units',TRIM(str70))
-!-
-    CALL ioget_calendar (str30)
-    iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid, &
- &           'calendar',TRIM(str30))
-!-
-    iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid, &
- &           'title','Time')
-!-
-    iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid, &
- &           'long_name','Time axis')
-!-
-    WRITE (UNIT=str70, &
- &   FMT='(" ",I4.4,"-",A3,"-",I2.2," ",I2.2,":",I2.2,":",I2.2)') &
- &    year,cal(month),day,hours,minutes,INT(sec)
-    iret = NF90_PUT_ATT (nfid,W_F(pfileid)%W_V(itx)%tdimid, &
- &           'time_origin',TRIM(str70))
-  ENDDO
-!-
-! 2.0 declare the variables
-!-
-  IF (l_dbg) WRITE(*,*) "histend : 2.0"
-!-
-  DO iv=1,W_F(pfileid)%n_var
-!---
-    itax = W_F(pfileid)%W_V(iv)%t_axid
-!---
-    IF (W_F(pfileid)%regular) THEN
-      dims(1:2) = (/ W_F(pfileid)%xid,W_F(pfileid)%yid /)
-      dim_cnt = 2
-    ELSE
-      dims(1) = W_F(pfileid)%xid
-      dim_cnt = 1
-    ENDIF
-!---
-    tmp_opp = W_F(pfileid)%W_V(iv)%topp
-    ziv = W_F(pfileid)%W_V(iv)%z_axid
-!---
-!   2.1 dimension of field
-!---
-    IF ((TRIM(tmp_opp) /= 'never')) THEN
-      IF (     (TRIM(tmp_opp) /= 'once')  &
-     &    .AND.(TRIM(tmp_opp) /= 'l_max') &
-     &    .AND.(TRIM(tmp_opp) /= 'l_min') ) THEN
-        IF (ziv == -99) THEN
-          ndim = dim_cnt+1
-          dims(dim_cnt+1:dim_cnt+2) = (/ W_F(pfileid)%tid,0 /)
-        ELSE
-          ndim = dim_cnt+2
-          dims(dim_cnt+1:dim_cnt+2) = &
- &         (/ W_F(pfileid)%zax_ids(ziv),W_F(pfileid)%tid /)
-        ENDIF
-      ELSE
-        IF (ziv == -99) THEN
-          ndim = dim_cnt
-          dims(dim_cnt+1:dim_cnt+2) = (/ 0,0 /)
-        ELSE
-          ndim = dim_cnt+1
-          dims(dim_cnt+1:dim_cnt+2) = (/ W_F(pfileid)%zax_ids(ziv),0 /)
-        ENDIF
-      ENDIF
-!-
-      iret = NF90_DEF_VAR (nfid,TRIM(W_F(pfileid)%W_V(iv)%v_name), &
- &             W_F(pfileid)%W_V(iv)%v_typ,dims(1:ABS(ndim)),nvid)
-!-
-      W_F(pfileid)%W_V(iv)%ncvid = nvid
-!-
-      IF (LEN_TRIM(W_F(pfileid)%W_V(iv)%unit_name) > 0) THEN
-        iret = NF90_PUT_ATT (nfid,nvid,'units', &
- &                           TRIM(W_F(pfileid)%W_V(iv)%unit_name))
-      ENDIF
-      iret = NF90_PUT_ATT (nfid,nvid,'standard_name', &
- &                         TRIM(W_F(pfileid)%W_V(iv)%title))
-!-
-      iret = NF90_PUT_ATT (nfid,nvid,'_FillValue', &
- &                         REAL(missing_val,KIND=4))
-      IF (W_F(pfileid)%W_V(iv)%hist_wrt_rng) THEN
-        iret = NF90_PUT_ATT (nfid,nvid,'valid_min', &
- &               REAL(W_F(pfileid)%W_V(iv)%hist_minmax(1),KIND=4))
-        iret = NF90_PUT_ATT (nfid,nvid,'valid_max', &
- &               REAL(W_F(pfileid)%W_V(iv)%hist_minmax(2),KIND=4))
-      ENDIF
-      iret = NF90_PUT_ATT (nfid,nvid,'long_name', &
- &                         TRIM(W_F(pfileid)%W_V(iv)%title))
-      iret = NF90_PUT_ATT (nfid,nvid,'online_operation', &
- &                         TRIM(W_F(pfileid)%W_V(iv)%fullop))
-!-
-      SELECT CASE(ndim)
-      CASE(-3,2:4)
-      CASE DEFAULT
-        CALL ipslerr (3,"histend", &
-       &  'less than 2 or more than 4 dimensions are not', &
-       &  'allowed at this stage',' ')
-      END SELECT
-!-
-      assoc=TRIM(W_F(pfileid)%hax_name(W_F(pfileid)%W_V(iv)%h_axid,2)) &
- &   //' '//TRIM(W_F(pfileid)%hax_name(W_F(pfileid)%W_V(iv)%h_axid,1))
-!-
-      ziv = W_F(pfileid)%W_V(iv)%z_axid
-      IF (ziv > 0) THEN
-        str30 = W_F(pfileid)%zax_name(ziv)
-        assoc = TRIM(str30)//' '//TRIM(assoc)
-      ENDIF
-!-
-      IF (itax > 0) THEN
-        IF (W_F(pfileid)%n_tax > 1) THEN
-          str30 = "t_"//W_F(pfileid)%W_V(itax)%tax_name
-        ELSE
-          str30 = "time_counter"
-        ENDIF
-        assoc = TRIM(str30)//' '//TRIM(assoc)
-!-
-        IF (l_dbg) THEN
-          WRITE(*,*) "histend : 2.0.n, freq_opp, freq_wrt", &
- &          W_F(pfileid)%W_V(iv)%freq_opp,W_F(pfileid)%W_V(iv)%freq_wrt
-        ENDIF
-!-
-        iret = NF90_PUT_ATT (nfid,nvid,'interval_operation', &
- &                           REAL(W_F(pfileid)%W_V(iv)%freq_opp,KIND=4))
-        iret = NF90_PUT_ATT (nfid,nvid,'interval_write', &
- &                           REAL(W_F(pfileid)%W_V(iv)%freq_wrt,KIND=4))
-      ENDIF
-      iret = NF90_PUT_ATT (nfid,nvid,'coordinates',TRIM(assoc))
-    ENDIF
-  ENDDO
-!-
-! 2.2 Add DOMAIN attributes if needed
-!-
-  IF (W_F(pfileid)%dom_id_svg >= 0) THEN
-    CALL flio_dom_att (nfid,W_F(pfileid)%dom_id_svg)
-  ENDIF
-!-
-! 3.0 Put the netcdf file into write mode
-!-
-  IF (l_dbg) WRITE(*,*) "histend : 3.0"
-!-
-  iret = NF90_ENDDEF (nfid)
-!-
-! 4.0 Give some informations to the user
-!-
-  IF (l_dbg) WRITE(*,*) "histend : 4.0"
-!-
-  WRITE(str70,'("All variables have been initialized on file :",I3)') pfileid
-  CALL ipslerr (1,'histend',str70,'',' ')
-!---------------------
-END SUBROUTINE histend
-!===
-SUBROUTINE histwrite_r1d (pfileid,pvarname,pitau,pdata,nbindex,nindex)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pitau,nbindex
-  INTEGER,DIMENSION(nbindex),INTENT(IN) :: nindex
-  REAL,DIMENSION(:),INTENT(IN) :: pdata
-  CHARACTER(LEN=*),INTENT(IN) :: pvarname
-!---------------------------------------------------------------------
-  CALL histw_rnd (pfileid,pvarname,pitau,nbindex,nindex,pdata_1d=pdata)
-!---------------------------
-END SUBROUTINE histwrite_r1d
-!===
-SUBROUTINE histwrite_r2d (pfileid,pvarname,pitau,pdata,nbindex,nindex)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pitau,nbindex
-  INTEGER,DIMENSION(nbindex),INTENT(IN) :: nindex
-  REAL,DIMENSION(:,:),INTENT(IN) :: pdata
-  CHARACTER(LEN=*),INTENT(IN) :: pvarname
-!---------------------------------------------------------------------
-  CALL histw_rnd (pfileid,pvarname,pitau,nbindex,nindex,pdata_2d=pdata)
-!---------------------------
-END SUBROUTINE histwrite_r2d
-!===
-SUBROUTINE histwrite_r3d (pfileid,pvarname,pitau,pdata,nbindex,nindex)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pitau,nbindex
-  INTEGER,DIMENSION(nbindex),INTENT(IN) :: nindex
-  REAL,DIMENSION(:,:,:),INTENT(IN) :: pdata
-  CHARACTER(LEN=*),INTENT(IN) :: pvarname
-!---------------------------------------------------------------------
-  CALL histw_rnd (pfileid,pvarname,pitau,nbindex,nindex,pdata_3d=pdata)
-!---------------------------
-END SUBROUTINE histwrite_r3d
-!===
-SUBROUTINE histw_rnd (pfileid,pvarname,pitau,nbindex,nindex, &
-  &                   pdata_1d,pdata_2d,pdata_3d)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pitau,nbindex
-  INTEGER,DIMENSION(nbindex),INTENT(IN) :: nindex
-  CHARACTER(LEN=*),INTENT(IN) :: pvarname
-  REAL,DIMENSION(:),INTENT(IN),OPTIONAL     :: pdata_1d
-  REAL,DIMENSION(:,:),INTENT(IN),OPTIONAL   :: pdata_2d
-  REAL,DIMENSION(:,:,:),INTENT(IN),OPTIONAL :: pdata_3d
-!-
-  LOGICAL :: do_oper,do_write,largebuf,l1d,l2d,l3d
-  INTEGER :: varid,io,nbpt_out
-  INTEGER              :: nbpt_in1
-  INTEGER,DIMENSION(2) :: nbpt_in2
-  INTEGER,DIMENSION(3) :: nbpt_in3
-  REAL,ALLOCATABLE,DIMENSION(:),SAVE :: buff_tmp
-  INTEGER,SAVE :: buff_tmp_sz
-  CHARACTER(LEN=7) :: tmp_opp
-  CHARACTER(LEN=13) :: c_nam
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  l1d=PRESENT(pdata_1d); l2d=PRESENT(pdata_2d); l3d=PRESENT(pdata_3d);
-  IF      (l1d) THEN
-    c_nam = 'histwrite_r1d'
-  ELSE IF (l2d) THEN
-    c_nam = 'histwrite_r2d'
-  ELSE IF (l3d) THEN
-    c_nam = 'histwrite_r3d'
-  ENDIF
-!-
-! 1.0 Try to catch errors like specifying the wrong file ID.
-!     Thanks Marine for showing us what errors users can make !
-!-
-  IF ( (pfileid < 1).OR.(pfileid > nb_files) ) THEN
-    CALL ipslerr (3,"histwrite", &
- &    'Illegal file ID in the histwrite of variable',pvarname,' ')
-  ENDIF
-!-
-! 1.1 Find the id of the variable to be written and the real time
-!-
-  CALL histvar_seq (pfileid,pvarname,varid)
-!-
-! 2.0 do nothing for never operation
-!-
-  tmp_opp = W_F(pfileid)%W_V(varid)%topp
-!-
-  IF (TRIM(tmp_opp) == "never") THEN
-    W_F(pfileid)%W_V(varid)%last_opp_chk = -99
-    W_F(pfileid)%W_V(varid)%last_wrt_chk = -99
-  ENDIF
-!-
-! 3.0 We check if we need to do an operation
-!-
-  IF (W_F(pfileid)%W_V(varid)%last_opp_chk == pitau) THEN
-    CALL ipslerr (3,"histwrite", &
- &    'This variable has already been analysed at the present', &
- &    'time step',TRIM(pvarname))
-  ENDIF
-!-
-  CALL isittime &
- &  (pitau,W_F(pfileid)%date0,W_F(pfileid)%deltat, &
- &   W_F(pfileid)%W_V(varid)%freq_opp, &
- &   W_F(pfileid)%W_V(varid)%last_opp, &
- &   W_F(pfileid)%W_V(varid)%last_opp_chk,do_oper)
-!-
-! 4.0 We check if we need to write the data
-!-
-  IF (W_F(pfileid)%W_V(varid)%last_wrt_chk == pitau) THEN
-    CALL ipslerr (3,"histwrite", &
- &    'This variable as already been written for the present', &
- &    'time step',' ')
-  ENDIF
-!-
-  CALL isittime &
- &  (pitau,W_F(pfileid)%date0,W_F(pfileid)%deltat, &
- &   W_F(pfileid)%W_V(varid)%freq_wrt, &
- &   W_F(pfileid)%W_V(varid)%last_wrt, &
- &   W_F(pfileid)%W_V(varid)%last_wrt_chk,do_write)
-!-
-! 5.0 histwrite called
-!-
-  IF (do_oper.OR.do_write) THEN
-!-
-!-- 5.1 Get the sizes of the data we will handle
-!-
-    IF (W_F(pfileid)%W_V(varid)%datasz_in(1) <= 0) THEN
-!---- There is the risk here that the user has over-sized the array.
-!---- But how can we catch this ?
-!---- In the worst case we will do impossible operations
-!---- on part of the data !
-      W_F(pfileid)%W_V(varid)%datasz_in(1:3) = -1
-      IF      (l1d) THEN
-        W_F(pfileid)%W_V(varid)%datasz_in(1) = SIZE(pdata_1d)
-      ELSE IF (l2d) THEN
-        W_F(pfileid)%W_V(varid)%datasz_in(1) = SIZE(pdata_2d,DIM=1)
-        W_F(pfileid)%W_V(varid)%datasz_in(2) = SIZE(pdata_2d,DIM=2)
-      ELSE IF (l3d) THEN
-        W_F(pfileid)%W_V(varid)%datasz_in(1) = SIZE(pdata_3d,DIM=1)
-        W_F(pfileid)%W_V(varid)%datasz_in(2) = SIZE(pdata_3d,DIM=2)
-        W_F(pfileid)%W_V(varid)%datasz_in(3) = SIZE(pdata_3d,DIM=3)
-      ENDIF
-    ENDIF
-!-
-!-- 5.2 The maximum size of the data will give the size of the buffer
-!-
-    IF (W_F(pfileid)%W_V(varid)%datasz_max <= 0) THEN
-      largebuf = .FALSE.
-      DO io=1,W_F(pfileid)%W_V(varid)%nbopp
-        IF (INDEX(fuchnbout,W_F(pfileid)%W_V(varid)%sopps(io)) > 0) THEN
-          largebuf = .TRUE.
-        ENDIF
-      ENDDO
-      IF (largebuf) THEN
-        W_F(pfileid)%W_V(varid)%datasz_max = &
- &        W_F(pfileid)%W_V(varid)%scsize(1) &
- &       *W_F(pfileid)%W_V(varid)%scsize(2) &
- &       *W_F(pfileid)%W_V(varid)%scsize(3)
-      ELSE
-        IF      (l1d) THEN
-          W_F(pfileid)%W_V(varid)%datasz_max = &
- &          W_F(pfileid)%W_V(varid)%datasz_in(1)
-        ELSE IF (l2d) THEN
-          W_F(pfileid)%W_V(varid)%datasz_max = &
- &          W_F(pfileid)%W_V(varid)%datasz_in(1) &
- &         *W_F(pfileid)%W_V(varid)%datasz_in(2)
-        ELSE IF (l3d) THEN
-          W_F(pfileid)%W_V(varid)%datasz_max = &
- &          W_F(pfileid)%W_V(varid)%datasz_in(1) &
- &         *W_F(pfileid)%W_V(varid)%datasz_in(2) &
- &         *W_F(pfileid)%W_V(varid)%datasz_in(3)
-        ENDIF
-      ENDIF
-    ENDIF
-!-
-    IF (.NOT.ALLOCATED(buff_tmp)) THEN
-      IF (l_dbg) THEN
-        WRITE(*,*) &
- &       c_nam//" : allocate buff_tmp for buff_sz = ", &
- &       W_F(pfileid)%W_V(varid)%datasz_max
-      ENDIF
-      ALLOCATE(buff_tmp(W_F(pfileid)%W_V(varid)%datasz_max))
-      buff_tmp_sz = W_F(pfileid)%W_V(varid)%datasz_max
-    ELSE IF (W_F(pfileid)%W_V(varid)%datasz_max > buff_tmp_sz) THEN
-      IF (l_dbg) THEN
-        WRITE(*,*) &
- &       c_nam//" : re-allocate buff_tmp for buff_sz = ", &
- &       W_F(pfileid)%W_V(varid)%datasz_max
-      ENDIF
-      DEALLOCATE(buff_tmp)
-      ALLOCATE(buff_tmp(W_F(pfileid)%W_V(varid)%datasz_max))
-      buff_tmp_sz = W_F(pfileid)%W_V(varid)%datasz_max
-    ENDIF
-!-
-!-- We have to do the first operation anyway.
-!-- Thus we do it here and change the ranke
-!-- of the data at the same time. This should speed up things.
-!-
-    nbpt_out = W_F(pfileid)%W_V(varid)%datasz_max
-    IF      (l1d) THEN
-      nbpt_in1 = W_F(pfileid)%W_V(varid)%datasz_in(1)
-      CALL mathop (W_F(pfileid)%W_V(varid)%sopps(1),nbpt_in1,pdata_1d, &
- &                 missing_val,nbindex,nindex, &
- &                 W_F(pfileid)%W_V(varid)%scal(1),nbpt_out,buff_tmp)
-    ELSE IF (l2d) THEN
-      nbpt_in2(1:2) = W_F(pfileid)%W_V(varid)%datasz_in(1:2)
-      CALL mathop (W_F(pfileid)%W_V(varid)%sopps(1),nbpt_in2,pdata_2d, &
- &                 missing_val,nbindex,nindex, &
- &                 W_F(pfileid)%W_V(varid)%scal(1),nbpt_out,buff_tmp)
-    ELSE IF (l3d) THEN
-      nbpt_in3(1:3) = W_F(pfileid)%W_V(varid)%datasz_in(1:3)
-      CALL mathop (W_F(pfileid)%W_V(varid)%sopps(1),nbpt_in3,pdata_3d, &
- &                 missing_val,nbindex,nindex, &
- &                 W_F(pfileid)%W_V(varid)%scal(1),nbpt_out,buff_tmp)
-    ENDIF
-    CALL histwrite_real (pfileid,varid,pitau,nbpt_out, &
- &            buff_tmp,nbindex,nindex,do_oper,do_write)
-  ENDIF
-!-
-! 6.0 Manage time steps
-!-
-  IF ((TRIM(tmp_opp) /= "once").AND.(TRIM(tmp_opp) /= "never")) THEN
-    W_F(pfileid)%W_V(varid)%last_opp_chk = pitau
-    W_F(pfileid)%W_V(varid)%last_wrt_chk = pitau
-  ELSE
-    W_F(pfileid)%W_V(varid)%last_opp_chk = -99
-    W_F(pfileid)%W_V(varid)%last_wrt_chk = -99
-  ENDIF
-!-----------------------
-END SUBROUTINE histw_rnd
-!===
-SUBROUTINE histwrite_real &
- & (pfileid,varid,pitau,nbdpt,buff_tmp,nbindex,nindex,do_oper,do_write)
-!---------------------------------------------------------------------
-!- This subroutine is internal and does the calculations and writing
-!- if needed. At a later stage it should be split into an operation
-!- and writing subroutines.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: pfileid,pitau,varid, &
- &                      nbindex,nindex(nbindex),nbdpt
-  REAL,DIMENSION(:)  :: buff_tmp
-  LOGICAL,INTENT(IN) :: do_oper,do_write
-!-
-  INTEGER :: tsz,nfid,nvid,i,iret,ipt,itax,io,nbin,nbout
-  INTEGER :: nx,ny,nz,ky,kz,kt,kc
-  INTEGER,DIMENSION(4) :: corner,edges
-  INTEGER :: itime
-!-
-  REAL :: rtime
-  CHARACTER(LEN=7) :: tmp_opp
-  REAL,ALLOCATABLE,DIMENSION(:),SAVE :: buff_tmp2,buffer_used
-  INTEGER,SAVE :: buff_tmp2_sz,buffer_sz
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) "histwrite 0.0 : VAR : ",W_F(pfileid)%W_V(varid)%v_name
-    WRITE(*,*) "histwrite 0.0 : nbindex,nindex :", &
- &  nbindex,nindex(1:MIN(3,nbindex)),'...',nindex(MAX(1,nbindex-3):nbindex)
-  ENDIF
-!-
-! The sizes which can be encoutered
-!-
-  tsz =  W_F(pfileid)%W_V(varid)%zsize(1) &
- &      *W_F(pfileid)%W_V(varid)%zsize(2) &
- &      *W_F(pfileid)%W_V(varid)%zsize(3)
-!-
-! 1.0 We allocate the memory needed to store the data between write
-!     and the temporary space needed for operations.
-!     We have to keep precedent buffer if needed
-!-
-  IF (.NOT. ALLOCATED(buffer)) THEN
-    IF (l_dbg) WRITE(*,*) "histwrite_real 1.0 allocate buffer ",buff_pos
-    ALLOCATE(buffer(buff_pos))
-    buffer_sz = buff_pos
-    buffer(:)=0.0
-  ELSE IF (buffer_sz < buff_pos) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) "histwrite_real 1.0.1 re-allocate buffer for ", &
- &      buff_pos," instead of ",SIZE(buffer)
-    ENDIF
-    IF (SUM(buffer)/=0.0) THEN
-      IF (l_dbg) WRITE (*,*) 'histwrite : buffer has been used. ', &
- &      'We have to save it before re-allocating.'
-      ALLOCATE(buffer_used(buffer_sz))
-      buffer_used(:)=buffer(:)
-      DEALLOCATE(buffer)
-      ALLOCATE(buffer(buff_pos))
-      buffer_sz = buff_pos
-      buffer(:)=0.0
-      buffer(:SIZE(buffer_used))=buffer_used
-      DEALLOCATE(buffer_used)
-    ELSE
-      IF (l_dbg) WRITE (*,*) 'histwrite : buffer has not been used. ', &
- &      'We have just to re-allocate it.'
-      DEALLOCATE(buffer)
-      ALLOCATE(buffer(buff_pos))
-      buffer_sz = buff_pos
-      buffer(:)=0.0
-    ENDIF
-  ENDIF
-!-
-! The buffers are only deallocated when more space is needed. This
-! reduces the umber of allocates but increases memory needs.
-!-
-  IF (.NOT.ALLOCATED(buff_tmp2)) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) "histwrite_real 1.1 allocate buff_tmp2 ",SIZE(buff_tmp)
-    ENDIF
-    ALLOCATE(buff_tmp2(W_F(pfileid)%W_V(varid)%datasz_max))
-    buff_tmp2_sz = W_F(pfileid)%W_V(varid)%datasz_max
-  ELSE IF (W_F(pfileid)%W_V(varid)%datasz_max > buff_tmp2_sz) THEN
-    IF (l_dbg) THEN
-      WRITE(*,*) "histwrite_real 1.2 re-allocate buff_tmp2 : ", &
-     & SIZE(buff_tmp)," instead of ",SIZE(buff_tmp2)
-    ENDIF
-    DEALLOCATE(buff_tmp2)
-    ALLOCATE(buff_tmp2(W_F(pfileid)%W_V(varid)%datasz_max))
-    buff_tmp2_sz = W_F(pfileid)%W_V(varid)%datasz_max
-  ENDIF
-!-
-  rtime = pitau*W_F(pfileid)%deltat
-  tmp_opp = W_F(pfileid)%W_V(varid)%topp
-!-
-! 3.0 Do the operations or transfer the slab of data into buff_tmp
-!-
-  IF (l_dbg) WRITE(*,*) "histwrite: 3.0",pfileid
-!-
-! 3.1 DO the Operations only if needed
-!-
-  IF (do_oper) THEN
-    i = pfileid
-    nbout = nbdpt
-!-
-!-- 3.4 We continue the sequence of operations
-!--     we started in the interface routine
-!-
-    DO io=2,W_F(i)%W_V(varid)%nbopp,2
-      nbin = nbout
-      nbout = W_F(i)%W_V(varid)%datasz_max
-      CALL mathop(W_F(i)%W_V(varid)%sopps(io),nbin,buff_tmp, &
- &      missing_val,nbindex,nindex,W_F(i)%W_V(varid)%scal(io), &
- &      nbout,buff_tmp2)
-      IF (l_dbg) THEN
-        WRITE(*,*) &
- &       "histwrite: 3.4a nbout : ",nbin,nbout,W_F(i)%W_V(varid)%sopps(io)
-      ENDIF
-!-
-      nbin = nbout
-      nbout = W_F(i)%W_V(varid)%datasz_max
-      CALL mathop(W_F(i)%W_V(varid)%sopps(io+1),nbin,buff_tmp2, &
- &      missing_val,nbindex,nindex,W_F(i)%W_V(varid)%scal(io+1), &
- &      nbout,buff_tmp)
-      IF (l_dbg) THEN
-        WRITE(*,*) &
- &     "histwrite: 3.4b nbout : ",nbin,nbout,W_F(i)%W_V(varid)%sopps(io+1)
-      ENDIF
-    ENDDO
-!-
-!   3.5 Zoom into the data
-!-
-    IF (l_dbg) THEN
-      WRITE(*,*) &
- &     "histwrite: 3.5 size(buff_tmp) : ",SIZE(buff_tmp)
-      WRITE(*,*) &
- &     "histwrite: 3.5 slab in X :", &
- &     W_F(i)%W_V(varid)%zorig(1),W_F(i)%W_V(varid)%zsize(1)
-      WRITE(*,*) &
- &     "histwrite: 3.5 slab in Y :", &
- &     W_F(i)%W_V(varid)%zorig(2),W_F(i)%W_V(varid)%zsize(2)
-      WRITE(*,*) &
- &     "histwrite: 3.5 slab in Z :", &
- &     W_F(i)%W_V(varid)%zorig(3),W_F(i)%W_V(varid)%zsize(3)
-      WRITE(*,*) &
- &     "histwrite: 3.5 slab of input:", &
- &     W_F(i)%W_V(varid)%scsize(1), &
- &     W_F(i)%W_V(varid)%scsize(2), &
- &     W_F(i)%W_V(varid)%scsize(3)
-    ENDIF
-!---
-!-- We have to consider blocks of contiguous data
-!---
-    nx=MAX(W_F(i)%W_V(varid)%zsize(1),1)
-    ny=MAX(W_F(i)%W_V(varid)%zsize(2),1)
-    nz=MAX(W_F(i)%W_V(varid)%zsize(3),1)
-    IF     (     (W_F(i)%W_V(varid)%zorig(1) == 1) &
- &          .AND.(   W_F(i)%W_V(varid)%zsize(1) &
- &                == W_F(i)%W_V(varid)%scsize(1)) &
- &          .AND.(W_F(i)%W_V(varid)%zorig(2) == 1) &
- &          .AND.(   W_F(i)%W_V(varid)%zsize(2) &
- &                == W_F(i)%W_V(varid)%scsize(2))) THEN
-      kt = (W_F(i)%W_V(varid)%zorig(3)-1)*nx*ny
-      buff_tmp2(1:nx*ny*nz) = buff_tmp(kt+1:kt+nx*ny*nz)
-    ELSEIF (     (W_F(i)%W_V(varid)%zorig(1) == 1) &
- &          .AND.(   W_F(i)%W_V(varid)%zsize(1) &
- &                == W_F(i)%W_V(varid)%scsize(1))) THEN
-      kc = -nx*ny
-      DO kz=W_F(i)%W_V(varid)%zorig(3),W_F(i)%W_V(varid)%zorig(3)+nz-1
-        kc = kc+nx*ny
-        kt = ( (kz-1)*W_F(i)%W_V(varid)%scsize(2) &
- &            +W_F(i)%W_V(varid)%zorig(2)-1)*nx
-        buff_tmp2(kc+1:kc+nx*ny) = buff_tmp(kt+1:kt+nx*ny)
-      ENDDO
-    ELSE
-      kc = -nx
-      DO kz=W_F(i)%W_V(varid)%zorig(3),W_F(i)%W_V(varid)%zorig(3)+nz-1
-        DO ky=W_F(i)%W_V(varid)%zorig(2),W_F(i)%W_V(varid)%zorig(2)+ny-1
-          kc = kc+nx
-          kt = ((kz-1)*W_F(i)%W_V(varid)%scsize(2)+ky-1) &
- &            *W_F(i)%W_V(varid)%scsize(1) &
- &            +W_F(i)%W_V(varid)%zorig(1)-1
-          buff_tmp2(kc+1:kc+nx) = buff_tmp(kt+1:kt+nx)
-        ENDDO
-      ENDDO
-    ENDIF
-!-
-!-- 4.0 Get the min and max of the field (buff_tmp)
-!-
-    IF (l_dbg) WRITE(*,*) "histwrite: 4.0 buff_tmp",pfileid,varid, &
- &    TRIM(tmp_opp),' ---- ',LEN_TRIM(tmp_opp),nbindex
-!-
-    IF (W_F(pfileid)%W_V(varid)%hist_calc_rng) THEN
-      W_F(pfileid)%W_V(varid)%hist_minmax(1) = &
- &      MIN(W_F(pfileid)%W_V(varid)%hist_minmax(1), &
- &      MINVAL(buff_tmp2(1:tsz),MASK=buff_tmp2(1:tsz) /= missing_val))
-      W_F(pfileid)%W_V(varid)%hist_minmax(2) = &
- &      MAX(W_F(pfileid)%W_V(varid)%hist_minmax(2), &
- &      MAXVAL(buff_tmp2(1:tsz),MASK=buff_tmp2(1:tsz) /= missing_val))
-    ENDIF
-!-
-!-- 5.0 Do the operations if needed. In the case of instantaneous
-!--     output we do not transfer to the buffer.
-!-
-    IF (l_dbg) WRITE(*,*) "histwrite: 5.0",pfileid,"tsz :",tsz
-!-
-    ipt = W_F(pfileid)%W_V(varid)%point
-!-
-!   WRITE(*,*) 'OPE ipt, buffer :',pvarname,ipt,varid
-!-
-    IF (     (TRIM(tmp_opp) /= "inst") &
- &      .AND.(TRIM(tmp_opp) /= "once") ) THEN
-      CALL moycum(tmp_opp,tsz,buffer(ipt:), &
- &           buff_tmp2,W_F(pfileid)%W_V(varid)%nb_opp)
-    ENDIF
-!-
-    W_F(pfileid)%W_V(varid)%last_opp = pitau
-    W_F(pfileid)%W_V(varid)%nb_opp = W_F(pfileid)%W_V(varid)%nb_opp+1
-!-
-  ENDIF
-!-
-! 6.0 Write to file if needed
-!-
-  IF (l_dbg) WRITE(*,*) "histwrite: 6.0",pfileid
-!-
-  IF (do_write) THEN
-!-
-    nfid = W_F(pfileid)%ncfid
-    nvid = W_F(pfileid)%W_V(varid)%ncvid
-!-
-!-- 6.1 Do the operations that are needed before writting
-!-
-    IF (l_dbg) WRITE(*,*) "histwrite: 6.1",pfileid
-!-
-    IF (     (TRIM(tmp_opp) /= "inst") &
- &      .AND.(TRIM(tmp_opp) /= "once") ) THEN
-      rtime = ( rtime &
- &             +W_F(pfileid)%W_V(varid)%last_wrt*W_F(pfileid)%deltat)/2.0
-    ENDIF
-!-
-!-- 6.2 Add a value to the time axis of this variable if needed
-!-
-    IF (     (TRIM(tmp_opp) /= "l_max") &
- &      .AND.(TRIM(tmp_opp) /= "l_min") &
- &      .AND.(TRIM(tmp_opp) /= "once") ) THEN
-!-
-      IF (l_dbg) WRITE(*,*) "histwrite: 6.2",pfileid
-!-
-      itax = W_F(pfileid)%W_V(varid)%t_axid
-      itime = W_F(pfileid)%W_V(varid)%nb_wrt+1
-!-
-      IF (W_F(pfileid)%W_V(itax)%tax_last < itime) THEN
-        iret = NF90_PUT_VAR (nfid,W_F(pfileid)%W_V(itax)%tdimid, &
- &               (/ rtime /),start=(/ itime /),count=(/ 1 /))
-        W_F(pfileid)%W_V(itax)%tax_last = itime
-      ENDIF
-    ELSE
-      itime=1
-    ENDIF
-!-
-!-- 6.3 Write the data. Only in the case of instantaneous output
-!       we do not write the buffer.
-!-
-    IF (l_dbg) THEN
-      WRITE(*,*) "histwrite: 6.3",pfileid,nfid,nvid,varid,itime
-    ENDIF
-!-
-    IF (W_F(pfileid)%W_V(varid)%scsize(3) == 1) THEN
-      IF (W_F(pfileid)%regular) THEN
-        corner(1:4) = (/ 1,1,itime,0 /)
-        edges(1:4) = (/ W_F(pfileid)%W_V(varid)%zsize(1), &
- &                      W_F(pfileid)%W_V(varid)%zsize(2),1,0 /)
-      ELSE
-        corner(1:4) = (/ 1,itime,0,0 /)
-        edges(1:4) = (/ W_F(pfileid)%W_V(varid)%zsize(1),1,0,0 /)
-      ENDIF
-    ELSE
-      IF (W_F(pfileid)%regular) THEN
-        corner(1:4) = (/ 1,1,1,itime /)
-        edges(1:4) = (/ W_F(pfileid)%W_V(varid)%zsize(1), &
- &                      W_F(pfileid)%W_V(varid)%zsize(2), &
- &                      W_F(pfileid)%W_V(varid)%zsize(3),1 /)
-      ELSE
-        corner(1:4) = (/ 1,1,itime,0 /)
-        edges(1:4) = (/ W_F(pfileid)%W_V(varid)%zsize(1), &
- &                      W_F(pfileid)%W_V(varid)%zsize(3),1,0 /)
-      ENDIF
-    ENDIF
-!-
-    ipt = W_F(pfileid)%W_V(varid)%point
-!-
-    IF (     (TRIM(tmp_opp) /= "inst") &
- &      .AND.(TRIM(tmp_opp) /= "once") ) THEN
-      iret = NF90_PUT_VAR (nfid,nvid,buffer(ipt:), &
- &                       start=corner(1:4),count=edges(1:4))
-    ELSE
-      iret = NF90_PUT_VAR (nfid,nvid,buff_tmp2, &
- &                       start=corner(1:4),count=edges(1:4))
-    ENDIF
-!-
-    W_F(pfileid)%W_V(varid)%last_wrt = pitau
-    W_F(pfileid)%W_V(varid)%nb_wrt = W_F(pfileid)%W_V(varid)%nb_wrt+1
-    W_F(pfileid)%W_V(varid)%nb_opp = 0
-!---
-!   After the write the file can be synchronized so that no data is
-!   lost in case of a crash. This feature gives up on the benefits of
-!   buffering and should only be used in debuging mode. A flag is
-!   needed here to switch to this mode.
-!---
-!   iret = NF90_SYNC (nfid)
-!-
-  ENDIF
-!----------------------------
-END SUBROUTINE histwrite_real
-!===
-SUBROUTINE histvar_seq (pfid,pvarname,pvid)
-!---------------------------------------------------------------------
-!- This subroutine optimized the search for the variable in the table.
-!- In a first phase it will learn the succession of the variables
-!- called and then it will use the table to guess what comes next.
-!- It is the best solution to avoid lengthy searches through array
-!- vectors.
-!-
-!- ARGUMENTS :
-!-
-!- pfid  : id of the file on which we work
-!- pvarname : The name of the variable we are looking for
-!- pvid     : The var id we found
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(in)  :: pfid
-  CHARACTER(LEN=*),INTENT(IN) :: pvarname
-  INTEGER,INTENT(out) :: pvid
-!-
-  LOGICAL,SAVE :: learning(nb_files_max)=.TRUE.
-  INTEGER,SAVE :: overlap(nb_files_max) = -1
-  INTEGER,SAVE :: varseq(nb_files_max,nb_var_max*3)
-  INTEGER,SAVE :: varseq_len(nb_files_max) = 0
-  INTEGER,SAVE :: varseq_pos(nb_files_max)
-  INTEGER,SAVE :: varseq_err(nb_files_max) = 0
-  INTEGER      :: ib,sp,nn,pos
-  CHARACTER(LEN=70) :: str70
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'histvar_seq, start of the subroutine :',learning(pfid)
-  ENDIF
-!-
-  IF (learning(pfid)) THEN
-!-
-!-- 1.0 We compute the length over which we are going
-!--     to check the overlap
-!-
-    IF (overlap(pfid) <= 0) THEN
-      IF (W_F(pfid)%n_var > 6) THEN
-        overlap(pfid) = W_F(pfid)%n_var/3*2
-      ELSE
-        overlap(pfid) = W_F(pfid)%n_var
-      ENDIF
-    ENDIF
-!-
-!-- 1.1 Find the position of this string
-!-
-    CALL find_str (W_F(pfid)%W_V(1:W_F(pfid)%n_var)%v_name,pvarname,pos)
-    IF (pos > 0) THEN
-      pvid = pos
-    ELSE
-      CALL ipslerr (3,"histvar_seq", &
- &      'The name of the variable you gave has not been declared', &
- &      'You should use subroutine histdef for declaring variable', &
- &      TRIM(pvarname))
-    ENDIF
-!-
-!-- 1.2 If we have not given up we store the position
-!--     in the sequence of calls
-!-
-    IF (varseq_err(pfid) >= 0) THEN
-      sp = varseq_len(pfid)+1
-      IF (sp <= nb_var_max*3) THEN
-        varseq(pfid,sp) = pvid
-        varseq_len(pfid) = sp
-      ELSE
-        CALL ipslerr (2,"histvar_seq",&
- &       'The learning process has failed and we give up. '// &
- &       'Either you sequence is',&
- &       'too complex or I am too dumb. '// &
- &       'This will only affect the efficiency',&
- &       'of your code. Thus if you wish to save time'// &
- &       ' contact the IOIPSL team. ')
-        WRITE(*,*) 'The sequence we have found up to now :'
-        WRITE(*,*) varseq(pfid,1:sp-1)
-        varseq_err(pfid) = -1
-      ENDIF
-!-
-!---- 1.3 Check if we have found the right overlap
-!-
-      IF (varseq_len(pfid) >= overlap(pfid)*2) THEN
-!-
-!------ We skip a few variables if needed as they could come
-!------ from the initialisation of the model.
-!-
-        DO ib = 0,sp-overlap(pfid)*2
-          IF ( learning(pfid) .AND.&
-            & SUM(ABS(varseq(pfid,ib+1:ib+overlap(pfid)) -&
-            & varseq(pfid,sp-overlap(pfid)+1:sp))) == 0 ) THEN
-            learning(pfid) = .FALSE.
-            varseq_len(pfid) = sp-overlap(pfid)-ib
-            varseq_pos(pfid) = overlap(pfid)+ib
-            varseq(pfid,1:varseq_len(pfid)) = &
- &            varseq(pfid,ib+1:ib+varseq_len(pfid))
-          ENDIF
-        ENDDO
-      ENDIF
-    ENDIF
-  ELSE
-!-
-!-- 2.0 Now we know how the calls to histwrite are sequenced
-!--     and we can get a guess at the var ID
-!-
-    nn = varseq_pos(pfid)+1
-    IF (nn > varseq_len(pfid)) nn = 1
-!-
-    pvid = varseq(pfid,nn)
-!-
-    IF (TRIM(W_F(pfid)%W_V(pvid)%v_name) /= TRIM(pvarname)) THEN
-      CALL find_str (W_F(pfid)%W_V(1:W_F(pfid)%n_var)%v_name,pvarname,pos)
-      IF (pos > 0) THEN
-        pvid = pos
-      ELSE
-        CALL ipslerr (3,"histvar_seq", &
- &  'The name of the variable you gave has not been declared',&
- &  'You should use subroutine histdef for declaring variable', &
- &  TRIM(pvarname))
-      ENDIF
-      varseq_err(pfid) = varseq_err(pfid)+1
-    ELSE
-!-
-!---- We only keep the new position if we have found the variable
-!---- this way. This way an out of sequence call to histwrite does
-!---- not defeat the process.
-!-
-      varseq_pos(pfid) = nn
-    ENDIF
-!-
-    IF (varseq_err(pfid) >= 10) THEN
-      WRITE(str70,'("for file ",I3)') pfid
-      CALL ipslerr (2,"histvar_seq", &
- &  'There were 10 errors in the learned sequence of variables',&
- &  str70,'This looks like a bug, please report it.')
-         varseq_err(pfid) = 0
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) &
- &   'histvar_seq, end of the subroutine :',TRIM(pvarname),pvid
-  ENDIF
-!-------------------------
-END SUBROUTINE histvar_seq
-!===
-SUBROUTINE histsync (file)
-!---------------------------------------------------------------------
-!- This subroutine will synchronise all
-!- (or one if defined) opened files.
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! file  : optional argument for fileid
-  INTEGER,INTENT(in),OPTIONAL :: file
-!-
-  INTEGER :: ifile,nfid,iret
-!-
-  LOGICAL :: file_exists
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) WRITE(*,*) 'Entering loop on files : ',nb_files
-!-
-! 1.The loop on files to synchronise
-!-
-  DO ifile=1,nb_files
-!-
-    IF (PRESENT(file)) THEN
-      file_exists = (ifile == file)
-    ELSE
-      file_exists = .TRUE.
-    ENDIF
-!-
-    IF (file_exists) THEN
-      IF (l_dbg) THEN
-        WRITE(*,*) 'Synchronising specified file number :',file
-      ENDIF
-      nfid = W_F(ifile)%ncfid
-      iret = NF90_SYNC (nfid)
-    ENDIF
-!-
-  ENDDO
-!----------------------
-END SUBROUTINE histsync
-!===
-SUBROUTINE histclo (fid)
-!---------------------------------------------------------------------
-!- This subroutine will close all (or one if defined) opened files
-!-
-!- VERSION
-!-
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-! fid  : optional argument for fileid
-  INTEGER,INTENT(in),OPTIONAL :: fid
-!-
-  INTEGER :: ifile,nfid,nvid,iret,iv
-  INTEGER :: start_loop,end_loop
-  CHARACTER(LEN=70) :: str70
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) WRITE(*,*) 'Entering loop on files :',nb_files
-!-
-  IF (PRESENT(fid)) THEN
-    start_loop = fid
-    end_loop = fid
-  ELSE
-    start_loop = 1
-    end_loop = nb_files
-  ENDIF
-!-
-  DO ifile=start_loop,end_loop
-    IF (l_dbg) WRITE(*,*) 'Closing specified file number :',ifile
-    nfid = W_F(ifile)%ncfid
-    iret = NF90_REDEF (nfid)
-!---
-!-- 1. Loop on the number of variables to add some final information
-!---
-    IF (l_dbg) WRITE(*,*) 'Entering loop on vars : ',W_F(ifile)%n_var
-    DO iv=1,W_F(ifile)%n_var
-      IF (W_F(ifile)%W_V(iv)%hist_wrt_rng) THEN
-        IF (l_dbg) THEN
-          WRITE(*,*) 'min value for file :',ifile,' var n. :',iv, &
-         &           ' is : ',W_F(ifile)%W_V(iv)%hist_minmax(1)
-          WRITE(*,*) 'max value for file :',ifile,' var n. :',iv, &
-         &           ' is : ',W_F(ifile)%W_V(iv)%hist_minmax(2)
-        ENDIF
-        IF (W_F(ifile)%W_V(iv)%hist_calc_rng) THEN
-!-------- Put the min and max values on the file
-          nvid = W_F(ifile)%W_V(iv)%ncvid
-          iret = NF90_PUT_ATT (nfid,nvid,'valid_min', &
- &                 REAL(W_F(ifile)%W_V(iv)%hist_minmax(1),KIND=4))
-          iret = NF90_PUT_ATT (nfid,nvid,'valid_max', &
- &                 REAL(W_F(ifile)%W_V(iv)%hist_minmax(2),KIND=4))
-        ENDIF
-      ENDIF
-    ENDDO
-!---
-!-- 2. Close the file
-!---
-    IF (l_dbg) WRITE(*,*) 'close file :',nfid
-    iret = NF90_CLOSE (nfid)
-    IF (iret /= NF90_NOERR) THEN
-      WRITE(str70,'("This file has been already closed :",I3)') ifile
-      CALL ipslerr (2,'histclo',str70,'','')
-    ENDIF
-  ENDDO
-!---------------------
-END SUBROUTINE histclo
-!===
-SUBROUTINE ioconf_modname (str)
-!---------------------------------------------------------------------
-!- This subroutine allows to configure the name
-!- of the model written into the file
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(IN) :: str
-!---------------------------------------------------------------------
-  IF (.NOT.lock_modname) THEN
-    model_name = str(1:MIN(LEN_TRIM(str),80))
-    lock_modname = .TRUE.
-  ELSE
-    CALL ipslerr (2,"ioconf_modname", &
-   &  'The model name can only be changed once and only', &
-   &  'before it is used. It is now set to :',model_name)
-  ENDIF
-!----------------------------
-END SUBROUTINE ioconf_modname
-!-
-!===
-!-
-!-----------------
-END MODULE histcom
Index: /codes/icosagcm/trunk/tools/ioipsl/ioipsl.f90
===================================================================
--- /codes/icosagcm/trunk/tools/ioipsl/ioipsl.f90	(revision 487)
+++ /codes/icosagcm/trunk/tools/ioipsl/ioipsl.f90	(revision 488)
@@ -8,10 +8,10 @@
   USE errioipsl 
   USE stringop
-  USE mathelp    
+ ! USE mathelp    
   USE getincom
-  USE calendar   
-  USE fliocom    
-  USE flincom    
-  USE histcom    
-  USE restcom
+!  USE calendar   
+!  USE fliocom    
+!  USE flincom    
+!  USE histcom    
+!  USE restcom
 END MODULE ioipsl
Index: des/icosagcm/trunk/tools/ioipsl/restcom.f90
===================================================================
--- /codes/icosagcm/trunk/tools/ioipsl/restcom.f90	(revision 487)
+++ 	(revision )
@@ -1,2546 +1,0 @@
-MODULE restcom
-!-
-!$Id: restcom.f90 430 2008-10-23 14:33:11Z bellier $
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!-
-USE netcdf
-!-
-USE errioipsl, ONLY : ipslerr,ipsldbg
-USE stringop
-USE calendar
-USE mathelp
-USE fliocom,   ONLY : flio_dom_file,flio_dom_att
-!-
-IMPLICIT NONE
-!-
-PRIVATE
-!-
-PUBLIC :: &
- &  restini, restget, restput, restclo, &
- &  ioconf_setatt, ioget_vname, ioconf_expval, &
- &  ioget_expval, ioget_vdim
-!-
-INTERFACE restput
-  MODULE PROCEDURE &
- &  restput_r3d, restput_r2d, restput_r1d, &
- &  restput_opp_r2d, restput_opp_r1d
-END INTERFACE
-!-
-INTERFACE restget
-  MODULE PROCEDURE &
- &  restget_r3d,restget_r2d,restget_r1d, &
- &  restget_opp_r2d,restget_opp_r1d
-END INTERFACE
-!-
-! We do not use allocatable arrays because these sizes are safe
-! and we do not know from start how many variables will be in
-! the out file.
-!-
-  INTEGER,PARAMETER :: &
- &  max_var=500, max_file=50, max_dim=NF90_MAX_VAR_DIMS
-!-
-  CHARACTER(LEN=9),SAVE :: calend_str='unknown'
-!-
-! The IDs of the netCDF files are going in pairs.
-! The input one (netcdf_id(?,1)) and the output one (netcdf_id(?,2))
-!-
-  INTEGER,SAVE :: nb_fi = 0
-  INTEGER,DIMENSION(max_file,2),SAVE :: netcdf_id = -1
-!-
-! Description of the content of the 'in' files and the 'out' files.
-!   Number of variables   : nbvar_*
-!   Number of dimensions  : nbdim_*
-!   ID of the time axis   : tdimid_*
-!-
-  INTEGER,SAVE :: nbvar_in(max_file), nbvar_out(max_file)
-  INTEGER,SAVE :: tdimid_in(max_file), tdimid_out(max_file)
-!-
-! Variables for one or the other file
-!-
-! Number of dimensions in the input file               : nbdim_in
-! Number of variables read so far from the input file  : nbvar_read
-! Type of variable read from the input file            : vartyp_in
-!   (Could be used later to test if we have a restart file)
-!-
-  INTEGER,SAVE :: nbdim_in(max_file), nbvar_read(max_file)
-  INTEGER,SAVE :: vartyp_in(max_file, max_var)
-!-
-! Time step and time origine in the input file.
-!-
-  REAL,DIMENSION(max_file),SAVE :: deltat,timeorig
-!-
-! Description of the axes in the output file
-!-
-!   tstp_out  : Index on the tie axis currently beeing written
-!   itau_out  : Time step which is written on this index of the file
-!-
-  INTEGER,DIMENSION(max_file),SAVE :: tstp_out,itau_out
-!-
-! Description of the axes in the output file
-!-
-! For the ?ax_infs variable the following order is used :
-!   ?ax_infs (if,in,1) = size of axis
-!   ?ax_infs (if,in,2) = id of dimension
-! Number of x,y and z axes in the output file :
-!   ?ax_nb(if)
-!-
-  INTEGER,DIMENSION(max_file,max_dim,2),SAVE :: &
- &  xax_infs,yax_infs,zax_infs
-  INTEGER,DIMENSION(max_file),SAVE :: &
- &  xax_nb=0,yax_nb=0,zax_nb=0
-!-
-! Description of the time axes in the input and output files
-!-
-!   ID of the variable which contains the itaus :
-!     tind_varid_*
-!   ID of the variables which contains the seconds since date :
-!     tax_varid_*
-!   Size of the time axis in the input file :
-!     tax_size_in
-!-
-  INTEGER,SAVE :: tind_varid_in(max_file),  tax_varid_in(max_file), &
- &                tind_varid_out(max_file), tax_varid_out(max_file)
-  INTEGER,SAVE :: tax_size_in(max_file)=1
-!-
-! The two time axes we have in the input file :
-!   t_index   : dates in itaus
-!               (thus the variable has a tstep_sec attribute)
-!   t_julian  : Julian days of the time axis
-!-
-  INTEGER,SAVE,ALLOCATABLE :: t_index(:,:)
-  REAL,SAVE,ALLOCATABLE :: t_julian(:,:)
-!-
-! Here we save a number of informations on the variables
-! in the files we are handling
-!-
-! Name of variables :                                    varname_*
-! ID of the variables :                                  varid_*
-! Number of dimensions of the variable :                 varnbdim_*
-! Dimensions which are used for the variable :           vardims_*
-! Number of attributes for a variables :                 varatt_*
-! A flag which markes the variables we have worked on :  touched_*
-!-
-  CHARACTER(LEN=20),DIMENSION(max_file,max_var),SAVE :: &
- &  varname_in,varname_out
-  INTEGER,DIMENSION(max_file,max_var),SAVE :: &
- &  varid_in,varid_out,varnbdim_in,varatt_in
-  INTEGER,DIMENSION(max_file,max_var,max_dim),SAVE :: &
- &  vardims_in
-  LOGICAL,DIMENSION(max_file,max_var),SAVE :: &
- &  touched_in,touched_out
-!-
-  CHARACTER(LEN=120),SAVE :: indchfun= 'scatter, fill, gather, coll'
-  REAL,PARAMETER :: missing_val=1.e20
-!                or HUGE(1.0) (maximum real number)
-!-
-! The default value we will use for variables
-! which are not present in the restart file
-!-
-  REAL,SAVE :: val_exp =  999999.
-  LOGICAL,SAVE :: lock_valexp = .FALSE.
-!-
-! Temporary variables in which we store the attributed which are going
-! to be given to a new variable which is going to be defined.
-!-
-  CHARACTER(LEN=80),SAVE :: rest_units='XXXXX',rest_lname='XXXXX'
-!-
-! For allocations
-!-
-  REAL,ALLOCATABLE,DIMENSION(:),SAVE :: buff_tmp1,buff_tmp2
-!-
-!===
-CONTAINS
-!===
-!-
-SUBROUTINE restini &
- & (fnamein,iim,jjm,lon,lat,llm,lev, &
- &  fnameout,itau,date0,dt,fid,owrite_time_in,domain_id)
-!---------------------------------------------------------------------
-!- This subroutine sets up all the restart process.
-!- It will call the subroutine which opens the input
-!- and output files.
-!- The time step (itau), date of origine (date0) and time step are
-!- READ from the input file.
-!- A file ID, which is common to the input and output file is returned
-!-
-!- If fnamein = fnameout then the same file is used for the reading
-!- the restart conditions and writing the new restart.
-!-
-!- A special mode can be switched in with filename='NONE'.
-!- This means that no restart file is present.
-!- Usefull for creating the first restart file
-!- or to get elements in a file without creating an output file.
-!-
-!- A mode needs to be written in which itau, date0 and dt
-!- are given to the restart process and thus
-!- written into the output restart file.
-!-
-!- INPUT
-!-
-!- fnamein  : name of the file for the restart
-!- iim      : Dimension in x
-!- jjm      : Dimension in y
-!- lon      : Longitude in the x,y domain
-!- lat      : Latitude in the x,y domain
-!- llm      : Dimension in the vertical
-!- lev      : Positions of the levels
-!- fnameout :
-!-
-!- OUTPUT
-!-
-!- itau     : Time step of the restart file and at which the model
-!-            should restart
-!- date0    : Time at which itau = 0
-!- dt       : time step in seconds between two succesiv itaus
-!- fid      : File identification of the restart file
-!-
-!- Optional INPUT arguments
-!-
-!- owrite_time_in : logical  argument which allows to
-!-                  overwrite the time in the restart file
-!- domain_id      : Domain identifier
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*),INTENT(IN) :: fnamein,fnameout
-  INTEGER :: iim,jjm,llm,fid,itau
-  REAL :: lon(iim,jjm),lat(iim,jjm),lev(llm)
-  REAL :: date0,dt
-  LOGICAL,OPTIONAL :: owrite_time_in
-  INTEGER,INTENT(IN),OPTIONAL :: domain_id
-!-
-  INTEGER :: ncfid
-  REAL :: dt_tmp,date0_tmp
-  LOGICAL :: l_fi,l_fo,l_rw
-  LOGICAL :: overwrite_time
-  CHARACTER(LEN=120) :: fname
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 0.0 Prepare the configuration before opening any files
-!-
-  IF (.NOT.PRESENT(owrite_time_in)) THEN
-    overwrite_time = .FALSE.
-  ELSE
-    overwrite_time = owrite_time_in
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'restini 0.0 : ',TRIM(fnamein),' , ',TRIM(fnameout)
-  ENDIF
-!-
-  nb_fi = nb_fi+1
-!-
-  IF (nb_fi > max_file) THEN
-    CALL ipslerr (3,'restini',&
- &   'Too many restart files are used. The problem can be',&
- &   'solved by increasing max_file in restcom.f90 ',&
- &   'and recompiling ioipsl.')
-  ENDIF
-!-
-! 0.1 Define the open flags
-!-
-  l_fi = (TRIM(fnamein)  /= 'NONE')
-  l_fo = (TRIM(fnameout) /= 'NONE')
-  IF ((.NOT.l_fi).AND.(.NOT.l_fo)) THEN
-    CALL ipslerr (3,'restini',&
- &   'Input and output file names are both to NONE.',&
- &   'It is probably an error.','Verify your logic.')
-  ENDIF
-  l_rw = l_fi.AND.l_fo.AND.(TRIM(fnamein) == TRIM(fnameout))
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'restini 0.1 l_fi, l_fo, l_rw : ',l_fi,l_fo,l_rw
-  ENDIF
-!-
-! 1.0 Open the input file.
-!-
-  IF (l_fi) THEN
-!---
-    IF (l_dbg) WRITE(*,*) 'restini 1.0 : Open input file'
-!-- Add DOMAIN number and ".nc" suffix in file names if needed
-    fname = fnamein
-    CALL flio_dom_file (fname,domain_id)
-!-- Open the file
-    CALL restopenin (nb_fi,fname,l_rw,iim,jjm,lon,lat,llm,lev,ncfid)
-    netcdf_id(nb_fi,1) = ncfid
-!---
-!-- 1.3 Extract the time information
-!---
-    IF (overwrite_time) THEN
-       date0_tmp = date0
-    ENDIF
-    CALL restsett (dt_tmp,date0_tmp,itau,overwrite_time)
-    IF (.NOT.overwrite_time) THEN
-      dt = dt_tmp
-      date0 = date0_tmp
-    ENDIF
-!---
-  ELSE
-!---
-!-- 2.0 The case of a missing restart file is dealt with
-!---
-    IF (l_dbg) WRITE(*,*) 'restini 2.0'
-!---
-    IF (     (ALL(MINLOC(lon(:iim,:jjm)) == MAXLOC(lon(:iim,:jjm)))) &
-        .AND.(iim > 1) ) THEN
-      CALL ipslerr (3,'restini',&
-        & 'For creating a restart file the longitudes of the',&
-        & 'grid need to be provided to restini. This ',&
-        & 'information is needed for the restart files')
-    ENDIF
-    IF (     (ALL(MINLOC(lat(:iim,:jjm)) == MAXLOC(lat(:iim,:jjm)))) &
-        .AND.(jjm > 1) ) THEN
-      CALL ipslerr (3,'restini',&
-        & 'For creating a restart file the latitudes of the',&
-        & 'grid need to be provided to restini. This ',&
-        & 'information is needed for the restart files')
-    ENDIF
-    IF (     (ALL(MINLOC(lev(:llm)) == MAXLOC(lev(:llm)))) &
-        .AND.(llm > 1) ) THEN
-      CALL ipslerr (3,'restini',&
-        & 'For creating a restart file the levels of the',&
-        & 'grid need to be provided to restini. This',&
-        & 'information is needed for the restart files')
-    ENDIF
-!---
-!-- 2.2 Allocate the time axes and write the inputed variables
-!---
-    tax_size_in(nb_fi) = 1
-    CALL rest_atim (l_dbg,'restini')
-    t_index(nb_fi,1) = itau
-    t_julian(nb_fi,1) = date0
-  ENDIF
-!-
-  IF (l_fo.AND.(.NOT.l_rw)) THEN
-!-- Add DOMAIN number and ".nc" suffix in file names if needed
-    fname = fnameout
-    CALL flio_dom_file (fname,domain_id)
-!-- Open the file
-    CALL restopenout &
-      (nb_fi,fname,iim,jjm,lon,lat,llm,lev,dt,date0,ncfid,domain_id)
-    netcdf_id(nb_fi,2) = ncfid
-  ELSE IF (l_fi.AND.l_fo) THEN
-    netcdf_id(nb_fi,2) = netcdf_id(nb_fi,1)
-    varname_out(nb_fi,:) = varname_in(nb_fi,:)
-    nbvar_out(nb_fi) = nbvar_in(nb_fi)
-    tind_varid_out(nb_fi) = tind_varid_in(nb_fi)
-    tax_varid_out(nb_fi) = tax_varid_in(nb_fi)
-    varid_out(nb_fi,:) = varid_in(nb_fi,:)
-    touched_out(nb_fi,:) = .TRUE.
-  ENDIF
-!-
-! 2.3 Set the calendar for the run.
-!     This should not produce any error message if
-!     This does not mean any change in calendar
-!     (to be modified in ioconf_calendar)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'restini 2.3 : Configure calendar if needed : ', &
-                calend_str
-  ENDIF
-!-
-  IF (INDEX(calend_str,'unknown') < 1) THEN
-    CALL ioconf_calendar (calend_str)
-    IF (l_dbg) THEN
-      WRITE(*,*) 'restini 2.3b : new calendar : ',calend_str
-    ENDIF
-  ENDIF
-!-
-! Save some data in the module
-!-
-  deltat(nb_fi) = dt
-!-
-! Prepare the variables which will be returned
-!-
-  fid = nb_fi
-  IF (l_dbg) THEN
-    WRITE(*,*) 'SIZE of t_index :',SIZE(t_index), &
-               SIZE(t_index,dim=1),SIZE(t_index,dim=2)
-    WRITE(*,*) 't_index = ',t_index(fid,:)
-  ENDIF
-  itau = t_index(fid,1)
-!-
-  IF (l_dbg) WRITE(*,*) 'restini END'
-!---------------------
-END SUBROUTINE restini
-!===
-SUBROUTINE restopenin &
-  (fid,fname,l_rw,iim,jjm,lon,lat,llm,lev,ncfid)
-!---------------------------------------------------------------------
-!- Opens the restart file and checks that it belongsd to the model.
-!- This means that the coordinates of the model are compared to the
-!- ones in the file.
-!-
-!- The number and name of variable in the file are exctracted. Also
-!- the time details.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: fid,iim,jjm,llm
-  CHARACTER(LEN=*),INTENT(IN) :: fname
-  REAL :: lon(iim,jjm),lat(iim,jjm),lev(llm)
-  LOGICAL,INTENT(IN) :: l_rw
-  INTEGER,INTENT(OUT) :: ncfid
-!-
-  INTEGER,DIMENSION(max_dim) :: var_dims,dimlen
-  INTEGER :: nb_dim,nb_var,id_unl,id,iv
-  INTEGER :: iread,jread,lread,iret
-  INTEGER :: lon_vid,lat_vid
-  REAL :: lon_read(iim,jjm),lat_read(iim,jjm)
-  REAL :: lev_read(llm)
-  REAL :: mdlon,mdlat
-  CHARACTER(LEN=80) :: units
-  CHARACTER(LEN=NF90_max_name),DIMENSION(max_dim) :: dimname
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! If we reuse the same file for input and output
-! then we open it in write mode
-!-
-  IF (l_rw) THEN; id = NF90_WRITE; ELSE; id = NF90_NOWRITE; ENDIF
-  iret = NF90_OPEN(fname,id,ncfid)
-  IF (iret /= NF90_NOERR) THEN
-    CALL ipslerr (3,'restopenin','Could not open file :',fname,' ')
-  ENDIF
-!-
-  IF (l_dbg) WRITE (*,*) "restopenin 0.0 ",TRIM(fname)
-  iret = NF90_INQUIRE(ncfid,nDimensions=nb_dim, &
- &         nVariables=nb_var,unlimitedDimId=id_unl)
-  tdimid_in(fid) = id_unl
-!-
-  IF (nb_dim > max_dim) THEN
-    CALL ipslerr (3,'restopenin',&
-      & 'More dimensions present in file that can be store',&
-      & 'Please increase max_dim in the global variables ',&
-      & 'in restcom.F90')
-  ENDIF
-  IF (nb_var > max_var) THEN
-    CALL ipslerr (3,'restopenin',&
-      & 'More variables present in file that can be store',&
-      & 'Please increase max_var in the global variables ',&
-      & 'in restcom.F90')
-  ENDIF
-!-
-  nbvar_in(fid) = nb_var
-  nbdim_in(fid) = nb_dim
-  iread = -1; jread = -1; lread = -1;
-  DO id=1,nb_dim
-    iret = NF90_INQUIRE_DIMENSION(ncfid,id, &
- &           len=dimlen(id),name=dimname(id))
-    IF (l_dbg) THEN
-      WRITE (*,*) "restopenin 0.0 dimname",id,TRIM(dimname(id))
-    ENDIF
-    IF      (TRIM(dimname(id)) == 'x') THEN
-      iread = dimlen(id)
-      IF (l_dbg) WRITE (*,*) "iread",iread
-    ELSE IF (TRIM(dimname(id)) == 'y') THEN
-      jread = dimlen(id)
-      IF (l_dbg) WRITE (*,*) "jread",jread
-    ELSE IF (TRIM(dimname(id)) == 'z') THEN
-      lread = dimlen(id)
-      IF (l_dbg) WRITE (*,*) "lread",lread
-    ENDIF
-  ENDDO
-!-
-  IF (id_unl > 0) THEN
-!---
-!-- 0.1 If we are going to add values to this file
-!--     we need to know where it ends
-!--     We also need to have all the dimensions in the file
-!---
-    IF (l_rw) THEN
-      tstp_out(fid) = dimlen(id_unl)
-      itau_out(fid) = -1
-      tdimid_out(fid) =  tdimid_in(fid)
-      IF (l_dbg) THEN
-        WRITE (*,*) &
- &       "restopenin 0.0 unlimited axis dimname", &
- &       dimname(id_unl),tstp_out(fid)
-      ENDIF
-!-----
-      xax_nb(fid) = 0
-      yax_nb(fid) = 0
-      zax_nb(fid) = 0
-!-----
-      DO id=1,nb_dim
-        IF      (dimname(id)(1:1) == 'x') THEN
-          xax_nb(fid) = xax_nb(fid)+1
-          xax_infs(fid,xax_nb(fid),1) = dimlen(id)
-          xax_infs(fid,xax_nb(fid),2) = id
-        ELSE IF (dimname(id)(1:1) == 'y') THEN
-          yax_nb(fid) = yax_nb(fid)+1
-          yax_infs(fid,yax_nb(fid),1) = dimlen(id)
-          yax_infs(fid,yax_nb(fid),2) = id
-        ELSE IF (dimname(id)(1:1) == 'z') THEN
-          zax_nb(fid) = zax_nb(fid)+1
-          zax_infs(fid,zax_nb(fid),1) = dimlen(id)
-          zax_infs(fid,zax_nb(fid),2) = id
-        ENDIF
-      ENDDO
-    ENDIF
-  ELSE
-!---
-!-- Still need to find a method for dealing with this
-!---
-!  CALL ipslerr (3,'restopenin',&
-!    & ' We do not deal yet with files without time axis.',' ',' ')
-  ENDIF
-!-
-! 1.0 First let us check that we have the righ restart file
-!-
-  IF ((iread /= iim).OR.(jread /= jjm).OR.(lread /= llm)) THEN
-    CALL ipslerr (3,'restopenin',&
- &    'The grid of the restart file does not correspond',&
- &    'to that of the model',' ')
-  ENDIF
-!-
-! 2.0 Get the list of variables
-!-
-  IF (l_dbg) WRITE(*,*) 'restopenin 1.2'
-!-
-  lat_vid = -1
-  lon_vid = -1
-  tind_varid_in(fid) = -1
-  tax_varid_in(fid) = -1
-!-
-  DO iv=1,nb_var
-!---
-    varid_in(fid,iv) = iv
-    var_dims(:) = 0
-    iret = NF90_INQUIRE_VARIABLE(ncfid,iv, &
- &           name=varname_in(fid,iv),xtype=vartyp_in(fid,iv), &
- &           ndims=varnbdim_in(fid,iv),dimids=var_dims, &
- &           nAtts=varatt_in(fid,iv))
-!---
-    DO id=1,varnbdim_in(fid,iv)
-      iret = NF90_INQUIRE_DIMENSION &
- &             (ncfid,var_dims(id),len=vardims_in(fid,iv,id))
-    ENDDO
-!---
-!-- 2.1 Read the units of the variable
-!---
-    units=''
-    iret = NF90_GET_ATT(ncfid,iv,'units',units)
-    CALL strlowercase (units)
-    CALL cmpblank (units)
-!---
-!-- 2.2 Catch the time variables
-!---
-    IF (varnbdim_in(fid,iv) == 1) THEN
-      IF (     (INDEX(units,'timesteps since') > 0) &
-          .AND.(tind_varid_in(fid) < 0) ) THEN
-        tind_varid_in(fid) = iv
-        tax_size_in(fid) = vardims_in(fid,iv,1)
-      ENDIF
-      IF (     (INDEX(units,'seconds since') > 0) &
-          .AND.(tax_varid_in(fid) < 0) ) THEN
-        tax_varid_in(fid) = iv
-        tax_size_in(fid) = vardims_in(fid,iv,1)
-      ENDIF
-    ENDIF
-!---
-!-- 2.3 Catch longitude and latitude variables
-!---
-    IF      (INDEX(units,'degrees_nort') > 0) THEN
-      lat_vid = iv
-    ELSE IF (INDEX(units,'degrees_east') > 0) THEN
-      lon_vid = iv
-    ENDIF
-!---
-  ENDDO
-!-
-! 2.4 None of the variables was yet read
-!-
-  nbvar_read(fid) = 0
-  touched_in(fid,:) = .FALSE.
-!-
-! 3.0 Reading the coordinates from the input restart file
-!-
-  lon_read = missing_val
-  lat_read = missing_val
-!-
-  IF (lon_vid < 0 .OR. lat_vid < 0) THEN
-    CALL ipslerr (3,'restopenin',&
-      & ' No variables containing longitude or latitude were ',&
-      & ' found in the restart file.',' ')
-  ELSE
-    iret = NF90_GET_VAR(ncfid,lon_vid,lon_read)
-    iret = NF90_GET_VAR(ncfid,lat_vid,lat_read)
-!---
-    IF (  (ABS( MAXVAL(lon(:,:)) &
- &             -MINVAL(lon(:,:))) < EPSILON(MAXVAL(lon(:,:)))) &
- &   .AND.(ABS( MAXVAL(lat(:,:)) &
- &             -MINVAL(lat(:,:))) < EPSILON(MAXVAL(lat(:,:)))) ) THEN
-!-----
-!---- 3.1 No longitude nor latitude are provided thus
-!---- they are taken from the restart file
-!-----
-      lon(:,:) = lon_read(:,:)
-      lat(:,:) = lat_read(:,:)
-    ELSE
-!-----
-!---- 3.2 We check that the longitudes and latitudes
-!----     in the file and the model are the same
-!-----
-      mdlon = MAXVAL(ABS(lon_read-lon))
-      mdlat = MAXVAL(ABS(lat_read-lat))
-!-----
-!---- We can not test against epsilon here as the longitude
-!---- can be stored at another precision in the netCDF file.
-!---- The test here does not need to be very precise.
-!-----
-      IF (mdlon > 1.e-4 .OR. mdlat > 1.e-4) THEN
-        CALL ipslerr (3,'restopenin',&
-          & ' The longitude or latitude found in the restart ',&
-          & ' file are not the same as the ones used in the model.',&
-          & ' ')
-      ENDIF
-    ENDIF
-  ENDIF
-!------------------------
-END SUBROUTINE restopenin
-!===
-SUBROUTINE restsett (timestep,date0,itau,owrite_time_in)
-!---------------------------------------------------------------------
-!- Here we get all the time information from the file.
-!-
-!- The time information can come in three forms :
-!- -global attributes which give the time origine and the
-!-  time step is taken from the input to restinit
-!- -A physical time exists and thus the julian date from the
-!-  input is used for positioning using the itau as input
-!- -A time-step axis exists and itau is positioned on it.
-!-
-!- What takes precedence : the model
-!-
-!- itau     : Time step of the model
-!-
-!- Optional INPUT arguments
-!-
-!- owrite_time_in : logical  argument which allows to
-!-                  overwrite the time in the restart file
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  REAL :: date0,timestep
-  INTEGER :: itau
-  LOGICAL,OPTIONAL :: owrite_time_in
-!-
-  INTEGER :: ncfid,iret,it,iax,iv
-  CHARACTER(LEN=80) :: itau_orig,tax_orig,calendar
-  CHARACTER(LEN=9) :: tmp_cal
-  INTEGER :: year0,month0,day0,hours0,minutes0,seci
-  REAL :: sec0,one_day,one_year,date0_ju,ttmp
-  CHARACTER :: strc
-  LOGICAL :: ow_time
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (PRESENT(owrite_time_in)) THEN
-    ow_time = owrite_time_in
-  ELSE
-    ow_time = .FALSE.
-  ENDIF
-!-
-  ncfid = netcdf_id(nb_fi,1)
-!-
-! Allocate the space we need for the time axes
-!-
-  CALL rest_atim (l_dbg,'restsett')
-!-
-! Get the calendar if possible. Else it will be gregorian.
-!-
-  IF (tax_size_in(nb_fi) > 0) THEN
-    calendar = ' '
-    iret = NF90_GET_ATT(ncfid,tax_varid_in(nb_fi),'calendar',calendar)
-    IF (iret == NF90_NOERR) THEN
-      CALL ioconf_calendar (calendar)
-      IF (l_dbg) THEN
-        WRITE(*,*) 'restsett : calendar of the restart ',calendar
-      ENDIF
-    ENDIF
-  ENDIF
-  CALL ioget_calendar (one_year,one_day)
-  IF (l_dbg) THEN
-    WRITE(*,*) 'one_year,one_day = ',one_year,one_day
-  ENDIF
-!-
-  itau_orig = 'XXXXX'
-  tax_orig  = 'XXXXX'
-!-
-! Get the time steps of the time axis if available on the restart file
-!-
-  IF (tind_varid_in(nb_fi) > 0) THEN
-    IF (ow_time) THEN
-      t_index(nb_fi,:) = itau
-      IF (l_dbg) THEN
-        WRITE(*,*) "nb_fi,t_index",nb_fi,t_index(nb_fi,:)
-      ENDIF
-      CALL ju2ymds (date0,year0,month0,day0,sec0)
-      hours0 = NINT(sec0/3600)
-      sec0 = sec0 - 3600 * hours0
-      minutes0 = NINT(sec0 / 60)
-      sec0 = sec0 - 60 * minutes0
-      seci = NINT(sec0)
-      strc=':'
-      IF (l_dbg) THEN
-        WRITE(*,*) date0
-        WRITE (UNIT=itau_orig,FMT='(I4.4,5(A,I2.2))') &
- &       year0,'-',month0,'-',day0,' ',hours0,':',minutes0,':',seci
-        WRITE(*,*) "itau_orig : ",itau_orig
-      ENDIF
-    ELSE
-      iret = NF90_GET_VAR(ncfid,tind_varid_in(nb_fi),t_index(nb_fi,:))
-      IF (l_dbg) THEN
-        WRITE(*,*) "restsett, time axis : ",t_index(nb_fi,:)
-      ENDIF
-      iret = NF90_GET_ATT(ncfid,tind_varid_in(nb_fi),'units',itau_orig)
-      itau_orig = &
- &      itau_orig(INDEX(itau_orig,'since')+6:LEN_TRIM(itau_orig))
-      iret = &
- &      NF90_GET_ATT(ncfid,tind_varid_in(nb_fi),'tstep_sec',timestep)
-!-----
-!---- This time origin will dominate as it is linked to the time steps.
-!-----
-      READ (UNIT=itau_orig,FMT='(I4.4,5(A,I2.2))') &
- &      year0,strc,month0,strc,day0,strc, &
- &      hours0,strc,minutes0,strc,seci
-      sec0 = REAL(seci)
-      sec0 = hours0*3600.+minutes0*60.+sec0
-      CALL ymds2ju (year0,month0,day0,sec0,date0)
-    ENDIF
-  ENDIF
-!-
-! If a julian day time axis is available then we get it
-!-
-  IF (tax_varid_in(nb_fi) > 0) THEN
-    iret = NF90_GET_VAR(ncfid,tax_varid_in(nb_fi),t_julian(nb_fi,:))
-    iret = NF90_GET_ATT(ncfid,tax_varid_in(nb_fi),'units',tax_orig)
-    tax_orig = tax_orig(INDEX(tax_orig,'since')+6:LEN_TRIM(tax_orig))
-    tmp_cal = ' '
-    iret = NF90_GET_ATT(ncfid,tax_varid_in(nb_fi),'calendar',tmp_cal)
-    IF (l_dbg) THEN
-      WRITE(*,*) 'restsett : tmp_calendar of the restart ',tmp_cal
-    ENDIF
-!---
-    CALL strlowercase (tmp_cal)
-    IF (INDEX(calend_str,tmp_cal) < 1) THEN
-      IF (INDEX(calend_str,'unknown') > 0) THEN
-        calend_str = tmp_cal
-      ELSE
-        CALL ipslerr (2,'restsett', &
- &       ' In the restart files two different calendars were found.', &
- &       ' Please check the files you have used.',' ')
-      ENDIF
-    ENDIF
-!---
-!-- We need to transform that into julian days
-!-- to get ride of the intial date.
-!---
-    IF (l_dbg) WRITE(*,*) 'tax_orig : ',TRIM(tax_orig)
-    READ (UNIT=tax_orig,FMT='(I4.4,5(a,I2.2))') &
-      year0,strc,month0,strc,day0,strc, &
-      hours0,strc,minutes0,strc,seci
-    sec0 = REAL(seci)
-    sec0 = hours0*3600.+minutes0*60.+sec0
-    CALL ymds2ju (year0,month0,day0,sec0,date0_ju)
-    t_julian(nb_fi,:) = t_julian(nb_fi,:)/one_day+date0_ju
-  ENDIF
-!-
-  IF (     (INDEX(itau_orig,'XXXXX') > 0) &
-      .AND.(INDEX(tax_orig,'XXXXX')  < 1) ) THEN
-!!- Compute the t_itau from the date read and the timestep in the input
-  ENDIF
-!-
-  IF (     (INDEX(tax_orig,'XXXXX')  > 0) &
-      .AND.(INDEX(itau_orig,'XXXXX') < 1) ) THEN
-    DO it=1,tax_size_in(nb_fi)
-      t_julian(nb_fi,it) = itau2date(t_index(nb_fi,it),date0,timestep)
-    ENDDO
-  ENDIF
-!-
-! If neither the indices or time is present then get global attributes
-! This is for compatibility reasons and should not be used.
-!-
-  IF ((tax_varid_in(nb_fi) < 0).AND.(tind_varid_in(nb_fi) < 0)) THEN
-    iax = -1
-    DO iv=1,nbvar_in(nb_fi)
-      IF (    (INDEX(varname_in(nb_fi,iv),'tsteps') > 0) &
- &        .OR.(INDEX(varname_in(nb_fi,iv),'time_steps') > 0)) THEN
-        iax = iv
-      ENDIF
-    ENDDO
-!---
-    IF (iax < 0) THEN
-      CALL ipslerr (3,'restsett',&
-        & 'No time axis was found in the restart file. Please check',&
-        & 'that it corresponds to the convention used in restsett',&
-        & ' ')
-    ELSE
-      iret = NF90_GET_VAR(ncfid,tind_varid_in(nb_fi),t_index(nb_fi,:))
-      iret = NF90_GET_ATT(ncfid,NF90_GLOBAL,'delta_tstep_sec',timestep)
-      iret = NF90_GET_ATT(ncfid,NF90_GLOBAL,'year0',ttmp)
-      year0 = NINT(ttmp)
-      iret = NF90_GET_ATT(ncfid,NF90_GLOBAL,'month0',ttmp)
-      month0 = NINT(ttmp)
-      iret = NF90_GET_ATT(ncfid,NF90_GLOBAL,'day0',ttmp)
-      day0 = NINT(ttmp)
-      iret = NF90_GET_ATT(ncfid,NF90_GLOBAL,'sec0',sec0)
-!---
-      CALL ymds2ju (year0,month0,day0,sec0,date0)
-      t_julian(nb_fi,1) = itau2date(t_index(nb_fi,1),date0,timestep)
-    ENDIF
-  ENDIF
-!----------------------
-END SUBROUTINE restsett
-!===
-SUBROUTINE restopenout &
-  (fid,fname,iim,jjm, &
-   lon,lat,llm,lev,timestep,date,ncfid,domain_id)
-!---------------------------------------------------------------------
-!- Opens the restart file for output.
-!- The longitude and time variables are written.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: fid,iim,jjm,llm
-  CHARACTER(LEN=*) :: fname
-  REAL :: date,timestep
-  REAL :: lon(iim,jjm),lat(iim,jjm),lev(llm)
-  INTEGER,INTENT(OUT) :: ncfid
-  INTEGER,INTENT(IN),OPTIONAL :: domain_id
-!-
-  INTEGER :: iret
-  CHARACTER(LEN=70) :: str_t
-  INTEGER :: x_id,y_id,z_id,itauid
-  INTEGER :: nlonid,nlatid,nlevid,timeid
-  INTEGER :: year,month,day,hours,minutes
-  REAL :: sec
-  CHARACTER(LEN=3),DIMENSION(12) :: &
-    cal = (/'JAN','FEB','MAR','APR','MAY','JUN', &
-            'JUL','AUG','SEP','OCT','NOV','DEC'/)
-  CHARACTER(LEN=30) :: timenow
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout 0.0 ",TRIM(fname)
-!-
-!  If we use the same file for input and output
-!- we will not even call restopenout
-!-
-  iret = NF90_CREATE(fname,NF90_NOCLOBBER,ncfid)
-  IF (iret == -35) THEN
-    CALL ipslerr (3,'restopenout',&
-      & ' The restart file aready exists on the disc. IOIPSL ',&
-      & ' will not overwrite it. You should remove the old one or ',&
-      & ' generate the new one with another name')
-  ENDIF
-!-
-  iret = NF90_DEF_DIM(ncfid,'x',iim,x_id)
-  xax_nb(fid) = xax_nb(fid)+1
-  xax_infs(fid,xax_nb(fid),1) = iim
-  xax_infs(fid,xax_nb(fid),2) = x_id
-!-
-  iret = NF90_DEF_DIM(ncfid,'y',jjm,y_id)
-  yax_nb(fid)  = yax_nb(fid)+1
-  yax_infs(fid,yax_nb(fid),1) = jjm
-  yax_infs(fid,yax_nb(fid),2) = y_id
-!-
-  iret = NF90_DEF_DIM(ncfid,'z',llm,z_id)
-  zax_nb(fid) = zax_nb(fid)+1
-  zax_infs(fid,zax_nb(fid),1) = llm
-  zax_infs(fid,zax_nb(fid),2) = z_id
-!-
-  iret = NF90_DEF_DIM(ncfid,'time',NF90_UNLIMITED,tdimid_out(fid))
-!-
-! 1.0 Longitude
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout 1.0"
-!-
-  iret = NF90_DEF_VAR(ncfid,"nav_lon",NF90_FLOAT,(/x_id,y_id/),nlonid)
-  iret = NF90_PUT_ATT(ncfid,nlonid,'units',"degrees_east")
-  iret = NF90_PUT_ATT(ncfid,nlonid,'valid_min',REAL(-180.,KIND=4))
-  iret = NF90_PUT_ATT(ncfid,nlonid,'valid_max',REAL( 180.,KIND=4))
-  iret = NF90_PUT_ATT(ncfid,nlonid,'long_name',"Longitude")
-!-
-! 2.0 Latitude
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout 2.0"
-!-
-  iret = NF90_DEF_VAR(ncfid,"nav_lat",NF90_FLOAT,(/x_id,y_id/),nlatid)
-  iret = NF90_PUT_ATT(ncfid,nlatid,'units',"degrees_north")
-  iret = NF90_PUT_ATT(ncfid,nlatid,'valid_min',REAL(-90.,KIND=4))
-  iret = NF90_PUT_ATT(ncfid,nlatid,'valid_max',REAL( 90.,KIND=4))
-  iret = NF90_PUT_ATT(ncfid,nlatid,'long_name',"Latitude")
-!-
-! 3.0 Levels
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout 3.0"
-!-
-  iret = NF90_DEF_VAR(ncfid,"nav_lev",NF90_FLOAT,z_id,nlevid)
-  iret = NF90_PUT_ATT(ncfid,nlevid,'units',"model_levels")
-  iret = NF90_PUT_ATT(ncfid,nlevid,'valid_min', &
- &                     REAL(MINVAL(lev),KIND=4))
-  iret = NF90_PUT_ATT(ncfid,nlevid,'valid_max', &
- &                     REAL(MAXVAL(lev),KIND=4))
-  iret = NF90_PUT_ATT(ncfid,nlevid,'long_name',"Model levels")
-!-
-! 4.0 Time axis, this is the seconds since axis
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout 4.0"
-!-
-  iret = NF90_DEF_VAR(ncfid,"time",NF90_FLOAT, &
-                       tdimid_out(fid),timeid)
-  tax_varid_out(fid) = timeid
-!-
-  timeorig(fid) = date
-  CALL ju2ymds (date,year,month,day,sec)
-  hours   = INT(sec/(60.*60.))
-  minutes = INT((sec-hours*60.*60.)/60.)
-  sec     = sec-(hours*60.*60.+minutes*60.)
-  WRITE (UNIT=str_t, &
-   FMT='("seconds since ",I4.4,2("-",I2.2)," ",I2.2,2(":",I2.2))') &
- &  year,month,day,hours,minutes,INT(sec)
-  iret = NF90_PUT_ATT(ncfid,timeid,'units',TRIM(str_t))
-!-
-  CALL ioget_calendar (str_t)
-  iret = NF90_PUT_ATT(ncfid,timeid,'calendar',TRIM(str_t))
-  iret = NF90_PUT_ATT(ncfid,timeid,'title','Time')
-  iret = NF90_PUT_ATT(ncfid,timeid,'long_name','Time axis')
-!-
-  WRITE(UNIT=str_t, &
-   FMT='(" ",I4.4,"-",A3,"-",I2.2," ",I2.2,2(":",I2.2))') &
- &  year,cal(month),day,hours,minutes,INT(sec)
-  iret = NF90_PUT_ATT(ncfid,timeid,'time_origin',TRIM(str_t))
-!-
-! 5.0 Time axis, this is the time steps since axis
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout 5.0"
-!-
-  iret = NF90_DEF_VAR(ncfid,"time_steps",NF90_INT, &
- &                    tdimid_out(fid),itauid)
-  tind_varid_out(fid) = itauid
-!-
-  CALL ju2ymds (date,year,month,day,sec)
-!-
-  hours   = INT(sec/(60.*60.))
-  minutes = INT((sec-hours*60.*60.)/60.)
-  sec     = sec-(hours*60.*60.+minutes*60.)
-!-
-  WRITE (UNIT=str_t, &
-   FMT='("timesteps since ",I4.4,2("-",I2.2)," ",I2.2,2(":",I2.2))') &
- &  year,month,day,hours,minutes,INT(sec)
-!-
-  iret = NF90_PUT_ATT(ncfid,itauid,'units',TRIM(str_t))
-  iret = NF90_PUT_ATT(ncfid,itauid,'title','Time steps')
-  iret = NF90_PUT_ATT(ncfid,itauid,'tstep_sec',REAL(timestep,KIND=4))
-  iret = NF90_PUT_ATT(ncfid,itauid,'long_name','Time step axis')
-!-
-  WRITE(UNIT=str_t, &
-   FMT='(" ",I4.4,"-",A3,"-",I2.2," ",I2.2,2(":",I2.2))') &
- &  year,cal(month),day,hours,minutes,INT(sec)
-  iret = NF90_PUT_ATT(ncfid,itauid,'time_origin',TRIM(str_t))
-!-
-!  5.2 Write global attributes
-!-
-  iret = NF90_PUT_ATT(ncfid,NF90_GLOBAL,'Conventions',"CF-1.1")
-  iret = NF90_PUT_ATT(ncfid,NF90_GLOBAL,'file_name',TRIM(fname))
-!!  TO BE DONE LATER
-!!   iret = NF90_PUT_ATT(ncfid,NF90_GLOBAL, &
-!!                       'production',TRIM(model_name))
-!!   lock_modname = .TRUE.
-  CALL ioget_timestamp (timenow)
-  iret = NF90_PUT_ATT(ncfid,NF90_GLOBAL,'TimeStamp',TRIM(timenow))
-!-
-! Add DOMAIN attributes if needed
-!-
-  CALL flio_dom_att (ncfid,domain_id)
-!-
-! 6.0 The coordinates are written to the file
-!-
-  iret = NF90_ENDDEF(ncfid)
-!-
-  iret = NF90_PUT_VAR(ncfid,nlonid,lon)
-  iret = NF90_PUT_VAR(ncfid,nlatid,lat)
-  iret = NF90_PUT_VAR(ncfid,nlevid,lev)
-!-
-! 7.0 Set a few variables related to the out file
-!-
-  nbvar_out(fid) = 0
-  itau_out(fid) = -1
-  tstp_out(fid) = 0
-  touched_out(fid,:) = .FALSE.
-!-
-! 7.1 The file is put back in define mode.
-!     This will last until itau_out >= 0
-!-
-  iret = NF90_REDEF(ncfid)
-!-
-  IF (l_dbg) WRITE(*,*) "restopenout END"
-!-------------------------
-END SUBROUTINE restopenout
-!===
-SUBROUTINE restget_opp_r1d &
- & (fid,vname_q,iim,jjm,llm,itau,def_beha, &
- &  var,MY_OPERATOR,nbindex,ijndex)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restget_real
-!-
-!- Should work as restput_opp_r1d but the other way around !
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  LOGICAL def_beha
-  REAL :: var(:)
-  CHARACTER(LEN=*) :: MY_OPERATOR
-  INTEGER :: nbindex,ijndex(nbindex)
-!-
-  INTEGER :: req_sz,siz1
-  REAL :: scal
-  CHARACTER(LEN=7) :: topp
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 0.0 What size should be the data in the file
-!-
-  req_sz = 1
-  IF (nbindex == iim .AND. jjm <= 1 .AND. llm <= 1) THEN
-    IF (xax_infs(fid,1,1) > 0) req_sz = req_sz*xax_infs(fid,1,1)
-    IF (yax_infs(fid,1,1) > 0) req_sz = req_sz*yax_infs(fid,1,1)
-    IF (zax_infs(fid,1,1) > 0) req_sz = req_sz*zax_infs(fid,1,1)
-  ELSE
-    CALL ipslerr (3,'resget_opp_r1d', &
-      'Unable to performe an operation on this variable as it has',&
-      'a second and third dimension',vname_q)
-  ENDIF
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var)
-  CALL rest_alloc (1,siz1,l_dbg,'restget_opp_r1d')
-  CALL rest_alloc (2,req_sz,l_dbg,'restget_opp_r1d')
-!-
-! 2.0 Here we get the variable from the restart file
-!-
-  CALL restget_real &
-    (fid,vname_q,xax_infs(fid,1,1),yax_infs(fid,1,1), &
-     zax_infs(fid,1,1),itau,def_beha,buff_tmp2)
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  topp = MY_OPERATOR(1:MIN(LEN_TRIM(MY_OPERATOR),7))
-!-
-  IF (INDEX(indchfun,topp(:LEN_TRIM(topp))) > 0) THEN
-    scal = missing_val
-    CALL mathop (topp,req_sz,buff_tmp2,missing_val, &
- &               nbindex,ijndex,scal,siz1,buff_tmp1)
-    var(:) = buff_tmp1(1:siz1)
-  ELSE
-    CALL ipslerr (3,'resget_opp_r1d', &
-      'The operation you wish to do on the variable for the ',&
-      'restart file is not allowed.',topp)
-  ENDIF
-!-----------------------------
-END SUBROUTINE restget_opp_r1d
-!===
-SUBROUTINE restget_opp_r2d &
- & (fid,vname_q,iim,jjm,llm,itau,def_beha, &
- &  var,MY_OPERATOR,nbindex,ijndex)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restget_real
-!-
-!- Should work as restput_opp_r2d but the other way around !
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  LOGICAL def_beha
-  REAL :: var(:,:)
-  CHARACTER(LEN=*) :: MY_OPERATOR
-  INTEGER :: nbindex,ijndex(nbindex)
-!-
-  INTEGER :: jj,req_sz,ist,var_sz,siz1
-  REAL :: scal
-  CHARACTER(LEN=7) :: topp
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 0.0 What size should be the data in the file
-!-
-  req_sz = 1
-  IF (nbindex == iim  .AND. llm <= 1) THEN
-    IF (xax_infs(fid,1,1) > 0) req_sz = req_sz*xax_infs(fid,1,1)
-    IF (yax_infs(fid,1,1) > 0) req_sz = req_sz*yax_infs(fid,1,1)
-  ELSE
-    CALL ipslerr (3,'resget_opp_r2d', &
-      'Unable to performe an operation on this variable as it has', &
-      'a second and third dimension',vname_q)
-  ENDIF
-!-
-  IF (jjm < 1) THEN
-    CALL ipslerr (3,'resget_opp_r2d', &
-      'Please specify a second dimension which is the', &
-      'layer on which the operations are performed',vname_q)
-  ENDIF
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var,1)
-  CALL rest_alloc (1,siz1,l_dbg,'restget_opp_r2d')
-  CALL rest_alloc (2,req_sz*jjm,l_dbg,'restget_opp_r2d')
-!-
-! 2.0 Here we get the full variable from the restart file
-!-
-  CALL restget_real &
- & (fid,vname_q,xax_infs(fid,1,1),yax_infs(fid,1,1), &
- &  jjm,itau,def_beha,buff_tmp2)
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  topp = MY_OPERATOR(1:MIN(LEN_TRIM(MY_OPERATOR),7))
-!-
-  IF (INDEX(indchfun,topp(:LEN_TRIM(topp))) > 0) THEN
-    scal = missing_val
-    var_sz = siz1
-    DO jj = 1,jjm
-      ist = (jj-1)*req_sz+1
-      CALL mathop (topp,req_sz,buff_tmp2(ist:ist+req_sz-1), &
- &      missing_val,nbindex,ijndex,scal,var_sz,buff_tmp1)
-      var(:,jj) = buff_tmp1(1:siz1)
-    ENDDO
-  ELSE
-    CALL ipslerr (3,'resget_opp_r2d', &
-      'The operation you wish to do on the variable for the ',&
-      'restart file is not allowed.',topp)
-  ENDIF
-!-----------------------------
-END SUBROUTINE restget_opp_r2d
-!===
-SUBROUTINE restget_r1d &
- & (fid,vname_q,iim,jjm,llm,itau,def_beha,var)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restget_real
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  LOGICAL :: def_beha
-  REAL :: var(:)
-!-
-  INTEGER :: ji,jl,req_sz,var_sz,siz1
-  CHARACTER(LEN=70) :: str,str2
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var)
-  var_sz = siz1
-  CALL rest_alloc (1,var_sz,l_dbg,'restget_r1d')
-!-
-! 2.0 Here we could check if the sizes specified agree
-!     with the size of the variable provided
-!-
-  req_sz = 1
-  IF (iim > 0) req_sz = req_sz*iim
-  IF (jjm > 0) req_sz = req_sz*jjm
-  IF (llm > 0) req_sz = req_sz*llm
-  IF (req_sz > var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable requested from file should be ",I6)') req_sz
-    WRITE(str2, &
- &    '("but the provided variable can only hold ",I6)') var_sz
-    CALL ipslerr (3,'restget_r1d',str,str2,' ')
-  ENDIF
-  IF (req_sz < var_sz) THEN
-    WRITE(str, &
- &    '("the size of variable requested from file is ",I6)') req_sz
-    WRITE(str2, &
- &    '("but the provided variable can hold ",I6)') var_sz
-    CALL ipslerr (2,'restget_r1d', &
-      'There could be a problem here :',str,str2)
-  ENDIF
-!-
-  CALL restget_real &
- & (fid,vname_q,iim,jjm,llm,itau,def_beha,buff_tmp1)
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  jl=0
-  DO ji=1,siz1
-    jl=jl+1
-    var(ji) = buff_tmp1(jl)
-  ENDDO
-!-------------------------
-END SUBROUTINE restget_r1d
-!===
-SUBROUTINE restget_r2d &
- & (fid,vname_q,iim,jjm,llm,itau,def_beha,var)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restget_real
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  LOGICAL :: def_beha
-  REAL :: var(:,:)
-!-
-  INTEGER :: ji,jj,jl,req_sz,var_sz,siz1,siz2
-  CHARACTER(LEN=70) :: str,str2
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var,1)
-  siz2 = SIZE(var,2)
-  var_sz = siz1*siz2
-  CALL rest_alloc (1,var_sz,l_dbg,'restget_r2d')
-!-
-! 2.0 Here we check if the sizes specified agree
-!     with the size of the variable provided
-!-
-  req_sz = 1
-  IF (iim > 0) req_sz = req_sz*iim
-  IF (jjm > 0) req_sz = req_sz*jjm
-  IF (llm > 0) req_sz = req_sz*llm
-  IF (req_sz > var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable ",A, &
- &      //" requested from file should be ",I6)') TRIM(vname_q),req_sz
-    WRITE(str2, &
- &    '("but the provided variable can only hold ",I6)') var_sz
-    CALL ipslerr (3,'restget_r2d',str,str2,' ')
-  ENDIF
-  IF (req_sz < var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable ",A, &
- &      //" requested from file is ",I6)') TRIM(vname_q),req_sz
-    WRITE(str2,'("but the provided variable can hold ",I6)') var_sz
-    CALL ipslerr (2,'restget_r2d', &
-      'There could be a problem here :',str,str2)
-  ENDIF
-!-
-  CALL restget_real &
- & (fid,vname_q,iim,jjm,llm,itau,def_beha,buff_tmp1)
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  jl=0
-  DO jj=1,siz2
-    DO ji=1,siz1
-      jl=jl+1
-      var(ji,jj) = buff_tmp1(jl)
-    ENDDO
-  ENDDO
-!-------------------------
-END SUBROUTINE restget_r2d
-!===
-SUBROUTINE restget_r3d &
-  (fid,vname_q,iim,jjm,llm,itau,def_beha,var)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restget_real
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  LOGICAL def_beha
-  REAL :: var(:,:,:)
-!-
-  INTEGER :: ji,jj,jk,jl,req_sz,var_sz,siz1,siz2,siz3
-  CHARACTER(LEN=70) :: str,str2
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var,1)
-  siz2 = SIZE(var,2)
-  siz3 = SIZE(var,3)
-  var_sz = siz1*siz2*siz3
-  CALL rest_alloc (1,var_sz,l_dbg,'restget_r3d')
-!-
-! 2.0 Here we check if the sizes specified agree
-!     with the size of the variable provided
-!-
-  req_sz = 1
-  IF (iim > 0) req_sz = req_sz*iim
-  IF (jjm > 0) req_sz = req_sz*jjm
-  IF (llm > 0) req_sz = req_sz*llm
-  IF (req_sz > var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable ",A, &
- &      //" requested from file should be ",I6)') TRIM(vname_q),req_sz
-    WRITE(str2, &
- &    '("but the provided variable can only hold ",I6)') var_sz
-    CALL ipslerr (3,'restget_r3d',str,str2,' ')
-  ENDIF
-  IF (req_sz < var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable ",A, &
- &      //" requested from file is ",I6)') TRIM(vname_q),req_sz
-    WRITE(str2,'("but the provided variable can hold ",I6)') var_sz
-    CALL ipslerr (2,'restget_r3d', &
-      'There could be a problem here :',str,str2)
-  ENDIF
-!-
-  CALL restget_real &
-    (fid,vname_q,iim,jjm,llm,itau,def_beha,buff_tmp1)
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  jl=0
-  DO jk=1,siz3
-    DO jj=1,siz2
-      DO ji=1,siz1
-        jl=jl+1
-        var(ji,jj,jk) = buff_tmp1(jl)
-      ENDDO
-    ENDDO
-  ENDDO
-!-------------------------
-END SUBROUTINE restget_r3d
-!===
-SUBROUTINE restget_real &
-  (fid,vname_q,iim,jjm,llm,itau,def_beha,var)
-!---------------------------------------------------------------------
-!- This subroutine is for getting a variable from the restart file.
-!- A number of verifications will be made :
-!- - Is this the first time we read this variable ?
-!- - Are the dimensions correct ?
-!- - Is the correct time step present in the file
-!- - is a default behaviour possible. If not the model is stoped.
-!- Default procedure is to write the content of val_exp on all values.
-!-
-!- INPUT
-!-
-!- fid            : Identification of the file
-!- vname_q        : Name of the variable to be read
-!- iim, jjm ,llm  : Dimensions of the variable that should be read
-!- itau           : Time step at whcih we are when we want
-!-                  to read the variable
-!- def_beha       : If the model can restart without this variable
-!-                  then some strange value is given.
-!-
-!- OUTPUT
-!-
-!- var            : Variable in which the data is put
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  LOGICAL :: def_beha
-  REAL :: var(:)
-!-
-  INTEGER :: vid,vnb,ncfid,iret,index,it,ndim,ia
-  CHARACTER(LEN=70) str,str2
-  CHARACTER(LEN=80) attname
-  INTEGER,DIMENSION(4) :: corner,edge
-!---------------------------------------------------------------------
-  ncfid = netcdf_id(fid,1)
-!-
-  CALL find_str (varname_in(fid,1:nbvar_in(fid)),vname_q,vnb)
-!-
-! 1.0 If the variable is not present then ERROR or filled up
-!     by default values if allowed
-!-
-  IF (vnb < 0) THEN
-    IF (def_beha) THEN
-!-----
-      lock_valexp = .TRUE.
-      var(:) = val_exp
-!----
-      str = 'Variable '//TRIM(vname_q) &
-          //' is not present in the restart file'
-      CALL ipslerr (1,'restget', &
- &      str,'but default values are used to fill in',' ')
-!----
-      IF (nbvar_in(fid) >= max_var) THEN
-        CALL ipslerr (3,'restget', &
-         'Too many variables for the restcom module', &
-         'Please increase the value of max_var',' ')
-      ENDIF
-      nbvar_in(fid) = nbvar_in(fid)+1
-      vnb = nbvar_in(fid)
-      varname_in(fid,vnb) = vname_q
-      touched_in(fid,vnb) = .TRUE.
-!-----
-      CALL restdefv (fid,vname_q,iim,jjm,llm,.TRUE.)
-!-----
-    ELSE
-      str = 'Variable '//TRIM(vname_q) &
-          //' is not present in the restart file'
-      CALL ipslerr (3,'restget', &
- &      str,'but it is need to restart the model',' ')
-    ENDIF
-!---
-  ELSE
-!---
-!--  2.0 Check if the variable has not yet been read
-!--      and that the time is OK
-!---
-    vid = varid_in(fid,vnb)
-!---
-    nbvar_read(fid) = nbvar_read(fid)+1
-!---
-    IF (touched_in(fid,vnb)) THEN
-      str = 'Variable '//TRIM(vname_q) &
-          //' has already been read from file'
-      CALL ipslerr (3,'restget',str,' ',' ')
-    ENDIF
-!---
-!-- 3.0 get the time step of the restart file
-!--     and check if it is correct
-!---
-    index = -1
-    DO it=1,tax_size_in(fid)
-      IF (t_index(fid,it) == itau)  index = it
-    ENDDO
-    IF (index < 0) THEN
-      str = 'The time step requested for variable '//TRIM(vname_q)
-      CALL ipslerr (3,'restget', &
- &      str,'is not available in the current file',' ')
-    ENDIF
-!---
-!-- 4.0 Read the data. Note that the variables in the restart files
-!--     have no time axis is and thus we write -1
-!---
-    str='Incorrect dimension for '//TRIM(vname_q)
-    ndim = 0
-    IF (iim > 0) THEN
-      ndim = ndim+1
-      IF (vardims_in(fid,vnb,ndim) == iim) THEN
-        corner(ndim) = 1
-        edge(ndim) = iim
-      ELSE
-        WRITE (str2,'("Incompatibility for iim : ",I6,I6)') &
-             iim,vardims_in(fid,vnb,ndim)
-        CALL ipslerr (3,'restget',str,str2,' ')
-      ENDIF
-    ENDIF
-!---
-    IF (jjm > 0) THEN
-      ndim = ndim+1
-      IF (vardims_in(fid,vnb,ndim) == jjm) THEN
-        corner(ndim) = 1
-        edge(ndim) = jjm
-      ELSE
-        WRITE (str2,'("Incompatibility for jjm : ",I6,I6)') &
-             jjm,vardims_in(fid,vnb,ndim)
-        CALL ipslerr (3,'restget',str,str2,' ')
-      ENDIF
-    ENDIF
-!---
-    IF (llm > 0) THEN
-      ndim = ndim+1
-      IF (vardims_in(fid,vnb,ndim) == llm) THEN
-        corner(ndim) = 1
-        edge(ndim) = llm
-      ELSE
-        WRITE (str2,'("Incompatibility for llm : ",I6,I6)') &
-             llm,vardims_in(fid,vnb,ndim)
-        CALL ipslerr (3,'restget',str,str2,' ')
-      ENDIF
-    ENDIF
-!---
-!-- Time
-!---
-    ndim = ndim+1
-    corner(ndim) = index
-!!????? edge(ndim) = index
-    edge(ndim) = 1
-!---
-    iret = NF90_GET_VAR(ncfid,vid,var, &
- &                      start=corner(1:ndim),count=edge(1:ndim))
-!---
-!-- 5.0 The variable we have just read is created
-!--      in the next restart file
-!---
-    IF (     (netcdf_id(fid,1) /= netcdf_id(fid,2))  &
- &      .AND.(netcdf_id(fid,2) > 0) ) THEN
-!-----
-      CALL restdefv (fid,vname_q,iim,jjm,llm,.FALSE.)
-!-----
-      DO ia = 1,varatt_in(fid,vnb)
-        iret = NF90_INQ_ATTNAME(ncfid,vid,ia,attname)
-        iret = NF90_COPY_ATT(ncfid,vid,attname, &
- &               netcdf_id(fid,2),varid_out(fid,nbvar_out(fid)))
-      ENDDO
-!-----
-      IF (itau_out(fid) >= 0) THEN
-        iret = NF90_ENDDEF(netcdf_id(fid,2))
-      ENDIF
-    ENDIF
-!---
-  ENDIF
-!--------------------------
-END SUBROUTINE restget_real
-!===
-SUBROUTINE restput_opp_r1d &
- & (fid,vname_q,iim,jjm,llm,itau,var,MY_OPERATOR,nbindex,ijndex)
-!---------------------------------------------------------------------
-!- This subroutine is the interface to restput_real which allows
-!- to re-index data onto the original grid of the restart file.
-!- The logic we use is still fuzzy in my mind but that is probably
-!- only because I have not yet though through everything.
-!-
-!- In the case iim = nbindex it means that the user attempts
-!- to project a vector back onto the original 2D or 3D field.
-!- This requires that jjm and llm be equal to 1 or 0,
-!- else I would not know what it means.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  REAL :: var(:)
-  CHARACTER(LEN=*) :: MY_OPERATOR
-  INTEGER :: nbindex,ijndex(nbindex)
-!-
-  INTEGER :: req_sz,siz1
-  REAL :: scal
-  CHARACTER(LEN=7) :: topp
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 0.0 What size should be the data in the file
-!-
-  req_sz = 1
-  IF ( nbindex == iim .AND. jjm <= 1 .AND. llm <= 1) THEN
-    IF (xax_infs(fid,1,1) > 0) req_sz = req_sz*xax_infs(fid,1,1)
-    IF (yax_infs(fid,1,1) > 0) req_sz = req_sz*yax_infs(fid,1,1)
-    IF (zax_infs(fid,1,1) > 0) req_sz = req_sz*zax_infs(fid,1,1)
-  ELSE
-    CALL ipslerr (3,'restput_opp_r1d', &
-      'Unable to performe an operation on this variable as it has', &
-      'a second and third dimension',vname_q)
-  ENDIF
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var)
-  CALL rest_alloc (1,siz1,l_dbg,'restput_opp_r1d')
-  CALL rest_alloc (2,req_sz,l_dbg,'restput_opp_r1d')
-!-
-! 2.0 We do the operation needed.
-!     It can only be a re-indexing operation.
-!     You would not want to change the values in a restart file or ?
-!-
-  topp = MY_OPERATOR(1:MIN(LEN_TRIM(MY_OPERATOR),7))
-!-
-  IF (INDEX(indchfun,topp(:LEN_TRIM(topp))) > 0) THEN
-    scal = missing_val
-    buff_tmp1(1:siz1) = var(:)
-    CALL mathop &
- &    (topp,siz1,buff_tmp1,missing_val,nbindex,ijndex, &
- &     scal,req_sz,buff_tmp2)
-  ELSE
-    CALL ipslerr (3,'restput_opp_r1d', &
- &    'The operation you wish to do on the variable for the ', &
- &    'restart file is not allowed.',topp)
-  ENDIF
-!-
-  CALL restput_real &
- & (fid,vname_q,xax_infs(fid,1,1),yax_infs(fid,1,1), &
- &  zax_infs(fid,1,1),itau,buff_tmp2)
-!-----------------------------
-END SUBROUTINE restput_opp_r1d
-!===
-SUBROUTINE restput_opp_r2d &
- & (fid,vname_q,iim,jjm,llm,itau,var,MY_OPERATOR,nbindex,ijndex)
-!---------------------------------------------------------------------
-!- This subroutine is the interface to restput_real which allows
-!- to re-index data onto the original grid of the restart file.
-!- The logic we use is still fuzzy in my mind but that is probably
-!- only because I have not yet though through everything.
-!-
-!- In the case iim = nbindex it means that the user attempts
-!- to project the first dimension of the matrix back onto a 3D field
-!- where jjm will be the third dimension.
-!- Here we do not allow for 4D data, thus we will take the first
-!- two dimensions in the file and require that llm = 1.
-!- These are pretty heavy constraints but I do not know how
-!- to make it more general. I need to think about it some more.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  REAL :: var(:,:)
-  CHARACTER(LEN=*) :: MY_OPERATOR
-  INTEGER :: nbindex,ijndex(nbindex)
-!-
-  INTEGER :: jj,req_sz,ist,siz1
-  REAL :: scal
-  CHARACTER(LEN=7) :: topp
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 0.0 What size should be the data in the file
-!-
-  req_sz = 1
-  IF ( nbindex == iim .AND. llm <= 1) THEN
-    IF (xax_infs(fid,1,1) > 0) req_sz = req_sz*xax_infs(fid,1,1)
-    IF (yax_infs(fid,1,1) > 0) req_sz = req_sz*yax_infs(fid,1,1)
-  ELSE
-    CALL ipslerr (3,'restput_opp_r2d', &
-      'Unable to performe an operation on this variable as it has', &
-      'a second and third dimension',vname_q)
-  ENDIF
-!-
-  IF (jjm < 1) THEN
-    CALL ipslerr (3,'restput_opp_r2d', &
-      'Please specify a second dimension which is the', &
-      'layer on which the operations are performed',vname_q)
-  ENDIF
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var,1)
-  CALL rest_alloc (1,siz1,l_dbg,'restput_opp_r2d')
-  CALL rest_alloc (2,req_sz*jjm,l_dbg,'restput_opp_r2d')
-!-
-! 2.0 We do the operation needed.
-!     It can only be a re-indexing operation.
-!     You would not want to change the values in a restart file or ?
-!-
-  topp = MY_OPERATOR(1:MIN(LEN_TRIM(MY_OPERATOR),7))
-!-
-  IF (INDEX(indchfun,topp(:LEN_TRIM(topp))) > 0) THEN
-    scal = missing_val
-    DO jj = 1,jjm
-      buff_tmp1(1:siz1) = var(:,jj)
-      ist = (jj-1)*req_sz+1
-      CALL mathop &
- &      (topp,siz1,buff_tmp1,missing_val,nbindex,ijndex, &
- &       scal,req_sz,buff_tmp2(ist:ist+req_sz-1))
-    ENDDO
-  ELSE
-    CALL ipslerr (3,'restput_opp_r2d', &
- &    'The operation you wish to do on the variable for the ', &
- &    'restart file is not allowed.',topp)
-  ENDIF
-!-
-  CALL restput_real &
- & (fid,vname_q,xax_infs(fid,1,1),yax_infs(fid,1,1), &
- &  jjm,itau,buff_tmp2)
-!-----------------------------
-END SUBROUTINE restput_opp_r2d
-!===
-SUBROUTINE restput_r1d (fid,vname_q,iim,jjm,llm,itau,var)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restput_real
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  REAL :: var(:)
-!-
-  INTEGER :: ji,jl,req_sz,var_sz,siz1
-  CHARACTER(LEN=70) :: str,str2
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var)
-  var_sz = siz1
-  CALL rest_alloc (1,var_sz,l_dbg,'restput_r1d')
-!-
-! 2.0 Here we could check if the sizes specified agree
-!     with the size of the variable provided
-!-
-  req_sz = 1
-  IF (iim > 0) req_sz = req_sz*iim
-  IF (jjm > 0) req_sz = req_sz*jjm
-  IF (llm > 0) req_sz = req_sz*llm
-  IF (req_sz > var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable put to the file should be ",I6)') req_sz
-    WRITE(str2, &
- &    '("but the provided variable is of size ",I6)') var_sz
-    CALL ipslerr (3,'restput_r1d',str,str2,' ')
-  ENDIF
-  IF (req_sz < var_sz) THEN
-    WRITE(str,'("the size of variable put to the file is ",I6)') req_sz
-    WRITE(str2,'("but the provided variable is larger ",I6)') var_sz
-    CALL ipslerr (2,'restput_r1d', &
-      'There could be a problem here :',str,str2)
-  ENDIF
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  jl=0
-  DO ji=1,siz1
-    jl=jl+1
-    buff_tmp1(jl) = var(ji)
-  ENDDO
-!-
-  CALL restput_real (fid,vname_q,iim,jjm,llm,itau,buff_tmp1)
-!-------------------------
-END SUBROUTINE restput_r1d
-!===
-SUBROUTINE restput_r2d (fid,vname_q,iim,jjm,llm,itau,var)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restput_real
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  REAL :: var(:,:)
-!-
-  INTEGER :: ji,jj,jl,req_sz,var_sz,siz1,siz2
-  CHARACTER(LEN=70) :: str,str2
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var,1)
-  siz2 = SIZE(var,2)
-  var_sz = siz1*siz2
-  CALL rest_alloc (1,var_sz,l_dbg,'restput_r2d')
-!-
-! 2.0 Here we could check if the sizes specified agree
-!     with the size of the variable provided
-!-
-  req_sz = 1
-  IF (iim > 0) req_sz = req_sz*iim
-  IF (jjm > 0) req_sz = req_sz*jjm
-  IF (llm > 0) req_sz = req_sz*llm
-  IF (req_sz > var_sz) THEN
-    WRITE(str, &
-&         '("Size of variable put to the file should be ",I6)') req_sz
-    WRITE(str2,'("but the provided variable is of size  ",I6)') var_sz
-    CALL ipslerr (3,'restput_r2d',str,str2,' ')
-  ENDIF
-  IF (req_sz < var_sz) THEN
-    WRITE(str,'("the size of variable put to the file is ",I6)') req_sz
-    WRITE(str2,'("but the provided variable is larger ",I6)')  var_sz
-    CALL ipslerr (2,'restput_r2d', &
-      'There could be a problem here :',str,str2)
-  ENDIF
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  jl=0
-  DO jj=1,siz2
-    DO ji=1,siz1
-      jl=jl+1
-      buff_tmp1(jl) = var(ji,jj)
-    ENDDO
-  ENDDO
-!-
-  CALL restput_real(fid,vname_q,iim,jjm,llm,itau,buff_tmp1)
-!-------------------------
-END SUBROUTINE restput_r2d
-!===
-SUBROUTINE restput_r3d (fid,vname_q,iim,jjm,llm,itau,var)
-!---------------------------------------------------------------------
-!- This subroutine serves as an interface to restput_real
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: iim,jjm,llm,itau
-  REAL :: var(:,:,:)
-!-
-  INTEGER :: ji,jj,jk,jl,req_sz,var_sz,siz1,siz2,siz3
-  CHARACTER(LEN=70) :: str,str2
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 1.0 Allocate the temporary buffer we need
-!     to put the variable in right dimension
-!-
-  siz1 = SIZE(var,1)
-  siz2 = SIZE(var,2)
-  siz3 = SIZE(var,3)
-  var_sz = siz1*siz2*siz3
-  CALL rest_alloc (1,var_sz,l_dbg,'restput_r3d')
-!-
-! 2.0 Here we could check if the sizes specified agree
-!     with the size of the variable provided
-!-
-  req_sz = 1
-  IF (iim > 0) req_sz = req_sz*iim
-  IF (jjm > 0) req_sz = req_sz*jjm
-  IF (llm > 0) req_sz = req_sz*llm
-  IF (req_sz > var_sz) THEN
-    WRITE(str, &
- &    '("Size of variable put to the file should be ",I6)') req_sz
-    WRITE(str2, &
- &    '("but the provided variable is of size  ",I6)')  var_sz
-    CALL ipslerr (3,'restput_r3d',str,str2,' ')
-  ENDIF
-  IF (req_sz < var_sz) THEN
-    WRITE(str,'("the size of variable put to the file is ",I6)') req_sz
-    WRITE(str2,'("but the provided variable is larger ",I6)')  var_sz
-    CALL ipslerr (2,'restput_r3d', &
-      'There could be a problem here :',str,str2)
-  ENDIF
-!-
-! 4.0 Transfer the buffer obtained from the restart file
-!     into the variable the model expects
-!-
-  jl=0
-  DO jk=1,siz3
-    DO jj=1,siz2
-      DO ji=1,siz1
-        jl=jl+1
-        buff_tmp1(jl) = var(ji,jj,jk)
-      ENDDO
-    ENDDO
-  ENDDO
-!-
-  CALL restput_real(fid,vname_q,iim,jjm,llm,itau,buff_tmp1)
-!-------------------------
-END SUBROUTINE restput_r3d
-!===
-SUBROUTINE restput_real (fid,vname_q,iim,jjm,llm,itau,var)
-!---------------------------------------------------------------------
-!- This subroutine will put a variable into the restart file.
-!- But it will do a lot of other things if needed :
-!- - Open a file if non is opened for this time-step
-!-   and all variables were written.
-!- - Add an axis if needed
-!- - verify that the variable has the right time step for this file
-!- - If it is time for a new file then it is opened
-!-   and the old one closed
-!- This requires that variables read from the last restart file were all
-!- written
-!-
-!- INPUT
-!-
-!- fid         : Id of the file in which we will write the variable
-!- vname_q     : Name of the variable to be written
-!- iim,jjm,llm : Size in 3D of the variable
-!- itau        : Time step at which the variable is written
-!- var         : Variable
-!-
-!- OUTPUT
-!-
-!- NONE
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER :: fid,iim,jjm,llm,itau
-  REAL :: var(:)
-!-
-  INTEGER :: iret,vid,ncid,iv,vnb
-  INTEGER :: ierr
-  REAL :: secsince,one_day,one_year
-  INTEGER :: ndims
-  INTEGER,DIMENSION(4) :: corner,edge
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-! 0.0 Get some variables
-!-
-  ncid = netcdf_id(fid,2)
-  IF (netcdf_id(fid,2) < 0) THEN
-    CALL ipslerr (3,'restput', &
- &    'The output restart file is undefined.',' ',' ')
-  ENDIF
-  CALL ioget_calendar (one_year,one_day)
-!-
-! 1.0 Check if the variable is already present
-!-
-  IF (l_dbg) WRITE(*,*) 'RESTPUT 1.0 : ',TRIM(vname_q)
-!-
-  CALL find_str (varname_out(fid,1:nbvar_out(fid)),vname_q,vnb)
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'RESTPUT 1.1 : ',varname_out(fid,1:nbvar_out(fid)),vnb
-  ENDIF
-!-
-! 2.0 If variable is not present then declare it
-!     and add extra dimensions if needed.
-!-
-  IF (vnb <= 0) THEN
-    CALL restdefv (fid,vname_q,iim,jjm,llm,.TRUE.)
-    vnb = nbvar_out(fid)
-  ENDIF
-  vid = varid_out(fid,vnb)
-!-
-  IF (l_dbg) WRITE(*,*) 'RESTPUT 2.0 : ',vnb,vid
-!-
-! 2.1 Is this file already in write mode ?
-!     If itau_out is still negative then we have
-!     never written to it and we need to go into write mode.
-!-
-  IF (itau_out(fid) < 0) THEN
-    iret = NF90_ENDDEF(ncid)
-  ENDIF
-!-
-! 3.0 Is this itau already on the axis ?
-!     If not then check that all variables of previous time is OK.
-!-
-  IF (l_dbg) WRITE(*,*) 'RESTPUT 3.0 : ',itau,itau_out(fid)
-!-
-  IF (itau /= itau_out(fid)) THEN
-!---
-!-- If it is the first time step written on the restart
-!-- then we only check the number
-!-- Else we see if every variable was written
-!---
-    IF (tstp_out(fid) == 0) THEN
-      IF (nbvar_out(fid) < nbvar_read(fid)) THEN
-        WRITE(*,*) "ERROR :",tstp_out(fid), &
-                   nbvar_out(fid),nbvar_read(fid)
-        CALL ipslerr (1,'restput', &
- &        'There are fewer variables read from the output file', &
- &        'than written onto the input file.', &
- &        'We trust you know what you are doing')
-      ENDIF
-    ELSE
-      ierr = 0
-      DO iv=1,nbvar_out(fid)
-        IF (.NOT.touched_out(fid,iv)) ierr = ierr+1
-      ENDDO
-      IF (ierr > 0) THEN
-        WRITE(*,*) "ERROR :",nbvar_out(fid)
-        CALL ipslerr (1,'restput', &
- &        'There are fewer variables in the output file for this', &
- &        'time step than for the previous one',' ')
-      ELSE
-        touched_out(fid,:) = .FALSE.
-      ENDIF
-    ENDIF
-!---
-    secsince = itau*deltat(fid)
-    corner(1) =  tstp_out(fid)+1
-    edge(1) = 1
-!---
-!-- 3.1 Here we add the values to the time axes
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) 'RESTPUT 3.1 : ',itau,secsince,corner(1),edge(1)
-    ENDIF
-!---
-    iret = NF90_PUT_VAR(ncid,tind_varid_out(fid),itau, &
- &                      start=corner(1:1))
-    iret = NF90_PUT_VAR(ncid,tax_varid_out(fid),secsince, &
- &                      start=corner(1:1))
-!---
-    tstp_out(fid) = tstp_out(fid)+1
-    itau_out(fid) = itau
-  ENDIF
-!-
-! 4.0 Variable and time step should be present
-!     now so we can dump variable
-!-
-  ndims = 0
-  IF (iim > 0) THEN
-    ndims = ndims+1
-    corner(ndims) = 1
-    edge(ndims) = iim
-  ENDIF
-  IF (jjm > 0) THEN
-    ndims = ndims+1
-    corner(ndims) = 1
-    edge(ndims) = jjm
-  ENDIF
-  IF (llm > 0) THEN
-    ndims = ndims+1
-    corner(ndims) = 1
-    edge(ndims) = llm
-  ENDIF
-  ndims = ndims+1
-  corner(ndims) = tstp_out(fid)
-  edge(ndims) = 1
-!-
-  iret = NF90_PUT_VAR(ncid,vid,var, &
- &                    start=corner(1:ndims),count=edge(1:ndims))
-!-
-  IF (iret /= NF90_NOERR) THEN
-    CALL ipslerr (2,'restput_real',NF90_STRERROR(iret), &
- &    'Bug in restput.',&
- &    'Please, verify compatibility between get and put commands.')
-  ENDIF
-!-
-!  5.0 Note that the variables was treated
-!-
-  touched_out(fid,vnb) = .TRUE.
-!---------------------------
-END  SUBROUTINE restput_real
-!===
-SUBROUTINE restdefv (fid,varname,iim,jjm,llm,write_att)
-!---------------------------------------------------------------------
-! This subroutine adds a variable to the output file.
-! The attributes are either taken from.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER ::fid
-  CHARACTER(LEN=*) :: varname
-  INTEGER :: iim,jjm,llm
-  LOGICAL :: write_att
-!-
-  INTEGER :: dims(4),ic,xloc,ndim,ncfid
-  INTEGER :: iret,ax_id
-  CHARACTER(LEN=3) :: str
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  ncfid = netcdf_id(fid,2)
-  IF (nbvar_out(fid) >= max_var) THEN
-    CALL ipslerr (3,'restdefv', &
-      'Too many variables for the restcom module', &
-      'Please increase the value of max_var',' ')
-  ENDIF
-  nbvar_out(fid) = nbvar_out(fid)+1
-  varname_out(fid,nbvar_out(fid)) = varname
-!-
-! 0.0 Put the file in define mode if needed
-!-
-  IF (itau_out(fid) >= 0) THEN
-    iret = NF90_REDEF(ncfid)
-  ENDIF
-!-
-! 1.0 Do we have all dimensions and can we go ahead
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'restdefv 1.0 :',TRIM(varname),nbvar_out(fid)
-  ENDIF
-!-
-  ndim = 0
-!-
-! 1.1 Work on x
-!-
-  IF (iim > 0) THEN
-    ndim = ndim+1
-    xloc = 0
-    DO ic=1,xax_nb(fid)
-      IF (xax_infs(fid,ic,1) == iim) xloc = ic
-    ENDDO
-!---
-    IF (xloc > 0) THEN
-      dims(ndim) = xax_infs(fid,xloc,2)
-    ELSE
-      str='x_'//CHAR(96+xax_nb(fid))
-      iret = NF90_DEF_DIM(ncfid,str,iim,ax_id)
-      xax_nb(fid) = xax_nb(fid)+1
-      xax_infs(fid,xax_nb(fid),1) = iim
-      xax_infs(fid,xax_nb(fid),2) = ax_id
-      dims(ndim) = ax_id
-    ENDIF
-  ENDIF
-!-
-! 1.2 Work on y
-!-
-  IF (jjm > 0) THEN
-    ndim = ndim+1
-    xloc = 0
-    DO ic=1,yax_nb(fid)
-      IF (yax_infs(fid,ic,1) == jjm) xloc = ic
-    ENDDO
-!---
-    IF (xloc > 0) THEN
-      dims(ndim) = yax_infs(fid,xloc,2)
-    ELSE
-      str='y_'//CHAR(96+yax_nb(fid))
-      iret = NF90_DEF_DIM(ncfid,str,jjm,ax_id)
-      yax_nb(fid) = yax_nb(fid)+1
-      yax_infs(fid,yax_nb(fid),1) = jjm
-      yax_infs(fid,yax_nb(fid),2) = ax_id
-      dims(ndim) = ax_id
-    ENDIF
-  ENDIF
-!-
-! 1.3 Work on z
-!-
-  IF (llm > 0) THEN
-    ndim = ndim+1
-    xloc = 0
-    DO ic=1,zax_nb(fid)
-      IF (zax_infs(fid,ic,1) == llm) xloc = ic
-    ENDDO
-!---
-    IF (xloc > 0) THEN
-      dims(ndim) = zax_infs(fid,xloc,2)
-    ELSE
-      str='z_'//CHAR(96+zax_nb(fid))
-      iret = NF90_DEF_DIM(ncfid,str,llm,ax_id)
-      zax_nb(fid) = zax_nb(fid)+1
-      zax_infs(fid,zax_nb(fid),1) = llm
-      zax_infs(fid,zax_nb(fid),2) = ax_id
-      dims(ndim) = ax_id
-    ENDIF
-  ENDIF
-!-
-! 1.4  Time needs to be added
-!-
-  ndim = ndim+1
-  dims(ndim) = tdimid_out(fid)
-!-
-! 2.0  Declare the variable
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) 'restdefv 2.0 :',ndim,' :: ',dims(1:ndim),tdimid_out(fid)
-  ENDIF
-!-
-  iret = NF90_DEF_VAR(ncfid,varname,NF90_DOUBLE,dims(1:ndim), &
- &                    varid_out(fid,nbvar_out(fid)))
-  IF (iret /= NF90_NOERR) THEN
-    CALL ipslerr (3,'restdefv', &
-      'Could not define new variable in file', &
-      NF90_STRERROR(iret),varname)
-  ENDIF
-!-
-! 3.0 Add the attributes if requested
-!-
-  IF (write_att) THEN
-    IF (rest_units /= 'XXXXX') THEN
-      iret =  NF90_PUT_ATT(ncfid,varid_out(fid,nbvar_out(fid)), &
- &                         'units',TRIM(rest_units))
-      rest_units = 'XXXXX'
-    ENDIF
-!---
-    IF (rest_lname /= 'XXXXX') THEN
-      iret =  NF90_PUT_ATT(ncfid,varid_out(fid,nbvar_out(fid)), &
- &                         'long_name',TRIM(rest_lname))
-      rest_lname = 'XXXXX'
-    ENDIF
-!---
-    iret = NF90_PUT_ATT(ncfid,varid_out(fid,nbvar_out(fid)), &
- &                      'missing_value',REAL(missing_val,KIND=4))
-!---
-    IF (itau_out(fid) >= 0) THEN
-      iret = NF90_ENDDEF(ncfid)
-    ENDIF
-  ENDIF
-!-
-  IF (l_dbg) THEN
-    WRITE(*,*) &
- &    'restdefv 3.0 : LIST OF VARS ',varname_out(fid,1:nbvar_out(fid))
-  ENDIF
-!----------------------
-END SUBROUTINE restdefv
-!===
-SUBROUTINE rest_atim (l_msg,c_p)
-!---------------------------------------------------------------------
-! Called by "c_p", [re]allocate the time axes
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  LOGICAL,INTENT(IN) :: l_msg
-  CHARACTER(LEN=*),INTENT(IN) :: c_p
-!-
-  INTEGER :: i_err,tszij
-  INTEGER,ALLOCATABLE :: tmp_index(:,:)
-  REAL,ALLOCATABLE :: tmp_julian(:,:)
-!---------------------------------------------------------------------
-!-
-!  Allocate the space we need for the time axes
-!-
-  IF (.NOT.ALLOCATED(t_index) .AND. .NOT.ALLOCATED(t_julian)) THEN
-    IF (l_msg) THEN
-      WRITE(*,*) TRIM(c_p)//' : Allocate times axes at :', &
- &               max_file,tax_size_in(nb_fi)
-    ENDIF
-!---
-    ALLOCATE(t_index(max_file,tax_size_in(nb_fi)),STAT=i_err)
-    IF (i_err/=0) THEN
-      WRITE(*,*) "ERROR IN ALLOCATION of t_index : ",i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &      'Problem in allocation of t_index','', &
- &      '(you must increase memory)')
-    ENDIF
-    t_index (:,:) = 0
-!---
-    ALLOCATE(t_julian(max_file,tax_size_in(nb_fi)),STAT=i_err)
-    IF (i_err/=0) THEN
-      WRITE(*,*) "ERROR IN ALLOCATION of t_julian : ",i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &      'Problem in allocation of max_file,tax_size_in','', &
- &      '(you must increase memory)')
-    ENDIF
-    t_julian (:,:) = 0.0
-  ELSE IF (    (SIZE(t_index,DIM=2)  < tax_size_in(nb_fi)) &
- &         .OR.(SIZE(t_julian,DIM=2) < tax_size_in(nb_fi)) ) THEN
-    IF (l_msg) THEN
-      WRITE(*,*) TRIM(c_p)//' : Reallocate times axes at :', &
- &               max_file,tax_size_in(nb_fi)
-    ENDIF
-!---
-    ALLOCATE (tmp_index(max_file,tax_size_in(nb_fi)),STAT=i_err)
-    IF (i_err/=0) THEN
-      WRITE(*,*) "ERROR IN ALLOCATION of tmp_index : ",i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &      'Problem in allocation of tmp_index','', &
- &      '(you must increase memory)')
-    ENDIF
-    tszij = SIZE(t_index,DIM=2)
-    tmp_index(:,1:tszij) = t_index(:,1:tszij)
-    DEALLOCATE(t_index)
-    ALLOCATE (t_index(max_file,tax_size_in(nb_fi)),STAT=i_err)
-    IF (i_err/=0) THEN
-      WRITE(*,*) "ERROR IN ALLOCATION of t_index : ",i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &     'Problem in reallocation of t_index','', &
- &     '(you must increase memory)')
-    ENDIF
-    t_index(:,1:tszij) = tmp_index(:,1:tszij)
-!---
-    ALLOCATE (tmp_julian(max_file,tax_size_in(nb_fi)),STAT=i_err)
-    IF (i_err/=0) THEN
-      WRITE(*,*) "ERROR IN ALLOCATION of tmp_julian : ",i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &     'Problem in allocation of tmp_julian','', &
- &     '(you must increase memory)')
-    ENDIF
-    tszij = SIZE(t_julian,DIM=2)
-    tmp_julian(:,1:tszij) = t_julian(:,1:tszij)
-    DEALLOCATE(t_julian)
-    ALLOCATE (t_julian(max_file,tax_size_in(nb_fi)),STAT=i_err)
-    IF (i_err/=0) THEN
-      WRITE(*,*) "ERROR IN ALLOCATION of t_julian : ",i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &      'Problem in reallocation of t_julian','', &
- &      '(you must increase memory)')
-    ENDIF
-    t_julian(:,1:tszij) = tmp_julian(:,1:tszij)
-  ENDIF
-!-----------------------
-END SUBROUTINE rest_atim
-!===
-SUBROUTINE rest_alloc (i_buff,i_qsz,l_msg,c_p)
-!---------------------------------------------------------------------
-! Called by "c_p", allocate a temporary buffer
-! (buff_tmp[1/2] depending on "i_buff" value) to the size "i_qsz".
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: i_buff,i_qsz
-  LOGICAL,INTENT(IN) :: l_msg
-  CHARACTER(LEN=*),INTENT(IN) :: c_p
-!-
-  INTEGER :: i_bsz,i_err
-  LOGICAL :: l_alloc1,l_alloc2
-  CHARACTER(LEN=9) :: cbn
-  CHARACTER(LEN=5) :: c_err
-!---------------------------------------------------------------------
-  IF      (i_buff == 1) THEN
-    IF (ALLOCATED(buff_tmp1)) THEN
-      i_bsz = SIZE(buff_tmp1)
-    ELSE
-      i_bsz = 0
-    ENDIF
-    l_alloc1 =    (.NOT.ALLOCATED(buff_tmp1)) &
- &            .OR.((ALLOCATED(buff_tmp1)).AND.(i_qsz > i_bsz))
-    l_alloc2 = .FALSE.
-    cbn = 'buff_tmp1'
-  ELSE IF (i_buff == 2) THEN
-    IF (ALLOCATED(buff_tmp2)) THEN
-      i_bsz = SIZE(buff_tmp2)
-    ELSE
-      i_bsz = 0
-    ENDIF
-    l_alloc1 = .FALSE.
-    l_alloc2 =    (.NOT.ALLOCATED(buff_tmp2)) &
- &            .OR.((ALLOCATED(buff_tmp2)).AND.(i_qsz > i_bsz))
-    cbn = 'buff_tmp2'
-  ELSE
-    CALL ipslerr (3,'rest_alloc', &
- &    'Called by '//TRIM(c_p),'with a wrong value of i_buff','')
-  ENDIF
-!-
-!-
-  IF (l_alloc1.OR.l_alloc2) THEN
-    IF (l_msg) THEN
-      IF (    (l_alloc1.AND.ALLOCATED(buff_tmp1)) &
- &        .OR.(l_alloc2.AND.ALLOCATED(buff_tmp2)) ) THEN
-        WRITE(*,*) TRIM(c_p)//" : re_allocate "//TRIM(cbn)//"=",i_qsz
-      ELSE
-        WRITE(*,*) TRIM(c_p)//" : allocate "//TRIM(cbn)//"=",i_qsz
-      ENDIF
-    ENDIF
-    IF (l_alloc1) THEN
-      IF (ALLOCATED(buff_tmp1)) THEN
-        DEALLOCATE(buff_tmp1)
-      ENDIF
-      ALLOCATE (buff_tmp1(i_qsz),STAT=i_err)
-    ELSE
-      IF (ALLOCATED(buff_tmp2)) THEN
-        DEALLOCATE(buff_tmp2)
-      ENDIF
-      ALLOCATE (buff_tmp2(i_qsz),STAT=i_err)
-    ENDIF
-    IF (i_err /= 0) THEN
-      WRITE (UNIT=c_err,FMT='(I5)') i_err
-      CALL ipslerr (3,TRIM(c_p), &
- &      'Problem in allocation of',TRIM(cbn), &
- &      'Error : '//TRIM(c_err)//' (you must increase memory)')
-    ENDIF
-  ENDIF
-!------------------------
-END SUBROUTINE rest_alloc
-!===
-SUBROUTINE ioconf_setatt (attname,value)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: attname,value
-!-
-  CHARACTER(LEN=LEN_TRIM(attname)) :: tmp_str
-!---------------------------------------------------------------------
-  tmp_str = attname
-  CALL strlowercase (tmp_str)
-!-
-  SELECT CASE(tmp_str)
-    CASE('units')
-      rest_units = value
-    CASE('long_name')
-      rest_lname = value
-    CASE DEFAULT
-      CALL ipslerr (2,'ioconf_restatt', &
-        'The attribute name provided is unknown',attname,' ')
-  END SELECT
-!---------------------------
-END SUBROUTINE ioconf_setatt
-!===
-SUBROUTINE ioget_vdim (fid,vname_q,varnbdim_max,varnbdim,vardims)
-!---------------------------------------------------------------------
-!- This routine allows the user to get the dimensions
-!- of a field in the restart file.
-!- This is the file which is read.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: fid
-  CHARACTER(LEN=*) :: vname_q
-  INTEGER,INTENT(IN) :: varnbdim_max
-  INTEGER,INTENT(OUT) ::  varnbdim
-  INTEGER,DIMENSION(varnbdim_max),INTENT(OUT) :: vardims
-!-
-  INTEGER :: vnb
-!---------------------------------------------------------------------
-! Find the index of the variable
-  CALL find_str (varname_in(fid,1:nbvar_in(fid)),vname_q,vnb)
-!-
-  IF (vnb > 0) THEN
-    varnbdim = varnbdim_in(fid,vnb)
-    IF (varnbdim_max < varnbdim) THEN
-      CALL ipslerr (3,'ioget_vdim', &
-        'The provided array for the variable dimensions is too small', &
-        '','')
-    ELSE
-      vardims(1:varnbdim) = vardims_in(fid,vnb,1:varnbdim)
-    ENDIF
-  ELSE
-    varnbdim = 0
-    CALL ipslerr (2,'ioget_vdim', &
-      'Variable '//TRIM(vname_q)//' not found','','')
-  ENDIF
-!------------------------
-END SUBROUTINE ioget_vdim
-!===
-SUBROUTINE ioget_vname (fid,nbvar,varnames)
-!---------------------------------------------------------------------
-!- This routine allows the user to extract the list
-!- of variables in an opened restart file.
-!- This is the file which is read
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: fid
-  INTEGER,INTENT(OUT) ::  nbvar
-  CHARACTER(LEN=*),INTENT(OUT) :: varnames(:)
-!---------------------------------------------------------------------
-  nbvar = nbvar_in(fid)
-!-
-  IF (SIZE(varnames) < nbvar) THEN
-    CALL ipslerr (3,'ioget_vname', &
-      'The provided array for the variable names is too small','','')
-  ELSE
-    varnames(1:nbvar) = varname_in(fid,1:nbvar)
-  ENDIF
-!-------------------------
-END SUBROUTINE ioget_vname
-!===
-SUBROUTINE ioconf_expval (new_exp_val)
-!---------------------------------------------------------------------
-!- The default value written into the variables which are not
-!- in the restart file can only be changed once.
-!- This avoids further complications.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  REAL :: new_exp_val
-!---------------------------------------------------------------------
-  IF (.NOT.lock_valexp) THEN
-    lock_valexp = .TRUE.
-    val_exp = new_exp_val
-  ELSE
-    CALL ipslerr (2,'ioconf_expval', &
-     'The default value for variable' &
-   //'not available in the restart file ', &
-     'has already been locked and can not be changed at this point', &
-     ' ')
-  ENDIF
-!---------------------------
-END SUBROUTINE ioconf_expval
-!===
-SUBROUTINE ioget_expval (get_exp_val)
-!---------------------------------------------------------------------
-!- Once the user has extracted the default value,
-!- we lock it so that it can not be changed anymore.
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  REAL :: get_exp_val
-!---------------------------------------------------------------------
-  get_exp_val = val_exp
-  lock_valexp = .TRUE.
-!--------------------------
-END SUBROUTINE ioget_expval
-!===
-SUBROUTINE restclo (fid)
-!---------------------------------------------------------------------
-!- This subroutine closes one or any opened restart file.
-!-
-!- INPUT
-!-
-!- fid    : File ID in the restcom system (not the netCDF ID)(optional)
-!-
-!- OUTPUT
-!-
-!- NONE
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(in),OPTIONAL :: fid
-!-
-  INTEGER :: iret,ifnc
-  CHARACTER(LEN=6) :: n_e
-  CHARACTER(LEN=3) :: n_f
-  LOGICAL :: l_dbg
-!---------------------------------------------------------------------
-  CALL ipsldbg (old_status=l_dbg)
-!-
-  IF (PRESENT(fid)) THEN
-!---
-    IF (l_dbg) THEN
-      WRITE(*,*) &
-        'restclo : Closing specified restart file number :', &
-        fid,netcdf_id(fid,1:2)
-    ENDIF
-!---
-    IF (netcdf_id(fid,1) > 0) THEN
-      iret = NF90_CLOSE(netcdf_id(fid,1))
-      IF (iret /= NF90_NOERR) THEN
-        WRITE (n_e,'(I6)') iret
-        WRITE (n_f,'(I3)') netcdf_id(fid,1)
-        CALL ipslerr (2,'restclo', &
-          "Error "//n_e//" in closing file : "//n_f,'',' ')
-      ENDIF
-      IF (netcdf_id(fid,1) == netcdf_id(fid,2)) THEN
-        netcdf_id(fid,2) = -1
-      ENDIF
-      netcdf_id(fid,1) = -1
-    ENDIF
-!---
-    IF (netcdf_id(fid,2) > 0)  THEN
-      iret = NF90_CLOSE(netcdf_id(fid,2))
-      IF (iret /= NF90_NOERR) THEN
-        WRITE (n_e,'(I6)') iret
-        WRITE (n_f,'(I3)') netcdf_id(fid,2)
-        CALL ipslerr (2,'restclo', &
-          "Error "//n_e//" in closing file : "//n_f,'',' ')
-      ENDIF
-      netcdf_id(fid,2) = -1
-    ENDIF
-!---
-  ELSE
-!---
-    IF (l_dbg) WRITE(*,*) 'restclo : Closing all files'
-!---
-    DO ifnc=1,nb_fi
-      IF (netcdf_id(ifnc,1) > 0) THEN
-        iret = NF90_CLOSE(netcdf_id(ifnc,1))
-        IF (iret /= NF90_NOERR) THEN
-          WRITE (n_e,'(I6)') iret
-          WRITE (n_f,'(I3)') netcdf_id(ifnc,1)
-          CALL ipslerr (2,'restclo', &
-            "Error "//n_e//" in closing file : "//n_f,'',' ')
-        ENDIF
-        IF (netcdf_id(ifnc,1) == netcdf_id(ifnc,2)) THEN
-          netcdf_id(ifnc,2) = -1
-        ENDIF
-        netcdf_id(ifnc,1) = -1
-      ENDIF
-!-----
-      IF (netcdf_id(ifnc,2) > 0) THEN
-        iret = NF90_CLOSE(netcdf_id(ifnc,2))
-        IF (iret /= NF90_NOERR) THEN
-          WRITE (n_e,'(I6)') iret
-          WRITE (n_f,'(I3)') netcdf_id(ifnc,2)
-          CALL ipslerr (2,'restclo', &
-            "Error "//n_e//" in closing file : "//n_f,'',' ')
-        END IF
-        netcdf_id(ifnc,2) = -1
-      ENDIF
-    ENDDO
-  ENDIF
-!---------------------
-END SUBROUTINE restclo
-!===
-!-----------------
-END MODULE restcom
