miscoutput.cpp 190 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976
  1. ///////////////////////////////////////////////////////////////////////////////////////
  2. /// \file outputmodule.cpp
  3. /// \brief Implementation of the common output module
  4. ///
  5. /// \author Joe Siltberg
  6. /// $Date: 2015-04-09 18:40:34 +0200 (Thu, 09 Apr 2015) $
  7. ///
  8. ///////////////////////////////////////////////////////////////////////////////////////
  9. #include "config.h"
  10. #include "miscoutput.h"
  11. #include "parameters.h"
  12. #include "guess.h"
  13. // ecev3 - add lpjguess_to_string to avoid problems with std library to_string not being available on NSC platforms
  14. #include <string.h>
  15. #include <sstream>
  16. using namespace std;
  17. std::string lpjguess_to_string(double d) {
  18. std::ostringstream os;
  19. os << d;
  20. return os.str();
  21. }
  22. namespace GuessOutput {
  23. // Nitrogen output is in kgN/ha instead of kgC/m2 as for carbon
  24. const double m2toha = 10000.0;
  25. REGISTER_OUTPUT_MODULE("misc", MiscOutput)
  26. MiscOutput::MiscOutput() {
  27. // Annual output variables
  28. declare_parameter("file_cmass_cropland", &file_cmass_cropland, 300, "Annual cropland cmass output file");
  29. declare_parameter("file_cmass_pasture", &file_cmass_pasture, 300, "Annual pasture cmass output file");
  30. declare_parameter("file_cmass_natural", &file_cmass_natural, 300, "Annual natural vegetation cmass output file");
  31. declare_parameter("file_cmass_forest", &file_cmass_forest, 300, "Annual managed forest cmass output file");
  32. declare_parameter("file_anpp_cropland", &file_anpp_cropland, 300, "Annual cropland NPP output file");
  33. declare_parameter("file_anpp_pasture", &file_anpp_pasture, 300, "Annual pasture NPP output file");
  34. declare_parameter("file_anpp_natural", &file_anpp_natural, 300, "Annual natural vegetation NPP output file");
  35. declare_parameter("file_anpp_forest", &file_anpp_forest, 300, "Annual managed forest NPP output file");
  36. declare_parameter("file_yield", &file_yield, 300, "Crop yield output file");
  37. declare_parameter("file_yield1", &file_yield1, 300, "Crop first yield output file");
  38. declare_parameter("file_yield2", &file_yield2, 300, "Crop second yield output file");
  39. declare_parameter("file_sdate1", &file_sdate1, 300, "Crop first sowing date output file");
  40. declare_parameter("file_sdate2", &file_sdate2, 300, "Crop second sowing date output file");
  41. declare_parameter("file_hdate1", &file_hdate1, 300, "Crop first harvest date output file");
  42. declare_parameter("file_hdate2", &file_hdate2, 300, "Crop second harvest date output file");
  43. declare_parameter("file_lgp", &file_lgp, 300, "Crop length of growing period output file");
  44. declare_parameter("file_phu", &file_phu, 300, "Crop potential heat units output file");
  45. declare_parameter("file_fphu", &file_fphu, 300, "Crop attained fraction of potential heat units output file");
  46. declare_parameter("file_fhi", &file_fhi, 300, "Crop attained fraction of harvest index output file");
  47. declare_parameter("file_irrigation", &file_irrigation, 300, "Crop irrigation output file");
  48. declare_parameter("file_seasonality", &file_seasonality, 300, "Seasonality output file");
  49. declare_parameter("file_mco2", &file_mco2, 300, "Monthly CO2 output file");
  50. declare_parameter("file_cflux_cropland", &file_cflux_cropland, 300, "C fluxes output file");
  51. declare_parameter("file_cflux_pasture", &file_cflux_pasture, 300, "C fluxes output file");
  52. declare_parameter("file_cflux_natural", &file_cflux_natural, 300, "C fluxes output file");
  53. declare_parameter("file_cflux_forest", &file_cflux_forest, 300, "C fluxes output file");
  54. declare_parameter("file_dens_natural", &file_dens_natural, 300, "Natural vegetation tree density output file");
  55. declare_parameter("file_dens_forest", &file_dens_forest, 300, "Managed forest tree density output file");
  56. declare_parameter("file_cpool_cropland", &file_cpool_cropland, 300, "Soil C output file");
  57. declare_parameter("file_cpool_pasture", &file_cpool_pasture, 300, "Soil C output file");
  58. declare_parameter("file_cpool_natural", &file_cpool_natural, 300, "Soil C output file");
  59. declare_parameter("file_cpool_forest", &file_cpool_forest, 300, "Soil C output file");
  60. declare_parameter("file_nflux_cropland", &file_nflux_cropland, 300, "N fluxes output file");
  61. declare_parameter("file_nflux_pasture", &file_nflux_pasture, 300, "N fluxes output file");
  62. declare_parameter("file_nflux_natural", &file_nflux_natural, 300, "N fluxes output file");
  63. declare_parameter("file_nflux_forest", &file_nflux_forest, 300, "N fluxes output file");
  64. declare_parameter("file_npool_cropland", &file_npool_cropland, 300, "Soil N output file");
  65. declare_parameter("file_npool_pasture", &file_npool_pasture, 300, "Soil N output file");
  66. declare_parameter("file_npool_natural", &file_npool_natural, 300, "Soil N output file");
  67. declare_parameter("file_npool_forest", &file_npool_forest, 300, "Soil N output file");
  68. //daily
  69. declare_parameter("file_daily_lai", &file_daily_lai, 300, "Daily output.");
  70. declare_parameter("file_daily_npp", &file_daily_npp, 300, "Daily output.");
  71. declare_parameter("file_daily_nmass", &file_daily_nmass, 300, "Daily output.");
  72. declare_parameter("file_daily_ndemand", &file_daily_ndemand, 300, "Daily output.");
  73. declare_parameter("file_daily_cmass", &file_daily_cmass, 300, "Daily output.");
  74. declare_parameter("file_daily_cton", &file_daily_cton, 300, "Daily output.");
  75. declare_parameter("file_daily_cmass_leaf", &file_daily_cmass_leaf, 300, "Daily output.");
  76. declare_parameter("file_daily_nmass_leaf", &file_daily_nmass_leaf, 300, "Daily output.");
  77. declare_parameter("file_daily_cmass_root", &file_daily_cmass_root, 300, "Daily output.");
  78. declare_parameter("file_daily_nmass_root", &file_daily_nmass_root, 300, "Daily output.");
  79. declare_parameter("file_daily_cmass_stem", &file_daily_cmass_stem, 300, "Daily output.");
  80. declare_parameter("file_daily_nmass_stem", &file_daily_nmass_stem, 300, "Daily output.");
  81. declare_parameter("file_daily_cmass_storage", &file_daily_cmass_storage, 300, "Daily output.");
  82. declare_parameter("file_daily_nmass_storage", &file_daily_nmass_storage, 300, "Daily output.");
  83. declare_parameter("file_daily_cmass_dead_leaf", &file_daily_cmass_dead_leaf, 300, "Daily output.");
  84. declare_parameter("file_daily_nmass_dead_leaf", &file_daily_nmass_dead_leaf, 300, "Daily output.");
  85. declare_parameter("file_daily_n_input_soil", &file_daily_n_input_soil, 300, "Daily output.");
  86. declare_parameter("file_daily_avail_nmass_soil", &file_daily_avail_nmass_soil, 300, "Daily output.");
  87. declare_parameter("file_daily_upper_wcont", &file_daily_upper_wcont, 300, "Daily output.");
  88. declare_parameter("file_daily_lower_wcont", &file_daily_lower_wcont, 300, "Daily output.");
  89. declare_parameter("file_daily_irrigation", &file_daily_irrigation, 300, "Daily output.");
  90. declare_parameter("file_daily_nminleach", &file_daily_nminleach, 300, "Daily output.");
  91. declare_parameter("file_daily_norgleach", &file_daily_norgleach, 300, "Daily output.");
  92. declare_parameter("file_daily_nuptake", &file_daily_nuptake, 300, "Daily output.");
  93. declare_parameter("file_daily_temp", &file_daily_temp, 300, "Daily output.");
  94. declare_parameter("file_daily_prec", &file_daily_prec, 300, "Daily output.");
  95. declare_parameter("file_daily_rad", &file_daily_rad, 300, "Daily output.");
  96. declare_parameter("file_daily_fphu", &file_daily_fphu, 300, "Daily DS output file"); //daglig ds
  97. if (ifnlim) {
  98. declare_parameter("file_daily_ds", &file_daily_ds, 300, "Daily DS output file"); //daglig ds
  99. declare_parameter("file_daily_stem", &file_daily_stem, 300, "Daily stem allocation output file");
  100. declare_parameter("file_daily_leaf", &file_daily_leaf, 300, "Daily leaf allocation output file");
  101. declare_parameter("file_daily_root", &file_daily_root, 300, "Daily root allocation output file");
  102. declare_parameter("file_daily_storage", &file_daily_storage, 300, "Daily storage allocation output file");
  103. }
  104. declare_parameter("file_baresoilFrac_yearly", &file_baresoilFrac_yearly, 300, "Gridcell fraction covered by bare soils [-]");
  105. declare_parameter("file_residualFrac_yearly", &file_residualFrac_yearly, 300, "Gridcell fraction covered by by non-vegetation and non-bare-soil [-]");
  106. declare_parameter("file_cLitter_yearly", &file_cLitter_yearly, 300, "Carbon in vegetation [kg C m-2]");
  107. declare_parameter("file_cLitterLut_yearly", &file_cLitterLut_yearly, 300, "Carbon in Above and Below Ground Litter Pools on Land Use Tiles [kg m-2]");
  108. declare_parameter("file_cProduct_yearly", &file_cProduct_yearly, 300, "Carbon in vegetation [kg C m-2]");
  109. declare_parameter("file_cProductLut_yearly", &file_cProductLut_yearly, 300, "Wood and agricultural product pool carbon associated with land use tiles; examples of products include paper, cardboard, timber for construction, and crop harvest for food or fuel.[kg m-2]");
  110. declare_parameter("file_cropFrac_yearly", &file_cropFrac_yearly, 300, "Gridcell fraction covered by crops [-]");
  111. declare_parameter("file_cSoil_yearly", &file_cSoil_yearly, 300, "Carbon in vegetation [kg C m-2]");
  112. declare_parameter("file_cSoilLut_yearly", &file_cSoilLut_yearly, 300, "Carbon in soil pool on land use tiles [kg m-2]");
  113. declare_parameter("file_cVeg_yearly", &file_cVeg_yearly, 300, "Carbon in vegetation [kg C m-2]");
  114. declare_parameter("file_cVegLut_yearly", &file_cVegLut_yearly, 300, "Carbon in vegetation on land use tiles [kg m-2]");
  115. declare_parameter("file_fracInLut_yearly", &file_fracInLut_yearly, 300, "Gross fraction that was transferred into this tile from other land use tiles [%]");
  116. declare_parameter("file_fracLut_yearly", &file_fracLut_yearly, 300, "Fraction of grid cell for each land use tile [%]");
  117. declare_parameter("file_fracOutLut_yearly", &file_fracOutLut_yearly, 300, "Gross fraction of land use tile that was transferred into other land use tiles [%]");
  118. declare_parameter("file_grassFrac_yearly", &file_grassFrac_yearly, 300, "Gridcell fraction covered by grass [-]");
  119. declare_parameter("file_pastureFrac_yearly", &file_pastureFrac_yearly, 300, "Gridcell fraction covered by pasture [-]");
  120. declare_parameter("file_shrubFrac_yearly", &file_shrubFrac_yearly, 300, "Gridcell fraction covered by shrubs [-]");
  121. declare_parameter("file_treeFrac_yearly", &file_treeFrac_yearly, 300, "Gridcell fraction covered by trees [-]");
  122. declare_parameter("file_vegFrac_yearly", &file_vegFrac_yearly, 300, "Gridcell fraction covered by vegetation [-]");
  123. declare_parameter("file_burntFractionAll_yearly", &file_burntFractionAll_yearly, 300, "Percentage of grid cell burned due to all fires including natural (should also include anthropogenic fires and those associated with anthropogenic Land-use change but doesn't) [-]");
  124. declare_parameter("file_burntFractionAll_monthly", &file_burntFractionAll_monthly, 300, "Percentage of grid cell burned due to all fires including natural (should also include anthropogenic fires and those associated with anthropogenic Land-use change but doesn't) [-]");
  125. declare_parameter("file_cLand_monthly", &file_cLand_monthly, 300, "Carbon on Land [kg C m-2]");
  126. declare_parameter("file_cLand1_monthly", &file_cLand1_monthly, 300, "Carbon on Land on 1st day of month [kg C m-2]");
  127. declare_parameter("file_cLandYr_yearly", &file_cLand_yearly, 300, "Carbon on Land [kg C m-2]");
  128. declare_parameter("file_cFluxYr_yearly", &file_cFlux_yearly, 300, "Yearly flux to the atmosphere [kg C m-2]");
  129. declare_parameter("file_cLitterCwd_monthly", &file_cLitterCwd_monthly, 300, "Carbon in Cwd litter [kg C m-2]");
  130. declare_parameter("file_cLitterSubSurf_monthly", &file_cLitterSubSurf_monthly, 300, "Carbon in sub surface litter [kg C m-2]");
  131. declare_parameter("file_cLitterSurf_monthly", &file_cLitterSurf_monthly, 300, "Carbon in surface litter [kg C m-2]");
  132. declare_parameter("file_cOther_monthly", &file_cOther_monthly, 300, "Carbon in other organs [kg C m-2]");
  133. declare_parameter("file_cropFracC3_monthly", &file_cropFracC3_monthly, 300, "C3 Crop Area Percentage [%]");
  134. declare_parameter("file_cropFracC4_monthly", &file_cropFracC4_monthly, 300, "C4 Crop Area Percentage [%]");
  135. declare_parameter("file_cSoil_monthly", &file_cSoil_monthly, 300, "Carbon in soil [kg C m-2]");
  136. declare_parameter("file_cStem_monthly", &file_cStem_monthly, 300, "Carbon in stem [kg C m-2]");
  137. declare_parameter("file_cTotFireLut_monthly", &file_cTotFireLut_monthly, 300, "Carbon loss from natural and managed fire on land use tile, including deforestation fires [kg m-2 s-1]");
  138. declare_parameter("file_cWood_monthly", &file_cWood_monthly, 300, "Carbon in wood [kg C m-2]");
  139. declare_parameter("file_evspsblpot_monthly", &file_evspsblpot_monthly, 300, "Potential Evapotranspiration [kg m-2 s-1]");
  140. declare_parameter("file_fAnthDisturb_monthly", &file_fAnthDisturb_monthly, 300, "CO2 Flux to Atmosphere from anthropogenic disturbance [kg C m-2 s-1]");
  141. declare_parameter("file_fBNF_monthly", &file_fBNF_monthly, 300, "Biological nitrogen fixation [kg N m-2 s-1]");
  142. declare_parameter("file_fCLandToOcean_monthly", &file_fCLandToOcean_monthly, 300, "Organic carbon leaching [kg C m-2 s-1]");
  143. declare_parameter("file_fDeforestToAtmos_monthly", &file_fDeforestToAtmos_monthly, 300, "CO2 Flux to Atmosphere from Land Use Change [kg C m-2 s-1]");
  144. declare_parameter("file_fDeforestToProduct_monthly", &file_fDeforestToProduct_monthly, 300, "Carbon Flux to Products from deforestation [kg C m-2 s-1]");
  145. declare_parameter("file_fFireAll_monthly", &file_fFireAll_monthly, 300, "CO2 Emission from all Fire [kg C m-2 s-1]");
  146. declare_parameter("file_fFireNat_monthly", &file_fFireNat_monthly, 300, "CO2 Emission from natural Fire [kg C m-2 s-1]");
  147. declare_parameter("file_fHarvestToAtmos_monthly", &file_fHarvestToAtmos_monthly, 300, "CO2 Emission from harvest [kg C m-2 s-1]");
  148. declare_parameter("file_fLitterFire_monthly", &file_fLitterFire_monthly, 300, "CO2 Emission from natural litter Fire [kg C m-2 s-1]");
  149. declare_parameter("file_fLuc_monthly", &file_fLuc_monthly, 300, "CO2 Flux to Atmosphere from land uce change [kg C m-2 s-1]");
  150. declare_parameter("file_fLulccAtmLut_monthly", &file_fLulccAtmLut_monthly, 300, "Carbon transferred directly to atmosphere due to any land-use or land-cover change activities including deforestation or agricultural fire [kg m-2 s-1]");
  151. declare_parameter("file_fLulccProductLut_monthly", &file_fLulccProductLut_monthly, 300, "Carbon harvested due to land-use or land-cover change that enters anthropogenic product pools on tile [kg m-2 s-1]");
  152. declare_parameter("file_fLulccResidueLut_monthly", &file_fLulccResidueLut_monthly, 300, "Carbon transferred to soil or litter pools due to land-use or land-cover change processes on tile [kg m-2 s-1]");
  153. declare_parameter("file_fNAnthDisturb_monthly", &file_fNAnthDisturb_monthly, 300, "Nitrogen Flux to Atmosphere from anthropogenic disturbance [kg N m-2 s-1]");
  154. declare_parameter("file_fNdep_monthly", &file_fNdep_monthly, 300, "Nitrogen deposition [kg N m-2 s-1]");
  155. declare_parameter("file_fNfert_monthly", &file_fNfert_monthly, 300, "Total nitrogen fertilisation to the ecosystem [kg N m-2 s-1]");
  156. declare_parameter("file_fNgas_monthly", &file_fNgas_monthly, 300, "Nitrogen gas flux [kg N m-2 s-1]");
  157. declare_parameter("file_fNgasFire_monthly", &file_fNgasFire_monthly, 300, "Nitrogen fire gas flux [kg N m-2 s-1]");
  158. declare_parameter("file_fNgasNonFire_monthly", &file_fNgasNonFire_monthly, 300, "Nitrogen non fire gas flux [kg N m-2 s-1]");
  159. declare_parameter("file_fNLandToOcean_monthly", &file_fNLandToOcean_monthly, 300, "Organic and mineral nitrogen leaching [kg C m-2 s-1]");
  160. declare_parameter("file_fNleach_monthly", &file_fNleach_monthly, 300, "Nitrogen leached [kg N m-2 s-1]");
  161. declare_parameter("file_fNLitterSoil_monthly", &file_fNLitterSoil_monthly, 300, "Total Nitrogen Flux from Litter to Soil [kg N m-2 s-1]");
  162. declare_parameter("file_fNloss_monthly", &file_fNloss_monthly, 300, "Total nitrogen loss from the ecosystem [kg N m-2 s-1]");
  163. declare_parameter("file_fNnetmin_monthly", &file_fNnetmin_monthly, 300, "Net Nitrogen Mineralisation [kg N m-2 s-1]");
  164. declare_parameter("file_fNProduct_monthly", &file_fNProduct_monthly, 300, "Nitrogen Flux to Products from Vegetation [kg N m-2 s-1]");
  165. declare_parameter("file_fNup_monthly", &file_fNup_monthly, 300, "Plant nitrogen uptake [kg N m-2 s-1]");
  166. declare_parameter("file_fNVegLitter_monthly", &file_fNVegLitter_monthly, 300, "Total nitrogen Flux from Vegetation to Litter [kg C m-2 s-1]");
  167. declare_parameter("file_fProductDecomp_monthly", &file_fProductDecomp_monthly, 300, "Carbon Flux to Athmosphere from Products [kg C m-2 s-1]");
  168. declare_parameter("file_fProductDecompLut_monthly", &file_fProductDecompLut_monthly, 300, "Flux from wood and agricultural product pools on land use tile into atmosphere [kg m-2 s-1]");
  169. declare_parameter("file_fracLut_monthly", &file_fracLut_monthly, 300, "Fraction of grid cell for each land use tile [%]");
  170. declare_parameter("file_fVegFire_monthly", &file_fVegFire_monthly, 300, "CO2 Emission from natural vegetation Fire [kg C m-2 s-1]");
  171. declare_parameter("file_gppGrass_monthly", &file_gppGrass_monthly, 300, "Gross Primary Production on grass tiles [kg C m-2 s-1]");
  172. declare_parameter("file_gppLut_monthly", &file_gppLut_monthly, 300, "Gross primary productivity on land use tile [kg m-2 s-1]");
  173. declare_parameter("file_gppTree_monthly", &file_gppTree_monthly, 300, "Gross Primary Production on tree tiles [kg C m-2 s-1]");
  174. declare_parameter("file_grassFracC3_monthly", &file_grassFracC3_monthly, 300, "C3 Grass Area Percentage [%]");
  175. declare_parameter("file_grassFracC4_monthly", &file_grassFracC4_monthly, 300, "C4 Grass Area Percentage [%]");
  176. declare_parameter("file_irrLut_monthly", &file_irrLut_monthly, 300, "Irrigation flux including any irrigation for crops, trees, pasture, or urban lawns [kg m-2 s-1]");
  177. declare_parameter("file_laiLut_monthly", &file_laiLut_monthly, 300, "Leaf Area Index on Land Use Tile []");
  178. declare_parameter("file_mrroLut_monthly", &file_mrroLut_monthly, 300, " Total runoff from land use tile [kg m-2 s-1]");
  179. declare_parameter("file_mrsll_monthly", &file_mrsll_monthly, 300, "Total liquid water content of soil layer [kg m-2]");
  180. declare_parameter("file_mrsol_monthly", &file_mrsol_monthly, 300, "Total water content of soil layer [kg m-2]");
  181. declare_parameter("file_mrsoLut_monthly", &file_mrsoLut_monthly, 300, "Total soil moisture of land use tile [kg m-2]");
  182. declare_parameter("file_mrsosLut_monthly", &file_mrsosLut_monthly, 300, "Moisture in Upper Portion of Soil Column of land use tile [kg m-2]");
  183. declare_parameter("file_necbLut_monthly", &file_necbLut_monthly, 300, "Net rate of C accumulation (or loss) on land use tile [kg m-2 s-1]");
  184. declare_parameter("file_nep_monthly", &file_nep_monthly, 300, "Carbon Mass Flux out of Atmosphere due to Net Biospheric Production on Land excluding fire from LU [kg C m-2 s-1]");
  185. declare_parameter("file_netAtmosLandCO2Flux_monthly", &file_netAtmosLandCO2Flux_monthly, 300, "Carbon Mass Flux out of Atmosphere due to Net Biospheric Production on Land [kg C m-2 s-1]");
  186. declare_parameter("file_nLand_monthly", &file_nLand_monthly, 300, "Nitrogen on Land [kg N m-2]");
  187. declare_parameter("file_nLeaf_monthly", &file_nLeaf_monthly, 300, "Nitrogen in leaf [kg N m-2]");
  188. declare_parameter("file_nLitter_monthly", &file_nLitter_monthly, 300, "Nitrogen in litter [kg N m-2]");
  189. declare_parameter("file_nLitterCwd_monthly", &file_nLitterCwd_monthly, 300, "Nitrogen in Cwd litter [kg N m-2]");
  190. declare_parameter("file_nLitterSubSurf_monthly", &file_nLitterSubSurf_monthly, 300, "Nitrogen in sub surface litter [kg N m-2]");
  191. declare_parameter("file_nLitterSurf_monthly", &file_nLitterSurf_monthly, 300, "Nitrogen in surface litter [kg N m-2]");
  192. declare_parameter("file_nMineral_monthly", &file_nMineral_monthly, 300, "Total mineral N in soil [kg N m-2]");
  193. declare_parameter("file_fN2O_monthly", &file_fN2O_monthly, 300, "Total land N2O flux [kg N m-2 s-1]");
  194. declare_parameter("file_fNOx_monthly", &file_fNOx_monthly, 300, "Total land NOx flux [kg N m-2 s-1]");
  195. declare_parameter("file_nMineralNH4_monthly", &file_nMineralNH4_monthly, 300, "Total mineral NH4 in soil [kg N m-2]");
  196. declare_parameter("file_nMineralNO3_monthly", &file_nMineralNO3_monthly, 300, "Total mineral NO3 in soil [kg N m-2]");
  197. declare_parameter("file_nOther_monthly", &file_nOther_monthly, 300, "Nitrogen in other organs [kg N m-2]");
  198. declare_parameter("file_nppGrass_monthly", &file_nppGrass_monthly, 300, "Net Primary Production on grass tiles [kg C m-2 s-1]");
  199. declare_parameter("file_nppLut_monthly", &file_nppLut_monthly, 300, "Net primary productivity on land use tile [kg m-2 s-1]");
  200. declare_parameter("file_nppTree_monthly", &file_nppTree_monthly, 300, "Net Primary Production on tree tiles [kg C m-2 s-1]");
  201. declare_parameter("file_nProduct_monthly", &file_nProduct_monthly, 300, "Nitrogen in products [kg N m-2]");
  202. declare_parameter("file_nRoot_monthly", &file_nRoot_monthly, 300, "Nitrogen in root [kg N m-2]");
  203. declare_parameter("file_nSoil_monthly", &file_nSoil_monthly, 300, "Nitrogen in soil [kg N m-2]");
  204. declare_parameter("file_nStem_monthly", &file_nStem_monthly, 300, "Nitrogen in stem [kg N m-2]");
  205. declare_parameter("file_nwdFracLut_monthly", &file_nwdFracLut_monthly, 300, "Fraction of land use tile that is non-woody vegetation ( e.g. herbaceous crops) [kg m-2 s-1]");
  206. declare_parameter("file_nVeg_monthly", &file_nVeg_monthly, 300, "Nitrogen in vegetation [kg N m-2]");
  207. declare_parameter("file_pastureFracC3_monthly", &file_pastureFracC3_monthly, 300, "C3 Pasture Area Percentage [%]");
  208. declare_parameter("file_pastureFracC4_monthly", &file_pastureFracC4_monthly, 300, "C4 Pasture Area Percentage [%]");
  209. declare_parameter("file_prCrop_monthly", &file_prCrop_monthly, 300, "Precipitation on crop [kg m-2 s-1]");
  210. declare_parameter("file_raGrass_monthly", &file_raGrass_monthly, 300, "Autotrophic respiration on grass tiles [kg C m-2 s-1]");
  211. declare_parameter("file_raLeaf_monthly", &file_raLeaf_monthly, 300, "Autotrophic Respiration from leaves [kg C m-2 s-1]");
  212. declare_parameter("file_raLut_monthly", &file_raLut_monthly, 300, "Plant respiration on land use tile [kg m-2 s-1]");
  213. declare_parameter("file_raOther_monthly", &file_raOther_monthly, 300, "Autotrophic Respiration from other compartments [kg C m-2 s-1]");
  214. declare_parameter("file_raRoot_monthly", &file_raRoot_monthly, 300, "Autotrophic Respiration from roots [kg C m-2 s-1]");
  215. declare_parameter("file_raStem_monthly", &file_raStem_monthly, 300, "Autotrophic Respiration from stem [kg C m-2 s-1]");
  216. declare_parameter("file_raTree_monthly", &file_raTree_monthly, 300, "Autotrophic respiration on tree tiles [kg C m-2 s-1]");
  217. declare_parameter("file_rhLitter_monthly", &file_rhLitter_monthly, 300, "Litter Respiration [kg C m-2 s-1]");
  218. declare_parameter("file_rhLut_monthly", &file_rhLut_monthly, 300, "Soil heterotrophic respiration on land use tile [kg m-2 s-1]");
  219. declare_parameter("file_rhSoil_monthly", &file_rhSoil_monthly, 300, "Soil Respiration [kg C m-2 s-1]");
  220. declare_parameter("file_treeFracBdlDcd_monthly", &file_treeFracBdlDcd_monthly, 300, "Broadleaf deciduous tree fraction [%]");
  221. declare_parameter("file_treeFracBdlEvg_monthly", &file_treeFracBdlEvg_monthly, 300, "Broadleaf evergreen tree fraction [%]");
  222. declare_parameter("file_treeFracNdlDcd_monthly", &file_treeFracNdlDcd_monthly, 300, "Needleleaf deciduous tree fraction [%]");
  223. declare_parameter("file_treeFracNdlEvg_monthly", &file_treeFracNdlEvg_monthly, 300, "Needleleaf evergreen tree fraction [%]");
  224. declare_parameter("file_vegFrac_monthly", &file_vegFrac_monthly, 300, "Gridcell fraction covered by any kind of vegetation [-]");
  225. declare_parameter("file_vegHeightTree_monthly", &file_vegHeightTree_monthly, 300, "Average tree height [m]");
  226. declare_parameter("file_baresoilFrac_monthly", &file_baresoilFrac_monthly, 300, "Gridcell fraction covered by bare soil [-]");
  227. declare_parameter("file_cCwd_monthly", &file_cCwd_monthly, 300, "Carbon in sub surface cwd [kg C m-2]");
  228. declare_parameter("file_cLeaf_monthly", &file_cLeaf_monthly, 300, "Carbon in leaf [kg C m-2]");
  229. declare_parameter("file_cLitter_monthly", &file_cLitter_monthly, 300, "Carbon in litter [kg C m-2]");
  230. declare_parameter("file_cLitterAbove_monthly", &file_cLitterAbove_monthly, 300, "Carbon in above surface litter [kg C m-2]");
  231. declare_parameter("file_cLitterBelow_monthly", &file_cLitterBelow_monthly, 300, "Carbon in below surface litter [kg C m-2]");
  232. declare_parameter("file_cProduct_monthly", &file_cProduct_monthly, 300, "Carbon in products [kg C m-2]");
  233. declare_parameter("file_cRoot_monthly", &file_cRoot_monthly, 300, "Carbon in root [kg C m-2]");
  234. declare_parameter("file_cropFrac_monthly", &file_cropFrac_monthly, 300, "Gridcell fraction covered by crop [-]");
  235. declare_parameter("file_cSoilFast_monthly", &file_cSoilFast_monthly, 300, "Carbon Mass in Fast Soil Pool [kg C m-2]");
  236. declare_parameter("file_cSoilMedium_monthly", &file_cSoilMedium_monthly, 300, "Carbon Mass in Medium Soil Pool [kg C m-2]");
  237. declare_parameter("file_cSoilSlow_monthly", &file_cSoilSlow_monthly, 300, "Carbon Mass in Slow Soil Pool [kg C m-2]");
  238. declare_parameter("file_cVeg_monthly", &file_cVeg_monthly, 300, "Carbon in vegetation [kg C m-2]");
  239. declare_parameter("file_evspsblsoi_monthly", &file_evspsblsoi_monthly, 300, "Water Evaporation from Soil [kg m-2 s-1]");
  240. declare_parameter("file_evspsblveg_monthly", &file_evspsblveg_monthly, 300, "Total evaporation from Canopy [kg m-2 s-1]");
  241. declare_parameter("file_evspsbl_monthly", &file_evspsbl_monthly, 300, "Total Evapotranspiration [kg m-2 s-1] [kg m-2 s-1]");
  242. declare_parameter("file_fco2antt_monthly", &file_fCO2antt_monthly, 300, "Carbon Mass Flux into Atmosphere Due to All Anthropogenic Emissions of CO2 [kg C m-2 s-1]");
  243. declare_parameter("file_fco2nat_monthly", &file_fCO2nat_monthly, 300, "Surface Carbon Mass Flux into the Atmosphere Due to Natural Sources [kg C m-2 s-1]");
  244. declare_parameter("file_fFire_monthly", &file_fFire_monthly, 300, "CO2 Emission from natural Fire [kg C m-2 s-1]");
  245. declare_parameter("file_fGrazing_monthly", &file_fGrazing_monthly, 300, "Carbon Mass Flux into Atmosphere due to Grazing on Land [kg C m-2 s-1]");
  246. declare_parameter("file_fHarvest_monthly", &file_fHarvest_monthly, 300, "CO2 Emission from harvest and products [kg C m-2 s-1]");
  247. declare_parameter("file_fLitterSoil_monthly", &file_fLitterSoil_monthly, 300, "Total Carbon Flux from Litter to Soil [kg C m-2 s-1]");
  248. declare_parameter("file_fVegLitter_monthly", &file_fVegLitter_monthly, 300, "Total Carbon Flux from Vegetation to Litter [kg C m-2 s-1]");
  249. declare_parameter("file_fVegOther_monthly", &file_fVegOther_monthly, 300, "Total Carbon Flux from Vegetation to Other [kg C m-2 s-1]");
  250. declare_parameter("file_gpp_monthly", &file_gpp_monthly, 300, "Gross Primary Production [kg C m-2 s-1]");
  251. declare_parameter("file_grassFrac_monthly", &file_grassFrac_monthly, 300, "Gridcell fraction covered by grass [-]");
  252. declare_parameter("file_lai_monthly", &file_lai_monthly, 300, "Leaf Area Index [m2 m-2]");
  253. declare_parameter("file_landCoverFrac_monthly", &file_landCoverFrac_monthly, 300, "Fractional Land Cover of PFT");
  254. declare_parameter("file_mrro_monthly", &file_mrro_monthly, 300, "Total Runoff [kg m-2 s-1]");
  255. declare_parameter("file_mrros_monthly", &file_mrros_monthly, 300, "Total Surface Runoff [kg m-2 s-1]");
  256. declare_parameter("file_mrso_monthly", &file_mrso_monthly, 300, "Soil Water Content [kg m-2]");
  257. declare_parameter("file_mrsos_monthly", &file_mrsos_monthly, 300, "Moisture in Upper Portion of Soil Column [kg m-2]");
  258. declare_parameter("file_nbp_monthly", &file_nbp_monthly, 300, "Carbon Mass Flux out of Atmosphere due to Net Biospheric Production on Land [kg C m-2 s-1]");
  259. declare_parameter("file_npp_monthly", &file_npp_monthly, 300, "Net Primary Production [kg C m-2 s-1]");
  260. declare_parameter("file_pastureFrac_monthly", &file_pastureFrac_monthly, 300, "Gridcell fraction covered by pasture [-]");
  261. declare_parameter("file_prveg_monthly", &file_prveg_monthly, 300, "Total intercepted water on Canopy (interception) [kg m-2 s-1]");
  262. declare_parameter("file_ra_monthly", &file_ra_monthly, 300, "Autotrophic (Plant) Respiration [kg C m-2 s-1]");
  263. declare_parameter("file_residualFrac_monthly", &file_residualFrac_monthly, 300, "Gridcell fraction covered by non-vegetation and non-bare-soil [-]");
  264. declare_parameter("file_rGrowth_monthly", &file_rGrowth_monthly, 300, "Autotrophic Respiration associated to growth [kg C m-2 s-1]");
  265. declare_parameter("file_rh_monthly", &file_rh_monthly, 300, "Heterotrophic Respiration [kg C m-2 s-1]");
  266. declare_parameter("file_rMaint_monthly", &file_rMaint_monthly, 300, "Autotrophic Respiration [kg C m-2 s-1]");
  267. declare_parameter("file_shrubFrac_monthly", &file_shrubFrac_monthly, 300, "Gridcell fraction covered by shrub [-]");
  268. declare_parameter("file_tran_monthly", &file_tran_monthly, 300, "Transpiration [kg m-2 s-1]");
  269. declare_parameter("file_treeFrac_monthly", &file_treeFrac_monthly, 300, "Gridcell fraction covered by trees [-]");
  270. declare_parameter("file_tsl_monthly", &file_tsl_monthly, 300, "Top soil layer temperature [C]");
  271. declare_parameter("file_ec_daily", &file_ec_daily, 300, "Total interception evaporation from Canopy [kg m-2 s-1]");
  272. declare_parameter("file_et_daily", &file_et_daily, 300, "Total Evapotranspiration [kg m-2 s-1]");
  273. declare_parameter("file_evspsblpot_daily", &file_evspsblpot_daily, 300, "Potential Evapotranspiration [kg m-2 s-1]");
  274. declare_parameter("file_lai_daily", &file_lai_daily, 300, "Leaf Area Index [m2 m-2]");
  275. declare_parameter("file_mrsll_daily", &file_mrsll_daily, 300, "Total liquid water content of soil layer [kg m-2]");
  276. declare_parameter("file_mrso_daily", &file_mrso_daily, 300, "Total water content of soil [Kg m-2]");
  277. declare_parameter("file_mrsol_daily", &file_mrsol_daily, 300, "Total water content of soil layer [Kg m-2]");
  278. declare_parameter("file_mrsos_daily", &file_mrsos_daily, 300, "Total water content of upper soil portion [Kg m-2]");
  279. declare_parameter("file_mrro_daily", &file_mrro_daily, 300, "Total runoff [Kg m-2]");
  280. declare_parameter("file_prCrop_daily", &file_prCrop_daily, 300, "Precipitation on crop [kg m-2 s-1]");
  281. declare_parameter("file_tran_daily", &file_tran_daily, 300, "Transpiration [kg m-2 s-1]");
  282. declare_parameter("file_tsl_daily", &file_tsl_daily, 300, "Temperature of Soil [K]");
  283. declare_parameter("file_prveg_daily", &file_prveg_daily, 300, "Total intercepted water on Canopy [kg m-2 s-1]");
  284. }
  285. MiscOutput::~MiscOutput() {
  286. }
  287. /// Define all output tables and their formats
  288. void MiscOutput::init() {
  289. define_output_tables();
  290. define_cmip6_and_crescendo_output_tables();
  291. }
  292. /// Specify all columns in all output tables
  293. /** This function specifies all columns in all output tables, their names,
  294. * column widths and precision.
  295. *
  296. * For each table a TableDescriptor object is created which is then sent to
  297. * the output channel to create the table.
  298. */
  299. void MiscOutput::define_output_tables() {
  300. // create a vector with the pft names
  301. std::vector<std::string> pfts;
  302. // create a vector with the crop pft names
  303. std::vector<std::string> crop_pfts;
  304. pftlist.firstobj();
  305. while (pftlist.isobj) {
  306. Pft& pft = pftlist.getobj();
  307. pfts.push_back((char*)pft.name);
  308. if (pft.landcover == CROPLAND)
  309. crop_pfts.push_back((char*)pft.name);
  310. pftlist.nextobj();
  311. }
  312. // create a vector with the landcover column titles
  313. std::vector<std::string> landcovers;
  314. const char* landcover_string[] = { "Urban_sum", "Crop_sum", "Pasture_sum",
  315. "Forest_sum", "Natural_sum", "Peatland_sum", "Barren_sum" };
  316. for (int i = 0; i<NLANDCOVERTYPES; i++) {
  317. if (run[i]) {
  318. landcovers.push_back(landcover_string[i]);
  319. }
  320. }
  321. // Create the month columns
  322. ColumnDescriptors month_columns;
  323. ColumnDescriptors month_columns_wide;
  324. xtring months[] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
  325. for (int i = 0; i < 12; i++) {
  326. month_columns += ColumnDescriptor(months[i], 8, 3);
  327. month_columns_wide += ColumnDescriptor(months[i], 10, 3);
  328. }
  329. // Create the columns for each output file
  330. // CMASS
  331. ColumnDescriptors cmass_columns;
  332. cmass_columns += ColumnDescriptors(pfts, 8, 3);
  333. cmass_columns += ColumnDescriptor("Total", 8, 3);
  334. ColumnDescriptors cmass_columns_lc = cmass_columns;
  335. cmass_columns += ColumnDescriptors(landcovers, 13, 3);
  336. // ANPP
  337. ColumnDescriptors anpp_columns = cmass_columns;
  338. ColumnDescriptors anpp_columns_lc = cmass_columns_lc;
  339. // DENS
  340. ColumnDescriptors dens_columns;
  341. dens_columns += ColumnDescriptors(pfts, 8, 4);
  342. dens_columns += ColumnDescriptor("Total", 8, 4);
  343. ColumnDescriptors dens_columns_lc = dens_columns;
  344. // CFLUX
  345. ColumnDescriptors cflux_columns;
  346. cflux_columns += ColumnDescriptor("Veg", 8, 3);
  347. cflux_columns += ColumnDescriptor("Repr", 8, 3);
  348. cflux_columns += ColumnDescriptor("Soil", 8, 3);
  349. cflux_columns += ColumnDescriptor("Fire", 8, 3);
  350. cflux_columns += ColumnDescriptor("Est", 8, 3);
  351. cflux_columns += ColumnDescriptor("Seed", 8, 3);
  352. cflux_columns += ColumnDescriptor("Harvest", 9, 3);
  353. cflux_columns += ColumnDescriptor("LU_ch", 9, 3);
  354. cflux_columns += ColumnDescriptor("Slow_h", 9, 3);
  355. cflux_columns += ColumnDescriptor("NEE", 10, 5);
  356. // CPOOL
  357. ColumnDescriptors cpool_columns;
  358. cpool_columns += ColumnDescriptor("VegC", 8, 3);
  359. if (!ifcentury) {
  360. cpool_columns += ColumnDescriptor("LittC", 8, 3);
  361. cpool_columns += ColumnDescriptor("SoilfC", 8, 3);
  362. cpool_columns += ColumnDescriptor("SoilsC", 8, 3);
  363. }
  364. else {
  365. cpool_columns += ColumnDescriptor("LitterC", 8, 3);
  366. cpool_columns += ColumnDescriptor("SoilC", 8, 3);
  367. }
  368. if (run_landcover && ifslowharvestpool) {
  369. cpool_columns += ColumnDescriptor("HarvSlowC", 10, 3);
  370. }
  371. cpool_columns += ColumnDescriptor("Total", 10, 3);
  372. //CROP YIELD
  373. ColumnDescriptors crop_columns;
  374. crop_columns += ColumnDescriptors(crop_pfts, 8, 3);
  375. //CROP SDATE & HDATE
  376. ColumnDescriptors date_columns;
  377. date_columns += ColumnDescriptors(crop_pfts, 8, 0);
  378. //IRRIGATION
  379. ColumnDescriptors irrigation_columns;
  380. irrigation_columns += ColumnDescriptor("Total", 10, 3);
  381. //SEASONALITY
  382. ColumnDescriptors seasonality_columns;
  383. seasonality_columns += ColumnDescriptor("Seasonal", 10, 0);
  384. seasonality_columns += ColumnDescriptor("V_temp", 10, 3);
  385. seasonality_columns += ColumnDescriptor("V_prec", 10, 3);
  386. seasonality_columns += ColumnDescriptor("temp_min", 10, 1);
  387. seasonality_columns += ColumnDescriptor("temp_mean", 10, 1);
  388. seasonality_columns += ColumnDescriptor("temp_seas", 10, 0);
  389. seasonality_columns += ColumnDescriptor("prec_min", 10, 2);
  390. seasonality_columns += ColumnDescriptor("prec", 10, 1);
  391. seasonality_columns += ColumnDescriptor("prec_range", 12, 0);
  392. // NPOOL
  393. ColumnDescriptors npool_columns;
  394. npool_columns += ColumnDescriptor("VegN", 9, 4);
  395. npool_columns += ColumnDescriptor("LitterN", 9, 4);
  396. npool_columns += ColumnDescriptor("SoilN", 9, 4);
  397. if (run_landcover && ifslowharvestpool) {
  398. npool_columns += ColumnDescriptor("HarvSlowN", 10, 4);
  399. }
  400. npool_columns += ColumnDescriptor("Total", 10, 4);
  401. // NFLUX
  402. ColumnDescriptors nflux_columns;
  403. nflux_columns += ColumnDescriptor("dep", 8, 2);
  404. nflux_columns += ColumnDescriptor("fix", 8, 2);
  405. nflux_columns += ColumnDescriptor("fert", 8, 2);
  406. nflux_columns += ColumnDescriptor("flux", 8, 2);
  407. nflux_columns += ColumnDescriptor("leach", 8, 2);
  408. if (run_landcover) {
  409. nflux_columns += ColumnDescriptor("seed", 8, 2);
  410. nflux_columns += ColumnDescriptor("harvest", 8, 2);
  411. nflux_columns += ColumnDescriptor("LU_ch", 8, 3);
  412. nflux_columns += ColumnDescriptor("Slow_h", 8, 3);
  413. }
  414. nflux_columns += ColumnDescriptor("NEE", 8, 2);
  415. ColumnDescriptors daily_columns;
  416. daily_columns += ColumnDescriptors(crop_pfts, 13, 3);
  417. ColumnDescriptors daily_columns_single;
  418. daily_columns_single += ColumnDescriptor("Total", 9, 3);
  419. // *** ANNUAL OUTPUT VARIABLES ***
  420. create_output_table(out_cmass_cropland, file_cmass_cropland, cmass_columns_lc);
  421. create_output_table(out_cmass_pasture, file_cmass_pasture, cmass_columns_lc);
  422. create_output_table(out_cmass_natural, file_cmass_natural, cmass_columns_lc);
  423. create_output_table(out_cmass_forest, file_cmass_forest, cmass_columns_lc);
  424. create_output_table(out_anpp_cropland, file_anpp_cropland, anpp_columns_lc);
  425. create_output_table(out_anpp_pasture, file_anpp_pasture, anpp_columns_lc);
  426. create_output_table(out_anpp_natural, file_anpp_natural, anpp_columns_lc);
  427. create_output_table(out_anpp_forest, file_anpp_forest, anpp_columns_lc);
  428. create_output_table(out_dens_natural, file_dens_natural, dens_columns_lc);
  429. create_output_table(out_dens_forest, file_dens_forest, dens_columns_lc);
  430. create_output_table(out_cflux_cropland, file_cflux_cropland, cflux_columns);
  431. create_output_table(out_cflux_pasture, file_cflux_pasture, cflux_columns);
  432. create_output_table(out_cflux_natural, file_cflux_natural, cflux_columns);
  433. create_output_table(out_cflux_forest, file_cflux_forest, cflux_columns);
  434. create_output_table(out_cpool_cropland, file_cpool_cropland, cpool_columns);
  435. create_output_table(out_cpool_pasture, file_cpool_pasture, cpool_columns);
  436. create_output_table(out_cpool_natural, file_cpool_natural, cpool_columns);
  437. create_output_table(out_cpool_forest, file_cpool_forest, cpool_columns);
  438. if (run_landcover && run[CROPLAND]) {
  439. create_output_table(out_yield, file_yield, crop_columns);
  440. create_output_table(out_yield1, file_yield1, crop_columns);
  441. create_output_table(out_yield2, file_yield2, crop_columns);
  442. create_output_table(out_sdate1, file_sdate1, date_columns);
  443. create_output_table(out_sdate2, file_sdate2, date_columns);
  444. create_output_table(out_hdate1, file_hdate1, date_columns);
  445. create_output_table(out_hdate2, file_hdate2, date_columns);
  446. create_output_table(out_lgp, file_lgp, date_columns);
  447. create_output_table(out_phu, file_phu, date_columns);
  448. create_output_table(out_fphu, file_fphu, crop_columns);
  449. create_output_table(out_fhi, file_fhi, crop_columns);
  450. create_output_table(out_seasonality, file_seasonality, seasonality_columns);
  451. }
  452. create_output_table(out_mco2, file_mco2, month_columns);
  453. if (run_landcover)
  454. create_output_table(out_irrigation, file_irrigation, irrigation_columns);
  455. create_output_table(out_npool_cropland, file_npool_cropland, npool_columns);
  456. create_output_table(out_npool_pasture, file_npool_pasture, npool_columns);
  457. create_output_table(out_npool_natural, file_npool_natural, npool_columns);
  458. create_output_table(out_npool_forest, file_npool_forest, npool_columns);
  459. create_output_table(out_nflux_cropland, file_nflux_cropland, nflux_columns);
  460. create_output_table(out_nflux_pasture, file_nflux_pasture, nflux_columns);
  461. create_output_table(out_nflux_natural, file_nflux_natural, nflux_columns);
  462. create_output_table(out_nflux_forest, file_nflux_forest, nflux_columns);
  463. // *** DAILY OUTPUT VARIABLES ***
  464. create_output_table(out_daily_lai, file_daily_lai, daily_columns);
  465. create_output_table(out_daily_npp, file_daily_npp, daily_columns);
  466. create_output_table(out_daily_ndemand, file_daily_ndemand, daily_columns);
  467. create_output_table(out_daily_nmass, file_daily_nmass, daily_columns);
  468. create_output_table(out_daily_cmass, file_daily_cmass, daily_columns);
  469. create_output_table(out_daily_nmass_leaf, file_daily_nmass_leaf, daily_columns);
  470. create_output_table(out_daily_cmass_leaf, file_daily_cmass_leaf, daily_columns);
  471. create_output_table(out_daily_nmass_root, file_daily_nmass_root, daily_columns);
  472. create_output_table(out_daily_cmass_root, file_daily_cmass_root, daily_columns);
  473. create_output_table(out_daily_nmass_stem, file_daily_nmass_stem, daily_columns);
  474. create_output_table(out_daily_cmass_stem, file_daily_cmass_stem, daily_columns);
  475. create_output_table(out_daily_nmass_storage, file_daily_nmass_storage, daily_columns);
  476. create_output_table(out_daily_cmass_storage, file_daily_cmass_storage, daily_columns);
  477. create_output_table(out_daily_nmass_dead_leaf, file_daily_nmass_dead_leaf, daily_columns);
  478. create_output_table(out_daily_cmass_dead_leaf, file_daily_cmass_dead_leaf, daily_columns);
  479. create_output_table(out_daily_n_input_soil, file_daily_n_input_soil, daily_columns);
  480. create_output_table(out_daily_avail_nmass_soil, file_daily_avail_nmass_soil, daily_columns);
  481. create_output_table(out_daily_upper_wcont, file_daily_upper_wcont, daily_columns);
  482. create_output_table(out_daily_lower_wcont, file_daily_lower_wcont, daily_columns);
  483. create_output_table(out_daily_irrigation, file_daily_irrigation, daily_columns);
  484. create_output_table(out_daily_temp, file_daily_temp, daily_columns);
  485. create_output_table(out_daily_prec, file_daily_prec, daily_columns);
  486. create_output_table(out_daily_rad, file_daily_rad, daily_columns);
  487. create_output_table(out_daily_cton, file_daily_cton, daily_columns);
  488. create_output_table(out_daily_nminleach, file_daily_nminleach, daily_columns);
  489. create_output_table(out_daily_norgleach, file_daily_norgleach, daily_columns);
  490. create_output_table(out_daily_nuptake, file_daily_nuptake, daily_columns);
  491. if (ifnlim) {
  492. create_output_table(out_daily_ds, file_daily_ds, daily_columns);
  493. create_output_table(out_daily_fphu, file_daily_fphu, daily_columns);
  494. create_output_table(out_daily_stem, file_daily_stem, daily_columns);
  495. create_output_table(out_daily_leaf, file_daily_leaf, daily_columns);
  496. create_output_table(out_daily_root, file_daily_root, daily_columns);
  497. create_output_table(out_daily_storage, file_daily_storage, daily_columns);
  498. }
  499. ColumnDescriptors mpft_columns;
  500. mpft_columns += ColumnDescriptors(pfts, 9, 4);
  501. create_output_table(out_mlambda, "mlambda.out", mpft_columns);
  502. }
  503. /// Specify all columns in all CMIP6 and CRESCENDO output tables
  504. /** This function specifies all columns in all output tables, their names,
  505. * column widths and precision for the CMIP6 and CRESCENDO projects.
  506. *
  507. * For each table a TableDescriptor object is created which is then sent to
  508. * the output channel to create the table.
  509. */
  510. void MiscOutput::define_cmip6_and_crescendo_output_tables() {
  511. if (!printcrescendo && !printcmip6 && !printcrescendodaily && !printcmip6daily && !printcrescendofacedaily)
  512. return;
  513. if (printcrescendo) {
  514. ColumnDescriptors single_column_8_2, single_column_9_3, single_column_11_5;
  515. single_column_8_2 += ColumnDescriptor("Total", 8, 2);
  516. single_column_9_3 += ColumnDescriptor("Total", 9, 3);
  517. single_column_11_5 += ColumnDescriptor("Total", 11, 5);
  518. ColumnDescriptors month_columns_7_2, month_columns_9_4, month_columns_11_6, month_columns_12_7, month_columns_15_10, month_columns_17_12;
  519. xtring months[] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
  520. for (int i = 0; i < 12; i++) {
  521. month_columns_7_2 += ColumnDescriptor(months[i], 7, 2);
  522. month_columns_9_4 += ColumnDescriptor(months[i], 9, 4);
  523. month_columns_11_6 += ColumnDescriptor(months[i], 11, 6);
  524. month_columns_12_7 += ColumnDescriptor(months[i], 12, 7);
  525. month_columns_15_10 += ColumnDescriptor(months[i], 15, 10);
  526. month_columns_17_12 += ColumnDescriptor(months[i], 17, 12);
  527. }
  528. // create a vector with soil layer names
  529. std::vector<std::string> soillayers;
  530. double soildepth[NSOILLAYER] = { SOILDEPTH_UPPER * 0.001, (SOILDEPTH_UPPER + SOILDEPTH_LOWER) * 0.001 };
  531. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  532. char columnname[100] = { '\0' };
  533. // ecev3 - avoid problems with std library to_string not being available on NSC platforms
  534. std::string numStr = lpjguess_to_string(soildepth[lyr]);
  535. strcat(columnname, numStr.c_str());
  536. soillayers.push_back(columnname);
  537. }
  538. ColumnDescriptors soillayer_columns_8_2;
  539. soillayer_columns_8_2 += ColumnDescriptors(soillayers, 8, 2);
  540. // create a vector with the pft names
  541. std::vector<std::string> pfts;
  542. // create a vector with the pft names and barren
  543. std::vector<std::string> pftsbarren;
  544. // create a vector with the tree pft names
  545. std::vector<std::string> tree_pfts;
  546. pftlist.firstobj();
  547. while (pftlist.isobj) {
  548. Pft& pft = pftlist.getobj();
  549. pfts.push_back((char*)pft.name);
  550. pftsbarren.push_back((char*)pft.name);
  551. if (pft.lifeform == TREE)
  552. tree_pfts.push_back((char*)pft.name);
  553. pftlist.nextobj();
  554. }
  555. pftsbarren.push_back("Barren");
  556. ColumnDescriptors pft_columns_8_2, mpft_columns_8_3, mtree_pft_columns_9_2, mtree_pft_columns_10_5, mlcf_pft_columns_9_4;
  557. mpft_columns_8_3 += ColumnDescriptors(pfts, 8, 3);
  558. mtree_pft_columns_9_2 += ColumnDescriptors(tree_pfts, 9, 2);
  559. mtree_pft_columns_10_5 += ColumnDescriptors(tree_pfts, 10, 5);
  560. mlcf_pft_columns_9_4 += ColumnDescriptors(pftsbarren, 9, 4);
  561. pft_columns_8_2 += ColumnDescriptors(pfts, 8, 2);
  562. pft_columns_8_2 += ColumnDescriptor("Total", 8, 2);
  563. // Physical variables
  564. // Near Surface Air Temperature [K]
  565. create_output_table(cresc_tas, "CRESCENDO/Crescendo_tas.out", month_columns_7_2);
  566. // Precipitation [kg m-2 s-1]
  567. create_output_table(cresc_pr, "CRESCENDO/Crescendo_pr.out", month_columns_12_7);
  568. // Surface Downwelling Shortwave Radiation [W m-2]
  569. create_output_table(cresc_rsds, "CRESCENDO/Crescendo_rsds.out", month_columns_7_2);
  570. // Total Soil Moisture Content [kg m-2]
  571. create_output_table(cresc_mrso, "CRESCENDO/Crescendo_mrso.out", month_columns_7_2);
  572. // Total Runoff [kg m-2 s-1]
  573. create_output_table(cresc_mrro, "CRESCENDO/Crescendo_mrro.out", month_columns_12_7);
  574. // Total Evapo-Transpiration [kg m-2 s-1]
  575. create_output_table(cresc_evapotrans, "CRESCENDO/Crescendo_evapotrans.out", month_columns_12_7);
  576. // Total Evaporation from Canopy (interception) [kg m-2 s-1]
  577. create_output_table(cresc_evspsblveg, "CRESCENDO/Crescendo_evspsblveg.out", month_columns_12_7);
  578. // Water Evaporation from Soil [kg m-2 s-1]
  579. create_output_table(cresc_evspsblsoi, "CRESCENDO/Crescendo_evspsblsoi.out", month_columns_12_7);
  580. // Transpiration [kg m-2 s-1]
  581. create_output_table(cresc_tran, "CRESCENDO/Crescendo_tran.out", month_columns_12_7);
  582. // Depth of snow layer [m]
  583. create_output_table(cresc_snd, "CRESCENDO/Crescendo_snd.out", month_columns_7_2);
  584. // Carbon in vegetation [kg C m-2]
  585. create_output_table(cresc_cVeg, "CRESCENDO/Crescendo_cVeg.out", single_column_9_3);
  586. // Nitrogen in vegetation [kg N m-2]
  587. create_output_table(cresc_nVeg, "CRESCENDO/Crescendo_nVeg.out", single_column_11_5);
  588. // Carbon in litter [kg C m-2]
  589. create_output_table(cresc_cLitter, "CRESCENDO/Crescendo_cLitter.out", single_column_9_3);
  590. // Nitrogen in litter [kg N m-2]
  591. create_output_table(cresc_nLitter, "CRESCENDO/Crescendo_nLitter.out", single_column_11_5);
  592. // Carbon in soil [kg C m-2]
  593. create_output_table(cresc_cSoil, "CRESCENDO/Crescendo_cSoil.out", single_column_9_3);
  594. // Nitrogen in soil [kg N m-2]
  595. create_output_table(cresc_nSoil, "CRESCENDO/Crescendo_nSoil.out", single_column_11_5);
  596. // Carbon in products [kg C m-2]
  597. create_output_table(cresc_cProduct, "CRESCENDO/Crescendo_cProduct.out", single_column_9_3);
  598. // Nitrogen in products [kg N m-2]
  599. create_output_table(cresc_nProduct, "CRESCENDO/Crescendo_nProduct.out", single_column_11_5);
  600. // Gross Primary Production [kg C m-2 s-1]
  601. create_output_table(cresc_gpp, "CRESCENDO/Crescendo_gpp.out", month_columns_15_10);
  602. // Net Primary Production [kg C m-2 s-1]
  603. create_output_table(cresc_npp, "CRESCENDO/Crescendo_npp.out", month_columns_15_10);
  604. // Autotrophic (Plant) Respiration [kg C m-2 s-1]
  605. create_output_table(cresc_ra, "CRESCENDO/Crescendo_ra.out", month_columns_15_10);
  606. // Heterotrophic Respiration [kg C m-2 s-1]
  607. create_output_table(cresc_rh, "CRESCENDO/Crescendo_rh.out", month_columns_15_10);
  608. // CO2 Emission from Fire [kg C m-2 s-1]
  609. create_output_table(cresc_fFire, "CRESCENDO/Crescendo_fFire.out", month_columns_15_10);
  610. // CO2 Flux to Atmosphere from Land Use Change [kg C m-2 s-1]
  611. create_output_table(cresc_fLuc, "CRESCENDO/Crescendo_fLuc.out", month_columns_15_10);
  612. // Net Biospheric Production [kg C m-2 s-1]
  613. create_output_table(cresc_nbp, "CRESCENDO/Crescendo_nbp.out", month_columns_17_12);
  614. // Reproduction and Establishmentflux [kg C m-2 s-1]
  615. create_output_table(cresc_fReprEst, "CRESCENDO/Crescendo_fReprEst.out", month_columns_15_10);
  616. // Seed flux [kg C m-2 s-1]
  617. create_output_table(cresc_fSeed, "CRESCENDO/Crescendo_fSeed.out", month_columns_15_10);
  618. // Harvest flux [kg C m-2 s-1]
  619. create_output_table(cresc_fHarv, "CRESCENDO/Crescendo_fHarv.out", month_columns_15_10);
  620. // Harvested crop flux [kg C m-2 s-1]
  621. create_output_table(cresc_harvcrop, "CRESCENDO/Crescendo_fHarvest.out", month_columns_15_10);
  622. // Harvested grazing flux [kg C m-2 s-1]
  623. create_output_table(cresc_harvgraz, "CRESCENDO/Crescendo_fGrazing.out", month_columns_15_10);
  624. // Production flux [kg C m-2 s-1]
  625. create_output_table(cresc_prod, "CRESCENDO/Crescendo_fProd.out", month_columns_15_10);
  626. // Total Carbon Flux from Vegetation to Litter [kg C m-2 s-1]
  627. create_output_table(cresc_fVegLitter, "CRESCENDO/Crescendo_fVegLitter.out", month_columns_15_10);
  628. // Total nitrogen Flux from Vegetation to Litter [kg N m-2 s-1]
  629. create_output_table(cresc_fNVegLitter, "CRESCENDO/Crescendo_fNVegLitter.out", month_columns_17_12);
  630. // Total Carbon Flux from Litter to Soil [kg C m-2 s-1]
  631. create_output_table(cresc_fLitterSoil, "CRESCENDO/Crescendo_fLitterSoil.out", month_columns_15_10);
  632. // Total Carbon Flux from Litter to Soil [kg N m-2 s-1]
  633. create_output_table(cresc_fNLitterSoil, "CRESCENDO/Crescendo_fNLitterSoil.out", month_columns_17_12);
  634. // Nitrogen deposition [kg N m-2 s-1]
  635. create_output_table(cresc_fNdep, "CRESCENDO/Crescendo_fNdep.out", month_columns_17_12);
  636. // Biological nitrogen fixation [kg N m-2 s-1]
  637. create_output_table(cresc_fBNF, "CRESCENDO/Crescendo_fBNF.out", month_columns_17_12);
  638. // Plant nitrogen uptake [kg N m-2 s-1]
  639. create_output_table(cresc_fNup, "CRESCENDO/Crescendo_fNup.out", month_columns_17_12);
  640. // Net nitrogen mineralisation [kg N m-2 s-1]
  641. create_output_table(cresc_fNnetmin, "CRESCENDO/Crescendo_fNnetmin.out", month_columns_17_12);
  642. // Nitrogen leached [kg N m-2 s-1]
  643. create_output_table(cresc_fNleach, "CRESCENDO/Crescendo_fNleach.out", month_columns_17_12);
  644. // Carbon leached [kg C m-2 s-1]
  645. create_output_table(cresc_fCleach, "CRESCENDO/Crescendo_fCleach.out", month_columns_17_12);
  646. // Nitrogen gas flux [kg N m-2 s-1]
  647. create_output_table(cresc_fNgas, "CRESCENDO/Crescendo_fNgas.out", month_columns_17_12);
  648. // Nitrogen fire gas flux [kg N m-2 s-1]
  649. create_output_table(cresc_fNgasFire, "CRESCENDO/Crescendo_fNgasFire.out", month_columns_17_12);
  650. // N2O flux [kg N m-2 s-1]
  651. create_output_table(cresc_fN2O, "CRESCENDO/Crescendo_fN2O.out", month_columns_17_12);
  652. // NOx flux [kg N m-2 s-1]
  653. create_output_table(cresc_fNOx, "CRESCENDO/Crescendo_fNOx.out", month_columns_17_12);
  654. // Total nitrogen loss from the ecosystem [kg N m-2 s-1]
  655. create_output_table(cresc_fNloss, "CRESCENDO/Crescendo_fNloss.out", month_columns_17_12);
  656. // Carbon in Leaves [kg C m-2]
  657. create_output_table(cresc_cLeaf, "CRESCENDO/Crescendo_cLeaf.out", single_column_9_3);
  658. // Carbon in Roots [kg C m-2]
  659. create_output_table(cresc_cRoot, "CRESCENDO/Crescendo_cRoot.out", single_column_9_3);
  660. // Carbon in wood [kg C m-2]
  661. create_output_table(cresc_cWood, "CRESCENDO/Crescendo_cWood.out", single_column_9_3);
  662. // Carbon in coarse woody debris [kg C m-2]
  663. create_output_table(cresc_cCwd, "CRESCENDO/Crescendo_cCwd.out", single_column_9_3);
  664. // Nitrogen in leaves [kg N m-2]
  665. create_output_table(cresc_nLeaf, "CRESCENDO/Crescendo_nLeaf.out", single_column_11_5);
  666. // Nitrogen in roots [kg N m-2]
  667. create_output_table(cresc_nRoot, "CRESCENDO/Crescendo_nRoot.out", single_column_11_5);
  668. // Nitrogen in wood [kg N m-2]
  669. create_output_table(cresc_nWood, "CRESCENDO/Crescendo_nWood.out", single_column_11_5);
  670. // Nitrogen in coarse woody debis [kg N m-2]
  671. create_output_table(cresc_nCwd, "CRESCENDO/Crescendo_nCwd.out", single_column_11_5);
  672. // Burnt area [%]
  673. create_output_table(cresc_burntArea, "CRESCENDO/Crescendo_burntArea.out", single_column_8_2);
  674. // Top soil layer temperature [C]
  675. create_output_table(cresc_tsl, "CRESCENDO/Crescendo_tsl.out", month_columns_7_2);
  676. // Monthly soil layer specific outputs
  677. // Moisture of Soil [kg m-2]
  678. create_output_table(cresc_msl, "CRESCENDO/Crescendo_msl.out", soillayer_columns_8_2);
  679. // Monthly PFT specific outputs
  680. // LAI [m2 m-2]
  681. create_output_table(cresc_lai, "CRESCENDO/Crescendo_lai.out", mpft_columns_8_3);
  682. // Fractional Land Cover of PFT
  683. create_output_table(cresc_lcf, "CRESCENDO/Crescendo_landCoverFrac.out", mlcf_pft_columns_9_4);
  684. // Fraction of Absorbed Photosynthetically Active Radiation
  685. create_output_table(cresc_fapar, "CRESCENDO/Crescendo_fapar.out", mpft_columns_8_3);
  686. // Vegetation Height [m]
  687. create_output_table(cresc_vH, "CRESCENDO/Crescendo_vegHeight.out", mtree_pft_columns_9_2);
  688. // Tree Population Density [m-2]
  689. create_output_table(cresc_tD, "CRESCENDO/Crescendo_treeDens.out", mtree_pft_columns_10_5);
  690. // Vegetation C:N ratio
  691. create_output_table(cresc_cton_veg, "CRESCENDO/Crescendo_ctonVeg.out", pft_columns_8_2);
  692. }
  693. if (printcrescendodaily) {
  694. ColumnDescriptors single_column;
  695. single_column += ColumnDescriptor("Total", 8, 3);
  696. // Gridcell fraction covered by grass [-]
  697. create_output_table(cresc_dlai, "CRESCENDO/Crescendo_dlai.out", single_column);
  698. }
  699. #ifdef CRESCENDO_FACE
  700. if (printcrescendofacedaily) {
  701. ColumnDescriptors single_column_11_3, single_column_12_6;
  702. single_column_11_3 += ColumnDescriptor("Total", 11, 3);
  703. single_column_12_6 += ColumnDescriptor("Total", 12, 6);
  704. // CO2 [Mean ppm]
  705. if (face_co2.invalid()) {
  706. create_output_table(face_co2, "CRESCENDO/FACE/FACE_co2.out", single_column_11_3);
  707. }
  708. // Precipitation [mm d-1]
  709. if (face_ppt.invalid()) {
  710. create_output_table(face_ppt, "CRESCENDO/FACE/FACE_ppt.out", single_column_11_3);
  711. }
  712. // PAR [mol m-2]
  713. if (face_par.invalid()) {
  714. create_output_table(face_par, "CRESCENDO/FACE/FACE_par.out", single_column_11_3);
  715. }
  716. // Air temp canopy [Mean oC]
  717. if (face_at.invalid()) {
  718. create_output_table(face_at, "CRESCENDO/FACE/FACE_at.out", single_column_11_3);
  719. }
  720. // Soil temp 10 cm [Mean oC]
  721. if (face_st.invalid()) {
  722. create_output_table(face_st, "CRESCENDO/FACE/FACE_st.out", single_column_11_3);
  723. }
  724. // Surface soil water [Mean %]
  725. if (face_sw.invalid()) {
  726. create_output_table(face_sw, "CRESCENDO/FACE/FACE_sw.out", single_column_11_3);
  727. }
  728. // Nitrogen deposition [gN m-2 d-1]
  729. if (face_ndep.invalid()) {
  730. create_output_table(face_ndep, "CRESCENDO/FACE/FACE_ndep.out", single_column_12_6);
  731. }
  732. // Evapotranspiration [kgH2O m-2 d-1]
  733. if (face_et.invalid()) {
  734. create_output_table(face_et, "CRESCENDO/FACE/FACE_et.out", single_column_11_3);
  735. }
  736. // Transpiration [kgH2O m-2 d-1]
  737. if (face_t.invalid()) {
  738. create_output_table(face_t, "CRESCENDO/FACE/FACE_t.out", single_column_11_3);
  739. }
  740. // Soil Evaporation [kgH2O m-2 d-1]
  741. if (face_es.invalid()) {
  742. create_output_table(face_es, "CRESCENDO/FACE/FACE_es.out", single_column_11_3);
  743. }
  744. // Canopy evaporation [kgH2O m-2 d-1]
  745. if (face_ec.invalid()) {
  746. create_output_table(face_ec, "CRESCENDO/FACE/FACE_ec.out", single_column_12_6);
  747. }
  748. // Runoff [kgH2O m-2 d-1]
  749. if (face_ro.invalid()) {
  750. create_output_table(face_ro, "CRESCENDO/FACE/FACE_ro.out", single_column_11_3);
  751. }
  752. // Drainage [kgH2O m-2 d-1]
  753. if (face_drain.invalid()) {
  754. create_output_table(face_drain, "CRESCENDO/FACE/FACE_drain.out", single_column_11_3);
  755. }
  756. // Net Eco Prod [gC m-2 d-1]
  757. if (face_nep.invalid()) {
  758. create_output_table(face_nep, "CRESCENDO/FACE/FACE_nep.out", single_column_12_6);
  759. }
  760. // Gross Prim Prod [gC m-2 d-1]
  761. if (face_gpp.invalid()) {
  762. create_output_table(face_gpp, "CRESCENDO/FACE/FACE_gpp.out", single_column_12_6);
  763. }
  764. // Net Prim Prod [gC m-2 d-1]
  765. if (face_npp.invalid()) {
  766. create_output_table(face_npp, "CRESCENDO/FACE/FACE_npp.out", single_column_12_6);
  767. }
  768. // Resp ecosystem [gC m-2 d-1]
  769. if (face_reco.invalid()) {
  770. create_output_table(face_reco, "CRESCENDO/FACE/FACE_reco.out", single_column_12_6);
  771. }
  772. // Resp autotrophic [gC m-2 d-1]
  773. if (face_rauto.invalid()) {
  774. create_output_table(face_rauto, "CRESCENDO/FACE/FACE_rauto.out", single_column_12_6);
  775. }
  776. // Resp leaves (maint) [gC m-2 d-1]
  777. if (face_rleaf.invalid()) {
  778. create_output_table(face_rleaf, "CRESCENDO/FACE/FACE_rleaf.out", single_column_12_6);
  779. }
  780. // Resp Wood (maint) [gC m-2 d-1]
  781. if (face_rwood.invalid()) {
  782. create_output_table(face_rwood, "CRESCENDO/FACE/FACE_rwood.out", single_column_12_6);
  783. }
  784. // Resp Fine Root (maint) [gC m-2 d-1]
  785. if (face_rroot.invalid()) {
  786. create_output_table(face_rroot, "CRESCENDO/FACE/FACE_rroot.out", single_column_12_6);
  787. }
  788. // Resp growth [gC m-2 d-1]
  789. if (face_rgrow.invalid()) {
  790. create_output_table(face_rgrow, "CRESCENDO/FACE/FACE_rgrow.out", single_column_12_6);
  791. }
  792. // Resp heterotrophic [gC m-2 d-1]
  793. if (face_rhet.invalid()) {
  794. create_output_table(face_rhet, "CRESCENDO/FACE/FACE_rhet.out", single_column_12_6);
  795. }
  796. // Resp from soil [gC m-2 d-1]
  797. if (face_rsoil.invalid()) {
  798. create_output_table(face_rsoil, "CRESCENDO/FACE/FACE_rsoil.out", single_column_12_6);
  799. }
  800. // Resp from other sources [gC m-2 d-1]
  801. if (face_rother.invalid()) {
  802. create_output_table(face_rother, "CRESCENDO/FACE/FACE_rother.out", single_column_12_6);
  803. }
  804. // Carbon Leaf Mass [gC m-2]
  805. if (face_cl.invalid()) {
  806. create_output_table(face_cl, "CRESCENDO/FACE/FACE_cl.out", single_column_11_3);
  807. }
  808. // Carbon Wood mass [gC m-2]
  809. if (face_cw.invalid()) {
  810. create_output_table(face_cw, "CRESCENDO/FACE/FACE_cw.out", single_column_11_3);
  811. }
  812. // Carbon Fine Root Mass [gC m-2]
  813. if (face_cfr.invalid()) {
  814. create_output_table(face_cfr, "CRESCENDO/FACE/FACE_cfr.out", single_column_11_3);
  815. }
  816. // Carbon Storage as TNC [gC m-2]
  817. if (face_tnc.invalid()) {
  818. create_output_table(face_tnc, "CRESCENDO/FACE/FACE_tnc.out", single_column_11_3);
  819. }
  820. // Carbon Fine Litter Total [gC m-2]
  821. if (face_cflit.invalid()) {
  822. create_output_table(face_cflit, "CRESCENDO/FACE/FACE_cflit.out", single_column_11_3);
  823. }
  824. // Carbon Fine Litter above [gC m-2]
  825. if (face_cflita.invalid()) {
  826. create_output_table(face_cflita, "CRESCENDO/FACE/FACE_cflita.out", single_column_11_3);
  827. }
  828. // Carbon Fine Litter below [gC m-2]
  829. if (face_cflitb.invalid()) {
  830. create_output_table(face_cflitb, "CRESCENDO/FACE/FACE_cflitb.out", single_column_11_3);
  831. }
  832. // Carbon Coarse Litter [gC m-2]
  833. if (face_cclitb.invalid()) {
  834. create_output_table(face_cclitb, "CRESCENDO/FACE/FACE_cclitb.out", single_column_11_3);
  835. }
  836. // Carbon Soil [gC m-2]
  837. if (face_csoil.invalid()) {
  838. create_output_table(face_csoil, "CRESCENDO/FACE/FACE_csoil.out", single_column_11_3);
  839. }
  840. // Carbon Leaf growth [gC m-2 d-1]
  841. if (face_gl.invalid()) {
  842. create_output_table(face_gl, "CRESCENDO/FACE/FACE_gl.out", single_column_11_3);
  843. }
  844. // Carbon Wood growth [gC m-2 d-1]
  845. if (face_gw.invalid()) {
  846. create_output_table(face_gw, "CRESCENDO/FACE/FACE_gw.out", single_column_11_3);
  847. }
  848. // Carbon Fine Root growth [gC m-2 d-1]
  849. if (face_gr.invalid()) {
  850. create_output_table(face_gr, "CRESCENDO/FACE/FACE_gr.out", single_column_11_3);
  851. }
  852. // Carbon Leaf Litterfall [gC m-2 d-1]
  853. if (face_cllfall.invalid()) {
  854. create_output_table(face_cllfall, "CRESCENDO/FACE/FACE_cllfall.out", single_column_11_3);
  855. }
  856. // Carbon Root litter inputs [gC m-2 d-1]
  857. if (face_crlin.invalid()) {
  858. create_output_table(face_crlin, "CRESCENDO/FACE/FACE_crlin.out", single_column_11_3);
  859. }
  860. // Carbon Wood/branch inputs [gC m-2 d-1]
  861. if (face_cwin.invalid()) {
  862. create_output_table(face_cwin, "CRESCENDO/FACE/FACE_cwin.out", single_column_11_3);
  863. }
  864. // LAI projected [m2 m-2]
  865. if (face_lai.invalid()) {
  866. create_output_table(face_lai, "CRESCENDO/FACE/FACE_lai.out", single_column_11_3);
  867. }
  868. // Leaf gC/leaf area [gC m-2]
  869. if (face_lma.invalid()) {
  870. create_output_table(face_lma, "CRESCENDO/FACE/FACE_lma.out", single_column_11_3);
  871. }
  872. // Nitrogen Conc Leaves [gN gd. m.1]
  873. if (face_ncon.invalid()) {
  874. create_output_table(face_ncon, "CRESCENDO/FACE/FACE_ncon.out", single_column_11_3);
  875. }
  876. // Nitrogen Mass Leaves [gN m-2]
  877. if (face_ncan.invalid()) {
  878. create_output_table(face_ncan, "CRESCENDO/FACE/FACE_ncan.out", single_column_12_6);
  879. }
  880. // Nitrogen Mass Wood [gN m-2]
  881. if (face_nwood.invalid()) {
  882. create_output_table(face_nwood, "CRESCENDO/FACE/FACE_nwood.out", single_column_12_6);
  883. }
  884. // Nitrogen Mass Fine Roots [gN m-2]
  885. if (face_nfr.invalid()) {
  886. create_output_table(face_nfr, "CRESCENDO/FACE/FACE_nfr.out", single_column_12_6);
  887. }
  888. // Nitrogen Storage [gN m-2]
  889. if (face_nstor.invalid()) {
  890. create_output_table(face_nstor, "CRESCENDO/FACE/FACE_nstor.out", single_column_12_6);
  891. }
  892. // Nitrogen Litter aboveground [gN m-2]
  893. if (face_nlit.invalid()) {
  894. create_output_table(face_nlit, "CRESCENDO/FACE/FACE_nlit.out", single_column_12_6);
  895. }
  896. // Nitrogen Litter belowground [gN m-2]
  897. if (face_nrlit.invalid()) {
  898. create_output_table(face_nrlit, "CRESCENDO/FACE/FACE_nrlit.out", single_column_12_6);
  899. }
  900. // Nitrogen Dead wood [gN m-2]
  901. if (face_ndw.invalid()) {
  902. create_output_table(face_ndw, "CRESCENDO/FACE/FACE_ndw.out", single_column_12_6);
  903. }
  904. // Nitrogen Soil Total [gN m-2]
  905. if (face_nsoil.invalid()) {
  906. create_output_table(face_nsoil, "CRESCENDO/FACE/FACE_nsoil.out", single_column_11_3);
  907. }
  908. // Nitrogen in Mineral form [gN m-2]
  909. if (face_npoolm.invalid()) {
  910. create_output_table(face_npoolm, "CRESCENDO/FACE/FACE_npoolm.out", single_column_11_3);
  911. }
  912. // Nitrogen in Organic form [gN m-2]
  913. if (face_npoolo.invalid()) {
  914. create_output_table(face_npoolo, "CRESCENDO/FACE/FACE_npoolo.out", single_column_11_3);
  915. }
  916. // Nitrogen fixation [gN m-2 d-1]
  917. if (face_nfix.invalid()) {
  918. create_output_table(face_nfix, "CRESCENDO/FACE/FACE_nfix.out", single_column_12_6);
  919. }
  920. // Nitrogen Leaf Litterfall [gN m-2 d-1]
  921. if (face_nlitin.invalid()) {
  922. create_output_table(face_nlitin, "CRESCENDO/FACE/FACE_nlitin.out", single_column_12_6);
  923. }
  924. // Nitrogen Wood/brch litterfall [gN m-2 d-1]
  925. if (face_nwlin.invalid()) {
  926. create_output_table(face_nwlin, "CRESCENDO/FACE/FACE_nwlin.out", single_column_12_6);
  927. }
  928. // Nitrogen Root litter input [gN m-2 d-1]
  929. if (face_nrlin.invalid()) {
  930. create_output_table(face_nrlin, "CRESCENDO/FACE/FACE_nrlin.out", single_column_12_6);
  931. }
  932. // Nitrogen Biomass Uptake [gN m-2 d-1]
  933. if (face_nup.invalid()) {
  934. create_output_table(face_nup, "CRESCENDO/FACE/FACE_nup.out", single_column_12_6);
  935. }
  936. // Nitrogen Gross Mineralization [gN m-2 d-1]
  937. if (face_ngmin.invalid()) {
  938. create_output_table(face_ngmin, "CRESCENDO/FACE/FACE_ngmin.out", single_column_12_6);
  939. }
  940. // Nitrogen Net mineralization [gN m-2 d-1]
  941. if (face_nmin.invalid()) {
  942. create_output_table(face_nmin, "CRESCENDO/FACE/FACE_nmin.out", single_column_12_6);
  943. }
  944. // Nitrogen Loss To Atmosphere [gN m-2 d-1]
  945. if (face_nvol.invalid()) {
  946. create_output_table(face_nvol, "CRESCENDO/FACE/FACE_nvol.out", single_column_12_6);
  947. }
  948. // Nitrogen Leaching [gN m-2 d-1]
  949. if (face_nleach.invalid()) {
  950. create_output_table(face_nleach, "CRESCENDO/FACE/FACE_nleach.out", single_column_12_6);
  951. }
  952. // Nitrogen Leaf growth [gN m-2 d-1]
  953. if (face_ngl.invalid()) {
  954. create_output_table(face_ngl, "CRESCENDO/FACE/FACE_ngl.out", single_column_12_6);
  955. }
  956. // Nitrogen Wood growth [gN m-2 d-1]
  957. if (face_ngw.invalid()) {
  958. create_output_table(face_ngw, "CRESCENDO/FACE/FACE_ngw.out", single_column_12_6);
  959. }
  960. // Nitrogen Fine Root growth [gN m-2 d-1]
  961. if (face_ngr.invalid()) {
  962. create_output_table(face_ngr, "CRESCENDO/FACE/FACE_ngr.out", single_column_12_6);
  963. }
  964. }
  965. #endif
  966. if (printcmip6) {
  967. ColumnDescriptors single_column_6_1, single_column_8_5, single_column_9_4, single_column_11_6;
  968. single_column_6_1 += ColumnDescriptor("Total", 6, 1);
  969. single_column_8_5 += ColumnDescriptor("Total", 8, 5);
  970. single_column_9_4 += ColumnDescriptor("Total", 9, 4);
  971. single_column_11_6 += ColumnDescriptor("Total", 11, 6);
  972. ColumnDescriptors month_columns_5_1, month_columns_9_4, month_columns_8_5, month_columns_9_6, month_columns_11_6, month_columns_15_10, month_columns_17_12, month_columns_19_14;
  973. xtring months[] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
  974. for (int i = 0; i < 12; i++) {
  975. month_columns_5_1 += ColumnDescriptor(months[i], 5, 1);
  976. month_columns_9_4 += ColumnDescriptor(months[i], 9, 4);
  977. month_columns_8_5 += ColumnDescriptor(months[i], 8, 5);
  978. month_columns_9_6 += ColumnDescriptor(months[i], 9, 6);
  979. month_columns_11_6 += ColumnDescriptor(months[i], 11, 6);
  980. month_columns_15_10 += ColumnDescriptor(months[i], 15, 10);
  981. month_columns_17_12 += ColumnDescriptor(months[i], 17, 12);
  982. month_columns_19_14 += ColumnDescriptor(months[i], 19, 14);
  983. }
  984. ColumnDescriptors single_column;
  985. single_column += ColumnDescriptor("Total", 12, 7);
  986. // create a vector with the pft names and barren
  987. std::vector<std::string> pftsbarren;
  988. pftlist.firstobj();
  989. while (pftlist.isobj) {
  990. Pft& pft = pftlist.getobj();
  991. pftsbarren.push_back((char*)pft.name);
  992. pftlist.nextobj();
  993. }
  994. pftsbarren.push_back("Bare_soil");
  995. ColumnDescriptors mpft_columns;
  996. mpft_columns += ColumnDescriptors(pftsbarren, 12, 7);
  997. create_output_table(cmip6_vegHeightTree, file_vegHeightTree_monthly, month_columns_9_4);
  998. create_output_table(cmip6_treeFrac, file_treeFrac_monthly, month_columns_8_5);
  999. create_output_table(cmip6_grassFrac, file_grassFrac_monthly, month_columns_8_5);
  1000. create_output_table(cmip6_shrubFrac, file_shrubFrac_monthly, month_columns_5_1);
  1001. create_output_table(cmip6_cropFrac, file_cropFrac_monthly, month_columns_8_5);
  1002. create_output_table(cmip6_pastureFrac, file_pastureFrac_monthly, month_columns_8_5);
  1003. create_output_table(cmip6_vegFrac, file_vegFrac_monthly, month_columns_8_5);
  1004. create_output_table(cmip6_acropFrac, file_cropFrac_yearly, single_column_8_5);
  1005. create_output_table(cmip6_apastureFrac, file_pastureFrac_yearly, single_column_8_5);
  1006. create_output_table(cmip6_agrassFrac, file_grassFrac_yearly, single_column_8_5);
  1007. create_output_table(cmip6_ashrubFrac, file_shrubFrac_yearly, single_column_6_1);
  1008. create_output_table(cmip6_atreeFrac, file_treeFrac_yearly, single_column_8_5);
  1009. create_output_table(cmip6_avegFrac, file_vegFrac_yearly, single_column_8_5);
  1010. create_output_table(cmip6_aburntFractionAll_yearly, file_burntFractionAll_yearly, single_column_8_5);
  1011. create_output_table(cmip6_aburntFractionAll_monthly, file_burntFractionAll_monthly, month_columns_8_5);
  1012. create_output_table(cmip6_abaresoilFrac, file_baresoilFrac_yearly, single_column_8_5);
  1013. create_output_table(cmip6_aresidualFrac, file_residualFrac_yearly, single_column_8_5);
  1014. create_output_table(cmip6_baresoilFrac, file_baresoilFrac_monthly, month_columns_8_5);
  1015. create_output_table(cmip6_residualFrac, file_residualFrac_monthly, month_columns_5_1);
  1016. create_output_table(cmip6_cropFracC3, file_cropFracC3_monthly, month_columns_8_5);
  1017. create_output_table(cmip6_cropFracC4, file_cropFracC4_monthly, month_columns_8_5);
  1018. create_output_table(cmip6_grassFracC3, file_grassFracC3_monthly, month_columns_8_5);
  1019. create_output_table(cmip6_grassFracC4, file_grassFracC4_monthly, month_columns_8_5);
  1020. create_output_table(cmip6_pastureFracC3, file_pastureFracC3_monthly, month_columns_8_5);
  1021. create_output_table(cmip6_pastureFracC4, file_pastureFracC4_monthly, month_columns_8_5);
  1022. create_output_table(cmip6_landCoverFrac, file_landCoverFrac_monthly, mpft_columns);
  1023. create_output_table(cmip6_acLitter, file_cLitter_yearly, single_column_9_4);
  1024. create_output_table(cmip6_acProduct, file_cProduct_yearly, single_column_11_6);
  1025. create_output_table(cmip6_acSoil, file_cSoil_yearly, single_column_9_4);
  1026. create_output_table(cmip6_acVeg, file_cVeg_yearly, single_column_9_4);
  1027. create_output_table(cmip6_cVeg, file_cVeg_monthly, month_columns_9_4);
  1028. create_output_table(cmip6_cLeaf, file_cLeaf_monthly, month_columns_9_4);
  1029. create_output_table(cmip6_cRoot, file_cRoot_monthly, month_columns_9_4);
  1030. create_output_table(cmip6_cStem, file_cStem_monthly, month_columns_9_4);
  1031. create_output_table(cmip6_cWood, file_cWood_monthly, month_columns_9_4);
  1032. create_output_table(cmip6_cOther, file_cOther_monthly, month_columns_9_4);
  1033. create_output_table(cmip6_cLitter, file_cLitter_monthly, month_columns_9_4);
  1034. create_output_table(cmip6_cCwd, file_cCwd_monthly, month_columns_5_1);
  1035. create_output_table(cmip6_cLitterCwd, file_cLitterCwd_monthly, month_columns_9_4);
  1036. create_output_table(cmip6_cLitterSurf, file_cLitterSurf_monthly, month_columns_9_4);
  1037. create_output_table(cmip6_cLitterSubSurf, file_cLitterSubSurf_monthly, month_columns_9_4);
  1038. create_output_table(cmip6_cLitterAbove, file_cLitterAbove_monthly, month_columns_9_4);
  1039. create_output_table(cmip6_cLitterBelow, file_cLitterBelow_monthly, month_columns_9_4);
  1040. create_output_table(cmip6_cSoil, file_cSoil_monthly, month_columns_9_4);
  1041. create_output_table(cmip6_cSoilFast, file_cSoilFast_monthly, month_columns_9_4);
  1042. create_output_table(cmip6_cSoilMedium, file_cSoilMedium_monthly, month_columns_9_4);
  1043. create_output_table(cmip6_cSoilSlow, file_cSoilSlow_monthly, month_columns_9_4);
  1044. create_output_table(cmip6_cProduct, file_cProduct_monthly, month_columns_9_6);
  1045. create_output_table(cmip6_cLand, file_cLand_monthly, month_columns_9_4);
  1046. create_output_table(cmip6_cLand1, file_cLand1_monthly, month_columns_9_4);
  1047. create_output_table(cmip6_cyLand, file_cLand_yearly, single_column);
  1048. create_output_table(cmip6_cyFlux, file_cFlux_yearly, single_column);
  1049. create_output_table(cmip6_nVeg, file_nVeg_monthly, month_columns_11_6);
  1050. create_output_table(cmip6_nLeaf, file_nLeaf_monthly, month_columns_11_6);
  1051. create_output_table(cmip6_nRoot, file_nRoot_monthly, month_columns_11_6);
  1052. create_output_table(cmip6_nStem, file_nStem_monthly, month_columns_11_6);
  1053. create_output_table(cmip6_nOther, file_nOther_monthly, month_columns_11_6);
  1054. create_output_table(cmip6_nLitter, file_nLitter_monthly, month_columns_11_6);
  1055. create_output_table(cmip6_nLitterCwd, file_nLitterCwd_monthly, month_columns_11_6);
  1056. create_output_table(cmip6_nLitterSurf, file_nLitterSurf_monthly, month_columns_11_6);
  1057. create_output_table(cmip6_nLitterSubSurf, file_nLitterSubSurf_monthly, month_columns_11_6);
  1058. create_output_table(cmip6_nSoil, file_nSoil_monthly, month_columns_11_6);
  1059. create_output_table(cmip6_nProduct, file_nProduct_monthly, month_columns_15_10);
  1060. create_output_table(cmip6_nLand, file_nLand_monthly, month_columns_11_6);
  1061. create_output_table(cmip6_nMinNH4, file_nMineralNH4_monthly, month_columns_17_12);
  1062. create_output_table(cmip6_nMinNO3, file_nMineralNO3_monthly, month_columns_5_1);
  1063. create_output_table(cmip6_nMineral, file_nMineral_monthly, month_columns_17_12);
  1064. create_output_table(cmip6_fN2O, file_fN2O_monthly, month_columns_17_12);
  1065. create_output_table(cmip6_fNOx, file_fNOx_monthly, month_columns_17_12);
  1066. create_output_table(cmip6_nbp, file_nbp_monthly, month_columns_19_14);
  1067. create_output_table(cmip6_netAtmosLandCO2Flux, file_netAtmosLandCO2Flux_monthly, month_columns_19_14);
  1068. create_output_table(cmip6_nep, file_nep_monthly, month_columns_19_14);
  1069. create_output_table(cmip6_gpp, file_gpp_monthly, month_columns_19_14);
  1070. create_output_table(cmip6_gppGrass, file_gppGrass_monthly, month_columns_17_12);
  1071. create_output_table(cmip6_gppTree, file_gppTree_monthly, month_columns_17_12);
  1072. create_output_table(cmip6_npp, file_npp_monthly, month_columns_19_14);
  1073. create_output_table(cmip6_nppGrass, file_nppGrass_monthly, month_columns_17_12);
  1074. create_output_table(cmip6_nppTree, file_nppTree_monthly, month_columns_17_12);
  1075. create_output_table(cmip6_ra, file_ra_monthly, month_columns_17_12);
  1076. create_output_table(cmip6_raLeaf, file_raLeaf_monthly, month_columns_17_12);
  1077. create_output_table(cmip6_raRoot, file_raRoot_monthly, month_columns_17_12);
  1078. create_output_table(cmip6_raStem, file_raStem_monthly, month_columns_17_12);
  1079. create_output_table(cmip6_raOther, file_raOther_monthly, month_columns_17_12);
  1080. create_output_table(cmip6_rGrowth, file_rGrowth_monthly, month_columns_17_12);
  1081. create_output_table(cmip6_rMaint, file_rMaint_monthly, month_columns_17_12);
  1082. create_output_table(cmip6_raGrass, file_raGrass_monthly, month_columns_17_12);
  1083. create_output_table(cmip6_raTree, file_raTree_monthly, month_columns_17_12);
  1084. create_output_table(cmip6_rh, file_rh_monthly, month_columns_17_12);
  1085. create_output_table(cmip6_rhSoil, file_rhSoil_monthly, month_columns_17_12);
  1086. create_output_table(cmip6_rhLitter, file_rhLitter_monthly, month_columns_17_12);
  1087. create_output_table(cmip6_fCLandToOcean, file_fCLandToOcean_monthly, month_columns_19_14);
  1088. create_output_table(cmip6_fNLandToOcean, file_fNLandToOcean_monthly, month_columns_19_14);
  1089. create_output_table(cmip6_fVegLitter, file_fVegLitter_monthly, month_columns_15_10);
  1090. create_output_table(cmip6_fVegOther, file_fVegOther_monthly, month_columns_15_10);
  1091. create_output_table(cmip6_fNVegLitter, file_fNVegLitter_monthly, month_columns_19_14);
  1092. create_output_table(cmip6_fLitterSoil, file_fLitterSoil_monthly, month_columns_17_12);
  1093. create_output_table(cmip6_fNLitterSoil, file_fNLitterSoil_monthly, month_columns_19_14);
  1094. create_output_table(cmip6_fFireNat, file_fFireNat_monthly, month_columns_17_12);
  1095. create_output_table(cmip6_fFire, file_fFire_monthly, month_columns_17_12);
  1096. create_output_table(cmip6_fVegFire, file_fVegFire_monthly, month_columns_17_12);
  1097. create_output_table(cmip6_fLitterFire, file_fLitterFire_monthly, month_columns_17_12);
  1098. create_output_table(cmip6_fFireAll, file_fFireAll_monthly, month_columns_17_12);
  1099. create_output_table(cmip6_fluc, file_fLuc_monthly, month_columns_19_14);
  1100. create_output_table(cmip6_fAnthDisturb, file_fAnthDisturb_monthly, month_columns_19_14);
  1101. create_output_table(cmip6_fNAnthDisturb, file_fNAnthDisturb_monthly, month_columns_19_14);
  1102. create_output_table(cmip6_fHarvest, file_fHarvest_monthly, month_columns_17_12);
  1103. create_output_table(cmip6_fHarvestToAtmos, file_fHarvestToAtmos_monthly, month_columns_17_12);
  1104. create_output_table(cmip6_fDeforestToAtmos, file_fDeforestToAtmos_monthly, month_columns_19_14);
  1105. create_output_table(cmip6_fDeforestToProduct, file_fDeforestToProduct_monthly, month_columns_15_10);
  1106. create_output_table(cmip6_fProductDecomp, file_fProductDecomp_monthly, month_columns_15_10);
  1107. create_output_table(cmip6_fGrazing, file_fGrazing_monthly, month_columns_17_12);
  1108. create_output_table(cmip6_fco2antt, file_fCO2antt_monthly, month_columns_17_12);
  1109. create_output_table(cmip6_fco2nat, file_fCO2nat_monthly, month_columns_17_12);
  1110. create_output_table(cmip6_fNProduct, file_fNProduct_monthly, month_columns_19_14);
  1111. create_output_table(cmip6_fBNF, file_fBNF_monthly, month_columns_19_14);
  1112. create_output_table(cmip6_fNloss, file_fNloss_monthly, month_columns_19_14);
  1113. create_output_table(cmip6_fNfert, file_fNfert_monthly, month_columns_19_14);
  1114. create_output_table(cmip6_fNup, file_fNup_monthly, month_columns_19_14);
  1115. create_output_table(cmip6_fNleach, file_fNleach_monthly, month_columns_19_14);
  1116. create_output_table(cmip6_fNgas, file_fNgas_monthly, month_columns_19_14);
  1117. create_output_table(cmip6_fNdep, file_fNdep_monthly, month_columns_19_14);
  1118. create_output_table(cmip6_fNnetmin, file_fNnetmin_monthly, month_columns_19_14);
  1119. create_output_table(cmip6_fNgasFire, file_fNgasFire_monthly, month_columns_19_14);
  1120. create_output_table(cmip6_fNgasNonFire, file_fNgasNonFire_monthly, month_columns_19_14);
  1121. create_output_table(cmip6_lai, file_lai_monthly, month_columns_9_4);
  1122. create_output_table(cmip6_mrso, file_mrso_monthly, month_columns_9_4);
  1123. create_output_table(cmip6_mrsos, file_mrsos_monthly, month_columns_9_4);
  1124. create_output_table(cmip6_prveg, file_prveg_monthly, month_columns_15_10);
  1125. create_output_table(cmip6_evspsbl, file_evspsbl_monthly, month_columns_15_10);
  1126. create_output_table(cmip6_evspsblveg, file_evspsblveg_monthly, month_columns_15_10);
  1127. create_output_table(cmip6_evspsblsoi, file_evspsblsoi_monthly, month_columns_15_10);
  1128. create_output_table(cmip6_evspsblpot, file_evspsblpot_monthly, month_columns_15_10);
  1129. create_output_table(cmip6_tran, file_tran_monthly, month_columns_15_10);
  1130. create_output_table(cmip6_mrro, file_mrro_monthly, month_columns_15_10);
  1131. create_output_table(cmip6_mrros, file_mrros_monthly, month_columns_15_10);
  1132. create_output_table(cmip6_prCrop, file_prCrop_monthly, month_columns_15_10);
  1133. create_output_table(cmip6_treeFracBdlDcd, file_treeFracBdlDcd_monthly, month_columns_9_6);
  1134. create_output_table(cmip6_treeFracBdlEvg, file_treeFracBdlEvg_monthly, month_columns_9_6);
  1135. create_output_table(cmip6_treeFracNdlDcd, file_treeFracNdlDcd_monthly, month_columns_9_6);
  1136. create_output_table(cmip6_treeFracNdlEvg, file_treeFracNdlEvg_monthly, month_columns_9_6);
  1137. // create a vector with soil layer names
  1138. std::vector<std::string> soillayers;
  1139. double soildepth[NSOILLAYER] = { SOILDEPTH_UPPER * 0.001, (SOILDEPTH_UPPER + SOILDEPTH_LOWER) * 0.001 };
  1140. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  1141. char columnname[100] = { '\0' };
  1142. // ecev3 - avoid problems with std library to_string not being available on NSC platforms
  1143. std::string numStr = lpjguess_to_string(soildepth[lyr]);
  1144. strcat(columnname, numStr.c_str());
  1145. soillayers.push_back(columnname);
  1146. }
  1147. ColumnDescriptors soillayer_columns;
  1148. soillayer_columns += ColumnDescriptors(soillayers, 9, 4);
  1149. create_output_table(cmip6_mrsol, file_mrsol_monthly, soillayer_columns);
  1150. create_output_table(cmip6_mrsll, file_mrsll_monthly, soillayer_columns);
  1151. create_output_table(cmip6_tsl, file_tsl_monthly, soillayer_columns);
  1152. ColumnDescriptors landcover_columns_10_4, landcover_columns_12_6, landcover_columns_14_9, landcover_columns_15_10, landcover_columns_19_14;
  1153. xtring landcover_string[] = { "psl", "crp", "pst", "urb" };
  1154. for (int lc = 0; lc < NCMIP6LANDCOVERTYPES; lc++) {
  1155. landcover_columns_10_4 += ColumnDescriptor(landcover_string[lc], 10, 4);
  1156. landcover_columns_12_6 += ColumnDescriptor(landcover_string[lc], 12, 6);
  1157. landcover_columns_14_9 += ColumnDescriptor(landcover_string[lc], 14, 9);
  1158. landcover_columns_15_10 += ColumnDescriptor(landcover_string[lc], 15, 10);
  1159. landcover_columns_19_14 += ColumnDescriptor(landcover_string[lc], 19, 14);
  1160. }
  1161. create_output_table(cmip6_cTotFireLut, file_cTotFireLut_monthly, landcover_columns_19_14);
  1162. create_output_table(cmip6_fLulccAtmLut, file_fLulccAtmLut_monthly, landcover_columns_19_14);
  1163. create_output_table(cmip6_fLulccProductLut, file_fLulccProductLut_monthly, landcover_columns_19_14);
  1164. create_output_table(cmip6_fLulccResidueLut, file_fLulccResidueLut_monthly, landcover_columns_19_14);
  1165. create_output_table(cmip6_fProductDecompLut, file_fProductDecompLut_monthly, landcover_columns_19_14);
  1166. create_output_table(cmip6_cProductLut, file_cProductLut_yearly, landcover_columns_12_6);
  1167. create_output_table(cmip6_gppLut, file_gppLut_monthly, landcover_columns_19_14);
  1168. create_output_table(cmip6_irrLut, file_irrLut_monthly, landcover_columns_19_14);
  1169. create_output_table(cmip6_fracLut, file_fracLut_yearly, landcover_columns_14_9);
  1170. create_output_table(cmip6_mfracLut, file_fracLut_monthly, landcover_columns_14_9);
  1171. create_output_table(cmip6_fracOutLut, file_fracOutLut_yearly, landcover_columns_14_9);
  1172. create_output_table(cmip6_fracInLut, file_fracInLut_yearly, landcover_columns_14_9);
  1173. create_output_table(cmip6_laiLut, file_laiLut_monthly, landcover_columns_10_4);
  1174. create_output_table(cmip6_mrroLut, file_mrroLut_monthly, landcover_columns_15_10);
  1175. create_output_table(cmip6_mrsoLut, file_mrsoLut_monthly, landcover_columns_12_6);
  1176. create_output_table(cmip6_mrsosLut, file_mrsosLut_monthly, landcover_columns_12_6);
  1177. create_output_table(cmip6_necbLut, file_necbLut_monthly, landcover_columns_19_14);
  1178. create_output_table(cmip6_nppLut, file_nppLut_monthly, landcover_columns_19_14);
  1179. create_output_table(cmip6_nwdFracLut, file_nwdFracLut_monthly, landcover_columns_14_9);
  1180. create_output_table(cmip6_raLut, file_raLut_monthly, landcover_columns_19_14);
  1181. create_output_table(cmip6_rhLut, file_rhLut_monthly, landcover_columns_19_14);
  1182. create_output_table(cmip6_cSoilLut, file_cSoilLut_yearly, landcover_columns_10_4);
  1183. create_output_table(cmip6_cVegLut, file_cVegLut_yearly, landcover_columns_10_4);
  1184. create_output_table(cmip6_cLitterLut, file_cLitterLut_yearly, landcover_columns_10_4);
  1185. }
  1186. if (printcmip6daily) {
  1187. ColumnDescriptors single_column_9_4, single_column_15_10, single_column_17_12;
  1188. single_column_9_4 += ColumnDescriptor("Total", 9, 4);
  1189. single_column_15_10 += ColumnDescriptor("Total", 15, 10);
  1190. single_column_17_12 += ColumnDescriptor("Total", 17, 12);
  1191. // create a vector with soil layer names
  1192. std::vector<std::string> soillayers;
  1193. double soildepth[NSOILLAYER] = { SOILDEPTH_UPPER * 0.001, (SOILDEPTH_UPPER + SOILDEPTH_LOWER) * 0.001 };
  1194. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  1195. char columnname[100] = { '\0' };
  1196. // ecev3 - avoid problems with std library to_string not being available on NSC platforms
  1197. std::string numStr = lpjguess_to_string(soildepth[lyr]);
  1198. strcat(columnname, numStr.c_str());
  1199. soillayers.push_back(columnname);
  1200. }
  1201. ColumnDescriptors soillayer_columns_9_4, soillayer_columns_15_10;
  1202. soillayer_columns_9_4 += ColumnDescriptors(soillayers, 9, 4);
  1203. soillayer_columns_15_10 += ColumnDescriptors(soillayers, 15, 10);
  1204. create_output_table(cmip6_dlai, file_lai_daily, single_column_9_4);
  1205. create_output_table(cmip6_dmrso, file_mrso_daily, single_column_9_4);
  1206. create_output_table(cmip6_dmrsol, file_mrsol_daily, soillayer_columns_9_4);
  1207. create_output_table(cmip6_dmrsos, file_mrsos_daily, single_column_9_4);
  1208. create_output_table(cmip6_dmrsll, file_mrsll_daily, soillayer_columns_9_4);
  1209. create_output_table(cmip6_dmrro, file_mrro_daily, single_column_15_10);
  1210. create_output_table(cmip6_dtsl, file_tsl_daily, soillayer_columns_9_4);
  1211. create_output_table(cmip6_devspsblpot, file_evspsblpot_daily, single_column_17_12);
  1212. create_output_table(cmip6_dec, file_ec_daily, single_column_17_12);
  1213. create_output_table(cmip6_det, file_et_daily, single_column_17_12);
  1214. create_output_table(cmip6_dprCrop, file_prCrop_daily, single_column_17_12);
  1215. create_output_table(cmip6_dtran, file_tran_daily, single_column_17_12);
  1216. create_output_table(cmip6_dprveg, file_prveg_daily, single_column_17_12);
  1217. }
  1218. if (printifsinputdaily) {
  1219. // IFS data sent to LPJ-GUESS - daily output
  1220. ColumnDescriptors ifs_data_column;
  1221. ifs_data_column += ColumnDescriptor("co2", 8, 2);
  1222. ifs_data_column += ColumnDescriptor("par", 8, 2); // really SW
  1223. ifs_data_column += ColumnDescriptor("LW", 8, 2);
  1224. ifs_data_column += ColumnDescriptor("precip", 8, 2);
  1225. ifs_data_column += ColumnDescriptor("airT", 8, 2);
  1226. ifs_data_column += ColumnDescriptor("soilT", 8, 2);
  1227. ifs_data_column += ColumnDescriptor("surfW", 8, 2);
  1228. ifs_data_column += ColumnDescriptor("deepW", 8, 2);
  1229. if (ifs_input.invalid()) {
  1230. create_output_table(ifs_input, "ifs_input.out", ifs_data_column);
  1231. }
  1232. }
  1233. }
  1234. /// Local analogue of OutputRows::add_value for restricting output
  1235. /** Use to restrict output to specified range of years
  1236. * (or other user-specified limitation)
  1237. *
  1238. * If only yearly output between, say 1961 and 1990 is requred, use:
  1239. * if (date.get_calendar_year() >= 1961 && date.get_calendar_year() <= 1990)
  1240. * (assuming the input module has set the first calendar year in the date object)
  1241. */
  1242. void outlimit_misc(OutputRows& out, const Table& table, double d) {
  1243. if (date.year >= nyear_spinup)
  1244. out.add_value(table, d);
  1245. }
  1246. /// Output of simulation results at the end of each year
  1247. /** Output of simulation results at the end of each year, or for specific years in
  1248. * the simulation of each stand or grid cell.
  1249. * This function does not have to provide any information to the framework.
  1250. *
  1251. * Restrict output to specific years in the local helper function outlimit_misc().
  1252. *
  1253. * Changes in the structure of CommonOutput::outannual() should be mirrored here.
  1254. */
  1255. void MiscOutput::outannual(Gridcell& gridcell) {
  1256. if (date.year < nyear_spinup - 2) {
  1257. if (printseparatestands || printcrescendo)
  1258. closelocalfiles(gridcell);
  1259. return;
  1260. }
  1261. if (printseparatestands) {
  1262. openlocalfiles(gridcell);
  1263. }
  1264. double lon = gridcell.get_lon();
  1265. double lat = gridcell.get_lat();
  1266. const double EPS = 1.0e-12;
  1267. Landcover& lc = gridcell.landcover;
  1268. // The OutputRows object manages the next row of output for each
  1269. // output table
  1270. OutputRows out(output_channel, lon, lat, date.get_calendar_year());
  1271. double landcover_cmass[NLANDCOVERTYPES] = { 0.0 };
  1272. double landcover_nmass[NLANDCOVERTYPES] = { 0.0 };
  1273. double landcover_clitter[NLANDCOVERTYPES] = { 0.0 };
  1274. double landcover_nlitter[NLANDCOVERTYPES] = { 0.0 };
  1275. double landcover_anpp[NLANDCOVERTYPES] = { 0.0 };
  1276. double landcover_densindiv_total[NLANDCOVERTYPES] = { 0.0 };
  1277. double mean_standpft_anpp_lc[NLANDCOVERTYPES] = { 0.0 };
  1278. double mean_standpft_cmass_lc[NLANDCOVERTYPES] = { 0.0 };
  1279. double mean_standpft_densindiv_total_lc[NLANDCOVERTYPES] = { 0.0 };
  1280. double mean_standpft_densindiv_total = 0.0;
  1281. // CREDSCENDO
  1282. double irrigation_gridcell = 0.0;
  1283. double cVeg_gridcell = 0.0;
  1284. double nVeg_gridcell = 0.0;
  1285. double cLitter_gridcell = 0.0;
  1286. double nLitter_gridcell = 0.0;
  1287. double cSoil_gridcell = 0.0;
  1288. double nSoil_gridcell = 0.0;
  1289. double availn = 0.0;
  1290. double cProduct_gridcell = 0.0;
  1291. double nProduct_gridcell = 0.0;
  1292. double cLeaf_gridcell = 0.0;
  1293. double nLeaf_gridcell = 0.0;
  1294. double cRoot_gridcell = 0.0;
  1295. double nRoot_gridcell = 0.0;
  1296. double cWood_gridcell = 0.0;
  1297. double nWood_gridcell = 0.0;
  1298. double cCwd_gridcell = 0.0;
  1299. double nCwd_gridcell = 0.0;
  1300. double cVegLitter_gridcell = 0.0;
  1301. double cmass_veg_gridcell = 0.0;
  1302. double nmass_veg_gridcell = 0.0;
  1303. double standpft_cLitter_CR = 0.0;
  1304. double standpft_nLitter_CR = 0.0;
  1305. double standpft_cSoil_CR = 0.0;
  1306. double standpft_nSoil_CR = 0.0;
  1307. double standpft_cLeaf = 0.0;
  1308. double standpft_nLeaf = 0.0;
  1309. double standpft_cRoot = 0.0;
  1310. double standpft_nRoot = 0.0;
  1311. double standpft_cWood = 0.0;
  1312. double standpft_nWood = 0.0;
  1313. double standpft_cCwd = 0.0;
  1314. double standpft_nCwd = 0.0;
  1315. double standpft_cmass = 0.0;
  1316. double standpft_nmass = 0.0;
  1317. double standpft_clitter = 0.0;
  1318. double standpft_nlitter = 0.0;
  1319. double standpft_anpp = 0.0;
  1320. double standpft_yield = 0.0;
  1321. double standpft_yield1 = 0.0;
  1322. double standpft_yield2 = 0.0;
  1323. double standpft_densindiv_total = 0.0;
  1324. double standpft_cmass_veg = 0.0;
  1325. double standpft_nmass_veg = 0.0;
  1326. double mean_standpft_cmass_veg = 0.0;
  1327. double mean_standpft_nmass_veg = 0.0;
  1328. double pft_mlambda_gpp[12][MAXNUMBER_PFTS] = { 0.0 };
  1329. double pft_mgpp[12][MAXNUMBER_PFTS] = { 0.0 };
  1330. double pft_treedens[MAXNUMBER_PFTS] = { 0.0 };
  1331. double pft_vegheight[MAXNUMBER_PFTS] = { 0.0 };
  1332. double pft_mlai[12][MAXNUMBER_PFTS] = { 0.0 };
  1333. double pft_mlcf[12][MAXNUMBER_PFTS] = { 0.0 };
  1334. double pft_mfapar[12][MAXNUMBER_PFTS] = { 0.0 };
  1335. double kgtog = 1000.0;
  1336. double secondsperday = 86400.0;
  1337. double secondspermonth[12];
  1338. for (int m = 0; m < 12; m++) {
  1339. secondspermonth[m] = secondsperday * (double)date.month_length(m);
  1340. }
  1341. // CMIP6
  1342. double vegHeightTree = 0.0;
  1343. double treefpc = 0.0;
  1344. pftlist.firstobj();
  1345. while (pftlist.isobj) {
  1346. Pft& pft = pftlist.getobj();
  1347. // Sum values across stands, patches and PFTs
  1348. double mean_standpft_yield = 0.0;
  1349. double mean_standpft_yield1 = 0.0;
  1350. double mean_standpft_yield2 = 0.0;
  1351. double standpft_heightindiv_total = 0.0;
  1352. double standpft_fpcindiv_total = 0.0;
  1353. mean_standpft_densindiv_total = 0.0;
  1354. mean_standpft_cmass_veg = 0.0;
  1355. mean_standpft_nmass_veg = 0.0;
  1356. for (int i = 0; i<NLANDCOVERTYPES; i++) {
  1357. mean_standpft_anpp_lc[i] = 0.0;
  1358. mean_standpft_cmass_lc[i] = 0.0;
  1359. mean_standpft_densindiv_total_lc[i] = 0.0;
  1360. }
  1361. // Determine area fraction of stands where this pft is active:
  1362. double active_fraction = 0.0;
  1363. double active_fraction_lc[NLANDCOVERTYPES] = { 0.0 };
  1364. Gridcell::iterator gc_itr = gridcell.begin();
  1365. while (gc_itr != gridcell.end()) {
  1366. Stand& stand = *gc_itr;
  1367. if (stand.pft[pft.id].active) {
  1368. active_fraction += stand.get_gridcell_fraction();
  1369. active_fraction_lc[stand.landcover] += stand.get_gridcell_fraction();
  1370. }
  1371. ++gc_itr;
  1372. }
  1373. // Loop through Stands
  1374. gc_itr = gridcell.begin();
  1375. while (gc_itr != gridcell.end()) {
  1376. Stand& stand = *gc_itr;
  1377. Standpft& standpft = stand.pft[pft.id];
  1378. if (!standpft.active) {
  1379. ++gc_itr;
  1380. continue;
  1381. }
  1382. // Sum values across patches and PFTs
  1383. standpft_cmass = 0.0;
  1384. standpft_nmass = 0.0;
  1385. standpft_clitter = 0.0;
  1386. standpft_nlitter = 0.0;
  1387. standpft_anpp = 0.0;
  1388. standpft_yield = 0.0;
  1389. standpft_yield1 = 0.0;
  1390. standpft_yield2 = 0.0;
  1391. standpft_densindiv_total = 0.0;
  1392. standpft_cLitter_CR = 0.0;
  1393. standpft_nLitter_CR = 0.0;
  1394. standpft_cSoil_CR = 0.0;
  1395. standpft_nSoil_CR = 0.0;
  1396. standpft_cLeaf = 0.0;
  1397. standpft_nLeaf = 0.0;
  1398. standpft_cRoot = 0.0;
  1399. standpft_nRoot = 0.0;
  1400. standpft_cWood = 0.0;
  1401. standpft_nWood = 0.0;
  1402. standpft_cCwd = 0.0;
  1403. standpft_nCwd = 0.0;
  1404. standpft_cmass_veg = 0.0;
  1405. standpft_nmass_veg = 0.0;
  1406. stand.firstobj();
  1407. // Loop through Patches
  1408. while (stand.isobj) {
  1409. Patch& patch = stand.getobj();
  1410. Patchpft& patchpft = patch.pft[pft.id];
  1411. Vegetation& vegetation = patch.vegetation;
  1412. double to_gridcell_average = stand.get_gridcell_fraction() / (double)stand.npatch();
  1413. standpft_anpp += patch.fluxes.get_annual_flux(Fluxes::NPP, pft.id);
  1414. standpft_clitter += patchpft.litter_leaf + patchpft.litter_root + patchpft.litter_sap + patchpft.litter_heart + patchpft.litter_repr;
  1415. standpft_nlitter += patchpft.nmass_litter_leaf + patchpft.nmass_litter_root + patchpft.nmass_litter_sap + patchpft.nmass_litter_heart;
  1416. standpft_cLitter_CR += patchpft.litter_leaf + patchpft.litter_sap + patchpft.litter_heart + patchpft.litter_repr;
  1417. standpft_nLitter_CR += patchpft.nmass_litter_leaf + patchpft.nmass_litter_sap + patchpft.nmass_litter_heart;
  1418. standpft_cSoil_CR += patchpft.litter_root;
  1419. standpft_nSoil_CR += patchpft.nmass_litter_root;
  1420. standpft_cCwd += patchpft.litter_sap + patchpft.litter_heart;
  1421. standpft_nCwd += patchpft.nmass_litter_sap + patchpft.nmass_litter_heart;
  1422. vegetation.firstobj();
  1423. while (vegetation.isobj) {
  1424. Individual& indiv = vegetation.getobj();
  1425. if (indiv.id != -1 && indiv.alive && indiv.pft.id == pft.id) {
  1426. standpft_cmass += indiv.ccont();
  1427. standpft_nmass += indiv.ncont();
  1428. standpft_cLeaf += indiv.cleafcont();
  1429. standpft_nLeaf += indiv.nleafcont();
  1430. standpft_cRoot += indiv.crootcont();
  1431. standpft_nRoot += indiv.nrootcont();
  1432. standpft_cWood += indiv.cmass_wood();
  1433. standpft_nWood += indiv.nmass_wood();
  1434. standpft_cmass_veg += indiv.cmass_veg;
  1435. standpft_nmass_veg += indiv.nmass_veg;
  1436. if (indiv.pft.lifeform == TREE) {
  1437. standpft_nWood += indiv.nstore();
  1438. }
  1439. if (pft.landcover == CROPLAND) {
  1440. standpft_yield += indiv.cropindiv->harv_yield;
  1441. standpft_yield1 += indiv.cropindiv->yield_harvest[0];
  1442. standpft_yield2 += indiv.cropindiv->yield_harvest[1];
  1443. }
  1444. else {
  1445. if (vegmode == COHORT || vegmode == INDIVIDUAL) {
  1446. // guess2008 - only count trees with a trunk above a certain diameter
  1447. if (pft.lifeform == TREE && indiv.age>0) {
  1448. double diam = pow(indiv.height / indiv.pft.k_allom2, 1.0 / indiv.pft.k_allom3);
  1449. if (diam>0.03) {
  1450. standpft_densindiv_total += indiv.densindiv; // indiv/m2
  1451. standpft_heightindiv_total += indiv.height * indiv.fpc * to_gridcell_average;
  1452. standpft_fpcindiv_total += indiv.fpc * to_gridcell_average;
  1453. vegHeightTree += indiv.height * indiv.fpc * to_gridcell_average;
  1454. treefpc += indiv.fpc * to_gridcell_average;
  1455. }
  1456. }
  1457. }
  1458. }
  1459. // Calculate monthly LAI
  1460. for (int m = 0; m<12; m++) {
  1461. pft_mlai[m][pft.id] += indiv.mlai[m] * to_gridcell_average;
  1462. pft_mlcf[m][pft.id] += indiv.mfpc[m] * to_gridcell_average * patch.fpc_rescale;
  1463. pft_mfapar[m][pft.id] += indiv.mfpar[m] * to_gridcell_average;
  1464. pft_mlambda_gpp[m][pft.id] += max(0.0, indiv.mlambda_gpp[m]) * to_gridcell_average;
  1465. pft_mgpp[m][pft.id] += max(0.0, indiv.mgpp[m]) * to_gridcell_average;
  1466. }
  1467. }
  1468. vegetation.nextobj();
  1469. }
  1470. stand.nextobj();
  1471. } // end of patch loop
  1472. standpft_cmass /= (double)stand.npatch();
  1473. standpft_nmass /= (double)stand.npatch();
  1474. standpft_clitter /= (double)stand.npatch();
  1475. standpft_nlitter /= (double)stand.npatch();
  1476. standpft_anpp /= (double)stand.npatch();
  1477. standpft_densindiv_total /= (double)stand.npatch();
  1478. standpft_yield /= (double)stand.npatch();
  1479. standpft_yield1 /= (double)stand.npatch();
  1480. standpft_yield2 /= (double)stand.npatch();
  1481. standpft_cLitter_CR /= (double)stand.npatch();
  1482. standpft_nLitter_CR /= (double)stand.npatch();
  1483. standpft_cSoil_CR /= (double)stand.npatch();
  1484. standpft_nSoil_CR /= (double)stand.npatch();
  1485. standpft_cLeaf /= (double)stand.npatch();
  1486. standpft_cRoot /= (double)stand.npatch();
  1487. standpft_cWood /= (double)stand.npatch();
  1488. standpft_cCwd /= (double)stand.npatch();
  1489. standpft_nLeaf /= (double)stand.npatch();
  1490. standpft_nRoot /= (double)stand.npatch();
  1491. standpft_nWood /= (double)stand.npatch();
  1492. standpft_nCwd /= (double)stand.npatch();
  1493. standpft_cmass_veg /= (double)stand.npatch();
  1494. standpft_nmass_veg /= (double)stand.npatch();
  1495. //Update landcover totals
  1496. landcover_cmass[stand.landcover] += standpft_cmass*stand.get_landcover_fraction();
  1497. landcover_nmass[stand.landcover] += standpft_nmass*stand.get_landcover_fraction();
  1498. landcover_clitter[stand.landcover] += standpft_clitter*stand.get_landcover_fraction();
  1499. landcover_nlitter[stand.landcover] += standpft_nlitter*stand.get_landcover_fraction();
  1500. landcover_anpp[stand.landcover] += standpft_anpp*stand.get_landcover_fraction();
  1501. landcover_densindiv_total[stand.landcover] += standpft_densindiv_total*stand.get_landcover_fraction();
  1502. // Update pft means for active stands
  1503. if (active_fraction > 0.0) { // ecev3 - Peter Anthoni (KIT)
  1504. mean_standpft_yield += standpft_yield * stand.get_gridcell_fraction() / active_fraction;
  1505. mean_standpft_yield1 += standpft_yield1 * stand.get_gridcell_fraction() / active_fraction;
  1506. mean_standpft_yield2 += standpft_yield2 * stand.get_gridcell_fraction() / active_fraction;
  1507. }
  1508. if (active_fraction_lc[stand.landcover] > 0.0) { // ecev3 - Peter Anthoni (KIT)
  1509. // Update pft mean for active stands in landcover
  1510. mean_standpft_anpp_lc[stand.landcover] += standpft_anpp * stand.get_gridcell_fraction() / active_fraction_lc[stand.landcover];
  1511. mean_standpft_cmass_lc[stand.landcover] += standpft_cmass * stand.get_gridcell_fraction() / active_fraction_lc[stand.landcover];
  1512. mean_standpft_densindiv_total_lc[stand.landcover] += standpft_densindiv_total * stand.get_gridcell_fraction() / active_fraction_lc[stand.landcover];
  1513. }
  1514. if (active_fraction > 0.0) { // ecev3 - added active_fraction check
  1515. mean_standpft_densindiv_total += standpft_densindiv_total * stand.get_gridcell_fraction() / active_fraction;
  1516. mean_standpft_cmass_veg += standpft_cmass_veg * stand.get_gridcell_fraction() / active_fraction;
  1517. mean_standpft_nmass_veg += standpft_nmass_veg * stand.get_gridcell_fraction() / active_fraction;
  1518. }
  1519. //Update stand totals
  1520. stand.anpp += standpft_anpp;
  1521. stand.cmass += standpft_cmass;
  1522. // CRESCENDO output
  1523. cVeg_gridcell += standpft_cmass * stand.get_gridcell_fraction();
  1524. nVeg_gridcell += standpft_nmass * stand.get_gridcell_fraction();
  1525. cLitter_gridcell += standpft_cLitter_CR * stand.get_landcover_fraction();
  1526. nLitter_gridcell += standpft_nLitter_CR * stand.get_landcover_fraction();
  1527. cLeaf_gridcell += standpft_cLeaf * stand.get_gridcell_fraction();
  1528. cRoot_gridcell += standpft_cRoot * stand.get_gridcell_fraction();
  1529. cWood_gridcell += standpft_cWood * stand.get_gridcell_fraction();
  1530. cCwd_gridcell += standpft_cCwd * stand.get_gridcell_fraction();
  1531. nLeaf_gridcell += standpft_nLeaf * stand.get_gridcell_fraction();
  1532. nRoot_gridcell += standpft_nRoot * stand.get_gridcell_fraction();
  1533. nWood_gridcell += standpft_nWood * stand.get_gridcell_fraction();
  1534. nCwd_gridcell += standpft_nCwd * stand.get_gridcell_fraction();
  1535. cmass_veg_gridcell += standpft_cmass_veg * stand.get_gridcell_fraction();
  1536. nmass_veg_gridcell += standpft_nmass_veg * stand.get_gridcell_fraction();
  1537. cSoil_gridcell += standpft_cSoil_CR * stand.get_landcover_fraction();
  1538. nSoil_gridcell += standpft_nSoil_CR * stand.get_landcover_fraction();
  1539. // Print per-stand pft values
  1540. if (printseparatestands) {
  1541. int id = stand.id;
  1542. if (stand.id >= MAXNUMBER_STANDS)
  1543. fail("Number of stands to high, increase MAXNUMBER_STANDS for output of individual stands !\n");
  1544. if (stand.landcover == NATURAL) {
  1545. if (!out_anpp_stand_natural[id].invalid())
  1546. outlimit_misc(out, out_anpp_stand_natural[id], standpft_anpp);
  1547. if (!out_cmass_stand_natural[id].invalid())
  1548. outlimit_misc(out, out_cmass_stand_natural[id], standpft_cmass);
  1549. }
  1550. else if (stand.landcover == FOREST) {
  1551. if (!out_anpp_stand_forest[id].invalid())
  1552. outlimit_misc(out, out_anpp_stand_forest[id], standpft_anpp);
  1553. if (!out_cmass_stand_forest[id].invalid())
  1554. outlimit_misc(out, out_cmass_stand_forest[id], standpft_cmass);
  1555. }
  1556. }
  1557. ++gc_itr;
  1558. }//End of loop through stands
  1559. pft_treedens[pft.id] = mean_standpft_densindiv_total;
  1560. pft_vegheight[pft.id] = !negligible(standpft_fpcindiv_total) ? min(99.9, standpft_heightindiv_total / standpft_fpcindiv_total) : 0.0;
  1561. outlimit_misc(out, cresc_cton_veg, !negligible(mean_standpft_nmass_veg) ? min(999.9, mean_standpft_cmass_veg / mean_standpft_nmass_veg) : 0.0);
  1562. // Print to landcover files in case pft:s are common to several landcovers (currently only used in NATURAL and FOREST)
  1563. if (run_landcover) {
  1564. for (int i = 0; i<NLANDCOVERTYPES; i++) {
  1565. if (run[i]) {
  1566. switch (i) {
  1567. case CROPLAND:
  1568. break;
  1569. case PASTURE:
  1570. if (run[NATURAL]) {
  1571. outlimit_misc(out, out_anpp_pasture, mean_standpft_anpp_lc[i]);
  1572. outlimit_misc(out, out_cmass_pasture, mean_standpft_cmass_lc[i]);
  1573. }
  1574. break;
  1575. case BARREN:
  1576. break;
  1577. case NATURAL:
  1578. // if(run[FOREST] || run[PASTURE]) {
  1579. if (run[FOREST]) {
  1580. outlimit_misc(out, out_anpp_natural, mean_standpft_anpp_lc[i]);
  1581. outlimit_misc(out, out_cmass_natural, mean_standpft_cmass_lc[i]);
  1582. outlimit_misc(out, out_dens_natural, mean_standpft_densindiv_total_lc[i]);
  1583. }
  1584. break;
  1585. case FOREST:
  1586. if (run[NATURAL]) {
  1587. outlimit_misc(out, out_anpp_forest, mean_standpft_anpp_lc[i]);
  1588. outlimit_misc(out, out_cmass_forest, mean_standpft_cmass_lc[i]);
  1589. outlimit_misc(out, out_dens_forest, mean_standpft_densindiv_total_lc[i]);
  1590. }
  1591. break;
  1592. case URBAN:
  1593. break;
  1594. case PEATLAND:
  1595. break;
  1596. default:
  1597. if (date.year == nyear_spinup)
  1598. dprintf("Modify code to deal with landcover output!\n");
  1599. }
  1600. }
  1601. }
  1602. }
  1603. if (pft.landcover == CROPLAND) {
  1604. outlimit_misc(out, out_yield, mean_standpft_yield);
  1605. outlimit_misc(out, out_yield1, mean_standpft_yield1);
  1606. outlimit_misc(out, out_yield2, mean_standpft_yield2);
  1607. int pft_sdate1 = -1;
  1608. int pft_sdate2 = -1;
  1609. int pft_hdate1 = -1;
  1610. int pft_hdate2 = -1;
  1611. int pft_lgp = -1;
  1612. double pft_phu = -1;
  1613. double pft_fphu = -1;
  1614. double pft_fhi = -1;
  1615. Gridcell::iterator gc_itr = gridcell.begin();
  1616. while (gc_itr != gridcell.end()) {
  1617. Stand& stand = *gc_itr;
  1618. if (stlist[stand.stid].pftinrotation(pft.name) >= 0) {
  1619. pft_sdate1 = stand[0].pft[pft.id].cropphen->sdate_thisyear[0];
  1620. pft_sdate2 = stand[0].pft[pft.id].cropphen->sdate_thisyear[1];
  1621. pft_hdate1 = stand[0].pft[pft.id].cropphen->hdate_harvest[0];
  1622. pft_hdate2 = stand[0].pft[pft.id].cropphen->hdate_harvest[1];
  1623. pft_lgp = stand[0].pft[pft.id].cropphen->lgp;
  1624. pft_phu = stand[0].pft[pft.id].cropphen->phu;
  1625. pft_fphu = stand[0].pft[pft.id].cropphen->fphu_harv;
  1626. pft_fhi = stand[0].pft[pft.id].cropphen->fhi_harv;
  1627. }
  1628. ++gc_itr;
  1629. }
  1630. outlimit_misc(out, out_sdate1, pft_sdate1);
  1631. outlimit_misc(out, out_sdate2, pft_sdate2);
  1632. outlimit_misc(out, out_hdate1, pft_hdate1);
  1633. outlimit_misc(out, out_hdate2, pft_hdate2);
  1634. outlimit_misc(out, out_lgp, pft_lgp);
  1635. outlimit_misc(out, out_phu, pft_phu);
  1636. outlimit_misc(out, out_fphu, pft_fphu);
  1637. outlimit_misc(out, out_fhi, pft_fhi);
  1638. }
  1639. pftlist.nextobj();
  1640. } // *** End of PFT loop ***
  1641. outlimit_misc(out, cresc_cton_veg, !negligible(nmass_veg_gridcell) ? min(999.9, cmass_veg_gridcell / nmass_veg_gridcell) : 0.0);
  1642. double flux_veg_lc[NLANDCOVERTYPES], flux_repr_lc[NLANDCOVERTYPES],
  1643. flux_soil_lc[NLANDCOVERTYPES], flux_fire_lc[NLANDCOVERTYPES],
  1644. flux_est_lc[NLANDCOVERTYPES], flux_seed_lc[NLANDCOVERTYPES];
  1645. double flux_charvest_lc[NLANDCOVERTYPES], c_org_leach_lc[NLANDCOVERTYPES];
  1646. double c_litter_lc[NLANDCOVERTYPES], c_fast_lc[NLANDCOVERTYPES],
  1647. c_slow_lc[NLANDCOVERTYPES], c_harv_slow_lc[NLANDCOVERTYPES];
  1648. double surfsoillitterc_lc[NLANDCOVERTYPES], cwdc_lc[NLANDCOVERTYPES],
  1649. centuryc_lc[NLANDCOVERTYPES];
  1650. double n_harv_slow_lc[NLANDCOVERTYPES], availn_lc[NLANDCOVERTYPES],
  1651. andep_lc[NLANDCOVERTYPES], anfert_lc[NLANDCOVERTYPES];
  1652. double anmin_lc[NLANDCOVERTYPES], animm_lc[NLANDCOVERTYPES],
  1653. anfix_lc[NLANDCOVERTYPES], n_org_leach_lc[NLANDCOVERTYPES],
  1654. n_min_leach_lc[NLANDCOVERTYPES];
  1655. double flux_ntot_lc[NLANDCOVERTYPES], flux_nharvest_lc[NLANDCOVERTYPES],
  1656. flux_nseed_lc[NLANDCOVERTYPES];
  1657. double surfsoillittern_lc[NLANDCOVERTYPES], cwdn_lc[NLANDCOVERTYPES],
  1658. centuryn_lc[NLANDCOVERTYPES];
  1659. // CRESCEDO and CMIP6 variables
  1660. double awc_tot, burntArea = 0.0;
  1661. double mmrso[12], mmrsos[12], mmrro[12], mmrros[12], mevapotrans[12], mevspsblveg[12], mevspsblsoi[12], mevspsblpot[12], mtran[12], msnd[12], mprecip[12];
  1662. double mnpp[12], mgpp[12], mrh[12], mra[12], mnbp[12], mnep[12], mfFire[12], mfLuc[12], mcfLucdeforest[12], mreprest[12], mseed[12], mharv[12], mharvcrop[12], mharvgraz[12];
  1663. double mfNdep[12], mfBNF[12], mnfert[12], mfNup[12], mfNnetmin[12], mfNleach[12], mfCleach[12], mfNgas[12], mfNgasFire[12], mfN2O[12], mfNOx[12], mnseed[12], mnharv[12], mnfLuc[12];
  1664. double mfNloss[12], mfVegLitter[12], mfNVegLitter[12], mfLitterSoil[12], mfNLitterSoil[12], mfDeforestToProduct[12], mfProductDecomp[12], mfNProductDecomp[12], mfNProduct[12], mfco2antt[12], mfco2nat[12];
  1665. double mtsl[12];
  1666. double mmsl[12][NSOILLAYER] = { 0.0 };
  1667. double mcVeg[12], mnVeg[12], mcLeaf[12], mnLeaf[12], mcRoot[12], mnRoot[12], mcStem[12], mnStem[12], mcOther[12], mcOtherNPP[12], mcOtherPhen[12], mnOther[12];
  1668. double mcLitter[12], mnLitter[12], mcLitterCwd[12], mnLitterCwd[12], mcLitterSurf[12], mnLitterSurf[12], mcLitterSubSurf[12], mnLitterSubSurf[12], mcLitterAbove[12], mcLitterBelow[12];
  1669. double mcSoil[12], mnSoil[12], mcFast[12], mcMedium[12], mcSlow[12];
  1670. double mcProduct[12], mnProduct[12], mcLand[12], mnLand[12], mnMinNH4[12], mnMinNO3[12];
  1671. double mgppGrass[12], mgppTree[12];
  1672. double mrhsoil[12], mrhlitter[12];
  1673. double mraleaf[12], mraroot[12], mrastem[12], mraother[12], mraGrass[12], mraTree[12], mfVegFire[12], mfLitterFire[12];
  1674. double mBdlDcd[12], mBdlEvg[12], mNdlDcd[12], mNdlEvg[12];
  1675. double mlai[12], mcropFrac[12], mcropFracC3[12], mcropFracC4[12], mpastureFrac[12], mpastureFracC3[12], mpastureFracC4[12], mgrassFrac[12], mgrassFracC3[12], mgrassFracC4[12], mtreeFrac[12];
  1676. double mvegFrac[12], mshrubFrac[12], mbaresoilFrac[12], mresidualFrac[12];
  1677. double dlai[366], dpet[366], daet[366], devap[366], dintercep[366], dprecip[366], dtsl[366][NSOILLAYER], dmrsol[366][NSOILLAYER], dmrro[366], dmrsll[366][NSOILLAYER];
  1678. double acropFrac, apastureFrac, agrassFrac, ashrubfrac, atreeFrac, avegFrac, abaresoilFrac, aresidualFrac, total_land;
  1679. double mgppLut[NCMIP6LANDCOVERTYPES+1][12], mraLut[NCMIP6LANDCOVERTYPES+1][12], mnppLut[NCMIP6LANDCOVERTYPES+1][12], mcTotFireLut[NCMIP6LANDCOVERTYPES+1][12], mrhLut[NCMIP6LANDCOVERTYPES+1][12], mnecbLut[NCMIP6LANDCOVERTYPES+1][12], mnwdFracLut[NCMIP6LANDCOVERTYPES+1][12];
  1680. double mlaiLut[NCMIP6LANDCOVERTYPES+1][12], mrsoLut[NCMIP6LANDCOVERTYPES+1][12], mrsosLut[NCMIP6LANDCOVERTYPES+1][12], mrroLut[NCMIP6LANDCOVERTYPES+1][12], mirrLut[NCMIP6LANDCOVERTYPES+1][12];
  1681. double mfLulccAtmLut[NCMIP6LANDCOVERTYPES+1][12], mfLulccProductLut[NCMIP6LANDCOVERTYPES+1][12], mfLulccResidueLut[NCMIP6LANDCOVERTYPES+1][12], mfProductDecompLut[NCMIP6LANDCOVERTYPES+1][12];
  1682. double acSoilLut[NCMIP6LANDCOVERTYPES+1], acVegLut[NCMIP6LANDCOVERTYPES+1], acLitterLut[NCMIP6LANDCOVERTYPES+1], acProductLut[NCMIP6LANDCOVERTYPES+1];
  1683. double fracLut[NCMIP6LANDCOVERTYPES+1], fracOutLut[NCMIP6LANDCOVERTYPES+1], fracInLut[NCMIP6LANDCOVERTYPES+1];
  1684. #ifdef CRESCENDO_FACE
  1685. double drunoff[366], ddrain[366], dgpp[366], dnpp[366], dother[366], drhet[366], drleaf[366], drroot[366], drwood[366], drgrowth[366];
  1686. double dcleaf[366], dnleaf[366], dcroot[366], dnroot[366], dcwood[366], dnwood[366], dcother[366], dnother[366];
  1687. double dcflita[366], dnlit[366], dcflitb[366], dnrlit[366], dcclitb[366], dndw[366], dcsoil[366], dnsoil[366], dnmineral[366], dnfix[366], dnup[366], dngmin[366], dnmin[366], dnvol[366], dnleach[366];
  1688. double dgl[366], dgw[366], dgr[366], dngl[366], dngw[366], dngr[366], dnlitin[366], dnwlin[366], dnrlin[366], dcllfall[366], dcrlin[366], dcwin[366];
  1689. #endif
  1690. acropFrac = apastureFrac = agrassFrac = ashrubfrac = atreeFrac = avegFrac = abaresoilFrac = aresidualFrac = total_land = 0.0;
  1691. for (int i = 0; i < NLANDCOVERTYPES; i++) {
  1692. flux_veg_lc[i] = 0.0;
  1693. flux_repr_lc[i] = 0.0;
  1694. flux_soil_lc[i] = 0.0;
  1695. flux_fire_lc[i] = 0.0;
  1696. flux_est_lc[i] = 0.0;
  1697. flux_seed_lc[i] = 0.0;
  1698. flux_charvest_lc[i] = 0.0;
  1699. c_org_leach_lc[i] = 0.0;
  1700. c_litter_lc[i] = 0.0;
  1701. c_fast_lc[i] = 0.0;
  1702. c_slow_lc[i] = 0.0;
  1703. c_harv_slow_lc[i] = 0.0;
  1704. surfsoillitterc_lc[i] = 0.0;
  1705. cwdc_lc[i] = 0.0;
  1706. centuryc_lc[i] = 0.0;
  1707. flux_ntot_lc[i] = 0.0;
  1708. flux_nharvest_lc[i] = 0.0;
  1709. flux_nseed_lc[i] = 0.0;
  1710. availn_lc[i] = 0.0;
  1711. andep_lc[i] = 0.0; // same value for all land covers
  1712. anfert_lc[i] = 0.0;
  1713. anmin_lc[i] = 0.0;
  1714. animm_lc[i] = 0.0;
  1715. anfix_lc[i] = 0.0;
  1716. n_org_leach_lc[i] = 0.0;
  1717. n_min_leach_lc[i] = 0.0;
  1718. n_harv_slow_lc[i] = 0.0;
  1719. surfsoillittern_lc[i] = 0.0;
  1720. cwdn_lc[i] = 0.0;
  1721. centuryn_lc[i] = 0.0;
  1722. }
  1723. for (int i = 0; i<NCMIP6LANDCOVERTYPES+1; i++) {
  1724. // CMIP6
  1725. for (int m = 0; m < 12; m++) {
  1726. mgppLut[i][m] = 0.0;
  1727. mraLut[i][m] = 0.0;
  1728. mnppLut[i][m] = 0.0;
  1729. mcTotFireLut[i][m] = 0.0;
  1730. mrhLut[i][m] = 0.0;
  1731. mnecbLut[i][m] = 0.0;
  1732. mnwdFracLut[i][m] = 0.0;
  1733. mlaiLut[i][m] = 0.0;
  1734. mrsoLut[i][m] = 0.0;
  1735. mrsosLut[i][m] = 0.0;
  1736. mrroLut[i][m] = 0.0;
  1737. mirrLut[i][m] = 0.0;
  1738. mfLulccAtmLut[i][m] = 0.0;
  1739. mfLulccProductLut[i][m] = 0.0;
  1740. mfLulccResidueLut[i][m] = 0.0;
  1741. mfProductDecompLut[i][m] = 0.0;
  1742. }
  1743. acSoilLut[i] = 0.0;
  1744. acVegLut[i] = 0.0;
  1745. acLitterLut[i] = 0.0;
  1746. acProductLut[i] = 0.0;
  1747. fracLut[i] = 0.0;
  1748. fracOutLut[i] = 0.0;
  1749. fracInLut[i] = 0.0;
  1750. }
  1751. for (int m = 0; m < 12; m++) {
  1752. mmrso[m] = 0.0;
  1753. mmrsos[m] = 0.0;
  1754. mmrro[m] = 0.0;
  1755. mmrros[m] = 0.0;
  1756. mevapotrans[m] = 0.0;
  1757. mevspsblveg[m] = 0.0;
  1758. mevspsblsoi[m] = 0.0;
  1759. mevspsblpot[m] = 0.0;
  1760. mtran[m] = 0.0;
  1761. msnd[m] = 0.0;
  1762. mprecip[m] = 0.0;
  1763. mnpp[m] = 0.0;
  1764. mgpp[m] = 0.0;
  1765. mrh[m] = 0.0;
  1766. mra[m] = 0.0;
  1767. mnbp[m] = 0.0;
  1768. mnep[m] = 0.0;
  1769. mfFire[m] = 0.0;
  1770. mfLuc[m] = 0.0;
  1771. mcfLucdeforest[m] = 0.0;
  1772. mreprest[m] = 0.0;
  1773. mseed[m] = 0.0;
  1774. mharv[m] = 0.0;
  1775. mharvcrop[m] = 0.0;
  1776. mharvgraz[m] = 0.0;
  1777. mfco2antt[m] = 0.0;
  1778. mfco2nat[m] = 0.0;
  1779. mfNdep[m] = 0.0;
  1780. mfBNF[m] = 0.0;
  1781. mnfert[m] = 0.0;
  1782. mfNup[m] = 0.0;
  1783. mfNnetmin[m] = 0.0;
  1784. mfNleach[m] = 0.0;
  1785. mfCleach[m] = 0.0;
  1786. mfNgas[m] = 0.0;
  1787. mfNgasFire[m] = 0.0;
  1788. mfN2O[m] = 0.0;
  1789. mfNOx[m] = 0.0;
  1790. mnseed[m] = 0.0;
  1791. mnharv[m] = 0.0;
  1792. mnfLuc[m] = 0.0;
  1793. mfNloss[m] = 0.0;
  1794. mfVegLitter[m] = 0.0;
  1795. mfNVegLitter[m] = 0.0;
  1796. mfLitterSoil[m] = 0.0;
  1797. mfNLitterSoil[m] = 0.0;
  1798. mfDeforestToProduct[m] = 0.0;
  1799. mfProductDecomp[m] = 0.0;
  1800. mfNProductDecomp[m] = 0.0;
  1801. mfNProduct[m] = 0.0;
  1802. mtsl[m] = 0.0;
  1803. mcVeg[m] = 0.0;
  1804. mnVeg[m] = 0.0;
  1805. mcLeaf[m] = 0.0;
  1806. mnLeaf[m] = 0.0;
  1807. mcRoot[m] = 0.0;
  1808. mnRoot[m] = 0.0;
  1809. mcStem[m] = 0.0;
  1810. mnStem[m] = 0.0;
  1811. mcOther[m] = 0.0;
  1812. mcOtherNPP[m] = 0.0;
  1813. mcOtherPhen[m] = 0.0;
  1814. mnOther[m] = 0.0;
  1815. mcLitter[m] = mnLitter[m] = mcLitterCwd[m] = mnLitterCwd[m] = mcLitterSurf[m] = mnLitterSurf[m] = mcLitterSubSurf[m] = mnLitterSubSurf[m] = mcLitterAbove[m] = mcLitterBelow[m] = 0.0;
  1816. mcSoil[m] = mnSoil[m] = mcFast[m] = mcMedium[m] = mcSlow[m] = 0.0;
  1817. mcProduct[m] = mnProduct[m] = mcLand[m] = mnLand[m] = mnMinNH4[m] = mnMinNO3[m] = 0.0;
  1818. mgppGrass[m] = mgppTree[m] = 0.0;
  1819. mrhsoil[m] = mrhlitter[m] = 0.0;
  1820. mraleaf[m] = mraroot[m] = mrastem[m] = mraother[m] = mraGrass[m] = mraTree[m] = 0.0;
  1821. mfVegFire[m] = mfLitterFire[m] = 0.0;
  1822. mlai[m] = mcropFrac[m] = mcropFracC3[m] = mcropFracC4[m] = mpastureFrac[m] = mpastureFracC3[m] = mpastureFracC4[m] = mgrassFrac[m] = mgrassFracC3[m] = mgrassFracC4[m] = mtreeFrac[m] = 0.0;
  1823. mvegFrac[m] = mshrubFrac[m] = mbaresoilFrac[m] = mresidualFrac[m] = 0.0;
  1824. mBdlDcd[m] = mBdlEvg[m] = mNdlDcd[m] = mNdlEvg[m] = mtreeFrac[m] = 0.0;
  1825. }
  1826. for (int d = 0; d < date.year_length(); d++) {
  1827. dlai[d] = 0.0;
  1828. dpet[d] = 0.0;
  1829. devap[d] = 0.0;
  1830. dprecip[d] = 0.0;
  1831. daet[d] = 0.0;
  1832. dintercep[d] = 0.0;
  1833. dmrro[d] = 0.0;
  1834. #ifdef CRESCENDO_FACE
  1835. drunoff[d] = 0.0;
  1836. ddrain[d] = 0.0;
  1837. dgpp[d] = 0.0;
  1838. dnpp[d] = 0.0;
  1839. dother[d] = 0.0;
  1840. drhet[d] = 0.0;
  1841. drleaf[d] = 0.0;
  1842. drroot[d] = 0.0;
  1843. drwood[d] = 0.0;
  1844. drgrowth[d] = 0.0;
  1845. dcleaf[d] = 0.0;
  1846. dnleaf[d] = 0.0;
  1847. dcroot[d] = 0.0;
  1848. dnroot[d] = 0.0;
  1849. dcwood[d] = 0.0;
  1850. dnwood[d] = 0.0;
  1851. dcother[d] = 0.0;
  1852. dnother[d] = 0.0;
  1853. dcflita[d] = 0.0;
  1854. dnlit[d] = 0.0;
  1855. dcflitb[d] = 0.0;
  1856. dnrlit[d] = 0.0;
  1857. dcclitb[d] = 0.0;
  1858. dndw[d] = 0.0;
  1859. dcsoil[d] = 0.0;
  1860. dnsoil[d] = 0.0;
  1861. dnmineral[d] = 0.0;
  1862. dnfix[d] = 0.0;
  1863. dnup[d] = 0.0;
  1864. dngmin[d] = 0.0;
  1865. dnmin[d] = 0.0;
  1866. dnvol[d] = 0.0;
  1867. dnleach[d] = 0.0;
  1868. dgl[d] = 0.0;
  1869. dgw[d] = 0.0;
  1870. dgr[d] = 0.0;
  1871. dngl[d] = 0.0;
  1872. dngw[d] = 0.0;
  1873. dngr[d] = 0.0;
  1874. dnlitin[d] = 0.0;
  1875. dnwlin[d] = 0.0;
  1876. dnrlin[d] = 0.0;
  1877. dcllfall[d] = 0.0;
  1878. dcrlin[d] = 0.0;
  1879. dcwin[d] = 0.0;
  1880. #endif
  1881. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  1882. dtsl[d][lyr] = 0.0;
  1883. dmrsol[d][lyr] = 0.0;
  1884. dmrsll[d][lyr] = 0.0;
  1885. }
  1886. }
  1887. // Sum C fluxes, dead C pools and runoff across patches
  1888. Gridcell::iterator gc_itr = gridcell.begin();
  1889. // Loop through Stands
  1890. while (gc_itr != gridcell.end()) {
  1891. Stand& stand = *gc_itr;
  1892. stand.firstobj();
  1893. int LCT = 0;
  1894. if (stand.landcover == URBAN)
  1895. LCT = URB;
  1896. else if (stand.landcover == PASTURE)
  1897. LCT = PST;
  1898. else if (stand.landcover == CROPLAND)
  1899. LCT = CRP;
  1900. else if (stand.landcover == BARREN)
  1901. LCT = 4; // will not be included in ouput because it is not land
  1902. else
  1903. LCT = PSL;
  1904. // Loop through Patches
  1905. while (stand.isobj) {
  1906. Patch& patch = stand.getobj();
  1907. Soil& soil = patch.soil;
  1908. double to_gridcell_average = stand.get_gridcell_fraction() / (double)stand.npatch();
  1909. awc_tot = 0.0;
  1910. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  1911. awc_tot += soil.soiltype.awc[lyr];
  1912. }
  1913. flux_nseed_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::SEEDN)*to_gridcell_average;
  1914. flux_nharvest_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::HARVESTN)*to_gridcell_average;
  1915. flux_ntot_lc[stand.landcover] += (patch.fluxes.get_annual_flux(Fluxes::NH3_FIRE) +
  1916. patch.fluxes.get_annual_flux(Fluxes::NOx_FIRE) +
  1917. patch.fluxes.get_annual_flux(Fluxes::N2O_FIRE) +
  1918. patch.fluxes.get_annual_flux(Fluxes::N2_FIRE) +
  1919. patch.fluxes.get_annual_flux(Fluxes::N_SOIL)) * to_gridcell_average;
  1920. flux_veg_lc[stand.landcover] += -patch.fluxes.get_annual_flux(Fluxes::NPP)*to_gridcell_average;
  1921. flux_repr_lc[stand.landcover] += -patch.fluxes.get_annual_flux(Fluxes::REPRC)*to_gridcell_average;
  1922. flux_soil_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::SOILC)*to_gridcell_average;
  1923. flux_fire_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::FIREC)*to_gridcell_average;
  1924. flux_est_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::ESTC)*to_gridcell_average;
  1925. flux_seed_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::SEEDC)*to_gridcell_average;
  1926. flux_charvest_lc[stand.landcover] += patch.fluxes.get_annual_flux(Fluxes::HARVESTC)*to_gridcell_average;
  1927. c_fast_lc[stand.landcover] += patch.soil.cpool_fast*to_gridcell_average;
  1928. c_slow_lc[stand.landcover] += patch.soil.cpool_slow*to_gridcell_average;
  1929. //Sum slow pools of harvested products
  1930. if (run_landcover && ifslowharvestpool) {
  1931. for (int q = 0; q<npft; q++) {
  1932. Patchpft& patchpft = patch.pft[q];
  1933. c_harv_slow_lc[stand.landcover] += patchpft.harvested_products_slow*to_gridcell_average; //slow pool in receiving landcover (1)
  1934. n_harv_slow_lc[stand.landcover] += patchpft.harvested_products_slow_nmass*to_gridcell_average;
  1935. cProduct_gridcell += patchpft.harvested_products_slow*to_gridcell_average;
  1936. nProduct_gridcell += patchpft.harvested_products_slow_nmass*to_gridcell_average;
  1937. }
  1938. }
  1939. //Gridcell irrigation
  1940. irrigation_gridcell += patch.irrigation_y*to_gridcell_average;
  1941. andep_lc[stand.landcover] += stand.get_climate().andep * to_gridcell_average;
  1942. anfert_lc[stand.landcover] += patch.anfert * to_gridcell_average;
  1943. anmin_lc[stand.landcover] += patch.soil.anmin * to_gridcell_average;
  1944. animm_lc[stand.landcover] += patch.soil.animmob * to_gridcell_average;
  1945. anfix_lc[stand.landcover] += patch.soil.anfix * to_gridcell_average;
  1946. n_min_leach_lc[stand.landcover] += patch.soil.aminleach * to_gridcell_average;
  1947. n_org_leach_lc[stand.landcover] += patch.soil.aorgNleach * to_gridcell_average;
  1948. c_org_leach_lc[stand.landcover] += patch.soil.aorgCleach * to_gridcell_average;
  1949. availn_lc[stand.landcover] += (patch.soil.nmass_avail + patch.soil.snowpack_nmass) * to_gridcell_average;
  1950. availn += (patch.soil.nmass_avail + patch.soil.snowpack_nmass) * to_gridcell_average;
  1951. for (int r = 0; r < NSOMPOOL - 1; r++) {
  1952. if (r == SURFMETA || r == SURFSTRUCT || r == SOILMETA || r == SOILSTRUCT) {
  1953. surfsoillitterc_lc[stand.landcover] += patch.soil.sompool[r].cmass * to_gridcell_average;
  1954. surfsoillittern_lc[stand.landcover] += patch.soil.sompool[r].nmass * to_gridcell_average;
  1955. }
  1956. else if (r == SURFFWD || r == SURFCWD) {
  1957. cwdc_lc[stand.landcover] += patch.soil.sompool[r].cmass * to_gridcell_average;
  1958. cwdn_lc[stand.landcover] += patch.soil.sompool[r].nmass * to_gridcell_average;
  1959. }
  1960. else {
  1961. centuryc_lc[stand.landcover] += patch.soil.sompool[r].cmass * to_gridcell_average;
  1962. centuryn_lc[stand.landcover] += patch.soil.sompool[r].nmass * to_gridcell_average;
  1963. }
  1964. // CRESCENDO
  1965. if (r == SURFMETA || r == SURFSTRUCT) {
  1966. cLitter_gridcell += soil.sompool[r].cmass * to_gridcell_average;
  1967. nLitter_gridcell += soil.sompool[r].nmass * to_gridcell_average;
  1968. }
  1969. else if (r == SURFFWD || r == SURFCWD) {
  1970. cLitter_gridcell += soil.sompool[r].cmass * to_gridcell_average;
  1971. nLitter_gridcell += soil.sompool[r].nmass * to_gridcell_average;
  1972. cCwd_gridcell += soil.sompool[r].cmass * to_gridcell_average;
  1973. nCwd_gridcell += soil.sompool[r].nmass * to_gridcell_average;
  1974. }
  1975. else {
  1976. cSoil_gridcell += soil.sompool[r].cmass * to_gridcell_average;
  1977. nSoil_gridcell += soil.sompool[r].nmass * to_gridcell_average;
  1978. }
  1979. }
  1980. // CRESCENDO / CMIP6 variables
  1981. if (printcrescendo || printcmip6) {
  1982. burntArea += patch.fireprob * 100.0 * to_gridcell_average;
  1983. double mnwdFrac[12] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
  1984. double fpcrescale = 0.0;
  1985. double fpctotal = 0.0;
  1986. double mfpctotal[12] = { 0.0 };
  1987. double mfpcrescale[12] = { 0.0 };
  1988. if (printcmip6) {
  1989. Vegetation& vegetation = patch.vegetation;
  1990. // Calculate correct FPC rescaling
  1991. vegetation.firstobj();
  1992. while (vegetation.isobj) {
  1993. Individual& indiv = vegetation.getobj();
  1994. fpctotal += indiv.fpc;
  1995. for (int m = 0; m < 12; m++) {
  1996. mfpctotal[m] += indiv.mfpc[m];
  1997. }
  1998. vegetation.nextobj();
  1999. }
  2000. fpcrescale = 1.0 / max(fpctotal, 1.0);
  2001. for (int m = 0; m < 12; m++) {
  2002. mfpcrescale[m] = 1.0 / max(mfpctotal[m], 1.0);
  2003. }
  2004. // Loop trough individuals
  2005. vegetation.firstobj();
  2006. while (vegetation.isobj) {
  2007. Individual& indiv = vegetation.getobj();
  2008. acVegLut[LCT] += indiv.ccont() * to_gridcell_average;
  2009. double indiv_fpc = indiv.fpc * to_gridcell_average * fpcrescale;
  2010. if (indiv.pft.landcover == CROPLAND) {
  2011. acropFrac += indiv_fpc;
  2012. }
  2013. else if (indiv.pft.landcover == PASTURE) {
  2014. apastureFrac += indiv_fpc;
  2015. }
  2016. else if (indiv.pft.lifeform == GRASS) {
  2017. agrassFrac += indiv_fpc;
  2018. }
  2019. else if (indiv.pft.lifeform == TREE && (indiv.pft.name == "BLSE" || indiv.pft.name == "BLSS")) {
  2020. ashrubfrac += indiv_fpc;
  2021. }
  2022. else if (indiv.pft.lifeform == TREE) {
  2023. atreeFrac += indiv_fpc;
  2024. }
  2025. avegFrac += indiv_fpc;
  2026. for (int m = 0; m < 12; m++) {
  2027. mlai[m] += indiv.mlai[m] * to_gridcell_average;
  2028. mlaiLut[LCT][m] += indiv.mlai[m] * to_gridcell_average;
  2029. double indiv_mfpc = indiv.mfpc[m] * to_gridcell_average * mfpcrescale[m];
  2030. if (indiv.pft.landcover == CROPLAND) {
  2031. mcropFrac[m] += indiv_mfpc;
  2032. if (indiv.pft.pathway == C3)
  2033. mcropFracC3[m] += indiv_mfpc;
  2034. else // C4
  2035. mcropFracC4[m] += indiv_mfpc;
  2036. }
  2037. else if (indiv.pft.landcover == PASTURE) {
  2038. mpastureFrac[m] += indiv_mfpc;
  2039. if (indiv.pft.pathway == C3)
  2040. mpastureFracC3[m] += indiv_mfpc;
  2041. else // C4
  2042. mpastureFracC4[m] += indiv_mfpc;
  2043. }
  2044. else if (indiv.pft.lifeform == GRASS) {
  2045. mgrassFrac[m] += indiv_mfpc;
  2046. if (indiv.pft.pathway == C3)
  2047. mgrassFracC3[m] += indiv_mfpc;
  2048. else // C4
  2049. mgrassFracC4[m] += indiv_mfpc;
  2050. }
  2051. else if (indiv.pft.lifeform == TREE) {
  2052. if (indiv.pft.name == "BLSE" || indiv.pft.name == "BLSS") {
  2053. mshrubFrac[m] += indiv_mfpc;
  2054. }
  2055. else {
  2056. if (indiv.pft.leafphysiognomy == BROADLEAF && (indiv.pft.phenology == SUMMERGREEN || indiv.pft.phenology == RAINGREEN)) {
  2057. mBdlDcd[m] += indiv_mfpc;
  2058. }
  2059. else if (indiv.pft.leafphysiognomy == BROADLEAF && indiv.pft.phenology == EVERGREEN) {
  2060. mBdlEvg[m] += indiv_mfpc;
  2061. }
  2062. else if (indiv.pft.leafphysiognomy == NEEDLELEAF && indiv.pft.phenology == SUMMERGREEN) {
  2063. mNdlDcd[m] += indiv_mfpc;
  2064. }
  2065. else if (indiv.pft.leafphysiognomy == NEEDLELEAF && indiv.pft.phenology == EVERGREEN) {
  2066. mNdlEvg[m] += indiv_mfpc;
  2067. }
  2068. mtreeFrac[m] += indiv_mfpc;
  2069. }
  2070. }
  2071. if (indiv.pft.lifeform == TREE) {
  2072. mnwdFrac[m] -= indiv.mfpc[m] * mfpcrescale[m];
  2073. }
  2074. }
  2075. vegetation.nextobj();
  2076. }
  2077. for (int q = 0; q < npft; q++) {
  2078. Patchpft& patchpft = patch.pft[q];
  2079. acProductLut[LCT] += patchpft.harvested_products_slow*to_gridcell_average;
  2080. }
  2081. for (int r = 0; r < NSOMPOOL - 1; r++) {
  2082. if (r == SURFMETA || r == SURFSTRUCT || r == SOILMETA || r == SOILSTRUCT || r == SURFFWD || r == SURFCWD) {
  2083. acLitterLut[LCT] += soil.sompool[r].cmass * to_gridcell_average;
  2084. }
  2085. else {
  2086. acSoilLut[LCT] += soil.sompool[r].cmass * to_gridcell_average;
  2087. }
  2088. }
  2089. fracLut[LCT] += to_gridcell_average;
  2090. }
  2091. if (stand.landcover != BARREN)
  2092. total_land += to_gridcell_average;
  2093. for (int m = 0; m < 12; m++) {
  2094. mmrso[m] += (soil.mwcont[m][0] * soil.soiltype.awc[0] + soil.mwcont[m][1] * soil.soiltype.awc[1]) * to_gridcell_average;
  2095. mmrsos[m] += soil.mwcont[m][0] * soil.soiltype.awc[0] * to_gridcell_average / SOILDEPTH_UPPER * 100.0; // top 10cm
  2096. mmrro[m] += patch.mrunoff[m] * to_gridcell_average;
  2097. mevspsblveg[m] += patch.mintercep[m] * to_gridcell_average;
  2098. mevspsblsoi[m] += patch.mevap[m] * to_gridcell_average;
  2099. mevspsblpot[m] += patch.mpet[m] * to_gridcell_average;
  2100. mtran[m] += patch.maet[m] * to_gridcell_average;
  2101. mevapotrans[m] += (patch.maet[m] + patch.mevap[m] + patch.mintercep[m]) * to_gridcell_average;
  2102. mgpp[m] += patch.fluxes.get_monthly_flux(Fluxes::GPP, m) * to_gridcell_average;
  2103. mra[m] += patch.fluxes.get_monthly_flux(Fluxes::RA, m) * to_gridcell_average;
  2104. mrh[m] += patch.fluxes.get_monthly_flux(Fluxes::SOILC, m) * to_gridcell_average;
  2105. mreprest[m] += (patch.fluxes.get_monthly_flux(Fluxes::ESTC, m) + patch.fluxes.get_monthly_flux(Fluxes::REPRC, m)) * to_gridcell_average;
  2106. mseed[m] += patch.fluxes.get_monthly_flux(Fluxes::SEEDC, m) * to_gridcell_average;
  2107. mharv[m] += patch.fluxes.get_monthly_flux(Fluxes::HARVESTC, m) * to_gridcell_average;
  2108. mharvgraz[m] += patch.fluxes.get_monthly_flux(Fluxes::HARVGRAZC, m) * to_gridcell_average;
  2109. mfFire[m] += patch.fluxes.get_monthly_flux(Fluxes::FIREC, m) * to_gridcell_average;
  2110. mfNdep[m] += patch.fluxes.get_monthly_flux(Fluxes::NDEP, m) * to_gridcell_average;
  2111. mfBNF[m] += patch.fluxes.get_monthly_flux(Fluxes::NFIX, m) * to_gridcell_average;
  2112. mfNup[m] += patch.fluxes.get_monthly_flux(Fluxes::NUP, m) * to_gridcell_average;
  2113. mfNnetmin[m] += patch.fluxes.get_monthly_flux(Fluxes::NMIN, m) * to_gridcell_average;
  2114. mfNleach[m] += patch.fluxes.get_monthly_flux(Fluxes::LEACHN, m) * to_gridcell_average;
  2115. mfCleach[m] += patch.fluxes.get_monthly_flux(Fluxes::LEACHC, m) * to_gridcell_average;
  2116. mfNgas[m] += (patch.fluxes.get_monthly_flux(Fluxes::NH3_FIRE, m) +
  2117. patch.fluxes.get_monthly_flux(Fluxes::NOx_FIRE, m) + patch.fluxes.get_monthly_flux(Fluxes::N2O_FIRE, m) +
  2118. patch.fluxes.get_monthly_flux(Fluxes::N2_FIRE, m) + patch.fluxes.get_monthly_flux(Fluxes::N_SOIL, m)) /
  2119. to_gridcell_average;
  2120. mfNgasFire[m] += (patch.fluxes.get_monthly_flux(Fluxes::NH3_FIRE, m) + patch.fluxes.get_monthly_flux(Fluxes::NOx_FIRE, m) +
  2121. patch.fluxes.get_monthly_flux(Fluxes::N2O_FIRE, m) + patch.fluxes.get_monthly_flux(Fluxes::N2_FIRE, m)) /
  2122. to_gridcell_average;
  2123. mnseed[m] += patch.fluxes.get_monthly_flux(Fluxes::SEEDN, m) * to_gridcell_average;
  2124. mnharv[m] += patch.fluxes.get_monthly_flux(Fluxes::HARVESTN, m) * to_gridcell_average;
  2125. mfVegLitter[m] += patch.fluxes.get_monthly_flux(Fluxes::VEGLITTERC, m) * to_gridcell_average;
  2126. mfNVegLitter[m] += patch.fluxes.get_monthly_flux(Fluxes::VEGLITTERN, m) * to_gridcell_average;
  2127. mfLitterSoil[m] += patch.fluxes.get_monthly_flux(Fluxes::LITTERSOILC, m) * to_gridcell_average;
  2128. mfNLitterSoil[m] += patch.fluxes.get_monthly_flux(Fluxes::LITTERSOILN, m) * to_gridcell_average;
  2129. mtsl[m] += soil.mtemp_K[m] * to_gridcell_average;
  2130. mfco2nat[m] += patch.fluxes.get_monthly_flux(Fluxes::CO2NAT, m) * to_gridcell_average;
  2131. mfco2antt[m] += patch.fluxes.get_monthly_flux(Fluxes::CO2ANTT, m) * to_gridcell_average;
  2132. if (stand.landcover != CROPLAND) { // Cropland has daily allocation so NPP is moved to Vegetation directly
  2133. mcOtherNPP[m] += (patch.fluxes.get_monthly_flux(Fluxes::GPP, m) - patch.fluxes.get_monthly_flux(Fluxes::RA, m)) * to_gridcell_average;
  2134. }
  2135. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  2136. mmsl[m][lyr] += soil.mwcont[m][lyr] * soil.soiltype.awc[lyr] * to_gridcell_average;
  2137. }
  2138. if (printcrescendo) {
  2139. msnd[m] += soil.msnd[m] * to_gridcell_average;
  2140. mharvcrop[m] += patch.fluxes.get_monthly_flux(Fluxes::HARVCROPC, m) * to_gridcell_average;
  2141. mfN2O[m] += patch.fluxes.get_monthly_flux(Fluxes::N2O_FIRE, m) * to_gridcell_average;
  2142. mfNOx[m] += patch.fluxes.get_monthly_flux(Fluxes::NOx_FIRE, m) * to_gridcell_average;
  2143. }
  2144. if (printcmip6) {
  2145. mmrros[m] += patch.mrunoff_surf[m] * to_gridcell_average;
  2146. mcVeg[m] += patch.mcVeg[m] * to_gridcell_average;
  2147. mnVeg[m] += patch.mnVeg[m] * to_gridcell_average;
  2148. mcLeaf[m] += patch.mcLeaf[m] * to_gridcell_average;
  2149. mnLeaf[m] += patch.mnLeaf[m] * to_gridcell_average;
  2150. mcRoot[m] += patch.mcRoot[m] * to_gridcell_average;
  2151. mnRoot[m] += patch.mnRoot[m] * to_gridcell_average;
  2152. mcStem[m] += patch.mcStem[m] * to_gridcell_average;
  2153. mnStem[m] += patch.mnStem[m] * to_gridcell_average;
  2154. mcOther[m] += patch.mcOther[m] * to_gridcell_average;
  2155. mcOtherPhen[m] += patch.mcOtherPhen[m] * to_gridcell_average;
  2156. mnOther[m] += patch.mnOther[m] * to_gridcell_average;
  2157. mcProduct[m] += patch.mcProduct[m] * to_gridcell_average;
  2158. mnProduct[m] += patch.mnProduct[m] * to_gridcell_average;
  2159. mcLitter[m] += soil.mcLitter[m] * to_gridcell_average;
  2160. mnLitter[m] += soil.mnLitter[m] * to_gridcell_average;
  2161. mcLitterCwd[m] += soil.mcLitterCwd[m] * to_gridcell_average;
  2162. mnLitterCwd[m] += soil.mnLitterCwd[m] * to_gridcell_average;
  2163. mcLitterSurf[m] += soil.mcLitterSurf[m] * to_gridcell_average;
  2164. mnLitterSurf[m] += soil.mnLitterSurf[m] * to_gridcell_average;
  2165. mcLitterSubSurf[m] += soil.mcLitterSubSurf[m] * to_gridcell_average;
  2166. mnLitterSubSurf[m] += soil.mnLitterSubSurf[m] * to_gridcell_average;
  2167. mcLitterAbove[m] += soil.mcLitterAbove[m] * to_gridcell_average;
  2168. mcLitterBelow[m] += soil.mcLitterBelow[m] * to_gridcell_average;
  2169. mcSoil[m] += soil.mcSoil[m] * to_gridcell_average;
  2170. mnSoil[m] += soil.mnSoil[m] * to_gridcell_average;
  2171. mcFast[m] += (soil.mcSoil[m] - (soil.mcMedium[m] + soil.mcSlow[m])) * to_gridcell_average;
  2172. mcMedium[m] += soil.mcMedium[m] * to_gridcell_average;
  2173. mcSlow[m] += soil.mcSlow[m] * to_gridcell_average;
  2174. mnMinNH4[m] += soil.mnMineralNH4[m] * to_gridcell_average;
  2175. mnMinNO3[m] += soil.mnMineralNO3[m] * to_gridcell_average;
  2176. mnLand[m] = mnVeg[m] + mnProduct[m] + mnLitter[m] + mnSoil[m] + mnMinNH4[m] + mnMinNO3[m]; // to_gridcell_average is already considered
  2177. mrhsoil[m] += (patch.fluxes.get_monthly_flux(Fluxes::SOILC, m) - patch.fluxes.get_monthly_flux(Fluxes::LITTERC, m)) * to_gridcell_average;
  2178. mrhlitter[m] += patch.fluxes.get_monthly_flux(Fluxes::LITTERC, m) * to_gridcell_average;
  2179. mgppGrass[m] += patch.fluxes.get_monthly_flux(Fluxes::GPPGRASS, m) * to_gridcell_average;
  2180. mgppTree[m] += patch.fluxes.get_monthly_flux(Fluxes::GPPTREE, m) * to_gridcell_average;
  2181. mraleaf[m] += patch.fluxes.get_monthly_flux(Fluxes::RALEAF, m) * to_gridcell_average;
  2182. mraroot[m] += patch.fluxes.get_monthly_flux(Fluxes::RAROOT, m) * to_gridcell_average;
  2183. mrastem[m] += patch.fluxes.get_monthly_flux(Fluxes::RASTEM, m) * to_gridcell_average;
  2184. mraother[m] += patch.fluxes.get_monthly_flux(Fluxes::RAGROWTH, m) * to_gridcell_average;
  2185. mraGrass[m] += patch.fluxes.get_monthly_flux(Fluxes::RAGRASS, m) * to_gridcell_average;
  2186. mraTree[m] += patch.fluxes.get_monthly_flux(Fluxes::RATREE, m) * to_gridcell_average;
  2187. mfVegFire[m] += patch.fluxes.get_monthly_flux(Fluxes::FIREVEGC, m) * to_gridcell_average;
  2188. mfLitterFire[m] += patch.fluxes.get_monthly_flux(Fluxes::FIRELITTERC, m) * to_gridcell_average;
  2189. mnfert[m] += patch.fluxes.get_monthly_flux(Fluxes::NFERT, m) * to_gridcell_average;
  2190. mcTotFireLut[LCT][m] += patch.fluxes.get_monthly_flux(Fluxes::FIREC, m) * to_gridcell_average;
  2191. mgppLut[LCT][m] += patch.fluxes.get_monthly_flux(Fluxes::GPP, m) * to_gridcell_average;
  2192. mraLut[LCT][m] += patch.fluxes.get_monthly_flux(Fluxes::RA, m) * to_gridcell_average;
  2193. mnppLut[LCT][m] += (patch.fluxes.get_monthly_flux(Fluxes::GPP, m) - patch.fluxes.get_monthly_flux(Fluxes::RA, m)) * to_gridcell_average;
  2194. mrhLut[LCT][m] += patch.fluxes.get_monthly_flux(Fluxes::SOILC, m) * to_gridcell_average;
  2195. mnecbLut[LCT][m] += (patch.fluxes.get_monthly_flux(Fluxes::GPP, m) - (patch.fluxes.get_monthly_flux(Fluxes::RA, m) +
  2196. patch.fluxes.get_monthly_flux(Fluxes::SOILC, m) + patch.fluxes.get_monthly_flux(Fluxes::FIREC, m) +
  2197. patch.fluxes.get_monthly_flux(Fluxes::ESTC, m) + patch.fluxes.get_monthly_flux(Fluxes::REPRC, m) + patch.fluxes.get_monthly_flux(Fluxes::LEACHC, m) +
  2198. patch.fluxes.get_monthly_flux(Fluxes::SEEDC, m) + patch.fluxes.get_monthly_flux(Fluxes::HARVESTC, m))) * to_gridcell_average;
  2199. mnwdFracLut[LCT][m] += max(0.0, mnwdFrac[m]) * to_gridcell_average;
  2200. mrroLut[LCT][m] += patch.mrunoff[m] * to_gridcell_average;
  2201. mrsoLut[LCT][m] += (soil.mwcont[m][0] * soil.soiltype.awc[0] + soil.mwcont[m][1] * soil.soiltype.awc[1]) * to_gridcell_average;
  2202. mrsosLut[LCT][m] += soil.mwcont[m][0] * soil.soiltype.awc[0] * to_gridcell_average / SOILDEPTH_UPPER * 100.0; // top 10cm;
  2203. mirrLut[LCT][m] += patch.irrigation_m[m] * to_gridcell_average;
  2204. mfLulccProductLut[LCT][m] += (patch.fluxes.get_monthly_flux(Fluxes::HARVCROPSLOWC, m) + patch.fluxes.get_monthly_flux(Fluxes::HARVGRAZSLOWC, m)) * to_gridcell_average;
  2205. mfLulccResidueLut[LCT][m] += patch.fluxes.get_monthly_flux(Fluxes::HARVCROPRESC, m) * to_gridcell_average;
  2206. mfLulccAtmLut[LCT][m] += (patch.fluxes.get_monthly_flux(Fluxes::HARVCROPC, m) + patch.fluxes.get_monthly_flux(Fluxes::HARVGRAZC, m)) * to_gridcell_average; }
  2207. }
  2208. }
  2209. if (printcmip6daily || printcrescendodaily || printcrescendofacedaily) {
  2210. for (int d = 0; d < date.year_length(); d++) {
  2211. dlai[d] += patch.dlai[d] * to_gridcell_average;
  2212. if (printcmip6daily || printcrescendofacedaily) {
  2213. dpet[d] += patch.dpet[d] * to_gridcell_average;
  2214. daet[d] += patch.daet[d] * to_gridcell_average;
  2215. devap[d] += patch.devap[d] * to_gridcell_average;
  2216. dintercep[d] += patch.dintercep[d] * to_gridcell_average;
  2217. dmrro[d] += patch.dmrro[d] * to_gridcell_average;
  2218. dmrsll[d][0] += soil.dwcontupper[d] * soil.soiltype.awc[0] * to_gridcell_average;
  2219. dmrsll[d][1] += soil.dwcontlower[d] * soil.soiltype.awc[1] * to_gridcell_average;
  2220. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  2221. dtsl[d][lyr] += soil.dtsl[d][lyr] * to_gridcell_average;
  2222. dmrsol[d][lyr] += soil.dmrsol[d][lyr] * to_gridcell_average;
  2223. }
  2224. }
  2225. #ifdef CRESCENDO_FACE
  2226. if (printcrescendofacedaily) {
  2227. dgpp[d] += patch.fluxes.get_daily_flux(Fluxes::GPP, d) * to_gridcell_average;
  2228. dnpp[d] += (patch.fluxes.get_daily_flux(Fluxes::GPP, d) - patch.fluxes.get_daily_flux(Fluxes::GPP, d)) * to_gridcell_average;
  2229. drunoff[d] += patch.drunoff[d] * to_gridcell_average;
  2230. ddrain[d] += patch.ddrain[d] * to_gridcell_average;
  2231. dcleaf[d] += patch.dcLeaf[d] * to_gridcell_average;
  2232. dnleaf[d] += patch.dnLeaf[d] * to_gridcell_average;
  2233. dcroot[d] += patch.dcRoot[d] * to_gridcell_average;
  2234. dnroot[d] += patch.dnRoot[d] * to_gridcell_average;
  2235. dcwood[d] += patch.dcStem[d] * to_gridcell_average;
  2236. dnwood[d] += patch.dnStem[d] * to_gridcell_average;
  2237. dcother[d] += patch.dcOther[d] * to_gridcell_average;
  2238. dnother[d] += patch.dnOther[d] * to_gridcell_average;
  2239. dcflita[d] += soil.dcflita[d] * to_gridcell_average;
  2240. dnlit[d] += soil.dnlit[d] * to_gridcell_average;
  2241. dcflitb[d] += soil.dcflitb[d] * to_gridcell_average;
  2242. dnrlit[d] += soil.dnrlit[d] * to_gridcell_average;
  2243. dcclitb[d] += soil.dcclitb[d] * to_gridcell_average;
  2244. dndw[d] += soil.dndw[d] * to_gridcell_average;
  2245. dcsoil[d] += soil.dcsoil[d] * to_gridcell_average;
  2246. dnsoil[d] += soil.dnsoil[d] * to_gridcell_average;
  2247. dnmineral[d] += soil.dnmineral[d] * to_gridcell_average;
  2248. dother[d] += (-patch.fluxes.get_daily_flux(Fluxes::DREPRC, d) + patch.fluxes.get_daily_flux(Fluxes::FIREC, d) + patch.fluxes.get_daily_flux(Fluxes::DESTC, d) + patch.fluxes.get_daily_flux(Fluxes::SEEDC, d) + patch.fluxes.get_daily_flux(Fluxes::HARVESTC, d)) * to_gridcell_average;
  2249. drhet[d] += patch.fluxes.get_daily_flux(Fluxes::SOILC, d) * to_gridcell_average;
  2250. drleaf[d] += patch.fluxes.get_daily_flux(Fluxes::DRALEAF, d) * to_gridcell_average;
  2251. drroot[d] += patch.fluxes.get_daily_flux(Fluxes::DRAROOT, d) * to_gridcell_average;
  2252. drwood[d] += patch.fluxes.get_daily_flux(Fluxes::DRASTEM, d) * to_gridcell_average;
  2253. drgrowth[d] += patch.fluxes.get_daily_flux(Fluxes::DRAGROWTH, d) * to_gridcell_average;
  2254. dnfix[d] += patch.fluxes.get_daily_flux(Fluxes::DNFIX, d) * to_gridcell_average;
  2255. dnup[d] += patch.fluxes.get_daily_flux(Fluxes::DNUP, d) * to_gridcell_average;
  2256. dngmin[d] += patch.fluxes.get_daily_flux(Fluxes::DGNMIN, d) * to_gridcell_average;
  2257. dnmin[d] += patch.fluxes.get_daily_flux(Fluxes::DNMIN, d) * to_gridcell_average;
  2258. dnvol[d] += patch.fluxes.get_daily_flux(Fluxes::DN_SOIL, d) * to_gridcell_average;
  2259. dnleach[d] += patch.fluxes.get_daily_flux(Fluxes::DLEACHN, d) * to_gridcell_average;
  2260. dngl[d] += patch.fluxes.get_daily_flux(Fluxes::DNGL, d) * to_gridcell_average;
  2261. dngw[d] += patch.fluxes.get_daily_flux(Fluxes::DNGW, d) * to_gridcell_average;
  2262. dngr[d] += patch.fluxes.get_daily_flux(Fluxes::DNGR, d) * to_gridcell_average;
  2263. dnlitin[d] += patch.fluxes.get_daily_flux(Fluxes::DLEAFLITN, d) * to_gridcell_average;
  2264. dnwlin[d] += patch.fluxes.get_daily_flux(Fluxes::DWOODLITN, d) * to_gridcell_average;
  2265. dnrlin[d] += patch.fluxes.get_daily_flux(Fluxes::DROOTLITN, d) * to_gridcell_average;
  2266. dcllfall[d] += patch.fluxes.get_daily_flux(Fluxes::DLEAFLITC, d) * to_gridcell_average;
  2267. dcwin[d] += patch.fluxes.get_daily_flux(Fluxes::DWOODLITC, d) * to_gridcell_average;
  2268. dcrlin[d] += patch.fluxes.get_daily_flux(Fluxes::DROOTLITC, d) * to_gridcell_average;
  2269. if (d == date.year_length() - 1) {
  2270. dgl[d] += patch.gl * to_gridcell_average;
  2271. dgw[d] += patch.gw * to_gridcell_average;
  2272. dgr[d] += patch.gr * to_gridcell_average;
  2273. }
  2274. }
  2275. #endif
  2276. }
  2277. }
  2278. stand.nextobj();
  2279. } // patch loop
  2280. ++gc_itr;
  2281. } // stand loop
  2282. // CMIP6
  2283. if (printcmip6) {
  2284. stlist.firstobj();
  2285. while (stlist.isobj) {
  2286. StandType& st = stlist.getobj();
  2287. int LCT = 0;
  2288. if (st.landcover == URBAN)
  2289. LCT = URB;
  2290. else if (st.landcover == PASTURE)
  2291. LCT = PST;
  2292. else if (st.landcover == CROPLAND)
  2293. LCT = CRP;
  2294. else
  2295. LCT = PSL;
  2296. fracOutLut[LCT] += gridcell.st[st.id].gross_frac_decrease;
  2297. fracInLut[LCT] += gridcell.st[st.id].gross_frac_increase;
  2298. mfLulccAtmLut[LCT][0] += gridcell.landcover.acflux_landuse_change_lc[st.landcover];
  2299. mcTotFireLut[LCT][0] += gridcell.landcover.acflux_landuse_change_lc[st.landcover];
  2300. mfProductDecompLut[LCT][0] += gridcell.landcover.acflux_harvest_slow_lc[st.landcover];
  2301. mfLulccProductLut[LCT][0] += gridcell.landcover.harvest_product_lc[st.landcover];
  2302. mfLulccResidueLut[LCT][0] += gridcell.landcover.acflux_harvest_wood_res_lc[st.landcover];
  2303. mnecbLut[LCT][0] -= (gridcell.landcover.acflux_landuse_change_lc[st.landcover] + gridcell.landcover.acflux_harvest_slow_lc[st.landcover]);
  2304. stlist.nextobj();
  2305. }
  2306. for (int m = 0; m < 12; m++) {
  2307. mprecip[m] = gridcell.climate.mprec[m];
  2308. }
  2309. for (int d = 0; d < date.year_length(); d++) {
  2310. dprecip[d] = gridcell.climate.dprec[d];
  2311. }
  2312. }
  2313. // CRESCENDO/CMIP6
  2314. if (printcrescendo || printcmip6) {
  2315. mfLuc[0] = gridcell.landcover.acflux_landuse_change;
  2316. mnfLuc[0] = gridcell.landcover.anflux_landuse_change;
  2317. mcfLucdeforest[0] = gridcell.landcover.anflux_landuse_change_lc[NATURAL];
  2318. mfProductDecomp[0] = gridcell.landcover.acflux_harvest_slow;
  2319. mfNProductDecomp[0] = gridcell.landcover.anflux_harvest_slow;
  2320. mfDeforestToProduct[0] += gridcell.landcover.harvest_product;
  2321. mfNProduct[0] = gridcell.landcover.harvest_product_nmass;
  2322. abaresoilFrac = max(0.0, 1.0 - (acropFrac + apastureFrac + agrassFrac + ashrubfrac + atreeFrac));
  2323. for (int m = 0; m < 12; m++) {
  2324. mnpp[m] = mgpp[m] - mra[m];
  2325. mnep[m] = mnpp[m] - (mrh[m] + mfFire[m] + mreprest[m] + mfCleach[m]); // Natural fluxes
  2326. mnbp[m] = mnep[m] - (mfLuc[m] + mseed[m] + mharv[m] + mfProductDecomp[m]); // Adding anthropogenic fluxes
  2327. mfNloss[m] = mnfLuc[m] + mfNProductDecomp[m] + mfNleach[m] + mfNgas[m] + mnseed[m] + mnharv[m];
  2328. if (m > 0) {
  2329. mcOtherNPP[m] += mcOtherNPP[m - 1];
  2330. }
  2331. mcVeg[m] += mcOtherNPP[m];
  2332. mcLand[m] = mcVeg[m] + mcProduct[m] + mcLitter[m] + mcSoil[m];
  2333. }
  2334. }
  2335. #ifdef CRESCENDO_FACE
  2336. // CRESCENDO
  2337. if (printcrescendofacedaily) {
  2338. dother[0] += gridcell.landcover.acflux_landuse_change;
  2339. dother[0] += gridcell.landcover.acflux_harvest_slow;
  2340. }
  2341. #endif
  2342. // Print per-stand totals
  2343. if (printseparatestands) {
  2344. Gridcell::iterator gc_itr = gridcell.begin();
  2345. while (gc_itr != gridcell.end()) {
  2346. Stand& stand = *gc_itr;
  2347. int id = stand.id;;
  2348. if (stand.landcover == NATURAL) {
  2349. if (!out_anpp_stand_natural[id].invalid())
  2350. outlimit_misc(out, out_anpp_stand_natural[id], stand.anpp);
  2351. if (!out_cmass_stand_natural[id].invalid())
  2352. outlimit_misc(out, out_cmass_stand_natural[id], stand.cmass);
  2353. }
  2354. else if (stand.landcover == FOREST) {
  2355. if (!out_anpp_stand_forest[id].invalid())
  2356. outlimit_misc(out, out_anpp_stand_forest[id], stand.anpp);
  2357. if (!out_cmass_stand_forest[id].invalid())
  2358. outlimit_misc(out, out_cmass_stand_forest[id], stand.cmass);
  2359. }
  2360. ++gc_itr;
  2361. }
  2362. }
  2363. if (run[CROPLAND]) {
  2364. outlimit_misc(out, out_irrigation, irrigation_gridcell);
  2365. }
  2366. // Print landcover totals to files
  2367. if (run_landcover) {
  2368. for (int i = 0; i<NLANDCOVERTYPES; i++) {
  2369. if (run[i]) {
  2370. switch (i) {
  2371. case CROPLAND:
  2372. break;
  2373. case PASTURE:
  2374. if (run[NATURAL]) {
  2375. outlimit_misc(out, out_anpp_pasture, landcover_anpp[i]);
  2376. outlimit_misc(out, out_cmass_pasture, landcover_cmass[i]);
  2377. }
  2378. break;
  2379. case BARREN:
  2380. break;
  2381. case NATURAL:
  2382. // if(run[FOREST] || run[PASTURE]) {
  2383. if (run[FOREST]) {
  2384. outlimit_misc(out, out_anpp_natural, landcover_anpp[i]);
  2385. outlimit_misc(out, out_cmass_natural, landcover_cmass[i]);
  2386. outlimit_misc(out, out_dens_natural, landcover_densindiv_total[i]);
  2387. }
  2388. break;
  2389. case FOREST:
  2390. if (run[NATURAL]) {
  2391. outlimit_misc(out, out_anpp_forest, landcover_anpp[i]);
  2392. outlimit_misc(out, out_cmass_forest, landcover_cmass[i]);
  2393. outlimit_misc(out, out_dens_forest, landcover_densindiv_total[i]);
  2394. }
  2395. break;
  2396. case URBAN:
  2397. break;
  2398. case PEATLAND:
  2399. break;
  2400. default:
  2401. if (date.year == nyear_spinup)
  2402. dprintf("Modify code to deal with landcover output!\n");
  2403. }
  2404. }
  2405. }
  2406. }
  2407. // Print C fluxes to per-landcover files
  2408. if (run_landcover) {
  2409. for (int i = 0; i < NLANDCOVERTYPES; i++) {
  2410. if (run[i]) {
  2411. GuessOutput::Table* table_p = NULL;
  2412. GuessOutput::Table* table_p_N = NULL;
  2413. switch (i) {
  2414. case CROPLAND:
  2415. table_p = &out_cflux_cropland;
  2416. table_p_N = &out_nflux_cropland;
  2417. break;
  2418. case PASTURE:
  2419. table_p = &out_cflux_pasture;
  2420. table_p_N = &out_nflux_pasture;
  2421. break;
  2422. case NATURAL:
  2423. table_p = &out_cflux_natural;
  2424. table_p_N = &out_nflux_natural;
  2425. break;
  2426. case FOREST:
  2427. table_p = &out_cflux_forest;
  2428. table_p_N = &out_nflux_forest;
  2429. break;
  2430. case URBAN:
  2431. break;
  2432. case PEATLAND:
  2433. break;
  2434. case BARREN:
  2435. break;
  2436. default:
  2437. if (date.year == nyear_spinup)
  2438. dprintf("Modify code to deal with landcover output!\n");
  2439. }
  2440. if (table_p) {
  2441. outlimit_misc(out, *table_p, flux_veg_lc[i]);
  2442. outlimit_misc(out, *table_p, -flux_repr_lc[i]);
  2443. outlimit_misc(out, *table_p, flux_soil_lc[i] + c_org_leach_lc[i]);
  2444. outlimit_misc(out, *table_p, flux_fire_lc[i]);
  2445. outlimit_misc(out, *table_p, flux_est_lc[i]);
  2446. outlimit_misc(out, *table_p_N, -andep_lc[i] * m2toha);
  2447. outlimit_misc(out, *table_p_N, -anfix_lc[i] * m2toha);
  2448. outlimit_misc(out, *table_p_N, -anfert_lc[i] * m2toha);
  2449. outlimit_misc(out, *table_p_N, flux_ntot_lc[i] * m2toha);
  2450. outlimit_misc(out, *table_p_N, (n_min_leach_lc[i] + n_org_leach_lc[i]) * m2toha);
  2451. if (run_landcover) {
  2452. outlimit_misc(out, *table_p, flux_seed_lc[i]);
  2453. outlimit_misc(out, *table_p, flux_charvest_lc[i]);
  2454. outlimit_misc(out, *table_p, lc.acflux_landuse_change_lc[i]);
  2455. outlimit_misc(out, *table_p, lc.acflux_harvest_slow_lc[i]);
  2456. outlimit_misc(out, *table_p_N, flux_nseed_lc[i] * m2toha);
  2457. outlimit_misc(out, *table_p_N, flux_nharvest_lc[i] * m2toha);
  2458. outlimit_misc(out, *table_p_N, lc.anflux_landuse_change_lc[i] * m2toha);
  2459. outlimit_misc(out, *table_p_N, lc.anflux_harvest_slow_lc[i] * m2toha);
  2460. }
  2461. }
  2462. double cflux_total = flux_veg_lc[i] - flux_repr_lc[i] + flux_soil_lc[i] + flux_fire_lc[i] + flux_est_lc[i] + c_org_leach_lc[i];
  2463. double nflux_total = -andep_lc[i] - anfix_lc[i] - anfert_lc[i] + flux_ntot_lc[i] + n_min_leach_lc[i] + n_org_leach_lc[i];
  2464. if (run_landcover) {
  2465. cflux_total += flux_seed_lc[i];
  2466. cflux_total += flux_charvest_lc[i];
  2467. cflux_total += lc.acflux_landuse_change_lc[i];
  2468. cflux_total += lc.acflux_harvest_slow_lc[i];
  2469. nflux_total += flux_nseed_lc[i];
  2470. nflux_total += flux_nharvest_lc[i];
  2471. nflux_total += lc.anflux_landuse_change_lc[i];
  2472. nflux_total += lc.anflux_harvest_slow_lc[i];
  2473. }
  2474. if (table_p) {
  2475. outlimit_misc(out, *table_p, cflux_total);
  2476. outlimit_misc(out, *table_p_N, nflux_total * m2toha);
  2477. }
  2478. }
  2479. }
  2480. // Print C pools to per-landcover files
  2481. for (int i = 0; i < NLANDCOVERTYPES; i++) {
  2482. if (run[i]) {
  2483. GuessOutput::Table* table_p = NULL;
  2484. GuessOutput::Table* table_p_N = NULL;
  2485. switch (i) {
  2486. case CROPLAND:
  2487. table_p = &out_cpool_cropland;
  2488. table_p_N = &out_npool_cropland;
  2489. break;
  2490. case PASTURE:
  2491. table_p = &out_cpool_pasture;
  2492. table_p_N = &out_npool_pasture;
  2493. break;
  2494. case NATURAL:
  2495. table_p = &out_cpool_natural;
  2496. table_p_N = &out_npool_natural;
  2497. break;
  2498. case FOREST:
  2499. table_p = &out_cpool_forest;
  2500. table_p_N = &out_npool_forest;
  2501. break;
  2502. case URBAN:
  2503. break;
  2504. case PEATLAND:
  2505. break;
  2506. case BARREN:
  2507. break;
  2508. default:
  2509. if (date.year == nyear_spinup)
  2510. dprintf("Modify code to deal with landcover output!\n");
  2511. }
  2512. if (table_p) {
  2513. outlimit_misc(out, *table_p, landcover_cmass[i] * lc.frac[i]);
  2514. outlimit_misc(out, *table_p_N, (landcover_nmass[i] + landcover_nlitter[i]) * lc.frac[i]);
  2515. if (!ifcentury) {
  2516. outlimit_misc(out, *table_p, landcover_clitter[i] * lc.frac[i]);
  2517. outlimit_misc(out, *table_p, c_fast_lc[i]);
  2518. outlimit_misc(out, *table_p, c_slow_lc[i]);
  2519. }
  2520. else {
  2521. outlimit_misc(out, *table_p, landcover_clitter[i] * lc.frac[i] + surfsoillitterc_lc[i] + cwdc_lc[i]);
  2522. outlimit_misc(out, *table_p, centuryc_lc[i]);
  2523. outlimit_misc(out, *table_p_N, surfsoillittern_lc[i] + cwdn_lc[i]);
  2524. outlimit_misc(out, *table_p_N, centuryn_lc[i] + availn_lc[i]);
  2525. }
  2526. if (run_landcover && ifslowharvestpool) {
  2527. outlimit_misc(out, *table_p, c_harv_slow_lc[i]);
  2528. outlimit_misc(out, *table_p_N, n_harv_slow_lc[i]);
  2529. }
  2530. }
  2531. // Calculate total cpool, starting with cmass and litter...
  2532. double cpool_total = (landcover_cmass[i] + landcover_clitter[i]) * lc.frac[i];
  2533. double npool_total = (landcover_nmass[i] + landcover_nlitter[i]) * lc.frac[i];
  2534. // Add SOM pools
  2535. if (!ifcentury) {
  2536. cpool_total += c_fast_lc[i] + c_slow_lc[i];
  2537. }
  2538. else {
  2539. cpool_total += centuryc_lc[i] + surfsoillitterc_lc[i] + cwdc_lc[i];
  2540. npool_total += centuryn_lc[i] + surfsoillittern_lc[i] + cwdn_lc[i] + availn_lc[i];
  2541. }
  2542. // Add slow harvest pool if needed
  2543. if (run_landcover && ifslowharvestpool) {
  2544. cpool_total += c_harv_slow_lc[i];
  2545. npool_total += n_harv_slow_lc[i];
  2546. }
  2547. if (table_p) {
  2548. outlimit_misc(out, *table_p, cpool_total);
  2549. outlimit_misc(out, *table_p_N, npool_total);
  2550. }
  2551. }
  2552. }
  2553. }
  2554. // Output of seasonality variables
  2555. if (run[CROPLAND]) {
  2556. outlimit_misc(out, out_seasonality, gridcell.climate.seasonality);
  2557. outlimit_misc(out, out_seasonality, gridcell.climate.var_temp);
  2558. outlimit_misc(out, out_seasonality, gridcell.climate.var_prec);
  2559. outlimit_misc(out, out_seasonality, gridcell.climate.mtemp_min20);
  2560. outlimit_misc(out, out_seasonality, gridcell.climate.atemp_mean);
  2561. outlimit_misc(out, out_seasonality, gridcell.climate.temp_seasonality);
  2562. outlimit_misc(out, out_seasonality, gridcell.climate.mprec_petmin20);
  2563. outlimit_misc(out, out_seasonality, gridcell.climate.aprec);
  2564. outlimit_misc(out, out_seasonality, gridcell.climate.prec_range);
  2565. }
  2566. // Monthly CO2
  2567. for (int m = 0; m < 12; m++) {
  2568. outlimit_misc(out, out_mco2, gridcell.climate.mco2[m]);
  2569. }
  2570. // Annual output of CRESCENDO variables
  2571. if (printcrescendo) {
  2572. outlimit_misc(out, cresc_burntArea, burntArea);
  2573. outlimit_misc(out, cresc_cVeg, cVeg_gridcell);
  2574. outlimit_misc(out, cresc_nVeg, nVeg_gridcell);
  2575. outlimit_misc(out, cresc_cLitter, cLitter_gridcell);
  2576. outlimit_misc(out, cresc_nLitter, nLitter_gridcell);
  2577. outlimit_misc(out, cresc_cSoil, cSoil_gridcell);
  2578. outlimit_misc(out, cresc_nSoil, nSoil_gridcell + availn);
  2579. outlimit_misc(out, cresc_cProduct, cProduct_gridcell);
  2580. outlimit_misc(out, cresc_nProduct, nProduct_gridcell);
  2581. outlimit_misc(out, cresc_cLeaf, cLeaf_gridcell);
  2582. outlimit_misc(out, cresc_nLeaf, nLeaf_gridcell);
  2583. outlimit_misc(out, cresc_cRoot, cRoot_gridcell);
  2584. outlimit_misc(out, cresc_nRoot, nRoot_gridcell);
  2585. outlimit_misc(out, cresc_cWood, cWood_gridcell);
  2586. outlimit_misc(out, cresc_nWood, nWood_gridcell);
  2587. outlimit_misc(out, cresc_cCwd, cCwd_gridcell);
  2588. outlimit_misc(out, cresc_nCwd, nCwd_gridcell);
  2589. }
  2590. // Annual output of CMIP6 variables
  2591. if (printcmip6) {
  2592. for (int lc = 0; lc < NCMIP6LANDCOVERTYPES; lc++) {
  2593. outlimit_misc(out, cmip6_fracLut, fracLut[lc]);
  2594. outlimit_misc(out, cmip6_cSoilLut, fracLut[lc] > EPS ? acSoilLut[lc] / fracLut[lc] : 0.0);
  2595. outlimit_misc(out, cmip6_cVegLut, fracLut[lc] > EPS ? acVegLut[lc] / fracLut[lc] : 0.0);
  2596. outlimit_misc(out, cmip6_cLitterLut, fracLut[lc] > EPS ? acLitterLut[lc] / fracLut[lc] : 0.0);
  2597. outlimit_misc(out, cmip6_cProductLut, fracLut[lc] > EPS ? acProductLut[lc] / fracLut[lc] : 0.0);
  2598. outlimit_misc(out, cmip6_fracOutLut, fracOutLut[lc]);
  2599. outlimit_misc(out, cmip6_fracInLut, fracInLut[lc]);
  2600. }
  2601. outlimit_misc(out, cmip6_acropFrac, acropFrac);
  2602. outlimit_misc(out, cmip6_apastureFrac, apastureFrac);
  2603. outlimit_misc(out, cmip6_agrassFrac, agrassFrac);
  2604. outlimit_misc(out, cmip6_ashrubFrac, ashrubfrac);
  2605. outlimit_misc(out, cmip6_atreeFrac, atreeFrac);
  2606. outlimit_misc(out, cmip6_avegFrac, avegFrac);
  2607. outlimit_misc(out, cmip6_abaresoilFrac, abaresoilFrac);
  2608. outlimit_misc(out, cmip6_aresidualFrac, aresidualFrac);
  2609. outlimit_misc(out, cmip6_acVeg, cVeg_gridcell);
  2610. outlimit_misc(out, cmip6_acLitter, cLitter_gridcell);
  2611. outlimit_misc(out, cmip6_acSoil, cSoil_gridcell);
  2612. outlimit_misc(out, cmip6_acProduct, cProduct_gridcell);
  2613. outlimit_misc(out, cmip6_aburntFractionAll_yearly, burntArea);
  2614. for (int m = 0; m < 11; m++) {
  2615. outlimit_misc(out, cmip6_aburntFractionAll_monthly, 0);
  2616. }
  2617. outlimit_misc(out, cmip6_aburntFractionAll_monthly, burntArea);
  2618. }
  2619. outlimit_misc(out, cmip6_cyLand, gridcell.cLand);
  2620. outlimit_misc(out, cmip6_cyFlux, gridcell.cFlux);
  2621. // Monthly output CRESCENDO/CMIP6 on a single row
  2622. if (printcrescendo || printcmip6) {
  2623. double NPP_acc;
  2624. for (int m = 0; m < 12; m++) {
  2625. double mthtosec = 1.0 / secondspermonth[m];
  2626. NPP_acc = m > 0 ? NPP_acc + mnpp[m - 1] : 0.0;
  2627. if (printcrescendo) {
  2628. outlimit_misc(out, cresc_tas, gridcell.climate.mtemp_K[m]);
  2629. outlimit_misc(out, cresc_pr, gridcell.climate.mprec[m] * mthtosec);
  2630. outlimit_misc(out, cresc_rsds, gridcell.climate.mrsds[m] * mthtosec);
  2631. outlimit_misc(out, cresc_mrso, mmrso[m]);
  2632. outlimit_misc(out, cresc_mrro, mmrro[m] * mthtosec);
  2633. outlimit_misc(out, cresc_evapotrans, mevapotrans[m] * mthtosec);
  2634. outlimit_misc(out, cresc_evspsblveg, mevspsblveg[m] * mthtosec);
  2635. outlimit_misc(out, cresc_evspsblsoi, mevspsblsoi[m] * mthtosec);
  2636. outlimit_misc(out, cresc_tran, mtran[m] * mthtosec);
  2637. outlimit_misc(out, cresc_snd, msnd[m]);
  2638. outlimit_misc(out, cresc_gpp, mgpp[m] * mthtosec);
  2639. outlimit_misc(out, cresc_ra, mra[m] * mthtosec);
  2640. outlimit_misc(out, cresc_rh, mrh[m] * mthtosec);
  2641. outlimit_misc(out, cresc_npp, mnpp[m] * mthtosec);
  2642. outlimit_misc(out, cresc_nbp, mnbp[m] * mthtosec);
  2643. outlimit_misc(out, cresc_fFire, mfFire[m] * mthtosec);
  2644. outlimit_misc(out, cresc_fLuc, mfLuc[m] * mthtosec);
  2645. outlimit_misc(out, cresc_fReprEst, mreprest[m] * mthtosec);
  2646. outlimit_misc(out, cresc_fSeed, mseed[m] * mthtosec);
  2647. outlimit_misc(out, cresc_fHarv, mharv[m] * mthtosec);
  2648. outlimit_misc(out, cresc_harvcrop, mharvcrop[m] * mthtosec);
  2649. outlimit_misc(out, cresc_harvgraz, mharvgraz[m] * mthtosec);
  2650. outlimit_misc(out, cresc_prod, mfProductDecomp[m] * mthtosec);
  2651. outlimit_misc(out, cresc_fNdep, mfNdep[m] * mthtosec);
  2652. outlimit_misc(out, cresc_fBNF, mfBNF[m] * mthtosec);
  2653. outlimit_misc(out, cresc_fNup, mfNup[m] * mthtosec);
  2654. outlimit_misc(out, cresc_fNnetmin, mfNnetmin[m] * mthtosec);
  2655. outlimit_misc(out, cresc_fNleach, mfNleach[m] * mthtosec);
  2656. outlimit_misc(out, cresc_fCleach, mfCleach[m] * mthtosec);
  2657. outlimit_misc(out, cresc_fNgas, mfNgas[m] * mthtosec);
  2658. outlimit_misc(out, cresc_fNgasFire, mfNgasFire[m] * mthtosec);
  2659. outlimit_misc(out, cresc_fN2O, mfN2O[m] * mthtosec);
  2660. outlimit_misc(out, cresc_fNOx, mfNOx[m] * mthtosec);
  2661. outlimit_misc(out, cresc_fNloss, mfNloss[m] * mthtosec);
  2662. outlimit_misc(out, cresc_fVegLitter, mfVegLitter[m] * mthtosec);
  2663. outlimit_misc(out, cresc_fNVegLitter, mfNVegLitter[m] * mthtosec);
  2664. outlimit_misc(out, cresc_fLitterSoil, mfLitterSoil[m] * mthtosec);
  2665. outlimit_misc(out, cresc_fNLitterSoil, mfNLitterSoil[m] * mthtosec);
  2666. outlimit_misc(out, cresc_tsl, mtsl[m]);
  2667. }
  2668. if (printcmip6) {
  2669. mvegFrac[m] = mtreeFrac[m] + mgrassFrac[m] + mshrubFrac[m] + mcropFrac[m] + mpastureFrac[m];
  2670. mbaresoilFrac[m] = max(0.0, total_land - (mvegFrac[m] + mresidualFrac[m]));
  2671. outlimit_misc(out, cmip6_treeFrac, mtreeFrac[m]);
  2672. outlimit_misc(out, cmip6_grassFrac, mgrassFrac[m]);
  2673. outlimit_misc(out, cmip6_shrubFrac, mshrubFrac[m]);
  2674. outlimit_misc(out, cmip6_cropFrac, mcropFrac[m]);
  2675. outlimit_misc(out, cmip6_pastureFrac, mpastureFrac[m]);
  2676. outlimit_misc(out, cmip6_vegFrac, mvegFrac[m]);
  2677. outlimit_misc(out, cmip6_baresoilFrac, mbaresoilFrac[m]);
  2678. outlimit_misc(out, cmip6_residualFrac, mresidualFrac[m]);
  2679. outlimit_misc(out, cmip6_pastureFracC3, mpastureFracC3[m]);
  2680. outlimit_misc(out, cmip6_pastureFracC4, mpastureFracC4[m]);
  2681. outlimit_misc(out, cmip6_grassFracC3, mgrassFracC3[m]);
  2682. outlimit_misc(out, cmip6_grassFracC4, mgrassFracC4[m]);
  2683. outlimit_misc(out, cmip6_cropFracC3, mcropFracC3[m]);
  2684. outlimit_misc(out, cmip6_cropFracC4, mcropFracC4[m]);
  2685. outlimit_misc(out, cmip6_lai, mlai[m]);
  2686. outlimit_misc(out, cmip6_cVeg, mcVeg[m]);
  2687. outlimit_misc(out, cmip6_cLeaf, mcLeaf[m]);
  2688. outlimit_misc(out, cmip6_cRoot, mcRoot[m]);
  2689. outlimit_misc(out, cmip6_cStem, mcStem[m]);
  2690. outlimit_misc(out, cmip6_cWood, mcStem[m]);
  2691. outlimit_misc(out, cmip6_cOther, mcOther[m] + mcOtherNPP[m] + mcOtherPhen[m]);
  2692. outlimit_misc(out, cmip6_cLitter, mcLitter[m]);
  2693. outlimit_misc(out, cmip6_cLitterCwd, mcLitterCwd[m]);
  2694. outlimit_misc(out, cmip6_cCwd, 0.0); // dead organic matter composed of coarse wood. It is distinct from litter.
  2695. outlimit_misc(out, cmip6_cLitterSurf, mcLitterSurf[m]);
  2696. outlimit_misc(out, cmip6_cLitterAbove, mcLitterAbove[m]);
  2697. outlimit_misc(out, cmip6_cLitterSubSurf, mcLitterSubSurf[m]);
  2698. outlimit_misc(out, cmip6_cLitterBelow, mcLitterBelow[m]);
  2699. outlimit_misc(out, cmip6_cSoil, mcSoil[m]);
  2700. outlimit_misc(out, cmip6_cSoilFast, mcFast[m]);
  2701. outlimit_misc(out, cmip6_cSoilMedium, mcMedium[m]);
  2702. outlimit_misc(out, cmip6_cSoilSlow, mcSlow[m]);
  2703. outlimit_misc(out, cmip6_cProduct, mcProduct[m]);
  2704. outlimit_misc(out, cmip6_cLand, mcLand[m]);
  2705. outlimit_misc(out, cmip6_nVeg, mnVeg[m]);
  2706. outlimit_misc(out, cmip6_nLeaf, mnLeaf[m]);
  2707. outlimit_misc(out, cmip6_nRoot, mnRoot[m]);
  2708. outlimit_misc(out, cmip6_nStem, mnStem[m]);
  2709. outlimit_misc(out, cmip6_nOther, mnOther[m]);
  2710. outlimit_misc(out, cmip6_nLitter, mnLitter[m]);
  2711. outlimit_misc(out, cmip6_nLitterCwd, mnLitterCwd[m]);
  2712. outlimit_misc(out, cmip6_nLitterSurf, mnLitterSurf[m]);
  2713. outlimit_misc(out, cmip6_nLitterSubSurf, mnLitterSubSurf[m]);
  2714. outlimit_misc(out, cmip6_nSoil, mnSoil[m]);
  2715. outlimit_misc(out, cmip6_nProduct, mnProduct[m]);
  2716. outlimit_misc(out, cmip6_nLand, mnLand[m]);
  2717. outlimit_misc(out, cmip6_nMinNH4, mnMinNH4[m]);
  2718. outlimit_misc(out, cmip6_nMinNO3, mnMinNO3[m]);
  2719. outlimit_misc(out, cmip6_nMineral, mnMinNH4[m] + mnMinNO3[m]);
  2720. outlimit_misc(out, cmip6_fN2O, mfN2O[m] * mthtosec);
  2721. outlimit_misc(out, cmip6_fNOx, mfNOx[m] * mthtosec);
  2722. outlimit_misc(out, cmip6_nbp, mnbp[m] * mthtosec);
  2723. outlimit_misc(out, cmip6_netAtmosLandCO2Flux, mnbp[m] * mthtosec);
  2724. outlimit_misc(out, cmip6_nep, mnep[m] * mthtosec);
  2725. outlimit_misc(out, cmip6_gpp, mgpp[m] * mthtosec);
  2726. outlimit_misc(out, cmip6_gppGrass, mgppGrass[m] * mthtosec);
  2727. outlimit_misc(out, cmip6_gppTree, mgppTree[m] * mthtosec);
  2728. outlimit_misc(out, cmip6_ra, mra[m] * mthtosec);
  2729. outlimit_misc(out, cmip6_rh, mrh[m] * mthtosec);
  2730. outlimit_misc(out, cmip6_npp, mnpp[m] * mthtosec);
  2731. outlimit_misc(out, cmip6_nppGrass, (mgppGrass[m] - mraGrass[m]) * mthtosec);
  2732. outlimit_misc(out, cmip6_nppTree, (mgppTree[m] - mraTree[m]) * mthtosec);
  2733. outlimit_misc(out, cmip6_rhSoil, mrhsoil[m] * mthtosec);
  2734. outlimit_misc(out, cmip6_rhLitter, mrhlitter[m] * mthtosec);
  2735. outlimit_misc(out, cmip6_fCLandToOcean, mfCleach[m] * mthtosec);
  2736. outlimit_misc(out, cmip6_fNLandToOcean, mfNleach[m] * mthtosec);
  2737. outlimit_misc(out, cmip6_raLeaf, mraleaf[m] * mthtosec);
  2738. outlimit_misc(out, cmip6_raRoot, mraroot[m] * mthtosec);
  2739. outlimit_misc(out, cmip6_raStem, mrastem[m] * mthtosec);
  2740. outlimit_misc(out, cmip6_raOther, mraother[m] * mthtosec);
  2741. outlimit_misc(out, cmip6_raGrass, mraGrass[m] * mthtosec);
  2742. outlimit_misc(out, cmip6_raTree, mraTree[m] * mthtosec);
  2743. outlimit_misc(out, cmip6_rGrowth, mraother[m] * mthtosec);
  2744. outlimit_misc(out, cmip6_rMaint, (mra[m] - mraother[m]) * mthtosec);
  2745. outlimit_misc(out, cmip6_fVegLitter, mfVegLitter[m] * mthtosec);
  2746. outlimit_misc(out, cmip6_fVegOther, (mreprest[m] + mseed[m] + mharv[m]) * mthtosec);
  2747. outlimit_misc(out, cmip6_fNVegLitter, mfNVegLitter[m] * mthtosec);
  2748. outlimit_misc(out, cmip6_fLitterSoil, mfLitterSoil[m] * mthtosec);
  2749. outlimit_misc(out, cmip6_fNLitterSoil, mfNLitterSoil[m] * mthtosec);
  2750. outlimit_misc(out, cmip6_fFireNat, mfFire[m] * mthtosec);
  2751. outlimit_misc(out, cmip6_fFire, mfFire[m] * mthtosec);
  2752. outlimit_misc(out, cmip6_fVegFire, mfVegFire[m] * mthtosec);
  2753. outlimit_misc(out, cmip6_fLitterFire, mfLitterFire[m] * mthtosec);
  2754. outlimit_misc(out, cmip6_fFireAll, (mfFire[m] + mfLuc[m]) * mthtosec);
  2755. outlimit_misc(out, cmip6_fAnthDisturb, (mfLuc[m] + mharv[m]) * mthtosec);
  2756. outlimit_misc(out, cmip6_fHarvestToAtmos, mharv[m] * mthtosec);
  2757. outlimit_misc(out, cmip6_fDeforestToAtmos, mcfLucdeforest[m] * mthtosec);
  2758. outlimit_misc(out, cmip6_fluc, mfLuc[m] * mthtosec);
  2759. outlimit_misc(out, cmip6_fHarvest, mharv[m] * mthtosec);
  2760. outlimit_misc(out, cmip6_fDeforestToProduct, mfDeforestToProduct[m] * mthtosec);
  2761. outlimit_misc(out, cmip6_fProductDecomp, mfProductDecomp[m] * mthtosec);
  2762. outlimit_misc(out, cmip6_fco2antt, mfco2antt[m] * mthtosec);
  2763. outlimit_misc(out, cmip6_fco2nat, mfco2nat[m] * mthtosec);
  2764. outlimit_misc(out, cmip6_fNProduct, mfNProduct[m] * mthtosec);
  2765. outlimit_misc(out, cmip6_fNAnthDisturb, (mnfLuc[m] + mnharv[m]) * mthtosec);
  2766. outlimit_misc(out, cmip6_fGrazing, mharvgraz[m] * mthtosec);
  2767. outlimit_misc(out, cmip6_fBNF, mfBNF[m] * mthtosec);
  2768. outlimit_misc(out, cmip6_fNloss, mfNloss[m] * mthtosec);
  2769. outlimit_misc(out, cmip6_fNfert, mnfert[m] * mthtosec);
  2770. outlimit_misc(out, cmip6_fNup, mfNup[m] * mthtosec);
  2771. outlimit_misc(out, cmip6_fNnetmin, mfNnetmin[m] * mthtosec);
  2772. outlimit_misc(out, cmip6_fNleach, mfNleach[m] * mthtosec);
  2773. outlimit_misc(out, cmip6_fNgas, mfNgas[m] * mthtosec);
  2774. outlimit_misc(out, cmip6_fNdep, mfNdep[m] * mthtosec);
  2775. outlimit_misc(out, cmip6_fNgasFire, mfNgasFire[m] * mthtosec);
  2776. outlimit_misc(out, cmip6_fNgasNonFire, (mfNgas[m] - mfNgasFire[m]) * mthtosec);
  2777. outlimit_misc(out, cmip6_mrso, mmrso[m]);
  2778. outlimit_misc(out, cmip6_evspsbl, mevapotrans[m] * mthtosec);
  2779. outlimit_misc(out, cmip6_evspsblveg, mevspsblveg[m] * mthtosec);
  2780. outlimit_misc(out, cmip6_prveg, mevspsblveg[m] * mthtosec);
  2781. outlimit_misc(out, cmip6_evspsblsoi, mevspsblsoi[m] * mthtosec);
  2782. outlimit_misc(out, cmip6_evspsblpot, mevspsblpot[m] * mthtosec);
  2783. outlimit_misc(out, cmip6_tran, mtran[m] * mthtosec);
  2784. outlimit_misc(out, cmip6_mrro, mmrro[m] * mthtosec);
  2785. outlimit_misc(out, cmip6_mrros, mmrros[m] * mthtosec);
  2786. outlimit_misc(out, cmip6_prCrop, mprecip[m] * mthtosec);
  2787. outlimit_misc(out, cmip6_mrsos, mmrsos[m]);
  2788. outlimit_misc(out, cmip6_treeFracBdlDcd, mBdlDcd[m]);
  2789. outlimit_misc(out, cmip6_treeFracBdlEvg, mBdlEvg[m]);
  2790. outlimit_misc(out, cmip6_treeFracNdlDcd, mNdlDcd[m]);
  2791. outlimit_misc(out, cmip6_treeFracNdlEvg, mNdlEvg[m]);
  2792. outlimit_misc(out, cmip6_vegHeightTree, min(99.9, treefpc > 0.0 ? vegHeightTree / treefpc : 0.0));
  2793. outlimit_misc(out, cmip6_cLand1, gridcell.mcLand1[m] + NPP_acc);
  2794. }
  2795. }
  2796. }
  2797. // Montly output for CRESCENDO/CMIP6 on multiple rows
  2798. if (printcrescendo || printcmip6) {
  2799. for (int m = 0; m < 12; m++) {
  2800. OutputRows out(output_channel, lon, lat, date.get_calendar_year(), CTMONTH, m + 1);
  2801. double mthtosec = 1.0 / secondspermonth[m];
  2802. double bare_soil = total_land;
  2803. pftlist.firstobj();
  2804. while (pftlist.isobj) {
  2805. Pft& pft = pftlist.getobj();
  2806. if (printcrescendo) {
  2807. outlimit_misc(out, cresc_lai, pft_mlcf[m][pft.id] > 0 ? pft_mlai[m][pft.id] / pft_mlcf[m][pft.id] : 0);
  2808. outlimit_misc(out, cresc_lcf, pft_mlcf[m][pft.id]);
  2809. outlimit_misc(out, cresc_fapar, pft_mfapar[m][pft.id]);
  2810. if (pft.lifeform == TREE) {
  2811. outlimit_misc(out, cresc_vH, pft_vegheight[pft.id]);
  2812. outlimit_misc(out, cresc_tD, pft_treedens[pft.id]);
  2813. }
  2814. }
  2815. if (printcmip6) {
  2816. outlimit_misc(out, cmip6_landCoverFrac, pft_mlcf[m][pft.id]);
  2817. }
  2818. bare_soil -= pft_mlcf[m][pft.id]; // reduce total land to represent bare soil
  2819. pftlist.nextobj();
  2820. }
  2821. if (printcrescendo) {
  2822. outlimit_misc(out, cresc_lcf, bare_soil);
  2823. }
  2824. if (printcmip6) {
  2825. outlimit_misc(out, cmip6_landCoverFrac, bare_soil);
  2826. }
  2827. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  2828. if (printcrescendo) {
  2829. outlimit_misc(out, cresc_msl, mmsl[m][lyr]);
  2830. }
  2831. if (printcmip6) {
  2832. outlimit_misc(out, cmip6_mrsol, mmsl[m][lyr]);
  2833. outlimit_misc(out, cmip6_mrsll, mmsl[m][lyr]);
  2834. outlimit_misc(out, cmip6_tsl, mtsl[m]);
  2835. }
  2836. }
  2837. if (printcmip6) {
  2838. for (int lc = 0; lc < NCMIP6LANDCOVERTYPES; lc++) {
  2839. outlimit_misc(out, cmip6_mfracLut, fracLut[lc]);
  2840. outlimit_misc(out, cmip6_cTotFireLut, fracLut[lc] > EPS ? mcTotFireLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2841. outlimit_misc(out, cmip6_fLulccAtmLut, fracLut[lc] > EPS ? mfLulccAtmLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2842. outlimit_misc(out, cmip6_fLulccProductLut, fracLut[lc] > EPS ? mfLulccProductLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2843. outlimit_misc(out, cmip6_fLulccResidueLut, fracLut[lc] > EPS ? mfLulccResidueLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2844. outlimit_misc(out, cmip6_fProductDecompLut, fracLut[lc] > EPS ? mfProductDecompLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2845. outlimit_misc(out, cmip6_gppLut, fracLut[lc] > EPS ? mgppLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2846. outlimit_misc(out, cmip6_irrLut, fracLut[lc] > EPS ? mirrLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2847. outlimit_misc(out, cmip6_laiLut, fracLut[lc] > EPS ? mlaiLut[lc][m] / fracLut[lc] : 0.0);
  2848. outlimit_misc(out, cmip6_mrroLut, fracLut[lc] > EPS ? mrroLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2849. outlimit_misc(out, cmip6_mrsoLut, fracLut[lc] > EPS ? mrsoLut[lc][m] / fracLut[lc] : 0.0);
  2850. outlimit_misc(out, cmip6_mrsosLut, fracLut[lc] > EPS ? mrsosLut[lc][m] / fracLut[lc] : 0.0);
  2851. outlimit_misc(out, cmip6_necbLut, fracLut[lc] > EPS ? mnecbLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2852. outlimit_misc(out, cmip6_nppLut, fracLut[lc] > EPS ? mnppLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2853. outlimit_misc(out, cmip6_nwdFracLut, fracLut[lc] > EPS ? mnwdFracLut[lc][m] / fracLut[lc] : 0.0);
  2854. outlimit_misc(out, cmip6_raLut, fracLut[lc] > EPS ? mraLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2855. outlimit_misc(out, cmip6_rhLut, fracLut[lc] > EPS ? mrhLut[lc][m] / fracLut[lc] * mthtosec : 0.0);
  2856. }
  2857. }
  2858. }
  2859. }
  2860. // Daily output for CRESCENDO/CMIP6
  2861. if (printcrescendodaily || printcmip6daily || printcrescendofacedaily) {
  2862. for (int d = 0; d < date.year_length(); d++) {
  2863. OutputRows out(output_channel, lon, lat, date.get_calendar_year(), CTDAY, d+1);
  2864. double daytosec = 1.0 / secondsperday;
  2865. if (printcrescendodaily) {
  2866. outlimit_misc(out, cresc_dlai, dlai[d]);
  2867. }
  2868. #ifdef CRESCENDO_FACE
  2869. if (printcrescendofacedaily) {
  2870. outlimit_misc(out, face_co2, gridcell.climate.co2_daily[d]);
  2871. outlimit_misc(out, face_ppt, gridcell.climate.ppt_daily[d]);
  2872. outlimit_misc(out, face_par, gridcell.climate.par_daily[d]);
  2873. outlimit_misc(out, face_at, gridcell.climate.at_daily[d]);
  2874. outlimit_misc(out, face_st, dtsl[d][0] - K2degC);
  2875. outlimit_misc(out, face_sw, 100.0 * dmrso[d] / awc_tot);
  2876. outlimit_misc(out, face_ndep, gridcell.climate.ndep_daily[d] * kgtog);
  2877. outlimit_misc(out, face_et, (daet[d] + devap[d]) * daytosec);
  2878. outlimit_misc(out, face_t, daet[d] * daytosec);
  2879. outlimit_misc(out, face_es, devap[d] * daytosec);
  2880. outlimit_misc(out, face_ec, dintercep[d] * daytosec);
  2881. outlimit_misc(out, face_ro, drunoff[d]);
  2882. outlimit_misc(out, face_drain, ddrain[d]);
  2883. outlimit_misc(out, face_nep, (dnpp[d] - drhet[d]) * kgtog);
  2884. outlimit_misc(out, face_gpp, dgpp[d] * kgtog);
  2885. outlimit_misc(out, face_npp, dnpp[d] * kgtog);
  2886. outlimit_misc(out, face_reco, (drhet[d] + (dgpp[d] - dnpp[d])) * kgtog);
  2887. outlimit_misc(out, face_rauto, (dgpp[d] - dnpp[d]) * kgtog);
  2888. outlimit_misc(out, face_rhet, drhet[d] * kgtog);
  2889. outlimit_misc(out, face_rsoil, drhet[d] * kgtog);
  2890. outlimit_misc(out, face_rother, dother[d] * kgtog);
  2891. outlimit_misc(out, face_rleaf, drleaf[d] * kgtog);
  2892. outlimit_misc(out, face_rroot, drroot[d] * kgtog);
  2893. outlimit_misc(out, face_rwood, drwood[d] * kgtog);
  2894. outlimit_misc(out, face_rgrow, drgrowth[d] * kgtog);
  2895. outlimit_misc(out, face_cl, dcleaf[d] * kgtog);
  2896. outlimit_misc(out, face_cw, dcwood[d] * kgtog);
  2897. outlimit_misc(out, face_cfr, dcroot[d] * kgtog);
  2898. outlimit_misc(out, face_tnc, dcother[d] * kgtog);
  2899. outlimit_misc(out, face_ncon, dnleaf[d] > 0.0 ? dcleaf[d] / dnleaf[d] : 0.0);
  2900. outlimit_misc(out, face_ncan, dnleaf[d] * kgtog);
  2901. outlimit_misc(out, face_nwood, dnwood[d] * kgtog);
  2902. outlimit_misc(out, face_nfr, dnroot[d] * kgtog);
  2903. outlimit_misc(out, face_nstor, dnother[d] * kgtog);
  2904. outlimit_misc(out, face_lai, dlai[d]);
  2905. outlimit_misc(out, face_lma, !negligible(dlai[d]) ? dcleaf[d] * kgtog / dlai[d] : 0.0);
  2906. outlimit_misc(out, face_cflit, (dcflita[d] + dcflitb[d]) * kgtog);
  2907. outlimit_misc(out, face_cflita, dcflita[d] * kgtog);
  2908. outlimit_misc(out, face_nlit, dnlit[d] * kgtog);
  2909. outlimit_misc(out, face_cflitb, dcflitb[d] * kgtog);
  2910. outlimit_misc(out, face_nrlit, dnrlit[d] * kgtog);
  2911. outlimit_misc(out, face_cclitb, dcclitb[d] * kgtog);
  2912. outlimit_misc(out, face_ndw, dndw[d] * kgtog);
  2913. outlimit_misc(out, face_csoil, dcsoil[d] * kgtog);
  2914. outlimit_misc(out, face_nsoil, (dnsoil[d] + dnmineral[d]) * kgtog);
  2915. outlimit_misc(out, face_npoolm, dnmineral[d] * kgtog);
  2916. outlimit_misc(out, face_npoolo, dnsoil[d] * kgtog);
  2917. outlimit_misc(out, face_nfix, dnfix[d] * kgtog);
  2918. outlimit_misc(out, face_nup, dnup[d] * kgtog);
  2919. outlimit_misc(out, face_ngmin, dngmin[d] * kgtog);
  2920. outlimit_misc(out, face_nmin, dnmin[d] * kgtog);
  2921. outlimit_misc(out, face_nvol, dnvol[d] * kgtog);
  2922. outlimit_misc(out, face_nleach, dnleach[d] * kgtog);
  2923. outlimit_misc(out, face_gl, dgl[d] * kgtog);
  2924. outlimit_misc(out, face_gw, dgw[d] * kgtog);
  2925. outlimit_misc(out, face_gr, dgr[d] * kgtog);
  2926. outlimit_misc(out, face_ngl, dngl[d] * kgtog);
  2927. outlimit_misc(out, face_ngw, dngw[d] * kgtog);
  2928. outlimit_misc(out, face_ngr, dngr[d] * kgtog);
  2929. outlimit_misc(out, face_nlitin, dnlitin[d] * kgtog);
  2930. outlimit_misc(out, face_nwlin, dnwlin[d] * kgtog);
  2931. outlimit_misc(out, face_nrlin, dnrlin[d] * kgtog);
  2932. outlimit_misc(out, face_cllfall, dcllfall[d] * kgtog);
  2933. outlimit_misc(out, face_crlin, dcrlin[d] * kgtog);
  2934. outlimit_misc(out, face_cwin, dcwin[d] * kgtog);
  2935. }
  2936. #endif
  2937. if (printcmip6daily) {
  2938. outlimit_misc(out, cmip6_dlai, dlai[d]);
  2939. outlimit_misc(out, cmip6_devspsblpot, dpet[d] * daytosec);
  2940. outlimit_misc(out, cmip6_dprCrop, dprecip[d] * daytosec);
  2941. outlimit_misc(out, cmip6_dtran, daet[d] * daytosec);
  2942. outlimit_misc(out, cmip6_dec, dintercep[d] * daytosec);
  2943. outlimit_misc(out, cmip6_dprveg, dintercep[d] * daytosec);
  2944. outlimit_misc(out, cmip6_det, (daet[d] + devap[d]) * daytosec);
  2945. outlimit_misc(out, cmip6_dmrso, dmrsol[d][0] + dmrsol[d][1]);
  2946. outlimit_misc(out, cmip6_dmrsos, dmrsol[d][0]);
  2947. outlimit_misc(out, cmip6_dmrro, dmrro[d] * daytosec);
  2948. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  2949. outlimit_misc(out, cmip6_dmrsol, dmrsol[d][lyr]);
  2950. outlimit_misc(out, cmip6_dtsl, dtsl[d][lyr]);
  2951. outlimit_misc(out, cmip6_dmrsll, dmrsll[d][lyr]);
  2952. }
  2953. }
  2954. }
  2955. }
  2956. // IFS data sent to LPJ-GUESS - daily output
  2957. if (printifsinputdaily) {
  2958. for (int d = 0; d < date.year_length(); d++) {
  2959. OutputRows out(output_channel, lon, lat, date.get_calendar_year(), CTDAY, d+1);
  2960. outlimit_misc(out, ifs_input, gridcell.ifs_co2[d]);
  2961. outlimit_misc(out, ifs_input, gridcell.ifs_par[d]);
  2962. outlimit_misc(out, ifs_input, gridcell.ifs_lw[d]);
  2963. outlimit_misc(out, ifs_input, gridcell.ifs_precip[d]);
  2964. outlimit_misc(out, ifs_input, gridcell.ifs_temp2m[d]);
  2965. outlimit_misc(out, ifs_input, gridcell.ifs_tempsoil[d]);
  2966. outlimit_misc(out, ifs_input, gridcell.ifs_soilw_surf[d]);
  2967. outlimit_misc(out, ifs_input, gridcell.ifs_soilw_deep[d]);
  2968. }
  2969. }
  2970. // Monthly output of lambda
  2971. for (int m = 0; m < 12; m++) {
  2972. OutputRows out(output_channel, lon, lat, date.get_calendar_year(), CTMONTH, m+1);
  2973. for (int q = 0; q < npft; q++) {
  2974. outlimit_misc(out, out_mlambda, !negligible(pft_mgpp[m][q]) ? pft_mlambda_gpp[m][q] / pft_mgpp[m][q] : 0.0);
  2975. }
  2976. }
  2977. }
  2978. /// Output of simulation results at the end of each day
  2979. /** This function does not have to provide any information to the framework.
  2980. */
  2981. void MiscOutput::outdaily(Gridcell& gridcell) {
  2982. double lon = gridcell.get_lon();
  2983. double lat = gridcell.get_lat();
  2984. OutputRows out(output_channel, lon, lat, date.get_calendar_year(), CTDAY, date.day);
  2985. if (date.year < nyear_spinup) {
  2986. return;
  2987. }
  2988. Climate& climate = gridcell.climate;
  2989. // reset mean monthly temperature output
  2990. if (date.day == 0) {
  2991. if (printcrescendo || printcmip6) {
  2992. for (int m = 0; m < 12; m++) {
  2993. climate.mtemp_K[m] = 0.0;
  2994. climate.mprec[m] = 0.0;
  2995. climate.mrsds[m] = 0.0;
  2996. }
  2997. for (int d = 0; d < date.year_length(); d++) {
  2998. climate.dprec[d] = 0.0;
  2999. }
  3000. }
  3001. #ifdef CRESCENDO_FACE
  3002. if (printcrescendofacedaily) {
  3003. for (int d = 0; d < date.year_length(); d++) {
  3004. climate.co2_daily[d] = 0.0;
  3005. climate.ppt_daily[d] = 0.0;
  3006. climate.par_daily[d] = 0.0;
  3007. climate.at_daily[d] = 0.0;
  3008. climate.ndep_daily[d] = 0.0;
  3009. }
  3010. }
  3011. #endif
  3012. }
  3013. // CRESCENDO and CMIP6 outputs
  3014. if (printcrescendo || printcmip6) {
  3015. climate.mtemp_K[date.month] += (climate.temp + K2degC) / (double)date.month_length(date.month);
  3016. climate.mprec[date.month] += climate.prec;
  3017. climate.mrsds[date.month] += climate.rad;
  3018. climate.dprec[date.day] = climate.prec;
  3019. }
  3020. #ifdef CRESCENDO_FACE
  3021. if (printcrescendofacedaily) {
  3022. climate.co2_daily[date.day] = climate.co2;
  3023. climate.ppt_daily[date.day] = climate.prec;
  3024. climate.par_daily[date.day] = climate.par * 0.00000456; // 1 J/s == 4.56*10-6 Mol/s in Daylight
  3025. climate.at_daily[date.day] = climate.temp;
  3026. climate.ndep_daily[date.day] = climate.dndep;
  3027. }
  3028. #endif
  3029. pftlist.firstobj();
  3030. while (pftlist.isobj) {
  3031. Pft& pft = pftlist.getobj();
  3032. if (pft.landcover != CROPLAND) {
  3033. pftlist.nextobj();
  3034. continue;
  3035. }
  3036. Gridcell::iterator gc_itr = gridcell.begin();
  3037. while (gc_itr != gridcell.end()) {
  3038. Stand& stand = *gc_itr;
  3039. if (stand.landcover != CROPLAND || stand.npatch() > 1) {
  3040. break;
  3041. }
  3042. stand.firstobj();
  3043. while (stand.isobj) {
  3044. Patch& patch = stand.getobj();
  3045. Vegetation& vegetation = patch.vegetation;
  3046. Patchpft& patchpft = patch.pft[pft.id];
  3047. double cwdn = patch.soil.sompool[SURFCWD].nmass + patch.soil.sompool[SURFFWD].nmass;
  3048. vegetation.firstobj();
  3049. while (vegetation.isobj) {
  3050. Individual& indiv = vegetation.getobj();
  3051. if (indiv.id != -1 && indiv.pft.id == pft.id) {//&& !indiv.cropindiv->isintercropgrass) {
  3052. //To be able to print values for the year after establishment of crops !
  3053. // (if not dead and has existed for at least one year)
  3054. // Ben 2007-11-28
  3055. plot("daily leaf N [g/m2]", pft.name, date.day, indiv.nmass_leaf*m2toha);
  3056. plot("daily leaf C [kg/m2]", pft.name, date.day, indiv.cmass_leaf_today()*m2toha);
  3057. outlimit_misc(out, out_daily_lai, indiv.lai_today());
  3058. outlimit_misc(out, out_daily_npp, indiv.dnpp*m2toha);
  3059. outlimit_misc(out, out_daily_cmass_leaf, indiv.cmass_leaf_today()*m2toha);
  3060. outlimit_misc(out, out_daily_nmass_leaf, indiv.nmass_leaf*m2toha);
  3061. outlimit_misc(out, out_daily_cmass_root, indiv.cmass_root_today()*m2toha);
  3062. outlimit_misc(out, out_daily_nmass_root, indiv.nmass_root*m2toha);
  3063. outlimit_misc(out, out_daily_avail_nmass_soil, m2toha*(patch.soil.nmass_avail + cwdn));
  3064. outlimit_misc(out, out_daily_n_input_soil, patch.soil.ninput*m2toha);
  3065. double uw = patch.soil.dwcontupper[date.day];
  3066. if (uw < 1e-22) {
  3067. uw = 0.0;
  3068. }
  3069. // double lw = patch.soil.dwcontlower[date.day];
  3070. double lw = patch.soil.dwcontlower_today;
  3071. if (lw < 1e-22) {
  3072. lw = 0.0;
  3073. }
  3074. outlimit_misc(out, out_daily_upper_wcont, uw);
  3075. outlimit_misc(out, out_daily_lower_wcont, lw);
  3076. outlimit_misc(out, out_daily_irrigation, patch.irrigation_d);
  3077. outlimit_misc(out, out_daily_cmass_storage, indiv.cropindiv->grs_cmass_ho*m2toha);
  3078. outlimit_misc(out, out_daily_nmass_storage, indiv.cropindiv->nmass_ho*m2toha);
  3079. outlimit_misc(out, out_daily_ndemand, indiv.ndemand);
  3080. outlimit_misc(out, out_daily_cton, limited_cton(indiv.cmass_leaf_today(), indiv.nmass_leaf*m2toha));
  3081. if (ifnlim) {
  3082. outlimit_misc(out, out_daily_ds, patch.pft[pft.id].cropphen->dev_stage); // daglig ds
  3083. outlimit_misc(out, out_daily_cmass_stem, (indiv.cropindiv->grs_cmass_agpool + indiv.cropindiv->grs_cmass_stem)*m2toha);
  3084. outlimit_misc(out, out_daily_nmass_stem, indiv.cropindiv->nmass_agpool*m2toha);
  3085. outlimit_misc(out, out_daily_cmass_dead_leaf, indiv.cropindiv->grs_cmass_dead_leaf*m2toha);
  3086. outlimit_misc(out, out_daily_nmass_dead_leaf, indiv.cropindiv->nmass_dead_leaf*m2toha);
  3087. outlimit_misc(out, out_daily_fphu, patch.pft[pft.id].cropphen->fphu);
  3088. outlimit_misc(out, out_daily_stem, patch.pft[pft.id].cropphen->f_alloc_stem);
  3089. outlimit_misc(out, out_daily_leaf, patch.pft[pft.id].cropphen->f_alloc_leaf);
  3090. outlimit_misc(out, out_daily_root, patch.pft[pft.id].cropphen->f_alloc_root);
  3091. outlimit_misc(out, out_daily_storage, patch.pft[pft.id].cropphen->f_alloc_horg);
  3092. }
  3093. }
  3094. vegetation.nextobj();
  3095. }
  3096. stand.nextobj();
  3097. }
  3098. ++gc_itr;
  3099. }
  3100. pftlist.nextobj();
  3101. }
  3102. outlimit_misc(out, out_daily_temp, gridcell.climate.temp);
  3103. outlimit_misc(out, out_daily_prec, gridcell.climate.prec);
  3104. outlimit_misc(out, out_daily_rad, gridcell.climate.rad);
  3105. // CRESCENDO/CMIP6 output variables
  3106. // Daily and summed monthly C and N pools across patches
  3107. if (printcrescendo || printcmip6 || printcrescendofacedaily) {
  3108. Gridcell::iterator gc_itr = gridcell.begin();
  3109. // Loop through Stands
  3110. while (gc_itr != gridcell.end()) {
  3111. Stand& stand = *gc_itr;
  3112. stand.firstobj();
  3113. //Loop through Patches
  3114. while (stand.isobj) {
  3115. Patch& patch = stand.getobj();
  3116. Soil& soil = patch.soil;
  3117. Vegetation& vegetation = patch.vegetation;
  3118. double to_gridcell_average = stand.get_gridcell_fraction() / (double)stand.npatch();
  3119. if (date.day == 0) {
  3120. for (int m = 0; m < 12; m++) {
  3121. patch.mcVeg[m] = 0.0;
  3122. patch.mnVeg[m] = 0.0;
  3123. patch.mcLeaf[m] = 0.0;
  3124. patch.mnLeaf[m] = 0.0;
  3125. patch.mcRoot[m] = 0.0;
  3126. patch.mnRoot[m] = 0.0;
  3127. patch.mcStem[m] = 0.0;
  3128. patch.mnStem[m] = 0.0;
  3129. patch.mcOther[m] = 0.0;
  3130. patch.mcOtherPhen[m] = 0.0;
  3131. patch.mnOther[m] = 0.0;
  3132. patch.mcProduct[m] = 0.0;
  3133. patch.mnProduct[m] = 0.0;
  3134. patch.mcLand[m] = 0.0;
  3135. patch.mnLand[m] = 0.0;
  3136. soil.msnd[m] = 0.0;
  3137. soil.mcLitter[m] = 0.0;
  3138. soil.mcLitterCwd[m] = 0.0;
  3139. soil.mcLitterSurf[m] = 0.0;
  3140. soil.mcLitterSubSurf[m] = 0.0;
  3141. soil.mcLitterAbove[m] = 0.0;
  3142. soil.mcLitterBelow[m] = 0.0;
  3143. soil.mcSoil[m] = 0.0;
  3144. soil.mcMedium[m] = 0.0;
  3145. soil.mcSlow[m] = 0.0;
  3146. soil.mnLitter[m] = 0.0;
  3147. soil.mnLitterCwd[m] = 0.0;
  3148. soil.mnLitterSurf[m] = 0.0;
  3149. soil.mnLitterSubSurf[m] = 0.0;
  3150. soil.mnSoil[m] = 0.0;
  3151. soil.mnMineralNH4[m] = 0.0;
  3152. soil.mnMineralNO3[m] = 0.0;
  3153. soil.mtemp_K[m] = 0.0;
  3154. }
  3155. for (int d = 0; d < date.year_length(); d++) {
  3156. patch.dlai[d] = 0.0;
  3157. patch.dmrro[d] = 0.0;
  3158. #ifdef CRESCENDO_FACE
  3159. if (printcrescendofacedaily) {
  3160. patch.dcLeaf[d] = 0.0;
  3161. patch.dnLeaf[d] = 0.0;
  3162. patch.dcRoot[d] = 0.0;
  3163. patch.dnRoot[d] = 0.0;
  3164. patch.dcStem[d] = 0.0;
  3165. patch.dnStem[d] = 0.0;
  3166. patch.dcOther[d] = 0.0;
  3167. patch.dnOther[d] = 0.0;
  3168. soil.dcflita[d] = 0.0;
  3169. soil.dnlit[d] = 0.0;
  3170. soil.dcflitb[d] = 0.0;
  3171. soil.dnrlit[d] = 0.0;
  3172. soil.dcclitb[d] = 0.0;
  3173. soil.dndw[d] = 0.0;
  3174. soil.dcsoil[d] = 0.0;
  3175. soil.dnsoil[d] = 0.0;
  3176. soil.dnmineral[d] = 0.0;
  3177. }
  3178. #endif
  3179. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  3180. soil.dtsl[d][lyr] = 0.0;
  3181. soil.dmrsol[d][lyr] = 0.0;
  3182. }
  3183. }
  3184. }
  3185. vegetation.firstobj();
  3186. while (vegetation.isobj) {
  3187. Individual& indiv = vegetation.getobj();
  3188. if (date.day == 0) {
  3189. for (int m = 0; m < 12; m++) {
  3190. indiv.mfpc[m] = 0.0;
  3191. indiv.mfpar[m] = 0.0;
  3192. }
  3193. }
  3194. indiv.mfpc[date.month] += indiv.fpc_today() / (double)date.month_length(date.month);
  3195. indiv.mfpar[date.month] += indiv.fpar / (double)date.month_length(date.month);
  3196. // Vegetation carbon
  3197. if (date.month < 11) {
  3198. patch.mcVeg[date.month] += (indiv.cleafcont() + indiv.crootcont() + indiv.cmass_wood()) / (double)date.month_length(date.month);
  3199. patch.mcLeaf[date.month] += indiv.cleafcont() * indiv.phen / (double)date.month_length(date.month);
  3200. patch.mcRoot[date.month] += indiv.crootcont() * indiv.phen / (double)date.month_length(date.month);
  3201. patch.mcStem[date.month] += indiv.cmass_wood() / (double)date.month_length(date.month);
  3202. patch.mcOtherPhen[date.month] += (indiv.cleafcont() + indiv.crootcont()) * (1.0 - indiv.phen) / (double)date.month_length(date.month);
  3203. }
  3204. else if (!date.islastday) { // last day of the year allocation of anpp will make the number inconsistent
  3205. patch.mcVeg[date.month] += (indiv.cleafcont() + indiv.crootcont() + indiv.cmass_wood()) / (double)(date.month_length(date.month) - 1);
  3206. patch.mcLeaf[date.month] += indiv.cleafcont() * indiv.phen / (double)(date.month_length(date.month) - 1);
  3207. patch.mcRoot[date.month] += indiv.crootcont() * indiv.phen / (double)(date.month_length(date.month) - 1);
  3208. patch.mcStem[date.month] += indiv.cmass_wood() / (double)(date.month_length(date.month) - 1);
  3209. patch.mcOtherPhen[date.month] += (indiv.cleafcont() + indiv.crootcont()) * (1.0 - indiv.phen) / (double)(date.month_length(date.month) - 1);
  3210. }
  3211. // Vegetation nitrogen
  3212. if (indiv.phen != 0.0) {
  3213. patch.mnVeg[date.month] += (indiv.nleafcont() + indiv.nrootcont() + indiv.nmass_wood()) / (double)date.month_length(date.month);
  3214. patch.mnLeaf[date.month] += indiv.nleafcont() / (double)date.month_length(date.month);
  3215. patch.mnRoot[date.month] += indiv.nrootcont() / (double)date.month_length(date.month);
  3216. }
  3217. else {
  3218. patch.mnVeg[date.month] += (indiv.nleafcont() + indiv.nrootcont()) / (double)date.month_length(date.month);
  3219. patch.mnOther[date.month] += (indiv.nleafcont() + indiv.nrootcont()) / (double)date.month_length(date.month);
  3220. }
  3221. patch.mnVeg[date.month] += indiv.nmass_wood() / (double)date.month_length(date.month);
  3222. patch.mnStem[date.month] += indiv.nmass_wood() / (double)date.month_length(date.month);
  3223. // Crop carbon and nitrogen
  3224. if (indiv.pft.landcover == CROPLAND) {
  3225. patch.mcVeg[date.month] += (indiv.cropindiv->grs_cmass_ho + indiv.cropindiv->grs_cmass_agpool + indiv.cropindiv->grs_cmass_dead_leaf + indiv.cropindiv->grs_cmass_stem) / (double)date.month_length(date.month);
  3226. patch.mnVeg[date.month] += (indiv.cropindiv->nmass_ho + indiv.cropindiv->nmass_agpool + indiv.cropindiv->nmass_dead_leaf) / (double)date.month_length(date.month);
  3227. patch.mcOther[date.month] += (indiv.cropindiv->grs_cmass_ho + indiv.cropindiv->grs_cmass_agpool + indiv.cropindiv->grs_cmass_dead_leaf + indiv.cropindiv->grs_cmass_stem) / (double)date.month_length(date.month);
  3228. patch.mnOther[date.month] += (indiv.cropindiv->nmass_ho + indiv.cropindiv->nmass_agpool + indiv.cropindiv->nmass_dead_leaf) / (double)date.month_length(date.month);
  3229. }
  3230. patch.dlai[date.day] += indiv.lai_today();
  3231. #ifdef CRESCENDO_FACE
  3232. if (printcrescendofacedaily) {
  3233. patch.dcLeaf[date.day] += indiv.cleafcont() * indiv.phen;
  3234. patch.dcRoot[date.day] += indiv.crootcont() * indiv.phen;
  3235. patch.dcStem[date.day] += indiv.cmass_wood();
  3236. patch.dcOther[date.day] += (indiv.cleafcont() + indiv.crootcont()) * (1.0 - indiv.phen);
  3237. // Vegetation nitrogen
  3238. if (indiv.phen != 0.0) {
  3239. patch.dnLeaf[date.day] += indiv.nleafcont();
  3240. patch.dnRoot[date.day] += indiv.nrootcont();
  3241. }
  3242. else {
  3243. patch.dnOther[date.day] += indiv.nleafcont() + indiv.nrootcont();
  3244. }
  3245. patch.dnStem[date.day] += indiv.nmass_wood();
  3246. if (indiv.pft.lifeform == TREE) {
  3247. patch.dnStem[date.day] -= indiv.nstore();
  3248. }
  3249. else if (indiv.phen != 0.0) {
  3250. patch.dnRoot[date.day] -= indiv.nstore();
  3251. }
  3252. patch.dnOther[date.day] += indiv.nstore();
  3253. // Crop carbon and nitrogen
  3254. if (indiv.pft.landcover == CROPLAND) {
  3255. patch.dcOther[date.day] += indiv.cropindiv->grs_cmass_ho + indiv.cropindiv->grs_cmass_agpool + indiv.cropindiv->grs_cmass_dead_leaf + indiv.cropindiv->grs_cmass_stem;
  3256. patch.dnOther[date.day] += indiv.cropindiv->nmass_ho + indiv.cropindiv->nmass_agpool + indiv.cropindiv->nmass_dead_leaf;
  3257. }
  3258. }
  3259. #endif
  3260. vegetation.nextobj();
  3261. }
  3262. // CRESCENDO physical variables output
  3263. soil.msnd[date.month] += soil.snowpack / (soil.snowdens * (double)date.month_length(date.month));
  3264. soil.mnMineralNH4[date.month] += soil.nmass_avail / (double)date.month_length(date.month);
  3265. soil.mnMineralNO3[date.month] += 0.0 / (double)date.month_length(date.month);
  3266. soil.mtemp_K[date.month] += (soil.temp + K2degC) / (double)date.month_length(date.month);
  3267. #ifdef CRESCENDO_FACE
  3268. soil.dnmineral[date.day] = soil.nmass_avail;
  3269. #endif
  3270. for (int r = 0; r < NSOMPOOL - 1; r++) {
  3271. if (r == SURFMETA || r == SURFSTRUCT) {
  3272. soil.mcLitter[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3273. soil.mnLitter[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3274. soil.mcLitterAbove[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3275. soil.mcLitterSurf[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3276. soil.mnLitterSurf[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3277. #ifdef CRESCENDO_FACE
  3278. if (printcrescendofacedaily) {
  3279. soil.dcflita[date.day] += soil.sompool[r].cmass;
  3280. soil.dnlit[date.day] += soil.sompool[r].nmass;
  3281. }
  3282. #endif
  3283. }
  3284. else if (r == SOILMETA || r == SOILSTRUCT) {
  3285. soil.mcLitter[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3286. soil.mnLitter[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3287. soil.mcLitterBelow[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3288. soil.mcLitterSubSurf[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3289. soil.mnLitterSubSurf[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3290. #ifdef CRESCENDO_FACE
  3291. if (printcrescendofacedaily) {
  3292. soil.dcflitb[date.day] += soil.sompool[r].cmass;
  3293. soil.dnrlit[date.day] += soil.sompool[r].nmass;
  3294. soil.dcsoil[date.day] += soil.sompool[r].cmass;
  3295. soil.dnsoil[date.day] += soil.sompool[r].nmass;
  3296. }
  3297. #endif
  3298. }
  3299. else if (r == SURFFWD || r == SURFCWD) {
  3300. soil.mcLitter[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3301. soil.mnLitter[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3302. soil.mcLitterSurf[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3303. soil.mnLitterSurf[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3304. soil.mcLitterCwd[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3305. soil.mnLitterCwd[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3306. #ifdef CRESCENDO_FACE
  3307. if (printcrescendofacedaily) {
  3308. soil.dcclitb[date.day] += soil.sompool[r].cmass;
  3309. soil.dndw[date.day] += soil.sompool[r].nmass;
  3310. }
  3311. #endif
  3312. }
  3313. else {
  3314. soil.mcSoil[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3315. soil.mnSoil[date.month] += soil.sompool[r].nmass / (double)date.month_length(date.month);
  3316. if (r == SLOWSOM) {
  3317. soil.mcMedium[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3318. }
  3319. if (r == PASSIVESOM) {
  3320. soil.mcSlow[date.month] += soil.sompool[r].cmass / (double)date.month_length(date.month);
  3321. }
  3322. #ifdef CRESCENDO_FACE
  3323. if (printcrescendofacedaily) {
  3324. soil.dcsoil[date.day] += soil.sompool[r].cmass;
  3325. soil.dnsoil[date.day] += soil.sompool[r].nmass;
  3326. }
  3327. #endif
  3328. }
  3329. }
  3330. for (int lyr = 0; lyr < NSOILLAYER; lyr++) {
  3331. soil.dtsl[date.day][lyr] += soil.temp + K2degC;
  3332. soil.dmrsol[date.day][lyr] += soil.wcont[lyr] * soil.soiltype.awc[lyr];
  3333. }
  3334. stand.nextobj();
  3335. } // patch loop
  3336. ++gc_itr;
  3337. } // stand loop
  3338. // Loop through patch pfts
  3339. pftlist.firstobj();
  3340. while (pftlist.isobj) {
  3341. Pft& pft = pftlist.getobj();
  3342. Gridcell::iterator gc_itr = gridcell.begin();
  3343. while (gc_itr != gridcell.end()) {
  3344. Stand& stand = *gc_itr;
  3345. double to_gridcell_average = stand.get_gridcell_fraction() / (double)stand.npatch();
  3346. stand.firstobj();
  3347. while (stand.isobj) {
  3348. Patch& patch = stand.getobj();
  3349. Vegetation& vegetation = patch.vegetation;
  3350. Patchpft& patchpft = patch.pft[pft.id];
  3351. patch.mcProduct[date.month] += patchpft.harvested_products_slow * to_gridcell_average / (double)date.ndaymonth[date.month];
  3352. patch.mnProduct[date.month] += patchpft.harvested_products_slow_nmass * to_gridcell_average / (double)date.ndaymonth[date.month];
  3353. if (date.month < 11) {
  3354. patch.soil.mcLitter[date.month] += (patchpft.litter_leaf + patchpft.litter_root + patchpft.litter_sap + patchpft.litter_heart) / (double)date.month_length(date.month);
  3355. patch.soil.mnLitter[date.month] += (patchpft.nmass_litter_leaf + patchpft.nmass_litter_root + patchpft.nmass_litter_sap + patchpft.nmass_litter_heart) / (double)date.month_length(date.month);
  3356. patch.soil.mcLitterCwd[date.month] += (patchpft.litter_sap + patchpft.litter_heart) / (double)date.month_length(date.month);
  3357. patch.soil.mnLitterCwd[date.month] += (patchpft.nmass_litter_sap + patchpft.nmass_litter_heart) / (double)date.month_length(date.month);
  3358. patch.soil.mcLitterAbove[date.month] += (patchpft.litter_leaf + patchpft.litter_root) / (double)date.month_length(date.month);
  3359. patch.soil.mcLitterSurf[date.month] += (patchpft.litter_leaf + patchpft.litter_sap + patchpft.litter_heart) / (double)date.month_length(date.month);
  3360. patch.soil.mnLitterSurf[date.month] += (patchpft.nmass_litter_leaf + patchpft.nmass_litter_sap + patchpft.nmass_litter_heart) / (double)date.month_length(date.month);
  3361. patch.soil.mcLitterSubSurf[date.month] += patchpft.litter_root / (double)date.month_length(date.month);
  3362. patch.soil.mnLitterSubSurf[date.month] += patchpft.nmass_litter_root / (double)date.month_length(date.month);
  3363. }
  3364. else if (!date.islastday) {
  3365. patch.soil.mcLitter[date.month] += (patchpft.litter_leaf + patchpft.litter_root + patchpft.litter_sap + patchpft.litter_heart) / (date.ndaymonth[date.month] - 1);
  3366. patch.soil.mnLitter[date.month] += (patchpft.nmass_litter_leaf + patchpft.nmass_litter_root + patchpft.nmass_litter_sap + patchpft.nmass_litter_heart) / (date.ndaymonth[date.month] - 1);
  3367. patch.soil.mcLitterCwd[date.month] += (patchpft.litter_sap + patchpft.litter_heart) / (double)(date.ndaymonth[date.month] - 1);
  3368. patch.soil.mnLitterCwd[date.month] += (patchpft.nmass_litter_sap + patchpft.nmass_litter_heart) / (double)(date.ndaymonth[date.month] - 1);
  3369. patch.soil.mcLitterAbove[date.month] += (patchpft.litter_leaf + patchpft.litter_root) / (double)(date.ndaymonth[date.month] - 1);
  3370. patch.soil.mcLitterSurf[date.month] += (patchpft.litter_leaf + patchpft.litter_sap + patchpft.litter_heart) / (double)(date.ndaymonth[date.month] - 1);
  3371. patch.soil.mnLitterSurf[date.month] += (patchpft.nmass_litter_leaf + patchpft.nmass_litter_sap + patchpft.nmass_litter_heart) / (double)(date.ndaymonth[date.month] - 1);
  3372. patch.soil.mcLitterSubSurf[date.month] += patchpft.litter_root / (double)(date.ndaymonth[date.month] - 1);
  3373. patch.soil.mnLitterSubSurf[date.month] += patchpft.nmass_litter_root / (double)(date.ndaymonth[date.month] - 1);
  3374. }
  3375. stand.nextobj();
  3376. }
  3377. ++gc_itr;
  3378. }
  3379. pftlist.nextobj();
  3380. }
  3381. }
  3382. outlimit_misc(out, out_daily_temp, gridcell.climate.temp);
  3383. outlimit_misc(out, out_daily_prec, gridcell.climate.prec);
  3384. outlimit_misc(out, out_daily_rad, gridcell.climate.rad);
  3385. }
  3386. void MiscOutput::openlocalfiles(Gridcell& gridcell) {
  3387. if (!printseparatestands)
  3388. return;
  3389. bool open_natural = false;
  3390. bool open_forest = false;
  3391. double lon = gridcell.get_lon();
  3392. double lat = gridcell.get_lat();
  3393. if (printseparatestands) {
  3394. Gridcell::iterator gc_itr = gridcell.begin();
  3395. // Loop through Stands
  3396. while (gc_itr != gridcell.end()) {
  3397. Stand& stand = *gc_itr;
  3398. stand.anpp = 0.0;
  3399. stand.cmass = 0.0;
  3400. if (stand.first_year == date.year || stand.clone_year == date.year) {
  3401. if (stand.landcover == NATURAL) {
  3402. open_natural = true;
  3403. }
  3404. else if (stand.landcover == FOREST) {
  3405. open_forest = true;
  3406. }
  3407. }
  3408. ++gc_itr;
  3409. }
  3410. if (PRINTFIRSTSTANDFROM1901 && date.year == nyear_spinup) {
  3411. open_natural = true;
  3412. open_forest = true;
  3413. }
  3414. if (open_natural || open_forest) {
  3415. gc_itr = gridcell.begin();
  3416. while (gc_itr != gridcell.end()) {
  3417. Stand& stand = *gc_itr;
  3418. int id = stand.id;
  3419. char outfilename[100] = { '\0' }, buffer[50] = { '\0' };
  3420. sprintf(buffer, "%.1f_%.1f_%d", lon, lat, id);
  3421. strcat(buffer, ".out");
  3422. // create a vector with the pft names
  3423. std::vector<std::string> pfts;
  3424. pftlist.firstobj();
  3425. while (pftlist.isobj) {
  3426. Pft& pft = pftlist.getobj();
  3427. Standpft& standpft = stand.pft[pft.id];
  3428. if (standpft.active)
  3429. pfts.push_back((char*)pft.name);
  3430. pftlist.nextobj();
  3431. }
  3432. ColumnDescriptors anpp_columns;
  3433. anpp_columns += ColumnDescriptors(pfts, 8, 3);
  3434. anpp_columns += ColumnDescriptor("Total", 8, 3);
  3435. if (open_natural && stand.landcover == NATURAL) {
  3436. strcpy(outfilename, "anpp_natural_");
  3437. strcat(outfilename, buffer);
  3438. if (out_anpp_stand_natural[id].invalid())
  3439. create_output_table(out_anpp_stand_natural[id], outfilename, anpp_columns);
  3440. outfilename[0] = '\0';
  3441. strcpy(outfilename, "cmass_natural_");
  3442. strcat(outfilename, buffer);
  3443. if (out_cmass_stand_natural[id].invalid())
  3444. create_output_table(out_cmass_stand_natural[id], outfilename, anpp_columns);
  3445. }
  3446. else if (open_forest && stand.landcover == FOREST) {
  3447. strcpy(outfilename, "anpp_forest_");
  3448. strcat(outfilename, buffer);
  3449. if (out_anpp_stand_forest[id].invalid())
  3450. create_output_table(out_anpp_stand_forest[id], outfilename, anpp_columns);
  3451. outfilename[0] = '\0';
  3452. strcpy(outfilename, "cmass_forest_");
  3453. strcat(outfilename, buffer);
  3454. if (out_cmass_stand_forest[id].invalid())
  3455. create_output_table(out_cmass_stand_forest[id], outfilename, anpp_columns);
  3456. }
  3457. ++gc_itr;
  3458. }
  3459. }
  3460. }
  3461. }
  3462. void MiscOutput::closelocalfiles(Gridcell& gridcell) {
  3463. if (!printseparatestands)
  3464. return;
  3465. if (printseparatestands) {
  3466. for (int id = 0; id < MAXNUMBER_STANDS; id++) {
  3467. if (!out_anpp_stand_natural[id].invalid())
  3468. close_output_table(out_anpp_stand_natural[id]);
  3469. if (!out_cmass_stand_natural[id].invalid())
  3470. close_output_table(out_cmass_stand_natural[id]);
  3471. if (!out_anpp_stand_forest[id].invalid())
  3472. close_output_table(out_anpp_stand_forest[id]);
  3473. if (!out_cmass_stand_forest[id].invalid())
  3474. close_output_table(out_cmass_stand_forest[id]);
  3475. }
  3476. }
  3477. }
  3478. } // namespace