Index: /IOIPSL/trunk/tools/flio_rbld.f90
===================================================================
--- /IOIPSL/trunk/tools/flio_rbld.f90	(revision 256)
+++ /IOIPSL/trunk/tools/flio_rbld.f90	(revision 257)
@@ -14,5 +14,5 @@
 !!
 !!   rebuild -h
-!!    
+!!
 !!   rebuild [-v] -o outfile infile[1] ... infile[n]
 !!
@@ -20,5 +20,5 @@
 !!
 !!   -h         : help
-!!   -v         : verbose writing mode
+!!   -v lev     : verbosity level
 !!   -f         : force executing mode
 !!   -o outfile : name of the recombined file.
@@ -27,9 +27,9 @@
 !! INPUT for "flio_rbld" :
 !!
-!!  (C) c_wmode  : writing mode (silencious/verbose)
+!!  (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 :
@@ -78,9 +78,11 @@
 ! DO loops and test related variables
   INTEGER :: i,ia,id,iv,iw,i_i,i_n
-  LOGICAL :: l_verbose,l_force
+  INTEGER :: ik,itmin,itmax,it1,it2,it
+  LOGICAL :: l_force,l_uld
 !-
 ! Input arguments related variables
-  CHARACTER(LEN=15) :: c_wmode,c_force
-  INTEGER :: f_nb
+  INTEGER :: i_v_lev
+  CHARACTER(LEN=15) :: c_force
+  INTEGER :: f_nb,f_nb_in
   CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: f_nm
 !-
@@ -96,14 +98,16 @@
   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_ul_d
-  INTEGER :: v_type,v_d_nb,v_a_nb
+  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) :: v_d_i,ib,ie
+  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
+ &  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
@@ -150,7 +154,6 @@
 !-------------------
 !-
-! Retrieve the write mode
-  READ (UNIT=*,FMT='(A)') c_wmode
-  l_verbose = (TRIM(c_wmode) == 'verbose')
+! Retrieve the verbosity level
+  READ (UNIT=*,FMT=*) i_v_lev
 !-
 ! Retrieve the executing mode
@@ -160,4 +163,5 @@
 ! Retrieve the number of arguments
   READ (UNIT=*,FMT=*) f_nb
+  f_nb_in = f_nb-1
 !-
 ! Retrieve the file names
@@ -167,18 +171,18 @@
   ENDDO
 !-
-  IF (l_verbose) THEN
+! 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='(" write mode : """,A,"""")') TRIM(c_wmode)
-    WRITE (UNIT=*,FMT='(" exec  mode : """,A,"""")') TRIM(c_force)
-    WRITE (UNIT=*,FMT='(" nb_args    : ",I4)') f_nb
+    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-1
+    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))
-  ENDIF
-!-
-  IF (l_verbose) THEN
 !-- time initializations
     CALL system_clock &
@@ -192,5 +196,5 @@
 !-
 ! Open the first file
-  CALL flioopfd (TRIM(f_nm(1)),f_id_i)
+  CALL flrb_of (1,f_id_i)
 !-
 ! Get the attribute "DOMAIN_number_total"
@@ -200,11 +204,11 @@
 ! should be equal to the total number
 ! of domains used in the simulation
-  IF (d_n_t /= (f_nb-1)) THEN
+  IF (d_n_t /= f_nb_in) THEN
     IF (l_force) THEN
       iw = 2
     ELSE
       iw = 3
-      DEALLOCATE(f_nm)
-      CALL flioclo (f_id_i)
+      DEALLOCATE(f_nm,f_a_id)
+      CALL flrb_cf (1,.TRUE.)
     ENDIF
     CALL ipslerr (iw,"flio_rbld", &
@@ -215,5 +219,5 @@
 ! 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_ul_d)
+ & (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
@@ -229,9 +233,5 @@
 !-
 ! Close the file
-  CALL flioclo (f_id_i)
-!-
-!----------------------------------------------------
-! Retrieve domain informations for each input file
-!----------------------------------------------------
+  CALL flrb_cf (1,.FALSE.)
 !-
 ! Check if the number of needed files is greater than
@@ -240,14 +240,12 @@
 ! otherwise keep the "flio" identifiers of the opened files.
   l_ocf = (f_nb > flio_max_files)
-  IF (.NOT.l_ocf) THEN
-    ALLOCATE(f_a_id(f_nb-1))
-  ENDIF
-!-
-  DO iw=1,f_nb-1
+!-
+!----------------------------------------------------
+! Retrieve domain informations for each input file
+!----------------------------------------------------
+!-
+  DO iw=1,f_nb_in
 !---
-    CALL flioopfd (TRIM(f_nm(iw)),f_id_i)
-    IF (.NOT.l_ocf) THEN
-      f_a_id(iw) = f_id_i
-    ENDIF
+    CALL flrb_of (iw,f_id_i)
 !---
     IF (iw > 1) THEN
@@ -275,4 +273,10 @@
       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(:)
@@ -335,5 +339,5 @@
         CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
         IF (iw == 1) THEN
-          ALLOCATE (d_s_l(a_l,f_nb-1))
+          ALLOCATE (d_s_l(a_l,f_nb_in))
         ENDIF
         d_s_l(:,iw)=dom_att(:)
@@ -358,5 +362,5 @@
         CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
         IF (iw == 1) THEN
-          ALLOCATE (d_p_f(a_l,f_nb-1))
+          ALLOCATE (d_p_f(a_l,f_nb_in))
         ENDIF
         d_p_f(:,iw)=dom_att(:)
@@ -381,5 +385,5 @@
         CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
         IF (iw == 1) THEN
-          ALLOCATE (d_p_l(a_l,f_nb-1))
+          ALLOCATE (d_p_l(a_l,f_nb_in))
         ENDIF
         d_p_l(:,iw)=dom_att(:)
@@ -404,5 +408,5 @@
         CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
         IF (iw == 1) THEN
-          ALLOCATE (d_h_s(a_l,f_nb-1))
+          ALLOCATE (d_h_s(a_l,f_nb_in))
         ENDIF
         d_h_s(:,iw)=dom_att(:)
@@ -427,5 +431,5 @@
         CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
         IF (iw == 1) THEN
-          ALLOCATE (d_h_e(a_l,f_nb-1))
+          ALLOCATE (d_h_e(a_l,f_nb_in))
         ENDIF
         d_h_e(:,iw)=dom_att(:)
@@ -466,10 +470,9 @@
     ENDIF
 !---
-    IF (l_ocf) THEN
-      CALL flioclo (f_id_i)
-    ENDIF
+    CALL flrb_cf (iw,l_ocf)
+!---
   ENDDO
 !-
-  IF (l_verbose) THEN
+  IF (i_v_lev >= 2) THEN
     WRITE (UNIT=*,FMT='("")')
     WRITE (*,'(" From the first file : ")')
@@ -481,6 +484,6 @@
       WRITE (*,'("       """,A,"""")') TRIM(f_d_nm(i))
     ENDDO
-    IF (f_ul_d > 0) THEN
-      WRITE (*,'("   Unlimited dimension id : ",I2)') f_d_i(f_ul_d)
+    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
@@ -494,4 +497,6 @@
       WRITE (*,'("       """,A,"""")') TRIM(f_a_nm(i))
     ENDDO
+  ENDIF
+  IF (i_v_lev >= 3) THEN
     WRITE (UNIT=*,FMT='("")')
     WRITE (*,'(" From input files : ")')
@@ -500,5 +505,5 @@
     WRITE (*,'("   DOMAIN_size_global    :",(10(1X,I5),:))') d_s_g(:)
     WRITE (*,'("   DOMAIN_type           : """,(A),"""")') TRIM(c_d_n)
-    DO iw=1,f_nb-1
+    DO iw=1,f_nb_in
       WRITE (*,'("   File   : ",A)') TRIM(f_nm(iw))
       WRITE (*,'("     d_s_l  :",(10(1X,I5),:))') d_s_l(:,iw)
@@ -537,6 +542,6 @@
   ENDDO
 !-
-  IF (f_ul_d > 0) THEN
-    i = f_d_l(f_ul_d); f_d_l(f_ul_d) = -1;
+  IF (f_d_ul > 0) THEN
+    i = f_d_l(f_d_ul); f_d_l(f_d_ul) = -1;
   ENDIF
 !-
@@ -544,20 +549,13 @@
   CALL fliocrfd (TRIM(f_nm(f_nb)),f_d_nm,f_d_l,f_id_o,c_f_n=c_wn1)
 !-
-  IF (l_verbose) THEN
-    WRITE (UNIT=*,FMT='("")')
-    WRITE (UNIT=*,FMT=*) "Output file : ",TRIM(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
 !-
-  IF (f_ul_d > 0) THEN
-    f_d_l(f_ul_d) = i
-  ENDIF
-!-
 ! open the first input file used to build the output file
 !-
-  IF (l_ocf) THEN
-    CALL flioopfd (TRIM(f_nm(1)),f_id_i1)
-  ELSE
-    f_id_i1 = f_a_id(1)
-  ENDIF
+  CALL flrb_of (1,f_id_i1)
 !-
 ! define the global attributes in the output file
@@ -576,16 +574,27 @@
 ! 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, &
- &    nb_dims=v_d_nb,id_dims=v_d_i,nb_atts=v_a_nb)
+ &   (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 == 0) THEN
+    IF (v_d_nb(iv) == 0) THEN
       CALL fliodefv &
- &     (f_id_o,TRIM(f_v_nm(iv)),v_t=v_type)
+ &     (f_id_o,TRIM(f_v_nm(iv)),v_t=v_type(iv))
     ELSE
       CALL fliodefv &
- &     (f_id_o,TRIM(f_v_nm(iv)),v_d_i(1:v_d_nb),v_t=v_type)
+ &     (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
@@ -600,742 +609,774 @@
   ENDDO
 !-
+! update valid_min valid_max attributes values
+!-
+  CALL flrb_rg
+!-
 !------------------------
 ! Fill the output file
 !------------------------
 !-
-  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, &
- &    nb_dims=v_d_nb,id_dims=v_d_i)
-    IF (l_verbose) THEN
-      WRITE (UNIT=*,FMT='("")')
-      WRITE (UNIT=*,FMT=*) "variable : ",TRIM(f_v_nm(iv))
+  DO ik=1,2
+    l_uld = (ik /= 1)
+    IF (l_uld) THEN
+      it1=itmin; it2=itmax;
+    ELSE
+      it1=1; it2=1;
     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) == d_d_i(i))
-      l_cgd = l_cgd.AND.ANY(d_s_l(i,1:f_nb-1) /= d_s_g(i))
-      IF (l_cgd) THEN
-        i_n = f_nb-1
-          EXIT
-      ENDIF
-    ENDDO
-    IF (v_d_nb > 0) THEN
-!---- Allocate io_i,io_n,ia_sm,io_sm,io_cm
-      ALLOCATE(io_i(v_d_nb),io_n(v_d_nb))
-      ALLOCATE(ia_sm(v_d_nb),io_sm(v_d_nb),io_cm(v_d_nb))
-!---- 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));
-      ia_sm(:) = 1; io_sm(:) = 1; io_cm(:) = io_n(:);
-!---- If needed, allocate offset
-      l_o_f = .FALSE.; l_o_l = .FALSE.;
-      IF (TRIM(c_d_n) == "apple") THEN
-        ALLOCATE(ia_sf(v_d_nb),io_sf(v_d_nb),io_cf(v_d_nb))
-        ALLOCATE(ia_sl(v_d_nb),io_sl(v_d_nb),io_cl(v_d_nb))
-        ia_sf(:) = 1; io_sf(:) = 1; io_cf(:) = io_n(:);
-        ia_sl(:) = 1; io_sl(:) = 1; io_cl(:) = io_n(:);
-      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
-        IF (l_ocf) THEN
-          IF (i_i == 1) THEN
-            f_id_i = f_id_i1
-          ELSE
-            CALL flioopfd (TRIM(f_nm(i_i)),f_id_i)
+    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
-        ELSE
-          f_id_i = f_a_id(i_i)
-        ENDIF
-!-------
-!------ 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
-            DO i=1,SIZE(d_d_i)
-              IF (v_d_i(id) == 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
-            DO i=1,SIZE(d_d_i)
-              IF (v_d_i(id) == 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_l = .FALSE.;
-        DO id=1,v_d_nb
-          DO i=1,SIZE(d_d_i)
-            IF (v_d_i(id) == 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.
+          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_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_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
-                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
+              ENDDO
+            ENDDO
+          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
-          ENDDO
+            WRITE (UNIT=*,FMT=*) "ia_sm : ",ia_sm(:)
+            WRITE (UNIT=*,FMT=*) "io_sm : ",io_sm(:)
+            WRITE (UNIT=*,FMT=*) "io_cm : ",io_cm(:)
+            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
+!?            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(:))
+!?            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
+!?            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(:))
+!?            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
+!?            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(:))
+!?            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
+!?            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(:))
+!?            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
+!?            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(:))
+!?            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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
+              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(:))
+              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
-      ELSE
-!------ the data can be read/write in one piece
-        f_id_i = f_id_i1
-      ENDIF
-!-----
-      IF (l_verbose) 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=*) "ia_sm : ",ia_sm(:)
-        WRITE (UNIT=*,FMT=*) "io_sm : ",io_sm(:)
-        WRITE (UNIT=*,FMT=*) "io_cm : ",io_cm(:)
-        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)
-!?INTEGERS of KIND 1 are not supported on all computers
-!?    CASE (flio_i1) !--- INTEGER 1
-!?      SELECT CASE (v_d_nb)
-!?      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
-!?        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(:))
-!?        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
-!?        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(:))
-!?        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
-!?        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(:))
-!?        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
-!?        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(:))
-!?        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
-!?        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(:))
-!?        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)
-        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(:))
+!------ 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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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)
-        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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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)
-        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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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)
-        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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-          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(:))
-          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
-!----
-      IF (l_ocf.AND.l_cgd.AND.(i_i /= 1)) THEN
-!------ close each file containing a small piece of data
-        CALL flioclo (f_id_i)
-      ENDIF
+        ENDIF
+      ENDDO
     ENDDO
-!---
-!-- If needed, deallocate io_* arrays
-    IF (v_d_nb > 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
 !-
@@ -1345,17 +1386,15 @@
 !-
 ! Close files
-  CALL flioclo ()
+  CALL flrb_cf (0,.TRUE.)
 !-
 ! Deallocate
-  DEALLOCATE(f_nm)
-  IF (.NOT.l_ocf) THEN
-    DEALLOCATE(f_a_id)
-  ENDIF
+  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 (l_verbose) THEN
+  IF (i_v_lev >= 1) THEN
 !-- elapsed and cpu time computation
     CALL cpu_time (t_cpu_end)
@@ -1367,4 +1406,160 @@
  &   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)
+        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)
+        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)
+        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/rebuild
===================================================================
--- /IOIPSL/trunk/tools/rebuild	(revision 256)
+++ /IOIPSL/trunk/tools/rebuild	(revision 257)
@@ -4,66 +4,81 @@
 # @(#)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 for the script (d_n/b_n)
+# Extract the calling sequence of the script (d_n/b_n)
 #-
-d_n=$(dirname $0); b_n=$(basename $0);
+d_n=${0%/*}; b_n=${0##*/};
 #-
-# Retrieving and validation of the options
+# Retrieving the options
 #-
-r_v='silencious'; r_f='noforce'; r_o="";
-while getopts :hvfo: V
+r_v='0'; r_f='noforce'; r_o="";
+while getopts :hv:fo: V
  do
   case $V in
-   (h) echo '';
-       echo '"'${b_n}'"';
-       echo '  rebuild a model_file from several input files.';
-       echo 'Each input file contains the model_data for a domain.';
-       echo 'Usage :';
-       echo ${b_n} '[-h]';
-       echo ${b_n} '[-v] [-f] -o output_file_name input_file_names';
-       echo ' -h : this help';
-       echo ' -v : verbose mode';
-       echo ' -f : executing mode';
-       echo '  (execute the program even if the number of input files';
-       echo '   is not equal to the total number of domains)';
-       echo '';
-       exit 0;;
-   (v) r_v='verbose';;
+   (h) rebuild_Usage; exit 0;;
+   (v) r_v=${OPTARG};;
    (f) r_f='force';;
    (o) r_o=${OPTARG};;
-   (:)  echo ${b_n}" : option $OPTARG : missing value" 1>&2;
-        exit 2;;
-   (\?) echo ${b_n}" : option $OPTARG : not supported" 1>&2;
-        exit 2;;
+   (:) 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
 #-
-if   [ ${#} -lt 1 ]; then
-  echo ${b_n}' : Too few arguments have been specified. (Use -h)' 1>&2;
+[[ ${#} < 1 ]] && \
+ {
+  print -u2 "${b_n} : Too few arguments have been specified. (Use -h)";
   exit 3;
-fi
+ }
 #-
 # Check for the output file name
 #-
-if [ '\?'${r_o} = '\?' ]; then
-  echo ' ' 1>&2;
-  echo ${b_n}' : output_file_name not specified. (Use -h)' 1>&2;
-  echo '          "rebuilt_file.nc" should be created.' 1>&2;
-  echo ' ' 1>&2;
-  r_o='rebuilt_file.nc'
-fi;
+[[ -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
 #-
-qi=0;
 for i in $*;
- do ((qi=qi+1));
-  [ ${qi} -le ${#} ] && [ ! -f ${i} ] && \
-    { echo "${i} unreachable ..."; exit 3;}
+ do
+  [[ ! -f ${i} ]] && { echo "${i} unreachable ..."; exit 3;}
  done
 #-
@@ -72,6 +87,5 @@
 echo ${r_v} > tmp.$$;
 echo ${r_f} >> tmp.$$;
-((qi=$#+1));
-echo ${qi} >> tmp.$$;
+echo $((${#}+1)) >> tmp.$$;
 for i in $*;
  do echo ${i} >> tmp.$$;
