Index: trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
===================================================================
--- trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh	(revision 1073)
+++ trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh	(revision 1074)
@@ -1056,4 +1056,96 @@
 
 #=======================================================================
+function IGCM_comp_modifyXmlFile
+{
+#
+# syntax:     IGCM_comp_modifyXmlFile  type  filein  keyid  keyattrib  value
+#
+# For example : IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 enabled .TRUE.
+#          or   IGCM_comp_modifyXmlFile blocker iodef.xml using_server NONE false
+#
+# This function is used to modify the value for a specific attribute and variable id.
+# The file must be a of xml syntax.
+# This function can be used in the comp.driver files for the components. 
+#
+# Arguments: 
+# - type      : first argument must be blocker, nonblocker or force. 
+#               For "blocker" case, the variable must be attributed the keyworld AUTO 
+#               otherwise this function will exit.
+#               For "nonblocker" case, the user can remove or modify the variable. For 
+#               this case, as long as AUTO is not set, no modification will be done.
+#               For "force" case, the variable will be modified even if it is not set to AUTO 
+# - filein    : the file in run directory of .xml type in which the variable should be set
+# - keyid     : the variable to modify
+# - keyattrib : the attribute name to modify. If NONE, then the variable itself will be modified
+# - value     : the value to set in the filein
+#
+    IGCM_debug_PushStack "IGCM_comp_modifyXmlFile"
+    
+    # Set local variables and test the arguments
+    if [ $# = 5 ] ; then
+	# Normal case with 4 arguments
+	type=$1 ; filein=$2 ; keyid=$3 ; keyattrib=$4 ; value=$5
+    else
+	IGCM_debug_Exit "IGCM_comp_modifyXmlFile: Bad number of arguments."
+	return
+    fi
+    IGCM_debug_Print 2 "Entering IGCM_comp_modifyXmlFile with arguments: type=$type file=$filein, id=$keyid attribute=$keyattrib, value=$value"
+
+    # Test if first argument is correct
+    if [ $type != blocker ] && [ $type != nonblocker ] && [ $type != force ] ; then
+	IGCM_debug_Exit "IGCM_comp_modifyXmlFile: Error in first argument must be blocker, nonblocker or force"
+	return
+    fi
+
+    # Test if the file exist
+    if [ ! -f ${filein} ] ; then
+	IGCM_debug_Exit "IGCM_comp_modifyXmlFile: $filein does not exist."
+	return
+    fi
+
+    # Test if keyid is set in filein, otherwise exit
+    if [ $( grep -w $keyid $filein | wc -l ) = 0 ] ; then
+	# Variable key is not set in filein, stop. 
+	IGCM_debug_Exit "IGCM_comp_modifyXmlFile : $keyid is not set in the file. Bad syntax of $filein file."
+	return
+    fi
+
+    # Check if AUTO is set on the same line as keyid and keyattrib
+    if [  $( grep -w $keyid $filein | grep AUTO | wc -l ) = 1 ] ; then
+	# Modifification will be done
+	modify=yes
+    else
+	if [ $type = blocker ] ; then
+	    # Exit, the variable must be set to AUTO
+	    IGCM_debug_Exit "IGCM_comp_modifyXmlFile : blocker function. The $keyattrib for $keyid must be set to AUTO in $filein."
+	    return
+	elif [ $type = nonblocker ] ; then
+	    # Nothing will be done
+	    IGCM_debug_Print 1 "Nonblocker nothing is done for ${filein}, id=${keyid} and attribute ${keyattrib}"
+	    modify=no
+	elif [ $type = force ] ; then
+	    # Force modification
+	    IGCM_debug_Print 1 "IGCM_comp_modifyXmlFile : Attribute=$keyattrib for id=$keyid was not set to AUTO. Modification will be forced."
+	    modify=yes
+	fi
+    fi
+
+    # Do the modifcation now
+    if [ $modify = yes ] ; then
+	if [ $keyattrib = NONE ] ; then
+	    # Case to modify the variable itself
+	    IGCM_debug_Print 1 "Now modify ${filein} for id=${keyid} by setting the variable=${value}"
+	    sed -e "s/\(<[^\"]*\"${keyid}\".*>\)\([^<]*\)\(<[^>]*\)/\1${value}\3/" $filein > $filein.tmp
+	else
+	    # Case to modify the attribute value
+	    IGCM_debug_Print 1 "Now modify ${filein} for id=${keyid} by setting attribute to ${keyattrib}=${value}"
+	    sed -e "/id=\"${keyid}\"/s/\(${keyattrib}=\"\)[^\"]*\(\"\)/\1${value}\2/" $filein > $filein.tmp
+	fi
+	\mv $filein.tmp $filein	
+    fi
+    IGCM_debug_PopStack "IGCM_comp_modifyXmlFile"
+}
+
+#=======================================================================
 function IGCM_comp_Update
 {
