source: branches/libIGCM_CESMEP/AA_clean_PeriodLength @ 1572

Last change on this file since 1572 was 1567, checked in by ssenesi, 18 months ago

house-keeping scripts hanlde CESMEP outputs

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 9.4 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# ID of your genci project. Curie only : post-processing jobs need it to run properly
13#-Q- curie export BRIDGE_MSUB_PROJECT=::default_project::
14#-Q- irene export BRIDGE_MSUB_PROJECT=::default_project::
15#-Q- irene-amd export BRIDGE_MSUB_PROJECT=::default_project::
16
17#set -eu
18#set -vx
19
20libIGCM=::modipsl::/libIGCM
21
22#D- Task type DO NOT CHANGE (computing, post-processing or checking)
23TaskType=post-processing
24
25#D--------------------------------------------------------------------==
26#D-                   -1. User modification place
27#D--------------------------------------------------------------------==
28
29#D- Increased verbosity (1, 2, 3)
30Verbosity=3
31
32#D- Low level debug : to bypass lib test checks and stack construction
33#D- Default=true
34DEBUG_debug=false
35
36#D--------------------------------------------------------------------==
37
38echo "clean PeriodLenght script :"
39echo "Script used to clean a PeriodLength from the IGCM_OUT directory !"
40echo "This script will erase files !!! Be careful and read all informations !"
41echo "----"
42echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
43echo "----"
44
45#D--------------------------------------------------------------------==
46
47. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
48. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
49. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
50#-------
51SUBMIT_DIR=$( pwd )
52. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
53. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
54#-------
55( ${DEBUG_debug} ) && IGCM_debug_Check
56( ${DEBUG_debug} ) && IGCM_card_Check
57( ${DEBUG_debug} ) && IGCM_date_Check
58
59clean_CESMEP()
60{
61    IGCM_card_DefineVariableFromOption ${prefix}config.card Post Cesmep
62    if [ ${config_Post_Cesmep} != FALSE ]; then
63        echo -e "\033[1;32mDo you want to erase the CESMEP atlas and dedicated CliMAF cache) ?"
64        echo -n -e " Your answer (y/n) : \033[m"
65        read reponse
66        case ${reponse} in
67            oui|OUI|o|y|yes|YES)
68                $SUBMIT_DIR/cesmep_lite/libIGCM_clean.sh
69                ;;
70        esac 
71    fi
72}
73
74#==================================
75# First of all
76#
77# Read libIGCM compatibility version in config.card
78# Read UserChoices section
79# Read Ensemble section
80# Read Post section
81# Define all netcdf output directories
82#==================================
83IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
84
85#==================================
86# Define default value to keep compatibility with previous card: means before changes due to TGCC
87if [ X${PackDefault} = Xtrue ] ; then
88  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
89else
90  config_Post_PackFrequency=NONE
91fi
92
93#==================================
94# Is the pack active
95if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
96  Pack=true
97fi
98
99IGCM_sys_TestDirArchive ${R_SAVE}
100[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
101
102if [ ! -f ${SUBMIT_DIR}/run.card ]; then
103  echo "You seem NOT to have a run.card in this directory !!"
104  echo "This script will fail because it doesn't know what to do without run.card available."
105  exit 1
106else
107  #===================================#
108  #        Read updated run.card      #
109  #===================================#
110  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
111  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
112  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
113  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
114
115  #
116  if [ X${run_Configuration_CumulPeriod} = X ] ; then
117    echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?"
118    echo -n -e " Your answer (y/n) : \033[m"
119    read reponse
120    case ${reponse} in
121
122    oui|OUI|o|y|yes|YES)
123      echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
124      IGCM_sys_Rm ${SUBMIT_DIR}/run.card
125      ;;
126    non|NON|n|no|NO)
127      echo "Nothing to do !"
128      ;;
129    esac
130    clean_CESMEP
131    exit 0
132  fi
133
134  PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
135  echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
136  set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
137  CountListFiles=${#ListFiles[@]}
138
139  if [ X${Pack} = Xtrue ] ; then
140    echo "Search files with ${PeriodDateEnd} in ${R_BUFR}"
141    set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " )
142    CountListFilesBuf=${#ListFilesBuf[@]}
143  else
144    CountListFilesBuf=0
145  fi
146
147  # If exist, erase REBUILD DIR
148  PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
149  CountRebuildDir=0
150  if [ X${config_Post_RebuildFrequency} != X ] ; then
151    set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" )
152    CountRebuildDir=${#RebuildDir[@]}
153  fi
154
155  IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}."
156  if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then
157    for file in ${ListFiles[@]} ; do
158      IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
159    done
160    if [ X${Pack} = Xtrue ] ; then
161      for file in ${ListFilesBuf[@]} ; do
162        IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
163      done
164    fi
165    echo -e "\033[1;32mDo you REALLY want to erase all those files ?"
166    echo -n -e " Your answer (y/n) : \033[m"
167    read reponse
168    case ${reponse} in
169
170      oui|OUI|o|y|yes|YES)
171        echo "OK. It will be erased."
172        IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
173        if [ X${Pack} = Xtrue ] ; then
174          IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
175        fi
176        echo "done."
177        ;;
178      non|NON|n|no|NO)
179        echo "Nothing to do !"
180        ;;
181    esac
182  fi
183
184  if [ ${CountRebuildDir} -gt 0 ] ; then
185    IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}."
186    for Dir in ${RebuildDir[@]} ; do
187      IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m"
188    done
189
190    echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?"
191    echo -n -e " Your answer (y/n) : \033[m"
192    read reponse
193    case ${reponse} in
194
195      oui|OUI|o|y|yes|YES)
196        echo "OK. It will be erased."
197        find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \;
198        echo "done."
199        ;;
200      non|NON|n|no|NO)
201        echo "Nothing to do !"
202        ;;
203    esac
204  fi
205
206  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
207  if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
208
209    echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?"
210    echo -n -e " Your answer (y/n) : \033[m"
211    read reponse
212    case ${reponse} in
213
214      oui|OUI|o|y|yes|YES)
215        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
216        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
217        ;;
218      non|NON|n|no|NO)
219        echo "Nothing to do !"
220        ;;
221    esac
222  else
223    echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
224  fi
225
226  if [ X${run_Configuration_CumulPeriod} = X1 ] ; then
227    echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?"
228    echo -n -e " Your answer (y/n) : \033[m"
229    read reponse
230    case ${reponse} in
231
232      oui|OUI|o|y|yes|YES)
233        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
234        IGCM_sys_Rm ${SUBMIT_DIR}/run.card
235        ;;
236      non|NON|n|no|NO)
237        echo "Nothing to do !"
238        ;;
239    esac
240  else
241    # if not first period
242    Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
243    Script_Output_Job=${Script_Output_Prefix}_${config_UserChoices_JobName}
244    Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${run_Configuration_CumulPeriod} )
245
246    echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?"
247    echo -n -e " Your answer (y/n) : \033[m"
248    read reponse
249    case ${reponse} in
250
251      oui|OUI|o|y|yes|YES)
252        cp ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$
253        sed -e"s/${Script_Output_Job}.[0-9][0-9][0-9][0-9][0-9][0-9]/${Script_Output}/"  ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$  >${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
254        echo "Job : Job_${config_UserChoices_JobName} modified."
255        echo "Old job saved here : Job_${config_UserChoices_JobName}_SAVED_$$"
256        ;;
257      non|NON|n|no|NO)
258        echo "Nothing done in Job_${config_UserChoices_JobName} !"
259        ;;
260    esac
261
262  fi
263
264  clean_CESMEP
265 
266fi
267exit 0
Note: See TracBrowser for help on using the repository browser.