Index: trunk/libIGCM/AA_pack_output
===================================================================
--- trunk/libIGCM/AA_pack_output	(revision 585)
+++ trunk/libIGCM/AA_pack_output	(revision 590)
@@ -3,5 +3,5 @@
 #-Q- cesium ## CESIUM   CEA ##
 #-Q- cesium ######################
-#-Q- cesium #MSUB -r PACKOUTPUT    # Nom du job                
+#-Q- cesium #MSUB -r PACKOUTPUT    # Nom du job
 #-Q- cesium #MSUB -N 1              # Reservation du noeud
 #-Q- cesium #MSUB -n 1              # Reservation du processus
@@ -27,5 +27,5 @@
 #-Q- sx8brodie # Nom du travail LoadLeveler
 #-Q- sx8brodie # @ job_name   = PACKOUTPUT
-#-Q- sx8brodie # Fichier de sortie standard du travail       
+#-Q- sx8brodie # Fichier de sortie standard du travail
 #-Q- sx8brodie # @ output     = $(job_name).$(jobid)
 #-Q- sx8brodie # Fichier de sortie d'erreur du travail
@@ -81,5 +81,5 @@
 #-Q- sx9mercure ## CESIUM   CEA ##
 #-Q- sx9mercure ######################
-#-Q- sx9mercure #MSUB -r PACKOUTPUT    # Nom du job                
+#-Q- sx9mercure #MSUB -r PACKOUTPUT    # Nom du job
 #-Q- sx9mercure #MSUB -N 1              # Reservation du noeud
 #-Q- sx9mercure #MSUB -n 1              # Reservation du processus
@@ -91,5 +91,5 @@
 #-Q- titane ## TITANE   CEA     ##
 #-Q- titane ######################
-#-Q- titane #MSUB -r PACKOUTPUT    # Nom du job                
+#-Q- titane #MSUB -r PACKOUTPUT    # Nom du job
 #-Q- titane #MSUB -eo
 #-Q- titane #MSUB -n 1              # Reservation du processus
@@ -200,10 +200,8 @@
 fi
 
-#
+#====================================================
 # First of all
 #
-#### 0- lecture de config.card 
-#### on veut les renseignements suivants : 
-#### JobName, PATH_SIMUL, DateBegin et DateEnd
+# Read config.card
 
 IGCM_card_DefineArrayFromSection     ${CARD_DIR}/config.card UserChoices
@@ -249,6 +247,5 @@
 # Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
 JobName=${config_UserChoices_JobName}
-PATH_SIMUL=${R_BUFR}
-echo $JobName $PATH_SIMUL $DateBegin $DateEnd
+echo $JobName $DateBegin $DateEnd
 
 # ------------------------------------------------------------------
@@ -268,5 +265,5 @@
 
   IGCM_debug_PrintVariables 3 number_pack
-  DaysTemp=$( IGCM_date_DaysInNextPeriod ${date_begin_pack} ${PeriodPack} )
+  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
   date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
 
@@ -283,45 +280,45 @@
       # Loop over the file type and pack them when in between date_begin_pack and date_end_pack
       for myType in ${fileType} ; do
-	grep ${myType} liste_files.${dirID}.txt > liste_files.${dirID}.${myType}.txt
-	nbfile=0
-	for file in $( gawk '{print $11}' liste_files.${dirID}.${myType}.txt ); do
-	  extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
-	  date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
-	  # echo pack nÂ°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
-	  if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then 
-	    echo ${file} >> liste_pack_${myType}_${number_pack}.txt
-	    ncdump -h ${file} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> liste_variables_${myType}_${number_pack}.txt
-	    (( nbfile = nbfile + 1 ))
-	  fi
-	done
-	# Select list of variables to work with
-	list_var=$( cat liste_variables_${myType}_${number_pack}.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d ',' )
-	liste_file_tmp=$( for i in $( cat liste_pack_${myType}_${number_pack}.txt ) ; do basename $i ; done )
-	# Create packed files
-	IGCM_debug_Print 1 "Ncrcat ongoing for ${dir} and ${myType}"
-	output=${JobName}_${date_begin_pack}_${date_end_pack}_${myType}
-	#cat liste_pack_${myType}_${number_pack}.txt | xargs ncrcat -v ${list_var} -o ${output}
-	if [ X${list_var} = X ] ; then
-	  ncrcat --omp_num_threads 4 -p ${dir} ${liste_file_tmp} --output ${output}
-	else
-	  ncrcat --omp_num_threads 4 -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
-	fi
-	# ------------------------------------------------------------------
+        grep ${myType} liste_files.${dirID}.txt > liste_files.${dirID}.${myType}.txt
+        nbfile=0
+        for file in $( gawk '{print $11}' liste_files.${dirID}.${myType}.txt ); do
+          extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
+          date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+          # echo pack nÂ°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
+          if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
+            echo ${file} >> liste_pack_${myType}_${number_pack}.txt
+            ncdump -h ${file} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> liste_variables_${myType}_${number_pack}.txt
+            (( nbfile = nbfile + 1 ))
+          fi
+        done
+        # Select list of variables to work with
+        list_var=$( cat liste_variables_${myType}_${number_pack}.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d ',' )
+        liste_file_tmp=$( for i in $( cat liste_pack_${myType}_${number_pack}.txt ) ; do basename $i ; done )
+        # Create packed files
+        IGCM_debug_Print 1 "Ncrcat ongoing for ${dir} and ${myType}"
+        output=${JobName}_${date_begin_pack}_${date_end_pack}_${myType}
+        #cat liste_pack_${myType}_${number_pack}.txt | xargs ncrcat -v ${list_var} -o ${output}
+        if [ X${list_var} = X ] ; then
+          IGCM_sys_ncrcat -p ${dir} ${liste_file_tmp} --output ${output}
+        else
+          IGCM_sys_ncrcat -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
+        fi
+        # ------------------------------------------------------------------
         # Test if all was right before proceeding further
         # ------------------------------------------------------------------
-	IGCM_debug_Verif_Exit_Post
+        IGCM_debug_Verif_Exit_Post
         # Save it
-	IGCM_sys_Put_Out ${output} ${R_SAVE}/$( echo $dir | sed "s:${R_BUFR}/::" )/${output}
-	# ------------------------------------------------------------------
+        IGCM_sys_Put_Out ${output} ${R_SAVE}/$( echo $dir | sed "s:${R_BUFR}/::" )/${output}
+        # ------------------------------------------------------------------
         # Test if all was right before proceeding further
         # ------------------------------------------------------------------
-	IGCM_debug_Verif_Exit_Post
+        IGCM_debug_Verif_Exit_Post
         # Clean file produced by ncrcat
-	IGCM_sys_Rm ${output}
+        IGCM_sys_Rm ${output}
         # Clean files used by ncrcat
-	cat liste_pack_${myType}_${number_pack}.txt | xargs rm
+        cat liste_pack_${myType}_${number_pack}.txt | xargs rm
         # Save the list of files that has been pack (ncrcat)
-	mv liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
-	IGCM_debug_Print 1 "Ncrcat and cleaning done for ${dir} and ${myType}"
+        mv liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
+        IGCM_debug_Print 1 "Ncrcat and cleaning done for ${dir} and ${myType}"
       done
     done
@@ -331,2 +328,7 @@
   date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
 done
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+date
