source: trunk/libIGCM/AA_create_se @ 58

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

Headers for LoadLeveler? 3.5

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