source: tags/ORCHIDEE_1_9_5_1/ORCHIDEE_OL/FLUXNET/fluxnet.ksh @ 56

Last change on this file since 56 was 52, checked in by mmaipsl, 14 years ago

Update scripts for OOL_1_9_5_1 tag.

File size: 7.6 KB
Line 
1#!/bin/ksh
2
3#D--------------------------------------------------------------------==
4
5function FLUXNET_initialize
6{
7    IGCM_debug_PushStack "FLUXNET_initialize"
8
9    # config.card :
10    # -------------
11    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices
12    typeset option
13    for option in ${config_UserChoices[*]} ; do
14        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option}
15    done
16   
17    DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
18    IGCM_date_GetYearMonth ${DateBegin} year month
19   
20    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF
21    typeset option
22    for option in ${config_SRF[*]} ; do
23        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option}
24    done
25    if [ X"${fluxnet_UserChoices_ok_stomate}" = "Xy" ] ; then
26        IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG
27        typeset option
28        for option in ${config_SBG[*]} ; do
29            IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option}
30        done
31    fi
32   
33    # Subjobs configuration :
34    # -----------------------
35
36    # 1) UserChoices section of fluxnet.card
37
38    # This section groups standard options to be passed to ORCHIDEE.
39    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card UserChoices
40    set +A fluxnet_UserChoices -- ${fluxnet_UserChoices[*]} > /dev/null 2>&1
41    typeset option
42    for option in ${fluxnet_UserChoices[*]} ; do
43        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card UserChoices ${option}
44    done
45
46    # 2) FLUXNET section :
47
48    # This section groups specific options for FLUXNET spinup :
49    # - Fluxnet files path
50    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET FluxnetPath
51
52    # - List of the sites/information to be treated :
53    #   * Number of PFTs
54    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbPFTs
55    NbPFTs=${fluxnet_FLUXNET_NbPFTs}
56
57    #   * Number of physical parameters on each sites per PFTs
58    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbSitesParam
59    #   * ORCHIDEE name for physical parameters on each sites
60    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NameSitesParam
61    #   * Sites descriptions
62    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET Sites
63    #   * Components for each physical parameter described in NameSitesParam
64    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET CompSitesParam
65
66    echo ${fluxnet_FLUXNET_Sites[*]}
67
68    # Number of columns by site in variable site : name, filename, length, + ${NbPFTs} PFT
69    NumInfosBySite=$(( 4 + ( NbPFTs * fluxnet_FLUXNET_NbSitesParam ) ))
70
71    # Number of sites :
72    NumSites=$(( ${#fluxnet_FLUXNET_Sites[*]} / NumInfosBySite ))
73    # Num of Columns : name, filename, length, + ${NbPFTs} PFT
74    ColumnName=0
75    ColumnFilename=1
76    ColumnYear=2
77    ColumnLength=3
78
79    # 3) SPINUP section : files path and spinup parameters
80    # This section groups specific options for SPINUP :
81    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SPINUP
82    set +A fluxnet_SPINUP -- ${fluxnet_SPINUP[*]} > /dev/null 2>&1
83    typeset option
84    for option in ${fluxnet_SPINUP[*]} ; do
85        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SPINUP ${option}
86    done
87
88    # 4) Subjob orchidee.def parametrisation : SubJobParams in fluxnet.card
89    # This section give flags to put in orchidee.def of Subjobs.
90    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SubJobParams
91    set +A fluxnet_SubJobParams -- ${fluxnet_SubJobParams[*]} > /dev/null 2>&1
92    eval first_option=${fluxnet_SubJobParams[0]} > /dev/null 2>&1
93    if [ X${first_option} != X"Error:" ] ; then
94        typeset option
95        for option in ${fluxnet_SubJobParams[*]} ; do
96            IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SubJobParams ${option}
97        done
98    fi
99
100    IGCM_debug_PopStack "FLUXNET_initialize"
101}
102
103# Function to sed parameter files in Subjob dirs
104# For sechiba.def :
105function SECHIBA_sed
106{
107    IGCM_debug_PushStack "SECHIBA_sed"
108   
109    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
110        sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
111            ${New_SUBMIT_DIR}/PARAM/sechiba.def > ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp
112        RET=$?
113        echo "SECHIBA_sed : ${1} ${2}"
114        \mv ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp ${New_SUBMIT_DIR}/PARAM/sechiba.def
115    fi
116
117    IGCM_debug_PopStack "SECHIBA_sed"
118    return $RET
119}
120
121# For stomate.def :
122function STOMATE_sed
123{
124    IGCM_debug_PushStack "STOMATE_sed"
125   
126    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
127        ${New_SUBMIT_DIR}/PARAM/stomate.def > ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp
128    RET=$?
129    echo "STOMATE_sed : ${1} ${2}"
130    \mv ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp ${New_SUBMIT_DIR}/PARAM/stomate.def
131   
132    IGCM_debug_PopStack "STOMATE_sed"
133    return $RET
134}
135
136# For driver.def :
137function DRIVER_sed
138{
139    IGCM_debug_PushStack "DRIVER_sed"
140   
141    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
142        sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
143            ${New_SUBMIT_DIR}/PARAM/driver.def > ${New_SUBMIT_DIR}/PARAM/driver.def.tmp
144        RET=$?
145        echo "DRIVER_sed : ${1} ${2}"
146        \mv ${New_SUBMIT_DIR}/PARAM/driver.def.tmp ${New_SUBMIT_DIR}/PARAM/driver.def
147    fi
148
149    IGCM_debug_PopStack "DRIVER_sed"
150    return $RET
151}
152
153
154# Function to grep parameter files in Subjob dirs
155# They search for the argmument value in the file.
156# The result of the function is given in ${SearchParam} global variable :
157# * "line" if the parameter is defined with the form
158#   PARAM__1=value1
159#   PARAM__2=value2
160#   etc...
161# * "vector" if the parameter is defined with the form
162#   PARAM=value1 value2 etc...
163# * "undefined" if the parameter is not definied in the parameters file
164#   This should give an error in the script.
165
166# For sechiba.def :
167function SECHIBA_grep
168{
169    IGCM_debug_PushStack "SECHIBA_grep"
170    typeset Output
171
172    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
173        set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
174        if [ X${Output[0]} != X ] ; then
175            SearchParam=line
176        else
177            unset Output
178            set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
179            if [ X${Output[0]} != X ] ; then
180                SearchParam=vector
181            else
182                SearchParam=undefined
183            fi
184        fi
185    else
186        SearchParam=undefined
187        echo "$@ : file not found !!"
188    fi
189
190    IGCM_debug_PopStack "SECHIBA_grep"
191    return $RET
192}
193
194# For stomate.def :
195function STOMATE_grep
196{
197    IGCM_debug_PushStack "STOMATE_grep"
198    typeset Output
199
200    if [ -f ${New_SUBMIT_DIR}/PARAM/stomate.def ] ; then
201        set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def )
202        if [ X${Output[0]} != X ] ; then
203            SearchParam=line
204        else
205            unset Output
206            set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def )
207            if [ X${Output[0]} != X ] ; then
208                SearchParam=vector
209            else
210                SearchParam=undefined
211            fi
212        fi
213    else
214        SearchParam=undefined
215        echo "$@ : file not found !!"
216    fi
217
218    IGCM_debug_PopStack "STOMATE_grep"
219    return $RET
220}
221
222# For driver.def :
223function DRIVER_grep
224{
225    IGCM_debug_PushStack "DRIVER_grep"
226    typeset Output
227
228    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
229        set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def )
230        if [ X${Output[0]} != X ] ; then
231            SearchParam=line
232        else
233            unset Output
234            set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def )
235            if [ X${Output[0]} != X ] ; then
236                SearchParam=vector
237            else
238                SearchParam=undefined
239            fi
240        fi
241    else
242        SearchParam=undefined
243        echo "$@ : file not found !!"
244    fi
245
246    IGCM_debug_PopStack "DRIVER_grep"
247    return $RET
248}
249
Note: See TracBrowser for help on using the repository browser.