Index: LMDZ6/branches/contrails/libf/misc/strings_mod.f90
===================================================================
--- LMDZ6/branches/contrails/libf/misc/strings_mod.f90	(revision 5418)
+++ LMDZ6/branches/contrails/libf/misc/strings_mod.f90	(revision 5618)
@@ -138,5 +138,5 @@
 END SUBROUTINE msg_m
 !==============================================================================================================================
-LOGICAL FUNCTION fmsg_1(str, modname, ll, unit) RESULT(l)
+ FUNCTION fmsg_1(str, modname, ll, unit) RESULT(l)
   IMPLICIT NONE
   CHARACTER(LEN=*),           INTENT(IN) :: str
@@ -144,4 +144,5 @@
   LOGICAL,          OPTIONAL, INTENT(IN) :: ll
   INTEGER,          OPTIONAL, INTENT(IN) :: unit
+  LOGICAL                                :: l
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: subn
@@ -153,5 +154,5 @@
 END FUNCTION fmsg_1
 !==============================================================================================================================
-LOGICAL FUNCTION fmsg_m(str, modname, ll, unit, nmax) RESULT(l)
+ FUNCTION fmsg_m(str, modname, ll, unit, nmax) RESULT(l)
   IMPLICIT NONE
   CHARACTER(LEN=*),           INTENT(IN)  :: str(:)
@@ -160,4 +161,5 @@
   INTEGER,          OPTIONAL, INTENT(IN) :: unit
   INTEGER,          OPTIONAL, INTENT(IN)  :: nmax
+  LOGICAL                                 :: l
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: subn
@@ -175,8 +177,9 @@
 !=== Lower/upper case conversion function. ====================================================================================
 !==============================================================================================================================
-ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION strLower(str) RESULT(out)
+ELEMENTAL FUNCTION strLower(str) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
   INTEGER :: k
+  CHARACTER(LEN=maxlen) :: out
   out = str
   DO k=1,LEN_TRIM(str)
@@ -185,8 +188,9 @@
 END FUNCTION strLower
 !==============================================================================================================================
-ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION strUpper(str) RESULT(out)
+ELEMENTAL FUNCTION strUpper(str) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
   INTEGER :: k
+  CHARACTER(LEN=maxlen)  :: out
   out = str
   DO k=1,LEN_TRIM(str)
@@ -203,9 +207,10 @@
 !===    * strHead(..,.TRUE.)  = 'a_b'         ${str%$sep*}                                                     ================
 !==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION strHead_1(str, sep, lBackward) RESULT(out)
+  FUNCTION strHead_1(str, sep, lBackward) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*),           INTENT(IN) :: str
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
   LOGICAL,          OPTIONAL, INTENT(IN) :: lBackward
+  CHARACTER(LEN=maxlen) :: out
 !------------------------------------------------------------------------------------------------------------------------------
   IF(PRESENT(sep)) THEN
@@ -241,9 +246,10 @@
 !===    * strTail(str, '_', .TRUE.)  = 'c'           ${str##*$sep}                                             ================
 !==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION strTail_1(str, sep, lBackWard) RESULT(out)
+  FUNCTION strTail_1(str, sep, lBackWard) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*),           INTENT(IN) :: str
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
   LOGICAL,          OPTIONAL, INTENT(IN) :: lBackWard
+  CHARACTER(LEN=maxlen) :: out
 !------------------------------------------------------------------------------------------------------------------------------
   IF(PRESENT(sep)) THEN
@@ -406,7 +412,8 @@
 !=== OPTIONALY: GET THE NUMBER OF FOUND ELEMENTS "n". NB: UNFOUND => INDEX=0                       ============================
 !==============================================================================================================================
-INTEGER FUNCTION strIdx_1(str, s) RESULT(out)
+  FUNCTION strIdx_1(str, s) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str(:), s
+  INTEGER :: out
   DO out = 1, SIZE(str); IF(str(out) == s) EXIT; END DO
   IF(out == 1+SIZE(str) .OR. SIZE(str)==0) out = 0
@@ -491,5 +498,5 @@
 !===                     * THEN TEST WHETHER THE STRING FROM START TO THE FOUND SEPARATOR IS A CORRECTLY FORMATTED NUMBER
 !==============================================================================================================================
-LOGICAL FUNCTION strIdx_prv(rawList, del, ibeg, idx, idel, lSc) RESULT(lerr)
+ FUNCTION strIdx_prv(rawList, del, ibeg, idx, idel, lSc) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),  INTENT(IN)  :: rawList                          !--- String in which delimiters have to be identified
@@ -498,5 +505,7 @@
   INTEGER,           INTENT(OUT) :: idx                              !--- Index of the first identified delimiter in "rawList"
   INTEGER,           INTENT(OUT) :: idel                             !--- Index of the identified delimiter (0 if idx==0)
-  LOGICAL, OPTIONAL, INTENT(IN)  :: lSc                              !--- Care about nbs with front sign or in scient. notation
+  LOGICAL, OPTIONAL, INTENT(IN)  :: lSc  
+  LOGICAL :: lerr
+!--- Care about nbs with front sign or in scient. notation
 !------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: idx0                                                    !--- Used to display an identified non-numeric string
@@ -526,5 +535,5 @@
 
 !------------------------------------------------------------------------------------------------------------------------------
-INTEGER FUNCTION strIdx1(str, del, ib, id) RESULT(i)
+ FUNCTION strIdx1(str, del, ib, id) RESULT(i)
 !--- Get the index of the first appereance of one of the delimiters "del(:)" in "str" starting from position "ib".
 !--- "id" is the index in "del(:)" of the first delimiter found.
@@ -533,4 +542,5 @@
   INTEGER,           INTENT(IN)  :: ib
   INTEGER,           INTENT(OUT) :: id
+  INTEGER :: i
 !------------------------------------------------------------------------------------------------------------------------------
   DO i = ib, LEN_TRIM(str); id = strIdx(del, str(i:i)); IF(id /= 0) EXIT; END DO
@@ -545,5 +555,5 @@
 !=== Count the number of elements separated by "delimiter" in list "rawList". =================================================
 !==============================================================================================================================
-LOGICAL FUNCTION strCount_11(rawList, delimiter, nb, lSc) RESULT(lerr)
+ FUNCTION strCount_11(rawList, delimiter, nb, lSc) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),  INTENT(IN)  :: rawList
@@ -551,4 +561,5 @@
   INTEGER,           INTENT(OUT) :: nb
   LOGICAL, OPTIONAL, INTENT(IN)  :: lSc
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   LOGICAL :: ll
@@ -557,5 +568,5 @@
 END FUNCTION strCount_11
 !==============================================================================================================================
-LOGICAL FUNCTION strCount_m1(rawList, delimiter, nb, lSc) RESULT(lerr)
+ FUNCTION strCount_m1(rawList, delimiter, nb, lSc) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),     INTENT(IN)  :: rawList(:)
@@ -563,4 +574,5 @@
   INTEGER, ALLOCATABLE, INTENT(OUT) :: nb(:)
   LOGICAL,    OPTIONAL, INTENT(IN)  :: lSc
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   LOGICAL :: ll
@@ -574,5 +586,5 @@
 END FUNCTION strCount_m1
 !==============================================================================================================================
-LOGICAL FUNCTION strCount_1m(rawList, delimiter, nb, lSc) RESULT(lerr)
+ FUNCTION strCount_1m(rawList, delimiter, nb, lSc) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),  INTENT(IN)  :: rawList
@@ -584,4 +596,6 @@
   LOGICAL              :: ll
   CHARACTER(LEN=1024)  :: r
+  LOGICAL :: lerr
+  
   lerr = .FALSE.
   ll   = .FALSE.; IF(PRESENT(lSc)) ll = lSc
@@ -605,5 +619,5 @@
 !===          Corresponding "vals" remains empty if the element does not contain "=" sign. ====================================
 !==============================================================================================================================
-LOGICAL FUNCTION strParse(rawList, delimiter, keys, n, vals) RESULT(lerr)
+ FUNCTION strParse(rawList, delimiter, keys, n, vals) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),                             INTENT(IN)  :: rawList, delimiter
@@ -611,4 +625,5 @@
   INTEGER,                            OPTIONAL, INTENT(OUT) :: n
   CHARACTER(LEN=maxlen), ALLOCATABLE, OPTIONAL, INTENT(OUT) :: vals(:)
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=1024) :: r
@@ -625,7 +640,8 @@
 
 !------------------------------------------------------------------------------------------------------------------------------
-INTEGER FUNCTION countK() RESULT(nkeys)
+ FUNCTION countK() RESULT(nkeys)
 !--- Get the number of elements after parsing.
   IMPLICIT NONE
+  INTEGER :: nkeys 
 !------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: ib, ie, nl
@@ -680,5 +696,5 @@
 END FUNCTION strParse
 !==============================================================================================================================
-LOGICAL FUNCTION strParse_m(rawList, delimiter, keys, n, vals, lSc, id) RESULT(lerr)
+ FUNCTION strParse_m(rawList, delimiter, keys, n, vals, lSc, id) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),                             INTENT(IN)  :: rawList, delimiter(:)
@@ -688,4 +704,5 @@
   LOGICAL,               OPTIONAL,              INTENT(IN)  :: lSc      !--- Take care about numbers in scientific notation
   INTEGER,               OPTIONAL, ALLOCATABLE, INTENT(OUT) :: id(:)    !--- Indexes of the separators in "delimiter(:)" vector
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=1024) :: r
@@ -1085,5 +1102,5 @@
 !===    higher, several partial tables are displayed ; the nHead (default: 1) first columns are included in each sub-table.
 !==============================================================================================================================
-LOGICAL FUNCTION dispTable(p, titles, s, i, r, rFmt, nRowMax, nColMax, nHead, unit, sub) RESULT(lerr)
+ FUNCTION dispTable(p, titles, s, i, r, rFmt, nRowMax, nColMax, nHead, unit, sub) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),           INTENT(IN)  :: p             !--- DISPLAY MAP: s/i/r
@@ -1098,4 +1115,5 @@
   INTEGER,          OPTIONAL, INTENT(IN)  :: unit          !--- Output unit (default: screen)
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: sub           !--- Subroutine name
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=2048) :: row
@@ -1194,5 +1212,5 @@
 
 !==============================================================================================================================
-LOGICAL FUNCTION dispNamelist(unt, p, titles, s, i, r, rFmt, llast) RESULT(lerr)
+  FUNCTION dispNamelist(unt, p, titles, s, i, r, rFmt, llast) RESULT(lerr)
   IMPLICIT NONE
   INTEGER,                    INTENT(IN)  :: unt           !--- Output unit
@@ -1204,4 +1222,5 @@
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: rFmt          !--- Format for reals
   LOGICAL,          OPTIONAL, INTENT(IN)  :: llast         !--- Last variable: no final ','
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen)  :: rFm, el
@@ -1277,5 +1296,5 @@
 
 !==============================================================================================================================
-LOGICAL FUNCTION dispOutliers_1(ll, a, n, err_msg, nam, subn, nRowmax, nColMax, nHead, unit) RESULT(lerr)
+  FUNCTION dispOutliers_1(ll, a, n, err_msg, nam, subn, nRowmax, nColMax, nHead, unit) RESULT(lerr)
   IMPLICIT NONE
 ! Display outliers list in tables
@@ -1289,4 +1308,5 @@
   INTEGER,          OPTIONAL, INTENT(IN)  :: nHead                   !--- Number of front columns to duplicate  (default: 1)
   INTEGER,          OPTIONAL, INTENT(IN)  :: unit                    !--- Output unit                           (def: lunout)
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen),      ALLOCATABLE :: ttl(:)
@@ -1356,5 +1376,5 @@
 END FUNCTION dispOutliers_1
 !==============================================================================================================================
-LOGICAL FUNCTION dispOutliers_2(ll, a, n, err_msg, nam, subn, nRowMax, nColMax, nHead, unit) RESULT(lerr)
+  FUNCTION dispOutliers_2(ll, a, n, err_msg, nam, subn, nRowMax, nColMax, nHead, unit) RESULT(lerr)
   IMPLICIT NONE
 ! Display outliers list in tables
@@ -1368,4 +1388,5 @@
   INTEGER,          OPTIONAL, INTENT(IN)  :: nHead                   !--- Number of front columns to duplicate  (default: 1)
   INTEGER,          OPTIONAL, INTENT(IN)  :: unit                    !--- Output unit                           (def: lunout)
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen)                   :: mes, sub, fm='(f12.9)', prf
@@ -1414,8 +1435,9 @@
 !=== Reduce an algebrical expression (basic operations and parenthesis) to a single number (string format) ====================
 !==============================================================================================================================
-LOGICAL FUNCTION reduceExpr_1(str, val) RESULT(lerr)
+  FUNCTION reduceExpr_1(str, val) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),      INTENT(IN)  :: str
   CHARACTER(LEN=maxlen), INTENT(OUT) :: val
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen)              :: v
@@ -1464,5 +1486,5 @@
 !=== Reduce a simple algebrical expression (basic operations, no parenthesis) to a single number (string format) ==============
 !==============================================================================================================================
-LOGICAL FUNCTION reduceExpr_basic(str, val) RESULT(lerr)
+ FUNCTION reduceExpr_basic(str, val) RESULT(lerr)
   IMPLICIT NONE
   CHARACTER(LEN=*),      INTENT(IN)  :: str
@@ -1472,4 +1494,5 @@
   CHARACTER(LEN=maxlen), ALLOCATABLE :: ky(:)
   CHARACTER(LEN=1),      ALLOCATABLE :: op(:)
+  LOGICAL :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=1024) :: s
@@ -1524,5 +1547,5 @@
 !=== Check whether a string is a number or not ================================================================================
 !==============================================================================================================================
-ELEMENTAL LOGICAL FUNCTION is_numeric(str) RESULT(out)
+ELEMENTAL FUNCTION is_numeric(str) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
@@ -1530,4 +1553,6 @@
   INTEGER :: e
   CHARACTER(LEN=12) :: fmt
+  LOGICAL :: out
+  
   IF(TRIM(str) == '') THEN; out = .FALSE.; RETURN; END IF
   WRITE(fmt,'("(f",i0,".0)")') LEN_TRIM(str)
@@ -1541,10 +1566,13 @@
 !=== Convert a string into a logical/integer integer or an integer/real into a string =========================================
 !==============================================================================================================================
-ELEMENTAL INTEGER FUNCTION str2bool(str) RESULT(out)  !--- Result: 0/1 for .FALSE./.TRUE., -1 if not a valid boolean
+ELEMENTAL FUNCTION str2bool(str) RESULT(out)  !--- Result: 0/1 for .FALSE./.TRUE., -1 if not a valid boolean
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
   INTEGER :: ierr
   LOGICAL :: lout
+  INTEGER :: out
+
   READ(str,*,IOSTAT=ierr) lout
+  
   out = -HUGE(1)
   IF(ierr /= 0) THEN
@@ -1556,39 +1584,47 @@
 END FUNCTION str2bool
 !==============================================================================================================================
-ELEMENTAL INTEGER FUNCTION str2int(str) RESULT(out)
+ELEMENTAL FUNCTION str2int(str) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
   INTEGER :: ierr
+  INTEGER :: out
+  
   READ(str,*,IOSTAT=ierr) out
   IF(ierr/=0) out = -HUGE(1)
 END FUNCTION str2int
 !==============================================================================================================================
-ELEMENTAL REAL FUNCTION str2real(str) RESULT(out)
+ELEMENTAL FUNCTION str2real(str) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
   INTEGER :: ierr
+  REAL :: out
+  
   READ(str,*,IOSTAT=ierr) out
   IF(ierr/=0) out = -HUGE(1.)
 END FUNCTION str2real
 !==============================================================================================================================
-ELEMENTAL DOUBLE PRECISION FUNCTION str2dble(str) RESULT(out)
+ELEMENTAL FUNCTION str2dble(str) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: str
   INTEGER :: ierr
+  DOUBLE PRECISION :: out
+  
   READ(str,*,IOSTAT=ierr) out
   IF(ierr/=0) out = -HUGE(1.d0)
 END FUNCTION str2dble
 !==============================================================================================================================
-ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION bool2str(b) RESULT(out)
+ELEMENTAL FUNCTION bool2str(b) RESULT(out)
   IMPLICIT NONE
   LOGICAL, INTENT(IN) :: b
+  CHARACTER(LEN=maxlen) :: out
   WRITE(out,*)b
   out = ADJUSTL(out)
 END FUNCTION bool2str
 !==============================================================================================================================
-ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION int2str(i, nDigits) RESULT(out)
+ELEMENTAL FUNCTION int2str(i, nDigits) RESULT(out)
   IMPLICIT NONE
   INTEGER,           INTENT(IN) :: i
   INTEGER, OPTIONAL, INTENT(IN) :: nDigits
+  CHARACTER(LEN=maxlen) :: out
 !------------------------------------------------------------------------------------------------------------------------------
   WRITE(out,*)i
@@ -1598,8 +1634,9 @@
 END FUNCTION int2str
 !==============================================================================================================================
-ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION real2str(r,fmt) RESULT(out)
+ELEMENTAL FUNCTION real2str(r,fmt) RESULT(out)
   IMPLICIT NONE
   REAL,                       INTENT(IN) :: r
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fmt
+  CHARACTER(LEN=maxlen) :: out
 !------------------------------------------------------------------------------------------------------------------------------
   IF(     PRESENT(fmt)) WRITE(out,fmt)r
@@ -1608,8 +1645,9 @@
 END FUNCTION real2str
 !==============================================================================================================================
-ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION dble2str(d,fmt) RESULT(out)
+ELEMENTAL FUNCTION dble2str(d,fmt) RESULT(out)
   IMPLICIT NONE
   DOUBLE PRECISION,           INTENT(IN) :: d
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fmt
+  CHARACTER(LEN=maxlen) :: out
 !------------------------------------------------------------------------------------------------------------------------------
   IF(     PRESENT(fmt)) WRITE(out,fmt)d
@@ -1656,8 +1694,9 @@
 END FUNCTION addQuotes_m
 !==============================================================================================================================
-ELEMENTAL LOGICAL FUNCTION needQuotes(s) RESULT(out)
+ELEMENTAL FUNCTION needQuotes(s) RESULT(out)
   IMPLICIT NONE
   CHARACTER(LEN=*), INTENT(IN) :: s
   CHARACTER(LEN=1) :: b, e
+  LOGICAL :: out
 !------------------------------------------------------------------------------------------------------------------------------
   out = .TRUE.; IF(TRIM(s) == '') RETURN
@@ -1671,5 +1710,5 @@
 !=== DISPLAY "<message>: the following <items> are <reason>" FOLLOWED BY THE LIST OF <str> FOR WHICH <lerr>==T. ===============
 !==============================================================================================================================
-LOGICAL FUNCTION checkList(str, lerr, message, items, reason, nmax) RESULT(out)
+ FUNCTION checkList(str, lerr, message, items, reason, nmax) RESULT(out)
   IMPLICIT NONE
 ! Purpose: Messages in case a list contains wrong elements (indicated by lerr boolean vector).
@@ -1679,4 +1718,5 @@
   CHARACTER(LEN=*),   INTENT(IN)  :: message, items, reason
   INTEGER,  OPTIONAL, INTENT(IN)  :: nmax
+  LOGICAL :: out
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: s(:)
