#!/bin/ksh #D--------------------------------------------------------------------== function FLUXNET_initialize { IGCM_debug_PushStack "FLUXNET_initialize" # config.card : # ------------- IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices typeset option for option in ${config_UserChoices[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} done DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) IGCM_date_GetYearMonth ${DateBegin} year month IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SubJobPost typeset option for option in ${config_SubJobPost[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SubJobPost ${option} done # Subjobs configuration : # ----------------------- # 1) UserChoices section of fluxnet.card # This section groups standard options to be passed to ORCHIDEE. IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card UserChoices set +A fluxnet_UserChoices -- ${fluxnet_UserChoices[*]} > /dev/null 2>&1 typeset option for option in ${fluxnet_UserChoices[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card UserChoices ${option} done IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF typeset option for option in ${config_SRF[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option} done if [ X"${fluxnet_UserChoices_ok_stomate}" = "Xy" ] ; then IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG typeset option for option in ${config_SBG[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option} done fi # 2) FLUXNET section : # This section groups specific options for FLUXNET spinup : # - Fluxnet files path IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET FluxnetPath # - List of the sites/information to be treated : # * Number of PFTs IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbPFTs NbPFTs=${fluxnet_FLUXNET_NbPFTs} # * Number of physical parameters on each sites per PFTs IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbSitesParam # * ORCHIDEE name for physical parameters on each sites IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NameSitesParam # * Sites descriptions IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET Sites # * Components for each physical parameter described in NameSitesParam IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET CompSitesParam echo ${fluxnet_FLUXNET_Sites[*]} # Number of columns by site in variable site : name, filename, length, + ${NbPFTs} PFT NumInfosBySite=$(( 4 + ( NbPFTs * fluxnet_FLUXNET_NbSitesParam ) )) # Number of sites : NumSites=$(( ${#fluxnet_FLUXNET_Sites[*]} / NumInfosBySite )) # Num of Columns : name, filename, length, + ${NbPFTs} PFT ColumnName=0 ColumnFilename=1 ColumnYear=2 ColumnLength=3 # 3) SPINUP section : files path and spinup parameters # This section groups specific options for SPINUP : IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SPINUP set +A fluxnet_SPINUP -- ${fluxnet_SPINUP[*]} > /dev/null 2>&1 typeset option for option in ${fluxnet_SPINUP[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SPINUP ${option} done # 4) Subjob orchidee.def parametrisation : SubJobParams in fluxnet.card # This section give flags to put in orchidee.def of Subjobs. IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SubJobParams set +A fluxnet_SubJobParams -- ${fluxnet_SubJobParams[*]} > /dev/null 2>&1 eval first_option=${fluxnet_SubJobParams[0]} > /dev/null 2>&1 if [ X${first_option} != X"Error:" ] ; then typeset option for option in ${fluxnet_SubJobParams[*]} ; do IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SubJobParams ${option} done fi IGCM_debug_PopStack "FLUXNET_initialize" } # Function to sed parameter files in Subjob dirs # For sechiba.def : function SECHIBA_sed { IGCM_debug_PushStack "SECHIBA_sed" if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ ${New_SUBMIT_DIR}/PARAM/sechiba.def > ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp RET=$? echo "SECHIBA_sed : ${1} ${2}" \mv ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp ${New_SUBMIT_DIR}/PARAM/sechiba.def fi IGCM_debug_PopStack "SECHIBA_sed" return $RET } # For stomate.def : function STOMATE_sed { IGCM_debug_PushStack "STOMATE_sed" sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ ${New_SUBMIT_DIR}/PARAM/stomate.def > ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp RET=$? echo "STOMATE_sed : ${1} ${2}" \mv ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp ${New_SUBMIT_DIR}/PARAM/stomate.def IGCM_debug_PopStack "STOMATE_sed" return $RET } # For driver.def : function DRIVER_sed { IGCM_debug_PushStack "DRIVER_sed" if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ ${New_SUBMIT_DIR}/PARAM/driver.def > ${New_SUBMIT_DIR}/PARAM/driver.def.tmp RET=$? echo "DRIVER_sed : ${1} ${2}" \mv ${New_SUBMIT_DIR}/PARAM/driver.def.tmp ${New_SUBMIT_DIR}/PARAM/driver.def fi IGCM_debug_PopStack "DRIVER_sed" return $RET } # Function to grep parameter files in Subjob dirs # They search for the argmument value in the file. # The result of the function is given in ${SearchParam} global variable : # * "line" if the parameter is defined with the form # PARAM__1=value1 # PARAM__2=value2 # etc... # * "vector" if the parameter is defined with the form # PARAM=value1 value2 etc... # * "undefined" if the parameter is not definied in the parameters file # This should give an error in the script. # For sechiba.def : function SECHIBA_grep { IGCM_debug_PushStack "SECHIBA_grep" typeset Output if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def ) if [ X${Output[0]} != X ] ; then SearchParam=line else unset Output set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def ) if [ X${Output[0]} != X ] ; then SearchParam=vector else SearchParam=undefined fi fi else SearchParam=undefined echo "$@ : file not found !!" fi IGCM_debug_PopStack "SECHIBA_grep" return $RET } # For stomate.def : function STOMATE_grep { IGCM_debug_PushStack "STOMATE_grep" typeset Output if [ -f ${New_SUBMIT_DIR}/PARAM/stomate.def ] ; then set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def ) if [ X${Output[0]} != X ] ; then SearchParam=line else unset Output set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def ) if [ X${Output[0]} != X ] ; then SearchParam=vector else SearchParam=undefined fi fi else SearchParam=undefined echo "$@ : file not found !!" fi IGCM_debug_PopStack "STOMATE_grep" return $RET } # For driver.def : function DRIVER_grep { IGCM_debug_PushStack "DRIVER_grep" typeset Output if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def ) if [ X${Output[0]} != X ] ; then SearchParam=line else unset Output set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def ) if [ X${Output[0]} != X ] ; then SearchParam=vector else SearchParam=undefined fi fi else SearchParam=undefined echo "$@ : file not found !!" fi IGCM_debug_PopStack "DRIVER_grep" return $RET }