[1095] | 1 | # $Id$ |
---|
| 2 | # |
---|
| 3 | #!/bin/ksh |
---|
| 4 | #----------------------------------------------------------------- |
---|
| 5 | function LMDZ_sed |
---|
| 6 | { |
---|
| 7 | IGCM_debug_PushStack "LMDZ_sed" |
---|
| 8 | |
---|
| 9 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
| 10 | RET=$? |
---|
| 11 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
| 12 | \mv ${1}.tmp ${1} |
---|
| 13 | |
---|
| 14 | IGCM_debug_PopStack "LMDZ_sed" |
---|
| 15 | return $RET |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | function ATM_Initialize |
---|
| 19 | { |
---|
| 20 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 21 | |
---|
| 22 | RESOL_ATM=$( echo $RESOL | awk "-F-" '{print $1}') |
---|
| 23 | |
---|
[1397] | 24 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x39 |
---|
[1095] | 25 | |
---|
| 26 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
| 27 | |
---|
| 28 | ##-- Calendar type for LMDZ |
---|
| 29 | case ${config_UserChoices_CalendarType} in |
---|
| 30 | leap|gregorian) |
---|
| 31 | CalendarTypeForLmdz=earth_366d;; |
---|
| 32 | noleap) |
---|
| 33 | CalendarTypeForLmdz=earth_365d;; |
---|
| 34 | 360d) |
---|
| 35 | CalendarTypeForLmdz=earth_360d;; |
---|
| 36 | *) |
---|
| 37 | CalendarTypeForLmdz=earth_360d |
---|
| 38 | esac |
---|
| 39 | |
---|
| 40 | ##- Create_etat0_limit version |
---|
| 41 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
| 42 | CREATE=${lmdz_UserChoices_CREATE} |
---|
| 43 | echo create_etat0_limit version : ${CREATE} |
---|
| 44 | |
---|
| 45 | ##- Default number of processor for lmdz |
---|
| 46 | NUM_PROC_ATM=4 |
---|
| 47 | if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then |
---|
| 48 | NUM_PROC_ATM=${BATCH_NUM_PROC_TOT} |
---|
| 49 | fi |
---|
| 50 | |
---|
| 51 | ##--Frequency purpose .... |
---|
| 52 | ##-- Initialisation .... |
---|
| 53 | OK_instan=n |
---|
| 54 | OK_journe=n |
---|
| 55 | OK_mensuel=n |
---|
| 56 | ok_hf=n |
---|
| 57 | |
---|
| 58 | case ${config_UserChoices_PeriodLength} in |
---|
| 59 | 1Y|1y|1M|1m) OK_mensuel=y ;; |
---|
| 60 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 61 | esac |
---|
| 62 | |
---|
| 63 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 64 | case ${frequency} in |
---|
| 65 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 66 | esac |
---|
| 67 | case ${frequency} in |
---|
| 68 | HF|hf) |
---|
| 69 | ok_hf=y |
---|
| 70 | OK_instan=y |
---|
| 71 | ;; |
---|
| 72 | esac |
---|
| 73 | done |
---|
| 74 | |
---|
| 75 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
| 76 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
| 77 | eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
| 78 | |
---|
| 79 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
| 80 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
| 81 | eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1 |
---|
| 82 | fi |
---|
| 83 | |
---|
| 84 | ## Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card |
---|
| 85 | eval LMDZ_Freq_aero=\${lmdz_UserChoices_LMDZ_Freq_aero} > /dev/null 2>&1 |
---|
| 86 | eval LMDZ_Length_aero=\${lmdz_UserChoices_LMDZ_Length_aero} > /dev/null 2>&1 |
---|
| 87 | |
---|
| 88 | ## Read LMDZ_COSP_monthly LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card |
---|
| 89 | eval LMDZ_COSP_OK=\${lmdz_UserChoices_LMDZ_COSP_OK} > /dev/null 2>&1 |
---|
| 90 | eval LMDZ_COSP_monthly=\${lmdz_UserChoices_LMDZ_COSP_monthly} > /dev/null 2>&1 |
---|
| 91 | eval LMDZ_COSP_daily=\${lmdz_UserChoices_LMDZ_COSP_daily} > /dev/null 2>&1 |
---|
| 92 | eval LMDZ_COSP_hf=\${lmdz_UserChoices_LMDZ_COSP_hf} > /dev/null 2>&1 |
---|
| 93 | |
---|
| 94 | ## Read LMDZ_NMC_monthly LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card |
---|
| 95 | eval LMDZ_NMC_monthly=\${lmdz_UserChoices_LMDZ_NMC_monthly} > /dev/null 2>&1 |
---|
| 96 | eval LMDZ_NMC_daily=\${lmdz_UserChoices_LMDZ_NMC_daily} > /dev/null 2>&1 |
---|
| 97 | eval LMDZ_NMC_hf=\${lmdz_UserChoices_LMDZ_NMC_hf} > /dev/null 2>&1 |
---|
| 98 | |
---|
| 99 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | #----------------------------------------------------------------- |
---|
| 103 | function ATM_Update |
---|
| 104 | { |
---|
| 105 | IGCM_debug_PushStack "ATM_Update" |
---|
| 106 | |
---|
| 107 | case ${config_UserChoices_PeriodLength} in |
---|
| 108 | *Y|*y) |
---|
| 109 | LMDZ_ecrit_mth=30. |
---|
| 110 | LMDZ_ecrit_ISCCP=30. |
---|
| 111 | LMDZ_periodav=30. |
---|
| 112 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
| 113 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
| 114 | exit |
---|
| 115 | fi |
---|
| 116 | ;; |
---|
| 117 | *) |
---|
| 118 | LMDZ_ecrit_mth=${PeriodLengthInDays}. |
---|
| 119 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 120 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 121 | ;; |
---|
| 122 | esac |
---|
| 123 | |
---|
| 124 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 125 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 126 | RAZ_DATE=1 |
---|
| 127 | else |
---|
| 128 | RAZ_DATE=0 |
---|
| 129 | fi |
---|
| 130 | |
---|
| 131 | ## To have more variables in output files for aerosols. Parameters are set in lmdz.card |
---|
| 132 | #if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then |
---|
| 133 | # if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then |
---|
| 134 | # lev_histmth=4 |
---|
| 135 | # else |
---|
| 136 | # lev_histmth=2 |
---|
| 137 | # fi |
---|
| 138 | #else |
---|
| 139 | # lev_histmth=2 |
---|
| 140 | #fi |
---|
| 141 | |
---|
| 142 | ## algo : For CumulPeriod=1 ; |
---|
| 143 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
| 144 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 145 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 146 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
| 147 | |
---|
| 148 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 149 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
| 150 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 151 | IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0 |
---|
| 152 | IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0" |
---|
| 153 | fi |
---|
| 154 | fi |
---|
| 155 | |
---|
| 156 | LMDZ_adjust=n |
---|
| 157 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 158 | |
---|
| 159 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 160 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
| 161 | |
---|
| 162 | [ ${CumulPeriod} -gt 1 ] && ( IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ) |
---|
| 163 | |
---|
| 164 | ##-- GHG forcing for the current year |
---|
[1397] | 165 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOESANDRCPS_1610_2500.txt | awk -F= '{print $2}'` |
---|
| 166 | IPCC_CO2=`grep Annee_${year} CO2_1765_2500.txt | awk -F= '{print $2}'` |
---|
[1463] | 167 | IPCC_CO2_per=`grep Annee_${year} CO2_1765_2500.txt | awk -F= '{print $2 * 4}'` |
---|
[1397] | 168 | IPCC_CH4=`grep Annee_${year} CH4_1765_2500.txt | awk -F= '{print $2}'` |
---|
| 169 | IPCC_N2O=`grep Annee_${year} N2O_1765_2500.txt | awk -F= '{print $2}'` |
---|
| 170 | IPCC_CFC11=`grep Annee_${year} CFC11_1765_2500.txt | awk -F= '{print $2}'` |
---|
| 171 | IPCC_CFC12=`grep Annee_${year} CFC12_1765_2500.txt | awk -F= '{print $2}'` |
---|
[1095] | 172 | |
---|
| 173 | ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} |
---|
| 174 | LMDZ_sed physiq.def OK_instan ${OK_instan} |
---|
| 175 | LMDZ_sed physiq.def OK_journe ${OK_journe} |
---|
| 176 | LMDZ_sed physiq.def OK_mensuel ${OK_mensuel} |
---|
| 177 | #LMDZ_sed physiq.def lev_histmth ${lev_histmth} |
---|
| 178 | LMDZ_sed physiq.def ok_hf ${ok_hf} |
---|
| 179 | LMDZ_sed physiq.def ecrit_mth ${LMDZ_ecrit_mth} |
---|
| 180 | LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
| 181 | LMDZ_sed physiq.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 182 | LMDZ_sed physiq.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 183 | LMDZ_sed physiq.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 184 | LMDZ_sed physiq.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
| 185 | LMDZ_sed physiq.def ok_histNMC "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" |
---|
| 186 | LMDZ_sed physiq.def solaire ${IPCC_SOLAR} |
---|
| 187 | LMDZ_sed physiq.def co2_ppm ${IPCC_CO2} |
---|
[1463] | 188 | LMDZ_sed physiq.def co2_ppm_per ${IPCC_CO2_per} |
---|
[1095] | 189 | LMDZ_sed physiq.def CH4_ppb ${IPCC_CH4} |
---|
| 190 | LMDZ_sed physiq.def N2O_ppb ${IPCC_N2O} |
---|
| 191 | LMDZ_sed physiq.def CFC11_ppt ${IPCC_CFC11} |
---|
| 192 | LMDZ_sed physiq.def CFC12_ppt ${IPCC_CFC12} |
---|
| 193 | |
---|
| 194 | ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified |
---|
| 195 | |
---|
| 196 | ## run.def parameters |
---|
| 197 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 198 | LMDZ_sed run.def anneeref ${InitYear} |
---|
| 199 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
| 200 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 201 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 202 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 203 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
| 204 | |
---|
| 205 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 206 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta |
---|
| 207 | eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1 |
---|
| 208 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
| 209 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 210 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 211 | echo |
---|
| 212 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 213 | echo |
---|
| 214 | cat gcm.def |
---|
| 215 | ByPass_hgardfou_teta=n |
---|
| 216 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
| 217 | fi |
---|
| 218 | |
---|
| 219 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 220 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats |
---|
| 221 | eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1 |
---|
| 222 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
| 223 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 224 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 225 | echo |
---|
| 226 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 227 | echo |
---|
| 228 | cat gcm.def |
---|
| 229 | ByPass_hgardfou_mats=n |
---|
| 230 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
| 231 | fi |
---|
| 232 | |
---|
| 233 | IGCM_debug_PopStack "ATM_Update" |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | #----------------------------------- |
---|
| 237 | function ATM_Finalize |
---|
| 238 | { |
---|
| 239 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 240 | |
---|
| 241 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
| 242 | |
---|
| 243 | echo FINALIZE ATM ! |
---|
| 244 | |
---|
| 245 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 246 | } |
---|