| 335 | === Card et Drivers === |
| 336 | |
| 337 | On modifie le driver de lmdz pour calculer la nouvelle pco2 à la fin de la simulation : |
| 338 | {{{ |
| 339 | function ATM_Finalize |
| 340 | { |
| 341 | |
| 342 | # get the fossile fuel file : |
| 343 | 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 ) |
| 344 | echo "Fossil Fuel for historical run :" ${fCO2_ff} |
| 345 | |
| 346 | # Get the value of ocean carbon flux |
| 347 | CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) |
| 348 | CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) |
| 349 | echo "Ocean carbon flux :" ${CO2MBG} |
| 350 | |
| 351 | # Get the value of land fluxes |
| 352 | set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) |
| 353 | CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) |
| 354 | CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) |
| 355 | CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) |
| 356 | echo "Land carbon flux (NEP) :" ${CO2SRF} |
| 357 | echo "LU flux (FLUC) :" ${CO2LU} |
| 358 | echo "Total Land carbon flux (NBP) :" ${CO2SBG} |
| 359 | |
| 360 | # Previous CO2 |
| 361 | CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
| 362 | echo "Previous CO2 :" ${CO2_ppm_prec} |
| 363 | |
| 364 | # Formula |
| 365 | CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) |
| 366 | echo "New CO2 :" ${CO2_ppm} |
| 367 | |
| 368 | # Save CO2 values in ExeCpuLog variable contents 5 fields |
| 369 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ |
| 370 | gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ |
| 371 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log |
| 372 | echo FINALIZE ATM ! |
| 373 | |
| 374 | IGCM_debug_PopStack "ATM_Finalize" |
| 375 | } |
| 376 | }}} |
| 377 | et aussi le driver de pisces pour mettre cette nouvelle valeur dans la namelist_pisces: |
| 378 | {{{ |
| 379 | function MBG_Update |
| 380 | { |
| 381 | |
| 382 | PathCO2log=${SUBMIT_DIR} |
| 383 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
| 384 | IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
| 385 | |
| 386 | sed -e "s%${PAT_PIS_ATCCO2}% atcco2=${IPCC_PIS_CO2}%" |
| 387 | |
| 388 | IGCM_debug_PopStack "MBG_Update" |
| 389 | } |
| 390 | }}} |