source: trunk/libIGCM/AA_SE_Checker @ 1517

Last change on this file since 1517 was 1450, checked in by jgipsl, 6 years ago

Correct error in SE_Checker : the date end was calculated wrong. It was always corresponding to the next coming period and therefor an error message was always done.

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