Index: IOIPSL/trunk/src/AA_make
===================================================================
--- IOIPSL/trunk/src/AA_make	(revision 10)
+++ IOIPSL/trunk/src/AA_make	(revision 11)
@@ -1,6 +1,15 @@
 #-
-#- $Id: AA_make,v 2.16 2006/01/18 06:34:11 adm Exp $
+#- $Id$
 #-
-#-Q- sx6nec F_O = $(F_D) $(F_P) -C vsafe -size_t64 -I $(MODDIR)
+MAKE_NAM = $(MAKE)
+ifneq ($(MAKE_NAM),$(M_K))
+ @$(error You must invoke this Makefile with the $(M_K) command)
+endif
+USER_DIR = $(shell pwd)
+MAKE_DIR = '??'
+ifneq ($(USER_DIR),$(MAKE_DIR))
+ @$(error You must invoke this Makefile from its directory)
+endif
+#-
 #-Q- sxdkrz F_O = $(F_D) $(F_P) -C vsafe -size_t64 -I $(MODDIR)
 #-Q- eshpux F_O = $(F_D) $(F_P) -C vsafe -I $(MODDIR)
@@ -9,30 +18,21 @@
 #---------------------------------------------------------------------
 
-PRF_PRC = !\#-P-
-DEF_PRC = $(PRF_PRC)$(D_P)
-SRC_PRC   = defprec.f90
-MODS1     = $(SRC_PRC)    \
-            errioipsl.f90 \
-            stringop.f90  \
-            mathelp.f90   \
-            getincom.f90  \
-            calendar.f90  \
-            fliocom.f90   \
-            flincom.f90   \
-            histcom.f90   \
-            restcom.f90   \
-            ioipsl.f90
+MODS1 = defprec.f90   \
+        errioipsl.f90 \
+        stringop.f90  \
+        mathelp.f90   \
+        getincom.f90  \
+        calendar.f90  \
+        fliocom.f90   \
+        flincom.f90   \
+        histcom.f90   \
+        restcom.f90   \
+        ioipsl.f90
 OBJSMODS1 = $(MODS1:.f90=.o)
 
-all: $(SRC_PRC) $(MODEL_LIB)($(OBJSMODS1))
+all: $(MODEL_LIB)($(OBJSMODS1))
 	@echo IOIPSL is OK
 
-$(SRC_PRC): def.prec
-	(sed -e "s/^$(DEF_PRC) */  /g" def.prec | \
-	 grep -v $(PRF_PRC) > $(SRC_PRC))
-
 .PRECIOUS : $(MODEL_LIB)
-#-Q- sxnec  .PRECIOUS : $(SXMODEL_LIB)
-#-Q- sx6nec .PRECIOUS : $(SXMODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
 #-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
@@ -42,8 +42,6 @@
 	$(A_C) $(MODEL_LIB) $*.o
 #-Q- sgi6 	mv $(shell echo $* | tr '[:lower:]' '[:upper:]').mod $(MODDIR)
-#-Q- sxnec	$(A_X) $(SXMODEL_LIB) $*.o
-#-Q- sxnec	mv $*.mod $(MODDIR)
-#-Q- sx6nec	$(A_X) $(SXMODEL_LIB) $*.o
-#-Q- sx6nec	mv $*.mod $(MODDIR)
+#-Q- sx8brodie	mv $*.mod $(MODDIR)
+#-Q- sx8mercure	mv $*.mod $(MODDIR)
 #-Q- sxdkrz	$(A_X) $(SXMODEL_LIB) $*.o
 #-Q- sxdkrz	mv $*.mod $(MODDIR)
@@ -54,18 +52,16 @@
 
 clean:
-#-Q- sxnec	$(RM) $(SXMODEL_LIB)
-#-Q- sx6nec	$(RM) $(SXMODEL_LIB)
 #-Q- sxdkrz	$(RM) $(SXMODEL_LIB)
 #-Q- eshpux	$(RM) $(SXMODEL_LIB)
+	$(RM) $(MODEL_LIB)
 	$(RM) *.*~ Makefile~ core *.o *.mod i.*.L *.L i.*.f90
 	$(RM) $(MODDIR)/*.mod $(MODDIR)/*.M *.M
-	$(RM) $(MODEL_LIB) $(SRC_PRC)
 
 #- Specific dependencies
 
-$(MODEL_LIB)(errioipsl.o):  \
+$(MODEL_LIB)(errioipsl.o):   \
   $(MODEL_LIB)(defprec.o)
 
-$(MODEL_LIB)(stringop.o):  \
+$(MODEL_LIB)(stringop.o):    \
   $(MODEL_LIB)(defprec.o)
 
@@ -74,5 +70,5 @@
   $(MODEL_LIB)(stringop.o)
 
-$(MODEL_LIB)(getincom.o):  \
+$(MODEL_LIB)(getincom.o):    \
   $(MODEL_LIB)(stringop.o)
 
@@ -96,5 +92,5 @@
   $(MODEL_LIB)(stringop.o)   \
   $(MODEL_LIB)(mathelp.o)    \
-  $(MODEL_LIB)(calendar.o)  \
+  $(MODEL_LIB)(calendar.o)   \
   $(MODEL_LIB)(fliocom.o)
 
@@ -103,5 +99,5 @@
   $(MODEL_LIB)(stringop.o)   \
   $(MODEL_LIB)(mathelp.o)    \
-  $(MODEL_LIB)(calendar.o)  \
+  $(MODEL_LIB)(calendar.o)   \
   $(MODEL_LIB)(fliocom.o)
 
Index: IOIPSL/trunk/src/AA_make.ldef
===================================================================
--- IOIPSL/trunk/src/AA_make.ldef	(revision 10)
+++ IOIPSL/trunk/src/AA_make.ldef	(revision 11)
@@ -1,4 +1,4 @@
 #-
-#- $Id: AA_make.ldef,v 2.6 2006/01/18 06:17:31 adm Exp $
+#- $Id$
 #-
 #---------------------------------------------------------------------
@@ -11,19 +11,7 @@
 MODDIR = $(LIBDIR)
 #---------------------------------------------------------------------
-#-P- I4R4     D_P = I4R4
-#-P- I4R8     D_P = I4R8
-#-P- I8R8     D_P = I8R8
-#-P- ??       D_P = I4R4
-#-Q- fjvpp    #-P- ??   D_P = I4R8
-#-Q- sxnec    #-P- ??   D_P = I4R8
-#-Q- sx6nec   #-P- ??   D_P = I4R8
-#-Q- sxdkrz   #-P- ??   D_P = I4R8
-#-Q- aix      #-P- ??   D_P = I4R8
-#-Q- eshpux   #-P- ??   D_P = I4R8
 P_P =
 MODEL_LIB = $(LIBDIR)/libioipsl.a
 SXMODEL_LIB = $(MODEL_LIB)
-#-Q- sxnec  SXMODEL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- sx6nec SXMODEL_LIB = $(LIBDIR)/libsxioipsl.a
 #-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/libsxioipsl.a
 #-Q- eshpux SXMODEL_LIB = $(LIBDIR)/libsxioipsl.a
Index: IOIPSL/trunk/src/calendar.f90
===================================================================
--- IOIPSL/trunk/src/calendar.f90	(revision 10)
+++ IOIPSL/trunk/src/calendar.f90	(revision 11)
@@ -1,3 +1,3 @@
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/calendar.f90,v 2.7 2005/02/25 10:40:32 adm Exp $
+!$Id$
 !-
 MODULE calendar
Index: IOIPSL/trunk/src/def.prec
===================================================================
--- IOIPSL/trunk/src/def.prec	(revision 10)
+++ IOIPSL/trunk/src/def.prec	(revision 11)
@@ -1,6 +1,3 @@
-! @author Jacques Bellier, Marie-Alice Foujols, Jan Polcher
-! @Version : $Revision: 2.1 $, $Date: 2005/06/24 09:57:17 $
-! $Header: /home/ioipsl/CVSROOT/IOIPSL/src/def.prec,v 2.1 2005/06/24 09:57:17 adm Exp $
-!
+! $Id$
 MODULE defprec 
 !!--------------------------------------------------------------------
@@ -17,7 +14,5 @@
   INTEGER,PARAMETER :: r_4=SELECTED_REAL_KIND(6,37)
   INTEGER,PARAMETER :: r_8=SELECTED_REAL_KIND(15,307)
-!#-P-I4R4   INTEGER,PARAMETER :: i_std=i_4, r_std=r_4
-!#-P-I4R8   INTEGER,PARAMETER :: i_std=i_4, r_std=r_8
-!#-P-I8R8   INTEGER,PARAMETER :: i_std=i_8, r_std=r_8
+  INTEGER,PARAMETER :: i_std=i_?, r_std=r_?
 !-----------------
 END MODULE defprec
Index: IOIPSL/trunk/src/errioipsl.f90
===================================================================
--- IOIPSL/trunk/src/errioipsl.f90	(revision 10)
+++ IOIPSL/trunk/src/errioipsl.f90	(revision 11)
@@ -1,3 +1,3 @@
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/errioipsl.f90,v 2.2 2005/02/22 10:14:14 adm Exp $
+!$Id$
 !-
 MODULE errioipsl
@@ -7,8 +7,8 @@
 PRIVATE
 !-
-PUBLIC :: ipslnlf, ipslerr, histerr, ipsldbg
-!-
-  INTEGER :: n_l=6
-  LOGICAL :: ioipsl_debug=.FALSE.
+PUBLIC :: ipslnlf, ipslerr, ipslerr_act, ipslerr_inq, histerr, ipsldbg
+!-
+  INTEGER :: n_l=6, ilv_cur=0, ilv_max=0
+  LOGICAL :: ioipsl_debug=.FALSE., lact_mode=.TRUE.
 !-
 !===
@@ -18,5 +18,5 @@
 !!--------------------------------------------------------------------
 !! The "ipslnlf" routine allows to know and modify
-!! the current logical number for the messages,
+!! the current logical number for the messages.
 !!
 !! SUBROUTINE ipslnlf (new_number,old_number)
@@ -71,12 +71,75 @@
 !---------------------------------------------------------------------
    IF ( (plev >= 1).AND.(plev <= 3) ) THEN
+     ilv_cur = plev
+     ilv_max = MAX(ilv_max,plev)
      WRITE(n_l,'(/,A," ",A)') TRIM(pemsg(plev)),TRIM(pcname)
      WRITE(n_l,'(3(" --> ",A,/))') TRIM(pstr1),TRIM(pstr2),TRIM(pstr3)
    ENDIF
-   IF (plev == 3) THEN
+   IF ( (plev == 3).AND.lact_mode) THEN
      STOP 'Fatal error from IOIPSL. See stdout for more details'
    ENDIF
 !---------------------
 END SUBROUTINE ipslerr
+!===
+SUBROUTINE ipslerr_act (new_mode,old_mode)
+!!--------------------------------------------------------------------
+!! The "ipslerr_act" routine allows to know and modify
+!! the current "action mode" for the error messages,
+!! and reinitialize the error level values.
+!!
+!! SUBROUTINE ipslerr_act (new_mode,old_mode)
+!!
+!! Optional INPUT argument
+!!
+!! (I) new_mode : new error action mode
+!!                .TRUE.  -> STOP     in case of fatal error
+!!                .FALSE. -> CONTINUE in case of fatal error
+!!
+!! Optional OUTPUT argument
+!!
+!! (I) old_mode : current error action mode
+!!--------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  LOGICAL,OPTIONAL,INTENT(IN)  :: new_mode
+  LOGICAL,OPTIONAL,INTENT(OUT) :: old_mode
+!---------------------------------------------------------------------
+  IF (PRESENT(old_mode)) THEN
+    old_mode = lact_mode
+  ENDIF
+  IF (PRESENT(new_mode)) THEN
+    lact_mode = new_mode
+  ENDIF
+  ilv_cur = 0
+  ilv_max = 0
+!-------------------------
+END SUBROUTINE ipslerr_act
+!===
+SUBROUTINE ipslerr_inq (current_level,maximum_level)
+!!--------------------------------------------------------------------
+!! The "ipslerr_inq" routine allows to know
+!! the current level of the error messages
+!! and the maximum level encountered since the
+!! last call to "ipslerr_act".
+!!
+!! SUBROUTINE ipslerr_inq (current_level,maximum_level)
+!!
+!! Optional OUTPUT argument
+!!
+!! (I) current_level : current error level
+!! (I) maximum_level : maximum error level
+!!--------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,OPTIONAL,INTENT(OUT) :: current_level,maximum_level
+!---------------------------------------------------------------------
+  IF (PRESENT(current_level)) THEN
+    current_level = ilv_cur
+  ENDIF
+  IF (PRESENT(maximum_level)) THEN
+    maximum_level = ilv_max
+  ENDIF
+!-------------------------
+END SUBROUTINE ipslerr_inq
 !===
 SUBROUTINE histerr (plev,pcname,pstr1,pstr2,pstr3)
Index: IOIPSL/trunk/src/flincom.f90
===================================================================
--- IOIPSL/trunk/src/flincom.f90	(revision 10)
+++ IOIPSL/trunk/src/flincom.f90	(revision 11)
@@ -1,3 +1,3 @@
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/flincom.f90,v 2.2 2006/03/07 09:21:51 adm Exp $
+!$Id$
 !-
 MODULE flincom
Index: IOIPSL/trunk/src/getincom.f90
===================================================================
--- IOIPSL/trunk/src/getincom.f90	(revision 10)
+++ IOIPSL/trunk/src/getincom.f90	(revision 11)
@@ -1,20 +1,21 @@
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/getincom.f90,v 2.1 2006/04/05 16:18:43 adm Exp $
+!$Id$
 !-
 MODULE getincom
 !---------------------------------------------------------------------
-  USE stringop, &
- &   ONLY : findpos,nocomma,cmpblank,strlowercase,gensig,find_sig
-!-
-  IMPLICIT NONE
-!-
-  PRIVATE
-  PUBLIC :: getin, getin_dump
-!-
-  INTERFACE getin
-    MODULE PROCEDURE getinrs, getinr1d, getinr2d, &
- &                   getinis, getini1d, getini2d, &
- &                   getincs, getinc1d, getinc2d, &
- &                   getinls, getinl1d, getinl2d
-  END INTERFACE
+USE errioipsl, ONLY : ipslerr
+USE stringop, &
+ &   ONLY : nocomma,cmpblank,strlowercase,gensig,find_sig
+!-
+IMPLICIT NONE
+!-
+PRIVATE
+PUBLIC :: getin, getin_dump
+!-
+INTERFACE getin
+  MODULE PROCEDURE getinrs, getinr1d, getinr2d, &
+ &                 getinis, getini1d, getini2d, &
+ &                 getincs, getinc1d, getinc2d, &
+ &                 getinls, getinl1d, getinl2d
+END INTERFACE
 !-
   INTEGER,PARAMETER :: max_files=100
@@ -22,19 +23,22 @@
   INTEGER,SAVE      :: nbfiles
 !-
-  INTEGER,PARAMETER :: max_lines=500
+  INTEGER,PARAMETER :: max_lines=500,l_n=30
   INTEGER,SAVE :: nb_lines
   CHARACTER(LEN=100),DIMENSION(max_lines),SAVE :: fichier
   INTEGER,DIMENSION(max_lines),SAVE :: targetsiglist,fromfile,compline
-  CHARACTER(LEN=30),DIMENSION(max_lines),SAVE  :: targetlist
+  CHARACTER(LEN=l_n),DIMENSION(max_lines),SAVE  :: targetlist
+!-
+  INTEGER,PARAMETER :: n_d_fmt=5,max_msgs=15
+  CHARACTER(LEN=6),SAVE :: c_i_fmt = '(I5.5)'
 !-
 ! The data base of parameters
 !-
   INTEGER,PARAMETER :: memslabs=200
-  INTEGER,PARAMETER :: compress_lim = 20
+  INTEGER,PARAMETER :: compress_lim=20
 !-
   INTEGER,SAVE :: nb_keys=0
   INTEGER,SAVE :: keymemsize=0
   INTEGER,SAVE,ALLOCATABLE :: keysig(:)
-  CHARACTER(LEN=30),SAVE,ALLOCATABLE :: keystr(:)
+  CHARACTER(LEN=l_n),SAVE,ALLOCATABLE :: keystr(:)
 !-
 ! keystatus definition
@@ -46,9 +50,11 @@
 !-
 ! keytype definition
-! keytype = 1 : Interger
+! keytype = 1 : Integer
 ! keytype = 2 : Real
 ! keytype = 3 : Character
 ! keytype = 4 : Logical
 !-
+  INTEGER,PARAMETER :: k_i=1, k_r=2, k_c=3, k_l=4
+!-
   INTEGER,SAVE,ALLOCATABLE :: keytype(:)
 !-
@@ -63,36 +69,36 @@
   INTEGER,SAVE,ALLOCATABLE :: keymemlen(:)
 !-
-  INTEGER,SAVE,ALLOCATABLE :: intmem(:)
-  INTEGER,SAVE             :: intmemsize=0, intmempos=0
-  REAL,SAVE,ALLOCATABLE :: realmem(:)
-  INTEGER,SAVE          :: realmemsize=0, realmempos=0
-  CHARACTER(LEN=100),SAVE,ALLOCATABLE :: charmem(:)
-  INTEGER,SAVE             :: charmemsize=0, charmempos=0
-  LOGICAL,SAVE,ALLOCATABLE :: logicmem(:)
-  INTEGER,SAVE             :: logicmemsize=0, logicmempos=0
+  INTEGER,SAVE,ALLOCATABLE :: i_mem(:)
+  INTEGER,SAVE             :: i_memsize=0, i_mempos=0
+  REAL,SAVE,ALLOCATABLE :: r_mem(:)
+  INTEGER,SAVE          :: r_memsize=0, r_mempos=0
+  CHARACTER(LEN=100),SAVE,ALLOCATABLE :: c_mem(:)
+  INTEGER,SAVE             :: c_memsize=0, c_mempos=0
+  LOGICAL,SAVE,ALLOCATABLE :: l_mem(:)
+  INTEGER,SAVE             :: l_memsize=0, l_mempos=0
 !-
 CONTAINS
 !-
-!=== REAL INTERFACES
-!-
-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
-!-
-  CHARACTER(LEN=*) :: TARGET
-  REAL :: ret_val
-!-
-  REAL,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig, pos, status=0, fileorig
+!=== INTEGER INTERFACE
+!-
+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
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER :: ret_val
+!-
+  INTEGER,DIMENSION(1) :: tmp_ret_val
+  INTEGER :: target_sig,pos,status=0,fileorig
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -104,34 +110,33 @@
   IF (pos < 0) THEN
 !-- Get the information out of the file
-    CALL getfilr (TARGET,status,fileorig,tmp_ret_val)
+    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwr (TARGET,target_sig,status,fileorig,1,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,1,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbrr (pos,1,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,1,target,i_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
 !---------------------
-END SUBROUTINE getinrs
-!-
+END SUBROUTINE getinis
 !===
-!-
-SUBROUTINE getinr1d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getinrs for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  REAL,DIMENSION(:) :: ret_val
-!-
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+SUBROUTINE getini1d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getinis for details. It is the same thing but for a vector
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER,DIMENSION(:) :: ret_val
+!-
+  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig, pos, size_of_in, status=0, fileorig
+  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -150,37 +155,35 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfilr (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwr &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,size_of_in,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbrr (pos,size_of_in,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
 !----------------------
-END SUBROUTINE getinr1d
-!-
+END SUBROUTINE getini1d
 !===
-!-
-SUBROUTINE getinr2d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getinrs for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  REAL,DIMENSION(:,:) :: ret_val
-!-
-  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+SUBROUTINE getini2d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getinis for details. It is the same thing but for a matrix
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER,DIMENSION(:,:) :: ret_val
+!-
+  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 :: jl, jj, ji
+  INTEGER :: jl,jj,ji
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -208,12 +211,163 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfilr (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwr &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,size_of_in,i_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbrr (pos,size_of_in,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      ret_val(ji,jj) = tmp_ret_val(jl)
+    ENDDO
+  ENDDO
+!----------------------
+END SUBROUTINE getini2d
+!-
+!=== REAL INTERFACE
+!-
+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
+!-
+  CHARACTER(LEN=*) :: target
+  REAL :: ret_val
+!-
+  REAL,DIMENSION(1) :: tmp_ret_val
+  INTEGER :: target_sig,pos,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! 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)
+!-
+  tmp_ret_val(1) = ret_val
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,target_sig,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)
+  ENDIF
+  ret_val = tmp_ret_val(1)
+!---------------------
+END SUBROUTINE getinrs
+!===
+SUBROUTINE getinr1d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getinrs for details. It is the same thing but for a vector
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  REAL,DIMENSION(:) :: ret_val
+!-
+  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)
+!-
+! Do we have this target in our database ?
+!-
+  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,target_sig,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)
+  ENDIF
+  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
+!----------------------
+END SUBROUTINE getinr1d
+!===
+SUBROUTINE getinr2d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getinrs for details. It is the same thing but for a matrix
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  REAL,DIMENSION(:,:) :: ret_val
+!-
+  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 :: 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)
+!-
+  size_of_in = SIZE(ret_val)
+  size_1 = SIZE(ret_val,1)
+  size_2 = SIZE(ret_val,2)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      tmp_ret_val(jl) = ret_val(ji,jj)
+    ENDDO
+  ENDDO
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,target_sig,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)
   ENDIF
 !-
@@ -228,246 +382,63 @@
 END SUBROUTINE getinr2d
 !-
-!===
-!-
-SUBROUTINE getfilr (TARGET,status,fileorig,ret_val)
-!---------------------------------------------------------------------
-!- Subroutine that will extract from the file the values
-!- attributed to the keyword target
-!-
-!- REALS
-!- -----
-!-
-!- target   : in  : CHARACTER(LEN=*)  target for which we will
-!-                                    look in the file
-!- status   : out : INTEGER tells us from where we obtained the data
-!- fileorig : out : The index of the file from which the key comes
-!- ret_val  : out : REAL(nb_to_ret) values read
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER :: status, fileorig
-  REAL,DIMENSION(:) :: ret_val
-!-
-  INTEGER :: nb_to_ret
-  INTEGER :: it, pos, len_str, epos, ppos, int_tmp, status_cnt
-  CHARACTER(LEN=3)  :: cnt, tl, dl
-  CHARACTER(LEN=10) :: fmt
-  CHARACTER(LEN=30) :: full_target
-  CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp
-  INTEGER :: full_target_sig
-  REAL :: compvalue
-!-
-  INTEGER,SAVE :: max_len = 0
-  LOGICAL,SAVE,ALLOCATABLE :: found(:)
-  LOGICAL,SAVE :: def_beha
-  LOGICAL :: compressed = .FALSE.
-!---------------------------------------------------------------------
-  nb_to_ret = SIZE(ret_val)
-  CALL getin_read
-!-
-! Get the variables and memory we need
-!-
-  IF (max_len == 0) THEN
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  IF (max_len < nb_to_ret) THEN
-    DEALLOCATE(found)
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  found(:) = .FALSE.
-!-
-! See what we find in the files read
-!-
-  DO it=1,nb_to_ret
-!---
-!-
-!-- First try the target as it is
-!---
-    full_target = TARGET(1:len_TRIM(target))
-    CALL gensig (full_target,full_target_sig)
-    CALL find_sig (nb_lines,targetlist,full_target, &
- &                 targetsiglist,full_target_sig,pos)
-!---
-!-- Another try
-!---
-    IF (pos < 0) THEN
-      WRITE(cnt,'(I3.3)') it
-      full_target = TARGET(1:len_TRIM(target))//'__'//cnt
-      CALL gensig (full_target,full_target_sig)
-      CALL find_sig (nb_lines,targetlist,full_target, &
- &                   targetsiglist,full_target_sig,pos)
-    ENDIF
-!---
-!-- A priori we dont know from which file the target could come.
-!-- Thus by default we attribute it to the first file :
-!---
-    fileorig = 1
-!--
-    IF (pos > 0) THEN
-!----
-      found(it) = .TRUE.
-      fileorig = fromfile(pos)
-!-----
-!---- DECODE
-!-----
-      str_READ = TRIM(ADJUSTL(fichier(pos)))
-      str_READ_lower = str_READ
-      CALL strlowercase (str_READ_lower)
-!----
-      IF (    (     (INDEX(str_READ_lower,'def') == 1)     &
- &             .AND.(LEN_TRIM(str_READ_lower) == 3)   )    &
- &        .OR.(     (INDEX(str_READ_lower,'default') == 1) &
- &             .AND.(LEN_TRIM(str_READ_lower) == 7)   )   ) THEN
-        def_beha = .TRUE.
-      ELSE
-        def_beha = .FALSE.
-        len_str = LEN_TRIM(str_READ)
-        epos = INDEX(str_READ,'e')
-        ppos = INDEX(str_READ,'.')
-!------
-        IF (epos > 0) THEN
-          WRITE(tl,'(I3.3)') len_str
-          WRITE(dl,'(I3.3)') epos-ppos-1
-          fmt='(e'//tl//'.'//dl//')'
-          READ(str_READ,fmt) ret_val(it)
-        ELSE IF (ppos > 0) THEN
-          WRITE(tl,'(I3.3)') len_str
-          WRITE(dl,'(I3.3)') len_str-ppos
-          fmt='(f'//tl//'.'//dl//')'
-          READ(str_READ,fmt) ret_val(it)
-        ELSE
-          WRITE(tl,'(I3.3)') len_str
-          fmt = '(I'//tl//')'
-          READ(str_READ,fmt) int_tmp
-          ret_val(it) = REAL(int_tmp)
-        ENDIF
-      ENDIF
-!----
-      targetsiglist(pos) = -1
-!-----
-!---- Is this the value of a compressed field ?
-!-----
-      IF (compline(pos) > 0) THEN
-        IF (compline(pos) == nb_to_ret) THEN
-          compressed = .TRUE.
-          compvalue = ret_val(it)
-        ELSE
-          WRITE(*,*) 'WARNING from getfilr'
-          WRITE(*,*) 'For key ',TRIM(TARGET), &
- & ' we have a compressed field but which does not have the right size.'
-          WRITE(*,*) 'We will try to fix that '
-          compressed = .TRUE.
-          compvalue = ret_val(it)
-        ENDIF
-      ENDIF
-    ELSE
-      found(it) = .FALSE.
-    ENDIF
-  ENDDO
-!--
-! If this is a compressed field then we will uncompress it
-!--
-  IF (compressed) THEN
-    DO it=1,nb_to_ret
-      IF (.NOT. found(it)) THEN
-        ret_val(it) = compvalue
-        found(it) = .TRUE.
-      ENDIF
-    ENDDO
-  ENDIF
-!-
-! Now we get the status for what we found
-!-
-  IF (def_beha) THEN
-    status = 2
-    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET)
+!=== CHARACTER INTERFACE
+!-
+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
+!-
+  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*) :: ret_val
+!-
+  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)
+!-
+! Do we have this target in our database ?
+!-
+  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
+!-
+  tmp_ret_val(1) = ret_val
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,1,c_val=tmp_ret_val)
   ELSE
-    status_cnt = 0
-    DO it=1,nb_to_ret
-      IF (.NOT. found(it)) THEN
-        status_cnt = status_cnt+1
-        IF (nb_to_ret > 1) THEN
-          WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it
-        ELSE
-          str_tmp = TRIM(TARGET)
-        ENDIF
-        WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it)
-      ENDIF
-    ENDDO
-!---
-    IF (status_cnt == 0) THEN
-      status = 1
-    ELSE IF (status_cnt == nb_to_ret) THEN
-      status = 2
-    ELSE
-      status = 3
-    ENDIF
-  ENDIF
-!---------------------
-END SUBROUTINE getfilr
-!-
-!=== INTEGER INTERFACES
-!-
-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
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER :: ret_val
-!-
-  INTEGER,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig, pos, status=0, fileorig
-!---------------------------------------------------------------------
-!-
-! 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)
-!-
-  tmp_ret_val(1) = ret_val
-!-
-  IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfili (TARGET,status,fileorig,tmp_ret_val)
-!-- Put the data into the database
-    CALL getdbwi (TARGET,target_sig,status,fileorig,1,tmp_ret_val)
-    ELSE
 !-- Get the value out of the database
-    CALL getdbri (pos,1,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,1,target,c_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
 !---------------------
-END SUBROUTINE getinis
-!-
+END SUBROUTINE getincs
 !===
-!-
-SUBROUTINE getini1d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getinis for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER,DIMENSION(:) :: ret_val
-!-
-  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+SUBROUTINE getinc1d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getincs for details. It is the same thing but for a vector
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*),DIMENSION(:) :: ret_val
+!-
+  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
+  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -486,37 +457,35 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfili (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwi &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,size_of_in,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbri (pos,size_of_in,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
 !----------------------
-END SUBROUTINE getini1d
-!-
+END SUBROUTINE getinc1d
 !===
-!-
-SUBROUTINE getini2d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getinis for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER,DIMENSION(:,:) :: ret_val
-!-
-  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+SUBROUTINE getinc2d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getincs for details. It is the same thing but for a matrix
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val
+!-
+  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 :: jl, jj, ji
+  INTEGER :: jl,jj,ji
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -544,12 +513,12 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfili (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwi &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,size_of_in,c_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbri (pos,size_of_in,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
   ENDIF
 !-
@@ -562,192 +531,27 @@
   ENDDO
 !----------------------
-END SUBROUTINE getini2d
-!-
-!===
-!-
-SUBROUTINE getfili (TARGET,status,fileorig,ret_val)
-!---------------------------------------------------------------------
-!- Subroutine that will extract from the file the values
-!- attributed to the keyword target
-!-
-!- INTEGER
-!- -------
-!-
-!- target   : in  : CHARACTER(LEN=*)  target for which we will
-!-                                    look in the file
-!- status   : out : INTEGER tells us from where we obtained the data
-!- fileorig : out : The index of the file from which the key comes
-!- ret_val  : out : INTEGER(nb_to_ret) values read
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER :: status, fileorig
-  INTEGER :: ret_val(:)
-!-
-  INTEGER :: nb_to_ret
-  INTEGER :: it, pos, len_str, status_cnt
-  CHARACTER(LEN=3)  :: cnt, chlen
-  CHARACTER(LEN=10) ::  fmt
-  CHARACTER(LEN=30) :: full_target
-  CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp
-  INTEGER :: full_target_sig
-  INTEGER :: compvalue
-!-
-  INTEGER,SAVE :: max_len = 0
-  LOGICAL,SAVE,ALLOCATABLE :: found(:)
-  LOGICAL,SAVE :: def_beha
-  LOGICAL :: compressed = .FALSE.
-!---------------------------------------------------------------------
-  nb_to_ret = SIZE(ret_val)
-  CALL getin_read
-!-
-! Get the variables and memory we need
-!-
-  IF (max_len == 0) THEN
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  IF (max_len < nb_to_ret) THEN
-    DEALLOCATE(found)
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  found(:) = .FALSE.
-!-
-! See what we find in the files read
-!-
-  DO it=1,nb_to_ret
-!---
-!-- First try the target as it is
-!---
-    full_target = TARGET(1:len_TRIM(target))
-    CALL gensig (full_target,full_target_sig)
-    CALL find_sig (nb_lines,targetlist,full_target, &
- &                 targetsiglist,full_target_sig,pos)
-!---
-!-- Another try
-!---
-    IF (pos < 0) THEN
-      WRITE(cnt,'(I3.3)') it
-      full_target = TARGET(1:len_TRIM(target))//'__'//cnt
-      CALL gensig (full_target,full_target_sig)
-      CALL find_sig (nb_lines,targetlist,full_target, &
- &                   targetsiglist,full_target_sig,pos)
-    ENDIF
-!---
-!-- A priori we dont know from which file the target could come.
-!-- Thus by default we attribute it to the first file :
-!---
-    fileorig = 1
-!-
-    IF (pos > 0) THEN
-!-----
-      found(it) = .TRUE.
-      fileorig = fromfile(pos)
-!-----
-!---- DECODE
-!----
-      str_READ = TRIM(ADJUSTL(fichier(pos)))
-      str_READ_lower = str_READ
-      CALL strlowercase (str_READ_lower)
-!-----
-      IF (    (     (INDEX(str_READ_lower,'def') == 1)     &
- &             .AND.(LEN_TRIM(str_READ_lower) == 3)   )    &
- &        .OR.(     (INDEX(str_READ_lower,'default') == 1) &
- &             .AND.(LEN_TRIM(str_READ_lower) == 7)   )   ) THEN
-        def_beha = .TRUE.
-      ELSE
-        def_beha = .FALSE.
-        len_str = LEN_TRIM(str_READ)
-        WRITE(chlen,'(I3.3)') len_str
-        fmt = '(I'//chlen//')'
-        READ(str_READ,fmt) ret_val(it)
-      ENDIF
-!-----
-      targetsiglist(pos) = -1
-!-----
-!---- Is this the value of a compressed field ?
-!-----
-      IF (compline(pos) > 0) THEN
-        IF (compline(pos) == nb_to_ret) THEN
-          compressed = .TRUE.
-          compvalue = ret_val(it)
-        ELSE
-          WRITE(*,*) 'WARNING from getfilr'
-          WRITE(*,*) 'For key ',TRIM(TARGET), &
- & ' we have a compressed field but which does not have the right size.'
-          WRITE(*,*) 'We will try to fix that '
-          compressed = .TRUE.
-          compvalue = ret_val(it)
-        ENDIF
-      ENDIF
-    ELSE
-      found(it) = .FALSE.
-    ENDIF
-  ENDDO
-!-
-! If this is a compressed field then we will uncompress it
-!-
-  IF (compressed) THEN
-    DO it=1,nb_to_ret
-      IF (.NOT. found(it)) THEN
-        ret_val(it) = compvalue
-        found(it) = .TRUE.
-      ENDIF
-    ENDDO
-  ENDIF
-!-
-! Now we get the status for what we found
-!-
-  IF (def_beha) THEN
-    status = 2
-    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET)
-  ELSE
-    status_cnt = 0
-    DO it=1,nb_to_ret
-      IF (.NOT. found(it)) THEN
-        status_cnt = status_cnt+1
-        IF (nb_to_ret > 1) THEN
-          WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it
-        ELSE
-          str_tmp = TRIM(TARGET)
-        ENDIF
-        WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it)
-      ENDIF
-    ENDDO
-!---
-    IF (status_cnt == 0) THEN
-      status = 1
-    ELSE IF (status_cnt == nb_to_ret) THEN
-      status = 2
-    ELSE
-      status = 3
-    ENDIF
-  ENDIF
-!---------------------
-END SUBROUTINE getfili
-!-
-!=== CHARACTER INTERFACES
-!-
-SUBROUTINE getincs (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- Get a CHARACTER scalar. We first check if we find it
+END SUBROUTINE getinc2d
+!-
+!=== LOGICAL INTERFACE
+!-
+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
 !-
-!- getinc1d and getinc2d are written on the same pattern
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  CHARACTER(LEN=*) :: ret_val
-!-
-  CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig, pos, status=0, fileorig
+!- getinl1d and getinl2d are written on the same pattern
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  LOGICAL :: ret_val
+!-
+  LOGICAL,DIMENSION(1) :: tmp_ret_val
+  INTEGER :: target_sig,pos,status=0,fileorig
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -758,35 +562,34 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfilc (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwc (TARGET,target_sig,status,fileorig,1,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,1,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbrc (pos,1,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,1,target,l_val=tmp_ret_val)
   ENDIF
   ret_val = tmp_ret_val(1)
 !---------------------
-END SUBROUTINE getincs
-!-
+END SUBROUTINE getinls
 !===
-!-
-SUBROUTINE getinc1d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getincs for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  CHARACTER(LEN=*),DIMENSION(:) :: ret_val
-!-
-  CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+SUBROUTINE getinl1d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getinls for details. It is the same thing but for a vector
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  LOGICAL,DIMENSION(:) :: ret_val
+!-
+  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
   INTEGER,SAVE :: tmp_ret_size = 0
-  INTEGER :: target_sig, pos, size_of_in, status=0, fileorig
+  INTEGER :: target_sig,pos,size_of_in,status=0,fileorig
 !---------------------------------------------------------------------
 !-
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -805,29 +608,27 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfilc (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwc &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,size_of_in,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbrc (pos,size_of_in,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
   ENDIF
   ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
 !----------------------
-END SUBROUTINE getinc1d
-!-
+END SUBROUTINE getinl1d
 !===
-!-
-SUBROUTINE getinc2d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getincs for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val
-!-
-  CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+SUBROUTINE getinl2d (target,ret_val)
+!---------------------------------------------------------------------
+!- See getinls for details. It is the same thing but for a matrix
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  LOGICAL,DIMENSION(:,:) :: ret_val
+!-
+  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
@@ -837,5 +638,5 @@
 ! Compute the signature of the target
 !-
-  CALL gensig (TARGET,target_sig)
+  CALL gensig (target,target_sig)
 !-
 ! Do we have this target in our database ?
@@ -863,300 +664,12 @@
 !-
   IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfilc (TARGET,status,fileorig,tmp_ret_val)
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
 !-- Put the data into the database
-    CALL getdbwc &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
+    CALL get_wdb &
+ &   (target,target_sig,status,fileorig,size_of_in,l_val=tmp_ret_val)
   ELSE
 !-- Get the value out of the database
-    CALL getdbrc (pos,size_of_in,TARGET,tmp_ret_val)
-  ENDIF
-!-
-  jl=0
-  DO jj=1,size_2
-    DO ji=1,size_1
-      jl=jl+1
-      ret_val(ji,jj) = tmp_ret_val(jl)
-    ENDDO
-  ENDDO
-!----------------------
-END SUBROUTINE getinc2d
-!-
-!===
-!-
-SUBROUTINE getfilc (TARGET,status,fileorig,ret_val)
-!---------------------------------------------------------------------
-!- Subroutine that will extract from the file the values
-!- attributed to the keyword target
-!-
-!- CHARACTER
-!- ---------
-!-
-!- target   : in  : CHARACTER(LEN=*)  target for which we will
-!-                                    look in the file
-!- status   : out : INTEGER tells us from where we obtained the data
-!- fileorig : out : The index of the file from which the key comes
-!- ret_val  : out : CHARACTER(nb_to_ret) values read
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER :: status, fileorig
-  CHARACTER(LEN=*),DIMENSION(:) :: ret_val
-!-
-  INTEGER :: nb_to_ret
-  INTEGER :: it, pos, len_str, status_cnt
-  CHARACTER(LEN=3)  :: cnt
-  CHARACTER(LEN=30) :: full_target
-  CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp
-  INTEGER :: full_target_sig
-!-
-  INTEGER,SAVE :: max_len = 0
-  LOGICAL,DIMENSION(:),SAVE,ALLOCATABLE :: found
-  LOGICAL,SAVE :: def_beha
-!---------------------------------------------------------------------
-  nb_to_ret = SIZE(ret_val)
-  CALL getin_read
-!-
-! Get the variables and memory we need
-!-
-  IF (max_len == 0) THEN
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  IF (max_len < nb_to_ret) THEN
-    DEALLOCATE(found)
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  found(:) = .FALSE.
-!-
-! See what we find in the files read
-!-
-  DO it=1,nb_to_ret
-!---
-!-- First try the target as it is
-    full_target = TARGET(1:len_TRIM(target))
-    CALL gensig (full_target,full_target_sig)
-    CALL find_sig (nb_lines,targetlist,full_target, &
- &                 targetsiglist,full_target_sig,pos)
-!---
-!-- Another try
-!---
-    IF (pos < 0) THEN
-      WRITE(cnt,'(I3.3)') it
-      full_target = TARGET(1:len_TRIM(target))//'__'//cnt
-      CALL gensig (full_target,full_target_sig)
-      CALL find_sig (nb_lines,targetlist,full_target, &
- &                   targetsiglist,full_target_sig,pos)
-    ENDIF
-!---
-!-- A priori we dont know from which file the target could come.
-!-- Thus by default we attribute it to the first file :
-!---
-    fileorig = 1
-!---
-    IF (pos > 0) THEN
-!-----
-      found(it) = .TRUE.
-      fileorig = fromfile(pos)
-!-----
-!---- DECODE
-!-----
-      str_READ = TRIM(ADJUSTL(fichier(pos)))
-      str_READ_lower = str_READ
-      CALL strlowercase (str_READ_lower)
-!-----
-      IF (    (     (INDEX(str_READ_lower,'def') == 1)     &
- &             .AND.(LEN_TRIM(str_READ_lower) == 3)   )    &
- &        .OR.(     (INDEX(str_READ_lower,'default') == 1) &
- &             .AND.(LEN_TRIM(str_READ_lower) == 7)   )   ) THEN
-        def_beha = .TRUE.
-      ELSE
-        def_beha = .FALSE.
-        len_str = LEN_TRIM(str_READ)
-        ret_val(it) = str_READ(1:len_str)
-      ENDIF
-!-----
-      targetsiglist(pos) = -1
-!-----
-    ELSE
-      found(it) = .FALSE.
-    ENDIF
-  ENDDO
-!-
-! Now we get the status for what we found
-!-
-  IF (def_beha) THEN
-    status = 2
-    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET)
-  ELSE
-    status_cnt = 0
-    DO it=1,nb_to_ret
-      IF (.NOT. found(it)) THEN
-        status_cnt = status_cnt+1
-        IF (nb_to_ret > 1) THEN
-          WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it
-        ELSE
-          str_tmp = TARGET(1:len_TRIM(target))
-        ENDIF
-        WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it)
-      ENDIF
-    ENDDO
-!-
-    IF (status_cnt == 0) THEN
-      status = 1
-    ELSE IF (status_cnt == nb_to_ret) THEN
-      status = 2
-    ELSE
-      status = 3
-    ENDIF
-  ENDIF
-!---------------------
-END SUBROUTINE getfilc
-!-
-!=== LOGICAL INTERFACES
-!-
-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
-!-
-  CHARACTER(LEN=*) :: TARGET
-  LOGICAL :: ret_val
-!-
-  LOGICAL,DIMENSION(1) :: tmp_ret_val
-  INTEGER :: target_sig, pos, status=0, fileorig
-!---------------------------------------------------------------------
-!-
-! 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)
-!-
-  tmp_ret_val(1) = ret_val
-!-
-  IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfill (TARGET,status,fileorig,tmp_ret_val)
-!-- Put the data into the database
-    CALL getdbwl (TARGET,target_sig,status,fileorig,1,tmp_ret_val)
-  ELSE
-!-- Get the value out of the database
-    CALL getdbrl (pos,1,TARGET,tmp_ret_val)
-  ENDIF
-  ret_val = tmp_ret_val(1)
-!---------------------
-END SUBROUTINE getinls
-!-
-!===
-!-
-SUBROUTINE getinl1d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getinls for details. It is the same thing but for a vector
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  LOGICAL,DIMENSION(:) :: ret_val
-!-
-  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)
-!-
-! Do we have this target in our database ?
-!-
-  CALL find_sig (nb_keys,keystr,target,keysig,target_sig,pos)
-!-
-  size_of_in = SIZE(ret_val)
-  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
-    ALLOCATE (tmp_ret_val(size_of_in))
-  ELSE IF (size_of_in > tmp_ret_size) THEN
-    DEALLOCATE (tmp_ret_val)
-    ALLOCATE (tmp_ret_val(size_of_in))
-    tmp_ret_size = size_of_in
-  ENDIF
-  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
-!-
-  IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfill (TARGET,status,fileorig,tmp_ret_val)
-!-- Put the data into the database
-    CALL getdbwl &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
-  ELSE
-!-- Get the value out of the database
-    CALL getdbrl (pos,size_of_in,TARGET,tmp_ret_val)
-  ENDIF
-  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
-!----------------------
-END SUBROUTINE getinl1d
-!-
-!===
-!-
-SUBROUTINE getinl2d (TARGET,ret_val)
-!---------------------------------------------------------------------
-!- See getinls for details. It is the same thing but for a matrix
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  LOGICAL,DIMENSION(:,:) :: ret_val
-!-
-  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 :: 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)
-!-
-  size_of_in = SIZE(ret_val)
-  size_1 = SIZE(ret_val,1)
-  size_2 = SIZE(ret_val,2)
-  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
-    ALLOCATE (tmp_ret_val(size_of_in))
-  ELSE IF (size_of_in > tmp_ret_size) THEN
-    DEALLOCATE (tmp_ret_val)
-    ALLOCATE (tmp_ret_val(size_of_in))
-    tmp_ret_size = size_of_in
-  ENDIF
-!-
-  jl=0
-  DO jj=1,size_2
-    DO ji=1,size_1
-      jl=jl+1
-      tmp_ret_val(jl) = ret_val(ji,jj)
-    ENDDO
-  ENDDO
-!-
-  IF (pos < 0) THEN
-!-- Ge the information out of the file
-    CALL getfill (TARGET,status,fileorig,tmp_ret_val)
-!-- Put the data into the database
-    CALL getdbwl &
- &   (TARGET,target_sig,status,fileorig,size_of_in,tmp_ret_val)
-  ELSE
-!-- Get the value out of the database
-    CALL getdbrl (pos,size_of_in,TARGET,tmp_ret_val)
+    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
   ENDIF
 !-
@@ -1171,60 +684,70 @@
 END SUBROUTINE getinl2d
 !-
-!===
-!-
-SUBROUTINE getfill (TARGET,status,fileorig,ret_val)
+!=== Generic file/database INTERFACE
+!-
+SUBROUTINE get_fil (target,status,fileorig,i_val,r_val,c_val,l_val)
 !---------------------------------------------------------------------
 !- Subroutine that will extract from the file the values
 !- attributed to the keyword target
 !-
-!- LOGICAL
-!- -------
-!-
-!- target   : in  : CHARACTER(LEN=*)  target for which we will
-!-                                    look in the file
-!- status   : out : INTEGER tells us from where we obtained the data
-!- fileorig : out : The index of the file from which the key comes
-!- ret_val  : out : LOGICAL(nb_to_ret) values read
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: TARGET
-  INTEGER :: status, fileorig
-  LOGICAL,DIMENSION(:) :: ret_val
-!-
-  INTEGER :: nb_to_ret
-  INTEGER :: it, pos, len_str, ipos_tr, ipos_fl, status_cnt
-  CHARACTER(LEN=3)  :: cnt
-  CHARACTER(LEN=30) :: full_target
-  CHARACTER(LEN=80) :: str_READ, str_READ_lower, str_tmp
+!- (C) target    : 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) i_val(:)  : INTEGER(nb_to_ret)   values
+!- (R) r_val(:)  : REAL(nb_to_ret)      values
+!- (L) l_val(:)  : LOGICAL(nb_to_ret)   values
+!- (C) c_val(:)  : CHARACTER(nb_to_ret) values
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER,INTENT(OUT) :: status,fileorig
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
+  REAL,DIMENSION(:),OPTIONAL             :: r_val
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
+!-
+  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
-!-
-  INTEGER,SAVE :: max_len = 0
-  LOGICAL,DIMENSION(:),SAVE,ALLOCATABLE :: found
-  LOGICAL,SAVE :: def_beha
-!---------------------------------------------------------------------
-  nb_to_ret = SIZE(ret_val)
+  LOGICAL,DIMENSION(:),ALLOCATABLE :: found
+  LOGICAL :: def_beha,compressed
+  CHARACTER(LEN=10) :: c_fmt
+  INTEGER :: i_cmpval
+  REAL    :: r_cmpval
+  INTEGER :: ipos_tr,ipos_fl
+!---------------------------------------------------------------------
+!-
+! 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
+    CALL ipslerr (3,'get_fil', &
+ &   'Internal error','Unknown type of data',' ')
+  END SELECT
+!-
+! Read the file(s)
   CALL getin_read
 !-
-! Get the variables and memory we need
-!-
-  IF (max_len == 0) THEN
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
-  IF (max_len < nb_to_ret) THEN
-    DEALLOCATE(found)
-    ALLOCATE(found(nb_to_ret))
-    max_len = nb_to_ret
-  ENDIF
+! Allocate and initialize the memory we need
+  ALLOCATE(found(nb_to_ret))
   found(:) = .FALSE.
 !-
 ! See what we find in the files read
-!-
   DO it=1,nb_to_ret
 !---
 !-- First try the target as it is
-!---
-    full_target = TARGET(1:len_TRIM(target))
+    full_target = target
     CALL gensig (full_target,full_target_sig)
     CALL find_sig (nb_lines,targetlist,full_target, &
@@ -1234,6 +757,6 @@
 !---
     IF (pos < 0) THEN
-      WRITE(cnt,'(I3.3)') it
-      full_target = TARGET(1:len_TRIM(target))//'__'//cnt
+      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, &
@@ -1241,7 +764,6 @@
     ENDIF
 !---
-!-- A priori we dont know from which file the target could come.
+!-- We dont know from which file the target could come.
 !-- Thus by default we attribute it to the first file :
-!---
     fileorig = 1
 !---
@@ -1253,32 +775,44 @@
 !---- DECODE
 !-----
-      str_READ = TRIM(ADJUSTL(fichier(pos)))
+      str_READ = ADJUSTL(fichier(pos))
       str_READ_lower = str_READ
       CALL strlowercase (str_READ_lower)
 !-----
-      IF (    (     (INDEX(str_READ_lower,'def') == 1)     &
- &             .AND.(LEN_TRIM(str_READ_lower) == 3)   )    &
- &        .OR.(     (INDEX(str_READ_lower,'default') == 1) &
- &             .AND.(LEN_TRIM(str_READ_lower) == 7)   )   ) THEN
+      IF (    (TRIM(str_READ_lower) == 'def')     &
+ &        .OR.(TRIM(str_READ_lower) == 'default') ) THEN
         def_beha = .TRUE.
       ELSE
         def_beha = .FALSE.
         len_str = LEN_TRIM(str_READ)
-        ipos_tr = -1
-        ipos_fl = -1
-!-------
-        ipos_tr = MAX(INDEX(str_READ,'tru'),INDEX(str_READ,'TRU'), &
- &                    INDEX(str_READ,'y'),INDEX(str_READ,'Y'))
-        ipos_fl = MAX(INDEX(str_READ,'fal'),INDEX(str_READ,'FAL'), &
- &                    INDEX(str_READ,'n'),INDEX(str_READ,'N'))
-!-------
-        IF (ipos_tr > 0) THEN
-          ret_val(it) = .TRUE.
-        ELSE IF (ipos_fl > 0) THEN
-          ret_val(it) = .FALSE.
-        ELSE
-          WRITE(*,*) "ERROR : getfill : TARGET ", &
- &                   TRIM(TARGET)," is not of logical value"
-          STOP 'getinl'
+        io_err = 0
+        SELECT CASE (k_typ)
+        CASE(k_i)
+          WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') len_str
+          READ (UNIT=str_READ(1:len_str), &
+ &              FMT=c_fmt,IOSTAT=io_err) i_val(it)
+        CASE(k_r)
+          READ (UNIT=str_READ(1:len_str), &
+ &              FMT=*,IOSTAT=io_err) r_val(it)
+        CASE(k_c)
+          c_val(it) = str_READ(1:len_str)
+        CASE(k_l)
+          ipos_tr = -1
+          ipos_fl = -1
+          ipos_tr = MAX(INDEX(str_READ_lower,'tru'), &
+ &                      INDEX(str_READ_lower,'y'))
+          ipos_fl = MAX(INDEX(str_READ_lower,'fal'), &
+ &                      INDEX(str_READ_lower,'n'))
+          IF (ipos_tr > 0) THEN
+            l_val(it) = .TRUE.
+          ELSE IF (ipos_fl > 0) THEN
+            l_val(it) = .FALSE.
+          ELSE
+            io_err = 100
+          ENDIF
+        END SELECT
+        IF (io_err /= 0) THEN
+          CALL ipslerr (3,'get_fil', &
+ &         'Target '//TRIM(target), &
+ &         'is not of '//TRIM(c_vtyp)//' type',' ')
         ENDIF
       ENDIF
@@ -1286,28 +820,74 @@
       targetsiglist(pos) = -1
 !-----
+      IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
+!-------
+!------ Is this the value of a compressed field ?
+        compressed = (compline(pos) > 0)
+        IF (compressed) THEN
+          IF (compline(pos) /= nb_to_ret) THEN
+            CALL ipslerr (2,'get_fil', &
+ &           'For key '//TRIM(target)//' we have a compressed field', &
+ &           'which does not have the right size.', &
+ &           'We will try to fix that.')
+          ENDIF
+          IF      (k_typ == k_i) THEN
+            i_cmpval = i_val(it)
+          ELSE IF (k_typ == k_r) THEN
+            r_cmpval = r_val(it)
+          ENDIF
+        ENDIF
+      ENDIF
     ELSE
-!-
       found(it) = .FALSE.
-!-
-    ENDIF
-!-
+      def_beha = .FALSE.
+      compressed = .FALSE.
+    ENDIF
   ENDDO
 !-
-! Now we get the status for what we found
-!-
+  IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
+!---
+!-- If this is a compressed field then we will uncompress it
+    IF (compressed) THEN
+      DO it=1,nb_to_ret
+        IF (.NOT.found(it)) THEN
+          IF      (k_typ == k_i) THEN
+            i_val(it) = i_cmpval
+          ELSE IF (k_typ == k_r) THEN
+          ENDIF
+          found(it) = .TRUE.
+        ENDIF
+      ENDDO
+    ENDIF
+  ENDIF
+!-
+! Now we set the status for what we found
   IF (def_beha) THEN
     status = 2
-    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(TARGET)
+    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(target)
   ELSE
     status_cnt = 0
     DO it=1,nb_to_ret
-      IF (.NOT. found(it)) THEN
+      IF (.NOT.found(it)) THEN
         status_cnt = status_cnt+1
-        IF (nb_to_ret > 1) THEN
-          WRITE(str_tmp,'(a,"__",I3.3)') TRIM(TARGET),it
-        ELSE
-          str_tmp = TRIM(TARGET)
+        IF      (status_cnt <= max_msgs) THEN
+          WRITE (UNIT=*,FMT='(" USING DEFAULTS : ",A)', &
+ &               ADVANCE='NO') TRIM(target)
+          IF (nb_to_ret > 1) THEN
+            WRITE (UNIT=*,FMT='("__")',ADVANCE='NO')
+            WRITE (UNIT=*,FMT=c_i_fmt,ADVANCE='NO') it
+          ENDIF
+          SELECT CASE (k_typ)
+          CASE(k_i)
+            WRITE (UNIT=*,FMT=*) "=",i_val(it)
+          CASE(k_r)
+            WRITE (UNIT=*,FMT=*) "=",r_val(it)
+          CASE(k_c)
+            WRITE (UNIT=*,FMT=*) "=",c_val(it)
+          CASE(k_l)
+            WRITE (UNIT=*,FMT=*) "=",l_val(it)
+          END SELECT
+        ELSE IF (status_cnt == max_msgs+1) THEN
+          WRITE (UNIT=*,FMT='(" USING DEFAULTS ... ",A)')
         ENDIF
-        WRITE(*,*) 'USING DEFAULTS : ',TRIM(str_tmp),'=',ret_val(it)
       ENDIF
     ENDDO
@@ -1321,8 +901,168 @@
     ENDIF
   ENDIF
+! Deallocate the memory
+  DEALLOCATE(found)
 !---------------------
-END SUBROUTINE getfill
-!-
+END SUBROUTINE get_fil
 !===
+SUBROUTINE get_rdb (pos,size_of_in,target,i_val,r_val,c_val,l_val)
+!---------------------------------------------------------------------
+!- Read the required variable in the database
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: pos,size_of_in
+  CHARACTER(LEN=*) :: target
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
+  REAL,DIMENSION(:),OPTIONAL             :: r_val
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
+!-
+  INTEGER :: k_typ
+  CHARACTER(LEN=9) :: c_vtyp
+!---------------------------------------------------------------------
+!-
+! Get the type of the argument
+  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
+  IF (     (k_typ /= k_i).AND.(k_typ /= k_r) &
+ &    .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN
+    CALL ipslerr (3,'get_rdb', &
+ &   'Internal error','Unknown type of data',' ')
+  ENDIF
+!-
+  IF (keytype(pos) /= k_typ) THEN
+    CALL ipslerr (3,'get_rdb', &
+ &   'Wrong data type for keyword '//TRIM(target), &
+ &   '(NOT '//TRIM(c_vtyp)//')',' ')
+  ENDIF
+!-
+  IF (keycompress(pos) > 0) THEN
+    IF (    (keycompress(pos) /= size_of_in) &
+ &      .OR.(keymemlen(pos) /= 1) ) THEN
+      CALL ipslerr (3,'get_rdb', &
+ &     'Wrong compression length','for keyword '//TRIM(target),' ')
+    ELSE
+      SELECT CASE (k_typ)
+      CASE(k_i)
+        i_val(1:size_of_in) = i_mem(keymemstart(pos))
+      CASE(k_r)
+        r_val(1:size_of_in) = r_mem(keymemstart(pos))
+      END SELECT
+    ENDIF
+  ELSE
+    IF (keymemlen(pos) /= size_of_in) THEN
+      CALL ipslerr (3,'get_rdb', &
+ &     'Wrong array length','for keyword '//TRIM(target),' ')
+    ELSE
+      SELECT CASE (k_typ)
+      CASE(k_i)
+        i_val(1:size_of_in) = &
+ &        i_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+      CASE(k_r)
+        r_val(1:size_of_in) = &
+ &        r_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+      CASE(k_c)
+        c_val(1:size_of_in) = &
+ &        c_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+      CASE(k_l)
+        l_val(1:size_of_in) = &
+ &        l_mem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
+      END SELECT
+    ENDIF
+  ENDIF
+!---------------------
+END SUBROUTINE get_rdb
+!===
+SUBROUTINE get_wdb &
+ &  (target,target_sig,status,fileorig,size_of_in, &
+ &   i_val,r_val,c_val,l_val)
+!---------------------------------------------------------------------
+!- Write data into the data base
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER :: target_sig,status,fileorig,size_of_in
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
+  REAL,DIMENSION(:),OPTIONAL             :: r_val
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
+!-
+  INTEGER :: k_typ
+  CHARACTER(LEN=9) :: c_vtyp
+  INTEGER :: k_mempos,k_memsize,k_len
+  LOGICAL :: l_cmp
+!---------------------------------------------------------------------
+!-
+! Get the type of the argument
+  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
+  IF (     (k_typ /= k_i).AND.(k_typ /= k_r) &
+ &    .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN
+    CALL ipslerr (3,'get_wdb', &
+ &   'Internal error','Unknown type of data',' ')
+  ENDIF
+!-
+! First check if we have sufficiant space for the new key
+  IF (nb_keys+1 > keymemsize) THEN
+    CALL getin_allockeys ()
+  ENDIF
+!-
+  SELECT CASE (k_typ)
+  CASE(k_i)
+    k_mempos = i_mempos; k_memsize = i_memsize;
+    l_cmp = (MINVAL(i_val) == MAXVAL(i_val)) &
+ &         .AND.(size_of_in > compress_lim)
+  CASE(k_r)
+    k_mempos = r_mempos; k_memsize = r_memsize;
+    l_cmp = (MINVAL(r_val) == MAXVAL(r_val)) &
+ &         .AND.(size_of_in > compress_lim)
+  CASE(k_c)
+    k_mempos = c_mempos; k_memsize = c_memsize;
+    l_cmp = .FALSE.
+  CASE(k_l)
+    k_mempos = l_mempos; k_memsize = l_memsize;
+    l_cmp = .FALSE.
+  END SELECT
+!-
+! 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
+  IF (l_cmp) THEN
+    keycompress(nb_keys) = size_of_in
+    keymemlen(nb_keys) = 1
+  ELSE
+    keycompress(nb_keys) = -1
+    keymemlen(nb_keys) = 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
+  SELECT CASE (k_typ)
+  CASE(k_i)
+    i_mem(keymemstart(nb_keys):k_len) = i_val(1:keymemlen(nb_keys))
+    i_mempos = k_len
+  CASE(k_r)
+    r_mem(keymemstart(nb_keys):k_len) = r_val(1:keymemlen(nb_keys))
+    r_mempos = k_len
+  CASE(k_c)
+    c_mem(keymemstart(nb_keys):k_len) = c_val(1:keymemlen(nb_keys))
+    c_mempos = k_len
+  CASE(k_l)
+    l_mem(keymemstart(nb_keys):k_len) = l_val(1:keymemlen(nb_keys))
+    l_mempos = k_len
+  END SELECT
+!---------------------
+END SUBROUTINE get_wdb
+!-
+!===
 !-
 SUBROUTINE getin_read
@@ -1331,13 +1071,13 @@
 !-
   INTEGER,SAVE :: allread=0
-  INTEGER,SAVE :: current,i
+  INTEGER,SAVE :: current
 !---------------------------------------------------------------------
   IF (allread == 0) THEN
 !-- Allocate a first set of memory.
     CALL getin_allockeys
-    CALL getin_allocmem (1,0)
-    CALL getin_allocmem (2,0)
-    CALL getin_allocmem (3,0)
-    CALL getin_allocmem (4,0)
+    CALL getin_allocmem (k_i,0)
+    CALL getin_allocmem (k_r,0)
+    CALL getin_allocmem (k_c,0)
+    CALL getin_allocmem (k_l,0)
 !-- Start with reading the files
     nbfiles = 1
@@ -1368,9 +1108,10 @@
   INTEGER :: current
 !-
-  CHARACTER(LEN=100) :: READ_str, NEW_str, new_key, last_key, key_str
-  CHARACTER(LEN=3) :: cnt
+  CHARACTER(LEN=100) :: READ_str,NEW_str,last_key,key_str
+  CHARACTER(LEN=n_d_fmt) :: cnt
+  CHARACTER(LEN=10) :: c_fmt
   INTEGER :: nb_lastkey
 !-
-  INTEGER :: eof, ptn, len_str, i, it, iund
+  INTEGER :: eof,ptn,len_str,i,it,iund,io_err
   LOGICAL :: check = .FALSE.
 !---------------------------------------------------------------------
@@ -1383,5 +1124,10 @@
   ENDIF
 !-
-  OPEN (22,file=filelist(current),ERR=9997,STATUS="OLD")
+  OPEN (UNIT=22,FILE=filelist(current),STATUS="OLD",IOSTAT=io_err)
+  IF (io_err /= 0) THEN
+    CALL ipslerr (2,'getin_readdef', &
+ &  'Could not open file '//TRIM(filelist(current)),' ',' ')
+    RETURN
+  ENDIF
 !-
   DO WHILE (eof /= 1)
@@ -1394,25 +1140,18 @@
 !---- Get the target
       key_str = TRIM(ADJUSTL(READ_str(1:ptn-1)))
-!---- Make sure that if a vector keyword has the right length
-      iund =  INDEX(key_str,'__')
+!---- Make sure that a vector keyword has the right length
+      iund = INDEX(key_str,'__')
       IF (iund > 0) THEN
-        SELECTCASE( len_trim(key_str)-iund )
-          CASE(2)
-            READ(key_str(iund+2:len_trim(key_str)),'(I1)') it
-          CASE(3)
-            READ(key_str(iund+2:len_trim(key_str)),'(I2)') it
-          CASE(4)
-            READ(key_str(iund+2:len_trim(key_str)),'(I3)') it
-          CASE DEFAULT
-            it = -1
-        END SELECT
-        IF (it > 0) THEN
-          WRITE(cnt,'(I3.3)') it
+        WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') &
+ &        LEN_TRIM(key_str)-iund-1
+        READ(UNIT=key_str(iund+2:LEN_TRIM(key_str)), &
+ &           FMT=c_fmt,IOSTAT=io_err) it
+        IF ( (io_err == 0).AND.(it > 0) ) THEN
+          WRITE(UNIT=cnt,FMT=c_i_fmt) it
           key_str = key_str(1:iund+1)//cnt
         ELSE
-          WRITE(*,*) &
- &          'getin_readdef : A very strange key has just been found'
-          WRITE(*,*) 'getin_readdef : ',key_str(1:len_TRIM(key_str))
-          STOP 'getin_readdef'
+          CALL ipslerr (3,'getin_readdef', &
+ &         'A very strange key has just been found :', &
+ &         TRIM(key_str),' ')
         ENDIF
       ENDIF
@@ -1443,14 +1182,14 @@
         ELSE
           IF (nb_lastkey /= 1) THEN
-            WRITE(*,*) &
- &   'getin_readdef : An error has occured. We can not have a scalar'
-            WRITE(*,*) 'getin_readdef : keywod and a vector content'
-            STOP 'getin_readdef'
+            CALL ipslerr (3,'getin_readdef', &
+ &           'We can not have a scalar keyword', &
+ &           'and a vector content',' ')
           ENDIF
 !-------- The last keyword needs to be transformed into a vector.
+          WRITE(UNIT=cnt,FMT=c_i_fmt) 1
           targetlist(nb_lines) = &
- &          last_key(1:MIN(len_trim(last_key),30))//'__001'
+ &         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))
+          key_str = last_key(1:LEN_TRIM(last_key))
         ENDIF
       ENDIF
@@ -1459,5 +1198,5 @@
       CALL getin_decrypt (current,key_str,NEW_str,last_key,nb_lastkey)
     ELSE
-!---- If we have an empty line the the keyword finishes
+!---- If we have an empty line then the keyword finishes
       nb_lastkey = 0
       IF (check) THEN
@@ -1467,18 +1206,13 @@
   ENDDO
 !-
-  CLOSE(22)
+  CLOSE(UNIT=22)
 !-
   IF (check) THEN
-    OPEN (22,file='run.def.test')
+    OPEN (UNIT=22,file='run.def.test')
     DO i=1,nb_lines
-      WRITE(22,*) targetlist(i)," : ",fichier(i)
+      WRITE(UNIT=22,FMT=*) targetlist(i)," : ",fichier(i)
     ENDDO
-    CLOSE(22)
-  ENDIF
-!-
-  RETURN
-!-
-9997 WRITE(*,*) "getin_readdef : Could not open file ", &
-          & TRIM(filelist(current))
+    CLOSE(UNIT=22)
+  ENDIF
 !---------------------------
 END SUBROUTINE getin_readdef
@@ -1496,13 +1230,13 @@
 ! ARGUMENTS
 !-
-  INTEGER :: current, nb_lastkey
-  CHARACTER(LEN=*) :: key_str, NEW_str, last_key
+  INTEGER :: current,nb_lastkey
+  CHARACTER(LEN=*) :: key_str,NEW_str,last_key
 !-
 ! LOCAL
 !-
-  INTEGER :: len_str, blk, nbve, starpos
-  CHARACTER(LEN=100) :: tmp_str, new_key, mult
-  CHARACTER(LEN=3)   :: cnt, chlen
-  CHARACTER(LEN=10)  :: fmt
+  INTEGER :: len_str,blk,nbve,starpos
+  CHARACTER(LEN=100) :: tmp_str,new_key,mult
+  CHARACTER(LEN=n_d_fmt) :: cnt
+  CHARACTER(LEN=10) :: c_fmt
 !---------------------------------------------------------------------
   len_str = LEN_TRIM(NEW_str)
@@ -1516,6 +1250,6 @@
     DO WHILE (blk > 0)
       IF (nbfiles+1 > max_files) THEN
-        WRITE(*,*) 'FATAL ERROR : Too many files to include'
-        STOP 'getin_readdef'
+        CALL ipslerr (3,'getin_decrypt', &
+ &       'Too many files to include',' ',' ')
       ENDIF
 !-----
@@ -1528,6 +1262,6 @@
 !---
     IF (nbfiles+1 > max_files) THEN
-      WRITE(*,*) 'FATAL ERROR : Too many files to include'
-      STOP 'getin_readdef'
+      CALL ipslerr (3,'getin_decrypt', &
+ &     'Too many files to include',' ',' ')
     ENDIF
 !---
@@ -1543,8 +1277,8 @@
     nb_lines = nb_lines+1
     IF (nb_lines > max_lines) THEN
-      WRITE(*,*) &
- &      'Too many line in the run.def files. You need to increase'
-      WRITE(*,*) 'the parameter max_lines in the module getincom.'
-      STOP 'getin_decrypt'
+      CALL ipslerr (3,'getin_decrypt', &
+ &     'Too many lines in the run.def files.', &
+ &     'You need to increase', &
+ &     'the parameter max_lines in the module getincom.')
     ENDIF
 !-
@@ -1556,13 +1290,9 @@
  &                    .AND.(tmp_str(1:1) /= "'") ) THEN
 !-----
-      IF (INDEX(key_str(1:len_TRIM(key_str)),'__') > 0) THEN
-        WRITE(*,*) 'ERROR : getin_decrypt'
-        WRITE(*,*) &
-&         'We can not have a compressed field of values for in a'
-        WRITE(*,*) &
-&         'vector notation. If a target is of the type TARGET__1'
-        WRITE(*,*) 'then only a scalar value is allowed'
-        WRITE(*,*) 'The key at fault : ',key_str(1:len_TRIM(key_str))
-        STOP 'getin_decrypt'
+      IF (INDEX(key_str(1:LEN_TRIM(key_str)),'__') > 0) THEN
+        CALL ipslerr (3,'getin_decrypt', &
+ &       'We can not have a compressed field of values', &
+ &       'in a vector notation (TARGET__n).', &
+ &       'The key at fault : '//TRIM(key_str))
       ENDIF
 !-
@@ -1575,10 +1305,9 @@
       blk = INDEX(NEW_str(1:len_str),' ')
       IF (blk > 1) THEN
-        WRITE(*,*) &
- &       'This is a strange behavior of getin_decrypt you could report'
-      ENDIF
-      WRITE(chlen,'(I3.3)') LEN_TRIM(mult)
-      fmt = '(I'//chlen//')'
-      READ(mult,fmt) compline(nb_lines)
+        CALL ipslerr (2,'getin_decrypt', &
+ &       'This is a strange behavior','you could report',' ')
+      ENDIF
+      WRITE (UNIT=c_fmt,FMT='("(I",I5.5,")")') LEN_TRIM(mult)
+      READ(UNIT=mult,FMT=c_fmt) compline(nb_lines)
 !---
     ELSE
@@ -1588,5 +1317,5 @@
 !-- If there is no space wthin the line then the target is a scalar
 !-- or the element of a properly written vector.
-!-- (ie of the type TARGET__1)
+!-- (ie of the type TARGET__00001)
 !-
     IF (    (blk <= 1) &
@@ -1597,14 +1326,15 @@
 !------ Save info of current keyword as a scalar
 !------ if it is not a continuation
-        targetlist(nb_lines) = key_str(1:MIN(len_trim(key_str),30))
-        last_key = key_str(1:MIN(len_trim(key_str),30))
+        targetlist(nb_lines) = key_str(1:MIN(LEN_TRIM(key_str),l_n))
+        last_key = key_str(1:MIN(LEN_TRIM(key_str),l_n))
         nb_lastkey = 1
       ELSE
 !------ We are continuing a vector so the keyword needs
 !------ to get the underscores
-        WRITE(cnt,'(I3.3)') nb_lastkey+1
+        WRITE(UNIT=cnt,FMT=c_i_fmt) nb_lastkey+1
         targetlist(nb_lines) = &
- &        key_str(1:MIN(len_trim(key_str),25))//'__'//cnt
-        last_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt
+ &        key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
+        last_key = &
+ &        key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
         nb_lastkey = nb_lastkey+1
       ENDIF
@@ -1617,20 +1347,17 @@
 !---- If there are blanks whithin the line then we are dealing
 !---- with a vector and we need to split it in many entries
-!---- with the TRAGET__1 notation.
+!---- with the TARGET__n notation.
 !----
 !---- Test if the targer is not already a vector target !
 !-
       IF (INDEX(TRIM(key_str),'__') > 0) THEN
-        WRITE(*,*) 'ERROR : getin_decrypt'
-        WRITE(*,*) 'We have found a mixed vector notation'
-        WRITE(*,*) 'If a target is of the type TARGET__1'
-        WRITE(*,*) 'then only a scalar value is allowed'
-        WRITE(*,*) 'The key at fault : ',key_str(1:len_TRIM(key_str))
-        STOP 'getin_decrypt'
+        CALL ipslerr (3,'getin_decrypt', &
+ &       'We have found a mixed vector notation (TARGET__n).', &
+ &       'The key at fault : '//TRIM(key_str),' ')
       ENDIF
 !-
       nbve = nb_lastkey
       nbve = nbve+1
-      WRITE(cnt,'(I3.3)') nbve
+      WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
 !-
       DO WHILE (blk > 0)
@@ -1639,6 +1366,7 @@
 !-
         fichier(nb_lines) = tmp_str(1:blk)
-        new_key =  key_str(1:MIN(len_trim(key_str),25))//'__'//cnt
-        targetlist(nb_lines) = new_key(1:MIN(len_trim(new_key),30))
+        new_key = &
+ &       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
@@ -1649,11 +1377,11 @@
         nb_lines = nb_lines+1
         IF (nb_lines > max_lines) THEN
-          WRITE(*,*) &
- &          'Too many line in the run.def files. You need to increase'
-          WRITE(*,*) 'the parameter max_lines in the module getincom.'
-          STOP 'getin_decrypt'
+          CALL ipslerr (3,'getin_decrypt', &
+ &         'Too many lines in the run.def files.', &
+ &         'You need to increase', &
+ &         'the parameter max_lines in the module getincom.')
         ENDIF
         nbve = nbve+1
-        WRITE(cnt,'(I3.3)') nbve
+        WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
 !-
       ENDDO
@@ -1662,10 +1390,12 @@
 !-
       fichier(nb_lines) = tmp_str(1:LEN_TRIM(tmp_str))
-      new_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt
-      targetlist(nb_lines) = new_key(1:MIN(len_trim(new_key),30))
+      new_key = &
+ &      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
 !-
-      last_key = key_str(1:MIN(len_trim(key_str),25))//'__'//cnt
+      last_key = &
+ &      key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
       nb_lastkey = nbve
 !-
@@ -1684,12 +1414,5 @@
   IMPLICIT NONE
 !-
-! Arguments
-!-
-!-
-! LOCAL
-!-
-  INTEGER :: line,i,sig
-  INTEGER :: found
-  CHARACTER(LEN=30) :: str
+  INTEGER :: line,found
 !---------------------------------------------------------------------
   DO line=1,nb_lines-1
@@ -1706,5 +1429,5 @@
 !-----
       WRITE(*,*) &
- & 'getin_checkcohe : Found a problem on key ',targetlist(line)
+ & 'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line))
       WRITE(*,*) &
  & 'getin_checkcohe : The following values were encoutered :'
@@ -1721,5 +1444,5 @@
     ENDIF
   ENDDO
-!-
+!-----------------------------
 END SUBROUTINE getin_checkcohe
 !-
@@ -1730,5 +1453,5 @@
   IMPLICIT NONE
 !-
-  INTEGER :: unit, eof, nb_lastkey
+  INTEGER :: unit,eof,nb_lastkey
   CHARACTER(LEN=100) :: dummy
   CHARACTER(LEN=100) :: out_string
@@ -1740,5 +1463,5 @@
 !-
   DO WHILE (first == "#")
-    READ (unit,'(a100)',ERR=9998,END=7778) dummy
+    READ (UNIT=unit,FMT='(A)',ERR=9998,END=7778) dummy
     dummy = TRIM(ADJUSTL(dummy))
     first=dummy(1:1)
@@ -1751,338 +1474,12 @@
   RETURN
 !-
-9998 WRITE(*,*) " GETIN_SKIPAFEW : Error while reading file "
-  STOP 'getin_skipafew'
-!-
-7778 eof = 1
+9998 CONTINUE
+  CALL ipslerr (3,'getin_skipafew','Error while reading file',' ',' ')
+!-
+7778 CONTINUE
+  eof = 1
 !----------------------------
 END SUBROUTINE getin_skipafew
 !-
-!=== INTEGER database INTERFACE
-!-
-SUBROUTINE getdbwi &
- &  (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Write the INTEGER data into the data base
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
-  INTEGER :: target_sig, status, fileorig, size_of_in
-  INTEGER,DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-!-
-! First check if we have sufficiant space for the new key
-!-
-  IF (nb_keys+1 > keymemsize) THEN
-    CALL getin_allockeys ()
-  ENDIF
-!-
-! 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),30))
-  keystatus(nb_keys) = status
-  keytype(nb_keys) = 1
-  keyfromfile(nb_keys) = fileorig
-!-
-! Can we compress the data base entry ?
-!-
-  IF (     (MINVAL(tmp_ret_val) == MAXVAL(tmp_ret_val)) &
- &    .AND.(size_of_in > compress_lim)) THEN
-    keymemstart(nb_keys) = intmempos+1
-    keycompress(nb_keys) = size_of_in
-    keymemlen(nb_keys) = 1
-  ELSE
-    keymemstart(nb_keys) = intmempos+1
-    keycompress(nb_keys) = -1
-    keymemlen(nb_keys) = size_of_in
-  ENDIF
-!-
-! Before writing the actual size lets see if we have the space
-!-
-  IF (keymemstart(nb_keys)+keymemlen(nb_keys) > intmemsize) THEN
-    CALL getin_allocmem (1,keymemlen(nb_keys))
-  ENDIF
-!-
-  intmem(keymemstart(nb_keys): &
- &       keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &
- &  tmp_ret_val(1:keymemlen(nb_keys))
-  intmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-1
-!---------------------
-END SUBROUTINE getdbwi
-!-
-!===
-!-
-SUBROUTINE getdbri (pos,size_of_in,target,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Read the required variables in the database for INTEGERS
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: pos, size_of_in
-  CHARACTER(LEN=*) :: target
-  INTEGER,DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-  IF (keytype(pos) /= 1) THEN
-    WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target
-    STOP 'getdbri'
-  ENDIF
-!-
-  IF (keycompress(pos) > 0) THEN
-    IF ( keycompress(pos) /= size_of_in .OR. keymemlen(pos) /= 1 ) THEN
-      WRITE(*,*) &
- &      'FATAL ERROR : Wrong compression length for keyword ',target
-      STOP 'getdbri'
-    ELSE
-      tmp_ret_val(1:size_of_in) = intmem(keymemstart(pos))
-    ENDIF
-  ELSE
-    IF (keymemlen(pos) /= size_of_in) THEN
-      WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target
-      STOP 'getdbri'
-    ELSE
-      tmp_ret_val(1:size_of_in) = &
- &      intmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
-    ENDIF
-  ENDIF
-!---------------------
-END SUBROUTINE getdbri
-!-
-!=== REAL database INTERFACE
-!-
-SUBROUTINE getdbwr &
- &  (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Write the REAL data into the data base
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
-  INTEGER :: target_sig, status, fileorig, size_of_in
-  REAL,DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-!-
-! First check if we have sufficiant space for the new key
-!-
-  IF (nb_keys+1 > keymemsize) THEN
-    CALL getin_allockeys ()
-  ENDIF
-!-
-! 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),30))
-  keystatus(nb_keys) = status
-  keytype(nb_keys) = 2
-  keyfromfile(nb_keys) = fileorig
-!-
-! Can we compress the data base entry ?
-!-
-  IF (     (MINVAL(tmp_ret_val) == MAXVAL(tmp_ret_val)) &
-&     .AND.(size_of_in > compress_lim)) THEN
-    keymemstart(nb_keys) = realmempos+1
-    keycompress(nb_keys) = size_of_in
-    keymemlen(nb_keys) = 1
-  ELSE
-    keymemstart(nb_keys) = realmempos+1
-    keycompress(nb_keys) = -1
-    keymemlen(nb_keys) = size_of_in
-  ENDIF
-!-
-! Before writing the actual size lets see if we have the space
-!-
-  IF (keymemstart(nb_keys)+keymemlen(nb_keys) > realmemsize) THEN
-    CALL getin_allocmem (2,keymemlen(nb_keys))
-  ENDIF
-!-
-  realmem(keymemstart(nb_keys): &
- &        keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &
- &  tmp_ret_val(1:keymemlen(nb_keys))
-  realmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-1
-!---------------------
-END SUBROUTINE getdbwr
-!-
-!===
-!-
-SUBROUTINE getdbrr (pos,size_of_in,target,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Read the required variables in the database for REALS
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: pos, size_of_in
-  CHARACTER(LEN=*) :: target
-  REAL,DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-  IF (keytype(pos) /= 2) THEN
-    WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target
-    STOP 'getdbrr'
-  ENDIF
-!-
-  IF (keycompress(pos) > 0) THEN
-    IF (    (keycompress(pos) /= size_of_in) &
- &      .OR.(keymemlen(pos) /= 1) ) THEN
-      WRITE(*,*) &
- &      'FATAL ERROR : Wrong compression length for keyword ',target
-      STOP 'getdbrr'
-    ELSE
-      tmp_ret_val(1:size_of_in) = realmem(keymemstart(pos))
-    ENDIF
-  ELSE
-    IF (keymemlen(pos) /= size_of_in) THEN
-      WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target
-      STOP 'getdbrr'
-    ELSE
-      tmp_ret_val(1:size_of_in) = &
- &      realmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
-    ENDIF
-  ENDIF
-!---------------------
-END SUBROUTINE getdbrr
-!-
-!=== CHARACTER database INTERFACE
-!-
-SUBROUTINE getdbwc &
- &  (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Write the CHARACTER data into the data base
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
-  INTEGER :: target_sig,status,fileorig,size_of_in
-  CHARACTER(LEN=*),DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-!-
-! First check if we have sufficiant space for the new key
-!-
-  IF (nb_keys+1 > keymemsize) THEN
-    CALL getin_allockeys ()
-  ENDIF
-!-
-! 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),30))
-  keystatus(nb_keys) = status
-  keytype(nb_keys) = 3
-  keyfromfile(nb_keys) = fileorig
-  keymemstart(nb_keys) = charmempos+1
-  keymemlen(nb_keys) = size_of_in
-!-
-! Before writing the actual size lets see if we have the space
-!-
-  IF (keymemstart(nb_keys)+keymemlen(nb_keys) > realmemsize) THEN
-    CALL getin_allocmem (3,keymemlen(nb_keys))
-  ENDIF
-!-
-  charmem(keymemstart(nb_keys): &
- &        keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &
- &  tmp_ret_val(1:keymemlen(nb_keys))
-  charmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-1
-!---------------------
-END SUBROUTINE getdbwc
-!-
-!===
-!-
-SUBROUTINE getdbrc(pos,size_of_in,target,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Read the required variables in the database for CHARACTER
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: pos, size_of_in
-  CHARACTER(LEN=*) :: target
-  CHARACTER(LEN=*),DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-  IF (keytype(pos) /= 3) THEN
-    WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target
-    STOP 'getdbrc'
-  ENDIF
-!-
-  IF (keymemlen(pos) /= size_of_in) THEN
-    WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target
-    STOP 'getdbrc'
-  ELSE
-    tmp_ret_val(1:size_of_in) = &
- &    charmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
-  ENDIF
-!---------------------
-END SUBROUTINE getdbrc
-!-
-!=== LOGICAL database INTERFACE
-!-
-SUBROUTINE getdbwl &
- &  (target,target_sig,status,fileorig,size_of_in,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Write the LOGICAL data into the data base
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  CHARACTER(LEN=*) :: target
-  INTEGER :: target_sig, status, fileorig, size_of_in
-  LOGICAL,DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-!-
-! First check if we have sufficiant space for the new key
-!-
-  IF (nb_keys+1 > keymemsize) THEN
-    CALL getin_allockeys ()
-  ENDIF
-!-
-! 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),30))
-  keystatus(nb_keys) = status
-  keytype(nb_keys) = 4
-  keyfromfile(nb_keys) = fileorig
-  keymemstart(nb_keys) = logicmempos+1
-  keymemlen(nb_keys) = size_of_in
-!-
-! Before writing the actual size lets see if we have the space
-!-
-  IF (keymemstart(nb_keys)+keymemlen(nb_keys) > logicmemsize) THEN
-    CALL getin_allocmem (4,keymemlen(nb_keys))
-  ENDIF
-!-
-  logicmem(keymemstart(nb_keys): &
- &         keymemstart(nb_keys)+keymemlen(nb_keys)-1) = &
- &  tmp_ret_val(1:keymemlen(nb_keys))
-  logicmempos = keymemstart(nb_keys)+keymemlen(nb_keys)-1
-!---------------------
-END SUBROUTINE getdbwl
-!-
-!===
-!-
-SUBROUTINE getdbrl(pos,size_of_in,target,tmp_ret_val)
-!---------------------------------------------------------------------
-!- Read the required variables in the database for LOGICALS
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: pos, size_of_in
-  CHARACTER(LEN=*) :: target
-  LOGICAL,DIMENSION(:) :: tmp_ret_val
-!---------------------------------------------------------------------
-  IF (keytype(pos) /= 4) THEN
-    WRITE(*,*) 'FATAL ERROR : Wrong data type for keyword ',target
-    STOP 'getdbrl'
-  ENDIF
-!-
-  IF (keymemlen(pos) /= size_of_in) THEN
-    WRITE(*,*) 'FATAL ERROR : Wrong array length for keyword ',target
-    STOP 'getdbrl'
-  ELSE
-    tmp_ret_val(1:size_of_in) = &
- &    logicmem(keymemstart(pos):keymemstart(pos)+keymemlen(pos)-1)
-  ENDIF
-!---------------------
-END SUBROUTINE getdbrl
-!-
 !===
 !-
@@ -2095,4 +1492,5 @@
 !-
   INTEGER :: ier
+  CHARACTER(LEN=20) :: c_tmp
 !---------------------------------------------------------------------
 !-
@@ -2100,185 +1498,173 @@
 !-
   IF (keymemsize == 0) THEN
-!-
+!---
+    WRITE (UNIT=c_tmp,FMT=*) memslabs
+!---
     ALLOCATE(keysig(memslabs),stat=ier)
     IF (ier /= 0) THEN
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keysig to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate keysig', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+    ENDIF
+!---
     ALLOCATE(keystr(memslabs),stat=ier)
     IF (ier /= 0) THEN
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keystr to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate keystr', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+    ENDIF
+!---
     ALLOCATE(keystatus(memslabs),stat=ier)
     IF (ier /= 0) THEN
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keystatus to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate keystatus', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+    ENDIF
+!---
     ALLOCATE(keytype(memslabs),stat=ier)
     IF (ier /= 0) THEN
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keytype to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keycompress to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keyfromfile to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keymemstart to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keymemlen to size ', &
- &      memslabs
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate tmp_str to size ', &
- &      keymemsize
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate tmp_int to size ', &
- &      keymemsize
-      STOP
-    ENDIF
-!-
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keysig to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keystr to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keystatus to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keytype to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keycompress to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keyfromfile to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keymemstart to size ', &
- &      keymemsize+memslabs
-      STOP
+      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
-      WRITE(*,*) &
- &      'getin_allockeys : Can not allocate keymemlen to size ', &
- &      keymemsize+memslabs
-      STOP
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate keymemlen', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
     ENDIF
     keymemlen(1:keymemsize) = tmp_int(1:keymemsize)
-!-
+!---
     keymemsize = keymemsize+memslabs
-!-
+!---
     DEALLOCATE(tmp_int)
     DEALLOCATE(tmp_str)
@@ -2292,13 +1678,9 @@
 !---------------------------------------------------------------------
 !- Allocate the memory of the data base for all 4 types of memory
-!-
-!- 1 = INTEGER
-!- 2 = REAL
-!- 3 = CHAR
-!- 4 = LOGICAL
-!---------------------------------------------------------------------
-  IMPLICIT NONE
-!-
-  INTEGER :: type, len_wanted
+!- INTEGER / REAL / CHAR / LOGICAL
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: type,len_wanted
 !-
   INTEGER,ALLOCATABLE :: tmp_int(:)
@@ -2307,133 +1689,133 @@
   LOGICAL,ALLOCATABLE :: tmp_logic(:)
   INTEGER :: ier
+  CHARACTER(LEN=20) :: c_tmp
 !---------------------------------------------------------------------
   SELECT CASE (type)
-  CASE(1)
-    IF (intmemsize == 0) THEN
-      ALLOCATE(intmem(memslabs),stat=ier)
+  CASE(k_i)
+    IF (i_memsize == 0) THEN
+      ALLOCATE(i_mem(memslabs),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate db-memory intmem to ', &
- &    memslabs
-        STOP
-      ENDIF
-      intmemsize=memslabs
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      i_memsize=memslabs
     ELSE
-      ALLOCATE(tmp_int(intmemsize),stat=ier)
+      ALLOCATE(tmp_int(i_memsize),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate tmp_int to ', &
- &    intmemsize
-        STOP
-      ENDIF
-      tmp_int(1:intmemsize) = intmem(1:intmemsize)
-      DEALLOCATE(intmem)
-      ALLOCATE(intmem(intmemsize+MAX(memslabs,len_wanted)),stat=ier)
+        WRITE (UNIT=c_tmp,FMT=*) i_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_int', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_int(1:i_memsize) = i_mem(1:i_memsize)
+      DEALLOCATE(i_mem)
+      ALLOCATE(i_mem(i_memsize+MAX(memslabs,len_wanted)),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to re-allocate db-memory intmem to ', &
- &    intmemsize+MAX(memslabs,len_wanted)
-        STOP
-      ENDIF
-      intmem(1:intmemsize) = tmp_int(1:intmemsize)
-      intmemsize = intmemsize+MAX(memslabs,len_wanted)
+        WRITE (UNIT=c_tmp,FMT=*) i_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      i_mem(1:i_memsize) = tmp_int(1:i_memsize)
+      i_memsize = i_memsize+MAX(memslabs,len_wanted)
       DEALLOCATE(tmp_int)
     ENDIF
-  CASE(2)
-    IF (realmemsize == 0) THEN
-      ALLOCATE(realmem(memslabs),stat=ier)
+  CASE(k_r)
+    IF (r_memsize == 0) THEN
+      ALLOCATE(r_mem(memslabs),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate db-memory realmem to ', &
- &    memslabs
-        STOP
-      ENDIF
-      realmemsize =  memslabs
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      r_memsize =  memslabs
     ELSE
-      ALLOCATE(tmp_real(realmemsize),stat=ier)
+      ALLOCATE(tmp_real(r_memsize),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate tmp_real to ', &
- &    realmemsize
-        STOP
-      ENDIF
-      tmp_real(1:realmemsize) = realmem(1:realmemsize)
-      DEALLOCATE(realmem)
-      ALLOCATE(realmem(realmemsize+MAX(memslabs,len_wanted)),stat=ier)
+        WRITE (UNIT=c_tmp,FMT=*) r_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_real', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_real(1:r_memsize) = r_mem(1:r_memsize)
+      DEALLOCATE(r_mem)
+      ALLOCATE(r_mem(r_memsize+MAX(memslabs,len_wanted)),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to re-allocate db-memory realmem to ', &
- &    realmemsize+MAX(memslabs,len_wanted)
-        STOP
-      ENDIF
-      realmem(1:realmemsize) = tmp_real(1:realmemsize)
-      realmemsize = realmemsize+MAX(memslabs,len_wanted)
+        WRITE (UNIT=c_tmp,FMT=*) r_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      r_mem(1:r_memsize) = tmp_real(1:r_memsize)
+      r_memsize = r_memsize+MAX(memslabs,len_wanted)
       DEALLOCATE(tmp_real)
     ENDIF
-  CASE(3)
-    IF (charmemsize == 0) THEN
-      ALLOCATE(charmem(memslabs),stat=ier)
+  CASE(k_c)
+    IF (c_memsize == 0) THEN
+      ALLOCATE(c_mem(memslabs),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate db-memory charmem to ', &
- &    memslabs
-        STOP
-      ENDIF
-      charmemsize = memslabs
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      c_memsize = memslabs
     ELSE
-      ALLOCATE(tmp_char(charmemsize),stat=ier)
+      ALLOCATE(tmp_char(c_memsize),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate tmp_char to ', &
- &    charmemsize
-        STOP
-      ENDIF
-      tmp_char(1:charmemsize) = charmem(1:charmemsize)
-      DEALLOCATE(charmem)
-      ALLOCATE(charmem(charmemsize+MAX(memslabs,len_wanted)),stat=ier)
+        WRITE (UNIT=c_tmp,FMT=*) c_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_char', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_char(1:c_memsize) = c_mem(1:c_memsize)
+      DEALLOCATE(c_mem)
+      ALLOCATE(c_mem(c_memsize+MAX(memslabs,len_wanted)),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to re-allocate db-memory charmem to ', &
- &    charmemsize+MAX(memslabs,len_wanted)
-        STOP
-      ENDIF
-      charmem(1:charmemsize) = tmp_char(1:charmemsize)
-      charmemsize = charmemsize+MAX(memslabs,len_wanted)
+        WRITE (UNIT=c_tmp,FMT=*) c_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      c_mem(1:c_memsize) = tmp_char(1:c_memsize)
+      c_memsize = c_memsize+MAX(memslabs,len_wanted)
       DEALLOCATE(tmp_char)
     ENDIF
-  CASE(4)
-    IF (logicmemsize == 0) THEN
-      ALLOCATE(logicmem(memslabs),stat=ier)
+  CASE(k_l)
+    IF (l_memsize == 0) THEN
+      ALLOCATE(l_mem(memslabs),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate db-memory logicmem to ', &
- &    memslabs
-        STOP
-      ENDIF
-      logicmemsize = memslabs
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      l_memsize = memslabs
     ELSE
-      ALLOCATE(tmp_logic(logicmemsize),stat=ier)
+      ALLOCATE(tmp_logic(l_memsize),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to allocate tmp_logic to ', &
- &    logicmemsize
-        STOP
-      ENDIF
-      tmp_logic(1:logicmemsize) = logicmem(1:logicmemsize)
-      DEALLOCATE(logicmem)
-      ALLOCATE(logicmem(logicmemsize+MAX(memslabs,len_wanted)),stat=ier)
+        WRITE (UNIT=c_tmp,FMT=*) l_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_logic', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_logic(1:l_memsize) = l_mem(1:l_memsize)
+      DEALLOCATE(l_mem)
+      ALLOCATE(l_mem(l_memsize+MAX(memslabs,len_wanted)),stat=ier)
       IF (ier /= 0) THEN
-        WRITE(*,*) &
- &    'getin_allocmem : Unable to re-allocate db-memory logicmem to ', &
- &    logicmemsize+MAX(memslabs,len_wanted)
-        STOP
-      ENDIF
-      logicmem(1:logicmemsize) = tmp_logic(1:logicmemsize)
-      logicmemsize = logicmemsize+MAX(memslabs,len_wanted)
+        WRITE (UNIT=c_tmp,FMT=*) l_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      l_mem(1:l_memsize) = tmp_logic(1:l_memsize)
+      l_memsize = l_memsize+MAX(memslabs,len_wanted)
       DEALLOCATE(tmp_logic)
     ENDIF
   CASE DEFAULT
-    WRITE(*,*) 'getin_allocmem : Unknown type : ',type
-    STOP
+    CALL ipslerr (3,'getin_allocmem','Unknown type of data',' ',' ')
   END SELECT
 !----------------------------
@@ -2456,12 +1838,14 @@
   CHARACTER(*),OPTIONAL :: fileprefix
 !-
-  CHARACTER(LEN=80) :: usedfileprefix = "used"
+  CHARACTER(LEN=80) :: usedfileprefix
   INTEGER :: ikey,if,iff,iv
-  CHARACTER(LEN=3) :: tmp3
-  CHARACTER(LEN=100) :: tmp_str, used_filename
+  CHARACTER(LEN=20) :: c_tmp
+  CHARACTER(LEN=100) :: tmp_str,used_filename
   LOGICAL :: check = .FALSE.
 !---------------------------------------------------------------------
   IF (PRESENT(fileprefix)) THEN
-    usedfileprefix = fileprefix(1:MIN(len_trim(fileprefix),80))
+    usedfileprefix = fileprefix(1:MIN(LEN_TRIM(fileprefix),80))
+  ELSE
+    usedfileprefix = "used"
   ENDIF
 !-
@@ -2474,131 +1858,160 @@
       WRITE(*,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys
     ENDIF
-    OPEN(unit=76,file=used_filename)
-!-
+    OPEN (UNIT=22,FILE=used_filename)
+!---
 !-- If this is the first file we need to add the list
 !-- of file which belong to it
-!-
-    IF ( (if == 1) .AND. (nbfiles > 1) ) THEN
-      WRITE(76,*) '# '
-      WRITE(76,*) '# This file is linked to the following files :'
-      WRITE(76,*) '# '
+    IF ( (if == 1).AND.(nbfiles > 1) ) THEN
+      WRITE(22,*) '# '
+      WRITE(22,*) '# This file is linked to the following files :'
+      WRITE(22,*) '# '
       DO iff=2,nbfiles
-        WRITE(76,*) 'INCLUDEDEF = ',TRIM(filelist(iff))
+        WRITE(22,*) 'INCLUDEDEF = ',TRIM(filelist(iff))
       ENDDO
-      WRITE(76,*) '# '
+      WRITE(22,*) '# '
     ENDIF
 !---
     DO ikey=1,nb_keys
-!-
-!---- Is this key form this file ?
-!-
+!-----
+!---- Is this key from this file ?
       IF (keyfromfile(ikey) == if) THEN
-!-
-!---- Write some comments
-!-
-        WRITE(76,*) '#'
+!-------
+!------ Write some comments
+        WRITE(22,*) '#'
         SELECT CASE (keystatus(ikey))
         CASE(1)
-          WRITE(76,*) '# Values of ', &
+          WRITE(22,*) '# Values of ', &
  &          TRIM(keystr(ikey)),' comes from the run.def.'
         CASE(2)
-          WRITE(76,*) '# Values of ', &
+          WRITE(22,*) '# Values of ', &
  &          TRIM(keystr(ikey)),' are all defaults.'
         CASE(3)
-          WRITE(76,*) '# Values of ', &
+          WRITE(22,*) '# Values of ', &
  &          TRIM(keystr(ikey)),' are a mix of run.def and defaults.'
         CASE DEFAULT
-          WRITE(76,*) '# Dont know from where the value of ', &
+          WRITE(22,*) '# Dont know from where the value of ', &
  &          TRIM(keystr(ikey)),' comes.'
         END SELECT
-        WRITE(76,*) '#'
-!-
-!---- Write the values
-!-
+        WRITE(22,*) '#'
+!-------
+!------ Write the values
         SELECT CASE (keytype(ikey))
-!-
-        CASE(1)
+        CASE(k_i)
           IF (keymemlen(ikey) == 1) THEN
             IF (keycompress(ikey) < 0) THEN
-              WRITE(76,*) &
- &              TRIM(keystr(ikey)),' = ',intmem(keymemstart(ikey))
+              WRITE(22,*) &
+ &              TRIM(keystr(ikey)),' = ',i_mem(keymemstart(ikey))
             ELSE
-              WRITE(76,*) &
+              WRITE(22,*) &
  &              TRIM(keystr(ikey)),' = ',keycompress(ikey), &
- &              ' * ',intmem(keymemstart(ikey))
+ &              ' * ',i_mem(keymemstart(ikey))
             ENDIF
           ELSE
             DO iv=0,keymemlen(ikey)-1
-              WRITE(tmp3,'(I3.3)') iv+1
-              WRITE(76,*) &
- &              TRIM(keystr(ikey)),'__',tmp3, &
- &              ' = ',intmem(keymemstart(ikey)+iv)
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              WRITE(22,*) &
+ &              TRIM(keystr(ikey)),'__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',i_mem(keymemstart(ikey)+iv)
             ENDDO
           ENDIF
-!-
-        CASE(2)
+        CASE(k_r)
           IF (keymemlen(ikey) == 1) THEN
             IF (keycompress(ikey) < 0) THEN
-              WRITE(76,*) &
- &              TRIM(keystr(ikey)),' = ',realmem(keymemstart(ikey))
+              WRITE(22,*) &
+ &              TRIM(keystr(ikey)),' = ',r_mem(keymemstart(ikey))
             ELSE
-              WRITE(76,*) &
+              WRITE(22,*) &
  &              TRIM(keystr(ikey)),' = ',keycompress(ikey),&
-                   & ' * ',realmem(keymemstart(ikey))
+                   & ' * ',r_mem(keymemstart(ikey))
             ENDIF
           ELSE
             DO iv=0,keymemlen(ikey)-1
-              WRITE(tmp3,'(I3.3)') iv+1
-              WRITE(76,*) &
- &              TRIM(keystr(ikey)),'__',tmp3, &
- &              ' = ',realmem(keymemstart(ikey)+iv)
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              WRITE(22,*) &
+ &              TRIM(keystr(ikey)),'__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',r_mem(keymemstart(ikey)+iv)
             ENDDO
           ENDIF
-        CASE(3)
+        CASE(k_c)
           IF (keymemlen(ikey) == 1) THEN
-            tmp_str = charmem(keymemstart(ikey))
-            WRITE(76,*) TRIM(keystr(ikey)),' = ',TRIM(tmp_str)
+            tmp_str = c_mem(keymemstart(ikey))
+            WRITE(22,*) TRIM(keystr(ikey)),' = ',TRIM(tmp_str)
           ELSE
             DO iv=0,keymemlen(ikey)-1
-              WRITE(tmp3,'(I3.3)') iv+1
-              tmp_str = charmem(keymemstart(ikey)+iv)
-              WRITE(76,*) &
- &              TRIM(keystr(ikey)),'__',tmp3,' = ',TRIM(tmp_str)
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              tmp_str = c_mem(keymemstart(ikey)+iv)
+              WRITE(22,*) &
+ &              TRIM(keystr(ikey)),'__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',TRIM(tmp_str)
             ENDDO
           ENDIF
-        CASE(4)
+        CASE(k_l)
           IF (keymemlen(ikey) == 1) THEN
-            IF (logicmem(keymemstart(ikey))) THEN
-              WRITE(76,*) TRIM(keystr(ikey)),' = TRUE '
+            IF (l_mem(keymemstart(ikey))) THEN
+              WRITE(22,*) TRIM(keystr(ikey)),' = TRUE '
             ELSE
-              WRITE(76,*) TRIM(keystr(ikey)),' = FALSE '
+              WRITE(22,*) TRIM(keystr(ikey)),' = FALSE '
             ENDIF
           ELSE
             DO iv=0,keymemlen(ikey)-1
-              WRITE(tmp3,'(I3.3)') iv+1
-              IF (logicmem(keymemstart(ikey)+iv)) THEN
-                WRITE(76,*) TRIM(keystr(ikey)),'__',tmp3,' = TRUE '
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              IF (l_mem(keymemstart(ikey)+iv)) THEN
+                WRITE(22,*) TRIM(keystr(ikey)),'__', &
+ &                          TRIM(ADJUSTL(c_tmp)),' = TRUE '
               ELSE
-                WRITE(76,*) TRIM(keystr(ikey)),'__',tmp3,' = FALSE '
+                WRITE(22,*) TRIM(keystr(ikey)),'__', &
+ &                          TRIM(ADJUSTL(c_tmp)),' = FALSE '
               ENDIF
             ENDDO
           ENDIF
-!-
         CASE DEFAULT
-          WRITE(*,*) &
- &          'FATAL ERROR : Unknown type for variable ', &
- &          TRIM(keystr(ikey))
-          STOP 'getin_dump'
+          CALL ipslerr (3,'getin_dump', &
+ &         'Unknown type for variable '//TRIM(keystr(ikey)),' ',' ')
         END SELECT
       ENDIF
     ENDDO
 !-
-    CLOSE(unit=76)
+    CLOSE(UNIT=22)
 !-
   ENDDO
 !------------------------
 END SUBROUTINE getin_dump
-!-
 !===
-!-
+SUBROUTINE get_qtyp (k_typ,c_vtyp,i_v,r_v,c_v,l_v)
+!---------------------------------------------------------------------
+!- Returns the type of the argument (mutually exclusive)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(OUT) :: k_typ
+  CHARACTER(LEN=*),INTENT(OUT) :: c_vtyp
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_v
+  REAL,DIMENSION(:),OPTIONAL             :: r_v
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_v
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_v
+!---------------------------------------------------------------------
+  k_typ = 0
+  IF (COUNT((/PRESENT(i_v),PRESENT(r_v),PRESENT(c_v),PRESENT(l_v)/)) &
+ &    /= 1) THEN
+    CALL ipslerr (3,'get_qtyp', &
+ &   'Invalid number of optional arguments','(/= 1)',' ')
+  ENDIF
+!-
+  IF     (PRESENT(i_v)) THEN
+    k_typ = k_i
+    c_vtyp = 'INTEGER'
+  ELSEIF (PRESENT(r_v)) THEN
+    k_typ = k_r
+    c_vtyp = 'REAL'
+  ELSEIF (PRESENT(c_v)) THEN
+    k_typ = k_c
+    c_vtyp = 'CHARACTER'
+  ELSEIF (PRESENT(l_v)) THEN
+    k_typ = k_l
+    c_vtyp = 'LOGICAL'
+  ENDIF
+!----------------------
+END SUBROUTINE get_qtyp
+!===
+!------------------
 END MODULE getincom
Index: IOIPSL/trunk/src/histcom.f90
===================================================================
--- IOIPSL/trunk/src/histcom.f90	(revision 10)
+++ IOIPSL/trunk/src/histcom.f90	(revision 11)
@@ -1,5 +1,5 @@
 MODULE histcom
 !-
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/histcom.f90,v 2.3 2005/10/10 08:02:57 adm Exp $
+!$Id$
 !-
   USE netcdf
Index: IOIPSL/trunk/src/ioipsl.f90
===================================================================
--- IOIPSL/trunk/src/ioipsl.f90	(revision 10)
+++ IOIPSL/trunk/src/ioipsl.f90	(revision 11)
@@ -1,5 +1,6 @@
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/ioipsl.f90,v 2.2 2005/10/10 08:02:57 adm Exp $
+MODULE ioipsl
 !
-MODULE ioipsl
+!$Id$
+!
   USE errioipsl 
   USE stringop
Index: IOIPSL/trunk/src/mathelp.f90
===================================================================
--- IOIPSL/trunk/src/mathelp.f90	(revision 10)
+++ IOIPSL/trunk/src/mathelp.f90	(revision 11)
@@ -1,3 +1,3 @@
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/mathelp.f90,v 2.2 2005/03/31 07:38:00 adm Exp $
+!$Id$
 !
 MODULE mathelp
Index: IOIPSL/trunk/src/restcom.f90
===================================================================
--- IOIPSL/trunk/src/restcom.f90	(revision 10)
+++ IOIPSL/trunk/src/restcom.f90	(revision 11)
@@ -1,5 +1,5 @@
 MODULE restcom
 !-
-!$Header: /home/ioipsl/CVSROOT/IOIPSL/src/restcom.f90,v 2.5 2005/10/27 07:25:58 adm Exp $
+!$Id$
 !-
 USE netcdf
