Index: LMDZ6/trunk/libf/misc/strings_mod.F90
===================================================================
--- LMDZ6/trunk/libf/misc/strings_mod.F90	(revision 4363)
+++ LMDZ6/trunk/libf/misc/strings_mod.F90	(revision 4403)
@@ -194,73 +194,73 @@
 
 !==============================================================================================================================
-!=== Extract the substring in front of the last (first if lFirst==TRUE) occurrence of separator "sep" in "str" ================
+!=== Extract the substring in front of the first (last if lBackward==TRUE) occurrence of "sep" in "str"        ================
 !=== Examples for str='a_b_c' and sep='_' and the bash command with the same effect:                           ================
 !===    * strHead(..,.FALSE.) = 'a'           ${str%%$sep*}                                                    ================
 !===    * strHead(..,.TRUE.)  = 'a_b'         ${str%$sep*}                                                     ================
 !==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION strHead_1(str,sep,lFirst) RESULT(out)
+CHARACTER(LEN=maxlen) FUNCTION strHead_1(str, sep, lBackward) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: str
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-!------------------------------------------------------------------------------------------------------------------------------
-  LOGICAL :: lf
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackward
+!------------------------------------------------------------------------------------------------------------------------------
   IF(PRESENT(sep)) THEN
-    out = str(1:INDEX(str,sep,.NOT.lf)-1)
+    IF(     PRESENT(lBackWard)) out = str(1:INDEX(str,sep,lBackWard)-1)
+    IF(.NOT.PRESENT(lBackWard)) out = str(1:INDEX(str,sep)-1)
   ELSE
-    out = str(1:INDEX(str,'/',.NOT.lf)-1)
+    IF(     PRESENT(lBackWard)) out = str(1:INDEX(str,'/',lBackWard)-1)
+    IF(.NOT.PRESENT(lBackWard)) out = str(1:INDEX(str,'/')-1)
   END IF
   IF(out == '') out = str
 END FUNCTION strHead_1
 !==============================================================================================================================
-FUNCTION strHead_m(str,sep,lFirst) RESULT(out)
+FUNCTION strHead_m(str, sep, lBackward) RESULT(out)
   CHARACTER(LEN=maxlen),     ALLOCATABLE :: out(:)
   CHARACTER(LEN=*),           INTENT(IN) :: str(:)
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-!------------------------------------------------------------------------------------------------------------------------------
-  LOGICAL :: lf
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackward
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
   IF(PRESENT(sep)) THEN
-    out = [(strHead_1(str(k), sep,   lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strHead_1(str(k), sep, lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strHead_1(str(k), sep),            k=1, SIZE(str))]
   ELSE
-    out = [(strHead_1(str(k), lFirst=lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strHead_1(str(k), '/', lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strHead_1(str(k), '/'),            k=1, SIZE(str))]
   END IF
 END FUNCTION strHead_m
 !==============================================================================================================================
-!=== Extract the substring following the last (first if lFirst==TRUE) occurrence of separator "sep" in "str"   ================
+!=== Extract the substring following the first (last if lBackward==TRUE) occurrence of "sep" in "str"          ================
 !=== Examples for str='a_b_c' and sep='_' and the bash command with the same effect:                           ================
-!===    * strTail(..,.FALSE.) = 'c'           ${str#*$sep}                                                     ================
-!===    * strTail(..,.TRUE.)  = 'b_c'         ${str##*$sep}                                                    ================
-!==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION strTail_1(str,sep,lFirst) RESULT(out)
+!===    * strTail(str, '_', .FALSE.) = 'b_c'         ${str#*$sep}                                              ================
+!===    * strTail(str, '_', .TRUE.)  = 'c'           ${str##*$sep}                                             ================
+!==============================================================================================================================
+CHARACTER(LEN=maxlen) FUNCTION strTail_1(str, sep, lBackWard) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: str
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-!------------------------------------------------------------------------------------------------------------------------------
-  LOGICAL :: lf
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackWard
+!------------------------------------------------------------------------------------------------------------------------------
   IF(PRESENT(sep)) THEN
-    out = str(INDEX(str,sep,.NOT.lf)+LEN(sep):LEN_TRIM(str))
+    IF(     PRESENT(lBackWard)) out = str(INDEX(str,sep,lBackWard)+LEN(sep):LEN_TRIM(str))
+    IF(.NOT.PRESENT(lBackWard)) out = str(INDEX(str,sep)          +LEN(sep):LEN_TRIM(str))
   ELSE
-    out = str(INDEX(str,'/',.NOT.lf)+1:LEN_TRIM(str))
+    IF(     PRESENT(lBackWard)) out = str(INDEX(str,'/',lBackWard)+1:LEN_TRIM(str))
+    IF(.NOT.PRESENT(lBackWard)) out = str(INDEX(str,'/')          +1:LEN_TRIM(str))
   END IF
   IF(out == '') out = str
 END FUNCTION strTail_1
 !==============================================================================================================================
-FUNCTION strTail_m(str,sep,lFirst) RESULT(out)
+FUNCTION strTail_m(str, sep, lBackWard) RESULT(out)
   CHARACTER(LEN=maxlen),     ALLOCATABLE :: out(:)
   CHARACTER(LEN=*),           INTENT(IN) :: str(:)
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-!------------------------------------------------------------------------------------------------------------------------------
-  LOGICAL :: lf
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackWard
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
   IF(PRESENT(sep)) THEN
-    out = [(strTail_1(str(k), sep,   lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strTail_1(str(k), sep, lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strTail_1(str(k), sep),            k=1, SIZE(str))]
   ELSE
-    out = [(strTail_1(str(k), lFirst=lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strTail_1(str(k), '/', lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strTail_1(str(k), '/'),            k=1, SIZE(str))]
   END IF
 END FUNCTION strTail_m
