source: tags/libIGCM_v1_10/AA_clean_month @ 1170

Last change on this file since 1170 was 373, checked in by sdipsl, 14 years ago

Remove libIGCM_sys_claude.ksh and libIGCM_sys_calculo.ksh
Update/homogenize all headers usgin the new fixed-length keyword syntax regarding properties keywords
$Rev:: 13 i $: Revision of last commit
$Author:: harry $: Author of last commit
$Date:: 2006-03-15 02:33:03 -0500 (Wed, 15 Mar 2006) $: Date of last commit
Add / update original author and contact when missing

  • Property svn:keywords set to Revision Author Date
File size: 5.5 KB
Line 
1#!/bin/ksh
2#**************************************************************
3# Author: Martial Mancip
4# Contact: Martil.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_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
60IGCM_debug_PrintVariables 3 config_UserChoices_JobName
61if [ 3 -le ${Verbosity} ] ; then
62        echo "--------------Debug3-->" "config_UserChoices_LongName="
63        echo "--------------Debug3-->" \"${config_UserChoices_LongName}\"
64fi
65IGCM_debug_PrintVariables 3 config_UserChoices_TagName
66IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
67IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
68IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
69IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
70
71#====================================================
72#R_SAVE : Job output directory
73if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
74    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
75    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
76else
77    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
78fi
79IGCM_sys_TestDirArchive ${R_SAVE}
80[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
81
82if [ ! -f ${SUBMIT_DIR}/run.card ]; then
83    echo "You seem NOT to have a run.card in this directory !!"
84    echo "This script will fail because it doesn't know what to do without run.card avaible."
85    exit 1
86else
87    #===================================#
88    #        Read updated run.card      #
89    #===================================#
90    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
91    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
92    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
93    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
94    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
95
96    PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
97    echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
98    set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
99    CountListFiles=${#ListFiles[@]}
100
101    IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}."
102    if [ ${CountListFiles} -gt 0 ] ; then
103        for file in ${ListFiles[@]} ; do
104            IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
105        done
106
107        echo "\033[1;32mDo you REALLY want to erase all those files ?"
108        echo -n " Your answer (y/n) : \033[m"
109        read reponse
110        case ${reponse} in
111           
112            oui|OUI|o|y|yes|YES)
113                echo "OK. It will be erased."
114                IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
115                echo "done."
116                ;;
117            non|NON|n|no|NO)
118                echo "Nothing to do !"
119                ;;
120        esac
121    fi
122   
123    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
124    if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
125        echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?"
126        echo -n -e " Your answer (y/n) : \033[m"
127        read reponse
128        case ${reponse} in
129           
130            oui|OUI|o|y|yes|YES)
131                echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
132                IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
133                ;;
134            non|NON|n|no|NO)
135                echo "Nothing to do !"
136                ;;
137        esac
138    else
139        echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
140    fi
141fi
142exit 0
Note: See TracBrowser for help on using the repository browser.