Changeset 1780 for CONFIG/UNIFORM/v5/IPSLCM5CHS_v5/GENERAL
- Timestamp:
- 06/15/12 18:01:45 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CONFIG/UNIFORM/v5/IPSLCM5CHS_v5/GENERAL/DRIVER/lmdz.driver
r1779 r1780 237 237 fi 238 238 239 # Add special treatement for CARBON CYCLE 239 240 ##-- Add special treatement for CARBON CYCLE 240 241 if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then 241 242 typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 243 typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 244 typeset PathCO2log 245 typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 246 247 if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then 248 ##--Initialization of fluxes to an undefined value at the first run 249 UndefinedValueCo2=-9999 250 InitPeriodCo2=0 251 InitDateBeginCo2=${UndefinedValueCo2} 252 InitYearCo2=$(( ${year} - 1 )) 253 InitDateEndCo2=${InitYearCo2}1231 254 fCO2_ff=${UndefinedValueCo2} 255 CO2SBG=${UndefinedValueCo2} 256 CO2LU=${UndefinedValueCo2} 257 CO2MBG=${UndefinedValueCo2} 258 CO2_ppm_prec=${UndefinedValueCo2} 259 # Get the initial value of atmosp. pco2 260 CO2_ppm=${lmdz_UserChoices_co2_init} 261 262 IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 263 IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 264 265 # Save CO2 values in ExeCpuLog variable contents 5 fields 266 echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ 267 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 268 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 269 270 # Get the path where the log file co2.log is 271 PathCO2log=${SUBMIT_DIR} 272 # Get Previous line in co2.log 273 PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 274 275 else 276 277 # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 278 # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 279 #SubmitRestartPath= 280 if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then 281 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 282 PathCO2log=${config_ATM_SubmitRestartPath} 283 Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 284 PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 285 286 IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 287 IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 288 289 # Save Last Line of control in new co2.log file 290 InitPeriodCo2=0 291 InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 292 InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 293 fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 294 CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 295 CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 296 CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 297 CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 298 CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 299 300 echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ 301 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 302 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 303 else 304 # Get restart line in co2.log 305 PathCO2log=${SUBMIT_DIR} 306 PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 307 # Get the value of atmosp. pco2 in co2.log 308 CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 309 fi 310 311 fi 312 313 if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 314 # Modify co2_ppm in config.def only for historical run 315 # If not historical run, keep co2_ppm value set earlier by LMDZ_sed 316 LMDZ_sed config.def co2_ppm ${CO2_ppm} 317 fi 318 fi 319 # end CARBON_CYCLE 242 ATM_Carbon_Update 243 fi 244 320 245 321 246 ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate … … 475 400 # Add special treatement for CARBON CYCLE 476 401 if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then 477 typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 478 402 ATM_Carbon_Finalize 403 fi 404 405 echo FINALIZE ATM ! 406 407 IGCM_debug_PopStack "ATM_Finalize" 408 } 409 410 411 412 function ATM_Carbon_Update 413 { 414 # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card 415 416 IGCM_debug_PushStack "ATM_Carbon_Update" 417 418 typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 419 typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 420 typeset PathCO2log 421 typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 422 423 if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then 424 ##--Initialization of fluxes to an undefined value at the first run 425 UndefinedValueCo2=-9999 426 InitPeriodCo2=0 427 InitDateBeginCo2=${UndefinedValueCo2} 428 InitYearCo2=$(( ${year} - 1 )) 429 InitDateEndCo2=${InitYearCo2}1231 430 fCO2_ff=${UndefinedValueCo2} 431 CO2SBG=${UndefinedValueCo2} 432 CO2LU=${UndefinedValueCo2} 433 CO2MBG=${UndefinedValueCo2} 434 CO2_ppm_prec=${UndefinedValueCo2} 435 # Get the initial value of atmosp. pco2 436 CO2_ppm=${lmdz_UserChoices_co2_init} 437 438 IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 439 IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 440 441 # Save CO2 values in ExeCpuLog variable contents 5 fields 442 echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ 443 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 444 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 445 446 # Get the path where the log file co2.log is 447 PathCO2log=${SUBMIT_DIR} 448 # Get Previous line in co2.log 449 PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 450 451 else 452 453 # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 454 # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 455 #SubmitRestartPath= 456 if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then 457 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 458 PathCO2log=${config_ATM_SubmitRestartPath} 459 Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 460 PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 461 462 IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 463 IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 464 465 # Save Last Line of control in new co2.log file 466 InitPeriodCo2=0 467 InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 468 InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 469 fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 470 CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 471 CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 472 CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 473 CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 474 CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 475 476 echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ 477 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 478 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 479 else 480 # Get restart line in co2.log 481 PathCO2log=${SUBMIT_DIR} 482 PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 483 # Get the value of atmosp. pco2 in co2.log 484 CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 485 fi 486 487 fi 488 489 if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 490 # Modify co2_ppm in config.def only for historical run 491 # If not historical run, keep co2_ppm value set earlier by LMDZ_sed 492 LMDZ_sed config.def co2_ppm ${CO2_ppm} 493 fi 494 IGCM_debug_PopStack "ATM_Carbon_Update" 495 } 496 497 498 function ATM_Carbon_Finalize 499 { 500 # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card 501 502 IGCM_debug_PushStack "ATM_Carbon_Finalize" 503 504 typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 505 479 506 # Fossil fuel emission 480 507 if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then 481 508 # For Control, no fossil fuel emission : 482 483 484 509 fCO2_ff=0 510 echo "Fossil Fuel for control run :" ${fCO2_ff} 511 else 485 512 # For historical, get the fossile fuel file : 486 487 488 489 513 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 ) 514 echo "Fossil Fuel for historical run :" ${fCO2_ff} 515 fi 516 490 517 # Get the value of ocean carbon flux 491 492 493 494 518 CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 519 CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 520 echo "Ocean carbon flux :" ${CO2MBG} 521 495 522 # Get the value of land fluxes 496 497 498 499 500 501 502 503 523 set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 524 CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 525 CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 526 CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 527 echo "Land carbon flux (NEP) :" ${CO2SRF} 528 echo "LU flux (FLUC) :" ${CO2LU} 529 echo "Total Land carbon flux (NBP) :" ${CO2SBG} 530 504 531 # Previous CO2 505 506 507 532 CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 533 echo "Previous CO2 :" ${CO2_ppm_prec} 534 508 535 # Formula 509 510 511 536 CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 537 echo "New CO2 :" ${CO2_ppm} 538 512 539 # Save CO2 values in ExeCpuLog variable contents 5 fields 513 514 540 echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \ 541 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 515 542 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 516 517 fi 518 519 echo FINALIZE ATM ! 520 521 IGCM_debug_PopStack "ATM_Finalize" 522 } 543 544 IGCM_debug_PopStack "ATM_Carbon_Finalize" 545 }
Note: See TracChangeset
for help on using the changeset viewer.