source: tags/libIGCM_v2.6/AA_clean_month @ 1456

Last change on this file since 1456 was 1185, checked in by sdipsl, 9 years ago

Bugfix. It failed if run.card contained PeriodState?="Fatal" and PeriodDateBegin?, PeriodDateEnd? and CumulPeriod? were empty.

  • 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: 7.6 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- Task type (computing or post-processing)
19TaskType=post-processing
20
21#D--------------------------------------------------------------------==
22#D-                   -1. User modification place
23#D--------------------------------------------------------------------==
24
25#D- Increased verbosity (1, 2, 3)
26Verbosity=3
27
28#D- Low level debug : to bypass lib test checks and stack construction
29#D- Default=true
30DEBUG_debug=false
31
32#D--------------------------------------------------------------------==
33
34echo "clean month script :"
35echo "Script used to clean a month on SAVE directory !"
36echo "This script will erase some files !!! Be careful and read all informations !"
37echo "----"
38echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
39echo "----"
40
41#D--------------------------------------------------------------------==
42
43. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
44. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
45. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
46#-------
47SUBMIT_DIR=$( pwd )
48. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
49. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
50#-------
51( ${DEBUG_debug} ) && IGCM_debug_Check
52( ${DEBUG_debug} ) && IGCM_card_Check
53( ${DEBUG_debug} ) && IGCM_date_Check
54
55#==================================
56# First of all
57#
58# Read libIGCM compatibility version in config.card
59# Read UserChoices section
60# Read Ensemble section
61# Read Post section
62# Define all netcdf output directories
63#==================================
64IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
65
66#==================================
67# Define default value to keep compatibility with previous card: means before changes due to TGCC
68if [ X${PackDefault} = Xtrue ] ; then
69  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
70else
71  config_Post_PackFrequency=NONE
72fi
73
74#==================================
75# Is the pack active
76if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
77  Pack=true
78fi
79
80IGCM_sys_TestDirArchive ${R_SAVE}
81[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
82
83if [ ! -f ${SUBMIT_DIR}/run.card ]; then
84  echo "You seem NOT to have a run.card in this directory !!"
85  echo "This script will fail because it doesn't know what to do without run.card available."
86  exit 1
87else
88  #===================================#
89  #        Read updated run.card      #
90  #===================================#
91  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
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  #
97  if [ X${run_Configuration_CumulPeriod} = X ] ; then
98    echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?"
99    echo -n -e " Your answer (y/n) : \033[m"
100    read reponse
101    case ${reponse} in
102
103    oui|OUI|o|y|yes|YES)
104      echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
105      IGCM_sys_Rm ${SUBMIT_DIR}/run.card
106      ;;
107    non|NON|n|no|NO)
108      echo "Nothing to do !"
109      ;;
110    esac
111    exit 0
112  fi
113
114  PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
115  echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
116  set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
117  CountListFiles=${#ListFiles[@]}
118
119  if [ X${Pack} = Xtrue ] ; then
120    echo "Search files with ${PeriodDateEnd} in ${R_BUFR}"
121    set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " )
122    CountListFilesBuf=${#ListFilesBuf[@]}
123  else
124    CountListFilesBuf=0
125  fi
126
127  # If exist, erase REBUILD DIR
128  PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
129  CountRebuildDir=0
130  if [ X${config_Post_RebuildFrequency} != X ] ; then
131    set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" )
132    CountRebuildDir=${#RebuildDir[@]}
133  fi
134
135  IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}."
136  if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then
137    for file in ${ListFiles[@]} ; do
138      IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
139    done
140    if [ X${Pack} = Xtrue ] ; then
141      for file in ${ListFilesBuf[@]} ; do
142        IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
143      done
144    fi
145    echo -e "\033[1;32mDo you REALLY want to erase all those files ?"
146    echo -n -e " Your answer (y/n) : \033[m"
147    read reponse
148    case ${reponse} in
149
150      oui|OUI|o|y|yes|YES)
151        echo "OK. It will be erased."
152        IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
153        if [ X${Pack} = Xtrue ] ; then
154          IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
155        fi
156        echo "done."
157        ;;
158      non|NON|n|no|NO)
159        echo "Nothing to do !"
160        ;;
161    esac
162  fi
163
164  if [ ${CountRebuildDir} -gt 0 ] ; then
165    IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}."
166    for Dir in ${RebuildDir[@]} ; do
167      IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m"
168    done
169
170    echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?"
171    echo -n -e " Your answer (y/n) : \033[m"
172    read reponse
173    case ${reponse} in
174
175      oui|OUI|o|y|yes|YES)
176        echo "OK. It will be erased."
177        find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \;
178        echo "done."
179        ;;
180      non|NON|n|no|NO)
181        echo "Nothing to do !"
182        ;;
183    esac
184  fi
185
186  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
187  if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
188
189    echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?"
190    echo -n -e " Your answer (y/n) : \033[m"
191    read reponse
192    case ${reponse} in
193
194      oui|OUI|o|y|yes|YES)
195        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
196        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
197        ;;
198      non|NON|n|no|NO)
199        echo "Nothing to do !"
200        ;;
201    esac
202  else
203    echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
204  fi
205
206  if [ X${run_Configuration_CumulPeriod} = X1 ] ; then
207    echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?"
208    echo -n -e " Your answer (y/n) : \033[m"
209    read reponse
210    case ${reponse} in
211
212      oui|OUI|o|y|yes|YES)
213        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
214        IGCM_sys_Rm ${SUBMIT_DIR}/run.card
215        ;;
216      non|NON|n|no|NO)
217        echo "Nothing to do !"
218        ;;
219    esac
220  fi
221fi
222exit 0
Note: See TracBrowser for help on using the repository browser.