Index: branches/libIGCM_CESMEP/AA_create_se
===================================================================
--- branches/libIGCM_CESMEP/AA_create_se	(revision 1553)
+++ branches/libIGCM_CESMEP/AA_create_se	(revision 1554)
@@ -719,4 +719,10 @@
 fi
 
+# Execute C-ESM-EP driver (which launches jobs)
+set -x
+if [ $PostCesmep = SE ] ; then
+    ${SUBMIT_DIR}/cesmep_lite/libIGCM_post.sh $DateBegin $PeriodDateEnd
+fi
+
 # Clean RUN_DIR_PATH (necessary for cesium and titane only)
 IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: branches/libIGCM_CESMEP/AA_create_ts
===================================================================
--- branches/libIGCM_CESMEP/AA_create_ts	(revision 1553)
+++ branches/libIGCM_CESMEP/AA_create_ts	(revision 1554)
@@ -820,5 +820,5 @@
 IGCM_debug_Verif_Exit
 # --------------------------------------------------------------------
-#D- Submit MONITORING
+#D- Submit MONITORING and C-ESM-EP
 # --------------------------------------------------------------------
 if ( [ X${TsTask} = X2D ] || [ X${TsTask} = X3D ] || [ X${TsTask} = X ] ) ; then
@@ -827,4 +827,7 @@
     Script_Post_Output=monitoring.${PeriodDateEnd}
     IGCM_sys_QsubPost monitoring
+    if [ $PostCesmep = TS ] ; then
+	${SUBMIT_DIR}/cesmep_lite/libIGCM_post.sh $DateBegin $PeriodDateEnd
+    fi
   fi
 fi
Index: branches/libIGCM_CESMEP/AA_pack_output
===================================================================
--- branches/libIGCM_CESMEP/AA_pack_output	(revision 1553)
+++ branches/libIGCM_CESMEP/AA_pack_output	(revision 1554)
@@ -330,4 +330,9 @@
 done
 
+# Execute C-ESM-EP driver (which launches jobs)
+if [ $PostCesmep = Pack ] ; then
+    ${SUBMIT_DIR}/cesmep_lite/libIGCM_post.sh $DateBegin $PeriodDateEnd
+fi
+
 # Flush post-processing submission
 if [ -f ${R_BUFR}/FlushPost_${DateEnd}.ksh ] ; then
Index: branches/libIGCM_CESMEP/ins_job
===================================================================
--- branches/libIGCM_CESMEP/ins_job	(revision 1553)
+++ branches/libIGCM_CESMEP/ins_job	(revision 1554)
@@ -653,4 +653,37 @@
   
 fi
+#
+# Install a light copy of C-ESM-EP in SUBMIT_DIR/Cesmep and create a
+# C-ESM-EP launch script there.
+#
+[ ${new_struct} == yes ] && prefix="$JobName/"  
+IGCM_card_DefineVariableFromOption ${prefix}config.card Post Cesmep
+
+# Compute mail adress - inspired by libIGCM_post.ksh - should be turned in a function 
+if [ ! -z ${config_UserChoices_MailName} ] ; then
+    MailAdress=${config_UserChoices_MailName}
+elif [ -f ~/.forward ] ; then
+    MailAdress=$( cat ~/.forward )
+else
+    MailAdress=${USER}
+fi
+
+#
+if [ ${config_Post_Cesmep} != FALSE ]; then
+    if [ X"${SYSTEM}" == "Xirene" ] ; then
+       IGCM_card_DefineVariableFromOption ${prefix}config.card Post CesmepCode
+       IGCM_card_DefineVariableFromOption ${prefix}config.card Post CesmepComparison
+       IGCM_card_DefineVariableFromOption ${prefix}config.card UserChoices DateBegin
+       # Need R_SAVE 
+       IGCM_config_CommonConfiguration ${prefix}config.card
+       ${config_Post_CesmepCode}/libIGCM_install.sh $(pwd)/${prefix} \
+		   ${config_Post_CesmepComparison} $JobName ${R_SAVE} ${ProjectID} \
+		   ${MailAdress} ${config_UserChoices_DateBegin} ${config_Post_Cesmep} 
+   else
+       echo "\nERROR Cannot yet handle CESMEP on this computer system"
+       echo "=> Variable Cesmep in config.card's section Post must be set to FALSE"
+       exit 5
+   fi
+fi
 #-
 [[ ${x_v} = 'verbose' ]] && print - "";
Index: branches/libIGCM_CESMEP/libIGCM_config/libIGCM_config.ksh
===================================================================
--- branches/libIGCM_CESMEP/libIGCM_config/libIGCM_config.ksh	(revision 1553)
+++ branches/libIGCM_CESMEP/libIGCM_config/libIGCM_config.ksh	(revision 1554)
@@ -179,4 +179,46 @@
   if ( [ X${config_Post_MetricsPCMDI} = X${NULL_STR} ] || [ X${config_Post_MetricsPCMDI} = X ] ) ; then
     config_Post_MetricsPCMDI=FALSE
+  fi
+
+  #====================================================
+  # Cesmep : apply default value FALSE if not defined, and if TRUE
+  # set it based on an adhoc algorithm
+  if ( [ X${config_Post_Cesmep} = XNONE ] || [ X${config_Post_Cesmep} = X ] ) ; then
+    config_Post_Cesmep=FALSE
+  elif [ X${config_Post_Cesmep} = XTRUE ]; then 
+    if ([ ! X${config_Post_SeasonalFrequency} = XNONE ] && [ ! X${config_Post_SeasonalFrequency} = X ] ) ; then
+      config_Post_Cesmep="SE"
+    elif ([ ! X${config_Post_TimeSeriesFrequency} = XNONE ] && [ ! X${config_Post_TimeSeriesFrequency} = X ] ) ; then
+      config_Post_Cesmep="TS"
+    elif ([ ! X${config_Post_PackFrequency} = XNONE ] && [ ! X${config_Post_PackFrequency} = X ] ) ; then
+      config_Post_Cesmep="Pack"
+    else
+      # This covers case SpaceName=TEST with no SE nor TS (nor Pack)
+      config_Post_Cesmep="AtEnd"
+    fi
+    #
+  else
+      # Check that user-provided value make sense
+      if ([ X${config_Post_Cesmep} = XSE ]) ; then
+	  if ([ X${config_Post_SeasonalFrequency} = XNONE ] || [ X${config_Post_SeasonalFrequency} = X ] ) ; then
+	      IGCM_debug_Exit "Cannot use SE for Cesmep : SE post-processing is not active"
+	  fi
+      elif ([ X${config_Post_Cesmep} = XTS ]) ; then
+	  if ([ X${config_Post_TimeSeriesFrequency} = XNONE ] || [ X${config_Post_TimeSeriesFrequency} = X ] ) ; then
+	      IGCM_debug_Exit "Cannot use TS for Cesmep : TS post-processing is not active"
+	  fi
+      elif ([ X${config_Post_Cesmep} = XPack ]) ; then
+	  if ([ X${config_Post_PackFrequency} = XNONE ] || [ X${config_Post_PackFrequency} = X ] ) ; then
+	      IGCM_debug_Exit "Cannot use Packed output for Cesmep : Pack post-processing is not active"
+	  fi
+      elif ([ X${config_Post_Cesmep} != XAtend ]) ; then
+	  IGCM_debug_Exit "config.card Post section value for Cesmep is invalid (use SE, TS, Pack, AtEnd or TRUE) : ${config_Post_Cesmep}"
+      fi
+  fi
+  if ( [ X${config_Post_CesmepComparison} = XNONE ] || [ X${config_Post_CesmepComparison} = X ] ) ; then
+      config_Post_CesmepComparison=standard_comparison
+  fi
+  if ( [ X${config_Post_CesmepCode} = XNONE ] || [ X${config_Post_CesmepCode} = X ] ) ; then
+      config_Post_CesmepCode=/ccc/work/cont003/gen0826/senesis/cesmep
   fi
 
Index: branches/libIGCM_CESMEP/libIGCM_post/libIGCM_post.ksh
===================================================================
--- branches/libIGCM_CESMEP/libIGCM_post/libIGCM_post.ksh	(revision 1553)
+++ branches/libIGCM_CESMEP/libIGCM_post/libIGCM_post.ksh	(revision 1554)
@@ -29,4 +29,5 @@
   TimeSeriesFrequency=false
   SeasonalFrequency=false
+  CesmepAtEnd=false
   unset list_post
   #
@@ -108,4 +109,10 @@
     fi
   fi
+
+  if ( [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] && [ X${config_Post_Cesmep} = XAtEnd ] ) ; then
+      CesmepAtEnd=true
+  fi
+  
+  
   IGCM_debug_PopStack "IGCM_post_Configure"
 }
@@ -197,4 +204,5 @@
             echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
             echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
+	    echo "export PostCesmep=${config_Post_Cesmep}                  " >> ${FunctionPath}
             echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
 #           if [ X${MASTER} = Xtitane ] ; then
@@ -234,4 +242,5 @@
                     export RESOL_SRF=${RESOL_SRF}
                     export RESOL_SBG=${RESOL_SBG}
+		    export PostCesmep=${config_Post_Cesmep}
                     export listVarEnv=${listVarEnv}
                     export Script_Post_Output=${Script_Post_Output}
@@ -315,4 +324,5 @@
               echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
               echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
+	      echo "export PostCesmep=${config_Post_Cesmep}                  " >> ${FunctionPath}
               echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
 #             if [ X${MASTER} = Xtitane ] ; then
@@ -353,4 +363,5 @@
                         export RESOL_SBG=${RESOL_SBG}
                         export listVarEnv=${listVarEnv}
+			export PostCesmep=${config_Post_Cesmep}
                         export Script_Post_Output=${Script_Post_Output}
                         . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
@@ -415,4 +426,5 @@
       echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
       echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
+      echo "export PostCesmep=${config_Post_Cesmep}                  " >> ${FunctionPath}
       echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
 #     if [ X${MASTER} = Xtitane ] ; then
@@ -448,4 +460,5 @@
             export RESOL_SBG=${RESOL_SBG}
             export listVarEnv=${listVarEnv}
+            export PostCesmep=${config_Post_Cesmep}
             export Script_Post_Output=${Script_Post_Output}
             . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
@@ -499,4 +512,5 @@
     export StandAlone=false
     export listVarEnv=${listVarEnv}
+    export PostCesmep=${config_Post_Cesmep}
     export Script_Post_Output=${Script_Post_Output}
     . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
@@ -529,4 +543,5 @@
       export StandAlone=false
       export listVarEnv=${listVarEnv}
+      export PostCesmep=${config_Post_Cesmep}
       export Script_Post_Output=${Script_Post_Output}
       . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
@@ -560,4 +575,5 @@
       echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
       echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+      echo "export PostCesmep=${config_Post_Cesmep}        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
       echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
       echo "export script=${script}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
@@ -590,4 +606,5 @@
         export StandAlone=false
         export listVarEnv=${listVarEnv}
+        export PostCesmep=${config_Post_Cesmep}
         export Script_Post_Output=${Script_Post_Output}
         . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
@@ -645,4 +662,5 @@
       export RESOL_SBG=${RESOL_SBG}
       export listVarEnv=${listVarEnv}
+      export PostCesmep=${config_Post_Cesmep}
       export Script_Post_Output=${Script_Post_Output}
       . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
@@ -655,4 +673,15 @@
 EOF
   fi
+
+  #========== CESMEP POST-PROCESSING at job end  ========#
+
+  IGCM_debug_Print 1 "Possibly launching C-ESM-EP run script"
+  if [ ${CesmepAtEnd} = true ] ; then
+      #
+      IGCM_debug_Print 1 "Launching C-ESM-EP run script"
+      ${SUBMIT_DIR}/cesmep_lite/libIGCM_post.sh $DateBegin $PeriodDateEnd
+  fi
+
+  
   IGCM_debug_PopStack "IGCM_post_Submit"
 }
@@ -790,5 +819,6 @@
   # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
   # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
-  # --> turn on post-processing submission when their modulo is zero
+  # --> turn on post-processing submission when their modulo is zero by 
+  # setting env variable post_freq
   # Input parameter are the name of the variable, not the frequency value itself
   # example
