source: branches/ORCHIDEE_2_2/ORCHIDEE_OL/ENSEMBLE/Job_ENSEMBLE

Last change on this file was 7075, checked in by nicolas.vuichard, 3 years ago

update ENSEMBLE configuration for new card (fluxnet_historical.card) to perform an historical transient simulation with CO2 varying

  • Property svn:executable set to *
File size: 17.4 KB
Line 
1#!/bin/ksh
2
3# $Date: 2010/06/25 19:03:52 $
4# $Author: ssipsl $
5# $Revision: 1.13 $
6# IPSL (2006)
7#  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
8
9#D--------------------------------------------------------------------==
10#D--------------------------------------------------------------------==
11#D-
12#D-                      Job to launch ENSEMBLE spinup simulations
13#D-
14#D--------------------------------------------------------------------==
15#D--------------------------------------------------------------------==
16#D-
17#                       Job inspired from Sonke Zaehle "site_new.def" job
18#                       #################################################
19
20export BRIDGE_MSUB_PROJECT=gen6328
21
22if [ $# -lt 1 ] ; then
23   echo ""
24   echo "ERROR: Bad usage. You must give the name of the card as argument."
25   echo ""
26   echo "Do as follow for fluxnet simulation with fluxnet.card:"
27   echo "   ./Job_ENSEMBLE fluxnet  > out_Job_ENSEMBLE"
28   echo "Do as follow for ensemble simulation with ensemble.card:"
29   echo "   ./Job_ENSEMBLE ensemble > out_Job_ENSMEBLE"
30   echo ""
31   exit
32fi
33
34SUBMIT_DIR=$( pwd )
35MODIPSL=$(cd ${SUBMIT_DIR}'/../../..';pwd;)
36libIGCM=${MODIPSL}/libIGCM
37
38
39# All SubJobs in SPINUP in ONE OR MORE YEARS run (must be used with libIGCM branches/AllPostFred).
40
41#D--------------------------------------------------------------------==
42#D-                   -1. User modification place
43#D--------------------------------------------------------------------==
44
45#D- Increased verbosity (1, 2, 3)
46#Verbosity=3
47
48#D-
49# --------------------------------------------------------------------
50#D- ! Optionnal features /!\ Use with care !
51# --------------------------------------------------------------------
52
53#D- Low level debug : to bypass lib test checks and stack construction
54#D- Default=true
55DEBUG_debug=false
56
57#D- Set DEBUG_sys to false to disable output calls of function
58#D- Default=true
59#DEBUG_sys=false
60
61#D- Turn in dry run mode ? (0,1,2,3)
62#D- Default=0
63#DRYRUN=3
64# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
65# -------------------------------------------------------------------------------------
66# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
67# |          |  Cp/Exe param files |            |  Chmod  |                           |
68# |          |      Qsub           |            |         |                           |
69# -------------------------------------------------------------------------------------
70# |    0     |       yes           |    yes     |  yes    |      yes                  |
71# -------------------------------------------------------------------------------------
72# |    1     |       yes           |    yes     |  yes    |      no                   |
73# -------------------------------------------------------------------------------------
74# |    2     |       yes           |    yes     |  no     |      no                   |
75# -------------------------------------------------------------------------------------
76# |    3     |       yes           |    no      |  no     |      no                   |
77# -------------------------------------------------------------------------------------
78
79
80#D-
81#D--------------------------------------------------------------------==
82#D-                   0. System Environment
83#D-                      - Define variables for Number of processors
84#D-                      - Define MPI variables
85#D-                      - Define batch scheduler variables
86#D-                      - Source IGCM Library
87#D-                      - Get RESOLution in .resol file (temporary)
88#D--------------------------------------------------------------------==
89
90#D--------------------------------------------------------------------==
91#TaskType=post-processing
92
93. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
94. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
95. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
96#-------
97. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
98. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
99. ${libIGCM}/libIGCM_comp/libIGCM_comp.ksh
100. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
101#-------
102( ${DEBUG_debug} ) && IGCM_debug_Check
103( ${DEBUG_debug} ) && IGCM_card_Check
104( ${DEBUG_debug} ) && IGCM_date_Check
105
106#D--------------------------------------------------------------------==
107#D- 0.1 COMMON ENVIRONMENT
108#D-     - Read libIGCM compatibility version in config.card
109#D-     - Read UserChoices section
110#D-     - Read Ensemble section
111#D-     - Read Post section
112#D-     - Define all netcdf output directories
113#D--------------------------------------------------------------------==
114IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
115
116
117
118#D--------------------------------------------------------------------==
119#D- 1. INITIALIZE CONFIGURATION
120#D-    - Simulation configuration
121#D-    - Simulation parameters
122#D-    - Execution parameter
123#D-    - Define input files directory
124#D-    - Read or initialize CumulPeriod
125#D-    - run.card
126#D---------------------------------------------------------------------==
127IGCM_config_Initialize
128
129
130
131IGCM_sys_Cp -p ensemble.card ref.card
132IGCM_sys_Cp -p $1.card ensemble.card
133
134
135#set -vx
136
137IGCM_sys_MkdirWork ${RUN_DIR_PATH}
138
139. ${SUBMIT_DIR}/ensemble.ksh
140
141ENSEMBLE_initialize
142
143
144IGCM_sys_MkdirWork ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_UserChoices_JobName}
145
146
147function correct_duree
148{
149    # Ths function compute the nearest multiple of dyear near duree
150    typeset duree dyear
151    duree=$1
152    dyear=$2
153    if [ $(( duree % dyear )) -gt 0 ] ; then
154        echo $(( ( duree / dyear + 1 ) * dyear ))
155    else
156        echo ${duree}
157    fi
158}
159
160# Path for all skeleton SubJob scripts to SPINUP directory
161Skeleton_Path=$( cd ../SPINUP/SUBJOB/; pwd )
162
163
164for group in  ${ensemble_CONFIG_Groups[*]} ; do
165   isite=1
166   index=0
167
168   eval temp=\${ensemble_CONFIG_${group}[*]}
169   set -A group_site -- $temp
170
171   # Number of sites :
172   NumSites=$(( ${#group_site[*]} / NumInfosBySite ))
173   NumAllSites=$(( NumAllSites + NumSites ))
174
175   while [ ${isite} -le ${NumSites} ] ; do
176   
177    site=${group_site[$index]}
178
179    echo "   ------------------------"
180    echo "   SPINUP for Site : ${site}"
181
182    DATE0_YEAR=${group_site[ $(( index + ColumnYear )) ]}
183    TIME_YEAR=${group_site[ $(( index + ColumnLength )) ]}
184
185#######################################################
186# Script internal settings
187# nothing to be modified below this line
188######################################################?
189
190# Copy the SPINUP directory
191    SubJobName=${site}${config_UserChoices_JobName}
192    New_SUBMIT_DIR=${SUBMIT_DIR}/${SubJobName}
193    IGCM_sys_Cp -Rp ../SPINUP ${New_SUBMIT_DIR}
194#     ls -la ${New_SUBMIT_DIR}
195#     cat ${New_SUBMIT_DIR}/config.card
196#     echo "---"
197
198    # Install this directory
199    # modifications on config.card
200    MyJobName=${config_UserChoices_JobName}
201    IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/config.card UserChoices JobName
202    OldJobName=${config_UserChoices_JobName}
203    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobName ${SubJobName}
204    config_UserChoices_JobName=${MyJobName}
205    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices TagName
206    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices TagName ${config_UserChoices_TagName}
207    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices CalendarType ${config_UserChoices_CalendarType}
208
209    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot}
210
211    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot}
212
213    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices SpaceName ${config_UserChoices_SpaceName}
214
215    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices ExperimentName ${config_UserChoices_ExperimentName}
216
217    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices ARCHIVE ${config_UserChoices_ARCHIVE}
218
219    # Give path for all skeleton SubJob scripts to SPINUP directory
220    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices SubJobPath ${Skeleton_Path}
221
222    # All SubJobs in SPINUP in one or more years (must be used with libIGCM branches/AllPostFred).
223    # It is the length of the forcing file.
224    if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then
225        This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1230
226        This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-30
227    else
228        This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1231
229        This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-31
230    fi
231
232    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateBegin ${DATE0_YEAR}-01-01
233    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodLength ${TIME_YEAR}Y
234
235    # DateEnd is defined by SpinUp job itself (it will be modified in config.card).
236    # but to get all SpinUp Job loops, we have to add at least a number of years greater
237    # than those that will be modified in config.card. Default is 150.00.00 years more for SpinUp.
238    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateEnd $(( DATE0_YEAR + TIME_YEAR ))-01-01
239
240    # Infinit SPINUP Job :
241    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodNb 99999
242
243    # SRF section : first restart and post-treatments
244    typeset option
245    for option in ${config_SRF[*]} ; do
246        eval value=\${config_SRF_${option}}
247        eval echo ${option} ${value}
248        if [ X${value} != X ] ; then
249            eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF ${option} \${config_SRF_${option}}
250        fi
251    done
252    if [ X"${ensemble_UserChoices_ok_stomate}" = "Xy" ] ; then
253        for option in ${config_SBG[*]} ; do
254            eval value=\${config_SBG_${option}}
255            eval echo ${option} ${value}
256            if [ X${value} != X ] ; then
257                eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG ${option} \${config_SBG_${option}}
258            fi
259        done
260    fi
261
262    # modifications on spinup.card
263    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile List "(${ensemble_CONFIG_ForcingPath}/${group_site[$(( index + ColumnFilename ))]}, forcing_file.nc)"
264
265    typeset option
266    for option in ${ensemble_UserChoices[*]} ; do
267        eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices ${option} \${ensemble_UserChoices_${option}}
268    done
269
270
271    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_NORESTART y
272    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_TIMELENGTH n
273
274    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_nostomate $( correct_duree ${ensemble_SPINUP_duree_nostomate} ${TIME_YEAR} )
275    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_inistomate $( correct_duree ${ensemble_SPINUP_duree_inistomate} ${TIME_YEAR} )
276    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_offlineini $( correct_duree ${ensemble_SPINUP_duree_offlineini} ${TIME_YEAR} )
277    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices n_iter ${ensemble_SPINUP_n_iter}
278    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_sechiba $( correct_duree ${ensemble_SPINUP_duree_sechiba} ${TIME_YEAR} )
279    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_stomate $( correct_duree ${ensemble_SPINUP_duree_stomate} ${TIME_YEAR} )
280    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_carbonsol $( correct_duree ${ensemble_SPINUP_duree_carbonsol} ${TIME_YEAR} )
281    eval eval_duree_final=\${ensemble_SPINUP_duree_final}
282    eval eval_duree_final=${eval_duree_final}
283
284    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_final $( correct_duree ${eval_duree_final} ${TIME_YEAR} )
285
286    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices BoundaryFilesListNonDel y
287
288    # TimeSeries : ALMAOUTPUT for SECHIBA
289    typeset option
290    for option in ${config_SubJobPost[*]} ; do
291        eval value=\${config_SubJobPost_${option}}
292        eval echo ${option} ${value}
293        if [ X${value} != X ] ; then
294            eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SubJobPost ${option} \${config_SubJobPost_${option}}
295        fi
296    done
297
298    # modifications on Job script
299    rm ${New_SUBMIT_DIR}/Job_${OldJobName}
300    IGCM_sys_Cp ${SUBMIT_DIR}/Job_${MyJobName} ${New_SUBMIT_DIR}/Job_${SubJobName}
301
302    sed -e "s/ ${MyJobName}/ ${SubJobName}/" \
303        -e "s/Script_Output_${MyJobName}/Script_Output_${SubJobName}/" \
304        -e "s/\(IGCM_config_Finalize\)/\1\nif\ [\ \${config_UserChoices_JobName}\ =\ \"${SubJobName}\"\ ]\nthen\nIGCM_sys_Mv\ \${R_OUT}\/\${config_UserChoices_TagName}\/\${config_UserChoices_SpaceName}\/\${config_UserChoices_ExperimentName}\/\${config_UserChoices_JobName}\ \${R_OUT}\/\${config_UserChoices_TagName}\/\${config_UserChoices_SpaceName}\/\${config_UserChoices_ExperimentName}\/${config_UserChoices_JobName}\/\nIGCM_sys_Mv\ \${R_OUT}\/\${config_UserChoices_TagName}\/\${config_UserChoices_SpaceName}\/\${config_UserChoices_ExperimentName}\/\${config_UserChoices_JobName}HIST\ \${R_OUT}\/\${config_UserChoices_TagName}\/\${config_UserChoices_SpaceName}\/\${config_UserChoices_ExperimentName}\/${config_UserChoices_JobName}\/\nfi/" \
305        ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_
306    IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName}
307    chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName}
308
309
310    # modification on parameter files
311    if [ ! -f ${SUBMIT_DIR}/PARAM/run.def ] ; then
312        echo "#ENSEMBLE add :" > ${New_SUBMIT_DIR}/PARAM/run.def
313    else
314        IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/run.def ${New_SUBMIT_DIR}/PARAM/run.def
315        echo "#ENSEMBLE add :" >> ${New_SUBMIT_DIR}/PARAM/run.def
316    fi
317    echo "" >> ${New_SUBMIT_DIR}/PARAM/run.def
318
319    eval first_option=${ensemble_SubJobParams[0]} > /dev/null 2>&1
320    if [ X${first_option} != X"Error:" ] ; then
321        IGCM_card_DefineArrayFromSection ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams
322        eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1
323
324        typeset option option_
325        for option in ${ensemble_SubJobParams[*]} ; do
326            echo "For parameter file run.def"
327            eval echo "${option}="\${ensemble_SubJobParams_${option}}
328            eval ORCHIDEE_grep ${option}
329            if [ ${SearchParam} == "undefined" ] ; then
330                echo "ERROR : parameter ${option} doesn't exist in run parameter file !"
331                echo "You must correct subjobparam option in your card file or add new parameter in run.def file"
332                echo "We must STOP here."
333                exit 1
334            fi
335            eval param=\${ensemble_SubJobParams_${option}}
336            eval ORCHIDEE_def ${option} $param
337           
338            if [ X${first_option} != X"Error:" ] ; then
339                for option_ in ${spinup_SubJobParams[*]} ; do
340                    echo "option=" ${option} " option_=" ${option_}
341                    if [ X${option} == X${option_} ] ; then
342                        eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams ${option} $param
343                    fi
344                done
345            fi
346        done
347    fi
348
349    (( iphys = 0 ))
350    (( indext = index + 4 ))
351    while [ $iphys -lt ${ensemble_CONFIG_NbSitesParam} ] ; do
352       
353        # Detect if physical parameter has
354        #  array description or line per PFT description in the parameter file
355        SearchParam=""
356        ORCHIDEE_grep ${ensemble_CONFIG_NameSitesParam[${iphys}]}
357
358        case ${SearchParam} in
359            undefined)
360                echo "ERROR : parameter ${ensemble_CONFIG_NameSitesParam[${iphys}]} doesn't exist in run.def parameter file !"
361                echo "You must correct NameSiteParam option in your card file or add new parameter in run.def file"
362                echo "We must STOP here."
363                exit 1
364                ;;
365            value)
366                ORCHIDEE_def ${ensemble_CONFIG_NameSitesParam[${iphys}]} ${group_site[$(( indext )) ]}
367                (( indext = indext + 1 ))
368                ;;
369            line)
370                ipft=1
371                while [ $ipft -le ${NbPFTs} ] ; do
372                    if [ $ipft -lt 10 ] ; then
373                        numpft=0${ipft}
374                    else
375                        numpft=${ipft}
376                    fi
377           
378                    ORCHIDEE_def ${ensemble_CONFIG_NameSitesParam[${iphys}]}__${numpft} ${group_site[$(( indext )) ]}
379                    (( indext = indext + 1 ))
380                    (( ipft = ipft + 1 ))
381                done
382                ;;
383            vector)
384                unset ValueSiteParams
385                ipft=0
386                while [ $ipft -lt ${NbPFTs} ] ; do
387                    ValueSiteParams[${ipft}]=${group_site[$(( indext )) ]}
388                    (( indext = indext + 1 ))
389                    (( ipft = ipft + 1 ))
390                done
391                ORCHIDEE_def ${ensemble_CONFIG_NameSitesParam[${iphys}]} "${ValueSiteParams[*]}"
392                ;;
393        esac
394
395        (( iphys = iphys + 1 ))
396    done
397
398    IGCM_debug_Verif_Exit
399
400# Lauch the SPINUP Job :
401
402    echo "#!/bin/ksh" > ${RUN_DIR_PATH}/SubJob${site}.ksh
403    echo "MODIPSL=${MODIPSL}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
404    echo "libIGCM=${libIGCM}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
405    echo "cd ${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
406    echo "export SUBMIT_DIR=${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
407    echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
408    echo ". ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
409    echo "export Script_Output=out_qsub_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
410    echo "export config_UserChoices_JobName=${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
411    echo "export CumulPeriod=1" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
412#    echo "nohup Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
413    echo "IGCM_sys_Qsub Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
414
415    if [ ${DRYRUN} -le 1 ] ; then
416        chmod u+x ${RUN_DIR_PATH}/SubJob${site}.ksh
417        nohup ${RUN_DIR_PATH}/SubJob${site}.ksh
418    fi
419
420    IGCM_debug_Verif_Exit
421
422    (( isite=isite+1 ))
423    (( index=index+NumInfosBySite ))
424done
425done
426
427IGCM_sys_Mv ref.card ensemble.card
428IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Note: See TracBrowser for help on using the repository browser.