source: tags/ORCHIDEE_1_9_5/ORCHIDEE_OL/FLUXNET/Job_FLUXNET_validation @ 8

Last change on this file since 8 was 8, checked in by orchidee, 14 years ago

import first tag equivalent to CVS orchidee_1_9_5 + OOL_1_9_5

File size: 14.0 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 FLUXNET spinup simulations
13#D-
14#D--------------------------------------------------------------------==
15#D--------------------------------------------------------------------==
16#D-
17#                       Job inspired from Sönke Zaehle "site_new.def" job
18#                       #################################################
19
20
21
22MODIPSL=::modipsl::
23libIGCM=${MODIPSL}/libIGCM
24
25# All SubJobs in SPINUP in ONE OR MORE YEARS run (must be used with libIGCM branches/AllPostFred).
26
27
28
29#D--------------------------------------------------------------------==
30#D-                   -1. User modification place
31#D--------------------------------------------------------------------==
32
33#D- Increased verbosity (1, 2, 3)
34#Verbosity=3
35
36#D-
37# --------------------------------------------------------------------
38#D- ! Optionnal features /!\ Use with care !
39# --------------------------------------------------------------------
40
41#D- Low level debug : to bypass lib test checks and stack construction
42#D- Default=true
43DEBUG_debug=false
44
45#D- Set DEBUG_sys to false to disable output calls of function
46#D- Default=true
47#DEBUG_sys=false
48
49#D- Turn in dry run mode ? (0,1,2,3)
50#D- Default=0
51#DRYRUN=3
52# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
53# -------------------------------------------------------------------------------------
54# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
55# |          |  Cp/Exe param files |            |  Chmod  |                           |
56# |          |      Qsub           |            |         |                           |
57# -------------------------------------------------------------------------------------
58# |    0     |       yes           |    yes     |  yes    |      yes                  |
59# -------------------------------------------------------------------------------------
60# |    1     |       yes           |    yes     |  yes    |      no                   |
61# -------------------------------------------------------------------------------------
62# |    2     |       yes           |    yes     |  no     |      no                   |
63# -------------------------------------------------------------------------------------
64# |    3     |       yes           |    no      |  no     |      no                   |
65# -------------------------------------------------------------------------------------
66
67
68#D-
69#D--------------------------------------------------------------------==
70#D-                   0. System Environment
71#D-                      - Define variables for Number of processors
72#D-                      - Define MPI variables
73#D-                      - Define batch scheduler variables
74#D-                      - Source IGCM Library
75#D-                      - Get RESOLution in .resol file (temporary)
76#D--------------------------------------------------------------------==
77
78#D--------------------------------------------------------------------==
79
80. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
81        ( ${DEBUG_debug} ) && IGCM_debug_Check
82. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
83       ( ${DEBUG_debug} ) && IGCM_card_Check
84. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
85       ( ${DEBUG_debug} ) && IGCM_date_Check
86#-------
87. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
88
89
90#set -vx
91R_BC=${R_IN}/BC
92
93IGCM_sys_MkdirWork ${RUN_DIR_PATH}
94
95. ${SUBMIT_DIR}/fluxnet.ksh
96
97FLUXNET_initialize
98
99function correct_duree
100{
101    # Ths function compute the nearest multiple of dyear near duree
102    typeset duree dyear
103    duree=$1
104    dyear=$2
105    if [ $(( duree % dyear )) -gt 0 ] ; then
106        echo $(( ( duree / dyear + 1 ) * dyear ))
107    else
108        echo ${duree}
109    fi
110}
111
112# Path for all skeleton SubJob scripts to SPINUP directory
113Skeleton_Path=$( cd ../; pwd )
114
115isite=1
116index=0
117echo ${isite} ${NumSites}
118while [ ${isite} -le ${NumSites} ] ; do
119   
120    site=${fluxnet_FLUXNET_Sites[$index]}
121    echo "   ------------------------"
122    echo "   SPINUP for Site : ${site}"
123
124    DATE0_YEAR=${fluxnet_FLUXNET_Sites[ $(( index + ColumnYear )) ]}
125    TIME_YEAR=${fluxnet_FLUXNET_Sites[ $(( index + ColumnLength )) ]}
126
127#######################################################
128# Script internal settings
129# nothing to be modified below this line
130######################################################ä
131
132# Copy the SPINUP directory
133    SubJobName=${site}${config_UserChoices_JobName}
134    New_SUBMIT_DIR=${SUBMIT_DIR}/${SubJobName}
135    IGCM_sys_Cp -Rp ../SPINUP ${New_SUBMIT_DIR}
136#     ls -la ${New_SUBMIT_DIR}
137#     cat ${New_SUBMIT_DIR}/config.card
138#     echo "---"
139
140    # Install this directory
141    # modifications on config.card
142    MyJobName=${config_UserChoices_JobName}
143    IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/config.card UserChoices JobName
144    OldJobName=${config_UserChoices_JobName}
145    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobName ${SubJobName}
146    config_UserChoices_JobName=${MyJobName}
147    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices TagName
148    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices TagName ${config_UserChoices_TagName}
149    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices CalendarType ${config_UserChoices_CalendarType}
150
151    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobClass ${config_UserChoices_JobClass}
152    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot}
153    sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card
154    IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card
155
156    # Give path for all skeleton SubJob scripts to SPINUP directory
157    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices SubJobPath ${Skeleton_Path}
158
159    # All SubJobs in SPINUP in one or more years (must be used with libIGCM branches/AllPostFred).
160    # It is the length of the forcing file.
161    if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then
162        This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1230
163        This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-30
164    else
165        This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1231
166        This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-31
167    fi
168
169    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateBegin ${DATE0_YEAR}-01-01
170    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodLength ${TIME_YEAR}Y
171
172    # DateEnd is defined by SpinUp job itself (it will be modified in config.card).
173    # but to get all SpinUp Job loops, we have to add at least a number of years greater
174    # than those that will be modified in config.card. Default is 150.00.00 years more for SpinUp.
175    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateEnd $(( DATE0_YEAR + 150 ))-01-01
176
177    # Infinit SPINUP Job :
178    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodNb 99999
179
180    # SRF section : first restart and post-treatments
181    typeset option
182    for option in ${config_SRF[*]} ; do
183        eval value=\${config_SRF_${option}}
184        eval echo ${option} ${value}
185        if [ X${value} != X ] ; then
186            eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF ${option} \${config_SRF_${option}}
187        fi
188    done
189    if [ X"${fluxnet_UserChoices_ok_stomate}" = "Xy" ] ; then
190        for option in ${config_SBG[*]} ; do
191            eval value=\${config_SBG_${option}}
192            eval echo ${option} ${value}
193            if [ X${value} != X ] ; then
194                eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG ${option} \${config_SBG_${option}}
195            fi
196        done
197    fi
198
199    # modifications on spinup.card
200    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile List "(${fluxnet_FLUXNET_FluxnetPath}/${fluxnet_FLUXNET_Sites[$(( index + ColumnFilename ))]}, forcing_file.nc)"
201
202    typeset option
203    for option in ${fluxnet_UserChoices[*]} ; do
204        eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices ${option} \${fluxnet_UserChoices_${option}}
205    done
206    # No routing for FLUXNET
207    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices ok_routing n
208
209    # Max levels for FLUXNET
210    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices sechiba_LEVEL 10
211    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices stomate_LEVEL 10
212
213    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_NORESTART y
214
215    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_nostomate $( correct_duree ${fluxnet_SPINUP_duree_nostomate} ${TIME_YEAR} )
216    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_inistomate $( correct_duree ${fluxnet_SPINUP_duree_inistomate} ${TIME_YEAR} )
217    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_offlineini $( correct_duree ${fluxnet_SPINUP_duree_offlineini} ${TIME_YEAR} )
218    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices n_iter ${fluxnet_SPINUP_n_iter}
219    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_sechiba $( correct_duree ${fluxnet_SPINUP_duree_sechiba} ${TIME_YEAR} )
220    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_stomate $( correct_duree ${fluxnet_SPINUP_duree_stomate} ${TIME_YEAR} )
221    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_carbonsol $( correct_duree ${fluxnet_SPINUP_duree_carbonsol} ${TIME_YEAR} )
222    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_final $( correct_duree ${fluxnet_SPINUP_duree_final} ${TIME_YEAR} )
223
224    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices BoundaryFilesListNonDel y
225
226    # TimeSeries : ALMAOUTPUT for SECHIBA
227
228# WARNING : You can use this first option if you set CONSERVE=y in fluxnet.card
229#    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF TimeSeriesFrequency ${TIME_YEAR}Y
230    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF TimeSeriesFrequency NONE
231    set -A sechiba_TimeSeriesVars2D -- nobiofrac SWnet LWnet Qh Qle Qg Qf DelSurfHeat DelColdCont Snowf Rainf Evap \
232                                     Qs Qsb Qsm DelSoilMoist DelSWE DelIntercept AvgSurfT RadT Albedo SWE SoilMoist SoilWet SoilTemp PotEvap \
233                                     ECanop TVeg ESoil RootMoist SubSnow ACond SnowFrac SAlbedo SnowDepth dis
234    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars2D "("$( echo ${sechiba_TimeSeriesVars2D[@]} | sed -e "s/ /,/g" )")"
235    set -A sechiba_TimeSeriesVars3D -- vegetfrac maxvegetfrac GPP
236    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars3D "("$( echo ${sechiba_TimeSeriesVars3D[@]} | sed -e "s/ /,/g" )")"
237
238    # modifications on Job script
239    rm ${New_SUBMIT_DIR}/Job_${OldJobName}
240    IGCM_sys_Cp ${SUBMIT_DIR}/Job_${MyJobName} ${New_SUBMIT_DIR}/Job_${SubJobName}
241
242    sed -e "s/ ${MyJobName}/ ${SubJobName}/" \
243        -e "s/Script_Output_${MyJobName}/Script_Output_${SubJobName}/" \
244        ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_
245    IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName}
246    chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName}
247
248
249    # modification on orchidee.def
250    IGCM_sys_Cp ${SUBMIT_DIR}/orchidee.def ${New_SUBMIT_DIR}/PARAM/orchidee.def
251
252    eval first_option=${fluxnet_SubJobParams[0]} > /dev/null 2>&1
253    if [ X${first_option} != X"Error:" ] ; then
254        IGCM_card_DefineArrayFromSection ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams
255        eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1
256           
257        typeset option option_
258        for option in ${fluxnet_SubJobParams[*]} ; do
259            eval echo "${option}="\${fluxnet_SubJobParams_${option}}
260            eval ORCHIDEE_sed ${option} \${fluxnet_SubJobParams_${option}}
261
262            if [ X${first_option} != X"Error:" ] ; then
263                for option_ in ${spinup_SubJobParams[*]} ; do
264                    if [ X${option} == X${option_} ] ; then
265                        eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams ${option} \${fluxnet_SubJobParams_${option}}
266                    fi
267                done
268            fi
269        done
270    fi
271
272    # Replace vegetation
273    eval ORCHIDEE_sed IMPOSE_VEG y
274
275    ipft=1
276    while [ $ipft -lt 14 ] ; do
277        if [ $ipft -lt 10 ] ; then
278            numpft=0${ipft}
279        else
280            numpft=${ipft}
281        fi
282        ORCHIDEE_sed SECHIBA_VEG__${numpft} ${fluxnet_FLUXNET_Sites[$(( index + ColumnPFT + ipft - 1 )) ]}
283        ORCHIDEE_sed SECHIBA_VEGMAX__${numpft} ${fluxnet_FLUXNET_Sites[$(( index + ColumnPFT + ipft - 1 )) ]}
284        ORCHIDEE_sed SECHIBA_LAI__${numpft} ${fluxnet_FLUXNET_Sites[$(( index + ColumnLAI + ipft - 1 )) ]}
285        let ipft=ipft+1
286    done
287
288    IGCM_debug_Verif_Exit
289
290# Lauch the SPINUP Job :
291
292    echo "#!/bin/ksh" > ${RUN_DIR_PATH}/SubJob${site}.ksh
293    echo "MODIPSL=${MODIPSL}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
294    echo "libIGCM=${libIGCM}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
295    echo "cd ${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
296    echo "export SUBMIT_DIR=${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
297    echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
298    echo ". ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
299    echo "export Script_Output=out_qsub_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
300    echo "export config_UserChoices_JobName=${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
301    echo "export CumulPeriod=1" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
302#    echo "nohup Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
303    echo "IGCM_sys_Qsub Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
304
305    if [ ${DRYRUN} -le 1 ] ; then
306        chmod u+x ${RUN_DIR_PATH}/SubJob${site}.ksh
307        nohup ${RUN_DIR_PATH}/SubJob${site}.ksh
308    fi
309
310    IGCM_debug_Verif_Exit
311
312    (( isite=isite+1 ))
313    (( index=index+NumInfosBySite ))
314done
315
316IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Note: See TracBrowser for help on using the repository browser.