source: trunk/libIGCM/AA_SE_Checker @ 1327

Last change on this file since 1327 was 1327, checked in by jgipsl, 8 years ago

Added possible dryrun and more comments, see ticket #288

  • 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.0 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13# ID of your genci project. Curie only : post-processing jobs need it to run properly
14#-Q- curie export BRIDGE_MSUB_PROJECT=::default_project::
15
16#D- Task type (computing or post-processing)
17TaskType=checking
18
19#D- Low level debug : to perform lib test checks, stack construction and IO functions instrumentation
20DEBUG_debug=false
21
22#D- Messaging : all activities and call stacks will be sent to ipsl servers
23BigBrother=false
24
25# Check that everything went well during seasonal average production
26# Display a short report
27# Launch what's missing when a simulation has been completed PeriodState=Completed
28
29#D- Path to libIGCM
30#D- Default : value from AA_job if any
31# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
32# WARNING you must check MirrorlibIGCM variable in sys library.
33# WARNING If this variable is true, you must use libIGCM_POST path instead
34# WARNING of your running libIGCM directory.
35libIGCM=${libIGCM:=::modipsl::/libIGCM}
36
37# répertoire courrant
38CURRENT_DIR=$( pwd )
39
40# Emplacement des cartes
41CARD_DIR=${CARD_DIR:=${CURRENT_DIR}}
42
43# répertoire de stockage des sorties des create_ts
44POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript}
45
46if [ ! -d ${CARD_DIR} ]; then
47  echo "No ${CARD_DIR}, we stop here"
48  exit
49fi
50
51########################################################################
52
53. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
54. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
55. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
56#-------
57. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
58. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
59#-------
60( ${DEBUG_debug} ) && IGCM_debug_Check
61( ${DEBUG_debug} ) && IGCM_card_Check
62( ${DEBUG_debug} ) && IGCM_date_Check
63
64########################################################################
65
66#set -vx
67
68echo "Hi I'm here to help you check and complete the seasonal average production"
69echo -e "\033[1;31mDo you want me to run in dryrun mode just telling what I would submit? Answer no in this case\033[m"
70echo -e "\033[1;31mOr do you want me to submit job for real? Answer yes in this case.\033[m"
71echo -n " Run for real (y/n) :"
72read ActionAnswer
73
74case ${ActionAnswer} in
75oui|OUI|o|y|yes|YES)
76  echo "OK. I will submit jobs"
77  action=true
78  ;;
79non|NON|n|no|NO)
80  echo "OK. I won't submit any jobs"
81  action=false
82  ;;
83*)
84  echo "I did not recognize your answer. I will stop here."
85  echo "Please answer: oui|OUI|o|y|yes|YES"
86  echo "Or answer: non|NON|n|no|NO"
87  exit
88  ;;
89esac
90
91#==================================
92# First of all
93#
94# Read libIGCM compatibility version in config.card
95# Read UserChoices section
96# Read Ensemble section
97# Read Post section
98# Define all netcdf output directories
99#==================================
100IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
101
102#==================================
103# Read ListOfComponents section:
104IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
105
106#==================================
107# Read SeasonalFrequency:
108IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
109
110#===================================#
111# Read updated run.card :
112IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration PeriodDateEnd
113
114#
115DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
116DateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
117
118#
119if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
120  PeriodOffset=0
121else
122  PeriodOffset=${config_Post_SeasonalFrequencyOffset}
123fi
124
125IGCM_debug_Print 1 "DateBegin for SE_Checker : "${DateBegin}
126IGCM_debug_Print 1 "DateEnd   for SE_Checker : "${DateEnd}
127IGCM_debug_Print 1 "Offset    for SE_Checker : "${PeriodOffset}
128echo
129#
130[ X${config_Post_SeasonalFrequency} = X"NONE" ] && exit
131
132freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
133
134an_deb=$( IGCM_date_YearDigit $(( DateBegin / 10000 + PeriodOffset )) )
135an_fin=$( IGCM_date_YearDigit $(( an_deb + freq - 1 )) )
136an_fin_all=$( IGCM_date_YearDigit $(( DateEnd / 10000 )) )
137
138#
139while [ ${an_fin} -le ${an_fin_all} ] ; do
140
141  countTotal=0
142  countGood=0
143  countBad=0
144
145  IGCM_debug_Print 1 " DateBegin/End for SE :  ${an_deb}_${an_fin} "
146
147  for comp in ${config_ListOfComponents[*]} ; do
148    localcountBad=0
149    # Debug Print
150    IGCM_debug_Print 1 ${comp}
151    # Define component
152    IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
153    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
154
155    # Read libIGCM compatibility version in ${compname}.card
156    card=${CARD_DIR}/COMP/${compname}.card
157
158    # Read and Build Output File stuff
159    #IGCM_debug_Print 1 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}"
160    IGCM_card_DefineArrayFromOption ${card} OutputFiles List
161    ListFilesName=${compname}_OutputFiles_List
162    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
163    #
164    if [ X${FileName0} != X${NULL_STR} ] ; then
165      #
166      # INITIALISATION
167      #
168      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
169      typeset i=2
170      #
171      until [ $i -gt $NbFiles ]; do
172        #
173        eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
174        #
175        if [ X${flag_post} != XNONE ] ; then
176          #
177          # Check if seasonal is required for this file
178          #
179          IGCM_card_DefineArrayFromSection ${card} ${flag_post}
180          #
181          # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
182          #
183          # variable option allready typeset above
184          for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
185            if [ ${option} = Seasonal ] ; then
186              FoundSeasonal=true
187              IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
188            fi
189          done
190          #
191          if [ ! X${FoundSeasonal} = Xtrue ] ; then
192            eval ${compname}_${flag_post}_Seasonal=ON
193          fi
194          #
195          if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
196            (( i=i+3 ))
197            continue
198          fi
199          #
200          # CREATE LIST
201          #
202          FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
203          #
204          DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
205          #
206          TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
207          #
208          (( countTotal = countTotal + 1 ))
209          IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile} >/dev/null 2>&1
210          if [ ! $? = 0 ] ; then
211            eval set +A LISTE_FILE_${comp}_${an_deb} \$\{LISTE_FILE_${comp}_${an_deb}[*]} ${TestedFile}
212            (( countBad = countBad + 1 ))
213            (( localcountBad = localcountBad + 1 ))
214          else
215            (( countGood = countGood + 1 ))
216          fi
217        fi
218        (( i=i+3 )) # to explore file list
219      done            # until [ $i -eq $NbFiles ]
220    fi                  # [ X${FileName0} != X${NULL_STR} ]
221
222    [ $localcountBad = 0 ] || IGCM_debug_Print 1 "$localcountBad file(s) missing for ${comp} : " $( eval echo \${LISTE_FILE_${comp}_${an_deb}[*]} )
223  done
224
225  # create_se submit if files don't exist
226  if [ $countGood != $countTotal ] ; then
227      if [ ${action} = true ] ; then
228
229          IGCM_debug_Print 2 -e "\033[1;31mSubmit create_se \033[m for period ${an_deb}-${an_fin}"
230         
231          listVarEnv="DEBUG_debug,BigBrother,libIGCM,SUBMIT_DIR,POST_DIR,Script_Post_Output,DateBegin,PeriodDateEnd,RebuildFrequency,RESOL_ATM,RESOL_SRF,RESOL_SBG,RESOL_OCE,RESOL_ICE,RESOL_MBG"
232          export DEBUG_debug=${DEBUG_debug}
233          export BigBrother=${BigBrother}
234          export libIGCM=${libIGCM}
235          export SUBMIT_DIR=${CARD_DIR}
236          export POST_DIR=${POST_DIR}
237          export DateBegin=${an_deb}
238          export PeriodDateEnd=${an_fin}1231
239          export RebuildFrequency=${RebuildFrequency}
240          export RESOL_ATM=${RESOL_ATM}
241          export RESOL_SRF=${RESOL_SRF}
242          export RESOL_SBG=${RESOL_SBG}
243          export RESOL_OCE=${RESOL_OCE}
244          export RESOL_ICE=${RESOL_ICE}
245          export RESOL_MBG=${RESOL_MBG}
246          export listVarEnv=${listVarEnv}
247          export Script_Post_Output=create_se.${PeriodDateEnd}
248         
249          IGCM_sys_MkdirWork ${POST_DIR}
250          IGCM_debug_Verif_Exit
251          IGCM_sys_QsubPost create_se
252          echo
253      else
254          # only dry run
255          IGCM_debug_Print 2 -e "\033[1;31mI should NOW Submit create_se \033[m for period ${an_deb}-${an_fin}"
256          echo
257      fi
258  else               
259      IGCM_debug_Print 2 -e "\033[1;32mFiles are OK for period ${an_deb}-${an_fin}.\033[m Nothing needs to be done for this period."
260      echo
261  fi
262
263  (( an_deb = an_deb + freq ))
264  (( an_fin = an_fin + freq ))
265
266done # while
Note: See TracBrowser for help on using the repository browser.