Index: trunk/libIGCM/AA_TimeSeries_Checker
===================================================================
--- trunk/libIGCM/AA_TimeSeries_Checker	(revision 399)
+++ trunk/libIGCM/AA_TimeSeries_Checker	(revision 401)
@@ -60,6 +60,6 @@
 echo "This action can potentially submit numbers of jobs (up to 50)"
 echo "This action can potentially remove unnecessary files but I will ALWAYS ask permission to do so"
-echo "\033[1;31mDo you want me to run in dryrun mode just telling what I would submit?\033[m"
-echo "\033[1;31mOr do you want me to submit job for real? Answer yes in this case.\033[m"
+echo -e "\033[1;31mDo you want me to run in dryrun mode just telling what I would submit?\033[m"
+echo -e "\033[1;31mOr do you want me to submit job for real? Answer yes in this case.\033[m"
 echo -n " Run for real (y/n) :"
 read ActionAnswer
@@ -339,5 +339,5 @@
 				IGCM_debug_Print 2 "File(s) that will be removed ${RemoveList[*]}"
 				if [ ${action} = true ] ; then
-				    echo "\033[1;32mDo you want to remove them?"
+				    echo -e "\033[1;32mDo you want to remove them?"
 				    echo -n " Your answer (y/n) : \033[m"
 				    read RemoveAnswer
@@ -345,5 +345,5 @@
 					oui|OUI|o|y|yes|YES)
 					    echo "OK. I will erase them"
-					    IGCM_sys_Rm ${RemoveList[*]}
+					    IGCM_sys_Rm -f ${RemoveList[*]}
 					    ;;
 					non|NON|n|no|NO)
@@ -411,5 +411,5 @@
 				    echo
 				else
-				    IGCM_debug_Print 2 "\033[1;31mI should NOW submit ${FILE} chunck ${Dimension}\033[m period ${ChunckDebut}-${ChunckFin} and CompletedFlag=${ChunckCompletedFlag}"
+				    IGCM_debug_Print 2 -e "\033[1;31mI should NOW submit ${FILE} chunck ${Dimension}\033[m period ${ChunckDebut}-${ChunckFin} and CompletedFlag=${ChunckCompletedFlag}"
 				fi
 			    fi
@@ -450,4 +450,8 @@
 IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
 CompletedFlag=${SavedCompletedFlag}
+
+unset CompToRead
+unset FlagToRead
+unset NameToRead
 
 if [ X${Launch2D} = Xtrue ] ; then
@@ -470,5 +474,5 @@
 	echo
     else
-	IGCM_debug_Print 2 "\033[1;31mI should NOW submit 2D without chunck\033[m period ${DateBegin}-${DateEnd}"
+	IGCM_debug_Print 2 -e "\033[1;31mI should NOW submit 2D without chunck\033[m period ${DateBegin}-${DateEnd}"
     fi
 fi
Index: trunk/libIGCM/libIGCM_post/IGCM_Patch_20101208_nudge_interp.ksh
===================================================================
--- trunk/libIGCM/libIGCM_post/IGCM_Patch_20101208_nudge_interp.ksh	(revision 399)
+++ trunk/libIGCM/libIGCM_post/IGCM_Patch_20101208_nudge_interp.ksh	(revision 401)
@@ -20,12 +20,13 @@
 # 
 #
-function IGCM_Patch_nudge_interp {
+function IGCM_Patch_20101208_nudge_interp {
     IGCM_debug_PushStack "IGCM_Patch_nudge_interp" $@
 
-#####
+###################################################################################################
+# 1 - Define variables
 # Filein is the first month to interpolate for a variable.
-# Filein name should be at format X_Y_ZZZZ.nc, where X=varaiable name [u or v], Y=[1,13] and ZZZZ=year.
+# Filein name should be at format X_Y_ZZZZ.nc, where X=varaiable name [u,v,ta], Y=[1,13] and ZZZZ=year.
 # To do one year complete for one variable X, 13 month must be present.
-#####
+###################################################################################################
     filein=${1}
 
@@ -38,8 +39,8 @@
     echo var=$var year=$year
 
-#####
-# Interpolate all files for the actual varaiable.
-# Original files will be overritten.
-#####
+###################################################################################################
+# 2 - Interpolate all files for the actual varaiable.
+#     Original files will be overritten.
+###################################################################################################
     filelist=${var}_*.nc
     echo 'filelist 1 = ' ${filelist}
@@ -51,7 +52,7 @@
     done
 
-#####
-# Add a final time step in each file, coming from the first time step in following month
-#####
+###################################################################################################
+# 3 - Add a final time step in each file, coming from the first time step in following month
+###################################################################################################
     filelist=${var}_*.nc
     echo 'filelist 2 = ' ${filelist}
@@ -70,7 +71,7 @@
     done
 
-#####
-# Remove 13'th month
-#####
+###################################################################################################
+# 4 - Remove 13'th month
+###################################################################################################
     if [ -f ${var}_13_${year}.nc ] ; then
 	echo Remove file ${var}_13_${year}.nc
@@ -84,10 +85,12 @@
 function IGCM_era2gcm {
 #set -xv
-#####################################################################
-# Function that interpolates filein at destionation gridfile.
-# Results in are stored in fileout.
-#####################################################################
+# Function that does a linear interpolation of the variable in 
+# filein towards the destionation grid in gridfile. Results in are 
+# stored in fileout.
+    IGCM_debug_PushStack "IGCM_era2gcm" $@
 
-    IGCM_debug_PushStack "IGCM_era2gcm" $@
+###################################################################
+# 1 - Define variables
+###################################################################
     filein=$1
     fileout=$2
@@ -95,68 +98,51 @@
     year=$4
 
-#####################################################################
-# Find dimension for destination grid
-#####################################################################
+# Define file with destination grid
     gridfile=start.nc
-    iip1=`ncdump -h $gridfile | grep rlonu | head -1 | awk ' { print $3 } '`
-    jjm=`ncdump -h $gridfile | grep rlatv | head -1 | awk ' { print $3 } '`
-    jjp1=`expr $jjm + 1`
-    iim=`expr $iip1 - 1`
     
-###################################################################
 # Find time boundaries
-###################################################################
     tmin=1
     tmax=`ncdump -h ${filein} | grep time | head -1 | awk ' { print $6 } '`
     tmax=$( echo ${tmax} | awk '-F(' '{print $2}' )
-    echo iim=$iim jjm=$jjm tmax=$tmax
     
+# Choose grid and output variable name 
+    if [ ${varin} = 'u' ] ; then 
+	varout=uwnd
+	grille='grille_u'
+    elif [ ${varin} = 'v' ] ; then 
+	varout=vwnd
+	grille='grille_v'
+    elif [ ${varin} = 'ta' ] ; then 
+	varout=air
+	grille='grille_t'
+    elif [ ${varin} = 'r' ] ; then 
+	varout=rh
+	grille='grille_t'
+    elif [ ${varin} = 'msl' ] ; then 
+	varout=sp
+	grille='grille_t'
+    else 
+	echo Error : ${varin} unknown!!!!
+	exit
+    fi 
+
 ###################################################################
-# Create ferret script for interpolation
+# 2 - Create ferret script for interpolation
 ###################################################################
-# Write first part of ferret script
-    cat << eod >  tmpinterp.jnl
+    cat << eod >  ${varin}.jnl
 set memory/size=50
 
 use ${gridfile}
 use ${filein}
-let uwnd=u
-let vwnd=v
-let air=ta
-let rh=r
-let sp=msl
+let ${varout}=${varin}
 
-define axis/t=1-jan-${year}:31-dec-${year}:6/units=hours thour
-eod
+define axis/t=01-JAN-${year}:31-DEC-${year}:6/units=hours thour
 
-# Add one line depending on variable name to ferret script
-    imax=${iip1}
-    jmax=${jjp1}
-    if [ ${varin} = 'u' ] ; then 
-	varout=uwnd
-	echo define grid/like=uwnd[d=2]/x=cu[d=1]/y=cu[d=1] grille >> tmpinterp.jnl
-    elif [ ${varin} = 'v' ] ; then 
-	varout=vwnd
-	jmax=${jjm}
-	echo define grid/like=vwnd[d=2]/x=cv[d=1]/y=cv[d=1] grille >> tmpinterp.jnl
-    elif [ ${varin} = 'ta' ] ; then 
-	varout=air
-	echo define grid/like=air[d=2]/x=cv[d=1]/y=cu[d=1] grille >> tmpinterp.jnl
-    elif [ ${varin} = 'r' ] ; then 
-	varout=rh
-	echo define grid/like=air[d=2]/x=cv[d=1]/y=cu[d=1] grille >> tmpinterp.jnl
-    elif [ ${varin} = 'msl' ] ; then 
-	varout=sp
-	echo define grid/like=air[d=2]/x=cv[d=1]/y=cu[d=1] grille >> tmpinterp.jnl
-    else 
-	echo Error : ${varin} unknown!!!!
-	exit
-    fi 
-    
-# Write second part of ferret script
-    cat << eod >>  tmpinterp.jnl
+define grid/like=${varout}[d=2]/x=cu[d=1]/y=cu[d=1] grille_u
+define grid/like=${varout}[d=2]/x=cv[d=1]/y=cv[d=1] grille_v
+define grid/like=${varout}[d=2]/x=cv[d=1]/y=cu[d=1] grille_t
 
-save/clobber/file=${fileout} ${varout}[d=2,g=grille,i=1:${imax},j=1:${jmax},l=1,gt=thour@asn]
-repeat/l=1:${tmax} save/file="${fileout}"/append ${varout}[d=2,g=grille,i=1:${imax},j=1:${jmax},gt=thour@asn]
+save/clobber/file=${fileout} ${varout}[d=2,g=${grille},l=1,gt=thour@asn]
+repeat/l=1:${tmax} save/file="${fileout}"/append ${varout}[d=2,g=${grille},gt=thour@asn]
 
 exit
@@ -164,8 +150,8 @@
     
 ###################################################################
-# Lanch interpolation with ferret
+# 3 - Launch interpolation with ferret
 ###################################################################
     ferret -nojnl <<eod >  /dev/null
-go tmpinterp.jnl
+go ${varin}.jnl
 quit
 eod
