Index: IOIPSL/trunk/src/getincom.f90
===================================================================
--- IOIPSL/trunk/src/getincom.f90	(revision 122)
+++ IOIPSL/trunk/src/getincom.f90	(revision 125)
@@ -5,5 +5,5 @@
 USE errioipsl, ONLY : ipslerr
 USE stringop, &
- &   ONLY : nocomma,cmpblank,strlowercase,gensig,find_sig
+ &   ONLY : nocomma,cmpblank,strlowercase
 !-
 IMPLICIT NONE
@@ -13,4 +13,21 @@
 !-
 INTERFACE getin
+!!--------------------------------------------------------------------
+!! The "getin" routines get a variable.
+!! We first check if we find it in the database
+!! and if not we get it from the run.def file.
+!!
+!! SUBROUTINE getin (target,ret_val)
+!!
+!! INPUT
+!!
+!! (C) target : Name of the variable
+!!
+!! OUTPUT
+!!
+!! (I/R/C/L) ret_val : scalar, vector or matrix that will contain
+!!                     that will contain the (standard)
+!!                     integer/real/character/logical values
+!!--------------------------------------------------------------------
   MODULE PROCEDURE getinrs, getinr1d, getinr2d, &
  &                 getinis, getini1d, getini2d, &
@@ -19,4 +36,18 @@
 END INTERFACE
 !-
+!!--------------------------------------------------------------------
+!! The "getin_dump" routine will dump the content of the database
+!! into a file which has the same format as the run.def file.
+!! The idea is that the user can see which parameters were used
+!! and re-use the file for another run.
+!!
+!!  SUBROUTINE getin_dump (fileprefix)
+!!
+!! OPTIONAL INPUT argument
+!!
+!! (C) fileprefix : allows the user to change the name of the file
+!!                  in which the data will be archived
+!!--------------------------------------------------------------------
+!-
   INTEGER,PARAMETER :: max_files=100
   CHARACTER(LEN=100),DIMENSION(max_files),SAVE :: filelist
@@ -26,6 +57,6 @@
   INTEGER,SAVE :: nb_lines
   CHARACTER(LEN=100),DIMENSION(max_lines),SAVE :: fichier
-  INTEGER,DIMENSION(max_lines),SAVE :: targetsiglist,fromfile,compline
-  CHARACTER(LEN=l_n),DIMENSION(max_lines),SAVE  :: targetlist
+  INTEGER,DIMENSION(max_lines),SAVE :: fromfile,compline
+  CHARACTER(LEN=l_n),DIMENSION(max_lines),SAVE :: targetlist
 !-
   INTEGER,PARAMETER :: n_d_fmt=5,max_msgs=15
@@ -39,6 +70,7 @@
   INTEGER,SAVE :: nb_keys=0
   INTEGER,SAVE :: keymemsize=0
-  INTEGER,SAVE,ALLOCATABLE :: keysig(:)
-  CHARACTER(LEN=l_n),SAVE,ALLOCATABLE :: keystr(:)
+!-
+! keystr definition
+! name of a key
 !-
 ! keystatus definition
@@ -46,6 +78,4 @@
 ! keystatus = 2 : Default value is used
 ! keystatus = 3 : Some vector elements were taken from default
-!-
-  INTEGER,SAVE,ALLOCATABLE :: keystatus(:)
 !-
 ! keytype definition
@@ -57,15 +87,15 @@
   INTEGER,PARAMETER :: k_i=1, k_r=2, k_c=3, k_l=4
 !-
-  INTEGER,SAVE,ALLOCATABLE :: keytype(:)
-!-
 ! Allow compression for keys (only for integer and real)
-! keycompress < 0 : not compresses
+! keycompress < 0 : not compressed
 ! keycompress > 0 : number of repeat of the value
 !-
-  INTEGER,SAVE,ALLOCATABLE :: keycompress(:)
-  INTEGER,SAVE,ALLOCATABLE :: keyfromfile(:)
-!-
-  INTEGER,SAVE,ALLOCATABLE :: keymemstart(:)
-  INTEGER,SAVE,ALLOCATABLE :: keymemlen(:)
+TYPE :: t_key
+  CHARACTER(LEN=l_n) :: keystr
+  INTEGER :: keystatus, keytype, keycompress, &
+ &           keyfromfile, keymemstart, keymemlen
+END TYPE t_key
+!-
+  TYPE(t_key),SAVE,ALLOCATABLE,DIMENSION(:) :: key_tab
 !-
   INTEGER,SAVE,ALLOCATABLE :: i_mem(:)
@@ -84,9 +114,4 @@
 SUBROUTINE getinis (target,ret_val)
 !---------------------------------------------------------------------
-!- Get a interer scalar. We first check if we find it
-!- in the database and if not we get it from the run.def
-!-
-!- getini1d and getini2d are written on the same pattern
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -95,14 +120,10 @@
 !-
   INTEGER,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig,pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   tmp_ret_val(1) = ret_val
@@ -113,5 +134,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,1,i_val=tmp_ret_val)
+ &   (target,status,fileorig,1,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -124,6 +145,4 @@
 SUBROUTINE getini1d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getinis for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -133,14 +152,10 @@
   INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -159,5 +174,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,i_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -170,6 +185,4 @@
 SUBROUTINE getini2d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getinis for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -179,15 +192,11 @@
   INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
   INTEGER :: jl,jj,ji
 !---------------------------------------------------------------------
 !-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
-!-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -215,5 +224,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,i_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -235,9 +244,4 @@
 SUBROUTINE getinrs (target,ret_val)
 !---------------------------------------------------------------------
-!-  Get a real scalar. We first check if we find it
-!-  in the database and if not we get it from the run.def
-!-
-!-  getinr1d and getinr2d are written on the same pattern
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -246,14 +250,10 @@
 !-
   REAL,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig,pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   tmp_ret_val(1) = ret_val
@@ -264,5 +264,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,1,r_val=tmp_ret_val)
+ &   (target,status,fileorig,1,r_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -275,6 +275,4 @@
 SUBROUTINE getinr1d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getinrs for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -284,14 +282,10 @@
   REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -310,5 +304,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,r_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -321,6 +315,4 @@
 SUBROUTINE getinr2d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getinrs for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -330,15 +322,11 @@
   REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
   INTEGER :: jl,jj,ji
 !---------------------------------------------------------------------
 !-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
-!-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -366,5 +354,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,r_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -386,9 +374,4 @@
 SUBROUTINE getincs (target,ret_val)
 !---------------------------------------------------------------------
-!- Get a CHARACTER scalar. We first check if we find it
-!- in the database and if not we get it from the run.def
-!-
-!- getinc1d and getinc2d are written on the same pattern
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -397,14 +380,10 @@
 !-
   CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig,pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   tmp_ret_val(1) = ret_val
@@ -415,5 +394,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,1,c_val=tmp_ret_val)
+ &   (target,status,fileorig,1,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -426,6 +405,4 @@
 SUBROUTINE getinc1d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getincs for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -435,14 +412,10 @@
   CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -461,5 +434,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,c_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -472,6 +445,4 @@
 SUBROUTINE getinc2d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getincs for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -481,15 +452,11 @@
   CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
   INTEGER :: jl,jj,ji
 !---------------------------------------------------------------------
 !-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
-!-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -517,5 +484,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,c_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -537,9 +504,4 @@
 SUBROUTINE getinls (target,ret_val)
 !---------------------------------------------------------------------
-!- Get a logical scalar. We first check if we find it
-!- in the database and if not we get it from the run.def
-!-
-!- getinl1d and getinl2d are written on the same pattern
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -548,14 +510,10 @@
 !-
   LOGICAL,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig,pos,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   tmp_ret_val(1) = ret_val
@@ -566,5 +524,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,1,l_val=tmp_ret_val)
+ &   (target,status,fileorig,1,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -577,6 +535,4 @@
 SUBROUTINE getinl1d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getinls for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -586,14 +542,10 @@
   LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
-!---------------------------------------------------------------------
-!-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
 !-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -612,5 +564,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,l_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -623,6 +575,4 @@
 SUBROUTINE getinl2d (target,ret_val)
 !---------------------------------------------------------------------
-!- See getinls for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
   IMPLICIT NONE
 !-
@@ -632,15 +582,11 @@
   LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig,pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
   INTEGER :: jl,jj,ji
 !---------------------------------------------------------------------
 !-
-! Compute the signature of the target
-!-
-  CALL gensig (target,target_sig)
-!-
 ! Do we have this target in our database ?
 !-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+  CALL get_findkey (1,target,pos)
 !-
   size_of_in = SIZE(ret_val)
@@ -668,5 +614,5 @@
 !-- Put the data into the database
     CALL get_wdb &
- &   (target,target_sig,status,fileorig,size_of_in,l_val=tmp_ret_val)
+ &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
@@ -710,8 +656,6 @@
   INTEGER :: k_typ,nb_to_ret,it,pos,len_str,status_cnt,io_err
   CHARACTER(LEN=n_d_fmt)  :: cnt
-  CHARACTER(LEN=37) :: full_target
   CHARACTER(LEN=80) :: str_READ,str_READ_lower
   CHARACTER(LEN=9)  :: c_vtyp
-  INTEGER :: full_target_sig
   LOGICAL,DIMENSION(:),ALLOCATABLE :: found
   LOGICAL :: def_beha,compressed
@@ -749,8 +693,5 @@
 !---
 !-- First try the target as it is
-    full_target = target
-    CALL gensig (full_target,full_target_sig)
-    CALL find_sig (nb_lines,targetlist,full_target, &
- &                 targetsiglist,full_target_sig,pos)
+    CALL get_findkey (2,target,pos)
 !---
 !-- Another try
@@ -758,8 +699,5 @@
     IF (pos < 0) THEN
       WRITE(UNIT=cnt,FMT=c_i_fmt) it
-      full_target = TRIM(target)//'__'//cnt
-      CALL gensig (full_target,full_target_sig)
-      CALL find_sig (nb_lines,targetlist,full_target, &
- &                   targetsiglist,full_target_sig,pos)
+      CALL get_findkey (2,TRIM(target)//'__'//cnt,pos)
     ENDIF
 !---
@@ -818,6 +756,4 @@
       ENDIF
 !-----
-      targetsiglist(pos) = -1
-!-----
       IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
 !-------
@@ -919,5 +855,5 @@
   CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
 !-
-  INTEGER :: k_typ
+  INTEGER :: k_typ,k_beg,k_end
   CHARACTER(LEN=9) :: c_vtyp
 !---------------------------------------------------------------------
@@ -931,5 +867,5 @@
   ENDIF
 !-
-  IF (keytype(pos) /= k_typ) THEN
+  IF (key_tab(pos)%keytype /= k_typ) THEN
     CALL ipslerr (3,'get_rdb', &
  &   'Wrong data type for keyword '//TRIM(target), &
@@ -937,7 +873,7 @@
   ENDIF
 !-
-  IF (keycompress(pos) > 0) THEN
-    IF (    (keycompress(pos) /= size_of_in) &
- &      .OR.(keymemlen(pos) /= 1) ) THEN
+  IF (key_tab(pos)%keycompress > 0) THEN
+    IF (    (key_tab(pos)%keycompress /= size_of_in) &
+ &      .OR.(key_tab(pos)%keymemlen /= 1) ) THEN
       CALL ipslerr (3,'get_rdb', &
  &     'Wrong compression length','for keyword '//TRIM(target),' ')
@@ -945,27 +881,25 @@
       SELECT CASE (k_typ)
       CASE(k_i)
-        i_val(1:size_of_in) = i_mem(keymemstart(pos))
+        i_val(1:size_of_in) = i_mem(key_tab(pos)%keymemstart)
       CASE(k_r)
-        r_val(1:size_of_in) = r_mem(keymemstart(pos))
+        r_val(1:size_of_in) = r_mem(key_tab(pos)%keymemstart)
       END SELECT
     ENDIF
   ELSE
-    IF (keymemlen(pos) /= size_of_in) THEN
+    IF (key_tab(pos)%keymemlen /= size_of_in) THEN
       CALL ipslerr (3,'get_rdb', &
  &     'Wrong array length','for keyword '//TRIM(target),' ')
     ELSE
+      k_beg = key_tab(pos)%keymemstart
+      k_end = k_beg+key_tab(pos)%keymemlen-1
       SELECT CASE (k_typ)
       CASE(k_i)
-        i_val(1:size_of_in) = &
- &        i_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+        i_val(1:size_of_in) = i_mem(k_beg:k_end)
       CASE(k_r)
-        r_val(1:size_of_in) = &
- &        r_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+        r_val(1:size_of_in) = r_mem(k_beg:k_end)
       CASE(k_c)
-        c_val(1:size_of_in) = &
- &        c_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+        c_val(1:size_of_in) = c_mem(k_beg:k_end)
       CASE(k_l)
-        l_val(1:size_of_in) = &
- &        l_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+        l_val(1:size_of_in) = l_mem(k_beg:k_end)
       END SELECT
     ENDIF
@@ -975,5 +909,5 @@
 !===
 SUBROUTINE get_wdb &
- &  (target,target_sig,status,fileorig,size_of_in, &
+ &  (target,status,fileorig,size_of_in, &
  &   i_val,r_val,c_val,l_val)
 !---------------------------------------------------------------------
@@ -983,5 +917,5 @@
 !-
   CHARACTER(LEN=*) :: target
-  INTEGER :: target_sig,status,fileorig,size_of_in
+  INTEGER :: status,fileorig,size_of_in
   INTEGER,DIMENSION(:),OPTIONAL          :: i_val
   REAL,DIMENSION(:),OPTIONAL             :: r_val
@@ -991,5 +925,5 @@
   INTEGER :: k_typ
   CHARACTER(LEN=9) :: c_vtyp
-  INTEGER :: k_mempos,k_memsize,k_len
+  INTEGER :: k_mempos,k_memsize,k_beg,k_end
   LOGICAL :: l_cmp
 !---------------------------------------------------------------------
@@ -1027,37 +961,38 @@
 ! Fill out the items of the data base
   nb_keys = nb_keys+1
-  keysig(nb_keys) = target_sig
-  keystr(nb_keys) = target(1:MIN(LEN_TRIM(target),l_n))
-  keystatus(nb_keys) = status
-  keytype(nb_keys) = k_typ
-  keyfromfile(nb_keys) = fileorig
-  keymemstart(nb_keys) = k_mempos+1
+  key_tab(nb_keys)%keystr = target(1:MIN(LEN_TRIM(target),l_n))
+  key_tab(nb_keys)%keystatus = status
+  key_tab(nb_keys)%keytype = k_typ
+  key_tab(nb_keys)%keyfromfile = fileorig
+  key_tab(nb_keys)%keymemstart = k_mempos+1
   IF (l_cmp) THEN
-    keycompress(nb_keys) = size_of_in
-    keymemlen(nb_keys) = 1
+    key_tab(nb_keys)%keycompress = size_of_in
+    key_tab(nb_keys)%keymemlen = 1
   ELSE
-    keycompress(nb_keys) = -1
-    keymemlen(nb_keys) = size_of_in
+    key_tab(nb_keys)%keycompress = -1
+    key_tab(nb_keys)%keymemlen = size_of_in
   ENDIF
 !-
 ! Before writing the actual size lets see if we have the space
-  IF (keymemstart(nb_keys)+keymemlen(nb_keys) > k_memsize) THEN
-    CALL getin_allocmem (k_typ,keymemlen(nb_keys))
-  ENDIF
-!-
-  k_len = keymemstart(nb_keys)+keymemlen(nb_keys)-1
+  IF (key_tab(nb_keys)%keymemstart+key_tab(nb_keys)%keymemlen &
+ &    > k_memsize) THEN
+    CALL getin_allocmem (k_typ,key_tab(nb_keys)%keymemlen)
+  ENDIF
+!-
+  k_beg = key_tab(nb_keys)%keymemstart
+  k_end = k_beg+key_tab(nb_keys)%keymemlen-1
   SELECT CASE (k_typ)
   CASE(k_i)
-    i_mem(keymemstart(nb_keys):k_len) = i_val(1:keymemlen(nb_keys))
-    i_mempos = k_len
+    i_mem(k_beg:k_end) = i_val(1:key_tab(nb_keys)%keymemlen)
+    i_mempos = k_end
   CASE(k_r)
-    r_mem(keymemstart(nb_keys):k_len) = r_val(1:keymemlen(nb_keys))
-    r_mempos = k_len
+    r_mem(k_beg:k_end) = r_val(1:key_tab(nb_keys)%keymemlen)
+    r_mempos = k_end
   CASE(k_c)
-    c_mem(keymemstart(nb_keys):k_len) = c_val(1:keymemlen(nb_keys))
-    c_mempos = k_len
+    c_mem(k_beg:k_end) = c_val(1:key_tab(nb_keys)%keymemlen)
+    c_mempos = k_end
   CASE(k_l)
-    l_mem(keymemstart(nb_keys):k_len) = l_val(1:keymemlen(nb_keys))
-    l_mempos = k_len
+    l_mem(k_beg:k_end) = l_val(1:key_tab(nb_keys)%keymemlen)
+    l_mempos = k_end
   END SELECT
 !---------------------
@@ -1190,5 +1125,4 @@
           targetlist(nb_lines) = &
  &         last_key(1:MIN(LEN_TRIM(last_key),l_n-n_d_fmt-2))//'__'//cnt
-          CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))
           key_str = last_key(1:LEN_TRIM(last_key))
         ENDIF
@@ -1340,5 +1274,4 @@
       ENDIF
 !-----
-      CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))
       fichier(nb_lines) = NEW_str(1:len_str)
       fromfile(nb_lines) = current
@@ -1369,5 +1302,4 @@
  &       key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
         targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n))
-        CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))
         fromfile(nb_lines) = current
 !-
@@ -1393,5 +1325,4 @@
  &      key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
       targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n))
-      CALL gensig (targetlist(nb_lines),targetsiglist(nb_lines))
       fromfile(nb_lines) = current
 !-
@@ -1414,32 +1345,31 @@
   IMPLICIT NONE
 !-
-  INTEGER :: line,found
+  INTEGER :: line,n_k,k
 !---------------------------------------------------------------------
   DO line=1,nb_lines-1
 !-
-    CALL find_sig &
- &    (nb_lines-line,targetlist(line+1:nb_lines),targetlist(line), &
- &     targetsiglist(line+1:nb_lines),targetsiglist(line),found)
+    n_k = 0
+    DO k=line+1,nb_lines
+      IF (TRIM(targetlist(line)) == TRIM(targetlist(k))) THEN
+        n_k = k
+        EXIT
+      ENDIF
+    ENDDO
 !---
 !-- IF we have found it we have a problem to solve.
 !---
-    IF (found > 0) THEN
-      WRITE(*,*) 'COUNT : ', &
- &  COUNT(ABS(targetsiglist(line+1:nb_lines)-targetsiglist(line)) < 1)
-!-----
+    IF (n_k > 0) THEN
+      WRITE(*,*) 'COUNT : ',n_k
       WRITE(*,*) &
- & 'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line))
+ &  'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line))
       WRITE(*,*) &
- & 'getin_checkcohe : The following values were encoutered :'
+ &  'getin_checkcohe : The following values were encoutered :'
       WRITE(*,*) &
- & '                ',TRIM(targetlist(line)), &
- &               targetsiglist(line),' == ',fichier(line)
+ &  '                ',TRIM(targetlist(line)),' == ',fichier(line)
       WRITE(*,*) &
- & '                ',TRIM(targetlist(line+found)), &
- &               targetsiglist(line+found),' == ',fichier(line+found)
+ &  '                ',TRIM(targetlist(k)),' == ',fichier(k)
       WRITE(*,*) &
- & 'getin_checkcohe : We will keep only the last value'
-!-----
-      targetsiglist(line) = 1
+ &  'getin_checkcohe : We will keep only the last value'
+      targetlist(line) = ' '
     ENDIF
   ENDDO
@@ -1488,4 +1418,5 @@
   IMPLICIT NONE
 !-
+  TYPE(t_key),ALLOCATABLE,DIMENSION(:) :: tmp_key_tab
   INTEGER,ALLOCATABLE :: tmp_int(:)
   CHARACTER(LEN=100),ALLOCATABLE :: tmp_str(:)
@@ -1494,179 +1425,44 @@
   CHARACTER(LEN=20) :: c_tmp
 !---------------------------------------------------------------------
-!-
-! Either nothing exists in these arrays and it is easy to do
-!-
   IF (keymemsize == 0) THEN
 !---
+!-- Nothing exists in memory arrays and it is easy to do.
+!---
     WRITE (UNIT=c_tmp,FMT=*) memslabs
-!---
-    ALLOCATE(keysig(memslabs),stat=ier)
+    ALLOCATE(key_tab(memslabs),stat=ier)
     IF (ier /= 0) THEN
       CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keysig', &
+ &     'Can not allocate key_tab', &
  &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
     ENDIF
-!---
-    ALLOCATE(keystr(memslabs),stat=ier)
+    nb_keys = 0
+    keymemsize = memslabs
+    key_tab(:)%keycompress = -1
+!---
+  ELSE
+!---
+!-- There is something already in the memory,
+!-- we need to transfer and reallocate.
+!---
+    WRITE (UNIT=c_tmp,FMT=*) keymemsize
+    ALLOCATE(tmp_key_tab(keymemsize),stat=ier)
     IF (ier /= 0) THEN
       CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keystr', &
+ &     'Can not allocate tmp_key_tab', &
  &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
     ENDIF
-!---
-    ALLOCATE(keystatus(memslabs),stat=ier)
+    WRITE (UNIT=c_tmp,FMT=*) keymemsize+memslabs
+    tmp_key_tab(1:keymemsize) = key_tab(1:keymemsize)
+    DEALLOCATE(key_tab)
+    ALLOCATE(key_tab(keymemsize+memslabs),stat=ier)
     IF (ier /= 0) THEN
       CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keystatus', &
+ &     'Can not allocate key_tab', &
  &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
     ENDIF
-!---
-    ALLOCATE(keytype(memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keytype', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    ALLOCATE(keycompress(memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keycompress', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    ALLOCATE(keyfromfile(memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keyfromfile', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    ALLOCATE(keymemstart(memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keymemstart', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    ALLOCATE(keymemlen(memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keymemlen', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    nb_keys = 0
-    keymemsize = memslabs
-    keycompress(:) = -1
-!---
-  ELSE
-!---
-!-- There is something already in the memory,
-!-- we need to transfer and reallocate.
-!---
-    WRITE (UNIT=c_tmp,FMT=*) keymemsize
-!---
-    ALLOCATE(tmp_str(keymemsize),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate tmp_str', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    ALLOCATE(tmp_int(keymemsize),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate tmp_int', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-!---
-    WRITE (UNIT=c_tmp,FMT=*) keymemsize+memslabs
-!---
-    tmp_int(1:keymemsize) = keysig(1:keymemsize)
-    DEALLOCATE(keysig)
-    ALLOCATE(keysig(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keysig', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keysig(1:keymemsize) = tmp_int(1:keymemsize)
-!---
-    tmp_str(1:keymemsize) = keystr(1:keymemsize)
-    DEALLOCATE(keystr)
-    ALLOCATE(keystr(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keystr', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keystr(1:keymemsize) = tmp_str(1:keymemsize)
-!---
-    tmp_int(1:keymemsize) = keystatus(1:keymemsize)
-    DEALLOCATE(keystatus)
-    ALLOCATE(keystatus(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keystatus', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keystatus(1:keymemsize) = tmp_int(1:keymemsize)
-!---
-    tmp_int(1:keymemsize) = keytype(1:keymemsize)
-    DEALLOCATE(keytype)
-    ALLOCATE(keytype(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keytype', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keytype(1:keymemsize) = tmp_int(1:keymemsize)
-!---
-    tmp_int(1:keymemsize) = keycompress(1:keymemsize)
-    DEALLOCATE(keycompress)
-    ALLOCATE(keycompress(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keycompress', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keycompress(:) = -1
-    keycompress(1:keymemsize) = tmp_int(1:keymemsize)
-!---
-    tmp_int(1:keymemsize) = keyfromfile(1:keymemsize)
-    DEALLOCATE(keyfromfile)
-    ALLOCATE(keyfromfile(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keyfromfile', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keyfromfile(1:keymemsize) = tmp_int(1:keymemsize)
-!---
-    tmp_int(1:keymemsize) = keymemstart(1:keymemsize)
-    DEALLOCATE(keymemstart)
-    ALLOCATE(keymemstart(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keymemstart', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keymemstart(1:keymemsize) = tmp_int(1:keymemsize)
-!---
-    tmp_int(1:keymemsize) = keymemlen(1:keymemsize)
-    DEALLOCATE(keymemlen)
-    ALLOCATE(keymemlen(keymemsize+memslabs),stat=ier)
-    IF (ier /= 0) THEN
-      CALL ipslerr (3,'getin_allockeys', &
- &     'Can not allocate keymemlen', &
- &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
-    ENDIF
-    keymemlen(1:keymemsize) = tmp_int(1:keymemsize)
-!---
+    key_tab(:)%keycompress = -1
+    key_tab(1:keymemsize) = tmp_key_tab(1:keymemsize)
+    DEALLOCATE(tmp_key_tab)
     keymemsize = keymemsize+memslabs
-!---
-    DEALLOCATE(tmp_int)
-    DEALLOCATE(tmp_str)
   ENDIF
 !-----------------------------
@@ -1678,5 +1474,5 @@
 !---------------------------------------------------------------------
 !- Allocate the memory of the data base for all 4 types of memory
-!- INTEGER / REAL / CHAR / LOGICAL
+!- INTEGER / REAL / CHARACTER / LOGICAL
 !---------------------------------------------------------------------
   IMPLICIT NONE
@@ -1685,6 +1481,6 @@
 !-
   INTEGER,ALLOCATABLE :: tmp_int(:)
+  REAL,ALLOCATABLE :: tmp_real(:)
   CHARACTER(LEN=100),ALLOCATABLE :: tmp_char(:)
-  REAL,ALLOCATABLE :: tmp_real(:)
   LOGICAL,ALLOCATABLE :: tmp_logic(:)
   INTEGER :: ier
@@ -1825,12 +1621,4 @@
 !-
 SUBROUTINE getin_dump (fileprefix)
-!---------------------------------------------------------------------
-!- This subroutine will dump the content of the database into  file
-!- which has the same format as the run.def. The idea is that the user
-!- can see which parameters were used and re-use the file for another
-!- run.
-!-
-!- The argument file allows the user to change the name of the file
-!- in which the data will be archived
 !---------------------------------------------------------------------
   IMPLICIT NONE
@@ -1875,90 +1663,98 @@
 !-----
 !---- Is this key from this file ?
-      IF (keyfromfile(ikey) == if) THEN
+      IF (key_tab(ikey)%keyfromfile == if) THEN
 !-------
 !------ Write some comments
         WRITE(22,*) '#'
-        SELECT CASE (keystatus(ikey))
+        SELECT CASE (key_tab(ikey)%keystatus)
         CASE(1)
           WRITE(22,*) '# Values of ', &
- &          TRIM(keystr(ikey)),' comes from the run.def.'
+ &          TRIM(key_tab(ikey)%keystr),' comes from the run.def.'
         CASE(2)
           WRITE(22,*) '# Values of ', &
- &          TRIM(keystr(ikey)),' are all defaults.'
+ &          TRIM(key_tab(ikey)%keystr),' are all defaults.'
         CASE(3)
           WRITE(22,*) '# Values of ', &
- &          TRIM(keystr(ikey)),' are a mix of run.def and defaults.'
+ &          TRIM(key_tab(ikey)%keystr), &
+ &          ' are a mix of run.def and defaults.'
         CASE DEFAULT
           WRITE(22,*) '# Dont know from where the value of ', &
- &          TRIM(keystr(ikey)),' comes.'
+ &          TRIM(key_tab(ikey)%keystr),' comes.'
         END SELECT
         WRITE(22,*) '#'
 !-------
 !------ Write the values
-        SELECT CASE (keytype(ikey))
+        SELECT CASE (key_tab(ikey)%keytype)
         CASE(k_i)
-          IF (keymemlen(ikey) == 1) THEN
-            IF (keycompress(ikey) < 0) THEN
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            IF (key_tab(ikey)%keycompress < 0) THEN
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),' = ',i_mem(keymemstart(ikey))
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',i_mem(key_tab(ikey)%keymemstart)
             ELSE
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),' = ',keycompress(ikey), &
- &              ' * ',i_mem(keymemstart(ikey))
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',key_tab(ikey)%keycompress, &
+ &              ' * ',i_mem(key_tab(ikey)%keymemstart)
             ENDIF
           ELSE
-            DO iv=0,keymemlen(ikey)-1
+            DO iv=0,key_tab(ikey)%keymemlen-1
               WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),'__',TRIM(ADJUSTL(c_tmp)), &
- &              ' = ',i_mem(keymemstart(ikey)+iv)
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              '__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',i_mem(key_tab(ikey)%keymemstart+iv)
             ENDDO
           ENDIF
         CASE(k_r)
-          IF (keymemlen(ikey) == 1) THEN
-            IF (keycompress(ikey) < 0) THEN
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            IF (key_tab(ikey)%keycompress < 0) THEN
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),' = ',r_mem(keymemstart(ikey))
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',r_mem(key_tab(ikey)%keymemstart)
             ELSE
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),' = ',keycompress(ikey),&
-                   & ' * ',r_mem(keymemstart(ikey))
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',key_tab(ikey)%keycompress, &
+                   & ' * ',r_mem(key_tab(ikey)%keymemstart)
             ENDIF
           ELSE
-            DO iv=0,keymemlen(ikey)-1
+            DO iv=0,key_tab(ikey)%keymemlen-1
               WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),'__',TRIM(ADJUSTL(c_tmp)), &
- &              ' = ',r_mem(keymemstart(ikey)+iv)
+ &              TRIM(key_tab(ikey)%keystr),'__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',r_mem(key_tab(ikey)%keymemstart+iv)
             ENDDO
           ENDIF
         CASE(k_c)
-          IF (keymemlen(ikey) == 1) THEN
-            tmp_str = c_mem(keymemstart(ikey))
-            WRITE(22,*) TRIM(keystr(ikey)),' = ',TRIM(tmp_str)
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            tmp_str = c_mem(key_tab(ikey)%keymemstart)
+            WRITE(22,*) TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',TRIM(tmp_str)
           ELSE
-            DO iv=0,keymemlen(ikey)-1
+            DO iv=0,key_tab(ikey)%keymemlen-1
               WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
-              tmp_str = c_mem(keymemstart(ikey)+iv)
+              tmp_str = c_mem(key_tab(ikey)%keymemstart+iv)
               WRITE(22,*) &
- &              TRIM(keystr(ikey)),'__',TRIM(ADJUSTL(c_tmp)), &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              '__',TRIM(ADJUSTL(c_tmp)), &
  &              ' = ',TRIM(tmp_str)
             ENDDO
           ENDIF
         CASE(k_l)
-          IF (keymemlen(ikey) == 1) THEN
-            IF (l_mem(keymemstart(ikey))) THEN
-              WRITE(22,*) TRIM(keystr(ikey)),' = TRUE '
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            IF (l_mem(key_tab(ikey)%keymemstart)) THEN
+              WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = TRUE '
             ELSE
-              WRITE(22,*) TRIM(keystr(ikey)),' = FALSE '
+              WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = FALSE '
             ENDIF
           ELSE
-            DO iv=0,keymemlen(ikey)-1
+            DO iv=0,key_tab(ikey)%keymemlen-1
               WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
-              IF (l_mem(keymemstart(ikey)+iv)) THEN
-                WRITE(22,*) TRIM(keystr(ikey)),'__', &
+              IF (l_mem(key_tab(ikey)%keymemstart+iv)) THEN
+                WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', &
  &                          TRIM(ADJUSTL(c_tmp)),' = TRUE '
               ELSE
-                WRITE(22,*) TRIM(keystr(ikey)),'__', &
+                WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', &
  &                          TRIM(ADJUSTL(c_tmp)),' = FALSE '
               ENDIF
@@ -1967,5 +1763,6 @@
         CASE DEFAULT
           CALL ipslerr (3,'getin_dump', &
- &         'Unknown type for variable '//TRIM(keystr(ikey)),' ',' ')
+ &         'Unknown type for variable '//TRIM(key_tab(ikey)%keystr), &
+ &         ' ',' ')
         END SELECT
       ENDIF
@@ -2014,4 +1811,48 @@
 END SUBROUTINE get_qtyp
 !===
+SUBROUTINE get_findkey (i_tab,c_key,pos)
+!---------------------------------------------------------------------
+!- This subroutine looks for a key in a table
+!---------------------------------------------------------------------
+!- INPUT
+!-   i_tab  : 1 -> search in key_tab(1:nb_keys)%keystr
+!-            2 -> search in targetlist(1:nb_lines)
+!-   c_key  : Name of the key we are looking for
+!- OUTPUT
+!-   pos    : -1 if key not found, else value in the table
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(in) :: i_tab
+  CHARACTER(LEN=*),INTENT(in) :: c_key
+  INTEGER,INTENT(out) :: pos
+!-
+  INTEGER :: ikey_max,ikey
+  CHARACTER(LEN=l_n) :: c_q_key
+!---------------------------------------------------------------------
+  pos = -1
+  IF     (i_tab == 1) THEN
+    ikey_max = nb_keys
+  ELSEIF (i_tab == 2) THEN
+    ikey_max = nb_lines
+  ELSE
+    ikey_max = 0
+  ENDIF
+  IF ( ikey_max > 0 ) THEN
+    DO ikey=1,ikey_max
+      IF (i_tab == 1) THEN
+        c_q_key = key_tab(ikey)%keystr
+      ELSE
+        c_q_key = targetlist(ikey)
+      ENDIF
+      IF (TRIM(c_q_key) == TRIM(c_key)) THEN
+        pos = ikey
+        EXIT
+      ENDIF
+    ENDDO
+  ENDIF
+!-------------------------
+END SUBROUTINE get_findkey
+!===
 !------------------
 END MODULE getincom
