Index: trunk/libIGCM/libIGCM_card/libIGCM_card.ksh
===================================================================
--- trunk/libIGCM/libIGCM_card/libIGCM_card.ksh	(revision 772)
+++ trunk/libIGCM/libIGCM_card/libIGCM_card.ksh	(revision 786)
@@ -58,10 +58,10 @@
     IGCM_debug_PushStack "IGCM_card_PrintOption" $@
     if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
-	gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk "$@"
-    else
-	echo
-        IGCM_debug_Print 1 "--Error--> IGCM_card_PrintOption $@"
-        IGCM_debug_Print 1 "           $1 is not readable"
-	IGCM_debug_Exit "IGCM_card_PrintOption"
+      gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk "$@"
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_PrintOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_PrintOption"
     fi
     IGCM_debug_PopStack "IGCM_card_PrintOption"
@@ -78,9 +78,9 @@
     IGCM_debug_PushStack "IGCM_card_PrintSection" $@
     if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
-	gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@"
-    else
-        IGCM_debug_Print 1 "--Error--> IGCM_card_PrintSection $@"
-        IGCM_debug_Print 1 "           $1 is not readable"
-	IGCM_debug_Exit "IGCM_card_PrintSection"
+      gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@"
+    else
+      IGCM_debug_Print 1 "--Error--> IGCM_card_PrintSection $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_PrintSection"
     fi
     IGCM_debug_PopStack "IGCM_card_PrintSection"
@@ -97,26 +97,26 @@
     IGCM_debug_PushStack "IGCM_card_DefineVariableFromOption" $@
     if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
-	# Get basename of card file ($1)
-	typeset name1=${1##*/}
-	# Build name of variable as $1_$2_$3 (cardname_Section_Option)
-	typeset name=${name1%%.*}_${2}_${3}
-	typeset value=$( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" )
-
-	# Only if a section is missing we exit the job.
-	# We must allow missing option to keep backward compatibilty.
-	if [ "${value}" = "Error: Section not found" ] ; then
-	    echo
-	    IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}."
-	    IGCM_debug_Print 1 "Error: Section ${2} not found"
-	    IGCM_debug_Exit
-	    IGCM_debug_Verif_Exit
-	fi
-	eval ${name}=${value}
-    else
-	echo
-        IGCM_debug_Print 1 "--Error--> IGCM_card_DefineVariableFromOption"
-        IGCM_debug_Print 1 "--Error--> $1 is not readable"
-	IGCM_debug_Exit "IGCM_card_DefineVariableFromOption"
-	IGCM_debug_Verif_Exit
+      # Get basename of card file ($1)
+      typeset name1=${1##*/}
+      # Build name of variable as $1_$2_$3 (cardname_Section_Option)
+      typeset name=${name1%%.*}_${2}_${3}
+      typeset value=$( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" )
+
+      # Only if a section is missing we exit the job.
+      # We must allow missing option to keep backward compatibilty.
+      if [ "${value}" = "Error: Section not found" ] ; then
+        echo
+        IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}."
+        IGCM_debug_Print 1 "Error: Section ${2} not found"
+        IGCM_debug_Exit
+        IGCM_debug_Verif_Exit
+      fi
+      eval ${name}=${value}
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineVariableFromOption"
+      IGCM_debug_Print 1 "--Error--> $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_DefineVariableFromOption"
+      IGCM_debug_Verif_Exit
     fi
     IGCM_debug_PopStack "IGCM_card_DefineVariableFromOption"
@@ -133,16 +133,16 @@
     IGCM_debug_PushStack "IGCM_card_DefineArrayFromOption" $@
     if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
-	# Get basename of card file ($1)
-	typeset name1=${1##*/}
-	# Build name of array as $1_$2_$3 (cardname_Section_Option)
-	typeset name=${name1%%.*}_${2}_${3}
-	eval unset ${name}
-	eval ${name}[0]=${NULL_STR}
-	set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" | gawk -- 'BEGIN {FS="[() ,]+"} {for (i=2; i <= NF-1; i++) printf("%s ",$i)}' )
-    else
-	echo
-        IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromOption $@"
-        IGCM_debug_Print 1 "           $1 is not readable"
-	IGCM_debug_Exit "IGCM_card_DefineArrayFromOption"
+      # Get basename of card file ($1)
+      typeset name1=${1##*/}
+      # Build name of array as $1_$2_$3 (cardname_Section_Option)
+      typeset name=${name1%%.*}_${2}_${3}
+      eval unset ${name}
+      eval ${name}[0]=${NULL_STR}
+      set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" | gawk -- 'BEGIN {FS="[() ,]+"} {for (i=2; i <= NF-1; i++) printf("%s ",$i)}' )
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_DefineArrayFromOption"
     fi
     IGCM_debug_PopStack "IGCM_card_DefineArrayFromOption"
@@ -159,28 +159,28 @@
     IGCM_debug_PushStack "IGCM_card_DefineArrayFromSection" $@
     if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
-	# Get basename of card file ($1)
-	typeset name1=${1##*/}
-	# Build name of array as $1_$2 (cardname_Section)
-	typeset name=${name1%%.*}_${2}
-	eval unset ${name}
-	eval ${name}[0]=${NULL_STR}
-	set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" )
-	#if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then
-	#    echo
-	#    IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}."
-	#    IGCM_debug_Print 1 "Error: Section ${2} not found"
-	#    IGCM_debug_Exit
-	#    IGCM_debug_Verif_Exit
-	#fi
-        if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then
-	  echo
-	  IGCM_debug_Print 1 "Warning with readding of ${name} variable in ${1}."
-	  IGCM_debug_Print 1 "Warning: Section ${2} not found"
-	  eval unset ${name}
-	fi
-    else
-        IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromSection $@"
-        IGCM_debug_Print 1 "           $1 is not readable"
-	IGCM_debug_Exit "IGCM_card_DefineArrayFromSection"
+      # Get basename of card file ($1)
+      typeset name1=${1##*/}
+      # Build name of array as $1_$2 (cardname_Section)
+      typeset name=${name1%%.*}_${2}
+      eval unset ${name}
+      eval ${name}[0]=${NULL_STR}
+      set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" )
+      #if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then
+      #    echo
+      #    IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}."
+      #    IGCM_debug_Print 1 "Error: Section ${2} not found"
+      #    IGCM_debug_Exit
+      #    IGCM_debug_Verif_Exit
+      #fi
+      if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then
+        echo
+        IGCM_debug_Print 1 "Warning with readding of ${name} variable in ${1}."
+        IGCM_debug_Print 1 "Warning: Section ${2} not found"
+        eval unset ${name}
+      fi
+    else
+      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromSection $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_DefineArrayFromSection"
     fi
     IGCM_debug_PopStack "IGCM_card_DefineArrayFromSection"
@@ -201,33 +201,33 @@
     IGCM_debug_PushStack "IGCM_card_WriteOption" $@
     if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then
-	typeset tmpfile=tmpfile_$$
-	( IGCM_card_PrintOption "$1" "$2" "$3" | grep "not found" ) > ${tmpfile}
-	if [ $( cat ${tmpfile} | wc -l ) -gt 0 ] ; then
-	    echo "-------------------------------------------"
-	    echo "!!! Problem with IGCM_card_WriteOption !!!"
-	    echo "Try to write : " $@
-	    echo "You have to correct some script." 
-	    echo "We won't do anything else !"
-	    exit 1
-	fi
-	\rm ${tmpfile}
-
-	# The tmpfile uses now the real path of the card to be modified, 
-	# not just a local tmpfile with PID.
-	tmpfile=$1_mutex_$$
-
-	IGCM_card_CheckConflict $1
-
-	# Do the job
-	( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile}
-
-	cp $1 $1.bak
-	mv ${tmpfile} $1
-
-    else
-	echo
-        IGCM_debug_Print 1 "--Error--> IGCM_card_WriteOption $@"
-        IGCM_debug_Print 1 "           $1 is not readable or not writable"
-	IGCM_debug_Exit "IGCM_card_WriteOption"
+      typeset tmpfile=tmpfile_$$
+      ( IGCM_card_PrintOption "$1" "$2" "$3" | grep "not found" ) > ${tmpfile}
+      if [ $( cat ${tmpfile} | wc -l ) -gt 0 ] ; then
+        echo "-------------------------------------------"
+        echo "!!! Problem with IGCM_card_WriteOption !!!"
+        echo "Try to write : " $@
+        echo "You have to correct some script." 
+        echo "We won't do anything else !"
+        exit 1
+      fi
+      \rm ${tmpfile}
+
+      # The tmpfile uses now the real path of the card to be modified, 
+      # not just a local tmpfile with PID.
+      tmpfile=$1_mutex_$$
+
+      IGCM_card_CheckConflict $1
+
+      # Do the job
+      ( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile}
+
+      cp $1 $1.bak
+      mv ${tmpfile} $1
+
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_WriteOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable or not writable"
+      IGCM_debug_Exit "IGCM_card_WriteOption"
     fi
     IGCM_debug_PopStack "IGCM_card_WriteOption"
@@ -244,16 +244,16 @@
     ((isleep=0))
     while [ ${#tmpfiles[@]} -gt 0 ] ; do 
- 	echo "Conflict between two processes working on " $1 "!!!" ${tmpfiles[@]}
-	sleep 1
-	((isleep=isleep+1))
-	if [ isleep -gt 20 ] ; then
-	    echo "Too many loops waiting for other process working on " $1 ". We continue."
-	    echo "You should see if one process of your run or post-treatment may have terminated suddenly."
-	    echo "Afer, you should erase this(those) file(s) : " ${tmpfiles[@]}
+      echo "Conflict between two processes working on " $1 "!!!" ${tmpfiles[@]}
+      sleep 1
+      ((isleep=isleep+1))
+      if [ isleep -gt 20 ] ; then
+        echo "Too many loops waiting for other process working on " $1 ". We continue."
+        echo "You should see if one process of your run or post-treatment may have terminated suddenly."
+        echo "Afer, you should erase this(those) file(s) : " ${tmpfiles[@]}
 # Send a mail to USER ??
-	    break ;
-	fi
-	unset tmpfiles
-	set +A tmpfiles -- $( ls $1_mutex_[0-9]* 2>/dev/null )
+        break ;
+      fi
+      unset tmpfiles
+      set +A tmpfiles -- $( ls $1_mutex_[0-9]* 2>/dev/null )
     done
 
@@ -273,16 +273,16 @@
 
     if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then
-	typeset tmpfile=tmpfile_$$
-	if [ X"${4}" != X"" ]; then
-	    tab=$4
-	    IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')'
-	else
-	    IGCM_card_WriteOption $1 $2 $3 '()'
-	fi
-    else
-	echo
-	IGCM_debug_Print 1 "--Error--> IGCM_card_WriteArrayOption $@"
-	IGCM_debug_Print 1 "           $1 is not readable or not writable"
-	IGCM_debug_Exit "IGCM_card_WriteArrayOption"
+      typeset tmpfile=tmpfile_$$
+      if [ X"${4}" != X"" ]; then
+        tab=$4
+        IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')'
+      else
+        IGCM_card_WriteOption $1 $2 $3 '()'
+      fi
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_WriteArrayOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable or not writable"
+      IGCM_debug_Exit "IGCM_card_WriteArrayOption"
     fi
     IGCM_debug_PopStack "IGCM_card_WriteArrayOption"
@@ -299,7 +299,7 @@
 #---------------------
     if [ ! -n "${libIGCM}" ] ; then
-	echo "Check libIGCM_card ...........................................[ FAILED ]"
-        echo "--Error--> libIGCM variable is not defined"
-	IGCM_debug_Exit "IGCM_card_Check"
+      echo "Check libIGCM_card ...........................................[ FAILED ]"
+      echo "--Error--> libIGCM variable is not defined"
+      IGCM_debug_Exit "IGCM_card_Check"
     fi
 
@@ -307,7 +307,7 @@
     whence -v gawk > /dev/null 2>&1
     if [ ! $? -eq 0 ] ; then
-	echo "Check libIGCM_card ...........................................[ FAILED ]"
-        echo "--Error--> gawk command is not defined"
-	IGCM_debug_Exit "IGCM_card_Check"
+      echo "Check libIGCM_card ...........................................[ FAILED ]"
+      echo "--Error--> gawk command is not defined"
+      IGCM_debug_Exit "IGCM_card_Check"
     fi
 
@@ -317,14 +317,14 @@
 
     if diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref > /dev/null 2>&1 ; then 
-	echo "Check libIGCM_card ...............................................[ OK ]"
-	rm -f IGCM_card_Test.ref.failed
+      echo "Check libIGCM_card ...............................................[ OK ]"
+      rm -f IGCM_card_Test.ref.failed
     else 
-	echo "Check libIGCM_card ...........................................[ FAILED ]"
-        echo "--Error--> Execution of ${libIGCM}/libIGCM_card/IGCM_card_Test.ksh"
-        echo "           has produced the file IGCM_card_Test.ref.failed"
-        echo "           Please analyse differences with the reference file by typing:"
-        echo "           diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref"
-	echo "           Report errors to the author: Patrick.Brockmann@cea.fr"
-	IGCM_debug_Exit "IGCM_card_Check"
+      echo "Check libIGCM_card ...........................................[ FAILED ]"
+      echo "--Error--> Execution of ${libIGCM}/libIGCM_card/IGCM_card_Test.ksh"
+      echo "           has produced the file IGCM_card_Test.ref.failed"
+      echo "           Please analyse differences with the reference file by typing:"
+      echo "           diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref"
+      echo "           Report errors to the author: Patrick.Brockmann@cea.fr"
+      IGCM_debug_Exit "IGCM_card_Check"
     fi
 
