miscoutput.cpp 185 KB

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