[396] | 1 | #!/bin/ksh |
---|
[763] | 2 | #D- Driver du script pour ORCHIDEE |
---|
[396] | 3 | #----------------------------------------------------------------- |
---|
| 4 | function SRF_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "SRF_Initialize" |
---|
| 7 | |
---|
[2018] | 8 | ##- Define variable DefSuffix set in orchidee.card |
---|
[2582] | 9 | ## This variable is used in orchidee.card to choose |
---|
| 10 | ## parameter file(orchidee.def_DefSuffix). |
---|
[2018] | 11 | if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then |
---|
[2582] | 12 | DefSuffix=${orchidee_UserChoices_DefSuffix} |
---|
[2018] | 13 | else |
---|
[2582] | 14 | DefSuffix=Choi |
---|
[2018] | 15 | fi |
---|
| 16 | |
---|
[396] | 17 | IGCM_debug_PopStack "SRF_Initialize" |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | #----------------------------------------------------------------- |
---|
| 21 | function SRF_Update |
---|
| 22 | { |
---|
| 23 | IGCM_debug_PushStack "SRF_Update" |
---|
| 24 | |
---|
[2674] | 25 | ## 1. Modifications in orchidee.def parameter file |
---|
| 26 | |
---|
[2343] | 27 | # Activate STOMATE if the compontent SBG=stomate is set in config.card |
---|
| 28 | if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then |
---|
[2674] | 29 | # Activate stomate in orchidee.def |
---|
[2582] | 30 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y |
---|
[2343] | 31 | else |
---|
[2674] | 32 | # Deactivate stomate in orchidee.def |
---|
[2582] | 33 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n |
---|
[2674] | 34 | # Deactivate output files for stomate |
---|
| 35 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
| 36 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
[2343] | 37 | fi |
---|
| 38 | |
---|
[2674] | 39 | # Define in orchidee.def if restart file should be used |
---|
[793] | 40 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
[2582] | 41 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc |
---|
[1692] | 42 | else |
---|
[2582] | 43 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE |
---|
[396] | 44 | fi |
---|
| 45 | |
---|
[2758] | 46 | # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices |
---|
[1536] | 47 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
[2582] | 48 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
[1692] | 49 | else |
---|
[2582] | 50 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y |
---|
[1536] | 51 | fi |
---|
| 52 | |
---|
[2674] | 53 | # Activate creation of river description file only for the first period |
---|
[2758] | 54 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 55 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y |
---|
| 56 | else |
---|
[2674] | 57 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n |
---|
[2758] | 58 | fi |
---|
[396] | 59 | |
---|
[1622] | 60 | |
---|
[2674] | 61 | ## 2. Mangement of output and modifications of related xml files |
---|
| 62 | |
---|
| 63 | # Set default values for sechiba1_enabled, sechiba1_freq and sechiba2_enabled. |
---|
| 64 | sechiba1_enabled=.FALSE. |
---|
| 65 | sechiba2_enabled=.FALSE. |
---|
| 66 | sechiba1_freq=0s |
---|
| 67 | |
---|
| 68 | # Get WriteFrenquecies from config.card for SECHIBA |
---|
| 69 | # Note that it is only possible to have one HF and one other option. |
---|
| 70 | # If more options are set in config.card only the latest will be used. |
---|
| 71 | for frequency in ${config_SRF_WriteFrequency} ; do |
---|
| 72 | case ${frequency} in |
---|
| 73 | *Y|*y) |
---|
| 74 | NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' ) |
---|
| 75 | NbDaysYear=$( IGCM_date_DaysInYear ${year} ) |
---|
| 76 | sechiba1_enabled=.TRUE. |
---|
| 77 | sechiba1_freq=${NbYears}y ;; |
---|
| 78 | *M|*m) |
---|
| 79 | NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' ) |
---|
| 80 | sechiba1_enabled=.TRUE. |
---|
| 81 | sechiba1_freq=${NbMonths}mo ;; |
---|
| 82 | *D|*d) |
---|
| 83 | NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' ) |
---|
| 84 | sechiba1_enabled=.TRUE. |
---|
| 85 | sechiba1_freq=${NbDays}d ;; |
---|
| 86 | *s) |
---|
| 87 | WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' ) |
---|
| 88 | sechiba1_enabled=.TRUE. |
---|
| 89 | sechiba1_freq=${WriteInSeconds}s ;; |
---|
| 90 | HF|hf) |
---|
| 91 | sechiba2_enabled=.TRUE. ;; |
---|
| 92 | *) |
---|
| 93 | IGCM_debug_Exit "SRF WriteFrequency=${frequency} is invalid. Choose between xY, xM, xD, xs and HF for Sechiba." ;; |
---|
| 94 | esac |
---|
| 95 | done |
---|
| 96 | |
---|
| 97 | # Do the modifications in file_def_orchidee.xml |
---|
| 98 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled ${sechiba1_enabled} |
---|
| 99 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${sechiba1_freq} |
---|
| 100 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled ${sechiba2_enabled} |
---|
| 101 | |
---|
[2300] | 102 | # Add include of orchidee context in iodef.xml |
---|
| 103 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
| 104 | # <context id="orchidee" src="./context_orchidee.xml"/> |
---|
[2582] | 105 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
| 106 | cp iodef.xml iodef.xml.tmp |
---|
| 107 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
| 108 | rm iodef.xml.tmp add.tmp |
---|
[2300] | 109 | |
---|
[396] | 110 | IGCM_debug_PopStack "SRF_Update" |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | #----------------------------------------------------------------- |
---|
| 114 | function SRF_Finalize |
---|
| 115 | { |
---|
| 116 | IGCM_debug_PushStack "SRF_Finalize" |
---|
| 117 | |
---|
| 118 | IGCM_debug_PopStack "SRF_Finalize" |
---|
| 119 | } |
---|