[1818] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
| 3 | function LMDZ_sed |
---|
| 4 | { |
---|
| 5 | # Usage : LMDZ_sed filedef var_name myvalue |
---|
| 6 | # In file filedef modify the line containing var_name=xxx into var_name=myvalue |
---|
| 7 | IGCM_debug_PushStack "LMDZ_sed" |
---|
| 8 | |
---|
| 9 | # Test if the fichier exist |
---|
| 10 | if [ ! -f ${1} ] ; then |
---|
| 11 | echo "WARNING : ${1} file does not exist. Following will not be done : LMDZ_sed : ${1} ${2} ${3}" |
---|
| 12 | return |
---|
| 13 | fi |
---|
| 14 | |
---|
| 15 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
| 16 | RET=$? |
---|
| 17 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
| 18 | \mv ${1}.tmp ${1} |
---|
| 19 | |
---|
| 20 | IGCM_debug_PopStack "LMDZ_sed" |
---|
| 21 | return $RET |
---|
| 22 | } |
---|
| 23 | function LMDZ_sed_default |
---|
| 24 | { |
---|
| 25 | # Usage : LMDZ_sed_default filedef var_name |
---|
| 26 | # In file filedef modify the line "var_name=xxx DEFAULT= myvalue" |
---|
| 27 | # into "var_name=myvalue" |
---|
| 28 | IGCM_debug_PushStack "LMDZ_sed_default" |
---|
| 29 | |
---|
| 30 | DefValue=$( grep ${2} ${1} | awk -F"DEFAULT.=*" '{print $2}') |
---|
| 31 | |
---|
| 32 | LMDZ_sed ${1} ${2} $DefValue |
---|
| 33 | IGCM_debug_PopStack "LMDZ_sed_default" |
---|
| 34 | return $RET |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | function ATM_Initialize |
---|
| 39 | { |
---|
| 40 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 41 | |
---|
| 42 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
| 43 | |
---|
| 44 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
| 45 | |
---|
| 46 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
| 47 | RESOL_ATM_X=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $1}' ) |
---|
| 48 | RESOL_ATM_Y=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $2}' ) |
---|
| 49 | RESOL_ATM_XY="${RESOL_ATM_X}x${RESOL_ATM_Y}" |
---|
| 50 | |
---|
[1923] | 51 | ##-- Calendar type for LMDZ and create_etat0_limit |
---|
[1818] | 52 | case ${config_UserChoices_CalendarType} in |
---|
| 53 | leap|gregorian) |
---|
[1923] | 54 | CalendarTypeForLmdz=earth_366d |
---|
| 55 | CalendarTypeForCreate=gregorian;; |
---|
[1818] | 56 | noleap) |
---|
[1923] | 57 | CalendarTypeForLmdz=earth_365d |
---|
| 58 | CalendarTypeForCreate=${CalendarTypeForLmdz};; |
---|
[1818] | 59 | 360d) |
---|
[1923] | 60 | CalendarTypeForLmdz=earth_360d |
---|
| 61 | CalendarTypeForCreate=${CalendarTypeForLmdz};; |
---|
[1818] | 62 | *) |
---|
| 63 | CalendarTypeForLmdz=earth_360d |
---|
[1923] | 64 | CalendarTypeForCreate=${CalendarTypeForLmdz} |
---|
[1818] | 65 | esac |
---|
| 66 | |
---|
| 67 | ##- LMDZ physics version |
---|
| 68 | ## Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics) |
---|
| 69 | if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then |
---|
| 70 | LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics} |
---|
| 71 | else |
---|
| 72 | LMDZ_Physics=AP |
---|
| 73 | fi |
---|
| 74 | echo LMDZ physics version : ${LMDZ_Physics} |
---|
| 75 | |
---|
| 76 | ##- Create_etat0_limit version |
---|
| 77 | ## Define variable CREATE only if it is set in lmdz.card section UserChoices. |
---|
| 78 | ## This variable is only used in lmdz.card to choose input files. |
---|
| 79 | if [ ! X${lmdz_UserChoices_CREATE} = X ] ; then |
---|
| 80 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
| 81 | CREATE=${lmdz_UserChoices_CREATE} |
---|
| 82 | echo create_etat0_limit version : ${CREATE} |
---|
| 83 | fi |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | ## - LMDZ choice of config.def file |
---|
| 87 | ## ConfType must be set in lmdz.card |
---|
| 88 | ConfType=${lmdz_UserChoices_ConfType} |
---|
| 89 | |
---|
| 90 | ##- LMDZ output level, to be set in lmdz.card |
---|
| 91 | if [ X${lmdz_UserChoices_OutLevel} = X ] ; then |
---|
| 92 | # OutLevel is not set. Take default value low. |
---|
| 93 | OutLevel=low |
---|
| 94 | else |
---|
| 95 | OutLevel=${lmdz_UserChoices_OutLevel} |
---|
| 96 | fi |
---|
| 97 | |
---|
| 98 | ##-- Output frequency purpose .... |
---|
| 99 | ##-- Initialisation .... |
---|
| 100 | ok_mensuel=n |
---|
| 101 | ok_journe=n |
---|
| 102 | ok_hf=n |
---|
| 103 | ok_hf3h=n |
---|
| 104 | ok_hf3hm=n |
---|
| 105 | ok_stn=n |
---|
| 106 | |
---|
| 107 | case ${config_UserChoices_PeriodLength} in |
---|
| 108 | 1Y|1y|1M|1m) ok_mensuel=y ;; |
---|
| 109 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
| 110 | esac |
---|
| 111 | |
---|
| 112 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 113 | case ${frequency} in |
---|
| 114 | 1M|1m) ok_mensuel=y ;; |
---|
| 115 | esac |
---|
| 116 | case ${frequency} in |
---|
| 117 | 5D|5d|1D|1d) ok_journe=y ;; |
---|
| 118 | esac |
---|
| 119 | case ${frequency} in |
---|
| 120 | HF|hf) ok_hf=y ;; |
---|
| 121 | esac |
---|
| 122 | case ${frequency} in |
---|
| 123 | HF3h|hf3h) ok_hf3h=y ;; |
---|
| 124 | esac |
---|
| 125 | case ${frequency} in |
---|
| 126 | HF3hm|hf3hm) ok_hf3hm=y ;; |
---|
| 127 | esac |
---|
| 128 | case ${frequency} in |
---|
| 129 | STN|stn) ok_stn=y ;; |
---|
| 130 | esac |
---|
| 131 | done |
---|
| 132 | |
---|
| 133 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
| 134 | if [ X"${lmdz_UserChoices_LMDZ_NbPeriod_adjust}" = X"" ] ; then |
---|
| 135 | # The variable is not in lmdz.card, set default value |
---|
| 136 | LMDZ_NbPeriod_adjust=0 |
---|
| 137 | else |
---|
| 138 | LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust} |
---|
| 139 | fi |
---|
| 140 | |
---|
| 141 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
| 142 | LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name} |
---|
| 143 | fi |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | ## Read LMDZ_COSP_OK in lmdz.card |
---|
| 147 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ] ; then |
---|
| 148 | LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK} |
---|
| 149 | else |
---|
| 150 | LMDZ_COSP_OK=n |
---|
| 151 | fi |
---|
| 152 | ## Read LMDZ_COSP_monthly in lmdz.card |
---|
| 153 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_monthly} = X ] ; then |
---|
| 154 | LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly} |
---|
| 155 | else |
---|
| 156 | LMDZ_COSP_monthly=n |
---|
| 157 | fi |
---|
| 158 | ## Read LMDZ_COSP_daily in lmdz.card |
---|
| 159 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_daily} = X ] ; then |
---|
| 160 | LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily} |
---|
| 161 | else |
---|
| 162 | LMDZ_COSP_daily=n |
---|
| 163 | fi |
---|
| 164 | ## Read LMDZ_COSP_hf in lmdz.card |
---|
| 165 | if [ ! X${lmdz_UserChoices_LMDZ_COSP_hf} = X ] ; then |
---|
| 166 | LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf} |
---|
| 167 | else |
---|
| 168 | LMDZ_COSP_hf=n |
---|
| 169 | fi |
---|
| 170 | |
---|
| 171 | ## Read LMDZ_NMC_monthly in lmdz.card |
---|
| 172 | if [ ! X${lmdz_UserChoices_LMDZ_NMC_monthly} = X ] ; then |
---|
| 173 | LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly} |
---|
| 174 | else |
---|
| 175 | LMDZ_NMC_monthly=n |
---|
| 176 | fi |
---|
| 177 | |
---|
| 178 | ## Read LMDZ_NMC_daily in lmdz.card |
---|
| 179 | if [ ! X${lmdz_UserChoices_LMDZ_NMC_daily} = X ] ; then |
---|
| 180 | LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily} |
---|
| 181 | else |
---|
| 182 | LMDZ_NMC_daily=n |
---|
| 183 | fi |
---|
| 184 | |
---|
| 185 | ## Read LMDZ_NMC_hf in lmdz.card |
---|
| 186 | if [ ! X${lmdz_UserChoices_LMDZ_NMC_hf} = X ] ; then |
---|
| 187 | LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf} |
---|
| 188 | else |
---|
| 189 | LMDZ_NMC_hf=n |
---|
| 190 | fi |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | #----------------------------------------------------------------- |
---|
| 197 | function ATM_Update |
---|
| 198 | { |
---|
| 199 | IGCM_debug_PushStack "ATM_Update" |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | case ${config_UserChoices_PeriodLength} in |
---|
| 203 | *Y|*y) |
---|
| 204 | LMDZ_ecrit_ISCCP=30. |
---|
| 205 | LMDZ_periodav=30. |
---|
| 206 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
| 207 | echo Do not consider following warning if your running create_etat0_limit : |
---|
| 208 | echo WARNING !!! For lmdz : calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
| 209 | fi |
---|
| 210 | ;; |
---|
| 211 | *) |
---|
| 212 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 213 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 214 | ;; |
---|
| 215 | esac |
---|
| 216 | |
---|
| 217 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 218 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 219 | RAZ_DATE=1 |
---|
| 220 | else |
---|
| 221 | RAZ_DATE=0 |
---|
| 222 | fi |
---|
| 223 | |
---|
[1892] | 224 | ## Algorithme for special treatment for Bands_xxx file |
---|
| 225 | ## For CumulPeriod=1 ; |
---|
| 226 | ## IF NbPeriod_Adjust = 0 ; set LMDZ_adjust=n |
---|
| 227 | ## IF LMDZ_Bands_file_name was given in lmdz.card THEN Get Bands file directly from server. Store it later with _0 suffix. |
---|
| 228 | ## IF no LMDZ_Bands_file_name was given, start without Bands file. Store it later with _0 suffix. |
---|
| 229 | ## ELSE set LMDZ_adjust=y ; start without Bands file ; Store it later in PARAM/ directory in submit directory with suffix _1 ; |
---|
| 230 | ## |
---|
| 231 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; |
---|
| 232 | ## Get Bands file from PARAM/ in submit directory (CumulPeriod-1) ; set LMDZ_adjust=y ; Store Bands file in PARAM/ ; |
---|
| 233 | ## |
---|
| 234 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from PARAM/ ; Do not store ; |
---|
[1818] | 235 | |
---|
| 236 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 237 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
| 238 | if [ ! X${LMDZ_Bands_file_name} = X ] ; then |
---|
| 239 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 240 | IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 241 | 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" |
---|
| 242 | fi |
---|
| 243 | fi |
---|
| 244 | fi |
---|
| 245 | |
---|
| 246 | LMDZ_adjust=n |
---|
| 247 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 248 | |
---|
| 249 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
| 250 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
| 251 | |
---|
[1897] | 252 | # Get Bands file from PARAM directory if file exist |
---|
[1998] | 253 | if ( [ ${CumulPeriod} -gt 1 ] && [ -f ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} ] ) ; then |
---|
[1894] | 254 | IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
[1892] | 255 | IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 256 | fi |
---|
[1818] | 257 | |
---|
| 258 | ##-- GHG forcing : |
---|
| 259 | ## If forcing file exist in run directory, read values for the current year and modify config.def |
---|
| 260 | if [ -f SOLARANDVOLCANOES.txt ] ; then |
---|
| 261 | IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` |
---|
| 262 | LMDZ_sed config.def solaire ${IPCC_SOLAR} |
---|
| 263 | else |
---|
| 264 | LMDZ_sed_default config.def solaire |
---|
| 265 | fi |
---|
| 266 | if [ -f CO2.txt ] ; then |
---|
| 267 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
| 268 | LMDZ_sed config.def co2_ppm ${IPCC_CO2} |
---|
| 269 | else |
---|
| 270 | LMDZ_sed_default config.def co2_ppm |
---|
| 271 | fi |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | if [ -f CH4.txt ] ; then |
---|
| 275 | IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` |
---|
| 276 | LMDZ_sed config.def CH4_ppb ${IPCC_CH4} |
---|
| 277 | else |
---|
| 278 | LMDZ_sed_default config.def CH4_ppb |
---|
| 279 | fi |
---|
| 280 | if [ -f N2O.txt ] ; then |
---|
| 281 | IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` |
---|
| 282 | LMDZ_sed config.def N2O_ppb ${IPCC_N2O} |
---|
| 283 | else |
---|
| 284 | LMDZ_sed_default config.def N2O_ppb |
---|
| 285 | fi |
---|
| 286 | if [ -f CFC11.txt ] ; then |
---|
| 287 | IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` |
---|
| 288 | LMDZ_sed config.def CFC11_ppt ${IPCC_CFC11} |
---|
| 289 | else |
---|
| 290 | LMDZ_sed_default config.def CFC11_ppt |
---|
| 291 | fi |
---|
| 292 | if [ -f CFC12.txt ] ; then |
---|
| 293 | IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` |
---|
| 294 | LMDZ_sed config.def CFC12_ppt ${IPCC_CFC12} |
---|
| 295 | else |
---|
| 296 | LMDZ_sed_default config.def CFC12_ppt |
---|
| 297 | fi |
---|
| 298 | |
---|
| 299 | |
---|
| 300 | ##-- Add special treatement for CARBON CYCLE |
---|
| 301 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
| 302 | ATM_Carbon_Update |
---|
| 303 | fi |
---|
| 304 | |
---|
| 305 | |
---|
| 306 | ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate |
---|
| 307 | ## COSP daily output for years 1979 and later (mandatory for historical CMIP5 run). |
---|
| 308 | if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] && [ ${year} -ge 1979 ]) ; then |
---|
| 309 | LMDZ_COSP_daily=y |
---|
| 310 | fi |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | ## output.def parameters |
---|
| 314 | # columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : |
---|
| 315 | # histmth histday histhf histfh3h histhf3hm histstn |
---|
| 316 | LMDZ_sed output.def phys_out_filekeys "${ok_mensuel} ${ok_journe} ${ok_hf} ${ok_hf3h} ${ok_hf3hm} ${ok_stn}" |
---|
| 317 | LMDZ_sed output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} |
---|
| 318 | LMDZ_sed output.def ok_cosp ${LMDZ_COSP_OK} |
---|
| 319 | LMDZ_sed output.def ok_mensuelCOSP ${LMDZ_COSP_monthly} |
---|
| 320 | LMDZ_sed output.def ok_journeCOSP ${LMDZ_COSP_daily} |
---|
| 321 | LMDZ_sed output.def ok_hfCOSP ${LMDZ_COSP_hf} |
---|
| 322 | LMDZ_sed output.def ok_histNMC "${LMDZ_NMC_monthly} ${LMDZ_NMC_daily} ${LMDZ_NMC_hf}" |
---|
| 323 | |
---|
| 324 | ## gcm.def parameters : |
---|
| 325 | # Modification only for new physics |
---|
| 326 | if [ X${LMDZ_Physics} = X"NPv3.1" ] ; then |
---|
| 327 | LMDZ_sed gcm.def iphysiq 5 |
---|
| 328 | else |
---|
| 329 | LMDZ_sed_default gcm.def iphysiq |
---|
| 330 | fi |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | ## run.def parameters |
---|
| 334 | LMDZ_sed run.def dayref ${InitDay} |
---|
| 335 | LMDZ_sed run.def nday ${PeriodLengthInDays} |
---|
| 336 | LMDZ_sed run.def raz_date ${RAZ_DATE} |
---|
| 337 | LMDZ_sed run.def periodav ${LMDZ_periodav} |
---|
| 338 | LMDZ_sed run.def adjust ${LMDZ_adjust} |
---|
| 339 | |
---|
| 340 | # Set anneeref different for gcm and ce0l |
---|
[1923] | 341 | # Variable calend is different for a run with create_etat0_limit and the gcm |
---|
[1818] | 342 | # Test if executable create_etat0_limit is present and lmdz.x is not present |
---|
| 343 | if [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then |
---|
| 344 | # for case ce0l : always take current year |
---|
| 345 | LMDZ_sed run.def anneeref ${year} |
---|
[1923] | 346 | LMDZ_sed run.def calend ${CalendarTypeForCreate} |
---|
[1818] | 347 | else |
---|
| 348 | # for case gcm : take first year of simulation |
---|
| 349 | LMDZ_sed run.def anneeref ${InitYear} |
---|
[1923] | 350 | LMDZ_sed run.def calend ${CalendarTypeForLmdz} |
---|
[1818] | 351 | fi |
---|
| 352 | |
---|
| 353 | # Activate creation of file grilles_gcm.nc only at first period |
---|
| 354 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 355 | LMDZ_sed run.def grilles_gcm_netcdf y |
---|
| 356 | else |
---|
| 357 | LMDZ_sed run.def grilles_gcm_netcdf n |
---|
| 358 | fi |
---|
| 359 | |
---|
| 360 | ## Determine from the variable ListOfComponents in config.card coupling to external models |
---|
| 361 | ## and set corresponding parameters in run.def |
---|
| 362 | echo ListOfComponents now running : ${config_ListOfComponents[*]} |
---|
| 363 | |
---|
| 364 | if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then |
---|
| 365 | echo "Activate ORCHIDEE, set VEGET=y in run.def" |
---|
| 366 | LMDZ_sed run.def VEGET y |
---|
| 367 | else |
---|
| 368 | echo "No ORCHIDEE, set VEGET=n in run.def" |
---|
| 369 | LMDZ_sed run.def VEGET n |
---|
| 370 | fi |
---|
| 371 | |
---|
| 372 | if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then |
---|
| 373 | echo "Activate coupling to ocean, set type_ocean=couple in run.def" |
---|
| 374 | LMDZ_sed run.def type_ocean couple |
---|
| 375 | else |
---|
| 376 | echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def" |
---|
| 377 | LMDZ_sed run.def type_ocean force |
---|
| 378 | fi |
---|
| 379 | |
---|
| 380 | if [ X${config_ListOfComponents_CHM} = Xinca ] ; then |
---|
| 381 | echo "Activate coupling to INCA, set type_trac=inca in run.def" |
---|
| 382 | LMDZ_sed run.def type_trac inca |
---|
| 383 | elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then |
---|
| 384 | echo "Activate coupling to REPROBUS, set type_trac=repr in run.def" |
---|
| 385 | LMDZ_sed run.def type_trac repr |
---|
| 386 | LMDZ_sed run.def config_inca none |
---|
| 387 | else |
---|
| 388 | echo "No coupling to chemistry model, set type_trac=lmdz in run.def" |
---|
| 389 | LMDZ_sed run.def type_trac lmdz |
---|
| 390 | LMDZ_sed run.def config_inca none |
---|
| 391 | fi |
---|
| 392 | |
---|
| 393 | |
---|
[2015] | 394 | # config.def : Activate direct radiative effect if ok_ade=y |
---|
| 395 | if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then |
---|
| 396 | LMDZ_sed config.def ok_ade ${lmdz_UserChoices_ok_ade} |
---|
| 397 | else |
---|
[1818] | 398 | LMDZ_sed config.def ok_ade n |
---|
[2015] | 399 | fi |
---|
| 400 | |
---|
| 401 | # config.def : Activate indirect radiative effect if ok_aie=y |
---|
| 402 | if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then |
---|
| 403 | LMDZ_sed config.def ok_aie ${lmdz_UserChoices_ok_aie} |
---|
| 404 | else |
---|
[1818] | 405 | LMDZ_sed config.def ok_aie n |
---|
[2015] | 406 | fi |
---|
[1818] | 407 | |
---|
[2015] | 408 | # config.def : Activate online aerosol coupled model if aerosol_couple=y |
---|
| 409 | if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then |
---|
| 410 | LMDZ_sed config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple} |
---|
[1818] | 411 | else |
---|
| 412 | LMDZ_sed config.def aerosol_couple n |
---|
[2015] | 413 | fi |
---|
[1818] | 414 | |
---|
[2015] | 415 | # config.def : Activate reading of ozone in climatology if read_climoz=2 |
---|
| 416 | if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then |
---|
| 417 | LMDZ_sed config.def read_climoz ${lmdz_UserChoices_read_climoz} |
---|
| 418 | else |
---|
| 419 | LMDZ_sed config.def read_climoz 0 |
---|
| 420 | fi |
---|
| 421 | |
---|
| 422 | # config.def : Choose aerosol use in radiative effect |
---|
| 423 | # type of coupled aerosol =1 (default) =2 => bc only =3 => pom only =4 => seasalt only |
---|
| 424 | # =5 => dust only =6 => all aerosol |
---|
| 425 | if [ ! X${lmdz_UserChoices_flag_aerosol} = X ]; then |
---|
| 426 | LMDZ_sed config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol} |
---|
| 427 | else |
---|
| 428 | LMDZ_sed config.def flag_aerosol 0 |
---|
| 429 | fi |
---|
| 430 | |
---|
| 431 | # config.def : Activate calcul of Cloud droplet number concentration if ok_cdnc=y |
---|
| 432 | if [ ! X${lmdz_UserChoices_ok_cdnc} = X ]; then |
---|
| 433 | LMDZ_sed config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc} |
---|
| 434 | else |
---|
| 435 | LMDZ_sed config.def ok_cdnc n |
---|
| 436 | fi |
---|
| 437 | |
---|
[1818] | 438 | # guide.def : Activate nudging if ok_guide=y set in lmdz.card |
---|
| 439 | if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then |
---|
| 440 | LMDZ_sed guide.def ok_guide ${lmdz_UserChoices_ok_guide} |
---|
| 441 | else |
---|
| 442 | LMDZ_sed guide.def ok_guide n |
---|
| 443 | fi |
---|
| 444 | |
---|
| 445 | ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 446 | ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta} |
---|
| 447 | if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then |
---|
| 448 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 449 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 450 | echo |
---|
| 451 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 452 | echo |
---|
| 453 | cat gcm.def |
---|
| 454 | ByPass_hgardfou_teta=n |
---|
| 455 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
| 456 | fi |
---|
| 457 | |
---|
| 458 | ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 459 | ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats} |
---|
| 460 | if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then |
---|
| 461 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 462 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 463 | echo |
---|
| 464 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 465 | echo |
---|
| 466 | cat gcm.def |
---|
| 467 | ByPass_hgardfou_mats=n |
---|
| 468 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
| 469 | fi |
---|
| 470 | |
---|
| 471 | if ( ${FirstInitialize} ) ; then |
---|
| 472 | if [ -f start.nc ] && [ -f startphy.nc ] ; then |
---|
| 473 | # The restart files already exist. They have been copied from a previous run or from a CREATE job |
---|
| 474 | echo "Restart files for LMDZ have been copied from a previous run" |
---|
| 475 | elif [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then |
---|
| 476 | # Do nothing because it is the program for creating restart files that is running and not LMDZ |
---|
| 477 | echo "create_etat0_limit.e will create initial start files" |
---|
| 478 | else |
---|
| 479 | # Restart files have to be created |
---|
| 480 | echo "Run create_etat0_limit.e to create restart files start.nc and startphy.nc for LMDZ" |
---|
| 481 | if [ ${DRYRUN} -le 2 ] ; then |
---|
| 482 | ##-- suppression of ozone file construction -- |
---|
| 483 | cp config.def config.def.save |
---|
| 484 | LMDZ_sed config.def read_climoz 0 |
---|
| 485 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 486 | if [ ${DRYRUN} -le 1 ] ; then |
---|
| 487 | ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e |
---|
| 488 | IGCM_sys_Put_Out start.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc |
---|
| 489 | IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc |
---|
| 490 | fi |
---|
| 491 | IGCM_sys_Mv config.def.save config.def |
---|
| 492 | else |
---|
| 493 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated" |
---|
| 494 | echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
| 495 | fi |
---|
| 496 | fi |
---|
| 497 | fi |
---|
| 498 | |
---|
| 499 | IGCM_debug_PopStack "ATM_Update" |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | #----------------------------------- |
---|
| 503 | function ATM_Finalize |
---|
| 504 | { |
---|
| 505 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 506 | |
---|
[1897] | 507 | # If the file exist, copy Bands_ file to PARAM/ in submit directory. This file will be used for the simulation. |
---|
[1892] | 508 | # Copy also the same file into ATM/Restart at ARCHIVE directory for backup. |
---|
[1897] | 509 | if [ -f Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ] ; then |
---|
| 510 | if [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] ; then |
---|
| 511 | IGCM_sys_Cp Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
| 512 | IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_R}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
| 513 | elif [ ${CumulPeriod} -eq 1 ] && [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
| 514 | # Special case : first period and no adjust => Save bands file with suffix _0 |
---|
| 515 | IGCM_sys_Cp Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0 |
---|
| 516 | IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_R}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0 |
---|
| 517 | fi |
---|
[1892] | 518 | fi |
---|
[1818] | 519 | |
---|
| 520 | # Add special treatement for CARBON CYCLE |
---|
| 521 | if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then |
---|
| 522 | ATM_Carbon_Finalize |
---|
| 523 | fi |
---|
| 524 | |
---|
| 525 | echo FINALIZE ATM ! |
---|
| 526 | |
---|
| 527 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | function ATM_Carbon_Update |
---|
| 533 | { |
---|
| 534 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
| 535 | |
---|
| 536 | IGCM_debug_PushStack "ATM_Carbon_Update" |
---|
| 537 | |
---|
| 538 | typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 |
---|
| 539 | typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 540 | typeset PathCO2log |
---|
| 541 | typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX |
---|
| 542 | |
---|
| 543 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then |
---|
| 544 | ##--Initialization of fluxes to an undefined value at the first run |
---|
| 545 | UndefinedValueCo2=-9999 |
---|
| 546 | InitPeriodCo2=0 |
---|
| 547 | InitDateBeginCo2=${UndefinedValueCo2} |
---|
| 548 | InitYearCo2=$(( ${year} - 1 )) |
---|
| 549 | InitDateEndCo2=${InitYearCo2}1231 |
---|
| 550 | fCO2_ff=${UndefinedValueCo2} |
---|
| 551 | CO2SBG=${UndefinedValueCo2} |
---|
| 552 | CO2LU=${UndefinedValueCo2} |
---|
| 553 | CO2MBG=${UndefinedValueCo2} |
---|
| 554 | CO2_ppm_prec=${UndefinedValueCo2} |
---|
| 555 | # Get the initial value of atmosp. pco2 |
---|
| 556 | CO2_ppm=${lmdz_UserChoices_co2_init} |
---|
| 557 | |
---|
| 558 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 559 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 560 | |
---|
| 561 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 562 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 563 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 564 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 565 | |
---|
| 566 | # Get the path where the log file co2.log is |
---|
| 567 | PathCO2log=${SUBMIT_DIR} |
---|
| 568 | # Get Previous line in co2.log |
---|
| 569 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 570 | |
---|
| 571 | else |
---|
| 572 | |
---|
| 573 | # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): |
---|
| 574 | # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. |
---|
| 575 | #SubmitRestartPath= |
---|
| 576 | if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then |
---|
| 577 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath |
---|
| 578 | PathCO2log=${config_ATM_SubmitRestartPath} |
---|
| 579 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) |
---|
| 580 | PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) |
---|
| 581 | |
---|
| 582 | IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log |
---|
| 583 | IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log |
---|
| 584 | |
---|
| 585 | # Save Last Line of control in new co2.log file |
---|
| 586 | InitPeriodCo2=0 |
---|
| 587 | InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) |
---|
| 588 | InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) |
---|
| 589 | fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) |
---|
| 590 | CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) |
---|
| 591 | CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) |
---|
| 592 | CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) |
---|
| 593 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) |
---|
| 594 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 595 | |
---|
| 596 | echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 597 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 598 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 599 | else |
---|
| 600 | # Get restart line in co2.log |
---|
| 601 | PathCO2log=${SUBMIT_DIR} |
---|
| 602 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 603 | # Get the value of atmosp. pco2 in co2.log |
---|
| 604 | CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 605 | fi |
---|
| 606 | |
---|
| 607 | fi |
---|
| 608 | |
---|
| 609 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then |
---|
| 610 | # Modify co2_ppm in config.def only for historical run |
---|
| 611 | # If not historical run, keep co2_ppm value set earlier by LMDZ_sed |
---|
| 612 | LMDZ_sed config.def co2_ppm ${CO2_ppm} |
---|
| 613 | fi |
---|
| 614 | IGCM_debug_PopStack "ATM_Carbon_Update" |
---|
| 615 | } |
---|
| 616 | |
---|
| 617 | |
---|
| 618 | function ATM_Carbon_Finalize |
---|
| 619 | { |
---|
| 620 | # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card |
---|
| 621 | |
---|
| 622 | IGCM_debug_PushStack "ATM_Carbon_Finalize" |
---|
| 623 | |
---|
| 624 | typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff |
---|
| 625 | |
---|
| 626 | # Fossil fuel emission |
---|
| 627 | if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then |
---|
| 628 | # For Control, no fossil fuel emission : |
---|
| 629 | fCO2_ff=0 |
---|
| 630 | echo "Fossil Fuel for control run :" ${fCO2_ff} |
---|
| 631 | else |
---|
| 632 | # For historical, get the fossile fuel file : |
---|
| 633 | fCO2_ff=$( gawk "{if (match(\$0,\"${year}\ *${month}\")) {print \$3}}" ${SUBMIT_DIR}/PARAM/CMIP5_gridcar_CO2_emissions_fossil_fuel_Andres_1751-2007_monthly_SC.txt ) |
---|
| 634 | echo "Fossil Fuel for historical run :" ${fCO2_ff} |
---|
| 635 | fi |
---|
| 636 | |
---|
| 637 | # Get the value of ocean carbon flux |
---|
| 638 | CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) |
---|
| 639 | CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) |
---|
| 640 | echo "Ocean carbon flux :" ${CO2MBG} |
---|
| 641 | |
---|
| 642 | # Get the value of land fluxes |
---|
| 643 | set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) |
---|
| 644 | CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) |
---|
| 645 | CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) |
---|
| 646 | CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) |
---|
| 647 | echo "Land carbon flux (NEP) :" ${CO2SRF} |
---|
| 648 | echo "LU flux (FLUC) :" ${CO2LU} |
---|
| 649 | echo "Total Land carbon flux (NBP) :" ${CO2SBG} |
---|
| 650 | |
---|
| 651 | # Previous CO2 |
---|
| 652 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 653 | echo "Previous CO2 :" ${CO2_ppm_prec} |
---|
| 654 | |
---|
| 655 | # Formula |
---|
| 656 | CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) |
---|
| 657 | echo "New CO2 :" ${CO2_ppm} |
---|
| 658 | |
---|
| 659 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
---|
| 660 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
---|
| 661 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
---|
| 662 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
---|
| 663 | |
---|
| 664 | IGCM_debug_PopStack "ATM_Carbon_Finalize" |
---|
| 665 | } |
---|