source: branches/libIGCM_MPI_OpenMP/AA_clean_month @ 494

Last change on this file since 494 was 428, checked in by sdipsl, 13 years ago

Add iitm AIX6 machine

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