source: trunk/libIGCM/AA_clean_PeriodLength @ 1510

Last change on this file since 1510 was 1464, checked in by mafoipsl, 6 years ago

Remove previous commit done for Irene.

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