source: trunk/libIGCM/AA_create_se @ 45

Last change on this file since 45 was 45, checked in by sdipsl, 15 years ago

SD : syntax error

  • 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 Date Author Revision
File size: 15.6 KB
Line 
1#-Q- platine #!/usr/bin/ksh
2#-Q- platine ###################
3#-Q- platine ## PLATINE   CEA ##
4#-Q- platine ###################
5#-Q- platine #BSUB -J SE                     # Nom du job
6#-Q- platine #BSUB -N                        # message a la fin du job
7#-Q- platine #BSUB -n 1                      # reservation des processeurs pour le job
8#-Q- platine #BSUB -W 1:00                   # Limite temps
9#-Q- platine #BSUB -q post              # Passage en queue post
10#-Q- sx8brodie #######################
11#-Q- sx8brodie ## SX8BRODIE   IDRIS ##
12#-Q- sx8brodie #######################
13#-Q- sx8brodie #QSUB -r SE                   # Nom du job
14#-Q- sx8brodie #QSUB -lT 1:00:00             # limite en temps total
15#-Q- sx8brodie #QSUB -lt 1:00:00             # limite en temps par process
16#-Q- sx8brodie #QSUB -lM 1Gb
17#-Q- sx8brodie #QSUB -eo                     # rassemble standard error et output
18#-Q- sx8brodie #QSUB -J m
19#-Q- sx8brodie #QSUB -l mpp_p=4
20#-Q- sx8brodie #QSUB -s /bin/ksh             # shell du job
21#-Q- sx8mercure #!/bin/ksh
22#-Q- sx8mercure ######################
23#-Q- sx8mercure ## SX8MERCURE   CEA ##
24#-Q- sx8mercure ######################
25#-Q- sx8mercure #PBS -N SE                   # Nom du job
26#-Q- sx8mercure #PBS -j o                    # regroupement des stdout et stderr
27#-Q- sx8mercure #PBS -S /usr/bin/ksh         # shell de soumission
28#-Q- sx8mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
29#-Q- sx8mercure #PBS -l cputim_job=1:00:00   # Limite temps a 1 heures
30#-Q- sx8mercure #PBS -q scalaire
31#-Q- default #!/bin/ksh
32#-Q- default ##################
33#-Q- default ## DEFAULT HOST ##
34#-Q- default ##################
35
36#set -vx
37
38date
39
40#-Q- sx8brodie export OMP_NUM_THREADS=1
41
42# $Date$
43# $Author$
44# $Revision$
45# IPSL (2006)
46#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
47
48########################################################################
49
50#D- Flag to determine if this job in a standalone mode
51#D- Default : value from AA_job if any
52StandAlone=${StandAlone:=true}
53
54#D- Flag to determine atlas job's output directory
55#D- Default : value from libIGCM_post.ksh if any
56POST_DIR=${POST_DIR:=${PBS_O_WORKDIR}}
57
58#D- Increased verbosity (1, 2, 3)
59#D- Default : value from AA_job if any
60Verbosity=${Verbosity:=3}
61
62#D- Low level debug : to bypass lib test checks and stack construction
63#D- Default : value from AA_job if any
64DEBUG_debug=${DEBUG_debug:=false}
65
66#D- Low level debug : to bypass lib test checks and stack construction
67#D- Default : value from AA_job if any
68libIGCM=${libIGCM:=/home/rech/ces/rces452/libIGCM}
69
70#D- TEMPORARY Flag to determine atmospheric resolution
71#D- Default : value from atmospheric driver if any
72RESOL_ATM=${RESOL_ATM:=LMD144142}
73
74#D- TEMPORARY Flag to determine ocean resolution
75#D- Default : value from ocean driver if any
76RESOL_OCE=${RESOL_OCE:=ORCA2}
77
78#D- TEMPORARY Flag to determine ice resolution
79#D- Default : value from ice driver if any
80RESOL_ICE=${RESOL_ICE:=ORCA2}
81
82#D- Flag to determine surface resolution
83#D- Default : value from surface driver if any
84RESOL_SRF=${RESOL_SRF:=LMD144142}
85
86########################################################################
87
88. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ;
89. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh     #; IGCM_debug_Check
90. ${libIGCM}/libIGCM_card/libIGCM_card.ksh   #; IGCM_card_Check
91. ${libIGCM}/libIGCM_date/libIGCM_date.ksh   #; IGCM_date_Check
92
93########################################################################
94
95#set -vx
96
97if [ ${DEBUG_debug} = true ] ; then
98    IGCM_sys_MkdirWork ${RUN_DIR_PATH}
99    echo "RUN_DIR_PATH ${RUN_DIR_PATH} ok."
100fi
101IGCM_sys_Cd ${RUN_DIR_PATH}
102
103if [ ${StandAlone} = true ] ; then
104    CARD_DIR=${SUBMIT_DIR}
105else
106    CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} )
107    IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH}
108fi
109
110#
111# First of all
112#
113IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card UserChoices
114typeset option
115for option in ${config_UserChoices[*]} ; do
116    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
117done
118#
119echo
120IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
121IGCM_debug_PrintVariables 3 config_UserChoices_JobName
122IGCM_debug_PrintVariables 3 config_UserChoices_LongName
123IGCM_debug_PrintVariables 3 config_UserChoices_TagName
124IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
125IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
126IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
127IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
128echo
129
130#==================================
131
132R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
133#
134IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card ListOfComponents
135#
136IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
137#
138# Determine period for seasonnal average. Default : value from AA_job if any
139#
140DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
141#
142PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
143#
144freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
145#
146an_fin=$( expr $( IGCM_date_ConvertGregorianDateToJulian $PeriodDateEnd ) / 1000 )
147an_deb=$( IGCM_date_YearDigit $(( an_fin - freq + 1 )) )
148an_fin=$( IGCM_date_YearDigit ${an_fin} )
149#
150# For each component selected determine which files need post-processing
151#
152for comp in ${config_ListOfComponents[*]} ; do
153    #
154    IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
155    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
156    #
157    card=${CARD_DIR}/COMP/${compname}.card
158    IGCM_card_DefineArrayFromOption ${card} OutputFiles List
159    #
160    ListFilesName=${compname}_OutputFiles_List
161    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
162    #
163    if [ X${FileName0} != X${NULL_STR} ] ; then
164        #
165        #IGCM_debug_Print 1 "Component      : ${compname}"
166        #
167        # INITIALISATION
168        #
169        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
170        typeset i=0
171        #
172        until [ $i -eq $NbFiles ]; do
173            #
174            eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
175            eval file_in=${file_in_}
176            let $(( i_ = i+2 ))
177            eval flag_post_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
178            eval flag_post=${flag_post_}
179            #
180            if [ X${flag_post} != XNONE ] ; then
181                #
182                # Initialize ${flag_post}_${compname}_${post_freq}
183                #
184                eval ${flag_post}_${compname}_SeasonalFrequency=true
185            fi
186            let $(( i=i+3 ))
187        done
188    fi
189
190    for element in $( set | grep Post_ | grep ${compname}_SeasonalFrequency | grep -i "=true" ) ; do
191        #
192        FILE=$( echo ${element} | awk -F "_${compname}" '{print $1}' | awk "-FPost_" '{print $2}' )
193        #
194        IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
195        #
196        # CREATE LIST
197        #
198        DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
199        #
200        TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
201        #
202        if [ ! -f ${DIRECTORY}/${TestedFile} ] ; then
203            eval set +A LISTE_FILE_${comp} \$\{LISTE_FILE_${comp}[*]} ${FILE}
204            eval set +A LISTE_PATCHES_${FILE} \$\{${compname}_Post_${FILE}_Patches[*]}
205            if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
206                for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
207                    if [ Xload${Patch} != X ] ; then
208                        . ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
209                        eval load${Patch}=loaded
210                    fi
211                done
212            fi
213        fi
214           #
215    done   # for element
216done       # for comp
217
218for comp in ${config_ListOfComponents[*]} ; do
219    #
220    eval R_OUT_${comp}=${R_SAVE}/${comp}
221    #
222    i=0
223    for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
224        #
225        # Determine in which output can we find file
226        # IE : Output/MO or Output/DA or ...
227        #
228        FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
229        case ${FlagDir} in
230            1Y)    FreqDir=YE  ;;
231            1M)    FreqDir=MO  ;;
232            5D|1D) FreqDir=DA  ;;
233            HF)    FreqDir=HF  ;;
234            INS)   FreqDir=INS ;;
235        esac
236        #
237        RESULT_SE=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${file}.nc
238        # Do not redoo an existing SE
239        if [ -f ${R_SAVE}/${comp}/Analyse/SE/${RESULT_SE} ] ; then
240            continue
241        fi
242        #
243        eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
244        #
245        case ${config_UserChoices_PeriodLength} in
246        # For Yearly simulation :
247        1Y|1y)
248          (( an = an_deb ))
249          # Initialize array
250          set -A liste_file_se
251          set -A liste_file_se_tmp
252          while [ ${an} -le ${an_fin} ] ; do
253              moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
254              #
255              an4=$(printf "%04i\n" ${an} )
256              #
257              diy=$( IGCM_date_DaysInYear $an4 )
258              afin=$( IGCM_date_AddDaysToGregorianDate ${an4}0101 $(( diy - 1 )) )
259              date=${an4}0101_${afin}
260              set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
261              set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
262              (( an = an + 1 ))
263          done
264          #
265          IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
266          eval ExitFlag=false
267          IGCM_debug_Verif_Exit_Post
268         
269          # Apply IGCM_Patch if needed
270          if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
271              for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
272                  for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
273                      IGCM_${Patch} ${file_t}
274                  done
275              done
276          fi
277
278          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
279          #
280              (( nb = ${mois} - 1 ))
281          #
282              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
283              IGCM_sys_ncra -O -d time_counter,${nb},,12 ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
284          done
285          IGCM_sys_Rm ${liste_file_se_tmp[*]}
286          eval ExitFlag=false
287          IGCM_debug_Verif_Exit_Post
288          ;;
289        # For Monthly simulation :
290        1M|1m)
291          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
292              #
293              (( nb = ${mois} - 1 ))
294              #
295              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
296              #
297              (( an = an_deb ))
298              # Initialize array
299              set -A liste_file_se
300              set -A liste_file_se_tmp
301              while [ ${an} -le ${an_fin} ] ; do
302                  moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
303                  #
304                  an4=$(printf "%04i\n" ${an} )
305                  #
306                  date=${an4}${mois}01_${an4}${mois}${moisL}
307                  set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
308                  set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
309                  (( an = an + 1 ))
310              done
311              #
312              IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
313              eval ExitFlag=false
314              IGCM_debug_Verif_Exit_Post
315             
316              # Apply IGCM_Patch if needed
317              if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
318                  for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
319                      for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
320                          IGCM_${Patch} ${file_t}
321                      done
322                  done
323              fi
324             
325              IGCM_sys_ncra -O ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
326              IGCM_sys_Rm ${liste_file_se_tmp[*]}
327              eval ExitFlag=false
328              IGCM_debug_Verif_Exit_Post
329          done
330          ;;
331        *D|*d)
332          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
333              #
334              (( nb = ${mois} - 1 ))
335              #
336              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
337              #
338              (( an = an_deb ))
339              # Initialize array
340              set -A liste_file_se
341              set -A liste_file_se_tmp
342              while [ ${an} -le ${an_fin} ] ; do
343                  moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
344                  #
345                  an4=$(printf "%04i\n" ${an} )
346                  #
347                  length_d=$(( ${config_UserChoices_PeriodLength} - 1 ))
348                  # for one day
349                  if [ ${length_d} -eq 1 ] ; then
350                      (( length_d = 0 ))
351                  fi
352                  (( day  = 1 ))
353                  while [ ${day} -le ${moisL} ] ; do
354                      day2=$(printf "%02i\n" ${day} )
355                      day_beg=${an4}${mois}${day2}
356                      day_end=$( IGCM_date_AddDaysToGregorianDate ${day_beg} ${length_d} )
357                      date=${an4}${mois}${day_beg}_${an4}${mois}${day_end}
358                      set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
359                      set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
360                      (( day = day + 1 ))
361                  done
362                  (( an = an + 1 ))
363              done
364              #
365              IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
366              eval ExitFlag=false
367              IGCM_debug_Verif_Exit_Post
368             
369              # Apply IGCM_Patch if needed
370              if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
371                  for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
372                      for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
373                          IGCM_${Patch} ${file_t}
374                      done
375                  done
376              fi
377
378              IGCM_sys_ncra -O ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
379              IGCM_sys_Rm ${liste_file_se_tmp[*]}
380              eval ExitFlag=false
381              IGCM_debug_Verif_Exit_Post
382          done
383          ;;
384        esac
385        #
386        IGCM_sys_ncrcat -O ${OUT_SE[*]} ${RESULT_SE}
387        #
388        IGCM_sys_Rm ${OUT_SE[*]}
389        #
390        ${ncatted} -a modulo,time_counter,c,c," " ${RESULT_SE}
391        #
392        eval IGCM_sys_Put_Out ${RESULT_SE} \${R_OUT_${comp}}/Analyse/SE/${RESULT_SE}
393        IGCM_sys_Rm ${RESULT_SE}
394        #
395        eval ExitFlag=false
396        IGCM_debug_Verif_Exit_Post
397    done
398done
399
400# DODS copy
401for comp in ${config_ListOfComponents[*]} ; do
402    for SE_Dir in $( ls ${R_SAVE}/${comp}/Analyse/ 2>&1 | grep SE ) ; do
403        [ -d ${R_SAVE}/${comp}/Analyse/${SE_Dir} ] && IGCM_sys_Put_Dods ${comp}/Analyse/${SE_Dir}
404    done
405done
406
407YEARS=${an_deb}_${an_fin}
408
409# clean environment variables and export usefull one :
410if [ X$( hostname -s ) = Xrhodes ] ; then
411    LISTE_ENV=$( env | grep -iv MYLANG | grep -iv HOST | grep -iv LOGIN | grep -iv config_ | grep -iv R_ | grep -iv libIGCM | grep -iv PERIOD \
412        | grep -iv DMFDIR | grep -iv AN_| grep -iv YEARS | grep -iv ex | grep -iv RESOL_ | grep -iv PATH | grep -iv WORKDIR | grep -iv USER   \
413        | grep -iv LOGNAME | grep -iv PROFILE | grep -iv ENV | grep -iv TMPDIR | grep -iv POST_DIR | grep -iv DB |awk -F= '{print $1}' )
414   
415    for variables in ${LISTE_ENV} ; do
416        unset ${variables}
417    done
418fi
419
420export POST_DIR; export SUBMIT_DIR; export libIGCM; export R_INIT; export R_BC; export StandAlone
421export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_SRF
422export R_SAVE; export config_UserChoices_JobName; export config_UserChoices_TagName; export YEARS;
423listVarEnv="POST_DIR,SUBMIT_DIR,libIGCM,R_INIT,R_BC,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF,R_SAVE,config_UserChoices_JobName,config_UserChoices_TagName,YEARS"
424export listVarEnv;
425
426#D-
427# --------------------------------------------------------------------
428#D- Test if all was right before ATLAS
429# --------------------------------------------------------------------
430IGCM_debug_Verif_Exit_Post
431
432if [ ${config_UserChoices_TagName} = "IPSLCM4_v1_OASIS3" ] || \
433   [ ${config_UserChoices_TagName} = "IPSLCM4_v2" ]        || \
434   [ ${config_UserChoices_TagName} = "IPSLCM5" ]           || \
435   [ ${config_UserChoices_TagName} = "IPSL_ESM_V1" ] ; then
436    #
437    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
438    IGCM_sys_QsubPost atlas_LMDZ         ;
439    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
440    IGCM_sys_QsubPost additionnal        ;
441    #
442elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ]  || \
443     [ ${config_UserChoices_TagName} = "LMDZOR" ]   || \
444     [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then
445    #
446    IGCM_sys_QsubPost atlas_LMDZ         ;
447    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
448    #
449elif [ ${config_UserChoices_TagName} = "LMDZ" ] ; then
450    #
451    IGCM_sys_QsubPost atlas_LMDZ         ;
452    #
453elif [ ${config_UserChoices_TagName} = "OL" ]      || \
454     [ ${config_UserChoices_TagName} = "OL2" ] ; then
455    #
456    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
457    #
458elif [ ${config_UserChoices_TagName} = "ORCA2_LIM" ] ; then
459    #
460    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
461    IGCM_sys_QsubPost additionnal        ;
462    #
463fi
Note: See TracBrowser for help on using the repository browser.