Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=brodie
@@ -866,5 +866,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_calculo.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_calculo.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_calculo.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname 
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 
 #D-
@@ -845,5 +845,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 
 #D-
@@ -225,4 +225,49 @@
 
 #D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+    IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@
+    if ( $DEBUG_sys ) ; then
+	echo "IGCM_sys_SendMail :" $@
+    fi
+
+    IGCM_sys_RshPost <<-EOF
+    export LOGIN=${LOGIN}
+    export config_UserChoices_JobName=${config_UserChoices_JobName}
+    export config_UserChoices_MailName=${config_UserChoices_MailName}
+    export DateBegin=${DateBegin}
+    export DateEnd=${DateEnd}
+    export R_SAVE=${R_SAVE}
+
+    cat  << END_MAIL > job_end.mail
+Dear ${LOGIN},
+
+  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Job started : ${DateBegin}
+  Job ended   : ${DateEnd}
+  Ouput files are available in ${R_SAVE}
+END_MAIL
+
+    if [ ! -z ${config_UserChoices_MailName} ] ; then
+       mailx -s "${config_UserChoices_JobName} completed" ${config_UserChoices_MailName} <  job_end.mail
+    elif [ -f ~/.forward ] ; then
+       mailx -s "${config_UserChoices_JobName} completed" $( cat ~/.forward ) < job_end.mail
+    fi
+
+    sleep 10
+    rm -f job_end.mail
+EOF
+
+    if [ $? -gt 0 ] ; then
+	echo "IGCM_sys_SendMail : erreur."
+	IGCM_debug_Exit "IGCM_sys_SendMail"
+    fi
+    IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
 #D-function IGCM_sys_Mkdir
 #D-* Purpose: Master locale mkdir command
@@ -466,4 +511,23 @@
     fi
     IGCM_debug_PopStack "IGCM_sys_UnTar"
+}
+
+
+#D-#==================================================
+#D-function IGCM_sys_Qsub
+#D-* Purpose: Qsub new job
+#D-* Examples:
+#D-
+function IGCM_sys_Qsub {
+    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
+    if ( $DEBUG_sys ) ; then
+	echo "IGCM_sys_Qsub :" $@
+    fi
+    /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output}.e < $1
+    if [ $? -gt 0 ] ; then
+	echo "IGCM_sys_Qsub : erreur  -o ${Script_Output} -e ${Script_Output}.e $@"
+	IGCM_debug_Exit "IGCM_sys_Qsub"
+    fi
+    IGCM_debug_PopStack "IGCM_sys_Qsub"
 }
 
@@ -820,4 +884,58 @@
 
 #D-#==================================================
+#D-function IGCM_sys_Put_Rest
+#D-* Purpose: Put computied restarts on $(ARCHIVE).
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Rest {
+    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
+    if ( $DEBUG_sys ) ; then
+	echo "IGCM_sys_Put_Rest :" $@
+    fi
+    if [ $DRYRUN = 0 ]; then
+	if [ ! -f ${1} ] ; then
+	    echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
+	    IGCM_debug_Exit "IGCM_sys_Put_Rest"
+	fi
+
+	typeset RET
+	#
+	if [ X${JobType} = XRUN ] ; then
+	    IGCM_sys_Chmod 444 ${1}
+	fi
+	#
+	IGCM_sys_TestDirArchive $( dirname $2 )
+	#
+	# USUAL WAY
+	\cp $1 $2 > out_rsync 2>&1
+        RET=$?
+
+# 	#RSYNC WITH NETWORK SSH CALL
+# 	echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
+# 	${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
+
+#  	#RSYNC WITH NFS USE
+#  	echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
+#  	${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
+
+#  	RET=$?
+#  	IGCM_sys_Rsync_out $RET
+
+#  	${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
+#  	(( RET=RET+$? ))
+
+	if [ ${RET} -gt 0 ] ; then
+	    echo "IGCM_sys_Put_Rest : error."
+	    cat out_rsync
+	    IGCM_debug_Exit "IGCM_sys_Put_Rest"
+	fi
+    else
+	( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
+    fi
+    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
+}
+
+#D-#==================================================
 #D-function IGCM_sys_Put_Out
 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
@@ -839,7 +957,23 @@
 	#
 	typeset RET
-	#
+
+	#=====================================================
+        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
+        #=====================================================
+
+	#echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
+	#if [ $? -eq 0 ] ; then
+	#    typeset WORKPATH FILEPATH
+	#    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
+	#    IGCM_sys_MkdirWork ${WORKPATH} 
+	#    FILEPATH=${WORKPATH}/$( basename $2 )
+        #    #
+	#    IGCM_sys_Cp ${1} ${FILEPATH}
+	#fi
+
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
@@ -946,5 +1080,5 @@
 	fi
 
-# 	#RSYNC WITH NETWORK RSH CALL
+# 	#RSYNC WITH NETWORK SSH CALL
 # 	echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
 # 	${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
@@ -960,4 +1094,9 @@
 #  	(( RET=RET+$? ))
 
+	if [ ${RET} -gt 0 ] ; then
+	    echo "IGCM_sys_Get : copy error."
+	    cat out_rsync
+	    IGCM_debug_Exit "IGCM_sys_Get"
+	fi
     else
 	( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
@@ -1263,5 +1402,5 @@
 
 function IGCM_sys_build_run_file {
-    IGCM_debug_PushStack "IGCM_sys_build_run_file"
+    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
     if ( $DEBUG_sys ) ; then
 	echo "IGCM_sys_build_run_file"
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_claude.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_claude.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_claude.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=claude
@@ -915,5 +915,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=${HOST}
@@ -905,5 +905,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercureTX.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercureTX.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercureTX.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 
 #D-
@@ -800,5 +800,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh	(revision 228)
@@ -69,7 +69,7 @@
 # Host and user names
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=mercure
@@ -853,5 +853,7 @@
 
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh	(revision 228)
@@ -69,7 +69,7 @@
 # Host and user names
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=mercure
@@ -915,5 +915,7 @@
 
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=obelix
@@ -900,5 +900,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 
 #D-
@@ -801,5 +801,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh	(revision 227)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh	(revision 228)
@@ -66,7 +66,7 @@
 # Host and user names 
 # $hostname ou hostname
-typeset  HOST=${HOST:=$( hostname ) }
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset  LOGIN=${LOGIN:=$( whoami ) }
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset -r MASTER=vargas
@@ -884,5 +884,7 @@
 	#
 	if [ X${JobType} = XRUN ] ; then
-	    IGCM_sys_Chmod 444 ${1}
+	    if [ X${3} = X ] ; then
+		IGCM_sys_Chmod 444 ${1}
+	    fi
 	fi
 	#
