source: trunk/libIGCM/AA_clean_month @ 288

Last change on this file since 288 was 288, checked in by mafoipsl, 14 years ago

Add SUBLIT_DIR in messgae snt at the end of each simulation. Complete messages in clean_month.

File size: 5.1 KB
Line 
1#!/usr/bin/ksh
2
3# $Date: $
4# $Author: $
5# $Revision: $
6# IPSL (2006)
7#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
8
9#set -eu
10#set -vx
11
12libIGCM=::modipsl::/libIGCM
13
14#D--------------------------------------------------------------------==
15#D-                   -1. User modification place
16#D--------------------------------------------------------------------==
17
18#D- Increased verbosity (1, 2, 3)
19Verbosity=3
20
21#D- Low level debug : to bypass lib test checks and stack construction
22#D- Default=true
23DEBUG_debug=false
24
25#D--------------------------------------------------------------------==
26
27echo "clean month script :"
28echo "Script used to clean a month on SAVE directory !"
29echo "This script will erase some files !!! Be careful and read all informations !"
30echo "----"
31echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
32echo "----"
33
34#D--------------------------------------------------------------------==
35
36. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
37       ( ${DEBUG_debug} ) && IGCM_debug_Check
38. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
39       ( ${DEBUG_debug} ) && IGCM_card_Check
40. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
41       ( ${DEBUG_debug} ) && IGCM_date_Check
42#-------
43SUBMIT_DIR=${pwd}
44. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
45. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
46
47
48#==================================
49IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices
50
51for option in ${config_UserChoices[*]} ; do
52    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option}
53done
54
55IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
56IGCM_debug_PrintVariables 3 config_UserChoices_JobName
57if [ 3 -le ${Verbosity} ] ; then
58        echo "--------------Debug3-->" "config_UserChoices_LongName="
59        echo "--------------Debug3-->" \"${config_UserChoices_LongName}\"
60fi
61IGCM_debug_PrintVariables 3 config_UserChoices_TagName
62IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
63IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
64IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
65IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
66
67#====================================================
68#R_SAVE : Job output directory
69if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
70    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
71    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
72else
73    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
74fi
75IGCM_sys_TestDirArchive ${R_SAVE}
76[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
77
78if [ ! -f ${SUBMIT_DIR}/run.card ]; then
79    echo "You seem NOT to have a run.card in this directory !!"
80    echo "This script will fail because it doesn't know what to do without run.card avaible."
81    exit 1
82else
83    #===================================#
84    #        Read updated run.card      #
85    #===================================#
86    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
87    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
88    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
89    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
90    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
91
92    PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
93    echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
94    set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
95    CountListFiles=${#ListFiles[@]}
96
97    IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}."
98    if [ ${CountListFiles} -gt 0 ] ; then
99        for file in ${ListFiles[@]} ; do
100            IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
101        done
102
103        echo "\033[1;32mDo you REALLY want to erase all those files ?"
104        echo -n " Your answer (y/n) : \033[m"
105        read reponse
106        case ${reponse} in
107           
108            oui|OUI|o|y|yes|YES)
109                echo "OK. It will be erased."
110                IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
111                echo "done."
112                ;;
113            non|NON|n|no|NO)
114                echo "Nothing to do !"
115                ;;
116        esac
117    fi
118   
119    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
120    if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
121        echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?"
122        echo -n -e " Your answer (y/n) : \033[m"
123        read reponse
124        case ${reponse} in
125           
126            oui|OUI|o|y|yes|YES)
127                echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
128                IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
129                ;;
130            non|NON|n|no|NO)
131                echo "Nothing to do !"
132                ;;
133        esac
134    else
135        echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}.
136    fi
137fi
138exit 0
Note: See TracBrowser for help on using the repository browser.