#!/usr/bin/ksh # $Date: $ # $Author: $ # $Revision: $ # IPSL (2006) # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC #set -eu #set -vx libIGCM=::modipsl::/libIGCM #D--------------------------------------------------------------------== #D- -1. User modification place #D--------------------------------------------------------------------== #D- Increased verbosity (1, 2, 3) Verbosity=3 #D- Low level debug : to bypass lib test checks and stack construction #D- Default=true DEBUG_debug=false #D--------------------------------------------------------------------== echo "clean month script :" echo "Script used to clean a month on SAVE directory !" echo "This script will erase some files !!! Be careful and read all informations !" echo "----" echo "It must be called in Experience directory (so-called SUBMIT_DIR)." echo "----" #D--------------------------------------------------------------------== . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ( ${DEBUG_debug} ) && IGCM_debug_Check . ${libIGCM}/libIGCM_card/libIGCM_card.ksh ( ${DEBUG_debug} ) && IGCM_card_Check . ${libIGCM}/libIGCM_date/libIGCM_date.ksh ( ${DEBUG_debug} ) && IGCM_date_Check #------- SUBMIT_DIR=${pwd} . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh . ${libIGCM}/libIGCM_config/libIGCM_config.ksh #================================== IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices for option in ${config_UserChoices[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} done IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" IGCM_debug_PrintVariables 3 config_UserChoices_JobName if [ 3 -le ${Verbosity} ] ; then echo "--------------Debug3-->" "config_UserChoices_LongName=" echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" fi IGCM_debug_PrintVariables 3 config_UserChoices_TagName IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength #==================================================== #R_SAVE : Job output directory if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} else R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} fi IGCM_sys_TestDirArchive ${R_SAVE} [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" if [ ! -f ${SUBMIT_DIR}/run.card ]; then echo "You seem NOT to have a run.card in this directory !!" echo "This script will fail because it doesn't know what to do without run.card avaible." exit 1 else #===================================# # Read updated run.card # #===================================# IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) echo "Search files with ${PeriodDateEnd} in ${R_SAVE}" set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) CountListFiles=${#ListFiles[@]} IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." if [ ${CountListFiles} -gt 0 ] ; then for file in ${ListFiles[@]} ; do IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" done echo "\033[1;32mDo you REALLY want to erase all those files ?" echo -n " Your answer (y/n) : \033[m" read reponse case ${reponse} in oui|OUI|o|y|yes|YES) echo "OK. It will be erased." IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" echo "done." ;; non|NON|n|no|NO) echo "Nothing to do !" ;; esac fi IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" echo -n -e " Your answer (y/n) : \033[m" read reponse case ${reponse} in oui|OUI|o|y|yes|YES) echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" ;; non|NON|n|no|NO) echo "Nothing to do !" ;; esac else echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." fi fi exit 0