source: tags/libIGCM_v1/AA_create_se @ 1137

Last change on this file since 1137 was 2, checked in by mmaipsl, 16 years ago

MM: import first trunk version of libIGCM.

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