source: tags/libIGCM_v2.8.1/AA_clean_month @ 1456

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