source: trunk/libIGCM/AA_clean_or_continue @ 1576

Last change on this file since 1576 was 1575, checked in by jgipsl, 15 months ago

Copied AA_clean_PeriodLength into AA_clean_or_continue as decided during the platform meeting 15/2. Added help option in the new script. The old script is used only to tell users to use the new one. Also remove the script continue_simulation which was never used.

  • 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: 10.3 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--------------------------------------------------------------------==
37echo ""
38echo "clean_or_continue.job "
39if  [ $# -gt 0 ] ; then
40    # Print help and exit
41    echo ""
42    echo "The script is called from in the your experiment directory, the so-called SUBMIT_DIR, in the following way"
43    echo "../../../libIGCM/clean_or_continue.job -h      : to print following information"
44    echo "../../../libIGCM/clean_or_continue.job         : normal execution"
45    echo ""
46    echo "This script can be used for 3 cases:"
47    echo "1- The simulation crashed and you have PeriodState=Fatal in run.card."
48    echo "For this case, all output from the current PeriodLength set in run.card will be deleted. "
49    echo "You need to answer yes to the questions."
50    echo ""
51    echo "2- The simulation stopped due to an exceeded time limit, PeriodState=Running in run.card".
52    echo "As for case 1, all output from the current PeriodLength will be deleted and you should answer yes to questions".
53    echo ""
54    echo "3- The simulation is completed but you want to continue it, PeriodState=Completed in run.card."
55    echo "For this case, you just need to change DateEnd in config.card and launch this script."
56    echo ""
57    echo "For all cases, the run.card is changed as needed and the number for the current period is set in the main Job_ for the Script_Output_ file"
58    echo ""
59    echo "This script needs to delete files to work correctly. Therefore you should answer yes to the questions."
60    echo ""
61
62    exit
63fi
64echo ""
65echo "This script needs to delete files to work correctly. Therefore you should answer yes to the questions."
66echo "Use ../../../libIGCM/clean_or_contine.job -h  for more information"
67echo ""
68
69#D--------------------------------------------------------------------==
70
71. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
72. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
73. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
74#-------
75SUBMIT_DIR=$( pwd )
76. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
77. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
78#-------
79( ${DEBUG_debug} ) && IGCM_debug_Check
80( ${DEBUG_debug} ) && IGCM_card_Check
81( ${DEBUG_debug} ) && IGCM_date_Check
82
83#==================================
84# First of all
85#
86# Read libIGCM compatibility version in config.card
87# Read UserChoices section
88# Read Ensemble section
89# Read Post section
90# Define all netcdf output directories
91#==================================
92IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
93
94#==================================
95# Define default value to keep compatibility with previous card: means before changes due to TGCC
96if [ X${PackDefault} = Xtrue ] ; then
97  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
98else
99  config_Post_PackFrequency=NONE
100fi
101
102#==================================
103# Is the pack active
104if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
105  Pack=true
106fi
107
108IGCM_sys_TestDirArchive ${R_SAVE}
109[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
110
111if [ ! -f ${SUBMIT_DIR}/run.card ]; then
112  echo "You seem NOT to have a run.card in this directory !!"
113  echo "This script will fail because it doesn't know what to do without run.card available."
114  exit 1
115else
116  #===================================#
117  #        Read updated run.card      #
118  #===================================#
119  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
120  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
121  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
122  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
123
124  #
125  if [ X${run_Configuration_CumulPeriod} = X ] ; then
126    echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?"
127    echo -n -e " Your answer (y/n) : \033[m"
128    read reponse
129    case ${reponse} in
130
131    oui|OUI|o|y|yes|YES)
132      echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
133      IGCM_sys_Rm ${SUBMIT_DIR}/run.card
134      ;;
135    non|NON|n|no|NO)
136      echo "Nothing to do !"
137      ;;
138    esac
139    exit 0
140  fi
141
142  PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
143  echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
144  set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
145  CountListFiles=${#ListFiles[@]}
146
147  if [ X${Pack} = Xtrue ] ; then
148    echo "Search files with ${PeriodDateEnd} in ${R_BUFR}"
149    set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " )
150    CountListFilesBuf=${#ListFilesBuf[@]}
151  else
152    CountListFilesBuf=0
153  fi
154
155  # If exist, erase REBUILD DIR
156  PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
157  CountRebuildDir=0
158  if [ X${config_Post_RebuildFrequency} != X ] ; then
159    set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" )
160    CountRebuildDir=${#RebuildDir[@]}
161  fi
162
163  IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}."
164  if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then
165    for file in ${ListFiles[@]} ; do
166      IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
167    done
168    if [ X${Pack} = Xtrue ] ; then
169      for file in ${ListFilesBuf[@]} ; do
170        IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
171      done
172    fi
173    echo -e "\033[1;32mDo you REALLY want to erase all those files ?"
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        IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
181        if [ X${Pack} = Xtrue ] ; then
182          IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
183        fi
184        echo "done."
185        ;;
186      non|NON|n|no|NO)
187        echo "Nothing to do !"
188        ;;
189    esac
190  fi
191
192  if [ ${CountRebuildDir} -gt 0 ] ; then
193    IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}."
194    for Dir in ${RebuildDir[@]} ; do
195      IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m"
196    done
197
198    echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?"
199    echo -n -e " Your answer (y/n) : \033[m"
200    read reponse
201    case ${reponse} in
202
203      oui|OUI|o|y|yes|YES)
204        echo "OK. It will be erased."
205        find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \;
206        echo "done."
207        ;;
208      non|NON|n|no|NO)
209        echo "Nothing to do !"
210        ;;
211    esac
212  fi
213
214  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
215  if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
216
217    echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?"
218    echo -n -e " Your answer (y/n) : \033[m"
219    read reponse
220    case ${reponse} in
221
222      oui|OUI|o|y|yes|YES)
223        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
224        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
225        ;;
226      non|NON|n|no|NO)
227        echo "Nothing to do !"
228        ;;
229    esac
230  else
231    echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
232  fi
233
234  if [ X${run_Configuration_CumulPeriod} = X1 ] ; then
235    echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?"
236    echo -n -e " Your answer (y/n) : \033[m"
237    read reponse
238    case ${reponse} in
239
240      oui|OUI|o|y|yes|YES)
241        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
242        IGCM_sys_Rm ${SUBMIT_DIR}/run.card
243        ;;
244      non|NON|n|no|NO)
245        echo "Nothing to do !"
246        ;;
247    esac
248  else
249    # if not first period
250    Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
251    Script_Output_Job=${Script_Output_Prefix}_${config_UserChoices_JobName}
252    Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${run_Configuration_CumulPeriod} )
253
254    echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?"
255    echo -n -e " Your answer (y/n) : \033[m"
256    read reponse
257    case ${reponse} in
258
259      oui|OUI|o|y|yes|YES)
260        cp ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$
261        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}
262        echo "Job : Job_${config_UserChoices_JobName} modified."
263        echo "Old job saved here : Job_${config_UserChoices_JobName}_SAVED_$$"
264        ;;
265      non|NON|n|no|NO)
266        echo "Nothing done in Job_${config_UserChoices_JobName} !"
267        ;;
268    esac
269
270  fi
271fi
272exit 0
Note: See TracBrowser for help on using the repository browser.