Index: IOIPSL/trunk/src/getincom.f90
===================================================================
--- IOIPSL/trunk/src/getincom.f90	(revision 1030)
+++ IOIPSL/trunk/src/getincom.f90	(revision 1313)
@@ -6,5 +6,5 @@
 ! See IOIPSL/IOIPSL_License_CeCILL.txt
 !---------------------------------------------------------------------
-USE errioipsl, ONLY : ipslerr
+USE errioipsl, ONLY : ipslerr,ipsldbg
 USE stringop, &
  &   ONLY : nocomma,cmpblank,strlowercase
@@ -35,9 +35,9 @@
 !! and if not we get it from the definition file.
 !!
-!! SUBROUTINE getin (target,ret_val)
+!! SUBROUTINE getin (targetname,ret_val)
 !!
 !! INPUT
 !!
-!! (C) target : Name of the variable
+!! (C) targetname : Name of the variable
 !!
 !! OUTPUT
@@ -98,4 +98,5 @@
 ! keystatus = 2 : Default value is used
 ! keystatus = 3 : Some vector elements were taken from default
+  INTEGER,PARAMETER :: nondefault=1, default=2, vectornondefault=3
 !-
 ! keytype definition
@@ -150,30 +151,32 @@
 !=== INTEGER INTERFACE
 !-
-SUBROUTINE getinis (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinis (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   INTEGER :: ret_val
 !-
   INTEGER,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+  INTEGER :: pos,status=0,fileorig, size_of_in
+!---------------------------------------------------------------------
+!-
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   tmp_ret_val(1) = ret_val
+  size_of_in = SIZE(tmp_ret_val)
+  
 !-
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,1,i_val=tmp_ret_val)
+ &   (targetname,status,fileorig,1,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,1,target,i_val=tmp_ret_val)
+    CALL get_rdb (pos,1,targetname,i_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
@@ -181,9 +184,9 @@
 END SUBROUTINE getinis
 !===
-SUBROUTINE getini1d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getini1d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   INTEGER,DIMENSION(:) :: ret_val
 !-
@@ -193,7 +196,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -209,11 +212,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,i_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
@@ -221,9 +224,9 @@
 END SUBROUTINE getini1d
 !===
-SUBROUTINE getini2d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getini2d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   INTEGER,DIMENSION(:,:) :: ret_val
 !-
@@ -234,7 +237,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -259,11 +262,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,i_val=tmp_ret_val)
   ENDIF
 !-
@@ -280,30 +283,31 @@
 !=== REAL INTERFACE
 !-
-SUBROUTINE getinrs (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinrs (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   REAL :: ret_val
 !-
   REAL,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+  INTEGER :: pos,status=0,fileorig, size_of_in
+!---------------------------------------------------------------------
+!-
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   tmp_ret_val(1) = ret_val
+  size_of_in = SIZE(tmp_ret_val)
 !-
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,1,r_val=tmp_ret_val)
+ &   (targetname,status,fileorig,1,r_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,1,target,r_val=tmp_ret_val)
+    CALL get_rdb (pos,1,targetname,r_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
@@ -311,9 +315,9 @@
 END SUBROUTINE getinrs
 !===
-SUBROUTINE getinr1d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinr1d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   REAL,DIMENSION(:) :: ret_val
 !-
@@ -323,7 +327,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -339,11 +343,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,r_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
@@ -351,9 +355,9 @@
 END SUBROUTINE getinr1d
 !===
-SUBROUTINE getinr2d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinr2d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   REAL,DIMENSION(:,:) :: ret_val
 !-
@@ -364,7 +368,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -389,11 +393,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,r_val=tmp_ret_val)
   ENDIF
 !-
@@ -410,30 +414,31 @@
 !=== CHARACTER INTERFACE
 !-
-SUBROUTINE getincs (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getincs (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   CHARACTER(LEN=*) :: ret_val
 !-
   CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val
-  INTEGER :: pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+  INTEGER :: pos,status=0,fileorig,size_of_in
+!---------------------------------------------------------------------
+!-
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   tmp_ret_val(1) = ret_val
+  size_of_in = SIZE(tmp_ret_val)
 !-
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,1,c_val=tmp_ret_val)
+ &   (targetname,status,fileorig,1,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,1,target,c_val=tmp_ret_val)
+    CALL get_rdb (pos,1,targetname,c_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
@@ -441,9 +446,9 @@
 END SUBROUTINE getincs
 !===
-SUBROUTINE getinc1d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinc1d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   CHARACTER(LEN=*),DIMENSION(:) :: ret_val
 !-
@@ -453,7 +458,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -469,11 +474,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,c_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
@@ -481,9 +486,9 @@
 END SUBROUTINE getinc1d
 !===
-SUBROUTINE getinc2d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinc2d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val
 !-
@@ -494,7 +499,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -519,11 +524,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,c_val=tmp_ret_val)
   ENDIF
 !-
@@ -540,30 +545,31 @@
 !=== LOGICAL INTERFACE
 !-
-SUBROUTINE getinls (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinls (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   LOGICAL :: ret_val
 !-
   LOGICAL,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+  INTEGER :: pos,status=0,fileorig,size_of_in
+!---------------------------------------------------------------------
+!-
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   tmp_ret_val(1) = ret_val
+  size_of_in = SIZE(tmp_ret_val)
 !-
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,1,l_val=tmp_ret_val)
+ &   (targetname,status,fileorig,1,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,1,target,l_val=tmp_ret_val)
+    CALL get_rdb (pos,1,targetname,l_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
@@ -571,9 +577,9 @@
 END SUBROUTINE getinls
 !===
-SUBROUTINE getinl1d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinl1d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   LOGICAL,DIMENSION(:) :: ret_val
 !-
@@ -583,7 +589,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -599,11 +605,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,l_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
@@ -611,9 +617,9 @@
 END SUBROUTINE getinl1d
 !===
-SUBROUTINE getinl2d (target,ret_val)
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
+SUBROUTINE getinl2d (targetname,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: targetname
   LOGICAL,DIMENSION(:,:) :: ret_val
 !-
@@ -624,7 +630,7 @@
 !---------------------------------------------------------------------
 !-
-! Do we have this target in our database ?
-!-
-  CALL get_findkey (1,target,pos)
+! Do we have this targetname in our database ?
+!-
+  CALL get_findkey (1,targetname,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -649,11 +655,11 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
+    CALL get_fil (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
+ &   (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,targetname,l_val=tmp_ret_val)
   ENDIF
 !-
@@ -670,12 +676,13 @@
 !=== Generic file/database INTERFACE
 !-
-SUBROUTINE get_fil (target,status,fileorig,i_val,r_val,c_val,l_val)
+SUBROUTINE get_fil (targetname,status,fileorig,nb_to_ret,i_val,r_val,c_val,l_val)
 !---------------------------------------------------------------------
 !- Subroutine that will extract from the file the values
-!- attributed to the keyword target
-!-
-!- (C) target    : target for which we will look in the file
+!- attributed to the keyword targetname
+!-
+!- (C) targetname    : target for which we will look in the file
 !- (I) status    : tells us from where we obtained the data
 !- (I) fileorig  : index of the file from which the key comes
+!- (I) nb_to_ret : size of output vector
 !- (I) i_val(:)  : INTEGER(nb_to_ret)   values
 !- (R) r_val(:)  : REAL(nb_to_ret)      values
@@ -685,6 +692,6 @@
   IMPLICIT NONE
 !-
-  CHARACTER(LEN=*) :: target
-  INTEGER,INTENT(OUT) :: status,fileorig
+  CHARACTER(LEN=*) :: targetname
+  INTEGER,INTENT(OUT) :: status,fileorig,nb_to_ret
   INTEGER,DIMENSION(:),OPTIONAL          :: i_val
   REAL,DIMENSION(:),OPTIONAL             :: r_val
@@ -692,5 +699,5 @@
   CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
 !-
-  INTEGER :: k_typ,nb_to_ret,it,pos,len_str,status_cnt,io_err
+  INTEGER :: k_typ,it,pos,len_str,status_cnt,io_err
   CHARACTER(LEN=n_d_fmt)  :: cnt
   CHARACTER(LEN=80) :: str_READ,str_READ_lower
@@ -702,21 +709,15 @@
   REAL    :: r_cmpval
   INTEGER :: ipos_tr,ipos_fl
+  LOGICAL :: l_dbg
+!---------------------------------------------------------------------
+  CALL ipsldbg (old_status=l_dbg)
 !---------------------------------------------------------------------
 !-
 ! Get the type of the argument
   CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
-  SELECT CASE (k_typ)
-  CASE(k_i)
-    nb_to_ret = SIZE(i_val)
-  CASE(k_r)
-    nb_to_ret = SIZE(r_val)
-  CASE(k_c)
-    nb_to_ret = SIZE(c_val)
-  CASE(k_l)
-    nb_to_ret = SIZE(l_val)
-  CASE DEFAULT
+  IF ( (k_typ.NE.k_i) .AND. (k_typ.NE.k_r) .AND. (k_typ.NE.k_c) .AND. (k_typ.NE.k_l) ) THEN
     CALL ipslerr (3,'get_fil', &
  &   'Internal error','Unknown type of data',' ')
-  END SELECT
+  ENDIF
 !-
 ! Read the file(s)
@@ -731,5 +732,5 @@
 !---
 !-- First try the target as it is
-    CALL get_findkey (2,target,pos)
+    CALL get_findkey (2,targetname,pos)
 !---
 !-- Another try
@@ -737,5 +738,5 @@
     IF (pos < 0) THEN
       WRITE(UNIT=cnt,FMT=c_i_fmt) it
-      CALL get_findkey (2,TRIM(target)//'__'//cnt,pos)
+      CALL get_findkey (2,TRIM(targetname)//'__'//cnt,pos)
     ENDIF
 !---
@@ -748,4 +749,9 @@
       found(it) = .TRUE.
       fileorig = fromfile(pos)
+      !
+      IF (l_dbg) THEN
+         WRITE(*,*) &
+              &      'getin_fil : read key ',targetname,' from file ',fileorig,' has type ',k_typ
+      ENDIF
 !-----
 !---- DECODE
@@ -754,4 +760,8 @@
       str_READ_lower = str_READ
       CALL strlowercase (str_READ_lower)
+      IF (l_dbg) THEN
+         WRITE(*,*) &
+              &      '            value    ',str_READ_lower
+      ENDIF
 !-----
       IF (    (TRIM(str_READ_lower) == 'def')     &
@@ -789,5 +799,5 @@
         IF (io_err /= 0) THEN
           CALL ipslerr (3,'get_fil', &
- &         'Target '//TRIM(target), &
+ &         'Target '//TRIM(targetname), &
  &         'is not of '//TRIM(c_vtyp)//' type',' ')
         ENDIF
@@ -801,5 +811,5 @@
           IF (compline(pos) /= nb_to_ret) THEN
             CALL ipslerr (2,'get_fil', &
- &           'For key '//TRIM(target)//' we have a compressed field', &
+ &           'For key '//TRIM(targetname)//' we have a compressed field', &
  &           'which does not have the right size.', &
  &           'We will try to fix that.')
@@ -837,6 +847,8 @@
 ! Now we set the status for what we found
   IF (def_beha) THEN
-    status = 2
-    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(target)
+    status = default
+    CALL ipslerr (1,'USING DEFAULT BEHAVIOUR FOR', &
+ &   TRIM(targetname),' ',' ')
+    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(targetname)
   ELSE
     status_cnt = 0
@@ -846,5 +858,5 @@
         IF      (status_cnt <= max_msgs) THEN
           WRITE (UNIT=*,FMT='(" USING DEFAULTS : ",A)', &
- &               ADVANCE='NO') TRIM(target)
+ &               ADVANCE='NO') TRIM(targetname)
           IF (nb_to_ret > 1) THEN
             WRITE (UNIT=*,FMT='("__")',ADVANCE='NO')
@@ -868,9 +880,9 @@
 !---
     IF (status_cnt == 0) THEN
-      status = 1
+      status = nondefault
     ELSE IF (status_cnt == nb_to_ret) THEN
-      status = 2
+      status = default
     ELSE
-      status = 3
+      status = vectornondefault
     ENDIF
   ENDIF
@@ -880,5 +892,5 @@
 END SUBROUTINE get_fil
 !===
-SUBROUTINE get_rdb (pos,size_of_in,target,i_val,r_val,c_val,l_val)
+SUBROUTINE get_rdb (pos,size_of_in,targetname,i_val,r_val,c_val,l_val)
 !---------------------------------------------------------------------
 !- Read the required variable in the database
@@ -887,5 +899,5 @@
 !-
   INTEGER :: pos,size_of_in
-  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*) :: targetname
   INTEGER,DIMENSION(:),OPTIONAL          :: i_val
   REAL,DIMENSION(:),OPTIONAL             :: r_val
@@ -907,5 +919,5 @@
   IF (key_tab(pos)%keytype /= k_typ) THEN
     CALL ipslerr (3,'get_rdb', &
- &   'Wrong data type for keyword '//TRIM(target), &
+ &   'Wrong data type for keyword '//TRIM(targetname), &
  &   '(NOT '//TRIM(c_vtyp)//')',' ')
   ENDIF
@@ -915,5 +927,5 @@
  &      .OR.(key_tab(pos)%keymemlen /= 1) ) THEN
       CALL ipslerr (3,'get_rdb', &
- &     'Wrong compression length','for keyword '//TRIM(target),' ')
+ &     'Wrong compression length','for keyword '//TRIM(targetname),' ')
     ELSE
       SELECT CASE (k_typ)
@@ -927,5 +939,5 @@
     IF (key_tab(pos)%keymemlen /= size_of_in) THEN
       CALL ipslerr (3,'get_rdb', &
- &     'Wrong array length','for keyword '//TRIM(target),' ')
+ &     'Wrong array length','for keyword '//TRIM(targetname),' ')
     ELSE
       k_beg = key_tab(pos)%keymemstart
@@ -947,5 +959,5 @@
 !===
 SUBROUTINE get_wdb &
- &  (target,status,fileorig,size_of_in, &
+ &  (targetname,status,fileorig,size_of_in, &
  &   i_val,r_val,c_val,l_val)
 !---------------------------------------------------------------------
@@ -954,5 +966,5 @@
   IMPLICIT NONE
 !-
-  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*) :: targetname
   INTEGER :: status,fileorig,size_of_in
   INTEGER,DIMENSION(:),OPTIONAL          :: i_val
@@ -965,4 +977,7 @@
   INTEGER :: k_mempos,k_memsize,k_beg,k_end
   LOGICAL :: l_cmp
+  LOGICAL :: l_dbg
+!---------------------------------------------------------------------
+  CALL ipsldbg (old_status=l_dbg)
 !---------------------------------------------------------------------
 !-
@@ -999,5 +1014,5 @@
 ! Fill out the items of the data base
   nb_keys = nb_keys+1
-  key_tab(nb_keys)%keystr = target(1:MIN(LEN_TRIM(target),l_n))
+  key_tab(nb_keys)%keystr = targetname(1:MIN(LEN_TRIM(targetname),l_n))
   key_tab(nb_keys)%keystatus = status
   key_tab(nb_keys)%keytype = k_typ
@@ -1011,4 +1026,14 @@
     key_tab(nb_keys)%keymemlen = size_of_in
   ENDIF
+  IF (l_dbg) THEN
+     WRITE(*,*) &
+ &     "get_wdb : nb_keys ",nb_keys," key_tab keystr   ",key_tab(nb_keys)%keystr,&
+ &                                       ",keystatus   ",key_tab(nb_keys)%keystatus,&
+ &                                       ",keytype     ",key_tab(nb_keys)%keytype,&
+ &                                       ",keycompress ",key_tab(nb_keys)%keycompress,&
+ &                                       ",keyfromfile ",key_tab(nb_keys)%keyfromfile,&
+ &                                       ",keymemstart ",key_tab(nb_keys)%keymemstart
+  ENDIF
+
 !-
 ! Before writing the actual size lets see if we have the space
@@ -1086,5 +1111,7 @@
 !-
   INTEGER :: eof,ptn,len_str,i,it,iund,io_err
-  LOGICAL :: check = .FALSE.
+  LOGICAL :: l_dbg
+!---------------------------------------------------------------------
+  CALL ipsldbg (old_status=l_dbg)
 !---------------------------------------------------------------------
   eof = 0
@@ -1092,5 +1119,5 @@
   nb_lastkey = 0
 !-
-  IF (check) THEN
+  IF (l_dbg) THEN
     WRITE(*,*) 'getin_readdef : Open file ',TRIM(filelist(current))
   ENDIF
@@ -1133,5 +1160,5 @@
       CALL cmpblank (NEW_str)
       NEW_str  = TRIM(ADJUSTL(NEW_str))
-      IF (check) THEN
+      IF (l_dbg) THEN
         WRITE(*,*) &
  &        '--> getin_readdef : ',TRIM(key_str),' :: ',TRIM(NEW_str)
@@ -1171,5 +1198,5 @@
 !---- If we have an empty line then the keyword finishes
       nb_lastkey = 0
-      IF (check) THEN
+      IF (l_dbg) THEN
         WRITE(*,*) 'getin_readdef : Have found an emtpy line '
       ENDIF
@@ -1179,5 +1206,5 @@
   CLOSE(UNIT=22)
 !-
-  IF (check) THEN
+  IF (l_dbg) THEN
     OPEN (UNIT=22,file=TRIM(def_file)//'.test')
     DO i=1,nb_lines
@@ -1186,4 +1213,13 @@
     CLOSE(UNIT=22)
   ENDIF
+!-
+  IF (l_dbg) THEN
+     WRITE(*,*) "nb_lines ",nb_lines,"nb_keys ",nb_keys
+     WRITE(*,*) "fichier ",fichier(1:nb_lines)
+     WRITE(*,*) "targetlist ",targetlist(1:nb_lines)
+     WRITE(*,*) "fromfile ",fromfile(1:nb_lines)
+     WRITE(*,*) "compline ",compline(1:nb_lines)
+    WRITE(*,*) '<-getin_readdef'
+  ENDIF
 !---------------------------
 END SUBROUTINE getin_readdef
@@ -1210,4 +1246,7 @@
   CHARACTER(LEN=n_d_fmt) :: cnt
   CHARACTER(LEN=10) :: c_fmt
+  LOGICAL :: l_dbg
+!---------------------------------------------------------------------
+  CALL ipsldbg (old_status=l_dbg)
 !---------------------------------------------------------------------
   len_str = LEN_TRIM(NEW_str)
@@ -1365,4 +1404,14 @@
 !-
   ENDIF
+
+  IF (l_dbg) THEN
+     WRITE(*,*) "getin_decrypt ->",TRIM(NEW_str), " : ", &
+          & TRIM(fichier(nb_lines)), &
+          & fromfile(nb_lines), &
+          & TRIM(filelist(fromfile(nb_lines)))
+     WRITE(*,*) "                compline : ",compline(nb_lines)
+     WRITE(*,*) "                targetlist : ",TRIM(targetlist(nb_lines))
+     WRITE(*,*) "                last_key : ",last_key
+  ENDIF
 !---------------------------
 END SUBROUTINE getin_decrypt
@@ -1402,4 +1451,6 @@
       WRITE(*,*) &
  &  'getin_checkcohe : We will keep only the last value'
+       CALL ipslerr (2,'getin_checkcohe','Found a problem on key ', &
+ &                     TRIM(targetlist(line)), fichier(line)//" "//fichier(k))
       targetlist(line) = ' '
     ENDIF
@@ -1778,7 +1829,11 @@
   CHARACTER(LEN=80) :: usedfileprefix
   INTEGER :: ikey,if,iff,iv
+  INTEGER :: ios
   CHARACTER(LEN=20) :: c_tmp
   CHARACTER(LEN=100) :: tmp_str,used_filename
-  LOGICAL :: check = .FALSE.
+  INTEGER :: io_err
+  LOGICAL :: l_dbg
+!---------------------------------------------------------------------
+  CALL ipsldbg (old_status=l_dbg)
 !---------------------------------------------------------------------
   IF (PRESENT(fileprefix)) THEN
@@ -1791,10 +1846,15 @@
 !---
     used_filename = TRIM(usedfileprefix)//'_'//TRIM(filelist(if))
-    IF (check) THEN
+    IF (l_dbg) THEN
       WRITE(*,*) &
- &      'GETIN_DUMP : opens file : ',TRIM(used_filename),' if = ',if
+ &      'getin_dump : opens file : ',TRIM(used_filename),' if = ',if
       WRITE(*,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys
     ENDIF
-    OPEN (UNIT=22,FILE=used_filename)
+    OPEN (UNIT=22,FILE=used_filename,iostat=io_err)
+    IF (io_err /= 0) THEN
+       CALL ipslerr (3,'getin_dump', &
+            &   'Could not open file :',TRIM(used_filename), &
+            &   '')
+    ENDIF
 !---
 !-- If this is the first file we need to add the list
@@ -1808,4 +1868,13 @@
       ENDDO
       WRITE(22,*) '# '
+      IF (l_dbg) THEN
+         WRITE(*,*) '# '
+         WRITE(*,*) '# This file is linked to the following files :'
+         WRITE(*,*) '# '
+         DO iff=2,nbfiles
+            WRITE(*,*) 'INCLUDEDEF = ',TRIM(filelist(iff))
+         ENDDO
+         WRITE(*,*) '# '
+      ENDIF
     ENDIF
 !---
@@ -1818,11 +1887,11 @@
         WRITE(22,*) '#'
         SELECT CASE (key_tab(ikey)%keystatus)
-        CASE(1)
+        CASE(nondefault)
           WRITE(22,*) '# Values of ', &
  &          TRIM(key_tab(ikey)%keystr),' comes from ',TRIM(def_file)
-        CASE(2)
+        CASE(default)
           WRITE(22,*) '# Values of ', &
  &          TRIM(key_tab(ikey)%keystr),' are all defaults.'
-        CASE(3)
+        CASE(vectornondefault)
           WRITE(22,*) '# Values of ', &
  &          TRIM(key_tab(ikey)%keystr), &
@@ -1833,4 +1902,10 @@
         END SELECT
         WRITE(22,*) '#'
+        !-
+        IF (l_dbg) THEN
+           WRITE(*,*) '#'
+           WRITE(*,*) '# Status of key ', ikey, ' : ',&
+ &          TRIM(key_tab(ikey)%keystr),key_tab(ikey)%keystatus
+        ENDIF
 !-------
 !------ Write the values
