Index: IOIPSL/trunk/bld.cfg
===================================================================
--- IOIPSL/trunk/bld.cfg	(revision 4999)
+++ IOIPSL/trunk/bld.cfg	(revision 5009)
@@ -18,7 +18,9 @@
 
 src::src             %SRC_PATH/src
+src::rebuild         %SRC_PATH/rebuild
 search_src           false
 bld::lib ioipsl
 bld::target libioipsl.a
+bld::target flio_rbld.exe rebuild
 bld::exe_dep             
 
Index: IOIPSL/trunk/makeioipsl_fcm
===================================================================
--- IOIPSL/trunk/makeioipsl_fcm	(revision 4999)
+++ IOIPSL/trunk/makeioipsl_fcm	(revision 5009)
@@ -147,3 +147,3 @@
 ln -s build/lib lib
 ln -s build/inc inc
-
+ln -s build/bin bin
Index: IOIPSL/trunk/rebuild/AA_make
===================================================================
--- IOIPSL/trunk/rebuild/AA_make	(revision 5009)
+++ IOIPSL/trunk/rebuild/AA_make	(revision 5009)
@@ -0,0 +1,35 @@
+#-
+#- $Id: AA_make 53 2007-06-06 15:27:26Z bellier $
+#-
+#-Q- sxdkrz F_O = $(F_D) $(F_P) -C vsafe -size_t64 -I $(MODDIR)
+#-Q- eshpux F_O = $(F_D) $(F_P) -C vsafe -I $(MODDIR)
+#---------------------------------------------------------------------
+#- Create "rebuild" related to IOIPSL
+#---------------------------------------------------------------------
+
+SXMODEL_LIB = $(MODEL_LIB)
+ifeq ($(L_X),1)
+SXMODEL_LIB = $(LIBDIR)/libsxioipsl.a
+endif
+
+rbld: libioipsl $(BINDIR)/rebuild $(BINDIR)/flio_rbld
+	@echo rebuild is OK
+
+$(BINDIR)/rebuild: ./rebuild
+	cp -p ./rebuild $(BINDIR)/rebuild
+	chmod a+rx $(BINDIR)/rebuild
+
+$(BINDIR)/flio_rbld: $(SXMODEL_LIB) flio_rbld.f90
+	$(F_C) $(F_O) -I$(NCDF_INC) flio_rbld.f90
+	$(F_L) flio_rbld.o -o $(BINDIR)/flio_rbld \
+               $(L_O) $(SXMODEL_LIB) $(NCDF_LIB)
+	chmod a+rx $(BINDIR)/flio_rbld
+	$(RM) flio_rbld.o
+
+libioipsl:
+	(cd ../src; $(M_K) -f Makefile)
+
+clean:
+	$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L i.*.f90 *.M
+	$(RM) $(BINDIR)/rebuild $(BINDIR)/flio_rbld
+
Index: IOIPSL/trunk/rebuild/AA_make.ldef
===================================================================
--- IOIPSL/trunk/rebuild/AA_make.ldef	(revision 5009)
+++ IOIPSL/trunk/rebuild/AA_make.ldef	(revision 5009)
@@ -0,0 +1,14 @@
+#-
+#- $Id: AA_make.ldef 53 2007-06-06 15:27:26Z bellier $
+#-
+#---------------------------------------------------------------------
+#- Local parameters related to the "tools" of IOIPSL (rebuild, config)
+#---------------------------------------------------------------------
+SHELL = /bin/ksh
+#---------------------------------------------------------------------
+LIBDIR = ../../../lib
+BINDIR = ../../../bin
+MODDIR = $(LIBDIR)
+#---------------------------------------------------------------------
+P_P =
+MODEL_LIB = $(LIBDIR)/libioipsl.a
Index: IOIPSL/trunk/rebuild/flio_rbld.f90
===================================================================
--- IOIPSL/trunk/rebuild/flio_rbld.f90	(revision 5009)
+++ IOIPSL/trunk/rebuild/flio_rbld.f90	(revision 5009)
@@ -0,0 +1,1622 @@
+PROGRAM flio_rbld
+!
+!$Id: flio_rbld.f90 2310 2014-08-04 13:51:24Z mafoipsl $
+!-
+! This software is governed by the CeCILL license
+! See IOIPSL/IOIPSL_License_CeCILL.txt
+!!--------------------------------------------------------------------
+!! PROGRAM flio_rbld
+!!
+!! PURPOSE :
+!!   Recombine the files of MPI version of IOIPSL
+!!   along several dimensions.
+!!
+!! CALLING SEQUENCE :
+!!
+!!   "flio_rbld" is usually invoked by the script "rebuild"
+!!
+!!   rebuild -h
+!!
+!!   rebuild [-v lev] [-f] -o outfile infile[1] ... infile[n]
+!!
+!! INPUT for "rebuild" :
+!!
+!!   -h         : help
+!!   -v lev     : verbosity level
+!!   -f         : force executing mode
+!!   -o outfile : name of the recombined file.
+!!   infiles    : names of the files that must be recombined.
+!!
+!! INPUT for "flio_rbld" :
+!!
+!!  (I) i_v_lev  : verbosity level
+!!  (C) c_force  : executing mode (noforce/force)
+!!  (I) f_nb     : total number of files
+!!  (C) f_nm(:)  : names of the files (input_files output_file)
+!!
+!!
+!! ASSOCIATED MODULES :
+!!   IOIPSL(fliocom)
+!!
+!! RESTRICTIONS :
+!!
+!!   Cases for character are not coded.
+!!
+!!   Cases for netCDF variables such as array with more
+!!   than 5 dimensions are not coded.
+!!
+!!   Input files must have the following global attributes :
+!!
+!!     "DOMAIN_number_total"
+!!     "DOMAIN_number"
+!!     "DOMAIN_dimensions_ids"
+!!     "DOMAIN_size_global"
+!!     "DOMAIN_size_local"
+!!     "DOMAIN_position_first"
+!!     "DOMAIN_position_last"
+!!     "DOMAIN_halo_size_start"
+!!     "DOMAIN_halo_size_end"
+!!     "DOMAIN_type"
+!!
+!!   NetCDF files must be smaller than 2 Gb.
+!!
+!!   Character variables should have less than 257 letters
+!!
+!! EXAMPLE :
+!!
+!!   rebuild -v -o sst.nc sst_[0-9][0-9][0-9][0-9].nc
+!!
+!! MODIFICATION HISTORY :
+!!   Sebastien Masson   (smasson@jamstec.go.jp)   March 2004
+!!   Jacques   Bellier  (Jacques.Bellier@cea.fr)  June  2005
+!!--------------------------------------------------------------------
+  USE IOIPSL
+  USE defprec
+!-
+  IMPLICIT NONE
+!-
+! Character length
+  INTEGER,PARAMETER :: chlen=256
+!-
+! DO loops and test related variables
+  INTEGER :: i,ia,id,iv,iw,i_i,i_n
+  INTEGER :: ik,itmin,itmax,it1,it2,it
+  LOGICAL :: l_force,l_uld
+!-
+! Input arguments related variables
+  INTEGER :: i_v_lev
+  CHARACTER(LEN=15) :: c_force
+  INTEGER :: f_nb,f_nb_in
+  CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: f_nm
+!-
+! Domains related variables
+  INTEGER :: d_n_t,i_ntd
+  INTEGER,DIMENSION(:),ALLOCATABLE :: dom_att,d_d_i,d_s_g
+  INTEGER,DIMENSION(:,:),ALLOCATABLE :: d_s_l,d_p_f,d_p_l,d_h_s,d_h_e
+  LOGICAL :: l_cgd,l_cof,l_col,l_o_f,l_o_m,l_o_l
+  CHARACTER(LEN=chlen) :: c_d_n
+!-
+! Model files related variables
+  LOGICAL :: l_ocf
+  INTEGER,DIMENSION(:),ALLOCATABLE :: f_a_id
+  INTEGER :: f_id_i1,f_id_i,f_id_o
+  INTEGER :: f_d_nb,f_v_nb,f_a_nb,f_d_ul
+  INTEGER :: v_a_nb,a_type
+  CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: &
+&  f_d_nm,f_v_nm,f_a_nm,v_a_nm
+  CHARACTER(LEN=chlen) :: f_u_nm
+  INTEGER,DIMENSION(:),ALLOCATABLE :: v_d_nb,v_d_ul,v_type
+  INTEGER,DIMENSION(:,:),ALLOCATABLE :: v_d_i
+  INTEGER,DIMENSION(:),ALLOCATABLE :: f_d_i,f_d_l
+  INTEGER :: a_l
+  INTEGER,DIMENSION(flio_max_var_dims) :: d_i,ib,ie
+  INTEGER,DIMENSION(:),ALLOCATABLE :: &
+ &  io_i,io_n,ia_sf,io_sf,io_cf,ia_sm,io_sm,io_cm,ia_sl,io_sl,io_cl
+  LOGICAL :: l_ex
+  CHARACTER(LEN=chlen) :: c_wn1,c_wn2
+!-
+!?INTEGERS of KIND 1 are not supported on all computers
+!?INTEGER(KIND=i_1) :: i1_0d
+!?INTEGER(KIND=i_1),DIMENSION(:),ALLOCATABLE :: i1_1d
+!?INTEGER(KIND=i_1),DIMENSION(:,:),ALLOCATABLE :: i1_2d
+!?INTEGER(KIND=i_1),DIMENSION(:,:,:),ALLOCATABLE :: i1_3d
+!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:),ALLOCATABLE :: i1_4d
+!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i1_5d
+  INTEGER(KIND=i_2) :: i2_0d
+  INTEGER(KIND=i_2),DIMENSION(:),ALLOCATABLE :: i2_1d
+  INTEGER(KIND=i_2),DIMENSION(:,:),ALLOCATABLE :: i2_2d
+  INTEGER(KIND=i_2),DIMENSION(:,:,:),ALLOCATABLE :: i2_3d
+  INTEGER(KIND=i_2),DIMENSION(:,:,:,:),ALLOCATABLE :: i2_4d
+  INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i2_5d
+  INTEGER(KIND=i_4) :: i4_0d
+  INTEGER(KIND=i_4),DIMENSION(:),ALLOCATABLE :: i4_1d
+  INTEGER(KIND=i_4),DIMENSION(:,:),ALLOCATABLE :: i4_2d
+  INTEGER(KIND=i_4),DIMENSION(:,:,:),ALLOCATABLE :: i4_3d
+  INTEGER(KIND=i_4),DIMENSION(:,:,:,:),ALLOCATABLE :: i4_4d
+  INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i4_5d
+  REAL(KIND=r_4) :: r4_0d
+  REAL(KIND=r_4),DIMENSION(:),ALLOCATABLE :: r4_1d
+  REAL(KIND=r_4),DIMENSION(:,:),ALLOCATABLE :: r4_2d
+  REAL(KIND=r_4),DIMENSION(:,:,:),ALLOCATABLE :: r4_3d
+  REAL(KIND=r_4),DIMENSION(:,:,:,:),ALLOCATABLE :: r4_4d
+  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: r4_5d
+  REAL(KIND=r_8) :: r8_0d
+  REAL(KIND=r_8),DIMENSION(:),ALLOCATABLE :: r8_1d
+  REAL(KIND=r_8),DIMENSION(:,:),ALLOCATABLE :: r8_2d
+  REAL(KIND=r_8),DIMENSION(:,:,:),ALLOCATABLE :: r8_3d
+  REAL(KIND=r_8),DIMENSION(:,:,:,:),ALLOCATABLE :: r8_4d
+  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: r8_5d
+!-
+! elapsed and cpu time computation variables
+  INTEGER :: nb_cc_ini,nb_cc_end,nb_cc_sec,nb_cc_max
+  REAL :: t_cpu_ini,t_cpu_end
+!---------------------------------------------------------------------
+!-
+!-------------------
+! INPUT arguments
+!-------------------
+!-
+! Retrieve the verbosity level
+  READ (UNIT=*,FMT=*) i_v_lev
+!-
+! Retrieve the executing mode
+  READ (UNIT=*,FMT='(A)') c_force
+  l_force = (TRIM(c_force)  == 'force')
+!-
+! Retrieve the number of arguments
+  READ (UNIT=*,FMT=*) f_nb
+  f_nb_in = f_nb-1
+!-
+! Retrieve the file names
+  ALLOCATE(f_nm(f_nb))
+  DO iw=1,f_nb
+    READ (UNIT=*,FMT='(A)') f_nm(iw)
+  ENDDO
+!-
+! Allocate and initialize the array of file access identifiers
+  ALLOCATE(f_a_id(f_nb_in)); f_a_id(:) = -1;
+!-
+  IF (i_v_lev >= 1) THEN
+    WRITE (UNIT=*,FMT='("")')
+    WRITE (UNIT=*,FMT='(" verbosity level : ",I4)') i_v_lev
+    WRITE (UNIT=*,FMT='(" executing  mode : ",A)') TRIM(c_force)
+    WRITE (UNIT=*,FMT='(" number of args  : ",I4)') f_nb
+    WRITE (UNIT=*,FMT='(" Input  files :")')
+    DO iw=1,f_nb_in
+      WRITE (*,'("   ",A)') TRIM(f_nm(iw))
+    ENDDO
+    WRITE (UNIT=*,FMT='(" Output file  :")')
+    WRITE (*,'("   ",A)') TRIM(f_nm(f_nb))
+!-- time initializations
+    CALL system_clock &
+ &   (count=nb_cc_ini,count_rate=nb_cc_sec,count_max=nb_cc_max)
+    CALL cpu_time (t_cpu_ini)
+  ENDIF
+!-
+!---------------------------------------------------
+! Retrieve basic informations from the first file
+!---------------------------------------------------
+!-
+! Open the first file
+  CALL flrb_of (1,f_id_i)
+!-
+! Get the attribute "DOMAIN_number_total"
+  CALL fliogeta (f_id_i,"?","DOMAIN_number_total",d_n_t)
+!-
+! Validate the number of input files :
+! should be equal to the total number
+! of domains used in the simulation
+  IF (d_n_t /= f_nb_in) THEN
+    IF (l_force) THEN
+      iw = 2
+    ELSE
+      iw = 3
+    ENDIF
+    CALL ipslerr (iw,"flio_rbld", &
+ &   "The number of input files", &
+ &   "is not equal to the number of DOMAINS"," ")
+  ENDIF
+!-
+! Retrieve the basic characteristics of the first input file
+  CALL flioinqf &
+ & (f_id_i,nb_dim=f_d_nb,nb_var=f_v_nb,nb_gat=f_a_nb,id_uld=f_d_ul)
+!-
+! Build the list of the names of the
+! dimensions/variables/global_attributes and retrieve
+! the unlimited_dimension name from the first input file
+  ALLOCATE(f_d_nm(f_d_nb),f_v_nm(f_v_nb),f_a_nm(f_a_nb))
+  CALL flioinqn (f_id_i,cn_dim=f_d_nm,cn_var=f_v_nm, &
+ &                      cn_gat=f_a_nm,cn_uld=f_u_nm)
+!-
+! Build the list of the dimensions identifiers and lengths
+  ALLOCATE(f_d_i(f_d_nb),f_d_l(f_d_nb))
+  CALL flioinqf (f_id_i,id_dim=f_d_i,ln_dim=f_d_l)
+!-
+! Close the file
+  CALL flrb_cf (1,.FALSE.)
+!-
+! Check if the number of needed files is greater than
+! the maximum number of simultaneously opened files.
+! In that case, open and close model files for each reading,
+! otherwise keep the "flio" identifiers of the opened files.
+  l_ocf = (f_nb > flio_max_files)
+!-
+!----------------------------------------------------
+! Retrieve domain informations for each input file
+!----------------------------------------------------
+!-
+  DO iw=1,f_nb_in
+!---
+    CALL flrb_of (iw,f_id_i)
+!---
+    IF (iw > 1) THEN
+      c_wn1 = "DOMAIN_number_total"
+      CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+      IF (l_ex) THEN
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),i_ntd)
+        IF (i_ntd /= d_n_t) THEN
+          CALL ipslerr (3,"flio_rbld", &
+ &        "File      : "//TRIM(f_nm(iw)), &
+ &        "Attribute : "//TRIM(c_wn1), &
+ &        "not equal to the one of the first file")
+        ENDIF
+      ELSE
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "Attribute : "//TRIM(c_wn1),"not found")
+      ENDIF
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_dimensions_ids"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      ALLOCATE(dom_att(a_l))
+      CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+      IF (iw == 1) THEN
+        IF (ANY(dom_att(:) == f_d_ul)) THEN
+          CALL ipslerr (3,"flio_rbld", &
+ &         "File      : "//TRIM(f_nm(iw)), &
+ &         "Attribute : "//TRIM(c_wn1), &
+ &         "contains the unlimited dimension")
+        ENDIF
+        ALLOCATE (d_d_i(a_l))
+        d_d_i(:) = dom_att(:)
+      ELSEIF (SIZE(dom_att) /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the one of the first file")
+      ELSEIF (ANY(dom_att(:) /= d_d_i(:))) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "Attribute : "//TRIM(c_wn1), &
+ &       "not equal to the one of the first file")
+      ENDIF
+      DEALLOCATE(dom_att)
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_size_global"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      IF (a_l /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the size of DOMAIN_dimensions_ids")
+      ELSE
+        ALLOCATE(dom_att(a_l))
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+        IF (iw == 1) THEN
+          ALLOCATE (d_s_g(a_l))
+          d_s_g(:)=dom_att(:)
+        ELSEIF (ANY(dom_att(:) /= d_s_g(:))) THEN
+          CALL ipslerr (3,"flio_rbld", &
+ &         "File      : "//TRIM(f_nm(iw)), &
+ &         "Attribute : "//TRIM(c_wn1), &
+ &         "not equal to the one of the first file")
+        ENDIF
+        DEALLOCATE(dom_att)
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_size_local"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      IF (a_l /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the size of DOMAIN_dimensions_ids")
+      ELSE
+        ALLOCATE(dom_att(a_l))
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+        IF (iw == 1) THEN
+          ALLOCATE (d_s_l(a_l,f_nb_in))
+        ENDIF
+        d_s_l(:,iw)=dom_att(:)
+        DEALLOCATE(dom_att)
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_position_first"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      IF (a_l /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the size of DOMAIN_dimensions_ids")
+      ELSE
+        ALLOCATE(dom_att(a_l))
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+        IF (iw == 1) THEN
+          ALLOCATE (d_p_f(a_l,f_nb_in))
+        ENDIF
+        d_p_f(:,iw)=dom_att(:)
+        DEALLOCATE(dom_att)
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_position_last"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      IF (a_l /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the size of DOMAIN_dimensions_ids")
+      ELSE
+        ALLOCATE(dom_att(a_l))
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+        IF (iw == 1) THEN
+          ALLOCATE (d_p_l(a_l,f_nb_in))
+        ENDIF
+        d_p_l(:,iw)=dom_att(:)
+        DEALLOCATE(dom_att)
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_halo_size_start"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      IF (a_l /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the size of DOMAIN_dimensions_ids")
+      ELSE
+        ALLOCATE(dom_att(a_l))
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+        IF (iw == 1) THEN
+          ALLOCATE (d_h_s(a_l,f_nb_in))
+        ENDIF
+        d_h_s(:,iw)=dom_att(:)
+        DEALLOCATE(dom_att)
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_halo_size_end"
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      IF (a_l /= SIZE(d_d_i)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "size of the attribute : "//TRIM(c_wn1), &
+ &       "not equal to the size of DOMAIN_dimensions_ids")
+      ELSE
+        ALLOCATE(dom_att(a_l))
+        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
+        IF (iw == 1) THEN
+          ALLOCATE (d_h_e(a_l,f_nb_in))
+        ENDIF
+        d_h_e(:,iw)=dom_att(:)
+        DEALLOCATE(dom_att)
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    c_wn1 = "DOMAIN_type"
+    c_wn2 = " "
+    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
+    IF (l_ex) THEN
+      CALL fliogeta (f_id_i,"?",TRIM(c_wn1),c_wn2)
+      CALL strlowercase (c_wn2)
+      IF (iw == 1) THEN
+        IF (    (TRIM(c_wn2) == "box") &
+ &          .OR.(TRIM(c_wn2) == "apple") ) THEN
+          c_d_n = c_wn2
+        ELSE
+          CALL ipslerr (3,"flio_rbld", &
+ &         "File      : "//TRIM(f_nm(iw)), &
+ &         "Attribute : "//TRIM(c_wn1), &
+ &         "type "//TRIM(c_wn2)//" not (yet) supported")
+        ENDIF
+      ELSEIF (TRIM(c_wn2) /= TRIM(c_d_n)) THEN
+        CALL ipslerr (3,"flio_rbld", &
+ &       "File      : "//TRIM(f_nm(iw)), &
+ &       "Attribute : "//TRIM(c_wn1), &
+ &       "not equal to the one of the first file")
+      ENDIF
+    ELSE
+      CALL ipslerr (3,"flio_rbld", &
+ &     "File      : "//TRIM(f_nm(iw)), &
+ &     "Attribute : "//TRIM(c_wn1),"not found")
+    ENDIF
+!---
+    CALL flrb_cf (iw,l_ocf)
+!---
+  ENDDO
+!-
+  IF (i_v_lev >= 2) THEN
+    WRITE (UNIT=*,FMT='("")')
+    WRITE (*,'(" From the first file : ")')
+    WRITE (*,'("   Number of dimensions : ",I2)') f_d_nb
+    WRITE (*,'("     Idents  : ",(10(1X,I4),:))') f_d_i(1:f_d_nb)
+    WRITE (*,'("     Lengths : ",(10(1X,I4),:))') f_d_l(1:f_d_nb)
+    WRITE (*,'("     Names: ")')
+    DO i=1,f_d_nb
+      WRITE (*,'("       """,A,"""")') TRIM(f_d_nm(i))
+    ENDDO
+    IF (f_d_ul > 0) THEN
+      WRITE (*,'("   Unlimited dimension id : ",I2)') f_d_i(f_d_ul)
+    ENDIF
+    WRITE (*,'("   Number of variables  : ",I2)') f_v_nb
+    WRITE (*,'("     Names: ")')
+    DO i=1,f_v_nb
+      WRITE (*,'("       """,A,"""")') TRIM(f_v_nm(i))
+    ENDDO
+    WRITE (*,'("   Number of global attributes : ",I2)') f_a_nb
+    WRITE (*,'("     Names: ")')
+    DO i=1,f_a_nb
+      WRITE (*,'("       """,A,"""")') TRIM(f_a_nm(i))
+    ENDDO
+  ENDIF
+  IF (i_v_lev >= 3) THEN
+    WRITE (UNIT=*,FMT='("")')
+    WRITE (*,'(" From input files : ")')
+    WRITE (*,'("   Total number of DOMAINS : ",I4)') d_n_t
+    WRITE (*,'("   DOMAIN_dimensions_ids :",(10(1X,I5),:))') d_d_i(:)
+    WRITE (*,'("   DOMAIN_size_global    :",(10(1X,I5),:))') d_s_g(:)
+    WRITE (*,'("   DOMAIN_type           : """,(A),"""")') TRIM(c_d_n)
+    DO iw=1,f_nb_in
+      WRITE (*,'("   File   : ",A)') TRIM(f_nm(iw))
+      WRITE (*,'("     d_s_l  :",(10(1X,I5),:))') d_s_l(:,iw)
+      WRITE (*,'("     d_p_f  :",(10(1X,I5),:))') d_p_f(:,iw)
+      WRITE (*,'("     d_p_l  :",(10(1X,I5),:))') d_p_l(:,iw)
+      WRITE (*,'("     d_h_s  :",(10(1X,I5),:))') d_h_s(:,iw)
+      IF (TRIM(c_d_n) == "apple") THEN
+        IF (COUNT(d_h_s(:,iw) /= 0) > 1) THEN
+          CALL ipslerr (3,"flio_rbld", &
+ &          "Beginning offset is not yet supported", &
+ &          "for more than one dimension"," ")
+        ENDIF
+      ENDIF
+      WRITE (*,'("     d_h_e  :",(10(1X,I5),:))') d_h_e(:,iw)
+      IF (TRIM(c_d_n) == "apple") THEN
+        IF (COUNT(d_h_e(:,iw) /= 0) > 1) THEN
+          CALL ipslerr (3,"flio_rbld", &
+ &          "Ending offset is not yet supported", &
+ &          "for more than one dimension"," ")
+        ENDIF
+      ENDIF
+    ENDDO
+  ENDIF
+!-
+!---------------------------------------
+! Create the dimensionned output file
+!---------------------------------------
+!-
+! Define the dimensions used in the output file
+  DO id=1,f_d_nb
+    DO i=1,SIZE(d_d_i)
+      IF (f_d_i(id) == d_d_i(i)) THEN
+        f_d_l(id) = d_s_g(i)
+      ENDIF
+    ENDDO
+  ENDDO
+!-
+  IF (f_d_ul > 0) THEN
+    i = f_d_l(f_d_ul); f_d_l(f_d_ul) = -1;
+  ENDIF
+!-
+! Create the output file
+  CALL fliocrfd (TRIM(f_nm(f_nb)),f_d_nm,f_d_l,f_id_o,c_f_n=c_wn1)
+!-
+  IF (f_d_ul > 0) THEN
+    f_d_l(f_d_ul) = i; itmin = 1; itmax = f_d_l(f_d_ul);
+  ELSE
+    itmin = 1; itmax = 1;
+  ENDIF
+!-
+! open the first input file used to build the output file
+!-
+  CALL flrb_of (1,f_id_i1)
+!-
+! define the global attributes in the output file
+! copy all global attributes except those beginning by "DOMAIN_"
+! eventually actualize the "file_name" attribute
+!-
+  DO ia=1,f_a_nb
+    IF (INDEX(TRIM(f_a_nm(ia)),"DOMAIN_") == 1)  CYCLE
+    IF (TRIM(f_a_nm(ia)) == "file_name") THEN
+      CALL flioputa (f_id_o,"?",TRIM(f_a_nm(ia)),TRIM(c_wn1))
+    ELSE
+      CALL fliocpya (f_id_i1,"?",TRIM(f_a_nm(ia)),f_id_o,"?")
+    ENDIF
+  ENDDO
+!-
+! define the variables in the output file
+!-
+  ALLOCATE(v_d_nb(f_v_nb)); v_d_nb(:) = 0;
+  ALLOCATE(v_d_ul(f_v_nb)); v_d_ul(:) = 0;
+  ALLOCATE(v_type(f_v_nb),v_d_i(flio_max_var_dims,f_v_nb));
+  DO iv=1,f_v_nb
+!-- get variable informations
+    CALL flioinqv &
+ &   (f_id_i1,TRIM(f_v_nm(iv)),l_ex,v_t=v_type(iv), &
+ &    nb_dims=v_d_nb(iv),id_dims=d_i,nb_atts=v_a_nb)
+!-- define the new variable
+    IF (v_d_nb(iv) == 0) THEN
+      CALL fliodefv &
+ &     (f_id_o,TRIM(f_v_nm(iv)),v_t=v_type(iv))
+    ELSE
+      CALL fliodefv &
+ &     (f_id_o,TRIM(f_v_nm(iv)),d_i(1:v_d_nb(iv)),v_t=v_type(iv))
+      DO iw=1,v_d_nb(iv)
+        IF (f_d_ul > 0) THEN
+          IF (d_i(iw) == f_d_ul) THEN
+            v_d_ul(iv) = iw
+          ENDIF
+        ENDIF
+      ENDDO
+      v_d_i(1:v_d_nb(iv),iv) = d_i(1:v_d_nb(iv))
+    ENDIF
+!-- copy all variable attributes
+    IF (v_a_nb > 0) THEN
+      ALLOCATE(v_a_nm(v_a_nb))
+      CALL flioinqv (f_id_i1,TRIM(f_v_nm(iv)),l_ex,cn_atts=v_a_nm)
+      DO ia=1,v_a_nb
+        CALL fliocpya &
+ &       (f_id_i1,TRIM(f_v_nm(iv)),TRIM(v_a_nm(ia)), &
+ &        f_id_o,TRIM(f_v_nm(iv)))
+      ENDDO
+      DEALLOCATE(v_a_nm)
+    ENDIF
+  ENDDO
+!-
+! update valid_min valid_max attributes values
+!-
+  CALL flrb_rg
+!-
+!------------------------
+! Fill the output file
+!------------------------
+!-
+  DO ik=1,2
+    l_uld = (ik /= 1)
+    IF (l_uld) THEN
+      it1=itmin; it2=itmax;
+    ELSE
+      it1=1; it2=1;
+    ENDIF
+    DO it=it1,it2
+      DO iv=1,f_v_nb
+        IF (    (.NOT.l_uld.AND.(v_d_ul(iv) > 0)) &
+ &          .OR.(l_uld.AND.(v_d_ul(iv) <= 0)) ) THEN
+          CYCLE
+        ENDIF
+        IF (i_v_lev >= 3) THEN
+          WRITE (UNIT=*,FMT='("")')
+          IF (l_uld) THEN
+            WRITE (UNIT=*,FMT=*) "time step     : ",it
+          ENDIF
+          WRITE (UNIT=*,FMT=*) "variable      : ",TRIM(f_v_nm(iv))
+          WRITE (UNIT=*,FMT=*) "var unlim dim : ",v_d_ul(iv)
+        ENDIF
+!------ do the variable contains dimensions to be recombined ?
+        l_cgd = .FALSE.
+        i_n = 1
+        DO i=1,SIZE(d_d_i)
+          l_cgd = ANY(v_d_i(1:v_d_nb(iv),iv) == d_d_i(i))
+          l_cgd = l_cgd.AND.ANY(d_s_l(i,1:f_nb_in) /= d_s_g(i))
+          IF (l_cgd) THEN
+            i_n = f_nb_in
+              EXIT
+          ENDIF
+        ENDDO
+        IF (v_d_nb(iv) > 0) THEN
+!-------- Allocate io_i,io_n,ia_sm,io_sm,io_cm
+          i = v_d_nb(iv)
+          ALLOCATE(io_i(i),io_n(i),ia_sm(i),io_sm(i),io_cm(i))
+!-------- Default definition of io_i,io_n,io_sm,io_cm
+          io_i(:) = 1; io_n(:) = f_d_l(v_d_i(1:v_d_nb(iv),iv));
+          ia_sm(:) = 1; io_sm(:) = 1;
+          IF (v_d_ul(iv) > 0) THEN
+            io_i(v_d_ul(iv))=it
+            io_n(v_d_ul(iv))=1
+            io_sm(v_d_ul(iv))=it
+          ENDIF
+          io_cm(:) = io_n(:);
+!-------- If needed, allocate offset
+          l_o_f = .FALSE.; l_o_m = .TRUE.; l_o_l = .FALSE.;
+          IF (TRIM(c_d_n) == "apple") THEN
+            ALLOCATE(ia_sf(i),io_sf(i),io_cf(i))
+            ALLOCATE(ia_sl(i),io_sl(i),io_cl(i))
+            ia_sf(:) = 1; io_sf(:) = 1; io_cf(:) = io_n(:);
+            ia_sl(:) = 1; io_sl(:) = 1; io_cl(:) = io_n(:);
+            IF (v_d_ul(iv) > 0) THEN
+              io_sf(v_d_ul(iv))=it
+              io_sl(v_d_ul(iv))=it
+            ENDIF
+          ENDIF
+        ENDIF
+!------
+        DO i_i=1,i_n
+          IF (l_cgd) THEN
+!---------- the variable contains dimensions to be recombined
+!-----------
+!---------- open each file containing a small piece of data
+            CALL flrb_of (i_i,f_id_i)
+!-----------
+!---------- do the variable has offset at first/last block ?
+            l_cof = .FALSE.; l_col = .FALSE.;
+            IF (TRIM(c_d_n) == "apple") THEN
+              L_BF: DO id=1,v_d_nb(iv)
+                DO i=1,SIZE(d_d_i)
+                  IF (v_d_i(id,iv) == d_d_i(i)) THEN
+                    l_cof = (d_h_s(i,i_i) /= 0)
+                    IF (l_cof)  EXIT L_BF
+                  ENDIF
+                ENDDO
+              ENDDO L_BF
+              L_BL: DO id=1,v_d_nb(iv)
+                DO i=1,SIZE(d_d_i)
+                  IF (v_d_i(id,iv) == d_d_i(i)) THEN
+                    l_col = (d_h_e(i,i_i) /= 0)
+                    IF (l_col)  EXIT L_BL
+                  ENDIF
+                ENDDO
+              ENDDO L_BL
+            ENDIF
+!---------- if needed, redefine start and count for dimensions
+            l_o_f = .FALSE.; l_o_m = .TRUE.; l_o_l = .FALSE.;
+            DO id=1,v_d_nb(iv)
+              DO i=1,SIZE(d_d_i)
+                IF (v_d_i(id,iv) == d_d_i(i)) THEN
+                  io_n(id) = d_p_l(i,i_i)-d_p_f(i,i_i)+1
+                  ia_sm(id) = 1
+                  io_sm(id) = d_p_f(i,i_i)
+                  io_cm(id) = io_n(id)
+                  IF     (TRIM(c_d_n) == "box") THEN
+                    ia_sm(id) = ia_sm(id)+d_h_s(i,i_i)
+                    io_sm(id) = io_sm(id)+d_h_s(i,i_i)
+                    io_cm(id) = io_cm(id)-d_h_s(i,i_i)-d_h_e(i,i_i)
+                  ELSEIF (TRIM(c_d_n) == "apple") THEN
+                    IF (l_cof) THEN
+                      IF (d_h_s(i,i_i) /= 0) THEN
+                        ia_sf(id) = 1+d_h_s(i,i_i)
+                        io_sf(id) = d_p_f(i,i_i)+d_h_s(i,i_i)
+                        io_cf(id) = io_n(id)-d_h_s(i,i_i)
+                      ELSE
+                        io_sf(id) = d_p_f(i,i_i)
+                        io_cf(id) = 1
+                        ia_sm(id) = ia_sm(id)+1
+                        io_sm(id) = io_sm(id)+1
+                        io_cm(id) = io_cm(id)-1
+                        l_o_f = .TRUE.
+                      ENDIF
+                    ENDIF
+                    IF (l_col) THEN
+                      IF (d_h_e(i,i_i) /= 0) THEN
+                        ia_sl(id) = 1
+                        io_sl(id) = d_p_f(i,i_i)
+                        io_cl(id) = io_n(id)-d_h_e(i,i_i)
+                      ELSE
+                        io_cm(id) = io_cm(id)-1
+                        ia_sl(id) = 1+io_n(id)-1
+                        io_sl(id) = d_p_f(i,i_i)+io_n(id)-1
+                        io_cl(id) = 1
+                        l_o_l = .TRUE.
+                      ENDIF
+                    ENDIF
+                  ENDIF
+                ENDIF
+              ENDDO
+            ENDDO
+            l_o_m = ALL(io_cm > 0)
+          ELSE
+!---------- the data can be read/write in one piece
+            f_id_i = f_id_i1
+          ENDIF
+!---------
+          IF (i_v_lev >= 3) THEN
+            WRITE (UNIT=*,FMT=*) &
+ &            TRIM(f_nm(i_i))//" - "//TRIM(f_v_nm(iv))
+            WRITE (UNIT=*,FMT=*) "io_i  : ",io_i(:)
+            WRITE (UNIT=*,FMT=*) "io_n  : ",io_n(:)
+            WRITE (UNIT=*,FMT=*) "l_o_f : ",l_o_f
+            IF (l_o_f) THEN
+              WRITE (UNIT=*,FMT=*) "ia_sf : ",ia_sf(:)
+              WRITE (UNIT=*,FMT=*) "io_sf : ",io_sf(:)
+              WRITE (UNIT=*,FMT=*) "io_cf : ",io_cf(:)
+            ENDIF
+            WRITE (UNIT=*,FMT=*) "l_o_m : ",l_o_m
+            IF (l_o_m) THEN
+              WRITE (UNIT=*,FMT=*) "ia_sm : ",ia_sm(:)
+              WRITE (UNIT=*,FMT=*) "io_sm : ",io_sm(:)
+              WRITE (UNIT=*,FMT=*) "io_cm : ",io_cm(:)
+            ENDIF
+            WRITE (UNIT=*,FMT=*) "l_o_l : ",l_o_l
+            IF (l_o_l) THEN
+              WRITE (UNIT=*,FMT=*) "ia_sl : ",ia_sl(:)
+              WRITE (UNIT=*,FMT=*) "io_sl : ",io_sl(:)
+              WRITE (UNIT=*,FMT=*) "io_cl : ",io_cl(:)
+            ENDIF
+          ENDIF
+!---------
+!-------- Cases according to the type, shape and offsets of the data
+!---------
+          SELECT CASE (v_type(iv))
+!?INTEGERS of KIND 1 are not supported on all computers
+!?        CASE (flio_i1) !--- INTEGER 1
+!?          SELECT CASE (v_d_nb(iv))
+!?          CASE (0) !--- Scalar
+!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_0d)
+!?            CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i1_0d)
+!?          CASE (1) !--- 1d array
+!?            ALLOCATE(i1_1d(io_n(1)))
+!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_1d, &
+!? &            start=io_i(:),count=io_n(:))
+!?            IF (l_o_f) THEN
+!?              ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_1d(ib(1):ie(1)), &
+!? &              start=io_sf(:),count=io_cf(:))
+!?            ENDIF
+!?            IF (l_o_m) THEN
+!?              ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_1d(ib(1):ie(1)), &
+!? &              start=io_sm(:),count=io_cm(:))
+!?            ENDIF
+!?            IF (l_o_l) THEN
+!?              ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_1d(ib(1):ie(1)), &
+!? &              start=io_sl(:),count=io_cl(:))
+!?            ENDIF
+!?            DEALLOCATE(i1_1d)
+!?          CASE (2) !--- 2d array
+!?            ALLOCATE(i1_2d(io_n(1),io_n(2)))
+!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_2d, &
+!? &            start=io_i(:),count=io_n(:))
+!?            IF (l_o_f) THEN
+!?              ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_2d(ib(1):ie(1),ib(2):ie(2)), &
+!? &              start=io_sf(:),count=io_cf(:))
+!?            ENDIF
+!?            IF (l_o_m) THEN
+!?              ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_2d(ib(1):ie(1),ib(2):ie(2)), &
+!? &              start=io_sm(:),count=io_cm(:))
+!?            ENDIF
+!?            IF (l_o_l) THEN
+!?              ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_2d(ib(1):ie(1),ib(2):ie(2)), &
+!? &              start=io_sl(:),count=io_cl(:))
+!?            ENDIF
+!?            DEALLOCATE(i1_2d)
+!?          CASE (3) !--- 3d array
+!?            ALLOCATE(i1_3d(io_n(1),io_n(2),io_n(3)))
+!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_3d, &
+!? &            start=io_i(:),count=io_n(:))
+!?            IF (l_o_f) THEN
+!?              ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+!? &              start=io_sf(:),count=io_cf(:))
+!?            ENDIF
+!?            IF (l_o_m) THEN
+!?              ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+!? &              start=io_sm(:),count=io_cm(:))
+!?            ENDIF
+!?            IF (l_o_l) THEN
+!?              ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+!? &              start=io_sl(:),count=io_cl(:))
+!?            ENDIF
+!?            DEALLOCATE(i1_3d)
+!?          CASE (4) !--- 4d array
+!?            ALLOCATE(i1_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
+!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_4d, &
+!? &            start=io_i(:),count=io_n(:))
+!?            IF (l_o_f) THEN
+!?              ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_4d(ib(1):ie(1),ib(2):ie(2), &
+!? &                    ib(3):ie(3),ib(4):ie(4)), &
+!? &              start=io_sf(:),count=io_cf(:))
+!?            ENDIF
+!?            IF (l_o_m) THEN
+!?              ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_4d(ib(1):ie(1),ib(2):ie(2), &
+!? &                    ib(3):ie(3),ib(4):ie(4)), &
+!? &              start=io_sm(:),count=io_cm(:))
+!?            ENDIF
+!?            IF (l_o_l) THEN
+!?              ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_4d(ib(1):ie(1),ib(2):ie(2), &
+!? &                    ib(3):ie(3),ib(4):ie(4)), &
+!? &              start=io_sl(:),count=io_cl(:))
+!?            ENDIF
+!?            DEALLOCATE(i1_4d)
+!?          CASE (5) !--- 5d array
+!?            ALLOCATE(i1_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
+!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_5d, &
+!? &            start=io_i(:),count=io_n(:))
+!?            IF (l_o_f) THEN
+!?              ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+!? &                    ib(4):ie(4),ib(5):ie(5)), &
+!? &              start=io_sf(:),count=io_cf(:))
+!?            ENDIF
+!?            IF (l_o_m) THEN
+!?              ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+!? &                    ib(4):ie(4),ib(5):ie(5)), &
+!? &              start=io_sm(:),count=io_cm(:))
+!?            ENDIF
+!?            IF (l_o_l) THEN
+!?              ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
+!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+!? &              i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+!? &                    ib(4):ie(4),ib(5):ie(5)), &
+!? &              start=io_sl(:),count=io_cl(:))
+!?            ENDIF
+!?            DEALLOCATE(i1_5d)
+!?          END SELECT
+!?        CASE (flio_i2) !--- INTEGER 2
+          CASE (flio_i1,flio_i2) !--- INTEGER 1/INTEGER 2
+            SELECT CASE (v_d_nb(iv))
+            CASE (0) !--- Scalar
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_0d)
+              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i2_0d)
+            CASE (1) !--- 1d array
+              ALLOCATE(i2_1d(io_n(1)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_1d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_1d(ib(1):ie(1)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_1d(ib(1):ie(1)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_1d(ib(1):ie(1)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i2_1d)
+            CASE (2) !--- 2d array
+              ALLOCATE(i2_2d(io_n(1),io_n(2)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_2d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i2_2d)
+            CASE (3) !--- 3d array
+              ALLOCATE(i2_3d(io_n(1),io_n(2),io_n(3)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_3d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i2_3d)
+            CASE (4) !--- 4d array
+              ALLOCATE(i2_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_4d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i2_4d)
+            CASE (5) !--- 5d array
+              ALLOCATE(i2_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_5d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i2_5d)
+            END SELECT
+          CASE (flio_i4) !--- INTEGER 4
+            SELECT CASE (v_d_nb(iv))
+            CASE (0) !--- Scalar
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_0d)
+              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i4_0d)
+            CASE (1) !--- 1d array
+              ALLOCATE(i4_1d(io_n(1)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_1d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_1d(ib(1):ie(1)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_1d(ib(1):ie(1)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_1d(ib(1):ie(1)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i4_1d)
+            CASE (2) !--- 2d array
+              ALLOCATE(i4_2d(io_n(1),io_n(2)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_2d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i4_2d)
+            CASE (3) !--- 3d array
+              ALLOCATE(i4_3d(io_n(1),io_n(2),io_n(3)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_3d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i4_3d)
+            CASE (4) !--- 4d array
+              ALLOCATE(i4_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_4d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i4_4d)
+            CASE (5) !--- 5d array
+              ALLOCATE(i4_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_5d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(i4_5d)
+            END SELECT
+          CASE (flio_r4) !--- REAL 4
+            SELECT CASE (v_d_nb(iv))
+            CASE (0) !--- Scalar
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_0d)
+              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),r4_0d)
+            CASE (1) !--- 1d array
+              ALLOCATE(r4_1d(io_n(1)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_1d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_1d(ib(1):ie(1)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_1d(ib(1):ie(1)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_1d(ib(1):ie(1)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r4_1d)
+            CASE (2) !--- 2d array
+              ALLOCATE(r4_2d(io_n(1),io_n(2)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_2d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r4_2d)
+            CASE (3) !--- 3d array
+              ALLOCATE(r4_3d(io_n(1),io_n(2),io_n(3)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_3d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r4_3d)
+            CASE (4) !--- 4d array
+              ALLOCATE(r4_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_4d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r4_4d)
+            CASE (5) !--- 5d array
+              ALLOCATE(r4_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_5d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r4_5d)
+            END SELECT
+          CASE (flio_r8) !--- REAL 8
+            SELECT CASE (v_d_nb(iv))
+            CASE (0) !--- Scalar
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_0d)
+              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),r8_0d)
+            CASE (1) !--- 1d array
+              ALLOCATE(r8_1d(io_n(1)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_1d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_1d(ib(1):ie(1)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_1d(ib(1):ie(1)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_1d(ib(1):ie(1)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r8_1d)
+            CASE (2) !--- 2d array
+              ALLOCATE(r8_2d(io_n(1),io_n(2)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_2d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_2d(ib(1):ie(1),ib(2):ie(2)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r8_2d)
+            CASE (3) !--- 3d array
+              ALLOCATE(r8_3d(io_n(1),io_n(2),io_n(3)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_3d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r8_3d)
+            CASE (4) !--- 4d array
+              ALLOCATE(r8_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_4d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_4d(ib(1):ie(1),ib(2):ie(2), &
+ &                      ib(3):ie(3),ib(4):ie(4)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r8_4d)
+            CASE (5) !--- 5d array
+              ALLOCATE(r8_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
+              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_5d, &
+ &              start=io_i(:),count=io_n(:))
+              IF (l_o_f) THEN
+                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sf(:),count=io_cf(:))
+              ENDIF
+              IF (l_o_m) THEN
+                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sm(:),count=io_cm(:))
+              ENDIF
+              IF (l_o_l) THEN
+                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
+                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
+ &                r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
+ &                      ib(4):ie(4),ib(5):ie(5)), &
+ &                start=io_sl(:),count=io_cl(:))
+              ENDIF
+              DEALLOCATE(r8_5d)
+            END SELECT
+          END SELECT
+!-------- eventually close each file containing a small piece of data
+          CALL flrb_cf (i_i,l_ocf.AND.l_cgd.AND.(i_i /= 1))
+        ENDDO
+!------ If needed, deallocate io_* arrays
+        IF (v_d_nb(iv) > 0) THEN
+          DEALLOCATE(io_i,io_n,ia_sm,io_sm,io_cm)
+          IF (TRIM(c_d_n) == "apple") THEN
+            DEALLOCATE(ia_sf,io_sf,io_cf)
+            DEALLOCATE(ia_sl,io_sl,io_cl)
+          ENDIF
+        ENDIF
+      ENDDO
+    ENDDO
+  ENDDO
+!-
+!-------------------
+! Ending the work
+!-------------------
+!-
+! Close files
+  CALL flrb_cf (0,.TRUE.)
+!-
+! Deallocate
+  DEALLOCATE(f_nm,f_a_id)
+  DEALLOCATE(f_d_nm,f_v_nm,f_a_nm)
+  DEALLOCATE(f_d_i,f_d_l)
+  DEALLOCATE(v_d_nb,v_d_ul,v_type,v_d_i)
+  DEALLOCATE(d_d_i,d_s_g)
+  DEALLOCATE(d_s_l,d_p_f,d_p_l,d_h_s,d_h_e)
+!-
+  IF (i_v_lev >= 1) THEN
+!-- elapsed and cpu time computation
+    CALL cpu_time (t_cpu_end)
+    CALL system_clock(count=nb_cc_end)
+    WRITE (UNIT=*,FMT='("")')
+    WRITE (UNIT=*,fmt='(" elapsed time (s) : ",1PE11.4)') &
+ &   REAL(nb_cc_end-nb_cc_ini)/REAL(nb_cc_sec)
+    WRITE (UNIT=*,fmt='(" CPU time (s) : ",1PE11.4)') &
+ &   t_cpu_end-t_cpu_ini
+  ENDIF
+!=======
+CONTAINS
+!=======
+SUBROUTINE flrb_of (i_f_n,i_f_i)
+!---------------------------------------------------------------------
+! Open the file of number "i_f_n" if necessary,
+! and returns its identifier in "i_f_i".
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN)  :: i_f_n
+  INTEGER,INTENT(OUT) :: i_f_i
+!---------------------------------------------------------------------
+  IF (f_a_id(i_f_n) < 0) THEN
+    CALL flioopfd (TRIM(f_nm(i_f_n)),i_f_i)
+    f_a_id(i_f_n) = i_f_i
+  ELSE
+    i_f_i = f_a_id(i_f_n)
+  ENDIF
+!---------------------
+END SUBROUTINE flrb_of
+!===
+SUBROUTINE flrb_cf (i_f_n,l_cf)
+!---------------------------------------------------------------------
+! Close the file of number "i_f_n" if "l_cf" is TRUE.
+! Close all files if "i_f_n <= 0".
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN) :: i_f_n
+  LOGICAL,INTENT(IN) :: l_cf
+!---------------------------------------------------------------------
+  IF (i_f_n <= 0) THEN
+    CALL flioclo ()
+    f_a_id(:) = -1
+  ELSE
+    IF (l_cf) THEN
+      IF (f_a_id(i_f_n) < 0) THEN
+        CALL ipslerr (2,"flio_rbld", &
+ &       "The file",TRIM(f_nm(i_f_n)),"is already closed")
+      ELSE
+        CALL flioclo (f_a_id(i_f_n))
+        f_a_id(i_f_n) = -1
+      ENDIF
+    ENDIF
+  ENDIF
+!---------------------
+END SUBROUTINE flrb_cf
+!===
+SUBROUTINE flrb_rg
+!---------------------------------------------------------------------
+! Update valid_min valid_max attributes values
+!---------------------------------------------------------------------
+  INTEGER :: k,j
+  LOGICAL :: l_vmin,l_vmax
+  INTEGER(KIND=i_4) :: i4_vmin,i4_vmax
+  REAL(KIND=r_4) :: r4_vmin,r4_vmax
+  REAL(KIND=r_8) :: r8_vmin,r8_vmax
+!---------------------------------------------------------------------
+  DO k=1,f_v_nb
+!-- get attribute informations
+    CALL flioinqa &
+ &    (f_id_i1,TRIM(f_v_nm(k)),'valid_min',l_vmin,a_t=a_type)
+    CALL flioinqa &
+ &    (f_id_i1,TRIM(f_v_nm(k)),'valid_max',l_vmax,a_t=a_type)
+!---
+    IF (l_vmin.OR.l_vmax) THEN
+!---- get values of min/max
+      SELECT CASE (a_type)
+      CASE (flio_i1,flio_i2,flio_i4) !--- INTEGER 1/2/4
+        DO j=1,f_nb_in
+          CALL flrb_of (j,f_id_i)
+          IF (l_vmin) THEN
+            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",i4_0d)
+            IF (j == 1) THEN
+              i4_vmin = i4_0d
+            ELSE
+              i4_vmin = MIN(i4_vmin,i4_0d)
+            ENDIF
+          ENDIF
+          IF (l_vmax) THEN
+            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",i4_0d)
+            IF (j == 1) THEN
+              i4_vmax = i4_0d
+            ELSE
+              i4_vmax = MAX(i4_vmax,i4_0d)
+            ENDIF
+          ENDIF
+          CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
+        ENDDO
+        IF (l_vmin) THEN
+          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",i4_vmin)
+        ENDIF
+        IF (l_vmax) THEN
+          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",i4_vmax)
+        ENDIF
+      CASE (flio_r4) !--- REAL 4
+        DO j=1,f_nb_in
+          CALL flrb_of (j,f_id_i)
+          IF (l_vmin) THEN
+            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",r4_0d)
+            IF (j == 1) THEN
+              r4_vmin = r4_0d
+            ELSE
+              r4_vmin = MIN(r4_vmin,r4_0d)
+            ENDIF
+          ENDIF
+          IF (l_vmax) THEN
+            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",r4_0d)
+            IF (j == 1) THEN
+              r4_vmax = r4_0d
+            ELSE
+              r4_vmax = MAX(r4_vmax,r4_0d)
+            ENDIF
+          ENDIF
+          CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
+        ENDDO
+        IF (l_vmin) THEN
+          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",r4_vmin)
+        ENDIF
+        IF (l_vmax) THEN
+          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",r4_vmax)
+        ENDIF
+      CASE (flio_r8) !--- REAL 8
+        DO j=1,f_nb_in
+          CALL flrb_of (j,f_id_i)
+          IF (l_vmin) THEN
+            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",r8_0d)
+            IF (j == 1) THEN
+              r8_vmin = r8_0d
+            ELSE
+              r8_vmin = MIN(r8_vmin,r8_0d)
+            ENDIF
+          ENDIF
+          IF (l_vmax) THEN
+            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",r8_0d)
+            IF (j == 1) THEN
+              r8_vmax = r8_0d
+            ELSE
+              r8_vmax = MAX(r8_vmax,r8_0d)
+            ENDIF
+          ENDIF
+          CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
+        ENDDO
+        IF (l_vmin) THEN
+          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",r8_vmin)
+        ENDIF
+        IF (l_vmax) THEN
+          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",r8_vmax)
+        ENDIF
+      END SELECT
+    ENDIF
+  ENDDO
+!---------------------
+END SUBROUTINE flrb_rg
+!===
+!--------------------
+END PROGRAM flio_rbld
Index: IOIPSL/trunk/rebuild/rebuild
===================================================================
--- IOIPSL/trunk/rebuild/rebuild	(revision 5009)
+++ IOIPSL/trunk/rebuild/rebuild	(revision 5009)
@@ -0,0 +1,110 @@
+#!/bin/ksh
+#
+#$Id: rebuild 761 2009-10-26 16:30:14Z bellier $
+#
+# This software is governed by the CeCILL license
+# See IOIPSL/IOIPSL_License_CeCILL.txt
+#---------------------------------------------------------------------
+# @(#)Rebuild IOIPSL domains
+#---------------------------------------------------------------------
+function rebuild_Usage
+{
+print - "
+\"${b_n}\"
+  rebuild a model_file from several input files.
+Each input file contains the model_data for a domain.
+
+Usage :
+  ${b_n} [-h]
+  ${b_n} [-v level] [-f] -o output_file_name input_file_names
+
+Options :
+  -h         : help
+  -v O/1/2/3 : verbose mode (verbosity increasing with level)
+  -f         : executing mode
+               (execute the program even if the number of input files
+                is not equal to the total number of domains)
+"
+}
+#-
+#set -xv
+#-
+# Extract the calling sequence of the script (d_n/b_n)
+#-
+d_n=${0%/*}; b_n=${0##*/};
+#-
+# Retrieving the options
+#-
+r_v='0'; r_f='noforce'; r_o="";
+while getopts :hv:fo: V
+ do
+  case $V in
+   (h) rebuild_Usage; exit 0;;
+   (v) r_v=${OPTARG};;
+   (f) r_f='force';;
+   (o) r_o=${OPTARG};;
+   (:) print -u2 "${b_n} : missing value for option $OPTARG"; exit 2;;
+   (\?) print -u2 "${b_n} : option $OPTARG not supported"; exit 2;;
+  esac
+ done
+shift $(($OPTIND-1));
+#-
+# Validate the -v option
+#-
+case ${r_v} in
+  ( 0 | 1 | 2 | 3 );;
+  ("") r_v='0';;
+  (*)
+    print -u2 "${b_n} :";
+    print -u2 "Invalid verbosity level requested : ${r_v}";
+    print -u2 "(must be 0, 1, 2 or 3)";
+    exit 1;;
+esac
+#-
+# Validate the number of arguments
+#-
+[[ ${#} < 1 ]] && \
+ {
+  print -u2 "${b_n} : Too few arguments have been specified. (Use -h)";
+  exit 3;
+ }
+#-
+# Check for the output file name
+#-
+[[ -z ${r_o} ]] && \
+ {
+  r_o='rebuilt_file.nc';
+  print -u2 - "
+   ${b_n} : output_file_name not specified. (Use -h)
+            rebuilt_file.nc should be created."
+ }
+#-
+# Validate the names of the input files
+#-
+for i in $*;
+ do
+  [[ ! -f ${i} ]] && { echo "${i} unreachable ..."; exit 3;}
+ done
+#-
+# Create the information file for the program
+#-
+echo ${r_v} > tmp.$$;
+echo ${r_f} >> tmp.$$;
+echo $((${#}+1)) >> tmp.$$;
+for i in $*;
+ do echo ${i} >> tmp.$$;
+ done
+echo ${r_o} >> tmp.$$;
+#-
+# Create the output file
+#-
+${d_n}/flio_rbld < tmp.$$
+r_c=$?
+#-
+# Clear
+#-
+rm -f tmp.$$
+#-
+# End
+#-
+exit ${r_c};
Index: IOIPSL/trunk/tools/AA_make
===================================================================
--- IOIPSL/trunk/tools/AA_make	(revision 4999)
+++ 	(revision )
@@ -1,68 +1,0 @@
-#-
-#- $Id$
-#-
-#-Q- sxdkrz F_O = $(F_D) $(F_P) -C vsafe -size_t64 -I $(MODDIR)
-#-Q- eshpux F_O = $(F_D) $(F_P) -C vsafe -I $(MODDIR)
-#---------------------------------------------------------------------
-#- Create "tools" related to IOIPSL
-#---------------------------------------------------------------------
-
-SXMODEL_LIB = $(MODEL_LIB)
-ifeq ($(L_X),1)
-SXMODEL_LIB = $(LIBDIR)/libsxioipsl.a
-endif
-
-rbld: libioipsl $(BINDIR)/rebuild $(BINDIR)/flio_rbld
-	@echo rebuild is OK
-
-ncregular: $(BINDIR)/ncregular 
-	@echo ncregular is OK
-
-config: libioipsl $(BINDIR)/Fparser $(BINDIR)/tkparse
-	$(BINDIR)/Fparser -name IOIPSL *.f90
-	echo 'Configuration of IOIPSL done'
-
-$(BINDIR)/rebuild: ./rebuild
-	cp -p ./rebuild $(BINDIR)/rebuild
-	chmod a+rx $(BINDIR)/rebuild
-
-$(BINDIR)/flio_rbld: $(SXMODEL_LIB) flio_rbld.f90
-	$(F_C) $(F_O) -I$(NCDF_INC) flio_rbld.f90
-	$(F_L) flio_rbld.o -o $(BINDIR)/flio_rbld \
-               $(L_O) $(SXMODEL_LIB) $(NCDF_LIB)
-	chmod a+rx $(BINDIR)/flio_rbld
-	$(RM) flio_rbld.o
-
-$(BINDIR)/ncregular: ncregular.f90
-	$(F_C) $(F_O) -I$(NCDF_INC) ncregular.f90
-	$(F_L) -o $(BINDIR)/ncregular ncregular.o $(L_O) $(NCDF_LIB)
-	$(RM) ncregular.o
-
-$(BINDIR)/Fparser: Fparser.o
-	$(F_L) -o $(BINDIR)/Fparser Fparser.o -L$(LIBDIR) -lioipsl
-	$(RM) Fparser.o
-
-Fparser.o: Fparser.f90
-	$(F_C) $(F_O) Fparser.f90
-
-$(BINDIR)/tkparse: tkparse.o tkcond.o tkgen.o
-	$(C_L) -o $(BINDIR)/tkparse tkparse.o tkcond.o tkgen.o
-	$(RM) tkparse.o tkcond.o tkgen.o
-
-tkparse.o: tkparse.c tkparse.h
-	$(C_C) $(C_O) -o tkparse.o tkparse.c
-
-tkcond.o: tkcond.c tkparse.h
-	$(C_C) $(C_O) -o tkcond.o tkcond.c
-
-tkgen.o: tkgen.c tkparse.h
-	$(C_C) $(C_O) -o tkgen.o tkgen.c
-
-libioipsl:
-	(cd ../src; $(M_K) -f Makefile)
-
-clean:
-	$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L i.*.f90 *.M
-	$(RM) $(BINDIR)/rebuild $(BINDIR)/flio_rbld
-	$(RM) $(BINDIR)/ncregular $(BINDIR)/Fparser $(BINDIR)/tkparse
-
Index: IOIPSL/trunk/tools/AA_make.ldef
===================================================================
--- IOIPSL/trunk/tools/AA_make.ldef	(revision 4999)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#-
-#- $Id$
-#-
-#---------------------------------------------------------------------
-#- Local parameters related to the "tools" of IOIPSL (rebuild, config)
-#---------------------------------------------------------------------
-SHELL = /bin/ksh
-#---------------------------------------------------------------------
-LIBDIR = ../../../lib
-BINDIR = ../../../bin
-MODDIR = $(LIBDIR)
-#---------------------------------------------------------------------
-P_P =
-MODEL_LIB = $(LIBDIR)/libioipsl.a
Index: IOIPSL/trunk/tools/Fparser.f90
===================================================================
--- IOIPSL/trunk/tools/Fparser.f90	(revision 4999)
+++ 	(revision )
@@ -1,793 +1,0 @@
-PROGRAM fparser
-!-
-!$Id$
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-
-  USE stringop
-
-  IMPLICIT NONE
-  !
-  !
-  !     Parses the code to create the Config.in Config.default and Config.help
-  !     which are used by the tk shell.
-  !
-  !
-  INTEGER nbkeymax, nbhelpmax, nbcasemax, nbsourmax, nbelmax
-  PARAMETER (nbkeymax=100, nbhelpmax=50, nbcasemax=50, nbsourmax=20,nbelmax=nbhelpmax+10)
-  INTEGER nbfilesmax
-  PARAMETER (nbfilesmax=150)
-
-  !
-  CHARACTER*120 :: configs(nbkeymax,nbelmax)
-  CHARACTER*120 :: tmp_help, tmp_key, tmp_desc, tmp_def
-  INTEGER :: keylen(nbkeymax), nbkeys
-  INTEGER :: key_pos(nbkeymax), help_pos(nbkeymax,2), def_pos(nbkeymax,2)
-  INTEGER :: des_pos(nbkeymax), IF_pos(nbkeymax)
-  CHARACTER*6 TYPE_op(nbkeymax)
-  !
-  CHARACTER*120 :: def_out(nbkeymax, nbhelpmax)
-  INTEGER :: nbdef_out(nbkeymax)
-  !
-  CHARACTER*120 :: tke
-  !
-  CHARACTER*2 :: nbstr
-  !
-  CHARACTER*80 :: files(nbfilesmax), source(nbsourmax), filetmp
-  CHARACTER*80 :: tmp, main_name
-  CHARACTER*120 :: keycase(nbcasemax), tmp_CASE
-  INTEGER :: nbcase, ii, find, nbsource
-  LOGICAL :: next_source, next_name, last_or
-
-  LOGICAL :: is_main, cont
-
-  CHARACTER*1 :: backslash, simplequote, doublequote
-
-  INTEGER :: ia, iread, iret, IFF, ih, nb_line, iv, id
-  INTEGER :: ind_space, ind_comma, ind_USE
-  INTEGER :: nbfiles, nb_key, nb_key_file
-  !
-  INTEGER, EXTERNAL ::  iargc, getarg 
-  !
-  !
-  next_source = .FALSE.
-  next_name = .FALSE.
-  is_main = .FALSE.
-  nbsource = 0
-  nbfiles = 0
-  main_name = 'IPSL'
-  !
-  backslash = ACHAR(92)
-  simplequote = ACHAR(39)
-  doublequote = ACHAR(34)
-  !
-  !
-  !
-  !     Analyse command line
-  !
-  !
-  !     Get the number of arguments, that is the options and the
-  !     files to be parsed.
-  !
-  !
-
-  iread = iargc()
-  !
-  DO ia=1,iread
-     !
-     iret = getarg(ia,tmp)
-     !
-     IF (next_source) THEN
-
-        nbsource = nbsource + 1
-        IF ( nbsource .GT. nbsourmax) THEN
-           WRITE(*,*) 'Too many files to source in the arguments.' 
-           WRITE(*,*) 'Increase nbsourmax'
-           STOP
-        ELSE
-           source(nbsource) = tmp(1:LEN_TRIM(tmp))
-        ENDIF
-        next_source = .FALSE.
-
-     ELSE IF (next_name) THEN
-        main_name = tmp(1:LEN_TRIM(tmp))
-        next_name = .FALSE.
-
-     ELSE
-        !     
-        IF ( INDEX(tmp,'-m') .GT. 0) THEN
-           is_main = .TRUE.
-        ELSE IF ( INDEX(tmp,'-n') .GT. 0) THEN
-           next_name = .TRUE.
-        ELSE IF ( INDEX(tmp,'-s') .GT. 0) THEN
-           next_source = .TRUE.
-        ELSE IF ( INDEX(tmp,'-h') .GT. 0) THEN
-           WRITE(*,*) 'USAGE : Fparse [-name NAME] '
-           WRITE(*,*) '               [-source file_to_source]'
-           WRITE(*,*) '               [-main] FORTAN_files'
-        ELSE
-           nbfiles = nbfiles + 1
-           IF ( nbfiles .GT. nbfilesmax) THEN
-              WRITE(*,*) 'Too many files to include in &
-                   &                 the arguments.' 
-              WRITE(*,*) 'Increase nbfilesmax'
-              STOP
-           ELSE
-              files(nbfiles) = tmp(1:LEN_TRIM(tmp))
-           ENDIF
-        ENDIF
-
-     ENDIF
-
-  ENDDO
-  !
-  IF ( nbfiles .LT. 1 ) THEN
-     WRITE(*,*) 'No files provided'
-     STOP
-  ENDIF
-  !
-  !
-  !     1.0 Read files and extract the lines which we need
-  !
-  !
-  nb_key = 0
-  !
-  DO IFF=1,nbfiles
-     !
-     filetmp = files(IFF)
-     CALL READ_from_file(filetmp, nbkeymax, nbelmax, configs, nb_key, keylen)
-     !
-  ENDDO
-  !
-  !     2.0 Scan the information we have extracted from the file for the elements we need
-  !
-  !
-  CALL analyse_configs(nbkeymax, nb_key, nbelmax, keylen, configs, key_pos, help_pos, def_pos, des_pos, IF_pos, TYPE_op)
-  !
-  !
-  !  3.0 Prepare the default values to put them in an array
-  !
-  !
-  DO ia = 1,nb_key
-     !
-     !  3.1 Go to blank delimited lines
-     !
-     nbdef_out(ia) = 0
-     !
-     DO ii=def_pos(ia,1), def_pos(ia,2)
-        !
-        tmp_help = configs(ia,ii)
-        ind_comma = INDEX(tmp_help(1:len_TRIM(tmp_help)),',')
-        DO WHILE (ind_comma .GT. 0) 
-           tmp_help(ind_comma:ind_comma) = ' '
-           ind_comma = INDEX(tmp_help,',')
-        ENDDO
-        CALL cmpblank(tmp_help)
-        configs(ia,ii) = tmp_help
-        !
-        !  3.2 extract the values
-        !
-        tmp_help = TRIM(ADJUSTL(configs(ia,ii)))
-        ind_space= INDEX(tmp_help(1:LEN_TRIM(tmp_help)),' ')
-        ! Get the first one (there is no space in between)
-        IF ( ind_space .EQ. 0) THEN
-           nbdef_out(ia) = nbdef_out(ia) + 1
-           def_out(ia, nbdef_out(ia)) = tmp_help(1:LEN_TRIM(tmp_help))
-        ELSE
-           ! Get all those which are before spaces
-           DO WHILE (ind_space .GT. 0) 
-              nbdef_out(ia) = nbdef_out(ia) + 1
-              def_out(ia, nbdef_out(ia)) = tmp_help(1:ind_space)
-              tmp_help = ADJUSTL(tmp_help(ind_space+1:LEN_TRIM(tmp_help)))
-              ind_space= INDEX(tmp_help(1:LEN_TRIM(tmp_help)),' ')
-           ENDDO
-           !    Get the last one which does not have a space behind
-           IF ( LEN_TRIM(tmp_help) .GT. 0) THEN
-              nbdef_out(ia) = nbdef_out(ia) + 1
-              def_out(ia, nbdef_out(ia)) = tmp_help(1:LEN_TRIM(tmp_help))
-           ENDIF
-           !
-        ENDIF
-     ENDDO
-     !
-  ENDDO
-  !
-  !
-  !
-  !      4.0 OPEN Config.in Defaults and Help files
-  !
-  !
-  OPEN (16, FILE='Config.in')
-  OPEN (17, FILE='Config.help')
-  OPEN (18, FILE='Config.defaults')
-  !
-  !     Some explantation
-  !
-  DO IFF=16,18
-     WRITE(IFF,'(1a)') '# '
-     WRITE(IFF,'(1a)') '# File created by Fparser, DO NOT EDIT'
-     WRITE(IFF,'(2a)') '# ', main_name(1:LEN_TRIM(main_name))
-     WRITE(IFF,'(1a)') '# '
-     WRITE(IFF,'(1a)') '# '
-  ENDDO
-  !
-  WRITE(17,'(2a)') '# Format of this file: description<nl>', &
-       &     ' variable<nl>helptext<nl><nl>.'
-  WRITE(17,'(2a)') '# If the question being documented is of', &
-       &     ' type "choice", we list'
-  WRITE(17,'(2a)') '# only the first occurring config variable.', &
-       &     ' The help texts'
-  WRITE(17,'(2a)') '# must not contain empty lines. No variable', &
-       &     ' should occur twice; if it'
-  WRITE(17,'(2a)') '# does, only the first occurrence will be', &
-       &     ' used by Configure. The lines'
-  WRITE(17,'(2a)') '# in a help text should be indented two', &
-       &     ' positions. Lines starting with'
-  WRITE(17,'(2a)') '# "#" are ignored. To be nice to menuconfig,', &
-       &     ' limit your lines to 70'
-  WRITE(17,'(2a)') '# characters. Use emacs" kfill.el to edit', &
-       &     ' this file or you lose.'
-  WRITE(17,'(2a)') '#'
-  !
-  IF ( is_main ) THEN
-     WRITE(16,'(3a)') 'mainmenu_name "Configuration of model ', &
-          &        main_name(1:LEN_TRIM(main_name)), '"'
-     WRITE(16,'(1a)') '# '
-  ENDIF
-  !
-  WRITE(16,'(1a)') 'mainmenu_option next_comment'
-  WRITE(16,'(3a)') 'comment "', main_name(1:LEN_TRIM(main_name)), '"'
-  WRITE(16,'(1a)') '# '
-  !
-  !   5.0 Loop through the KEYWORDS to prepare the output
-  !
-  DO IFF =1,nb_key
-     !
-     !     Config.in file
-     !
-
-     !
-     !     Is it a conditional option ?
-     !
-     IF ( IF_pos(IFF) .GE. 0)  THEN
-        tmp_help = configs(IFF,IF_pos(IFF))
-        !
-        IF ( (index(tmp_help,'||') .LE. 0) .AND. (index(tmp_help,'&&') .LE. 0) ) THEN
-           IF ( tmp_help(1:1) .EQ. '!') THEN
-              WRITE(16,'(3a)') 'if [ "$', tmp_help(2:LEN_TRIM(tmp_help)),  '" = "n" ]; then'
-           ELSE
-              WRITE(16,'(3a)') 'if [ "$', tmp_help(1:LEN_TRIM(tmp_help)),  '" = "y" ]; then'
-           ENDIF
-        ELSE
-           !
-           last_or = .TRUE.
-           nbcase = 0
-           !
-           DO WHILE( INDEX(tmp_help,'||') .GT. 0)
-              ii = INDEX(tmp_help,'||')
-              nbcase = nbcase + 1
-              if ( nbcase .EQ. 1 ) THEN
-                 IF ( tmp_help(1:1) .EQ. '!') THEN
-                    WRITE(16,'(3a)') 'if [ "$', tmp_help(2:ii-1),  '" = "n" \\'
-                 ELSE
-                    WRITE(16,'(3a)') 'if [ "$', tmp_help(1:ii-1),  '" = "y" \\'
-                 ENDIF
-              ELSE
-                 IF ( tmp_help(1:1) .EQ. '!') THEN
-                    WRITE(16,'(3a)') '-o "$', tmp_help(2:ii-1),  '" = "n" \\'
-                 ELSE
-                    WRITE(16,'(3a)') '-o "$', tmp_help(1:ii-1),  '" = "y" \\'
-                 ENDIF
-              ENDIF
-              tmp_help = TRIM(ADJUSTL(tmp_help(ii+2:LEN_TRIM(tmp_help))))
-           ENDDO
-           !
-           DO WHILE( INDEX(tmp_help,'&&') .GT. 0)
-              ii = INDEX(tmp_help,'&&')
-              nbcase = nbcase + 1
-              if ( nbcase .EQ. 1 ) THEN
-                 IF ( tmp_help(1:1) .EQ. '!') THEN
-                    WRITE(16,'(3a)') 'if [ "$', tmp_help(2:ii-1),  '" = "n" \\'
-                 ELSE
-                    WRITE(16,'(3a)') 'if [ "$', tmp_help(1:ii-1),  '" = "y" \\'
-                 ENDIF
-              ELSE
-                 IF ( tmp_help(1:1) .EQ. '!') THEN
-                    WRITE(16,'(3a)') '-a "$', tmp_help(2:ii-1),  '" = "n" \\'
-                 ELSE
-                    WRITE(16,'(3a)') '-a "$', tmp_help(1:ii-1),  '" = "y" \\'
-                 ENDIF
-              ENDIF
-              tmp_help = TRIM(ADJUSTL(tmp_help(ii+2:LEN_TRIM(tmp_help))))
-              last_or = .FALSE.
-           ENDDO
-           !
-           IF ( last_or ) THEN
-              IF ( tmp_help(1:1) .EQ. '!') THEN
-                 WRITE(16,'(3a)') '-o "$', tmp_help(2:LEN_TRIM(tmp_help)),  '" = "n" ]; then'
-              ELSE
-                 WRITE(16,'(3a)') '-o "$', tmp_help(1:LEN_TRIM(tmp_help)),  '" = "y" ]; then'
-              ENDIF
-           ELSE
-              IF ( tmp_help(1:1) .EQ. '!') THEN
-                 WRITE(16,'(3a)') '-a "$', tmp_help(2:LEN_TRIM(tmp_help)),  '" = "n" ]; then'
-              ELSE
-                 WRITE(16,'(3a)') '-a "$', tmp_help(1:LEN_TRIM(tmp_help)),  '" = "y" ]; then'
-              ENDIF
-           ENDIF
-        ENDIF
-        WRITE(16,'(1a)') '       '
-     ENDIF
-     !
-     !      Extract the information from configs
-     !
-     DO iv = 1,nbdef_out(IFF)
-
-        IF (nbdef_out(IFF) .EQ. 1) THEN
-           tmp_key = configs(IFF,key_pos(IFF))
-           tmp_desc = configs(IFF,des_pos(IFF))
-           tmp_def = def_out(IFF,iv)
-        ELSE
-           tmp_key = configs(IFF,key_pos(IFF))
-           WRITE(nbstr,'(I2.2)') iv
-           tmp_key = tmp_key(1:LEN_TRIM(tmp_key))//'__'//nbstr
-           tmp_desc = configs(IFF,des_pos(IFF))
-           IF ( iv .EQ. 1) THEN
-              tmp_desc = tmp_desc(1:LEN_TRIM(tmp_desc))//' (Vector)'
-           ELSE
-              tmp_desc = 'Cont...    '//tmp_key(1:LEN_TRIM(tmp_key))
-           ENDIF
-           tmp_def = def_out(IFF,iv)
-        ENDIF
-        !
-        !
-        !
-        IF (INDEX(TYPE_op(IFF),'bool') .GT. 0) THEN
-           !
-           WRITE(16,'(4a)') 'bool "', tmp_desc(1:LEN_TRIM(tmp_desc)), &
-                &              '" ',tmp_key(1:LEN_TRIM(tmp_key))
-           !
-        ELSE IF (INDEX(TYPE_op(IFF),'hex') .GT. 0) THEN
-           !
-           WRITE(16,'(6a)') 'hex "', tmp_desc(1:LEN_TRIM(tmp_desc)) &
-                &              ,'" ',tmp_key(1:LEN_TRIM(tmp_key)) &
-                &              ,' ',tmp_def(1:LEN_TRIM(tmp_def))
-           !
-        ELSE IF (INDEX(TYPE_op(IFF),'choice') .GT. 0) THEN
-           !
-           !   Get number of options
-           !
-           nbcase = 0
-           DO WHILE( INDEX(tmp_key,'||') .GT. 0)
-              ii = INDEX(tmp_key,'||')
-              nbcase = nbcase + 1
-              keycase(nbcase) = tmp_key(1:ii-1)
-              tmp_key=tmp_key(ii+2:LEN_TRIM(tmp_key))
-           ENDDO
-           nbcase = nbcase + 1
-           keycase(nbcase) = tmp_key(1:LEN_TRIM(tmp_key))
-
-           WRITE(16,'(4a)') "choice '", tmp_desc(1:LEN_TRIM(tmp_desc))," '",backslash
-           !
-           !   List options
-           !
-           tmp_CASE = keycase(1)
-           WRITE(16,'(5a)') '        "', tmp_CASE(1:LEN_TRIM(tmp_CASE)), "          "&
-                &,tmp_CASE(1:LEN_TRIM(tmp_CASE)), backslash
-           !
-           DO ii=2,nbcase-1
-              tmp_CASE = keycase(ii)
-              WRITE(16,'(5a)') '         ',   tmp_CASE(1:LEN_TRIM(tmp_CASE)),  '          ',&
-                   & tmp_CASE(1:LEN_TRIM(tmp_CASE)),  backslash
-           ENDDO
-           !
-           tmp_CASE = keycase(nbcase)
-           WRITE(16,'(6a)') '         ', &
-                &              tmp_CASE(1:LEN_TRIM(tmp_CASE)), &
-                &              '          ', tmp_CASE(1:LEN_TRIM(tmp_CASE)), &
-                &              '"  ',tmp_def(1:LEN_TRIM(tmp_def)) 
-           !
-        ELSE
-           WRITE(*,'(2a)') 'Uniplemented operation : ', TYPE_op(IFF)
-           STOP
-        ENDIF
-        !
-        !     Config.help file
-        !
-        tmp_key = configs(IFF,key_pos(IFF))
-        IF (INDEX(TYPE_op(IFF),'choice') .GT. 0) THEN
-           ii = INDEX(tmp_key,'||')-1
-        ELSE
-           ii = LEN_TRIM(tmp_key)
-        ENDIF
-
-        IF ( nbdef_out(IFF) .GT. 1) THEN
-           WRITE(17,'(1a)') tmp_desc(1:LEN_TRIM(tmp_desc))
-           WRITE(nbstr,'(I2.2)') iv
-           tke = tmp_key(1:ii)//'__'//nbstr
-           WRITE(17,'(1a)') tke(1:LEN_TRIM(tke))
-           WRITE(17,'(1a)') '  (Vector)'
-        ELSE
-           WRITE(17,'(1a)') tmp_desc(1:LEN_TRIM(tmp_desc))
-           WRITE(17,'(1a)') tmp_key(1:ii)
-        ENDIF
-        !
-        DO ih=help_pos(IFF,1),help_pos(IFF,2)
-           tmp_help = configs(IFF,ih)
-           WRITE(17,'("  ",1a)') tmp_help(1:LEN_TRIM(tmp_help))
-        ENDDO
-        !
-        !     Config.default file
-        !
-        IF (INDEX(TYPE_op(IFF),'choice') .GT. 0) THEN
-
-           WRITE(18,'(2a)') tmp_def(1:LEN_TRIM(tmp_def)),'=y'
-
-        ELSE
-
-           WRITE(18,'(3a)') tmp_key(1:LEN_TRIM(tmp_key)),'=', &
-                &              tmp_def(1:LEN_TRIM(tmp_def))
-
-        ENDIF
-        !     
-        !     Add some empty line to all files
-        !     
-        WRITE(16,'(1a)') '       '
-        WRITE(17,'(1a)') '       '
-        WRITE(17,'(1a)') '       '
-     ENDDO
-     !
-     !
-     !     Close the IF if needed
-     !
-
-     IF ( IF_pos(IFF) .GT. 0) THEN
-        WRITE(16,'(1a)') 'fi'
-        WRITE(16,'(1a)') '       '
-     ENDIF
-
-     !
-  ENDDO
-  !
-  WRITE(16,'(1a)') 'endmenu'
-  WRITE(16,'(1a)') '       '
-  IF ( nbsource .GT. 0) THEN
-     DO ih=1,nbsource
-        tmp = source(ih)
-        WRITE(16,'(1a)') '              '
-        WRITE(16,'(3a)') 'source ',tmp(1:LEN_TRIM(tmp)), &
-             &           '/Config.in'
-     ENDDO
-  ENDIF
-  !
-  !
-  CLOSE(16)
-  CLOSE(17)
-  CLOSE(18)
-  !
-  !
-  !
-  STOP
-
-END PROGRAM fparser
-!
-!
-!==========================================================
-!
-!
-SUBROUTINE READ_from_file(file, nbkeymax, nbelmax, configs, nbitems, itemlen)
-  !
-  USE stringop
-  !
-  IMPLICIT NONE
-  !
-  !
-  !     This routine reads the file and adds the config info it finds to the configs array.
-  !     Thus the nbitems is an imput variable as it can be increased as we go through the files.
-  !
-  !
-  CHARACTER*(*) :: file
-  INTEGER :: nbkeymax, nbelmax
-  CHARACTER*120 :: configs(nbkeymax, nbelmax)
-  INTEGER ::  nbitems, itemlen(nbkeymax)
-  !
-  INTEGER :: conf_pos, ip
-  CHARACTER*250 line
-  LOGICAL :: cont, conf_END
-  !
-  cont = .TRUE.
-  conf_END = .TRUE.
-  !
-  OPEN (12, file=file)
-  !
-  !   1.0 Loop over all the lines of a given file to extract all the configuration line
-  !
-  DO WHILE (cont)
-    READ(12,'(a)',END=9999) line
-    !
-    !   1.0  A configuration line is detected by the line below.
-    !
-    IF ( INDEX(line,'Config') .EQ. 1 .OR. INDEX(line,'!'//'Config') .GE. 1 ) THEN
-        !
-        IF ( conf_END ) THEN
-            nbitems = nbitems + 1
-            IF ( nbitems .GT. nbkeymax) THEN
-                WRITE(*,*) 'read_from_file : The number of keys in the input array is too small for this file'
-                STOP
-            ENDIF
-            itemlen(nbitems) = 0
-            conf_END = .FALSE.
-        ENDIF
-        !
-        itemlen(nbitems) = itemlen(nbitems) + 1
-        IF ( itemlen(nbitems) .GT. nbelmax ) THEN
-            WRITE(*,*) 'read_from_file : The number of elements per key in the input array is too small'
-            STOP
-        ENDIF
-        !
-        !  The detected line is shaved !
-        !
-        IF ( INDEX(line,'Config') .EQ. 1) THEN
-            conf_pos = 7
-        ELSE
-            conf_pos = INDEX(line,'!'//'Config') +7
-        ENDIF
-        line = line(conf_pos:LEN_TRIM(line))
-        line = TRIM(ADJUSTL(line))
-        CALL cmpblank(line)
-        !
-        configs(nbitems,itemlen(nbitems)) = line
-        !
-    ELSE
-        !
-        !   Look for the end of a configuration structure.
-        !  It is determined by a call to the getin subroutine
-        !
-        CALL strlowercase(line)
-        CALL cmpblank(line)
-        ip = INDEX(line,' (')
-        DO WHILE (ip .GT. 0)
-          line = line(1:ip-1)//line(ip+1:LEN_TRIM(line))
-          ip = INDEX(line,' (')
-        ENDDO
-        IF ( INDEX(line, 'call getin(') .GT. 0 .OR. INDEX(line, 'call setvar(') .GT. 0) THEN
-            conf_END = .TRUE.
-        ENDIF
-        !
-    ENDIF
-    !
-    cont = .TRUE.
-    GOTO 8888
-9999 cont = .FALSE.
-8888 CONTINUE
-    
-    ENDDO
-  !
-  CLOSE(12)
-  !
-  END SUBROUTINE READ_from_file
-  !
-  !==========================================================
-  !
-  !
-  SUBROUTINE analyse_configs(nbkmax, nb_key, nbelmax, keylen, configs, key_pos, help_pos, def_pos, des_pos, IF_pos, TYPE_op)
-    !
-  USE stringop
-  !
-    IMPLICIT NONE
-    !
-    !
-    !    This subroutine will localize the KEYWORDS in the configs array
-    !    and extract all their arguments. For the moment 5 arguments are recognized :
-    !    KEY  : The keyword by which the all is identified
-    !    HELP : This identifies the help text
-    !    DEF : The default value of for this KEYWORD
-    !    DESC : A short description, not more than one line
-    !    IF : Specifies the other Keyword it depend on. This is a nice features for the menus as it can hide 
-    !            things we do not need
-    !
-    !    The DEF and HELP keywords can be multi line
-    !
-    INTEGER :: nbkmax, nb_key, nbelmax
-    INTEGER :: keylen(nbkmax)
-    INTEGER :: key_pos(nbkmax), help_pos(nbkmax,2), def_pos(nbkmax,2), des_pos(nbkmax), IF_pos(nbkmax)
-    CHARACTER*120 :: configs(nbkmax,nbelmax)
-    CHARACTER*6 :: TYPE_op(nbkmax)
-    !
-    !   This is the number of arguments we need to find an end for and the total number of arguments  we can have.
-    !   Thus these parameters needs to be updated when the list of arguments to the routine is changed
-    !
-    INTEGER, PARAMETER :: toendlen=2, indexlen=5
-    !
-    INTEGER :: toend(toendlen), foundend(toendlen), kindex(indexlen)
-    INTEGER :: ik, il, ieq
-    CHARACTER*120 :: tmp_str, tmp_str2
-    !
-    !
-    key_pos(1:nb_key)=-1
-    help_pos(1:nb_key,1:2)=-1
-    def_pos(1:nb_key,1:2)=-1
-    des_pos(1:nb_key)=-1
-    IF_pos(1:nb_key)=-1
-    TYPE_op(1:nb_key)='hex'
-    !
-    DO ik=1,nb_key
-      !
-      !
-      DO il=1,keylen(ik)
-        !
-        ieq = INDEX(configs(ik,il),'=')
-        tmp_str = configs(ik,il)
-        tmp_str = tmp_str(1:ieq)
-        CALL struppercase(tmp_str)
-        !
-        !      Decide if this is a reserved name and where it fits
-        !
-        !      At the same time we clean up the configs array
-        !
-        IF ( INDEX(tmp_str,'KEY') .GT. 0) THEN
-            IF ( key_pos(ik) .GT. 0) THEN
-                WRITE(*,*) 'analyse_config : Already have a KEYWORD, check that you have a call to getin'
-                WRITE(*,*) 'analyse_config : ', configs(ik,il)
-                STOP
-            ENDIF
-            key_pos(ik) = il
-            tmp_str2 = configs(ik,il)
-            tmp_str2 = tmp_str2(ieq+1:LEN_TRIM(tmp_str2))
-            configs(ik,il) = TRIM(ADJUSTL(tmp_str2))
-            !
-            !   Here we have to check that we are not in an 'choice' case
-            !
-            IF ( INDEX(tmp_str2,'||') .GT. 0) THEN
-                TYPE_op(ik) = 'choice'
-            ENDIF
-            !
-        ENDIF
-        !
-        IF ( INDEX(tmp_str,'DEF') .GT. 0) THEN
-            IF ( def_pos(ik,1) .GT. 0) THEN
-                WRITE(*,*) 'analyse_config : Already have a DEF, check that you have a call to getin'
-                WRITE(*,*) 'analyse_config : ', configs(ik,il)
-                STOP
-            ENDIF
-            def_pos(ik,1) = il
-            tmp_str2 = configs(ik,il)
-            tmp_str2 = tmp_str2(ieq+1:LEN_TRIM(tmp_str2))
-            tmp_str2 = TRIM(ADJUSTL(tmp_str2))
-            configs(ik,il) = tmp_str2 
-            !
-            !  Here we can check if we have a boolean operation
-            !  We also wish to standardise the value of booleans
-            !
-            CALL struppercase(tmp_str2)
-            IF (INDEX(tmp_str2,'Y') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 1 .OR.&
-               & INDEX(tmp_str2,'T') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 1 .OR.&
-               & INDEX(tmp_str2,'YES') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 3 .OR.&
-               & INDEX(tmp_str2,'TRUE') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 4 .OR.&
-               & INDEX(tmp_str2,'.TRUE.') .EQ. 1) THEN
-                configs(ik,il) = 'y'
-                TYPE_op(ik) = 'bool'
-            ENDIF
-            !
-            IF (INDEX(tmp_str2,'N') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 1 .OR.&
-               & INDEX(tmp_str2,'F') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 1 .OR.&
-               & INDEX(tmp_str2,'NO') .EQ. 1 .AND. LEN_TRIM(tmp_str2) .EQ. 2 .OR.&
-               & INDEX(tmp_str2,'FALSE') .EQ. 1  .AND. LEN_TRIM(tmp_str2) .EQ. 5 .OR.&
-               & INDEX(tmp_str2,'.FALSE.') .EQ. 1) THEN
-                configs(ik,il) = 'n'
-                TYPE_op(ik) = 'bool'
-            ENDIF
-            !
-            ! Here we check if we have a default behavior and put a standard name
-            !
-            IF (INDEX(tmp_str2,'DEF') .EQ. 1 .OR. INDEX(tmp_str2,'NONE') .EQ. 1) THEN
-                configs(ik,il) = 'default'
-            ENDIF
-            !
-        ENDIF
-        !
-        IF ( INDEX(tmp_str,'DESC') .GT. 0) THEN
-            IF ( des_pos(ik) .GT. 0) THEN
-                WRITE(*,*) 'analyse_config : Already have a DESC, check that you have a call to getin'
-                WRITE(*,*) 'analyse_config : ', configs(ik,il)
-                STOP
-            ENDIF
-            des_pos(ik) = il
-            tmp_str2 = configs(ik,il)
-            tmp_str2 = tmp_str2(ieq+1:LEN_TRIM(tmp_str2))
-            configs(ik,il) = TRIM(ADJUSTL(tmp_str2))
-        ENDIF
-        !
-        IF ( INDEX(tmp_str,'IF') .GT. 0) THEN
-            IF ( IF_pos(ik) .GT. 0) THEN
-                WRITE(*,*) 'analyse_config : Already have a IF, check that you have a call to getin'
-                WRITE(*,*) 'analyse_config : ', configs(ik,il)
-                STOP
-            ENDIF
-            IF_pos(ik) = il
-            tmp_str2 = configs(ik,il)
-            tmp_str2 = tmp_str2(ieq+1:LEN_TRIM(tmp_str2))
-            configs(ik,il) = TRIM(ADJUSTL(tmp_str2))
-        ENDIF 
-        !
-        IF ( INDEX(tmp_str,'HELP') .GT. 0) THEN
-            help_pos(ik,1) = il
-            tmp_str2 = configs(ik,il)
-            tmp_str2 = tmp_str2(ieq+1:LEN_TRIM(tmp_str2))
-            configs(ik,il) = TRIM(ADJUSTL(tmp_str2))
-        ENDIF
-        !
-      ENDDO
-      !
-      !     Check if we not missing some important informations as for instance
-      !
-      !     THE KEYWORD 
-      !
-      IF ( key_pos(ik) .LT. 1) THEN
-          WRITE(*,*) 'analyse_configs : Could not find a keyword in the following entry :'
-          DO il=1,keylen(ik)
-            WRITE(*,'(a70)') configs(ik,il)
-          ENDDO
-          STOP
-      ENDIF
-      !
-      !      THE DEFAULT VALUE
-      !
-      IF ( def_pos(ik,1) .LT. 1) THEN
-          WRITE(*,*) 'analyse_configs : Could not find a default value in the following entry :'
-          DO il=1,keylen(ik)
-            WRITE(*,'(a70)') configs(ik,il)
-          ENDDO
-          STOP
-      ENDIF
-      !
-      !   Get the end of all the multi line arguments
-      !
-      toend(1) = MAX(def_pos(ik,1),1)
-      toend(2) = MAX(help_pos(ik,1),1)
-      foundend(:) = keylen(ik)
-      kindex(1) = MAX(key_pos(ik),1)
-      kindex(2) = MAX(des_pos(ik),1)
-      kindex(3) = MAX(def_pos(ik,1),1)
-      kindex(4) = MAX(IF_pos(ik),1)
-      kindex(5) = MAX(help_pos(ik,1),1)
-      CALL find_ends(toendlen, toend, indexlen, kindex, foundend)
-      def_pos(ik,2) = foundend(1)
-      help_pos(ik,2) = foundend(2)
-      !
-    ENDDO
-    !
-  END SUBROUTINE analyse_configs
-  !
-  SUBROUTINE find_ends(toendlen, toend, indexlen, kindex, foundend)
-    !
-    IMPLICIT NONE
-    !
-    !
-    !  We find the end of the text for all the elements in the key which are multi line
-    !   This subroutine aims at providing a flexible way to determine this so that other
-    !   elements in the Keyword can be multi line. For the moment it is only the Help and Ded 
-    !  which are allowed to be multi line.
-    !
-    !  Foundend need to be initialized to the maximum value of the elements
-    !
-    !
-    INTEGER :: toendlen, toend(toendlen), indexlen, kindex(indexlen), foundend(toendlen)
-    !
-    INTEGER :: whmin(1), ie, ii
-    !
-    DO ie=1,toendlen
-      !
-      whmin = MINLOC(toend(1:toendlen))
-      !
-      DO ii=1,indexlen
-        IF ( kindex(ii) .GT. toend(whmin(1)) .AND. foundend(whmin(1)) .GE. kindex(ii)) THEN
-            foundend(whmin(1)) = kindex(ii)-1
-            toend(whmin(1)) = 100000
-        ENDIF
-      ENDDO
-      !
-    ENDDO
-    !
-  END SUBROUTINE find_ends
Index: IOIPSL/trunk/tools/flio_rbld.f90
===================================================================
--- IOIPSL/trunk/tools/flio_rbld.f90	(revision 4999)
+++ 	(revision )
@@ -1,1622 +1,0 @@
-PROGRAM flio_rbld
-!
-!$Id$
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!!--------------------------------------------------------------------
-!! PROGRAM flio_rbld
-!!
-!! PURPOSE :
-!!   Recombine the files of MPI version of IOIPSL
-!!   along several dimensions.
-!!
-!! CALLING SEQUENCE :
-!!
-!!   "flio_rbld" is usually invoked by the script "rebuild"
-!!
-!!   rebuild -h
-!!
-!!   rebuild [-v lev] [-f] -o outfile infile[1] ... infile[n]
-!!
-!! INPUT for "rebuild" :
-!!
-!!   -h         : help
-!!   -v lev     : verbosity level
-!!   -f         : force executing mode
-!!   -o outfile : name of the recombined file.
-!!   infiles    : names of the files that must be recombined.
-!!
-!! INPUT for "flio_rbld" :
-!!
-!!  (I) i_v_lev  : verbosity level
-!!  (C) c_force  : executing mode (noforce/force)
-!!  (I) f_nb     : total number of files
-!!  (C) f_nm(:)  : names of the files (input_files output_file)
-!!
-!!
-!! ASSOCIATED MODULES :
-!!   IOIPSL(fliocom)
-!!
-!! RESTRICTIONS :
-!!
-!!   Cases for character are not coded.
-!!
-!!   Cases for netCDF variables such as array with more
-!!   than 5 dimensions are not coded.
-!!
-!!   Input files must have the following global attributes :
-!!
-!!     "DOMAIN_number_total"
-!!     "DOMAIN_number"
-!!     "DOMAIN_dimensions_ids"
-!!     "DOMAIN_size_global"
-!!     "DOMAIN_size_local"
-!!     "DOMAIN_position_first"
-!!     "DOMAIN_position_last"
-!!     "DOMAIN_halo_size_start"
-!!     "DOMAIN_halo_size_end"
-!!     "DOMAIN_type"
-!!
-!!   NetCDF files must be smaller than 2 Gb.
-!!
-!!   Character variables should have less than 257 letters
-!!
-!! EXAMPLE :
-!!
-!!   rebuild -v -o sst.nc sst_[0-9][0-9][0-9][0-9].nc
-!!
-!! MODIFICATION HISTORY :
-!!   Sebastien Masson   (smasson@jamstec.go.jp)   March 2004
-!!   Jacques   Bellier  (Jacques.Bellier@cea.fr)  June  2005
-!!--------------------------------------------------------------------
-  USE IOIPSL
-  USE defprec
-!-
-  IMPLICIT NONE
-!-
-! Character length
-  INTEGER,PARAMETER :: chlen=256
-!-
-! DO loops and test related variables
-  INTEGER :: i,ia,id,iv,iw,i_i,i_n
-  INTEGER :: ik,itmin,itmax,it1,it2,it
-  LOGICAL :: l_force,l_uld
-!-
-! Input arguments related variables
-  INTEGER :: i_v_lev
-  CHARACTER(LEN=15) :: c_force
-  INTEGER :: f_nb,f_nb_in
-  CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: f_nm
-!-
-! Domains related variables
-  INTEGER :: d_n_t,i_ntd
-  INTEGER,DIMENSION(:),ALLOCATABLE :: dom_att,d_d_i,d_s_g
-  INTEGER,DIMENSION(:,:),ALLOCATABLE :: d_s_l,d_p_f,d_p_l,d_h_s,d_h_e
-  LOGICAL :: l_cgd,l_cof,l_col,l_o_f,l_o_m,l_o_l
-  CHARACTER(LEN=chlen) :: c_d_n
-!-
-! Model files related variables
-  LOGICAL :: l_ocf
-  INTEGER,DIMENSION(:),ALLOCATABLE :: f_a_id
-  INTEGER :: f_id_i1,f_id_i,f_id_o
-  INTEGER :: f_d_nb,f_v_nb,f_a_nb,f_d_ul
-  INTEGER :: v_a_nb,a_type
-  CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: &
-&  f_d_nm,f_v_nm,f_a_nm,v_a_nm
-  CHARACTER(LEN=chlen) :: f_u_nm
-  INTEGER,DIMENSION(:),ALLOCATABLE :: v_d_nb,v_d_ul,v_type
-  INTEGER,DIMENSION(:,:),ALLOCATABLE :: v_d_i
-  INTEGER,DIMENSION(:),ALLOCATABLE :: f_d_i,f_d_l
-  INTEGER :: a_l
-  INTEGER,DIMENSION(flio_max_var_dims) :: d_i,ib,ie
-  INTEGER,DIMENSION(:),ALLOCATABLE :: &
- &  io_i,io_n,ia_sf,io_sf,io_cf,ia_sm,io_sm,io_cm,ia_sl,io_sl,io_cl
-  LOGICAL :: l_ex
-  CHARACTER(LEN=chlen) :: c_wn1,c_wn2
-!-
-!?INTEGERS of KIND 1 are not supported on all computers
-!?INTEGER(KIND=i_1) :: i1_0d
-!?INTEGER(KIND=i_1),DIMENSION(:),ALLOCATABLE :: i1_1d
-!?INTEGER(KIND=i_1),DIMENSION(:,:),ALLOCATABLE :: i1_2d
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:),ALLOCATABLE :: i1_3d
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:),ALLOCATABLE :: i1_4d
-!?INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i1_5d
-  INTEGER(KIND=i_2) :: i2_0d
-  INTEGER(KIND=i_2),DIMENSION(:),ALLOCATABLE :: i2_1d
-  INTEGER(KIND=i_2),DIMENSION(:,:),ALLOCATABLE :: i2_2d
-  INTEGER(KIND=i_2),DIMENSION(:,:,:),ALLOCATABLE :: i2_3d
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:),ALLOCATABLE :: i2_4d
-  INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i2_5d
-  INTEGER(KIND=i_4) :: i4_0d
-  INTEGER(KIND=i_4),DIMENSION(:),ALLOCATABLE :: i4_1d
-  INTEGER(KIND=i_4),DIMENSION(:,:),ALLOCATABLE :: i4_2d
-  INTEGER(KIND=i_4),DIMENSION(:,:,:),ALLOCATABLE :: i4_3d
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:),ALLOCATABLE :: i4_4d
-  INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i4_5d
-  REAL(KIND=r_4) :: r4_0d
-  REAL(KIND=r_4),DIMENSION(:),ALLOCATABLE :: r4_1d
-  REAL(KIND=r_4),DIMENSION(:,:),ALLOCATABLE :: r4_2d
-  REAL(KIND=r_4),DIMENSION(:,:,:),ALLOCATABLE :: r4_3d
-  REAL(KIND=r_4),DIMENSION(:,:,:,:),ALLOCATABLE :: r4_4d
-  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: r4_5d
-  REAL(KIND=r_8) :: r8_0d
-  REAL(KIND=r_8),DIMENSION(:),ALLOCATABLE :: r8_1d
-  REAL(KIND=r_8),DIMENSION(:,:),ALLOCATABLE :: r8_2d
-  REAL(KIND=r_8),DIMENSION(:,:,:),ALLOCATABLE :: r8_3d
-  REAL(KIND=r_8),DIMENSION(:,:,:,:),ALLOCATABLE :: r8_4d
-  REAL(KIND=r_8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: r8_5d
-!-
-! elapsed and cpu time computation variables
-  INTEGER :: nb_cc_ini,nb_cc_end,nb_cc_sec,nb_cc_max
-  REAL :: t_cpu_ini,t_cpu_end
-!---------------------------------------------------------------------
-!-
-!-------------------
-! INPUT arguments
-!-------------------
-!-
-! Retrieve the verbosity level
-  READ (UNIT=*,FMT=*) i_v_lev
-!-
-! Retrieve the executing mode
-  READ (UNIT=*,FMT='(A)') c_force
-  l_force = (TRIM(c_force)  == 'force')
-!-
-! Retrieve the number of arguments
-  READ (UNIT=*,FMT=*) f_nb
-  f_nb_in = f_nb-1
-!-
-! Retrieve the file names
-  ALLOCATE(f_nm(f_nb))
-  DO iw=1,f_nb
-    READ (UNIT=*,FMT='(A)') f_nm(iw)
-  ENDDO
-!-
-! Allocate and initialize the array of file access identifiers
-  ALLOCATE(f_a_id(f_nb_in)); f_a_id(:) = -1;
-!-
-  IF (i_v_lev >= 1) THEN
-    WRITE (UNIT=*,FMT='("")')
-    WRITE (UNIT=*,FMT='(" verbosity level : ",I4)') i_v_lev
-    WRITE (UNIT=*,FMT='(" executing  mode : ",A)') TRIM(c_force)
-    WRITE (UNIT=*,FMT='(" number of args  : ",I4)') f_nb
-    WRITE (UNIT=*,FMT='(" Input  files :")')
-    DO iw=1,f_nb_in
-      WRITE (*,'("   ",A)') TRIM(f_nm(iw))
-    ENDDO
-    WRITE (UNIT=*,FMT='(" Output file  :")')
-    WRITE (*,'("   ",A)') TRIM(f_nm(f_nb))
-!-- time initializations
-    CALL system_clock &
- &   (count=nb_cc_ini,count_rate=nb_cc_sec,count_max=nb_cc_max)
-    CALL cpu_time (t_cpu_ini)
-  ENDIF
-!-
-!---------------------------------------------------
-! Retrieve basic informations from the first file
-!---------------------------------------------------
-!-
-! Open the first file
-  CALL flrb_of (1,f_id_i)
-!-
-! Get the attribute "DOMAIN_number_total"
-  CALL fliogeta (f_id_i,"?","DOMAIN_number_total",d_n_t)
-!-
-! Validate the number of input files :
-! should be equal to the total number
-! of domains used in the simulation
-  IF (d_n_t /= f_nb_in) THEN
-    IF (l_force) THEN
-      iw = 2
-    ELSE
-      iw = 3
-    ENDIF
-    CALL ipslerr (iw,"flio_rbld", &
- &   "The number of input files", &
- &   "is not equal to the number of DOMAINS"," ")
-  ENDIF
-!-
-! Retrieve the basic characteristics of the first input file
-  CALL flioinqf &
- & (f_id_i,nb_dim=f_d_nb,nb_var=f_v_nb,nb_gat=f_a_nb,id_uld=f_d_ul)
-!-
-! Build the list of the names of the
-! dimensions/variables/global_attributes and retrieve
-! the unlimited_dimension name from the first input file
-  ALLOCATE(f_d_nm(f_d_nb),f_v_nm(f_v_nb),f_a_nm(f_a_nb))
-  CALL flioinqn (f_id_i,cn_dim=f_d_nm,cn_var=f_v_nm, &
- &                      cn_gat=f_a_nm,cn_uld=f_u_nm)
-!-
-! Build the list of the dimensions identifiers and lengths
-  ALLOCATE(f_d_i(f_d_nb),f_d_l(f_d_nb))
-  CALL flioinqf (f_id_i,id_dim=f_d_i,ln_dim=f_d_l)
-!-
-! Close the file
-  CALL flrb_cf (1,.FALSE.)
-!-
-! Check if the number of needed files is greater than
-! the maximum number of simultaneously opened files.
-! In that case, open and close model files for each reading,
-! otherwise keep the "flio" identifiers of the opened files.
-  l_ocf = (f_nb > flio_max_files)
-!-
-!----------------------------------------------------
-! Retrieve domain informations for each input file
-!----------------------------------------------------
-!-
-  DO iw=1,f_nb_in
-!---
-    CALL flrb_of (iw,f_id_i)
-!---
-    IF (iw > 1) THEN
-      c_wn1 = "DOMAIN_number_total"
-      CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-      IF (l_ex) THEN
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),i_ntd)
-        IF (i_ntd /= d_n_t) THEN
-          CALL ipslerr (3,"flio_rbld", &
- &        "File      : "//TRIM(f_nm(iw)), &
- &        "Attribute : "//TRIM(c_wn1), &
- &        "not equal to the one of the first file")
-        ENDIF
-      ELSE
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "Attribute : "//TRIM(c_wn1),"not found")
-      ENDIF
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_dimensions_ids"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      ALLOCATE(dom_att(a_l))
-      CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-      IF (iw == 1) THEN
-        IF (ANY(dom_att(:) == f_d_ul)) THEN
-          CALL ipslerr (3,"flio_rbld", &
- &         "File      : "//TRIM(f_nm(iw)), &
- &         "Attribute : "//TRIM(c_wn1), &
- &         "contains the unlimited dimension")
-        ENDIF
-        ALLOCATE (d_d_i(a_l))
-        d_d_i(:) = dom_att(:)
-      ELSEIF (SIZE(dom_att) /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the one of the first file")
-      ELSEIF (ANY(dom_att(:) /= d_d_i(:))) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "Attribute : "//TRIM(c_wn1), &
- &       "not equal to the one of the first file")
-      ENDIF
-      DEALLOCATE(dom_att)
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_size_global"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      IF (a_l /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the size of DOMAIN_dimensions_ids")
-      ELSE
-        ALLOCATE(dom_att(a_l))
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-        IF (iw == 1) THEN
-          ALLOCATE (d_s_g(a_l))
-          d_s_g(:)=dom_att(:)
-        ELSEIF (ANY(dom_att(:) /= d_s_g(:))) THEN
-          CALL ipslerr (3,"flio_rbld", &
- &         "File      : "//TRIM(f_nm(iw)), &
- &         "Attribute : "//TRIM(c_wn1), &
- &         "not equal to the one of the first file")
-        ENDIF
-        DEALLOCATE(dom_att)
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_size_local"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      IF (a_l /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the size of DOMAIN_dimensions_ids")
-      ELSE
-        ALLOCATE(dom_att(a_l))
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-        IF (iw == 1) THEN
-          ALLOCATE (d_s_l(a_l,f_nb_in))
-        ENDIF
-        d_s_l(:,iw)=dom_att(:)
-        DEALLOCATE(dom_att)
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_position_first"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      IF (a_l /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the size of DOMAIN_dimensions_ids")
-      ELSE
-        ALLOCATE(dom_att(a_l))
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-        IF (iw == 1) THEN
-          ALLOCATE (d_p_f(a_l,f_nb_in))
-        ENDIF
-        d_p_f(:,iw)=dom_att(:)
-        DEALLOCATE(dom_att)
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_position_last"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      IF (a_l /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the size of DOMAIN_dimensions_ids")
-      ELSE
-        ALLOCATE(dom_att(a_l))
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-        IF (iw == 1) THEN
-          ALLOCATE (d_p_l(a_l,f_nb_in))
-        ENDIF
-        d_p_l(:,iw)=dom_att(:)
-        DEALLOCATE(dom_att)
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_halo_size_start"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      IF (a_l /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the size of DOMAIN_dimensions_ids")
-      ELSE
-        ALLOCATE(dom_att(a_l))
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-        IF (iw == 1) THEN
-          ALLOCATE (d_h_s(a_l,f_nb_in))
-        ENDIF
-        d_h_s(:,iw)=dom_att(:)
-        DEALLOCATE(dom_att)
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_halo_size_end"
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      IF (a_l /= SIZE(d_d_i)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "size of the attribute : "//TRIM(c_wn1), &
- &       "not equal to the size of DOMAIN_dimensions_ids")
-      ELSE
-        ALLOCATE(dom_att(a_l))
-        CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
-        IF (iw == 1) THEN
-          ALLOCATE (d_h_e(a_l,f_nb_in))
-        ENDIF
-        d_h_e(:,iw)=dom_att(:)
-        DEALLOCATE(dom_att)
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    c_wn1 = "DOMAIN_type"
-    c_wn2 = " "
-    CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
-    IF (l_ex) THEN
-      CALL fliogeta (f_id_i,"?",TRIM(c_wn1),c_wn2)
-      CALL strlowercase (c_wn2)
-      IF (iw == 1) THEN
-        IF (    (TRIM(c_wn2) == "box") &
- &          .OR.(TRIM(c_wn2) == "apple") ) THEN
-          c_d_n = c_wn2
-        ELSE
-          CALL ipslerr (3,"flio_rbld", &
- &         "File      : "//TRIM(f_nm(iw)), &
- &         "Attribute : "//TRIM(c_wn1), &
- &         "type "//TRIM(c_wn2)//" not (yet) supported")
-        ENDIF
-      ELSEIF (TRIM(c_wn2) /= TRIM(c_d_n)) THEN
-        CALL ipslerr (3,"flio_rbld", &
- &       "File      : "//TRIM(f_nm(iw)), &
- &       "Attribute : "//TRIM(c_wn1), &
- &       "not equal to the one of the first file")
-      ENDIF
-    ELSE
-      CALL ipslerr (3,"flio_rbld", &
- &     "File      : "//TRIM(f_nm(iw)), &
- &     "Attribute : "//TRIM(c_wn1),"not found")
-    ENDIF
-!---
-    CALL flrb_cf (iw,l_ocf)
-!---
-  ENDDO
-!-
-  IF (i_v_lev >= 2) THEN
-    WRITE (UNIT=*,FMT='("")')
-    WRITE (*,'(" From the first file : ")')
-    WRITE (*,'("   Number of dimensions : ",I2)') f_d_nb
-    WRITE (*,'("     Idents  : ",(10(1X,I4),:))') f_d_i(1:f_d_nb)
-    WRITE (*,'("     Lengths : ",(10(1X,I4),:))') f_d_l(1:f_d_nb)
-    WRITE (*,'("     Names: ")')
-    DO i=1,f_d_nb
-      WRITE (*,'("       """,A,"""")') TRIM(f_d_nm(i))
-    ENDDO
-    IF (f_d_ul > 0) THEN
-      WRITE (*,'("   Unlimited dimension id : ",I2)') f_d_i(f_d_ul)
-    ENDIF
-    WRITE (*,'("   Number of variables  : ",I2)') f_v_nb
-    WRITE (*,'("     Names: ")')
-    DO i=1,f_v_nb
-      WRITE (*,'("       """,A,"""")') TRIM(f_v_nm(i))
-    ENDDO
-    WRITE (*,'("   Number of global attributes : ",I2)') f_a_nb
-    WRITE (*,'("     Names: ")')
-    DO i=1,f_a_nb
-      WRITE (*,'("       """,A,"""")') TRIM(f_a_nm(i))
-    ENDDO
-  ENDIF
-  IF (i_v_lev >= 3) THEN
-    WRITE (UNIT=*,FMT='("")')
-    WRITE (*,'(" From input files : ")')
-    WRITE (*,'("   Total number of DOMAINS : ",I4)') d_n_t
-    WRITE (*,'("   DOMAIN_dimensions_ids :",(10(1X,I5),:))') d_d_i(:)
-    WRITE (*,'("   DOMAIN_size_global    :",(10(1X,I5),:))') d_s_g(:)
-    WRITE (*,'("   DOMAIN_type           : """,(A),"""")') TRIM(c_d_n)
-    DO iw=1,f_nb_in
-      WRITE (*,'("   File   : ",A)') TRIM(f_nm(iw))
-      WRITE (*,'("     d_s_l  :",(10(1X,I5),:))') d_s_l(:,iw)
-      WRITE (*,'("     d_p_f  :",(10(1X,I5),:))') d_p_f(:,iw)
-      WRITE (*,'("     d_p_l  :",(10(1X,I5),:))') d_p_l(:,iw)
-      WRITE (*,'("     d_h_s  :",(10(1X,I5),:))') d_h_s(:,iw)
-      IF (TRIM(c_d_n) == "apple") THEN
-        IF (COUNT(d_h_s(:,iw) /= 0) > 1) THEN
-          CALL ipslerr (3,"flio_rbld", &
- &          "Beginning offset is not yet supported", &
- &          "for more than one dimension"," ")
-        ENDIF
-      ENDIF
-      WRITE (*,'("     d_h_e  :",(10(1X,I5),:))') d_h_e(:,iw)
-      IF (TRIM(c_d_n) == "apple") THEN
-        IF (COUNT(d_h_e(:,iw) /= 0) > 1) THEN
-          CALL ipslerr (3,"flio_rbld", &
- &          "Ending offset is not yet supported", &
- &          "for more than one dimension"," ")
-        ENDIF
-      ENDIF
-    ENDDO
-  ENDIF
-!-
-!---------------------------------------
-! Create the dimensionned output file
-!---------------------------------------
-!-
-! Define the dimensions used in the output file
-  DO id=1,f_d_nb
-    DO i=1,SIZE(d_d_i)
-      IF (f_d_i(id) == d_d_i(i)) THEN
-        f_d_l(id) = d_s_g(i)
-      ENDIF
-    ENDDO
-  ENDDO
-!-
-  IF (f_d_ul > 0) THEN
-    i = f_d_l(f_d_ul); f_d_l(f_d_ul) = -1;
-  ENDIF
-!-
-! Create the output file
-  CALL fliocrfd (TRIM(f_nm(f_nb)),f_d_nm,f_d_l,f_id_o,c_f_n=c_wn1)
-!-
-  IF (f_d_ul > 0) THEN
-    f_d_l(f_d_ul) = i; itmin = 1; itmax = f_d_l(f_d_ul);
-  ELSE
-    itmin = 1; itmax = 1;
-  ENDIF
-!-
-! open the first input file used to build the output file
-!-
-  CALL flrb_of (1,f_id_i1)
-!-
-! define the global attributes in the output file
-! copy all global attributes except those beginning by "DOMAIN_"
-! eventually actualize the "file_name" attribute
-!-
-  DO ia=1,f_a_nb
-    IF (INDEX(TRIM(f_a_nm(ia)),"DOMAIN_") == 1)  CYCLE
-    IF (TRIM(f_a_nm(ia)) == "file_name") THEN
-      CALL flioputa (f_id_o,"?",TRIM(f_a_nm(ia)),TRIM(c_wn1))
-    ELSE
-      CALL fliocpya (f_id_i1,"?",TRIM(f_a_nm(ia)),f_id_o,"?")
-    ENDIF
-  ENDDO
-!-
-! define the variables in the output file
-!-
-  ALLOCATE(v_d_nb(f_v_nb)); v_d_nb(:) = 0;
-  ALLOCATE(v_d_ul(f_v_nb)); v_d_ul(:) = 0;
-  ALLOCATE(v_type(f_v_nb),v_d_i(flio_max_var_dims,f_v_nb));
-  DO iv=1,f_v_nb
-!-- get variable informations
-    CALL flioinqv &
- &   (f_id_i1,TRIM(f_v_nm(iv)),l_ex,v_t=v_type(iv), &
- &    nb_dims=v_d_nb(iv),id_dims=d_i,nb_atts=v_a_nb)
-!-- define the new variable
-    IF (v_d_nb(iv) == 0) THEN
-      CALL fliodefv &
- &     (f_id_o,TRIM(f_v_nm(iv)),v_t=v_type(iv))
-    ELSE
-      CALL fliodefv &
- &     (f_id_o,TRIM(f_v_nm(iv)),d_i(1:v_d_nb(iv)),v_t=v_type(iv))
-      DO iw=1,v_d_nb(iv)
-        IF (f_d_ul > 0) THEN
-          IF (d_i(iw) == f_d_ul) THEN
-            v_d_ul(iv) = iw
-          ENDIF
-        ENDIF
-      ENDDO
-      v_d_i(1:v_d_nb(iv),iv) = d_i(1:v_d_nb(iv))
-    ENDIF
-!-- copy all variable attributes
-    IF (v_a_nb > 0) THEN
-      ALLOCATE(v_a_nm(v_a_nb))
-      CALL flioinqv (f_id_i1,TRIM(f_v_nm(iv)),l_ex,cn_atts=v_a_nm)
-      DO ia=1,v_a_nb
-        CALL fliocpya &
- &       (f_id_i1,TRIM(f_v_nm(iv)),TRIM(v_a_nm(ia)), &
- &        f_id_o,TRIM(f_v_nm(iv)))
-      ENDDO
-      DEALLOCATE(v_a_nm)
-    ENDIF
-  ENDDO
-!-
-! update valid_min valid_max attributes values
-!-
-  CALL flrb_rg
-!-
-!------------------------
-! Fill the output file
-!------------------------
-!-
-  DO ik=1,2
-    l_uld = (ik /= 1)
-    IF (l_uld) THEN
-      it1=itmin; it2=itmax;
-    ELSE
-      it1=1; it2=1;
-    ENDIF
-    DO it=it1,it2
-      DO iv=1,f_v_nb
-        IF (    (.NOT.l_uld.AND.(v_d_ul(iv) > 0)) &
- &          .OR.(l_uld.AND.(v_d_ul(iv) <= 0)) ) THEN
-          CYCLE
-        ENDIF
-        IF (i_v_lev >= 3) THEN
-          WRITE (UNIT=*,FMT='("")')
-          IF (l_uld) THEN
-            WRITE (UNIT=*,FMT=*) "time step     : ",it
-          ENDIF
-          WRITE (UNIT=*,FMT=*) "variable      : ",TRIM(f_v_nm(iv))
-          WRITE (UNIT=*,FMT=*) "var unlim dim : ",v_d_ul(iv)
-        ENDIF
-!------ do the variable contains dimensions to be recombined ?
-        l_cgd = .FALSE.
-        i_n = 1
-        DO i=1,SIZE(d_d_i)
-          l_cgd = ANY(v_d_i(1:v_d_nb(iv),iv) == d_d_i(i))
-          l_cgd = l_cgd.AND.ANY(d_s_l(i,1:f_nb_in) /= d_s_g(i))
-          IF (l_cgd) THEN
-            i_n = f_nb_in
-              EXIT
-          ENDIF
-        ENDDO
-        IF (v_d_nb(iv) > 0) THEN
-!-------- Allocate io_i,io_n,ia_sm,io_sm,io_cm
-          i = v_d_nb(iv)
-          ALLOCATE(io_i(i),io_n(i),ia_sm(i),io_sm(i),io_cm(i))
-!-------- Default definition of io_i,io_n,io_sm,io_cm
-          io_i(:) = 1; io_n(:) = f_d_l(v_d_i(1:v_d_nb(iv),iv));
-          ia_sm(:) = 1; io_sm(:) = 1;
-          IF (v_d_ul(iv) > 0) THEN
-            io_i(v_d_ul(iv))=it
-            io_n(v_d_ul(iv))=1
-            io_sm(v_d_ul(iv))=it
-          ENDIF
-          io_cm(:) = io_n(:);
-!-------- If needed, allocate offset
-          l_o_f = .FALSE.; l_o_m = .TRUE.; l_o_l = .FALSE.;
-          IF (TRIM(c_d_n) == "apple") THEN
-            ALLOCATE(ia_sf(i),io_sf(i),io_cf(i))
-            ALLOCATE(ia_sl(i),io_sl(i),io_cl(i))
-            ia_sf(:) = 1; io_sf(:) = 1; io_cf(:) = io_n(:);
-            ia_sl(:) = 1; io_sl(:) = 1; io_cl(:) = io_n(:);
-            IF (v_d_ul(iv) > 0) THEN
-              io_sf(v_d_ul(iv))=it
-              io_sl(v_d_ul(iv))=it
-            ENDIF
-          ENDIF
-        ENDIF
-!------
-        DO i_i=1,i_n
-          IF (l_cgd) THEN
-!---------- the variable contains dimensions to be recombined
-!-----------
-!---------- open each file containing a small piece of data
-            CALL flrb_of (i_i,f_id_i)
-!-----------
-!---------- do the variable has offset at first/last block ?
-            l_cof = .FALSE.; l_col = .FALSE.;
-            IF (TRIM(c_d_n) == "apple") THEN
-              L_BF: DO id=1,v_d_nb(iv)
-                DO i=1,SIZE(d_d_i)
-                  IF (v_d_i(id,iv) == d_d_i(i)) THEN
-                    l_cof = (d_h_s(i,i_i) /= 0)
-                    IF (l_cof)  EXIT L_BF
-                  ENDIF
-                ENDDO
-              ENDDO L_BF
-              L_BL: DO id=1,v_d_nb(iv)
-                DO i=1,SIZE(d_d_i)
-                  IF (v_d_i(id,iv) == d_d_i(i)) THEN
-                    l_col = (d_h_e(i,i_i) /= 0)
-                    IF (l_col)  EXIT L_BL
-                  ENDIF
-                ENDDO
-              ENDDO L_BL
-            ENDIF
-!---------- if needed, redefine start and count for dimensions
-            l_o_f = .FALSE.; l_o_m = .TRUE.; l_o_l = .FALSE.;
-            DO id=1,v_d_nb(iv)
-              DO i=1,SIZE(d_d_i)
-                IF (v_d_i(id,iv) == d_d_i(i)) THEN
-                  io_n(id) = d_p_l(i,i_i)-d_p_f(i,i_i)+1
-                  ia_sm(id) = 1
-                  io_sm(id) = d_p_f(i,i_i)
-                  io_cm(id) = io_n(id)
-                  IF     (TRIM(c_d_n) == "box") THEN
-                    ia_sm(id) = ia_sm(id)+d_h_s(i,i_i)
-                    io_sm(id) = io_sm(id)+d_h_s(i,i_i)
-                    io_cm(id) = io_cm(id)-d_h_s(i,i_i)-d_h_e(i,i_i)
-                  ELSEIF (TRIM(c_d_n) == "apple") THEN
-                    IF (l_cof) THEN
-                      IF (d_h_s(i,i_i) /= 0) THEN
-                        ia_sf(id) = 1+d_h_s(i,i_i)
-                        io_sf(id) = d_p_f(i,i_i)+d_h_s(i,i_i)
-                        io_cf(id) = io_n(id)-d_h_s(i,i_i)
-                      ELSE
-                        io_sf(id) = d_p_f(i,i_i)
-                        io_cf(id) = 1
-                        ia_sm(id) = ia_sm(id)+1
-                        io_sm(id) = io_sm(id)+1
-                        io_cm(id) = io_cm(id)-1
-                        l_o_f = .TRUE.
-                      ENDIF
-                    ENDIF
-                    IF (l_col) THEN
-                      IF (d_h_e(i,i_i) /= 0) THEN
-                        ia_sl(id) = 1
-                        io_sl(id) = d_p_f(i,i_i)
-                        io_cl(id) = io_n(id)-d_h_e(i,i_i)
-                      ELSE
-                        io_cm(id) = io_cm(id)-1
-                        ia_sl(id) = 1+io_n(id)-1
-                        io_sl(id) = d_p_f(i,i_i)+io_n(id)-1
-                        io_cl(id) = 1
-                        l_o_l = .TRUE.
-                      ENDIF
-                    ENDIF
-                  ENDIF
-                ENDIF
-              ENDDO
-            ENDDO
-            l_o_m = ALL(io_cm > 0)
-          ELSE
-!---------- the data can be read/write in one piece
-            f_id_i = f_id_i1
-          ENDIF
-!---------
-          IF (i_v_lev >= 3) THEN
-            WRITE (UNIT=*,FMT=*) &
- &            TRIM(f_nm(i_i))//" - "//TRIM(f_v_nm(iv))
-            WRITE (UNIT=*,FMT=*) "io_i  : ",io_i(:)
-            WRITE (UNIT=*,FMT=*) "io_n  : ",io_n(:)
-            WRITE (UNIT=*,FMT=*) "l_o_f : ",l_o_f
-            IF (l_o_f) THEN
-              WRITE (UNIT=*,FMT=*) "ia_sf : ",ia_sf(:)
-              WRITE (UNIT=*,FMT=*) "io_sf : ",io_sf(:)
-              WRITE (UNIT=*,FMT=*) "io_cf : ",io_cf(:)
-            ENDIF
-            WRITE (UNIT=*,FMT=*) "l_o_m : ",l_o_m
-            IF (l_o_m) THEN
-              WRITE (UNIT=*,FMT=*) "ia_sm : ",ia_sm(:)
-              WRITE (UNIT=*,FMT=*) "io_sm : ",io_sm(:)
-              WRITE (UNIT=*,FMT=*) "io_cm : ",io_cm(:)
-            ENDIF
-            WRITE (UNIT=*,FMT=*) "l_o_l : ",l_o_l
-            IF (l_o_l) THEN
-              WRITE (UNIT=*,FMT=*) "ia_sl : ",ia_sl(:)
-              WRITE (UNIT=*,FMT=*) "io_sl : ",io_sl(:)
-              WRITE (UNIT=*,FMT=*) "io_cl : ",io_cl(:)
-            ENDIF
-          ENDIF
-!---------
-!-------- Cases according to the type, shape and offsets of the data
-!---------
-          SELECT CASE (v_type(iv))
-!?INTEGERS of KIND 1 are not supported on all computers
-!?        CASE (flio_i1) !--- INTEGER 1
-!?          SELECT CASE (v_d_nb(iv))
-!?          CASE (0) !--- Scalar
-!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_0d)
-!?            CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i1_0d)
-!?          CASE (1) !--- 1d array
-!?            ALLOCATE(i1_1d(io_n(1)))
-!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_1d, &
-!? &            start=io_i(:),count=io_n(:))
-!?            IF (l_o_f) THEN
-!?              ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_1d(ib(1):ie(1)), &
-!? &              start=io_sf(:),count=io_cf(:))
-!?            ENDIF
-!?            IF (l_o_m) THEN
-!?              ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_1d(ib(1):ie(1)), &
-!? &              start=io_sm(:),count=io_cm(:))
-!?            ENDIF
-!?            IF (l_o_l) THEN
-!?              ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_1d(ib(1):ie(1)), &
-!? &              start=io_sl(:),count=io_cl(:))
-!?            ENDIF
-!?            DEALLOCATE(i1_1d)
-!?          CASE (2) !--- 2d array
-!?            ALLOCATE(i1_2d(io_n(1),io_n(2)))
-!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_2d, &
-!? &            start=io_i(:),count=io_n(:))
-!?            IF (l_o_f) THEN
-!?              ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_2d(ib(1):ie(1),ib(2):ie(2)), &
-!? &              start=io_sf(:),count=io_cf(:))
-!?            ENDIF
-!?            IF (l_o_m) THEN
-!?              ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_2d(ib(1):ie(1),ib(2):ie(2)), &
-!? &              start=io_sm(:),count=io_cm(:))
-!?            ENDIF
-!?            IF (l_o_l) THEN
-!?              ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_2d(ib(1):ie(1),ib(2):ie(2)), &
-!? &              start=io_sl(:),count=io_cl(:))
-!?            ENDIF
-!?            DEALLOCATE(i1_2d)
-!?          CASE (3) !--- 3d array
-!?            ALLOCATE(i1_3d(io_n(1),io_n(2),io_n(3)))
-!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_3d, &
-!? &            start=io_i(:),count=io_n(:))
-!?            IF (l_o_f) THEN
-!?              ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
-!? &              start=io_sf(:),count=io_cf(:))
-!?            ENDIF
-!?            IF (l_o_m) THEN
-!?              ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
-!? &              start=io_sm(:),count=io_cm(:))
-!?            ENDIF
-!?            IF (l_o_l) THEN
-!?              ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
-!? &              start=io_sl(:),count=io_cl(:))
-!?            ENDIF
-!?            DEALLOCATE(i1_3d)
-!?          CASE (4) !--- 4d array
-!?            ALLOCATE(i1_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
-!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_4d, &
-!? &            start=io_i(:),count=io_n(:))
-!?            IF (l_o_f) THEN
-!?              ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_4d(ib(1):ie(1),ib(2):ie(2), &
-!? &                    ib(3):ie(3),ib(4):ie(4)), &
-!? &              start=io_sf(:),count=io_cf(:))
-!?            ENDIF
-!?            IF (l_o_m) THEN
-!?              ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_4d(ib(1):ie(1),ib(2):ie(2), &
-!? &                    ib(3):ie(3),ib(4):ie(4)), &
-!? &              start=io_sm(:),count=io_cm(:))
-!?            ENDIF
-!?            IF (l_o_l) THEN
-!?              ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_4d(ib(1):ie(1),ib(2):ie(2), &
-!? &                    ib(3):ie(3),ib(4):ie(4)), &
-!? &              start=io_sl(:),count=io_cl(:))
-!?            ENDIF
-!?            DEALLOCATE(i1_4d)
-!?          CASE (5) !--- 5d array
-!?            ALLOCATE(i1_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
-!?            CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_5d, &
-!? &            start=io_i(:),count=io_n(:))
-!?            IF (l_o_f) THEN
-!?              ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
-!? &                    ib(4):ie(4),ib(5):ie(5)), &
-!? &              start=io_sf(:),count=io_cf(:))
-!?            ENDIF
-!?            IF (l_o_m) THEN
-!?              ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
-!? &                    ib(4):ie(4),ib(5):ie(5)), &
-!? &              start=io_sm(:),count=io_cm(:))
-!?            ENDIF
-!?            IF (l_o_l) THEN
-!?              ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
-!?              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
-!? &              i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
-!? &                    ib(4):ie(4),ib(5):ie(5)), &
-!? &              start=io_sl(:),count=io_cl(:))
-!?            ENDIF
-!?            DEALLOCATE(i1_5d)
-!?          END SELECT
-!?        CASE (flio_i2) !--- INTEGER 2
-          CASE (flio_i1,flio_i2) !--- INTEGER 1/INTEGER 2
-            SELECT CASE (v_d_nb(iv))
-            CASE (0) !--- Scalar
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_0d)
-              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i2_0d)
-            CASE (1) !--- 1d array
-              ALLOCATE(i2_1d(io_n(1)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_1d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_1d(ib(1):ie(1)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_1d(ib(1):ie(1)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_1d(ib(1):ie(1)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i2_1d)
-            CASE (2) !--- 2d array
-              ALLOCATE(i2_2d(io_n(1),io_n(2)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_2d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i2_2d)
-            CASE (3) !--- 3d array
-              ALLOCATE(i2_3d(io_n(1),io_n(2),io_n(3)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_3d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i2_3d)
-            CASE (4) !--- 4d array
-              ALLOCATE(i2_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_4d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i2_4d)
-            CASE (5) !--- 5d array
-              ALLOCATE(i2_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_5d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i2_5d)
-            END SELECT
-          CASE (flio_i4) !--- INTEGER 4
-            SELECT CASE (v_d_nb(iv))
-            CASE (0) !--- Scalar
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_0d)
-              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i4_0d)
-            CASE (1) !--- 1d array
-              ALLOCATE(i4_1d(io_n(1)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_1d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_1d(ib(1):ie(1)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_1d(ib(1):ie(1)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_1d(ib(1):ie(1)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i4_1d)
-            CASE (2) !--- 2d array
-              ALLOCATE(i4_2d(io_n(1),io_n(2)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_2d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i4_2d)
-            CASE (3) !--- 3d array
-              ALLOCATE(i4_3d(io_n(1),io_n(2),io_n(3)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_3d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i4_3d)
-            CASE (4) !--- 4d array
-              ALLOCATE(i4_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_4d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i4_4d)
-            CASE (5) !--- 5d array
-              ALLOCATE(i4_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_5d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(i4_5d)
-            END SELECT
-          CASE (flio_r4) !--- REAL 4
-            SELECT CASE (v_d_nb(iv))
-            CASE (0) !--- Scalar
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_0d)
-              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),r4_0d)
-            CASE (1) !--- 1d array
-              ALLOCATE(r4_1d(io_n(1)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_1d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_1d(ib(1):ie(1)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_1d(ib(1):ie(1)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_1d(ib(1):ie(1)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r4_1d)
-            CASE (2) !--- 2d array
-              ALLOCATE(r4_2d(io_n(1),io_n(2)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_2d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r4_2d)
-            CASE (3) !--- 3d array
-              ALLOCATE(r4_3d(io_n(1),io_n(2),io_n(3)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_3d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r4_3d)
-            CASE (4) !--- 4d array
-              ALLOCATE(r4_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_4d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r4_4d)
-            CASE (5) !--- 5d array
-              ALLOCATE(r4_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_5d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r4_5d)
-            END SELECT
-          CASE (flio_r8) !--- REAL 8
-            SELECT CASE (v_d_nb(iv))
-            CASE (0) !--- Scalar
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_0d)
-              CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),r8_0d)
-            CASE (1) !--- 1d array
-              ALLOCATE(r8_1d(io_n(1)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_1d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_1d(ib(1):ie(1)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_1d(ib(1):ie(1)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_1d(ib(1):ie(1)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r8_1d)
-            CASE (2) !--- 2d array
-              ALLOCATE(r8_2d(io_n(1),io_n(2)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_2d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_2d(ib(1):ie(1),ib(2):ie(2)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r8_2d)
-            CASE (3) !--- 3d array
-              ALLOCATE(r8_3d(io_n(1),io_n(2),io_n(3)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_3d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r8_3d)
-            CASE (4) !--- 4d array
-              ALLOCATE(r8_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_4d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_4d(ib(1):ie(1),ib(2):ie(2), &
- &                      ib(3):ie(3),ib(4):ie(4)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r8_4d)
-            CASE (5) !--- 5d array
-              ALLOCATE(r8_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
-              CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_5d, &
- &              start=io_i(:),count=io_n(:))
-              IF (l_o_f) THEN
-                ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sf(:),count=io_cf(:))
-              ENDIF
-              IF (l_o_m) THEN
-                ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sm(:),count=io_cm(:))
-              ENDIF
-              IF (l_o_l) THEN
-                ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
-                CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
- &                r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
- &                      ib(4):ie(4),ib(5):ie(5)), &
- &                start=io_sl(:),count=io_cl(:))
-              ENDIF
-              DEALLOCATE(r8_5d)
-            END SELECT
-          END SELECT
-!-------- eventually close each file containing a small piece of data
-          CALL flrb_cf (i_i,l_ocf.AND.l_cgd.AND.(i_i /= 1))
-        ENDDO
-!------ If needed, deallocate io_* arrays
-        IF (v_d_nb(iv) > 0) THEN
-          DEALLOCATE(io_i,io_n,ia_sm,io_sm,io_cm)
-          IF (TRIM(c_d_n) == "apple") THEN
-            DEALLOCATE(ia_sf,io_sf,io_cf)
-            DEALLOCATE(ia_sl,io_sl,io_cl)
-          ENDIF
-        ENDIF
-      ENDDO
-    ENDDO
-  ENDDO
-!-
-!-------------------
-! Ending the work
-!-------------------
-!-
-! Close files
-  CALL flrb_cf (0,.TRUE.)
-!-
-! Deallocate
-  DEALLOCATE(f_nm,f_a_id)
-  DEALLOCATE(f_d_nm,f_v_nm,f_a_nm)
-  DEALLOCATE(f_d_i,f_d_l)
-  DEALLOCATE(v_d_nb,v_d_ul,v_type,v_d_i)
-  DEALLOCATE(d_d_i,d_s_g)
-  DEALLOCATE(d_s_l,d_p_f,d_p_l,d_h_s,d_h_e)
-!-
-  IF (i_v_lev >= 1) THEN
-!-- elapsed and cpu time computation
-    CALL cpu_time (t_cpu_end)
-    CALL system_clock(count=nb_cc_end)
-    WRITE (UNIT=*,FMT='("")')
-    WRITE (UNIT=*,fmt='(" elapsed time (s) : ",1PE11.4)') &
- &   REAL(nb_cc_end-nb_cc_ini)/REAL(nb_cc_sec)
-    WRITE (UNIT=*,fmt='(" CPU time (s) : ",1PE11.4)') &
- &   t_cpu_end-t_cpu_ini
-  ENDIF
-!=======
-CONTAINS
-!=======
-SUBROUTINE flrb_of (i_f_n,i_f_i)
-!---------------------------------------------------------------------
-! Open the file of number "i_f_n" if necessary,
-! and returns its identifier in "i_f_i".
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN)  :: i_f_n
-  INTEGER,INTENT(OUT) :: i_f_i
-!---------------------------------------------------------------------
-  IF (f_a_id(i_f_n) < 0) THEN
-    CALL flioopfd (TRIM(f_nm(i_f_n)),i_f_i)
-    f_a_id(i_f_n) = i_f_i
-  ELSE
-    i_f_i = f_a_id(i_f_n)
-  ENDIF
-!---------------------
-END SUBROUTINE flrb_of
-!===
-SUBROUTINE flrb_cf (i_f_n,l_cf)
-!---------------------------------------------------------------------
-! Close the file of number "i_f_n" if "l_cf" is TRUE.
-! Close all files if "i_f_n <= 0".
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER,INTENT(IN) :: i_f_n
-  LOGICAL,INTENT(IN) :: l_cf
-!---------------------------------------------------------------------
-  IF (i_f_n <= 0) THEN
-    CALL flioclo ()
-    f_a_id(:) = -1
-  ELSE
-    IF (l_cf) THEN
-      IF (f_a_id(i_f_n) < 0) THEN
-        CALL ipslerr (2,"flio_rbld", &
- &       "The file",TRIM(f_nm(i_f_n)),"is already closed")
-      ELSE
-        CALL flioclo (f_a_id(i_f_n))
-        f_a_id(i_f_n) = -1
-      ENDIF
-    ENDIF
-  ENDIF
-!---------------------
-END SUBROUTINE flrb_cf
-!===
-SUBROUTINE flrb_rg
-!---------------------------------------------------------------------
-! Update valid_min valid_max attributes values
-!---------------------------------------------------------------------
-  INTEGER :: k,j
-  LOGICAL :: l_vmin,l_vmax
-  INTEGER(KIND=i_4) :: i4_vmin,i4_vmax
-  REAL(KIND=r_4) :: r4_vmin,r4_vmax
-  REAL(KIND=r_8) :: r8_vmin,r8_vmax
-!---------------------------------------------------------------------
-  DO k=1,f_v_nb
-!-- get attribute informations
-    CALL flioinqa &
- &    (f_id_i1,TRIM(f_v_nm(k)),'valid_min',l_vmin,a_t=a_type)
-    CALL flioinqa &
- &    (f_id_i1,TRIM(f_v_nm(k)),'valid_max',l_vmax,a_t=a_type)
-!---
-    IF (l_vmin.OR.l_vmax) THEN
-!---- get values of min/max
-      SELECT CASE (a_type)
-      CASE (flio_i1,flio_i2,flio_i4) !--- INTEGER 1/2/4
-        DO j=1,f_nb_in
-          CALL flrb_of (j,f_id_i)
-          IF (l_vmin) THEN
-            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",i4_0d)
-            IF (j == 1) THEN
-              i4_vmin = i4_0d
-            ELSE
-              i4_vmin = MIN(i4_vmin,i4_0d)
-            ENDIF
-          ENDIF
-          IF (l_vmax) THEN
-            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",i4_0d)
-            IF (j == 1) THEN
-              i4_vmax = i4_0d
-            ELSE
-              i4_vmax = MAX(i4_vmax,i4_0d)
-            ENDIF
-          ENDIF
-          CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
-        ENDDO
-        IF (l_vmin) THEN
-          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",i4_vmin)
-        ENDIF
-        IF (l_vmax) THEN
-          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",i4_vmax)
-        ENDIF
-      CASE (flio_r4) !--- REAL 4
-        DO j=1,f_nb_in
-          CALL flrb_of (j,f_id_i)
-          IF (l_vmin) THEN
-            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",r4_0d)
-            IF (j == 1) THEN
-              r4_vmin = r4_0d
-            ELSE
-              r4_vmin = MIN(r4_vmin,r4_0d)
-            ENDIF
-          ENDIF
-          IF (l_vmax) THEN
-            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",r4_0d)
-            IF (j == 1) THEN
-              r4_vmax = r4_0d
-            ELSE
-              r4_vmax = MAX(r4_vmax,r4_0d)
-            ENDIF
-          ENDIF
-          CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
-        ENDDO
-        IF (l_vmin) THEN
-          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",r4_vmin)
-        ENDIF
-        IF (l_vmax) THEN
-          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",r4_vmax)
-        ENDIF
-      CASE (flio_r8) !--- REAL 8
-        DO j=1,f_nb_in
-          CALL flrb_of (j,f_id_i)
-          IF (l_vmin) THEN
-            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",r8_0d)
-            IF (j == 1) THEN
-              r8_vmin = r8_0d
-            ELSE
-              r8_vmin = MIN(r8_vmin,r8_0d)
-            ENDIF
-          ENDIF
-          IF (l_vmax) THEN
-            CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",r8_0d)
-            IF (j == 1) THEN
-              r8_vmax = r8_0d
-            ELSE
-              r8_vmax = MAX(r8_vmax,r8_0d)
-            ENDIF
-          ENDIF
-          CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
-        ENDDO
-        IF (l_vmin) THEN
-          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",r8_vmin)
-        ENDIF
-        IF (l_vmax) THEN
-          CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",r8_vmax)
-        ENDIF
-      END SELECT
-    ENDIF
-  ENDDO
-!---------------------
-END SUBROUTINE flrb_rg
-!===
-!--------------------
-END PROGRAM flio_rbld
Index: IOIPSL/trunk/tools/ncregular.f90
===================================================================
--- IOIPSL/trunk/tools/ncregular.f90	(revision 4999)
+++ 	(revision )
@@ -1,328 +1,0 @@
-PROGRAM ncregular
-!
-!$Id$
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!---------------------------------------------------------------------
-!- This code replaces a 2D surface grid by vectors.
-!- Obviously it only works if you have a regular grid.
-!-
-!- Jan Polcher (polcher@lmd.jussieu.fr)
-!- Jacques Bellier (jacques.bellier@cea.fr)
-!---------------------------------------------------------------------
-  USE netcdf
-!-
-  IMPLICIT NONE
-!-
-  INTEGER :: iread, if, in, iv, sz
-  INTEGER :: ier, nb_files, iret, ndims, nvars, nb_glat
-  INTEGER :: lon_dim_id, lat_dim_id
-  INTEGER :: lon_len, lat_len, lon_id, lat_id
-  INTEGER :: nav_lon_id, nav_lat_id
-  INTEGER :: alloc_stat_lon, alloc_stat_lat
-!-
-  INTEGER,ALLOCATABLE ::  file_id(:), tax_id(:)
-  CHARACTER(LEN=80),ALLOCATABLE :: names(:)
-  CHARACTER(LEN=80) :: dim_name
-  CHARACTER(LEN=80) :: varname
-  CHARACTER(LEN=20) :: xname, yname, lonname, latname
-  LOGICAL :: check, regular
-!-
-  REAL,ALLOCATABLE :: lon(:), lat(:), lon2(:), lat2(:)
-  REAL,ALLOCATABLE :: del_lon(:), del_lat(:)
-!-
-  INTEGER iargc, getarg
-  EXTERNAL iargc, getarg
-!---------------------------------------------------------------------
-  alloc_stat_lon = 0
-  alloc_stat_lat = 0
-!-
-  iread = iargc()
-!-
-  ALLOCATE (names(iread),stat=ier)
-  IF (ier /= 0) THEN
-    WRITE (*,*) ' Could not allocate names of size ', iread
-    STOP 'nctax'
-  ENDIF
-!-
-  CALL nct_getarg (iread, nb_files, names, check, &
- &                 xname, yname, lonname, latname)
-!-
-! Allocate space
-!-
-  ALLOCATE (file_id(nb_files),stat=ier)
-  IF (ier /= 0) THEN
-    WRITE (*,*) ' Could not allocate file_id of size ', nb_files
-    STOP 'nctax'
-  ENDIF
-!-
-  ALLOCATE (tax_id(nb_files),stat=ier)
-  IF (ier /= 0) THEN
-    WRITE (*,*) ' Could not allocate tax_id of size ', nb_files
-    STOP 'nctax'
-  ENDIF
-!-
-  DO if=1,nb_files
-!---
-    IF (check) THEN
-      WRITE(*,*) 'ncregular : ', if,  names(if)
-    ENDIF
-!---
-    iret = NF90_OPEN (names(if),NF90_WRITE,file_id(if))
-    iret = NF90_INQUIRE (file_id(if),ndims,nvars,nb_glat,tax_id(if))
-!---
-!-- Get the IDs of the variables
-!---
-    lon_len = -9999
-    lat_len = -9999
-    DO in=1,ndims
-!-----
-      iret = NF90_INQUIRE_DIMENSION (file_id(if), in, dim_name, sz)
-!-----
-      IF (     (LEN_TRIM(dim_name) == 1) &
- &        .AND.(INDEX(dim_name,TRIM(xname)) == 1) ) THEN
-        lon_dim_id = in
-        lon_len = sz
-      ENDIF
-!-----
-      IF (     (LEN_TRIM(dim_name) == 1) &
- &        .AND.(INDEX(dim_name,TRIM(yname)) == 1) ) THEN
-        lat_dim_id = in
-        lat_len = sz
-      ENDIF
-!-----
-    ENDDO
-!---
-    IF ( (lon_len == -9999).OR.(lat_len == -9999) ) THEN
-      WRITE(*,*) 'ncregular : The specified dimensions were not'
-      WRITE(*,*) 'found in file : ',names(if)
-      iret = NF90_CLOSE (file_id(if))
-      STOP
-    ENDIF
-!---
-    IF (check) THEN
-      WRITE(*,*) 'ncregular : lon_dim_id, lon_len',lon_dim_id,lon_len
-      WRITE(*,*) 'ncregular : lat_dim_id, lat_len',lat_dim_id,lat_len
-    ENDIF
-!---
-!-- Look for the right variables
-!---
-    nav_lon_id = -9999
-    nav_lat_id = -9999
-    DO iv=1,nvars
-      iret = NF90_INQUIRE_VARIABLE (file_id(if),iv,name=varname)
-      IF (INDEX(varname,TRIM(lonname)) > 0) THEN
-        nav_lon_id = iv
-      ENDIF
-      IF (INDEX(varname,TRIM(latname)) > 0) THEN
-        nav_lat_id = iv
-      ENDIF
-    ENDDO
-!---
-    IF ( (nav_lon_id == -9999).OR.(nav_lat_id == -9999) ) THEN
-      WRITE(*,*) 'ncregular : The specified coordinate fields'
-      WRITE(*,*) 'were not found in file : ',names(if)
-      iret = NF90_CLOSE (file_id(if))
-      STOP
-    ENDIF
-!---
-    IF (check) THEN
-      WRITE(*,*) 'ncregular : nav_lon_id :', nav_lon_id
-      WRITE(*,*) 'ncregular : nav_lat_id :', nav_lat_id
-    ENDIF
-!---
-!-- Read variables from file and check if regular
-!---
-!-- Do we have the variable to read the
-!---
-    IF ( alloc_stat_lon < lon_len) THEN
-      IF ( alloc_stat_lon > 0) THEN
-        deallocate(lon)
-        deallocate(lon2)
-        deallocate(del_lon)
-      ENDIF
-      allocate(lon(lon_len))
-      allocate(lon2(lon_len))
-      allocate(del_lon(lon_len))
-      alloc_stat_lon = lon_len
-    ENDIF
-!---
-    IF ( alloc_stat_lat < lat_len) THEN
-      IF ( alloc_stat_lat > 0) THEN
-        deallocate(lat)
-        deallocate(lat2)
-        deallocate(del_lat)
-      ENDIF
-      allocate(lat(lat_len))
-      allocate(lat2(lat_len))
-      allocate(del_lat(lat_len))
-      alloc_stat_lat = lat_len
-    ENDIF
-!---
-!-- Read data
-!---
-    iret = NF90_GET_VAR (file_id(if),nav_lon_id,lon, &
- & start=(/1,1/),count=(/lon_len,1/),stride=(/1,1/))
-    iret = NF90_GET_VAR (file_id(if),nav_lon_id,lon2, &
- & start=(/1,int(lat_len/2)/),count=(/lon_len,1/),stride=(/1,1/))
-    del_lon = lon-lon2
-!-
-    iret = NF90_GET_VAR (file_id(if),nav_lat_id,lat, &
- & start=(/1,1/),count=(/1,lat_len/),stride=(/lon_len,1/))
-    iret = NF90_GET_VAR (file_id(if),nav_lat_id,lat2, &
- & start=(/int(lon_len/2),1/),count=(/1,lat_len/),stride=(/lon_len,1/))
-    del_lat = lat-lat2
-!-
-    regular = (    (MAXVAL(del_lon) < 0.001) &
- &             .OR.(MAXVAL(del_lat) < 0.001) )
-!---
-!-- Create the new variables
-!---
-    IF (regular) THEN
-      IF (check) THEN
-        WRITE(*,*) 'Regular case'
-      ENDIF
-      iret = NF90_REDEF (file_id(if))
-      iret = NF90_RENAME_DIM (file_id(if), lon_dim_id, 'lon')
-      iret = NF90_RENAME_DIM (file_id(if), lat_dim_id, 'lat')
-      IF (check) THEN
-        WRITE(*,*) 'Dimensions renamed'
-      ENDIF
-      iret = NF90_DEF_VAR (file_id(if), 'lon', NF90_FLOAT, &
- &                         lon_dim_id, lon_id)
-      iret = NF90_DEF_VAR (file_id(if), 'lat', NF90_FLOAT, &
- &                         lat_dim_id, lat_id)
-      IF (check) THEN
-        WRITE(*,*) 'New variables defined'
-      ENDIF
-!-----
-!---- Copy attributes
-!-----
-      iret = NF90_COPY_ATT (file_id(if),nav_lon_id,'units', &
- &                          file_id(if),lon_id)
-      iret = NF90_COPY_ATT (file_id(if),nav_lon_id,'title', &
- &                          file_id(if),lon_id)
-      iret = NF90_COPY_ATT (file_id(if),nav_lon_id,'valid_max', &
- &                          file_id(if),lon_id)
-      iret = NF90_COPY_ATT (file_id(if),nav_lon_id,'valid_min', &
- &                          file_id(if),lon_id)
-!-----
-      iret = NF90_COPY_ATT (file_id(if),nav_lat_id,'units', &
- &                          file_id(if),lat_id)
-      iret = NF90_COPY_ATT (file_id(if),nav_lat_id,'title', &
- &                          file_id(if),lat_id)
-      iret = NF90_COPY_ATT (file_id(if),nav_lat_id,'valid_max', &
- &                          file_id(if),lat_id)
-      iret = NF90_COPY_ATT (file_id(if),nav_lat_id,'valid_min', &
- &                          file_id(if),lat_id)
-!-----
-!---- Go into write mode
-!-----
-      iret = NF90_ENDDEF (file_id(if))
-!-----
-!---- Write data
-!-----
-      iret = NF90_PUT_VAR (file_id(if),lon_id,lon(1:lon_len))
-      iret = NF90_PUT_VAR (file_id(if),lat_id,lat(1:lat_len))
-!-
-      iret = NF90_CLOSE (file_id(if))
-    ELSE
-      WRITE(*,*) 'ncregular : Your grid is not regular'
-      WRITE(*,*) names(if), 'remains unchanged'
-      iret = NF90_CLOSE (file_id(if))
-    ENDIF
-!-
-  ENDDO
-!--------------------
-END PROGRAM ncregular
-!-
-!===
-!-
-SUBROUTINE nct_getarg (argx, nb_files, names, check, &
- &                     xname, yname, lonname, latname)
-!---------------------------------------------------------------------
-!- Read the arguments of nctax.
-!---------------------------------------------------------------------
-  INTEGER,INTENT(in) :: argx
-  INTEGER, INTENT(out) :: nb_files
-  CHARACTER(LEN=80),INTENT(out) :: names(argx)
-  CHARACTER(LEN=20) :: xname, yname, lonname, latname
-!-
-  CHARACTER(LEN=80) :: tmp, tmp_arg
-  LOGICAL :: check
-!---------------------------------------------------------------------
-  check = .FALSE.
-!-
-! Get the number of arguments
-!-
-  nb_files = 0
-!-
-  xname = 'x'
-  yname = 'y'
-  lonname = 'nav_lon'
-  latname = 'nav_lat'
-!-
-! Go through the arguments and analyse them one by one
-!-
-  IF (check) WRITE(*,*) 'Start going through the arguments'
-!-
-  IF (argx == 0) THEN
-    WRITE(*,*) 'To get usage : nctax -h '
-    STOP
-  ENDIF
-!-
-  iread = 1
-  DO WHILE (iread <= argx)
-    iret = getarg(iread,tmp)
-    IF (check) WRITE(*,*) ' iread, tmp :', iread, tmp
-    SELECTCASE(tmp)
-      CASE('-d')
-        WRITE(*,*) 'DEBUG MODE SELECTED'
-        check = .TRUE.
-        iread = iread+1
-      CASE('-h')
-        WRITE(*,*) 'Usage : nregular [options] file1 [file2 ...]'
-        WRITE(*,*) '    -d : Verbose mode'
-        WRITE(*,*) '    -h : This output'
-        STOP
-      CASE('-dim_lon')
-        iread = iread+1
-        iret  = getarg(iread,tmp_arg)
-        xname = TRIM(tmp_arg)
-        iread = iread+1
-      CASE('-dim_lat')
-        iread = iread+1
-        iret  = getarg(iread,tmp_arg)
-        yname = TRIM(tmp_arg)
-        iread = iread+1
-      CASE('-coo_lon')
-        iread = iread+1
-        iret  = getarg(iread,tmp_arg)
-        lonname = TRIM(tmp_arg)
-        iread = iread+1
-      CASE('-coo_lat')
-        iread = iread+1
-        iret  = getarg(iread,tmp_arg)
-        latname = TRIM(tmp_arg)
-        iread = iread+1
-      CASE DEFAULT
-        IF (check) WRITE(*,*) 'nct_getarg : CASE default'
-        IF (INDEX(tmp,'-') /= 1) THEN
-          nb_files = nb_files+1
-          names(nb_files) = tmp
-          iread = iread+1
-        ELSE
-          WRITE(*,*) "WARNING Unknown option ",tmp
-          WRITE(*,*) "For ore information : nctax -h"
-        ENDIF
-    END SELECT
-  ENDDO
-!-
-  IF (check) THEN
-    WRITE(*,*) ' nct_getarg : output >> '
-    WRITE(*,*) '>> nb_files : ', nb_files
-    WRITE(*,*) '>> names :', (names(ii), ii=1,nb_files)
-  ENDIF
-!------------------------
-END SUBROUTINE nct_getarg
Index: IOIPSL/trunk/tools/ncunderflow.f90
===================================================================
--- IOIPSL/trunk/tools/ncunderflow.f90	(revision 4999)
+++ 	(revision )
@@ -1,393 +1,0 @@
-MODULE declare
-! -*- Mode: f90 -*-
-!$Id$
-!-
-! This software is governed by the CeCILL license
-! See IOIPSL/IOIPSL_License_CeCILL.txt
-!-
-! f90 -L/usr/local/lib -lnetcdf -align dcommons -g
-!     -ladebug -check format -check bounds
-!     -check output_conversion -fpe1
-!     -I/usr/local/include -free -arch host -tune host
-!     -warn declarations -warn argument_checking
-!     ncunderflow.f  -o ncunderflow
-!
-! ifc -FR -cl,ncunderflow.pcl -o ncunderflow ncunderflow.f
-!     -L/usr/local/install/netcdf/lib/libnetcdf.a -lPEPCF90
-!
-  IMPLICIT NONE
-  INTEGER, PARAMETER :: r4 = 4, r8 = 8, i4 = 4, i8 = 8
-  INTEGER, PARAMETER :: il = KIND(1)
-  LOGICAL :: ldebug = .FALSE.
-  INTEGER (kind = il) :: nout = 0, nerr = 0         ! Standard output, standard error
-  CHARACTER (LEN=4), PARAMETER :: cerror = 'VOID'
-END MODULE declare
-!!
-MODULE mod_nfdiag
-CONTAINS
-  SUBROUTINE nfdiag ( kios, clmess, lcd)
-    !!
-    !! Imprime un message d'erreur NetCDF
-    !!
-    USE declare
-    IMPLICIT NONE
-    INCLUDE 'netcdf.inc'
-    !!
-    INTEGER (kind=i4), INTENT (in) :: kios
-    CHARACTER (len = *), INTENT (in) :: clmess
-    LOGICAL, INTENT (in), OPTIONAL :: lcd 
-    CHARACTER (len = 80) :: clt
-    LOGICAL :: ld
-    !!
-    IF ( PRESENT ( lcd)) THEN
-        ld = lcd
-    ELSE
-        ld = ldebug
-    ENDIF
-    !!
-    clt = TRIM ( NF_STRERROR ( kios) )
-    !!
-    IF ( ld ) THEN 
-        IF ( kios == NF_NOERR ) THEN 
-            WRITE ( unit = nout, fmt = * ) "OK : ", TRIM (clmess)
-        ELSE
-            WRITE ( unit = nout, fmt = * ) "ERROR : ", TRIM (clmess), " : ", TRIM ( clt), " : ", kios
-            IF ( .NOT. ld ) STOP
-        END IF
-    ELSE
-        IF ( kios /= NF_NOERR ) THEN 
-            WRITE ( unit = nout, fmt = * ) "ERROR : ", TRIM (clmess), " : ", TRIM ( clt), " : ", kios
-            STOP
-        END IF
-    ENDIF
-    !!
-    RETURN
-    !!
-  END SUBROUTINE nfdiag
-  !!
-END MODULE mod_nfdiag
-
-MODULE mod_lec
-CONTAINS
-  !!
-  SUBROUTINE lec (chaine, cval, c_c)
-    !!
-    USE declare
-    IMPLICIT NONE
-    !!
-    CHARACTER (len = *), INTENT ( inout) :: chaine
-    CHARACTER (len = *), INTENT ( inout) :: cval
-    CHARACTER (len=*), OPTIONAL :: c_c
-    INTEGER (kind = il) :: ji, ji1, ji2, ji3, jl, jb
-    INTEGER (kind = i4) :: index
-    !!
-    !! Read character string up to ':' or ',', or in c_c if present
-    !! Returns the real before the character (xerror if not available)
-    !! Reduce the string
-    !!
-    jl = LEN (chaine) ; jb = LEN_TRIM (chaine)
-    IF ( ldebug) WRITE ( nout, *) 'Lec : jl, jb ', jl, jb
-    IF ( jb == 0 ) THEN 
-        cval = cerror
-    ELSE
-        ji1 = INDEX (chaine, ':') ; ji2 = INDEX (chaine, ',')
-        IF ( PRESENT (c_c)) THEN 
-            ji3 = INDEX (chaine, c_c) ; ji = MAX (ji1, ji2, ji3)
-        ELSE
-            ji = MAX (ji1, ji2)
-        ENDIF
-        IF ( ji == 0 ) THEN 
-            READ ( chaine (1:jb) , fmt = * ) cval
-            chaine (1:jl-jb) = chaine (jb+1:jl)
-        ELSE IF ( ji == 1 ) THEN 
-            cval = cerror
-            chaine (1:jl-1) = chaine (2:jl)
-        ELSE
-            cval = chaine (1:ji-1)
-            chaine (1:jl-ji) = chaine (ji+1:jl )
-        END IF
-    END IF
-    !!
-  END SUBROUTINE lec
-END MODULE mod_lec
-
-PROGRAM ncunderflow
-
-  ! Ce programme ouvre un fichier de donnees au format netcdf
-  ! et met a zero toutes les valeurs trop petites pour etre
-  ! representees par un reel sur 4 octets au format IEEE
-  !
-  ! Revision 2.0  2004/04/05 14:47:50  adm
-  ! JB+MAF+AC: switch to IOIPSL 2.0 (1)
-  !
-  ! Revision 1.1  2003/04/09 15:21:56  adm
-  ! add ncunderflow in IOIPSL
-  ! and modify AA_make to take it into account
-  ! SD + MAF
-  !
-  ! Revision 1.1  2001/02/07  14:36:07  jypeter
-  ! J-Y Peterschmitt / LMCE / 07/02/2001
-  ! Initial revision
-  !
-  USE declare
-  USE mod_nfdiag
-  USE mod_lec
-  IMPLICIT NONE
-
-  INCLUDE 'netcdf.inc'
-
-  INTEGER (kind=il), EXTERNAL :: iargc
-
-  ! Nombre maximal de dimensions : 6
-
-  INTEGER (kind=il), PARAMETER :: jpmaxdim = 6, jpmaxvar = 1024
-
-  CHARACTER (len = 128) :: clnomprog, clnomfic
-  CHARACTER (len = 1024) :: clistvar, clecline
-  CHARACTER (len = 128), DIMENSION(jpmaxdim) :: clnomdim
-  CHARACTER (len = 128), DIMENSION(jpmaxvar) :: clvarcmd, clvarfic, clvar ! Nom des variables dans le fichier est sur la ligne de commande.
-  LOGICAL :: lrever = .FALSE. ! Si .true., on traite toutes les variables sauf celle de la ligne de commande
-  LOGICAL :: lnocoord = .FALSE. ! Si .truee., on exclu les variables coordonnées
-  LOGICAL :: lverbose = .TRUE.
-  
-  INTEGER (kind=il) :: incid, ircode, ivarid, ivartype, inbdim, inbatt
-  INTEGER (kind=il) :: nvarcmd, nvarfic, nvar, nfile, jvarcmd, jvarfic, jvar, jfile, ierr
-  INTEGER (kind=il) :: ji, jdim3, jdim4, jdim5, jdim6, j1, j2, j3, jarg, ncumul
-  INTEGER (kind=il), DIMENSION(jpmaxdim) :: idimid, idimsize, istart, icount
-  REAL (kind=r4), DIMENSION(:,:), ALLOCATABLE :: zdatacorr
-  REAL (kind=r8), DIMENSION(:,:), ALLOCATABLE :: zdata
-  REAL (kind=r4) :: reps = TINY (1.0_r4) * 10.0_r4
-  LOGICAL :: lok
-
-  ! Verification du nombre de parametres
-  IF(iargc() .LT. 2) THEN
-      CALL usage
-      STOP
-  ENDIF
-
-  ! Aide
-  jarg = 1
-  Lab1: DO WHILE ( jarg <= 3 )
-    IF (ldebug) WRITE(nout,*) 'lecture ligne commande ', jarg
-    CALL getarg (jarg,clecline)
-    IF ( clecline(1:1) /= '-' ) EXIT Lab1
-    IF ( clecline(1:2) == '-h' .OR. clecline(1:2) == '-?'  ) THEN
-        CALL usage
-        STOP 
-    ELSE IF ( clecline(1:2) == '-x' ) THEN
-        lrever = .TRUE. 
-    ELSE IF ( clecline(1:2) == '-d' ) THEN
-        ldebug = .TRUE. 
-    ELSE IF ( clecline(1:2) == '-V' ) THEN
-        lverbose = .FALSE. 
-    ELSE IF ( clecline(1:2) == '-v' ) THEN
-        jarg = jarg + 1
-        ! Recuperation des noms de variables
-        IF (ldebug) WRITE(nout,*) 'lecture liste vriables ', jarg
-        CALL getarg (jarg,clistvar)
-        clistvar = TRIM(ADJUSTL(clistvar))
-        jvarcmd = 0 ; nvarcmd = 0
-        SeekVar: DO WHILE ( .TRUE. )
-          CALL lec ( clistvar, clvarcmd(jvarcmd+1)(:) )
-          IF ( TRIM(clvarcmd(jvarcmd+1)(:)) == cerror ) EXIT SeekVar
-          jvarcmd = jvarcmd + 1
-          nvarcmd = jvarcmd
-          IF (ldebug) WRITE(nout,*) 'affecte variable ', jvarcmd, TRIM(clvarcmd(jvarcmd))
-        END DO SeekVar
-    ENDIF
-    jarg = jarg + 1
-  END DO Lab1
-
-  ! Boucle sur les fichiers
-  FileLoop: DO jfile = jarg, iargc()
-    
-    ! Recuperation du nom du fichier a traiter
-    CALL getarg ( jfile, clnomfic)
-    
-    ! Ouverture du fichier
-    CALL nfdiag ( NF_OPEN ( TRIM(clnomfic), NF_WRITE, incid ), "Opening " // TRIM(clnomfic) )
-    WRITE (nout,*) TRIM(clnomfic)
-
-    ! Recuparation de la liste des variables du fichier
-    nvarfic = 0
-    DO jvarfic = 1, jpmaxvar
-      j3 = NF_INQ_VAR ( incid, jvarfic, clvarfic(jvarfic)(:), ivartype, inbdim, idimid, inbatt)
-      IF ( j3 /= NF_NOERR ) EXIT
-      nvarfic = jvarfic
-    END DO
-
-    ! Liste des variables a traiter
-    IF ( lrever ) THEN
-        IF ( nvarcmd == 0) THEN 
-            clvar = clvarfic
-            nvar  = nvarfic
-        ELSE 
-            jvar = 0
-            DO jvarfic = 1, nvarfic
-              lok = .TRUE.
-              DO jvarcmd = 1, nvarcmd
-                IF ( TRIM(clvarfic(jvarfic)(:)) == TRIM(clvarcmd(jvarcmd)(:)) ) THEN
-                    lok = .FALSE.
-                END IF
-              END DO
-              IF ( lok) THEN 
-                  jvar = jvar + 1
-                  clvar(jvar) = clvarfic(jvarfic)
-              END IF
-            END DO
-            nvar = jvar
-        END IF
-    ELSE
-        clvar = clvarcmd
-        nvar  = nvarcmd
-    END IF
-
-    ncumul = 0
-    VarLoop: DO jvar = 1, nvar 
-      
-      IF (lverbose) &
-         & WRITE(nout, FMT='("Correction de ", A, " dans ", A, " : ", $)') TRIM(clvar(jvar)(:)), TRIM(clnomfic)
-
-      ! Passage de netcdf en mode 'erreurs non fatales'
-      !  CALL ncpopt(NCVERBOS)
-      ! En fait, on reste dans le mode par defaut, dans lequel une erreur
-      ! netcdf cause un arret du programme. Du coup, il n'est pas
-      ! necessaire de tester la valeur de la variable ircode
-      ! ATTENTION! Si jamais on veut arreter le programme a cause d'une
-      ! erreur ne provenant pas de netcdf, il faut penser a fermer
-      ! manuellement le fichier avec un appel a ncclos
-      
-      ! Recuperation de l'identificateur de la variable
-      CALL nfdiag ( NF_INQ_VARID ( incid, TRIM(clvar(jvar)(:)), ivarid), "Get var id " // TRIM(clvar(jvar)(:)))
-
-      ivartype = 0 ; idimid = 0 ; inbdim = 0 ; inbatt = 0
-      ! Recuperation du nombre de dimensions de la variable
-      CALL nfdiag ( NF_INQ_VAR ( incid, ivarid, clvar(jvar)(:), ivartype, inbdim, idimid, inbatt),  &
-         & "Get var info " // TRIM(clvar(jvar)(:)))
-      
-      IF(inbdim .GT. jpmaxdim) THEN
-          WRITE(nout,*)
-          WRITE(nout, *) 'La variable ', TRIM(clvar(jvar)(:)), ' a trop de dimensions'
-          CALL nfdiag ( NF_CLOSE (incid), "Closing file")
-          STOP
-      ENDIF
-      
-      ! Recuperation des dimensions effectives
-      idimsize(3:jpmaxdim) = 1 ! Au cas ou la variable n'ait que
-      ! 2 ou 3 dims, on initialise ces valeurs
-      ! qui serviront dans le controle des boucles
-      ! et qui auraient une valeur indefinie sinon
-      DO ji = 1, inbdim
-        CALL nfdiag ( NF_INQ_DIM ( incid, idimid(ji), clnomdim(ji), idimsize(ji)), "NF_INQ_DIM")
-        IF (lverbose) WRITE(nout, '(A,A,A,I3,$)') '    ', TRIM(clnomdim(ji)), ' = ', idimsize(ji)
-        IF ( idimsize(ji) == 0 ) THEN
-            WRITE(nout, '(A,A,A,A,I3)') TRIM(clvar(jvar)(:)), ', ', TRIM(clnomdim(ji)), ' = ', idimsize(ji)
-            CYCLE VarLoop
-        END IF
-      ENDDO
-      IF (lverbose) WRITE(nout,*)
-      idimsize = MAX ( idimsize, 1)
-      ncumul = ncumul + 1
-      
-      ! Determination du type de la variable, en fonction du nom de
-      ! la premiere dimension
-!$$$  IF(INDEX(TRIM(clnomdim(1)),'ongitude') .NE. 0) THEN
-!$$$      ! var de type map ou 3d
-!$$$      write(nout, *) '  --> MAP/3D'
-!$$$  ELSE IF(INDEX(TRIM(clnomdim(1)),'atitude') .NE. 0) THEN
-!$$$      ! var de type xsec 
-!$$$      write(nout, *) '  --> XSEC'
-!$$$  ELSE
-!$$$      WRITE(nout, *)
-!$$$      WRITE(nout, *) 'Bizarre, la premiere dimension n''est ni "longitude" ni "latitude"'
-!$$$      CALL ncclos(incid, ircode)
-!$$$      STOP
-!$$$  ENDIF
-
-      ! Reservation de memoire pour charger et traiter
-      ! une grille idimsize(1)*idimsize(2) de la variable
-      ALLOCATE(zdata(idimsize(1), idimsize(2)), stat=ierr)
-      IF(ierr .NE. 0) THEN
-          WRITE(nout, *) 'Erreur d''allocation memoire pour zdata'
-          CALL nfdiag ( NF_CLOSE (incid), "NF_CLOSE")
-          STOP
-      ENDIF
-      ALLOCATE(zdatacorr(idimsize(1), idimsize(2)), stat=ierr)
-      IF(ierr .NE. 0) THEN
-          WRITE(nout, *) 'Erreur d''allocation memoire pour zdatacorr'
-          CALL nfdiag ( NF_CLOSE (incid), "NF_CLOSE")
-          STOP
-      ENDIF
-
-      ! Parametrisation de la partie de la variable a charger en memoire
-      ! (une 'grille' que l'on lira autant de fois qu'il y a de niveaux et
-      !  de pas de temps)
-      ! Rappel : seuls les elements 1..inbdim des tableaux sont
-      ! significatifs et utiles
-
-      icount = 0
-      
-      DO jdim6 = 1, idimsize(6)
-        DO jdim5 = 1, idimsize(5)
-          DO jdim4 = 1, idimsize(4)
-            DO jdim3 = 1, idimsize(3)
-              istart = (/   1        ,      1      , jdim3, jdim4, jdim5, jdim6 /)
-              icount = (/ idimsize(1),  idimsize(2),   1  ,  1   ,  1   ,  1    /)
-
-              ! Chargement d'une 'grille' de donnees, en real*8
-              CALL nfdiag ( NF_GET_VARA_DOUBLE(incid, ivarid, istart(1:inbdim), icount(1:inbdim), zdata), &
-                 & "NF_GET_VARA_DOUBLE")
-              ! Mise a zero de toutes les valeurs trop petites pour etre
-              ! representees par un reel sur 4 octets au format IEEE.
-              ! Le truc est de faire une operation nulle (addition de 0)
-              ! sur des donnees qui posent problemes, EN AYANT COMPILE LE PROG
-              ! AVEC l'OPTION "-fpe1". Dans ce cas, les valeurs trop petites
-              ! sont remplacees par zero (0.0) et le programme continue,
-              ! au lieu de planter.
-              ! Il est possible de faire afficher le nb de valeurs qui ont pose
-              ! un pb en utilisant en plus l'option "-check underflow"
-              zdata = zdata + 0.0_r8
-              zdatacorr = REAL(zdata, KIND=r4)
-              WHERE ( ABS (zdatacorr) < reps) zdatacorr = 0.0_r4
-              
-              ! Sauvegarde de la grille corrigee dans le fichier
-              ! (a la place de la grille initiale), en real*4
-              CALL nfdiag ( NF_PUT_VARA_REAL(incid, ivarid, istart, icount, zdatacorr), "NF_PUT_VARA_REAL" )
-              
-            END DO
-          END DO
-        END DO
-      END DO
-      
-      DEALLOCATE ( zdata)
-      DEALLOCATE ( zdatacorr)
-      
-    END DO VarLoop
-    
-    WRITE (nout,*) 'ncunderflow, nombre de variables corrigees : ', ncumul
-
-    ! Fermeture du fichier
-    CALL nfdiag ( NF_CLOSE (incid), "Closing" )
-    
-  END DO FileLoop
-
-CONTAINS
-  SUBROUTINE usage
-    IMPLICIT NONE
-    CALL getarg (0, clnomprog)
-
-    WRITE(nout, FMT='("Command : ", A)') TRIM(clnomprog)
-    WRITE(nout, FMT='("Removes underflows in NetCDF files") ')
-    WRITE(nout, FMT='("Usage : ", A, " [-x] [-V] [-d] -v nomvar[,nomvar] nomfic [nomfic]")' ) TRIM(clnomprog)
-    WRITE(nout, FMT='("Options : ")' )
-    WRITE(nout, FMT='("  -V : mode verbose off. Default is verbose on.")' )
-    WRITE(nout, FMT='("  -d : debug mode on. Default is debug off.")' )
-    WRITE(nout, FMT='("  -v : gives list of variables to be corrected, separated by a coma.")' )
-    WRITE(nout, FMT='("  -x : reverses meaning of -v : given variable are not corrected")' )
-    WRITE(nout, FMT='("       if -x is given, and not -v, all variables are corrected.")' )
-    
-    
-    STOP
-  END SUBROUTINE usage
-  
-END PROGRAM ncunderflow
Index: IOIPSL/trunk/tools/rebuild
===================================================================
--- IOIPSL/trunk/tools/rebuild	(revision 4999)
+++ 	(revision )
@@ -1,110 +1,0 @@
-#!/bin/ksh
-#
-#$Id$
-#
-# This software is governed by the CeCILL license
-# See IOIPSL/IOIPSL_License_CeCILL.txt
-#---------------------------------------------------------------------
-# @(#)Rebuild IOIPSL domains
-#---------------------------------------------------------------------
-function rebuild_Usage
-{
-print - "
-\"${b_n}\"
-  rebuild a model_file from several input files.
-Each input file contains the model_data for a domain.
-
-Usage :
-  ${b_n} [-h]
-  ${b_n} [-v level] [-f] -o output_file_name input_file_names
-
-Options :
-  -h         : help
-  -v O/1/2/3 : verbose mode (verbosity increasing with level)
-  -f         : executing mode
-               (execute the program even if the number of input files
-                is not equal to the total number of domains)
-"
-}
-#-
-#set -xv
-#-
-# Extract the calling sequence of the script (d_n/b_n)
-#-
-d_n=${0%/*}; b_n=${0##*/};
-#-
-# Retrieving the options
-#-
-r_v='0'; r_f='noforce'; r_o="";
-while getopts :hv:fo: V
- do
-  case $V in
-   (h) rebuild_Usage; exit 0;;
-   (v) r_v=${OPTARG};;
-   (f) r_f='force';;
-   (o) r_o=${OPTARG};;
-   (:) print -u2 "${b_n} : missing value for option $OPTARG"; exit 2;;
-   (\?) print -u2 "${b_n} : option $OPTARG not supported"; exit 2;;
-  esac
- done
-shift $(($OPTIND-1));
-#-
-# Validate the -v option
-#-
-case ${r_v} in
-  ( 0 | 1 | 2 | 3 );;
-  ("") r_v='0';;
-  (*)
-    print -u2 "${b_n} :";
-    print -u2 "Invalid verbosity level requested : ${r_v}";
-    print -u2 "(must be 0, 1, 2 or 3)";
-    exit 1;;
-esac
-#-
-# Validate the number of arguments
-#-
-[[ ${#} < 1 ]] && \
- {
-  print -u2 "${b_n} : Too few arguments have been specified. (Use -h)";
-  exit 3;
- }
-#-
-# Check for the output file name
-#-
-[[ -z ${r_o} ]] && \
- {
-  r_o='rebuilt_file.nc';
-  print -u2 - "
-   ${b_n} : output_file_name not specified. (Use -h)
-            rebuilt_file.nc should be created."
- }
-#-
-# Validate the names of the input files
-#-
-for i in $*;
- do
-  [[ ! -f ${i} ]] && { echo "${i} unreachable ..."; exit 3;}
- done
-#-
-# Create the information file for the program
-#-
-echo ${r_v} > tmp.$$;
-echo ${r_f} >> tmp.$$;
-echo $((${#}+1)) >> tmp.$$;
-for i in $*;
- do echo ${i} >> tmp.$$;
- done
-echo ${r_o} >> tmp.$$;
-#-
-# Create the output file
-#-
-${d_n}/flio_rbld < tmp.$$
-r_c=$?
-#-
-# Clear
-#-
-rm -f tmp.$$
-#-
-# End
-#-
-exit ${r_c};
Index: IOIPSL/trunk/tools/tkcond.c
===================================================================
--- IOIPSL/trunk/tools/tkcond.c	(revision 4999)
+++ 	(revision )
@@ -1,546 +1,0 @@
-/* parser config.in
- * $Id$
- *
- * This software is governed by the CeCILL license
- * See IOIPSL/IOIPSL_License_CeCILL.txt
- *
- * Version 1.0
- * Eric Youngdale
- * 10/95
- *
- * The general idea here is that we want to parse a config.in file and 
- * from this, we generate a wish script which gives us effectively the
- * same functionality that the original config.in script provided.
- *
- * This task is split roughly into 3 parts.  The first parse is the parse
- * of the input file itself.  The second part is where we analyze the 
- * #ifdef clauses, and attach a linked list of tokens to each of the
- * menu items.  In this way, each menu item has a complete list of
- * dependencies that are used to enable/disable the options.
- * The third part is to take the configuration database we have build,
- * and build the actual wish script.
- *
- * This file contains the code to further process the conditions from
- * the "ifdef" clauses.
- *
- * The conditions are assumed to be one of the following formats
- *
- * simple_condition:= "$VARIABLE" == y/n/m
- * simple_condition:= "$VARIABLE != y/n/m
- *
- * simple_condition -a simple_condition
- *
- * If the input condition contains '(' or ')' it would screw us up, but for now
- * this is not a problem.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "tkparse.h"
-
-
-/*
- * Walk a condition chain and invert it so that the logical result is
- * inverted.
- */
-static void invert_condition(struct condition * cnd)
-{
-  /*
-   * This is simple.  Just walk through the list, and invert
-   * all of the operators.
-   */
-  for(;cnd; cnd = cnd->next)
-    {
-      switch(cnd->op)
-	{
-	case op_and:
-	  cnd->op = op_or;
-	  break;
-	case op_or:
-	  /*
-	   * This is not turned into op_and - we need to keep track
-	   * of what operators were used here since we have an optimization
-	   * later on to remove duplicate conditions, and having
-	   * inverted ors in there would make it harder if we did not
-	   * distinguish an inverted or from an and we inserted because
-	   * of nested ifs.
-	   */
-	  cnd->op = op_and1;
-	  break;
-	case op_neq:
-	  cnd->op = op_eq;
-	  break;
-	case op_eq:
-	  cnd->op = op_neq;
-	  break;
-	default:
-	  break;
-	}
-    }
-}
-
-/*
- * Walk a condition chain, and free the memory associated with it.
- */
-static void free_condition(struct condition * cnd)
-{
-  struct condition * next;
-  for(;cnd; cnd = next)
-    {
-      next = cnd->next;
-
-      if( cnd->variable.str != NULL )
-	free(cnd->variable.str);
-
-      free(cnd);
-    }
-}
-
-/*
- * Walk all of the conditions, and look for choice values.  Convert
- * the tokens into something more digestible.
- */
-void fix_choice_cond()
-{
-  struct condition * cond;
-  struct condition * cond2;
-  struct kconfig * cfg;
-  char tmpbuf[10];
-
-  for(cfg = config;cfg != NULL; cfg = cfg->next)
-    {
-      if( cfg->cond == NULL )
-	{
-	  continue;
-	}
-
-      for(cond = cfg->cond; cond != NULL; cond = cond->next)
-	{
-	  if( cond->op != op_kvariable )
-	    continue;
-
-	  if( cond->variable.cfg->tok != tok_choice )
-	    continue;
-
-	  /*
-	   * Look ahead for what we are comparing this to.  There should
-	   * be one operator in between.
-	   */
-	  cond2 = cond->next->next;
-	  strcpy(tmpbuf, cond->variable.cfg->label);
-
-	  if( strcmp(cond2->variable.str, "y") == 0 )
-	    {
-	      cond->variable.cfg = cond->variable.cfg->choice_label;
-	      cond2->variable.str = strdup(tmpbuf);
-	    }
-	  else
-	    {
-	      fprintf(stderr,"Ooops\n");
-	      exit(0);
-	    }
-	}
-
-    }
-}
-
-/*
- * Walk the stack of conditions, and clone all of them with "&&" operators
- * gluing them together.  The conditions from each level of the stack
- * are wrapped in parenthesis so as to guarantee that the results
- * are logically correct.
- */
-struct condition * get_token_cond(struct condition ** cond, int depth)
-{
-  int i;
-  struct condition * newcond;
-  struct condition * tail;
-  struct condition * new;
-  struct condition * ocond;
-  struct kconfig * cfg;
-
-  newcond = tail = NULL;
-  for(i=0; i<depth; i++, cond++)
-    {
-      /*
-       * First insert the left parenthesis
-       */
-      new = (struct condition *) malloc(sizeof(struct condition));
-      memset(new, 0, sizeof(*new));
-      new->op = op_lparen;
-      if( tail == NULL )
-	{
-	  newcond = tail = new;
-	}
-      else
-	{
-	  tail->next = new;
-	  tail = new;
-	}
-
-      /*
-       * Now duplicate the chain.
-       */
-      ocond = *cond;
-      for(;ocond != NULL; ocond = ocond->next)
-	{
-	  new = (struct condition *) malloc(sizeof(struct condition));
-	  memset(new, 0, sizeof(*new));
-	  new->op = ocond->op;
-	  if( ocond->variable.str != NULL )
-	    {
-	      if( ocond->op == op_variable )
-		{
-		  /*
-		   * Search for structure to insert here.
-		   */
-		  for(cfg = config;cfg != NULL; cfg = cfg->next)
-		    {
-		      if( cfg->tok != tok_bool
-		         && cfg->tok != tok_int
-		         && cfg->tok != tok_hex
-			 && cfg->tok != tok_tristate 
-			 && cfg->tok != tok_choice
-			 && cfg->tok != tok_dep_tristate)
-			{
-			  continue;
-			}
-		      if( strcmp(cfg->optionname, ocond->variable.str) == 0)
-			{
-			  new->variable.cfg = cfg;
-			  new->op = op_kvariable;
-			  break;
-			}
-		    }
-		  if( cfg == NULL )
-		    {
-		      new->variable.str = strdup(ocond->variable.str);
-		    }
-		}
-	      else
-		{
-		  new->variable.str = strdup(ocond->variable.str);
-		}
-	    }
-	  tail->next = new;
-	  tail = new;
-	}
-
-      /*
-       * Next insert the left parenthesis
-       */
-      new = (struct condition *) malloc(sizeof(struct condition));
-      memset(new, 0, sizeof(*new));
-      new->op = op_rparen;
-      tail->next = new;
-      tail = new;
-
-      /*
-       * Insert an and operator, if we have another condition.
-       */
-      if( i < depth - 1 )
-	{
-	  new = (struct condition *) malloc(sizeof(struct condition));
-	  memset(new, 0, sizeof(*new));
-	  new->op = op_and;
-	  tail->next = new;
-	  tail = new;
-	}
-
-    }
-
-  return newcond;
-}
-
-/*
- * Walk a single chain of conditions and clone it.  These are assumed
- * to be created/processed by  get_token_cond in a previous pass.
- */
-struct condition * get_token_cond_frag(struct condition * cond, 
-				       struct condition ** last)
-{
-  struct condition * newcond;
-  struct condition * tail;
-  struct condition * new;
-  struct condition * ocond;
-
-  newcond = tail = NULL;
-
-  /*
-   * Now duplicate the chain.
-   */
-  for(ocond = cond;ocond != NULL; ocond = ocond->next)
-    {
-      new = (struct condition *) malloc(sizeof(struct condition));
-      memset(new, 0, sizeof(*new));
-      new->op = ocond->op;
-      new->variable.cfg = ocond->variable.cfg;
-      if( tail == NULL )
-	{
-	  newcond = tail = new;
-	}
-      else
-	{
-	  tail->next = new;
-	  tail = new;
-	}
-    }
-
-  new = (struct condition *) malloc(sizeof(struct condition));
-  memset(new, 0, sizeof(*new));
-  new->op = op_and;
-  tail->next = new;
-  tail = new;
-  
-  *last = tail;
-  return newcond;
-}
-
-/*
- * Walk through the if conditionals and maintain a chain.
- */
-void fix_conditionals(struct kconfig * scfg)
-{
-  int depth = 0;
-  int i;
-  struct kconfig * cfg;
-  struct kconfig * cfg1;
-  struct condition * conditions[25];
-  struct condition * cnd;
-  struct condition * cnd1;
-  struct condition * cnd2;
-  struct condition * cnd3;
-  struct condition * newcond;
-  struct condition * last;
-
-  /*
-   * Start by walking the chain.  Every time we see an ifdef, push
-   * the condition chain on the stack.  When we see an "else", we invert
-   * the condition at the top of the stack, and when we see an "endif"
-   * we free all of the memory for the condition at the top of the stack
-   * and remove the condition from the top of the stack.
-   *
-   * For any other type of token (i.e. a bool), we clone a new condition chain
-   * by anding together all of the conditions that are currently stored on
-   * the stack.  In this way, we have a correct representation of whatever
-   * conditions govern the usage of each option.
-   */
-  memset(conditions, 0, sizeof(conditions));
-  for(cfg=scfg;cfg != NULL; cfg = cfg->next)
-    {
-      switch(cfg->tok)
-	{
-	case tok_if:
-	  /*
-	   * Push this condition on the stack, and nuke the token
-	   * representing the ifdef, since we no longer need it.
-	   */
-	  conditions[depth] = cfg->cond;
-	  depth++;
-	  cfg->tok = tok_nop;
-	  cfg->cond =  NULL;
-	  break;
-	case tok_else:
-	  /*
-	   * For an else, we just invert the condition at the top of
-	   * the stack.  This is done in place with no reallocation
-	   * of memory taking place.
-	   */
-	  invert_condition(conditions[depth-1]);
-	  cfg->tok = tok_nop;
-	  break;
-	case tok_fi:
-	  depth--;
-	  free_condition(conditions[depth]);
-	  conditions[depth] = NULL;
-	  cfg->tok = tok_nop;
-	  break;
-	case tok_comment:
-	case tok_define:
-	case tok_menuoption:
-	case tok_bool:
-	case tok_tristate:
-	case tok_int:
-	case tok_hex:
-	case tok_choice:
-	case tok_make:
-	  /*
-	   * We need to duplicate the chain of conditions and attach them to
-	   * this token.
-	   */
-	  cfg->cond = get_token_cond(&conditions[0], depth);
-	  break;
-	case tok_dep_tristate:
-	  /*
-	   * Same as tok_tristate et al except we have a temporary
-	   * conditional. (Sort of a hybrid tok_if, tok_tristate, tok_fi
-	   * option)
-	   */
-	  conditions[depth] = cfg->cond;
-	  depth++;
-	  cfg->cond = get_token_cond(&conditions[0], depth);
-	  depth--;
-	  free_condition(conditions[depth]);
-	  conditions[depth] = NULL;
-	default:
-	  break;
-	}
-    }
-
-  /*
-   * Fix any conditions involving the "choice" operator.
-   */
-  fix_choice_cond();
-
-  /*
-   * Walk through and see if there are multiple options that control the
-   * same kvariable.  If there are we need to treat them a little bit
-   * special.
-   */
-  for(cfg=scfg;cfg != NULL; cfg = cfg->next)
-    {
-      switch(cfg->tok)
-	{
-	case tok_bool:
-	case tok_tristate:
-	case tok_dep_tristate:
-	case tok_int:
-	case tok_hex:
-	  for(cfg1=cfg;cfg1 != NULL; cfg1 = cfg1->next)
-	    {
-	      switch(cfg1->tok)
-		{
-		case tok_define:
-		case tok_bool:
-		case tok_tristate:
-		case tok_dep_tristate:
-		case tok_int:
-		case tok_hex:
-		  if( strcmp(cfg->optionname, cfg1->optionname) == 0)
-		    {
-		      cfg->flags |= CFG_DUP;
-		      cfg1->flags |= CFG_DUP;
-		    }
-		  break;
-		default:
-		  break;
-		}
-	    }
-	  break;
-	default:
-	  break;
-	}
-    }
-
-  /*
-   * Now go through the list, and every time we see a kvariable, check
-   * to see whether it also has some dependencies.  If so, then
-   * append it to our list.  The reason we do this is that we might have
-   * option CONFIG_FOO which is only used if CONFIG_BAR is set.  It may
-   * turn out that in config.in that the default value for CONFIG_BAR is
-   * set to "y", but that CONFIG_BAR is not enabled because CONFIG_XYZZY
-   * is not set.  The current condition chain does not reflect this, but
-   * we can fix this by searching for the tokens that this option depends
-   * upon and cloning the conditions and merging them with the list.
-   */
-  for(cfg=scfg;cfg != NULL; cfg = cfg->next)
-    {
-      /*
-       * Search for a token that has a condition list.
-       */
-      if(cfg->cond == NULL) continue;
-      for(cnd = cfg->cond; cnd; cnd=cnd->next)
-	{
-	  /*
-	   * Now search the condition list for a known configuration variable
-	   * that has conditions of its own.
-	   */
-	  if(cnd->op != op_kvariable) continue;
-	  if(cnd->variable.cfg->cond == NULL) continue;
-
-	  if(cnd->variable.cfg->flags & CFG_DUP) continue; 
-	  /*
-	   * OK, we have some conditions to append to cfg.  Make  a clone
-	   * of the conditions,
-	   */
-	  newcond = get_token_cond_frag(cnd->variable.cfg->cond, &last);
-
-	  /*
-	   * Finally, we splice it into our list.
-	   */
-	  last->next = cfg->cond;
-	  cfg->cond = newcond;
-
-	}
-    }
-
-  /*
-   * There is a strong possibility that we have duplicate conditions
-   * in here.  It would make the script more efficient and readable to
-   * remove these.  Here is where we assume here that there are no
-   * parenthesis in the input script.
-   */
-  for(cfg=scfg;cfg != NULL; cfg = cfg->next)
-    {
-      /*
-       * Search for configuration options that have conditions.
-       */
-      if(cfg->cond == NULL) continue;
-      for(cnd = cfg->cond; cnd; cnd=cnd->next)
-	{
-	  /*
-	   * Search for a left parenthesis.
-	   */
-	  if(cnd->op != op_lparen) continue;
-	  for(cnd1 = cnd->next; cnd1; cnd1=cnd1->next)
-	    {
-	      /*
-	       * Search after the previous left parenthesis, and try
-	       * and find a second left parenthesis.
-	       */
-	      if(cnd1->op != op_lparen) continue;
-
-	      /*
-	       * Now compare the next 5 tokens to see if they are
-	       * identical.  We are looking for two chains that
-	       * are like: '(' $VARIABLE operator constant ')'.
-	       */
-	      cnd2 = cnd;
-	      cnd3 = cnd1;
-	      for(i=0; i<5; i++, cnd2=cnd2->next, cnd3=cnd3->next)
-		{
-		  if(!cnd2 || !cnd3) break;
-		  if(cnd2->op != cnd3->op) break;
-		  if(i == 1 && (cnd2->op != op_kvariable 
-		     || cnd2->variable.cfg != cnd3->variable.cfg) ) break;
-		  if(i==2 && cnd2->op != op_eq && cnd2->op != op_neq) break;
-		  if(i == 3 && cnd2->op != op_constant &&
-		     strcmp(cnd2->variable.str, cnd3->variable.str) != 0)
-		    break;
-		  if(i==4 && cnd2->op != op_rparen) break;
-		}
-	      /*
-	       * If these match, and there is an and gluing these together,
-	       * then we can nuke the second one.
-	       */
-	      if(i==5 && ((cnd3 && cnd3->op == op_and)
-			  ||(cnd2 && cnd2->op == op_and)))
-		{
-		  /*
-		   * We have a duplicate.  Nuke 5 ops.
-		   */
-		  cnd3 = cnd1;
-		  for(i=0; i<5; i++, cnd3=cnd3->next)
-		    {
-		      cnd3->op = op_nuked;
-		    }
-		  /*
-		   * Nuke the and that glues the conditions together.
-		   */
-		  if(cnd3 && cnd3->op == op_and) cnd3->op = op_nuked;
-		  else if(cnd2 && cnd2->op == op_and) cnd2->op = op_nuked;
-		}
-	    }
-	}
-    }
-}
Index: IOIPSL/trunk/tools/tkgen.c
===================================================================
--- IOIPSL/trunk/tools/tkgen.c	(revision 4999)
+++ 	(revision )
@@ -1,1136 +1,0 @@
-/* Generate tk script based upon config.in
- * $Id$
- *
- * This software is governed by the CeCILL license
- * See IOIPSL/IOIPSL_License_CeCILL.txt
- *
- * Version 1.0
- * Eric Youngdale
- * 10/95
- *
- * 1996 01 04
- * Avery Pennarun - Aesthetic improvements.
- *
- * 1996 01 24
- * Avery Pennarun - Bugfixes and more aesthetics.
- *
- * 1996 03 08
- * Avery Pennarun - The int and hex config.in commands work right.
- *                - Choice buttons are more user-friendly.
- *                - Disabling a text entry line greys it out properly.
- *                - dep_tristate now works like in Configure. (not pretty)
- *                - No warnings in gcc -Wall. (Fixed some "interesting" bugs.)
- *                - Faster/prettier "Help" lookups.
- *
- * 1996 03 15
- * Avery Pennarun - Added new sed script from Axel Boldt to make help even
- *                  faster. (Actually awk is downright slow on some machines.)
- *                - Fixed a bug I introduced into Choice dependencies.  Thanks
- *                  to Robert Krawitz for pointing this out.
- *
- * 1996 03 16
- * Avery Pennarun - basic "do_make" support added to let sound config work.
- *
- * 1996 03 25
- *     Axel Boldt - Help now works on "choice" buttons.
- *
- * 1996 04 06
- * Avery Pennarun - Improved sound config stuff. (I think it actually works
- *                  now!)
- *                - Window-resize-limits don't use ugly /usr/lib/tk4.0 hack.
- *                - int/hex work with tk3 again. (The "cget" error.)
- *                - Next/Prev buttons switch between menus.  I can't take
- *                  much credit for this; the code was already there, but
- *                  ifdef'd out for some reason.  It flickers a lot, but
- *                  I suspect there's no "easy" fix for that.
- *                - Labels no longer highlight as you move the mouse over
- *                  them (although you can still press them... oh well.)
- *                - Got rid of the last of the literal color settings, to
- *                  help out people with mono X-Windows systems. 
- *                  (Apparently there still are some out there!)
- *                - Tabstops seem sensible now.
- *
- * 1996 04 14
- * Avery Pennarun - Reduced flicker when creating windows, even with "update
- *                  idletasks" hack.
- *
- * TO DO:
- *   - clean up - there are useless ifdef's everywhere.
- *   - better comments throughout - C code generating tcl is really cryptic.
- *   - eliminate silly "update idletasks" hack to improve display speed and
- *     reduce flicker.  But how?
- *   - make canvas contents resize with the window (good luck).
- *   - some way to make submenus inside of submenus (ie. Main->Networking->IP)
- *           (perhaps a button where the description would be)
- *   - make the main menu use the same tcl code as the submenus.
- *   - make choice and int/hex input types line up vertically with
- *           bool/tristate.
- *   - general speedups - how?  The canvas seems to slow it down a lot.
- *   - choice buttons should default to the first menu option, rather than a
- *           blank.  Also look up the right variable when the help button
- *           is pressed.
- *   - clean up +/- 16 confusion for enabling/disabling variables; causes
- *           (theoretical, at the moment) problems with dependencies.
- *   
- */
-#include <stdio.h>
-#include <unistd.h>
-#include "tkparse.h"
-
-#ifndef TRUE
-#define TRUE (1)
-#endif
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-/*
- * This is the total number of submenus that we have.
- */
-static int tot_menu_num =0;
-
-/*
- * Generate portion of wish script for the beginning of a submenu.
- * The guts get filled in with the various options.
- */
-static void start_proc(char * label, int menu_num, int flag)
-{
-  if( flag )
-    printf("menu_option menu%d %d \"%s\"\n", menu_num, menu_num, label);
-  printf("proc menu%d {w title} {\n", menu_num);
-  printf("\tcatch {destroy $w}\n");
-  printf("\ttoplevel $w -class Dialog\n");
-  printf("\twm withdraw $w\n");
-  printf("\tmessage $w.m -width 400 -aspect 300 -text \\\n");
-  printf("\t\t\"%s\"  -relief raised\n",label);
-  printf("\tpack $w.m -pady 10 -side top -padx 10\n");
-  printf("\twm title $w \"%s\" \n\n", label);
-  
-  /*
-   * Attach the "Prev", "Next" and "OK" buttons at the end of the window.
-   */
-  printf("\tset oldFocus [focus]\n");
-  printf("\tframe $w.f\n");
-  printf("\tbutton $w.f.back -text \"Main Menu\" \\\n"
-         "\t\t-width 15 -command \"destroy $w; focus $oldFocus; update_mainmenu $w\"\n");
-  printf("\tbutton $w.f.next -text \"Next\" \\\n"
-         "\t\t-width 15 -command \" destroy $w; focus $oldFocus;  menu%d .menu%d \\\"$title\\\"\"\n",
-         	menu_num+1, menu_num+1);
-  if (menu_num == tot_menu_num)
-  	printf("\t$w.f.next configure -state disabled\n");
-  printf("\tbutton $w.f.prev -text \"Prev\" \\\n"
-         "\t\t-width 15 -command \" destroy $w; focus $oldFocus; menu%d .menu%d \\\"$title\\\"\"\n",
-       		menu_num-1, menu_num-1);
-  if (1 == menu_num)
-  	printf("\t$w.f.prev configure -state disabled\n");
-  printf("\tpack $w.f.back $w.f.next $w.f.prev -side left -expand on\n");
-  printf("\tpack $w.f -pady 10 -side bottom -anchor w -fill x\n");
-
-  /*
-   * Lines between canvas and other areas of the window.
-   */
-  printf("\tframe $w.topline -relief ridge -borderwidth 2 -height 2\n");
-  printf("\tpack $w.topline -side top -fill x\n\n");
-  printf("\tframe $w.botline -relief ridge -borderwidth 2 -height 2\n");
-  printf("\tpack $w.botline -side bottom -fill x\n\n");
-  
-  /*
-   * The "config" frame contains the canvas and a scrollbar.
-   */
-  printf("\tframe $w.config\n");
-  printf("\tpack $w.config -fill y -expand on\n\n");
-  printf("\tscrollbar $w.config.vscroll -command \"$w.config.canvas yview\"\n");
-  printf("\tpack $w.config.vscroll -side right -fill y\n\n");
-  
-  /*
-   * The scrollable canvas itself, where the real work (and mess) gets done.
-   */
-  printf("\tcanvas $w.config.canvas -height 1\\\n"
-  	 "\t\t-relief flat -borderwidth 0 -yscrollcommand \"$w.config.vscroll set\" \\\n"
-  	 "\t\t-width [expr [winfo screenwidth .] * 1 / 2] \n");
-  printf("\tframe $w.config.f\n");
-  printf("\tpack $w.config.canvas -side right -fill y\n");
-  
-  printf("\n\n");
-}
-
-/*
- * Each proc we create needs a global declaration for any global variables we
- * use.  To minimize the size of the file, we set a flag each time we output
- * a global declaration so we know whether we need to insert one for a
- * given function or not.
- */
-void clear_globalflags(struct kconfig * cfg)
-{
-  for(; cfg != NULL; cfg = cfg->next)
-  {
-    cfg->flags &= ~GLOBAL_WRITTEN;
-  }
-}
-
-/*
- * Output a "global" line for a given variable.  Also include the
- * call to "vfix".  (If vfix is not needed, then it's fine to just printf
- * a "global" line).
- */
-void global(char *var)
-{
-  printf("\tglobal %s; vfix %s\n", var, var);
-}
-
-/*
- * This function walks the chain of conditions that we got from cond.c,
- * and creates a wish conditional to enable/disable a given widget.
- */
-void generate_if(struct kconfig * item,
-	    struct condition * cond,
-	    int menu_num,
-	    int line_num)
-{
-  struct condition * ocond;
-
-  ocond = cond;
-
-  /*
-   * First write any global declarations we need for this conditional.
-   */
-  while(cond != NULL )
-    {
-      switch(cond->op){
-      case op_variable:
-      	global(cond->variable.str);
-	break;
-      case op_kvariable:
-	if(cond->variable.cfg->flags & GLOBAL_WRITTEN) break;
-	cond->variable.cfg->flags |= GLOBAL_WRITTEN;
-	global(cond->variable.cfg->optionname);
-	break;
-      default:
-	break;
-      }
-      cond = cond->next;
-    }
-  
-  /*
-   * Now write this option.
-   */
-  if(   (item->flags & GLOBAL_WRITTEN) == 0
-     && (item->optionname != NULL) )
-    {
-      global(item->optionname);
-      item->flags |= GLOBAL_WRITTEN;
-    }
-  /*
-   * Now generate the body of the conditional.
-   */
-  printf("\tif {");
-  cond = ocond;
-  while(cond != NULL )
-    {
-      switch(cond->op){
-      case op_bang:
-	printf(" ! ");
-	break;
-      case op_eq:
-	printf(" == ");
-	break;
-      case op_neq:
-	printf(" != ");
-	break;
-      case op_and:
-      case op_and1:
-	printf(" && ");
-	break;
-      case op_or:
-	printf(" || ");
-	break;
-      case op_lparen:
-	printf("(");
-	break;
-      case op_rparen:
-	printf(")");
-	break;
-      case op_variable:
-	printf("$%s", cond->variable.str);
-	break;
-      case op_kvariable:
-	printf("$%s", cond->variable.cfg->optionname);
-	break;
-      case op_shellcmd:
-	printf("[exec %s]", cond->variable.str);
-	break;
-      case op_constant:
-	if( strcmp(cond->variable.str, "y") == 0 )
-	  printf("1");
-	else if( strcmp(cond->variable.str, "n") == 0 )
-	  printf("0");
-	else if( strcmp(cond->variable.str, "m") == 0 )
-	  printf("2");
-	else
-	  printf("\"%s\"", cond->variable.str);
-	break;
-      default:
-        break;
-      }
-      cond = cond->next;
-    }
-
-  /*
-   * Now we generate what we do depending upon the value of the conditional.
-   * Depending upon what the token type is, there are different things
-   * we must do to enable/disable the given widget - this code needs to
-   * be closely coordinated with the widget creation procedures in header.tk.
-   */
-  switch(item->tok)
-    {
-    case tok_define:
-      printf("} then { set %s %s } \n",  item->optionname, item->value);
-      break;
-    case tok_menuoption:
-      printf("} then { .f0.x%d configure -state normal } else { .f0.x%d configure -state disabled }\n",
-	     menu_num, menu_num);
-      break;
-    case tok_int:
-    case tok_hex:
-      printf("} then { ");
-      printf(".menu%d.config.f.x%d.x configure -state normal -fore [ cget .ref -foreground ]; ", menu_num, line_num);
-      printf(".menu%d.config.f.x%d.l configure -state normal; ", menu_num, line_num);
-      printf("} else { ");
-      printf(".menu%d.config.f.x%d.x configure -state disabled -fore [ cget .ref -disabledforeground ];", menu_num, line_num );
-      printf(".menu%d.config.f.x%d.l configure -state disabled;", menu_num, line_num );
-      printf("}\n");
-      break;
-    case tok_bool:
-#ifdef BOOL_IS_BUTTON
-      /*
-       * If a bool is just a button, then use this definition.
-       */
-      printf("} then { .menu%d.config.f.x%d configure -state normal } else { .menu%d.config.f.x%d configure -state disabled }\n",
-	     menu_num, line_num,
-	     menu_num, line_num );
-#else
-      /*
-       * If a bool is a radiobutton, then use this instead.
-       */
-      printf("} then { ");
-      printf(".menu%d.config.f.x%d.y configure -state normal;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.n configure -state normal;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.l configure -state normal;",menu_num, line_num);
-      printf("set %s [expr $%s&15];", item->optionname, item->optionname);
-      printf("} else { ");
-      printf(".menu%d.config.f.x%d.y configure -state disabled;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.n configure -state disabled;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.l configure -state disabled;",menu_num, line_num);
-      printf("set %s [expr $%s|16];", item->optionname, item->optionname);
-      printf("}\n");
-#endif
-      break;
-    case tok_tristate:
-    case tok_dep_tristate:
-      printf("} then { ");
-      if( item->tok == tok_dep_tristate )
-	{
-	  global(item->depend.str);
-	  printf("if { $%s != 1 && $%s != 0 } then {", 
-	  	item->depend.str,item->depend.str);
-	  printf(".menu%d.config.f.x%d.y configure -state disabled;",menu_num, line_num);
-	  printf("} else {");
-	  printf(".menu%d.config.f.x%d.y configure -state normal;",menu_num, line_num);
-	  printf("}; ");
-	}
-      else
-	{
-	  printf(".menu%d.config.f.x%d.y configure -state normal;",menu_num, line_num);
-	}
-      
-      printf(".menu%d.config.f.x%d.n configure -state normal;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.m configure -state normal;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.l configure -state normal;",menu_num, line_num);
-      /*
-       * Or in a bit to the variable - this causes all of the radiobuttons
-       * to be deselected (i.e. not be red).
-       */
-      printf("set %s [expr $%s&15];", item->optionname, item->optionname);
-      printf("} else { ");
-      printf(".menu%d.config.f.x%d.y configure -state disabled;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.n configure -state disabled;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.m configure -state disabled;",menu_num, line_num);
-      printf(".menu%d.config.f.x%d.l configure -state disabled;",menu_num, line_num);
-      /*
-       * Clear the disable bit - this causes the correct radiobutton
-       * to appear selected (i.e. turn red).
-       */
-      printf("set %s [expr $%s|16];", item->optionname, item->optionname);
-      printf("}\n");
-      break;
-    case tok_choose:
-    case tok_choice:
-      fprintf(stderr,"Fixme\n");
-      exit(0);
-    default:
-      break;
-    }
-}
-
-/*
- * Similar to generate_if, except we come here when generating an
- * output file.  Thus instead of enabling/disabling a widget, we
- * need to decide whether to write out a given configuration variable
- * to the output file.
- */
-void generate_if_for_outfile(struct kconfig * item,
-	    struct condition * cond)
-{
-  struct condition * ocond;
-
-  /*
-   * First write any global declarations we need for this conditional.
-   */
-  ocond = cond;
-  for(; cond != NULL; cond = cond->next )
-    {
-      switch(cond->op){
-      case op_variable:
-        global(cond->variable.str);
-	break;
-      case op_kvariable:
-	if(cond->variable.cfg->flags & GLOBAL_WRITTEN) break;
-	cond->variable.cfg->flags |= GLOBAL_WRITTEN;
-	global(cond->variable.cfg->optionname);
-	break;
-      default:
-	break;
-      }
-    }
-
-  /*
-   * Now generate the body of the conditional.
-   */
-  printf("\tif {");
-  cond = ocond;
-  while(cond != NULL )
-    {
-      switch(cond->op){
-      case op_bang:
-	printf(" ! ");
-	break;
-      case op_eq:
-	printf(" == ");
-	break;
-      case op_neq:
-	printf(" != ");
-	break;
-      case op_and:
-      case op_and1:
-	printf(" && ");
-	break;
-      case op_or:
-	printf(" || ");
-	break;
-      case op_lparen:
-	printf("(");
-	break;
-      case op_rparen:
-	printf(")");
-	break;
-      case op_variable:
-	printf("$%s", cond->variable.str);
-	break;
-      case op_shellcmd:
-	printf("[exec %s]", cond->variable.str);
-	break;
-      case op_kvariable:
-	printf("$%s", cond->variable.cfg->optionname);
-	break;
-      case op_constant:
-	if( strcmp(cond->variable.str, "y") == 0 )
-	  printf("1");
-	else if( strcmp(cond->variable.str, "n") == 0 )
-	  printf("0");
-	else if( strcmp(cond->variable.str, "m") == 0 )
-	  printf("2");
-	else
-	  printf("\"%s\"", cond->variable.str);
-	break;
-      default:
-        break;
-      }
-      cond = cond->next;
-    }
-
-  /*
-   * Now we generate what we do depending upon the value of the
-   * conditional.  Depending upon what the token type is, there are
-   * different things we must do write the value the given widget -
-   * this code needs to be closely coordinated with the widget
-   * creation procedures in header.tk.  
-   */
-  switch(item->tok)
-    {
-    case tok_define:
-      printf("} then {write_tristate $cfg $autocfg %s %s $notmod }\n", item->optionname, item->value);
-      break;
-    case tok_comment:
-      printf("} then {write_comment $cfg $autocfg \"%s\"}\n", item->label);
-      break;
-    case tok_dep_tristate:
-      printf("} then { write_tristate $cfg $autocfg %s $%s $%s } \n", 
-	     item->optionname, item->optionname, item->depend.str);
-      break;
-    case tok_tristate:
-    case tok_bool:
-      printf("} then { write_tristate $cfg $autocfg %s $%s $notmod }\n", 
-	     item->optionname, item->optionname);
-      break;
-    case tok_int:
-      printf("} then { write_int $cfg $autocfg %s $%s $notmod }\n",
-             item->optionname, item->optionname);
-      break;
-    case tok_hex:
-      printf("} then { write_hex $cfg $autocfg %s $%s $notmod }\n",
-             item->optionname, item->optionname);
-      break;
-    case tok_make:
-      printf("} then { do_make {%s} }\n",item->value);
-      break;
-    case tok_choose:
-    case tok_choice:
-      fprintf(stderr,"Fixme\n");
-      exit(0);
-    default:
-      break;
-    }
-}
-
-/*
- * Generates a fragment of wish script that closes out a submenu procedure.
- */
-static void end_proc(int menu_num)
-{
-  struct kconfig * cfg;
-
-  printf("\n\n\n");
-  printf("\tfocus $w\n");
-  printf("\tupdate_menu%d $w.config.f\n", menu_num);
-  printf("\tglobal winx; global winy\n");
-  printf("\tset winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]\n");
-  printf("\twm geometry $w +$winx+$winy\n");
-  
-  /*
-   * Now that the whole window is in place, we need to wait for an "update"
-   * so we can tell the canvas what its virtual size should be.
-   *
-   * Unfortunately, this causes some ugly screen-flashing because the whole
-   * window is drawn, and then it is immediately resized.  It seems
-   * unavoidable, though, since "frame" objects won't tell us their size
-   * until after an update, and "canvas" objects can't automatically pack
-   * around frames.  Sigh.
-   */
-  printf("\tupdate idletasks\n");
-  printf("\t$w.config.canvas create window 0 0 -anchor nw -window $w.config.f\n\n");
-  printf("\t$w.config.canvas configure \\\n"
-  	 "\t\t-width [expr [winfo reqwidth $w.config.f] + 1]\\\n"
-  	 "\t\t-scrollregion \"-1 -1 [expr [winfo reqwidth $w.config.f] + 1] \\\n"
-  	 "\t\t\t [expr [winfo reqheight $w.config.f] + 1]\"\n\n");
-  	 
-  /*
-   * If the whole canvas will fit in 3/4 of the screen height, do it;
-   * otherwise, resize to around 1/2 the screen and let us scroll.
-   */
-  printf("\tset winy [expr [winfo reqh $w] - [winfo reqh $w.config.canvas]]\n");
-  printf("\tset scry [expr [winfo screenh $w] / 2]\n");
-  printf("\tset maxy [expr [winfo screenh $w] * 3 / 4]\n");
-  printf("\tset canvtotal [expr [winfo reqh $w.config.f] + 2]\n");
-  printf("\tif [expr $winy + $canvtotal < $maxy] {\n"
-  	 "\t\t$w.config.canvas configure -height $canvtotal\n"
-  	 "\t} else {\n"
-  	 "\t\t$w.config.canvas configure -height [expr $scry - $winy]\n"
-  	 "\t}\n");
-  
-  /*
-   * Limit the min/max window size.  Height can vary, but not width,
-   * because of the limitations of canvas and our laziness.
-   */
-  printf("\tupdate idletasks\n");
-  printf("\twm maxsize $w [winfo width $w] [winfo screenheight $w]\n");
-  printf("\twm minsize $w [winfo width $w] 100\n\n");
-  printf("\twm deiconify $w\n");
-    
-  printf("}\n\n\n");
-
-  /*
-   * Now we generate the companion procedure for the menu we just
-   * generated.  This procedure contains all of the code to
-   * disable/enable widgets based upon the settings of the other
-   * widgets, and will be called first when the window is mapped,
-   * and each time one of the buttons in the window are clicked.
-   */
-  printf("proc update_menu%d {w}  {\n", menu_num);
-
-  printf("\tupdate_define\n");
-  clear_globalflags(config);
-  for(cfg = config;cfg != NULL; cfg = cfg->next)
-    {
-      /*
-       * Skip items not for this menu, or ones having no conditions.
-       */
-      if (cfg->menu_number != menu_num ) continue;
-      if (cfg->tok != tok_define) continue;
-      /*
-       * Clear all of the booleans that are defined in this menu.
-       */
-      if(   (cfg->flags & GLOBAL_WRITTEN) == 0
-	 && (cfg->optionname != NULL) )
-	{
-	  printf("\tglobal %s\n", cfg->optionname);
-	  cfg->flags |= GLOBAL_WRITTEN;
-	  printf("\tset %s 0\n", cfg->optionname);
-	}
-
-    }
-  for(cfg = config;cfg != NULL; cfg = cfg->next)
-    {
-      /*
-       * Skip items not for this menu, or ones having no conditions.
-       */
-      if (cfg->menu_number != menu_num ) continue;
-      if (cfg->tok == tok_menuoption) continue;
-      if (cfg->cond != NULL ) 
-	generate_if(cfg, cfg->cond, menu_num, cfg->menu_line);
-      else
-	{
-	  /*
-	   * If this token has no conditionals, check to see whether
-	   * it is a tristate - if so, then generate the conditional
-	   * to enable/disable the "y" button based upon the setting
-	   * of the option it depends upon.
-	   */
-	  if(cfg->tok == tok_dep_tristate)
-	    {
-	      global(cfg->depend.str);
-	      printf("\tif {$%s != 1 && $%s != 0 } then { .menu%d.config.f.x%d.y configure -state disabled } else { .menu%d.config.f.x%d.y configure -state normal}\n",
-		     cfg->depend.str,cfg->depend.str,
-		     menu_num, cfg->menu_line,
-		     menu_num, cfg->menu_line);
-	    }
-	}
-
-    }
-
-
-  printf("}\n\n\n");
-}
-
-/*
- * This function goes through and counts up the number of items in
- * each submenu. If there are too many options, we need to split it
- * into submenus.  This function just calculates how many submenus,
- * and how many items go in each submenu.
- */
-static void find_menu_size(struct kconfig *cfg,
-			  int *menu_max, 
-			  int *menu_maxlines)
-
-{
-  struct kconfig * pnt;
-  int tot;
-  
-  /*
-   * First count up the number of options in this menu.
-   */
-  tot = 0;
-  for(pnt = cfg->next; pnt; pnt = pnt->next)
-  {
-    if( pnt->tok == tok_menuoption) break;
-    switch (pnt->tok)
-      {
-      case tok_bool:
-      case tok_tristate:
-      case tok_dep_tristate:
-      case tok_int:
-      case tok_hex:
-      case tok_choose:
-	tot++;
-	break;
-      case tok_choice:
-      default:
-	break;
-      }
-  }
-
-  *menu_max = cfg->menu_number;
-  *menu_maxlines = tot;
-}
-
-/*
- * This is the top level function for generating the tk script.
- */
-void dump_tk_script(struct kconfig *scfg)
-{
-  int menu_num =0;
-  int menu_max =0;
-  int menu_min =0;
-  int menu_line = 0;
-  int menu_maxlines = 0;
-  struct kconfig * cfg;
-  struct kconfig * cfg1 = NULL;
-  char * menulabel;
-
-  /*
-   * Start by assigning menu numbers, and submenu numbers.
-   */
-  for(cfg = scfg;cfg != NULL; cfg = cfg->next)
-    {
-      switch (cfg->tok)
-	{
-	case tok_menuname:
-	  break;
-	case tok_menuoption:
-	  /*
-	   * At the start of a new menu, calculate the number of items
-	   * we will put into each submenu so we know when to bump the
-	   * menu number. The submenus are really no different from a
-	   * normal menu, but the top level buttons only access the first
-	   * of the chain of menus, and the prev/next buttons are used
-	   * access the submenus.
-	   */
-	  cfg->menu_number = ++menu_num;
-	  find_menu_size(cfg, &menu_max, &menu_maxlines);
-	  cfg->submenu_start = menu_num;
-	  cfg->submenu_end = menu_max;
-	  menu_line = 0;
-	  break;
-	case tok_bool:
-	case tok_tristate:
-	case tok_dep_tristate:
-	case tok_int:
-	case tok_hex:
-	case tok_choose:
-	  /*
-	   * If we have overfilled the menu, then go to the next one.
-	   */
-	  if( menu_line == menu_maxlines )
-	    {
-	      menu_line = 0;
-	      menu_num++;
-	    }
-	  cfg->menu_number = menu_num;
-	  cfg->submenu_start = menu_min;
-	  cfg->submenu_end = menu_max;
-	  cfg->menu_line = menu_line++;
-	  break;
-	case tok_define:
-	  cfg->menu_number = -1;
-	case tok_choice:
-	default:
-	  break;
-	};
-    }
-
-  /*
-   * Record this so we can set up the prev/next buttons correctly.
-   */
-  tot_menu_num = menu_num;
-
-  /*
-   * Now start generating the actual wish script that we will use.
-   * We need to keep track of the menu numbers of the min/max menu
-   * for a range of submenus so that we can correctly limit the
-   * prev and next buttons so that they don't go over into some other
-   * category.
-   */
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      switch (cfg->tok)
-	{
-	case tok_menuname:
-	  printf("mainmenu_name \"%s\"\n", cfg->label);
-	  break;
-	case tok_menuoption:
-	  /*
-	   * We are at the start of a new menu. If we had one that
-	   * we were working on before, close it out, and then generate
-	   * the script to start the new one.
-	   */
-	  if( cfg->menu_number > 1 )
-	    {
-	      end_proc(menu_num);
-	    }
-	  menulabel = cfg->label;
-	  start_proc(cfg->label, cfg->menu_number, TRUE);
-	  menu_num = cfg->menu_number;
-	  menu_max = cfg->submenu_end;
-	  menu_min = cfg->submenu_start;
-	  break;
-	case tok_bool:
-	  /*
-	   * If we reached the point where we need to switch over
-	   * to the next submenu, then bump the menu number and generate
-	   * the code to close out the old menu and start the new one.
-	   */
-	  if( cfg->menu_number != menu_num )
-	    {
-	      end_proc(menu_num);
-	      start_proc(menulabel, cfg->menu_number, FALSE);
-	      menu_num = cfg->menu_number;
-	    }
-	  printf("\tbool $w.config.f %d %d \"%s\" %s\n",
-		 cfg->menu_number,
-		 cfg->menu_line,
-		 cfg->label,
-		 cfg->optionname);
-	  break;
-
-	case tok_choice:
-	  printf("\t$w.config.f.x%d.x.menu add radiobutton -label \"%s\" -variable %s -value \"%s\" -command \"update_menu%d .menu%d.config.f\"\n",
-		 cfg1->menu_line,
-		 cfg->label,
-		 cfg1->optionname,
-		 cfg->label,
-		 cfg1->menu_number, cfg1->menu_number);
-	  break;
-	case tok_choose:
-	  if( cfg->menu_number != menu_num )
-	    {
-	      end_proc(menu_num);
-	      start_proc(menulabel, cfg->menu_number, FALSE);
-	      menu_num = cfg->menu_number;
-	    }
-	  printf("\tglobal %s\n",cfg->optionname);
-	  printf("\tminimenu $w.config.f %d %d \"%s\" %s %s\n",
-	  	cfg->menu_number,
-	  	cfg->menu_line,
-	  	cfg->label,
-	  	cfg->optionname,
-	  	/*
-	  	 * We rely on the fact that the first tok_choice corresponding
-	  	 * to the current tok_choose is cfg->next (compare parse() in
-	  	 * tkparse.c).  We need its name to pick out the right help
-	  	 * text from Configure.help.
-	  	 */
-	  	cfg->next->optionname);
-	  printf("\tmenu $w.config.f.x%d.x.menu\n", cfg->menu_line);
-	  cfg1 = cfg;
-	  break;
-	case tok_tristate:
-	  if( cfg->menu_number != menu_num )
-	    {
-	      end_proc(menu_num);
-	      start_proc(menulabel, cfg->menu_number, FALSE);
-	      menu_num = cfg->menu_number;
-	    }
-	  printf("\ttristate $w.config.f %d %d \"%s\" %s\n",
-		 cfg->menu_number,
-		 cfg->menu_line,
-		 cfg->label,
-		 cfg->optionname);
-	  break;
-	case tok_dep_tristate:
-	  if( cfg->menu_number != menu_num )
-	    {
-	      end_proc(menu_num);
-	      start_proc(menulabel, cfg->menu_number, FALSE);
-	      menu_num = cfg->menu_number;
-	    }
-	  printf("\tdep_tristate $w.config.f %d %d \"%s\" %s %s\n",
-		 cfg->menu_number,
-		 cfg->menu_line,
-		 cfg->label,
-		 cfg->optionname,
-		 cfg->depend.str);
-	  break;
-	case tok_int:
-	  if( cfg->menu_number != menu_num )
-	    {
-	      end_proc(menu_num);
-	      start_proc(menulabel, cfg->menu_number, FALSE);
-	      menu_num = cfg->menu_number;
-	    }
-	  printf("\tint $w.config.f %d %d \"%s\" %s\n",
-		 cfg->menu_number,
-		 cfg->menu_line,
-		 cfg->label,
-		 cfg->optionname);
-	  break;
-	case tok_hex:
-	  if( cfg->menu_number != menu_num )
-	    {
-	      end_proc(menu_num);
-	      start_proc(menulabel, cfg->menu_number, FALSE);
-	      menu_num = cfg->menu_number;
-	    }
-	  printf("\thex $w.config.f %d %d \"%s\" %s\n",
-		 cfg->menu_number,
-		 cfg->menu_line,
-		 cfg->label,
-		 cfg->optionname);
-	  break;
-	default:
-	  break;
-	}
-
-    }
-
-  /*
-   * Generate the code to close out the last menu.
-   */
-  end_proc(menu_num);
-
-#ifdef ERIC_DONT_DEF
-  /*
-   * Generate the code for configuring the sound driver.  Right now this
-   * cannot be done from the X script, but we insert the menu anyways.
-   */
-  start_proc("Configure sound driver", ++menu_num, TRUE);
-#if 0
-  printf("\tdo_make -C drivers/sound config\n");
-  printf("\techo check_sound_config %d\n",menu_num);
-#endif
-  printf("\tlabel $w.config.f.m0 -bitmap error\n");
-  printf("\tmessage $w.config.f.m1 -width 400 -aspect 300 -text \"The sound drivers cannot as of yet be configured via the X-based interface\" -relief raised\n");
-  printf("\tpack $w.config.f.m0 $w.config.f.m1 -side top -pady 10 -expand on\n");
-  /*
-   * Close out the last menu.
-   */
-  end_proc(menu_num);
-#endif
-
-  /*
-   * The top level menu also needs an update function.  When we exit a
-   * submenu, we may need to disable one or more of the submenus on
-   * the top level menu, and this procedure will ensure that things are
-   * correct.
-   */
-  printf("proc update_mainmenu {w}  {\n");
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      switch (cfg->tok)
-	{
-	case tok_menuoption:
-	  if (cfg->cond != NULL ) 
-	    generate_if(cfg, cfg->cond, cfg->menu_number, cfg->menu_line);
-	  break;
-	default:
-	  break;
-	}
-    }
-
-  printf("}\n\n\n");
-
-#if 0
-  /*
-   * Generate some code to set the variables that are "defined".
-   */
-  for(cfg = config;cfg != NULL; cfg = cfg->next)
-    {
-      /*
-       * Skip items not for this menu, or ones having no conditions.
-       */
-      if( cfg->tok != tok_define) continue;
-      if (cfg->cond != NULL ) 
-	generate_if(cfg, cfg->cond, menu_num, cfg->menu_line);
-      else
-	{
-	  printf("\twrite_define %s %s\n", cfg->optionname, cfg->value);
-	}
-
-    }
-#endif
-
-  /*
-   * Now generate code to load the default settings into the variables.
-   * Note that the script in tail.tk will attempt to load .config,
-   * which may override these settings, but that's OK.
-   */
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      switch (cfg->tok)
-	{
-	case tok_bool:
-	case tok_tristate:
-	case tok_dep_tristate:
-	case tok_choice:
-	  printf("set %s 0\n", cfg->optionname);
-	  break;
-	case tok_int:
-	case tok_hex:
-	  printf("set %s %s\n", cfg->optionname, cfg->value);
-	  break;
-	case tok_choose:
-	  printf("set %s \"(not set)\"\n",cfg->optionname);
-	default:
-	  break;
-	}
-    }
-
-  /*
-   * Next generate a function that can be called from the main menu that will
-   * write all of the variables out.  This also serves double duty - we can
-   * save configuration to a file using this.
-   */
-  printf("proc writeconfig {file1 file2} {\n");
-  printf("\tset cfg [open $file1 w]\n");
-  printf("\tset autocfg [open $file2 w]\n");
-  printf("\tset notmod 1\n");
-  printf("\tset notset 0\n");
-  clear_globalflags(config);
-  printf("\tputs $cfg \"#\"\n");
-  printf("\tputs $cfg \"# Automatically generated make config: don't edit\"\n");
-  printf("\tputs $cfg \"#\"\n");
-
-  printf("\tputs $autocfg \"/*\"\n");
-  printf("\tputs $autocfg \" * Automatically generated C config: don't edit\"\n");
-  printf("\tputs $autocfg \" */\"\n");
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      switch (cfg->tok)
-	{
-	case tok_int:
-	case tok_hex:
-	case tok_bool:
-	case tok_tristate:
-	case tok_dep_tristate:
-	case tok_define:
-	case tok_choose:
-	  if(!(cfg->flags & GLOBAL_WRITTEN))
-	    {
-	      cfg->flags |= GLOBAL_WRITTEN;
-	      printf("\tglobal %s\n", cfg->optionname);
-	    }
-	  /* fall through */
-	case tok_make:
-	case tok_comment:
-	  if (cfg->cond != NULL ) 
-	    generate_if_for_outfile(cfg, cfg->cond);
-	  else
-	    {
-	      if(cfg->tok == tok_dep_tristate)
-		{
-		  printf("\tif {$%s == 0 } then {\n"
-		  	 "\t\twrite_tristate $cfg $autocfg %s $notset $notmod\n"
-		  	 "\t} else {\n"
-		  	 "\t\twrite_tristate $cfg $autocfg %s $%s $%s\n"
-		  	 "\t}\n",
-		  	 cfg->depend.str,
-			 cfg->optionname,
-			 cfg->optionname,
-			 cfg->optionname,
-			 cfg->depend.str);
-		}
-	      else if(cfg->tok == tok_comment)
-		{
-		  printf("\twrite_comment $cfg $autocfg \"%s\"\n", cfg->label);
-		}
-#if 0
-	      else if(cfg->tok == tok_define)
-		{
-		  printf("\twrite_define %s %s\n", cfg->optionname,
-			 cfg->value);
-		}
-#endif
-	      else if (cfg->tok == tok_choose )
-		{
-		  for(cfg1 = cfg->next; 
-		      cfg1 != NULL && cfg1->tok == tok_choice;
-		      cfg1 = cfg1->next)
-		    {
-		      printf("\tif { $%s == \"%s\" } then { write_tristate $cfg $autocfg %s 1 $notmod }\n",
-			     cfg->optionname,
-			     cfg1->label,
-			     cfg1->optionname);
-		    }
-		}
-	      else if (cfg->tok == tok_int )
-	        {
-		  printf("\twrite_int $cfg $autocfg %s $%s $notmod\n",
-			 cfg->optionname,
-			 cfg->optionname);
-	        }
-	      else if (cfg->tok == tok_hex )
-	        {
-		  printf("\twrite_hex $cfg $autocfg %s $%s $notmod\n",
-			 cfg->optionname,
-			 cfg->optionname);
-	        }
-	      else if (cfg->tok == tok_make )
-	        {
-	          printf("\tdo_make {%s}\n",cfg->value);
-	        }
-	      else
-		{
-		  printf("\twrite_tristate $cfg $autocfg %s $%s $notmod\n",
-			 cfg->optionname,
-			 cfg->optionname);
-		}
-	    }
-	  break;
-	default:
-	  break;
-	}
-    }
-  printf("\tclose $cfg\n");
-  printf("\tclose $autocfg\n");
-  printf("}\n\n\n");
-
-  /*
-   * Finally write a simple function that updates the master choice
-   * variable depending upon what values were loaded from a .config
-   * file.  
-   */
-  printf("proc clear_choices { } {\n");
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      if( cfg->tok != tok_choose ) continue;
-      for(cfg1 = cfg->next; 
-	  cfg1 != NULL && cfg1->tok == tok_choice;
-	  cfg1 = cfg1->next)
-	{
-	  printf("\tglobal %s; set %s 0\n",cfg1->optionname,cfg1->optionname);
-	}
-    }
-  printf("}\n\n\n");
-
-  printf("proc update_choices { } {\n");
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      if( cfg->tok != tok_choose ) continue;
-      printf("\tglobal %s\n", cfg->optionname);
-      for(cfg1 = cfg->next; 
-	  cfg1 != NULL && cfg1->tok == tok_choice;
-	  cfg1 = cfg1->next)
-	{
-	  printf("\tglobal %s\n", cfg1->optionname);
-	  printf("\tif { $%s == 1 } then { set %s \"%s\" }\n",
-		 cfg1->optionname,
-		 cfg->optionname,
-		 cfg1->label);
-	}
-    }
-  printf("}\n\n\n");
-
-  printf("proc update_define { } {\n");
-  clear_globalflags(config);
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      if( cfg->tok != tok_define ) continue;
-      printf("\tglobal %s; set %s 0\n",  cfg->optionname,  cfg->optionname);
-      cfg->flags |= GLOBAL_WRITTEN;
-    }
-  for(cfg = scfg; cfg != NULL; cfg = cfg->next)
-    {
-      if( cfg->tok != tok_define ) continue;
-      if (cfg->cond != NULL ) 
-	generate_if(cfg, cfg->cond, -1, 0);
-      else
-	{
-	  printf("\tset %s %s\n",
-		 cfg->optionname, cfg->value);
-	}
-    }
-  printf("}\n\n\n");
-  /*
-   * That's it.  We are done.  The output of this file will have header.tk
-   * prepended and tail.tk appended to create an executable wish script.
-   */
-}
Index: IOIPSL/trunk/tools/tkparse.c
===================================================================
--- IOIPSL/trunk/tools/tkparse.c	(revision 4999)
+++ 	(revision )
@@ -1,755 +1,0 @@
-/* parser config.in
- * $Id$
- *
- * This software is governed by the CeCILL license
- * See IOIPSL/IOIPSL_License_CeCILL.txt
- *
- * Version 1.0
- * Eric Youngdale
- * 10/95
- *
- * The general idea here is that we want to parse a config.in file and 
- * from this, we generate a wish script which gives us effectively the
- * same functionality that the original config.in script provided.
- *
- * This task is split roughly into 3 parts.  The first parse is the parse
- * of the input file itself.  The second part is where we analyze the 
- * #ifdef clauses, and attach a linked list of tokens to each of the
- * menu items.  In this way, each menu item has a complete list of
- * dependencies that are used to enable/disable the options.
- * The third part is to take the configuration database we have build,
- * and build the actual wish script.
- *
- * This file contains the code to do the first parse of config.in.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "tkparse.h"
-
-struct kconfig * config = NULL;
-struct kconfig * clast = NULL;
-struct kconfig * koption = NULL;
-static int lineno = 0;
-static int menus_seen = 0;
-static char * current_file = NULL;
-static int do_source(char * filename);
-static char * get_string(char *pnt, char ** labl);
-static int choose_number = 0;
-
-
-/*
- * Simple function just to skip over spaces and tabs in config.in.
- */
-static char * skip_whitespace(char * pnt)
-{
-  while( *pnt && (*pnt == ' ' || *pnt == '\t')) pnt++;
-  return pnt;
-}
-
-/*
- * This function parses a conditional from a config.in (i.e. from an ifdef)
- * and generates a linked list of tokens that describes the conditional.
- */
-static struct condition * parse_if(char * pnt)
-{
-  char * opnt;
-  struct condition *list;
-  struct condition *last;
-  struct condition *cpnt;
-  char varname[64];
-  char * pnt1;
-
-  opnt = pnt;
-
-  /*
-   * We need to find the various tokens, and build the linked list.
-   */
-  pnt = skip_whitespace(pnt);
-  if( *pnt != '[' ) return NULL;
-  pnt++;
-  pnt = skip_whitespace(pnt);
-
-  list = last = NULL;
-  while(*pnt && *pnt != ']') {
-
-    pnt = skip_whitespace(pnt);
-    if(*pnt== '\0' || *pnt == ']') break;
-
-    /*
-     * Allocate memory for the token we are about to parse, and insert
-     * it in the linked list.
-     */
-    cpnt = (struct condition *) malloc(sizeof(struct condition));
-    memset(cpnt, 0, sizeof(struct condition));
-    if( last == NULL )
-      {
-	list = last = cpnt;
-      }
-    else
-      {
-	last->next = cpnt;
-	last = cpnt;
-      }
-
-    /*
-     * Determine what type of operation this token represents.
-     */
-    if( *pnt == '-' && pnt[1] == 'a' )
-      {
-	cpnt->op = op_and;
-	pnt += 2;
-	continue;
-      }
-
-    if( *pnt == '-' && pnt[1] == 'o' )
-      {
-	cpnt->op = op_or;
-	pnt += 2;
-	continue;
-      }
-
-    if( *pnt == '!' && pnt[1] == '=' )
-      {
-	cpnt->op = op_neq;
-	pnt += 2;
-	continue;
-      }
-
-    if( *pnt == '=')
-      {
-	cpnt->op = op_eq;
-	pnt += 1;
-	continue;
-      }
-
-    if( *pnt == '!')
-      {
-	cpnt->op = op_bang;
-	pnt += 1;
-	continue;
-      }
-
-    if( *pnt != '"' ) goto error;  /* This cannot be right. */
-    pnt++;
-    if( *pnt == '`' )
-      {
-	cpnt->op = op_shellcmd;
-	pnt1 = varname;
-	pnt++;
-	while(*pnt && *pnt != '`') *pnt1++ = *pnt++;
-	*pnt1++ = '\0';
-	cpnt->variable.str = strdup(varname);
-	if( *pnt == '`' ) pnt++;
-	if( *pnt == '"' ) pnt++;
-	continue;
-      }
-    if( *pnt == '$' )
-      {
-	cpnt->op = op_variable;
-	pnt1 = varname;
-	pnt++;
-	while(*pnt && *pnt != '"') *pnt1++ = *pnt++;
-	*pnt1++ = '\0';
-	cpnt->variable.str = strdup(varname);
-	if( *pnt == '"' ) pnt++;
-	continue;
-      }
-
-    cpnt->op = op_constant;
-    pnt1 = varname;
-    while(*pnt && *pnt != '"') *pnt1++ = *pnt++;
-    *pnt1++ = '\0';
-    cpnt->variable.str = strdup(varname);
-    if( *pnt == '"' ) pnt++;
-    continue;
-  }
-
-  return list;
-
- error:
-  if(current_file != NULL) 
-    fprintf(stderr, 
-	    "Bad if clause at line %d(%s):%s\n", lineno, current_file, opnt);
-  else
-    fprintf(stderr,
-	    "Bad if clause at line %d:%s\n", lineno, opnt);
-  return NULL;
-}
-
-/*
- * This function looks for a quoted string, from the input buffer, and
- * returns a pointer to a copy of this string.  Any characters in
- * the string that need to be "quoted" have a '\' character inserted
- * in front - this way we can directly write these strings into
- * wish scripts.
- */
-static char * get_qstring(char *pnt, char ** labl)
-{
-  char quotechar;
-  char newlabel[1024];
-  char * pnt1;
-  char * pnt2;
-
-  while( *pnt && *pnt != '"' && *pnt != '\'') pnt++;
-  if (*pnt == '\0') return pnt;
-
-  quotechar = *pnt++;
-  pnt1 = newlabel;
-  while(*pnt && *pnt != quotechar && pnt[-1] != '\\')
-    {
-      /*
-       * Quote the character if we need to.
-       */
-      if( *pnt == '"' || *pnt == '\'' || *pnt == '[' || *pnt == ']')
-	*pnt1++ = '\\';
-
-      *pnt1++ = *pnt++;
-    }
-  *pnt1++ = '\0';
-
-  pnt2 = (char *) malloc(strlen(newlabel) + 1);
-  strcpy(pnt2, newlabel);
-  *labl = pnt2;
-
-  /*
-   * Skip over last quote, and whitespace.
-   */
-  pnt++;
-  pnt = skip_whitespace(pnt);
-  return pnt;
-}
-
-static char * parse_choices(struct kconfig * choice_kcfg, char * pnt)
-{
-  struct kconfig * kcfg;
-  int index = 1;
-
-  /*
-   * Choices appear in pairs of strings.  The parse is fairly trivial.
-   */
-  while(1)
-    {
-      pnt = skip_whitespace(pnt);
-      if(*pnt == '\0') break;
-
-      kcfg = (struct kconfig *) malloc(sizeof(struct kconfig));
-      memset(kcfg, 0, sizeof(struct kconfig));
-      kcfg->tok = tok_choice;
-      if( clast != NULL )
-	{
-	  clast->next = kcfg;
-	  clast = kcfg;
-	}
-      else
-	{
-	  clast = config = kcfg;
-	}
-
-      pnt = get_string(pnt, &kcfg->label);
-      pnt = skip_whitespace(pnt);
-      pnt = get_string(pnt, &kcfg->optionname);
-      kcfg->choice_label = choice_kcfg;
-      kcfg->choice_value = index++;
-      if( strcmp(kcfg->label, choice_kcfg->value) == 0 )
-	choice_kcfg->choice_value = kcfg->choice_value;
-    }
-    
-    return pnt;
-}
-
-
-/*
- * This function grabs one text token from the input buffer
- * and returns a pointer to a copy of just the identifier.
- * This can be either a variable name (i.e. CONFIG_NET),
- * or it could be the default value for the option.
- */
-static char * get_string(char *pnt, char ** labl)
-{
-  char newlabel[1024];
-  char * pnt1;
-  char * pnt2;
-
-  if (*pnt == '\0') return pnt;
-
-  pnt1 = newlabel;
-  while(*pnt && *pnt != ' ' && *pnt != '\t')
-    {
-      *pnt1++ = *pnt++;
-    }
-  *pnt1++ = '\0';
-
-  pnt2 = (char *) malloc(strlen(newlabel) + 1);
-  strcpy(pnt2, newlabel);
-  *labl = pnt2;
-
-  if( *pnt ) pnt++;
-  return pnt;
-}
-
-
-/*
- * Top level parse function.  Input pointer is one complete line from config.in
- * and the result is that we create a token that describes this line
- * and insert it into our linked list.
- */
-void parse(char * pnt) {
-  enum token tok;
-  struct kconfig * kcfg;
-  char tmpbuf[24],fake_if[1024];
-
-  /*
-   * Ignore comments and leading whitespace.
-   */
-
-  pnt = skip_whitespace(pnt);
-  while( *pnt && (*pnt == ' ' || *pnt == '\t')) pnt++;
-  if(! *pnt ) return;
-  if( *pnt == '#' ) return;
-
-  /*
-   * Now categorize the next token.
-   */
-  tok = tok_unknown;
-  if      (strncmp(pnt, "mainmenu_name", 13) == 0) 
-    {
-      tok = tok_menuname;
-      pnt += 13;
-    }
-  else if      (strncmp(pnt, "source", 6) == 0) 
-    {
-      pnt += 7;
-      pnt = skip_whitespace(pnt);
-      do_source(pnt);
-      return;
-    }
-  else if (strncmp(pnt, "mainmenu_option", 15) == 0) 
-    {
-      menus_seen++;
-      tok = tok_menuoption;
-      pnt += 15;
-    }
-  else if (strncmp(pnt, "$MAKE ", 6) == 0) 
-    {
-      tok = tok_make;
-    }
-  else if (strncmp(pnt, "comment", 7) == 0) 
-    {
-      tok = tok_comment;
-      pnt += 7;
-    }
-  else if (strncmp(pnt, "choice", 6) == 0) 
-    {
-      tok = tok_choose;
-      pnt += 6;
-    }
-  else if (strncmp(pnt, "define_bool", 11) == 0) 
-    {
-      tok = tok_define;
-      pnt += 11;
-    }
-  else if (strncmp(pnt, "bool", 4) == 0) 
-    {
-      tok = tok_bool;
-      pnt += 4;
-    }
-  else if (strncmp(pnt, "tristate", 8) == 0) 
-    {
-      tok = tok_tristate;
-      pnt += 8;
-    }
-  else if (strncmp(pnt, "dep_tristate", 12) == 0) 
-    {
-      tok = tok_dep_tristate;
-      pnt += 12;
-    }
-  else if (strncmp(pnt, "int", 3) == 0) 
-    {
-      tok = tok_int;
-      pnt += 3;
-    }
-  else if (strncmp(pnt, "hex", 3) == 0) 
-    {
-      tok = tok_hex;
-      pnt += 3;
-    }
-  else if (strncmp(pnt, "if", 2) == 0) 
-    {
-      tok = tok_if;
-      pnt += 2;
-    }
-  else if (strncmp(pnt, "else", 4) == 0) 
-    {
-      tok = tok_else;
-      pnt += 4;
-    }
-  else if (strncmp(pnt, "fi", 2) == 0) 
-    {
-      tok = tok_fi;
-      pnt += 2;
-    }
-  else if (strncmp(pnt, "endmenu", 7) == 0) 
-    {
-      tok = tok_endmenu;
-      pnt += 7;
-    }
-
-  if( tok == tok_unknown)
-    {
-      if( clast != NULL && clast->tok == tok_if 
-	  && strcmp(pnt,"then") == 0) return;
-      if( current_file != NULL )
-	fprintf(stderr, "unknown command=%s(%s %d)\n", pnt,
-		current_file, lineno);
-      else
-	fprintf(stderr, "unknown command=%s(%d)\n", pnt,lineno);
-      return;
-    }
-
-  /*
-   * Allocate memory for this item, and attach it to the end of the linked
-   * list.
-   */
-  kcfg = (struct kconfig *) malloc(sizeof(struct kconfig));
-  memset(kcfg, 0, sizeof(struct kconfig));
-  kcfg->tok = tok;
-  if( clast != NULL )
-    {
-      clast->next = kcfg;
-      clast = kcfg;
-    }
-  else
-    {
-      clast = config = kcfg;
-    }
-
-  pnt = skip_whitespace(pnt);
-
-  /*
-   * Now parse the remaining parts of the option, and attach the results
-   * to the structure.
-   */
-  switch (tok)
-    {
-    case tok_choose:
-      pnt = get_qstring(pnt, &kcfg->label);
-      pnt = get_qstring(pnt, &kcfg->optionname);
-      pnt = get_string(pnt, &kcfg->value);
-      /*
-       * Now we need to break apart the individual options into their
-       * own configuration structures.
-       */
-      parse_choices(kcfg, kcfg->optionname);
-      free(kcfg->optionname);
-      sprintf(tmpbuf, "tmpvar_%d", choose_number++);
-      kcfg->optionname = strdup(tmpbuf);
-      break;
-    case tok_define:
-      pnt = get_string(pnt, &kcfg->optionname);
-      if(*pnt == 'y' || *pnt == 'Y' ) kcfg->value = "1";
-      if(*pnt == 'n' || *pnt == 'N' ) kcfg->value = "0";
-      if(*pnt == 'm' || *pnt == 'M' ) kcfg->value = "2";
-      break;
-    case tok_menuname:
-      pnt = get_qstring(pnt, &kcfg->label);
-      break;
-    case tok_bool:
-    case tok_tristate:
-      pnt = get_qstring(pnt, &kcfg->label);
-      pnt = get_string(pnt, &kcfg->optionname);
-      break;
-    case tok_int:
-    case tok_hex:
-      pnt = get_qstring(pnt, &kcfg->label);
-      pnt = get_string(pnt, &kcfg->optionname);
-      pnt = get_string(pnt, &kcfg->value);
-      break;
-    case tok_dep_tristate:
-      pnt = get_qstring(pnt, &kcfg->label);
-      pnt = get_string(pnt, &kcfg->optionname);
-      pnt = skip_whitespace(pnt);
-      if( *pnt == '$') pnt++;
-      pnt = get_string(pnt, &kcfg->depend.str);
-
-      /*
-       * Create a conditional for this object's dependency.
-       *
-       * We can't use "!= n" because this is internally converted to "!= 0"
-       * and if UMSDOS depends on MSDOS which depends on FAT, then when FAT
-       * is disabled MSDOS has 16 added to its value, making UMSDOS fully
-       * available.  Whew.
-       *
-       * This is more of a hack than a fix.  Nested "if" conditionals are
-       * probably affected too - that +/- 16 affects things in too many
-       * places.  But this should do for now.
-       */
-      sprintf(fake_if,"[ \"$%s\" = \"y\" -o \"$%s\" = \"m\" ]; then",
-	      	kcfg->depend.str,kcfg->depend.str);
-      kcfg->cond = parse_if(fake_if);
-      if(kcfg->cond == NULL )
-	{
-	  exit(1);
-	}
-      break;
-    case tok_comment:
-      pnt = get_qstring(pnt, &kcfg->label);
-      if( koption != NULL )
-	{
-	  pnt = get_qstring(pnt, &kcfg->label);
-	  koption->label = kcfg->label;
-	  koption = NULL;
-	}
-      break;
-    case tok_menuoption:
-      if( strncmp(pnt, "next_comment", 12) == 0)
-	{
-	  koption = kcfg;
-	}
-      else
-	{
-	  pnt = get_qstring(pnt, &kcfg->label);
-	}
-      break;
-    case tok_make:
-      kcfg->value=strdup(pnt);
-      break;
-    case tok_else:
-    case tok_fi:
-    case tok_endmenu:
-      break;
-    case tok_if:
-      /*
-       * Conditionals are different.  For the first level parse, only
-       * tok_if and tok_dep_tristate items have a ->cond chain attached.
-       */
-      kcfg->cond = parse_if(pnt);
-      if(kcfg->cond == NULL )
-	{
-	  exit(1);
-	}
-      break;
-    default:
-      exit(0);
-    }
-    
-    return;
-}
-
-/*
- * Simple function to dump to the screen what the condition chain looks like.
- */
-void dump_if(struct condition * cond)
-{
-  printf(" ");
-  while(cond != NULL )
-    {
-      switch(cond->op){
-      case op_eq:
-	printf(" = ");
-	break;
-      case op_bang:
-	printf(" ! ");
-	break;
-      case op_neq:
-	printf(" != ");
-	break;
-      case op_and:
-	printf(" -a ");
-	break;
-      case op_lparen:
-	printf("(");
-	break;
-      case op_rparen:
-	printf(")");
-	break;
-      case op_variable:
-	printf("$%s", cond->variable.str);
-	break;
-      case op_constant:
-	printf("'%s'", cond->variable.str);
-	break;
-      default:
-        break;
-      }
-      cond = cond->next;
-    }
-
-  printf("\n");
-}
-
-static int do_source(char * filename)
-{
-  char buffer[1024];
-  int  offset;
-  int old_lineno;
-  char * old_file;
-  char * pnt;
-  FILE * infile;
-
-  if( strcmp(filename, "-") == 0 )
-    infile = stdin;
-  else
-    infile = fopen(filename,"r");
-
-  /*
-   * If our cwd was in the scripts directory, we might have to go up one
-   * to find the sourced file.
-   */
-  if(!infile) {
-    strcpy (buffer, "../");
-    strcat (buffer, filename);
-    infile = fopen(buffer,"r");
-  }
-
-  if(!infile) {
-    fprintf(stderr,"Unable to open file %s\n", filename);
-    return 1;
-  }
-  old_lineno = lineno;
-  lineno = 0;
-  if( infile != stdin ) {
-    old_file = current_file;
-    current_file = filename;
-  }
-  offset = 0;
-  while(1)
-    {
-      fgets(&buffer[offset], sizeof(buffer) - offset, infile);
-      if(feof(infile)) break;
-
-      /*
-       * Strip the trailing return character.
-       */
-      pnt = buffer + strlen(buffer) - 1;
-      if( *pnt == '\n') *pnt-- = 0;
-      lineno++;
-      if( *pnt == '\\' )
-	{
-	  offset = pnt - buffer;
-	}
-      else
-	{
-	  parse(buffer);
-	  offset = 0;
-	}
-    }
-  fclose(infile);
-  if( infile != stdin ) {
-    current_file = old_file;
-  }
-  lineno = old_lineno;
-  return 0;
-}
-
-int main(int argc, char * argv[])
-{
-#if 0
-  char buffer[1024];
-  char * pnt;
-  struct kconfig * cfg;
-  int    i;
-#endif
-
-  /*
-   * Read stdin to get the top level script.
-   */
-  do_source("-");
-
-  if( menus_seen == 0 )
-    {
-      fprintf(stderr,"The config.in file for this platform does not support\n");
-      fprintf(stderr,"menus.\n");
-      exit(1);
-    }
-  /*
-   * Input file is now parsed.  Next we need to go through and attach
-   * the correct conditions to each of the actual menu items and kill
-   * the if/else/endif tokens from the list.  We also flag the menu items
-   * that have other things that depend upon its setting.
-   */
-  fix_conditionals(config);
-
-  /*
-   * Finally, we generate the wish script.
-   */
-  dump_tk_script(config);
-
-#if 0
-  /*
-   * Now dump what we have so far.  This is only for debugging so that
-   * we can display what we think we have in the list.
-   */
-  for(cfg = config; cfg; cfg = cfg->next)
-    {
-
-      if(cfg->cond != NULL && cfg->tok != tok_if)
-	dump_if(cfg->cond);
-
-      switch(cfg->tok)
-	{
-	case tok_menuname:
-	  printf("main_menuname ");
-	  break;
-	case tok_bool:
-	  printf("bool ");
-	  break;
-	case tok_tristate:
-	  printf("tristate ");
-	  break;
-	case tok_dep_tristate:
-	  printf("dep_tristate ");
-	  break;
-	case tok_int:
-	  printf("int ");
-	  break;
-	case tok_hex:
-	  printf("hex ");
-	  break;
-	case tok_comment:
-	  printf("comment ");
-	  break;
-	case tok_menuoption:
-	  printf("menuoption ");
-	  break;
-	case tok_else:
-	  printf("else");
-	  break;
-	case tok_fi:
-	  printf("fi");
-	  break;
-	case tok_if:
-	  printf("if");
-	  break;
-	default:
-	}
-
-      switch(cfg->tok)
-	{
-	case tok_menuoption:
-	case tok_comment:
-	case tok_menuname:
-	  printf("%s\n", cfg->label);
-	  break;
-	case tok_bool:
-	case tok_tristate:
-	case tok_dep_tristate:
-	case tok_int:
-	case tok_hex:
-	  printf("%s %s\n", cfg->label, cfg->optionname);
-	  break;
-	case tok_if:
-	  dump_if(cfg->cond);
-	  break;
-	case tok_nop:
-	case tok_endmenu:
-	  break;
-	default:
-	  printf("\n");
-	}
-    }
-#endif
-
-  return 0;
-
-}
Index: IOIPSL/trunk/tools/tkparse.h
===================================================================
--- IOIPSL/trunk/tools/tkparse.h	(revision 4999)
+++ 	(revision )
@@ -1,82 +1,0 @@
-
-enum token {
-  tok_menuname, 
-  tok_menuoption, 
-  tok_comment, 
-  tok_bool, 
-  tok_tristate, 
-  tok_dep_tristate,
-  tok_nop,
-  tok_if, 
-  tok_else, 
-  tok_fi, 
-  tok_int,
-  tok_hex,
-  tok_make,
-  tok_define,
-  tok_choose,
-  tok_choice,
-  tok_endmenu,
-  tok_unknown
-};
-
-enum operator {
-  op_eq,
-  op_neq,
-  op_and,
-  op_and1,
-  op_or,
-  op_bang,
-  op_lparen,
-  op_rparen,
-  op_variable,
-  op_kvariable,
-  op_shellcmd,
-  op_constant,
-  op_nuked
-};
-
-union var
-{
-  char * str;
-  struct kconfig * cfg;
-};
-
-struct condition
-{
-  struct condition * next;
-  enum operator op;
-  union var variable;
-};
-
-#define GLOBAL_WRITTEN  1
-#define CFG_DUP 	2
-#define UNSAFE		4
-
-struct kconfig
-{
-  struct kconfig 	* next;
-  int 			  flags;
-  enum 			  token tok;
-  char   		  menu_number;
-  char   		  menu_line;
-  char   		  submenu_start;
-  char   		  submenu_end;
-  char 			* optionname;
-  char 			* label;
-  char 			* value;
-  int   		  choice_value;
-  struct kconfig        * choice_label;
-  union var 		  depend;
-  struct condition 	* cond;
-};
-
-extern struct kconfig * config;
-extern struct kconfig * clast;
-extern struct kconfig * koption;
-
-/*
- * Prototypes
- */
-void fix_conditionals(struct kconfig * scfg);	/* tkcond.c */
-void dump_tk_script(struct kconfig *scfg);	/* tkgen.c  */
