From d540e7a8c6c8e27c0d78092e47af9d987f41ff08 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Sun, 30 Apr 2017 22:40:49 -0700 Subject: [PATCH 01/12] Updated namelist generation for fates. Valid compsets are ICLM45ED. This passes the flag -bgc ed -no-megan to the namelist generation script. Later changes should update this to FATES, however there are string lenth limitations in place that have to be identified first. continued work on fates-BGC interface, specifically cold-start initialization for carbon flux and state vars, and not allocating memory in patch-level carbon flux and state vars FATES integration: removed provisional fates-side interface call. Also, copied in the wrappers used on CLM side in the fates developer repository. fates interface: incremental progress towards bringing in the clmfates interface wrappers and the fates submodule. FATES-interface: Debugging newly attached interface. Included the removal of duplicate history fields that showed up in native CN vegetation and FATES, such as NEP. Fixed call order of fates parameters. Fates interface: fixed call order of fates dynamics, cleaned out some of the use_ed filtering that occurs in history and summary during CNCarbonState and CNCarbonflux. FATES-interface: Shuffled around the call order of FATES parameter reads. FATES-inteface: Partitioned the summary variables in soil bgc used during fates calls, as well as history initialization. FATES-interface: renamed EDBGCDyn to FatesBGCDyn. FATES-interface: modified the test user nl --- .gitmodules | 4 + .../allactive/clm/fates}/user_nl_clm | 3 +- components/clm/bld/CLMBuildNamelist.pm | 149 +- components/clm/bld/configure | 7 +- .../namelist_defaults_clm4_5.xml | 15 +- .../namelist_definition_clm4_5.xml | 14 +- .../bld/unit_testers/build-namelist_test.pl | 2 +- .../clm/cime_config/config_component.xml | 5 +- .../clm/cime_config/config_compsets.xml | 14 +- .../testmods_dirs/clm/fates/include_user_mods | 1 + .../clm/{edTest => fates}/shell_commands | 0 .../testmods_dirs/clm/fates/user_nl_clm | 11 + components/clm/src/CMakeLists.txt | 5 + .../clm/src/ED/main/FatesInterfaceMod.F90 | 54 - .../clm/src/biogeochem/CNBalanceCheckMod.F90 | 2 +- .../clm/src/biogeochem/CNCarbonFluxType.F90 | 6510 +++++++++-------- .../clm/src/biogeochem/CNCarbonStateType.F90 | 2620 +++---- .../src/biogeochem/CNDecompCascadeCNMod.F90 | 10 +- .../{EDBGCDynMod.F90 => FatesBGCDynMod.F90} | 341 +- .../clm/src/biogeophys/CanopyFluxesMod.F90 | 36 +- .../src/biogeophys/CanopyTemperatureMod.F90 | 10 +- .../src/biogeophys/HydrologyNoDrainageMod.F90 | 15 +- .../clm/src/biogeophys/SoilStateType.F90 | 4 +- .../clm/src/biogeophys/SurfaceAlbedoMod.F90 | 12 +- .../src/dyn_subgrid/dynSubgridDriverMod.F90 | 2 +- components/clm/src/fates | 1 + components/clm/src/main/clm_driver.F90 | 105 +- components/clm/src/main/clm_initializeMod.F90 | 32 +- components/clm/src/main/clm_instMod.F90 | 16 +- components/clm/src/main/clm_varctl.F90 | 8 +- components/clm/src/main/clm_varpar.F90 | 3 - .../clm/src/main/clmfates_interfaceMod.F90 | 2360 ++++++ .../src/main/clmfates_paraminterfaceMod.F90 | 238 + components/clm/src/main/controlMod.F90 | 5 +- components/clm/src/main/histFileMod.F90 | 152 +- components/clm/src/main/initVerticalMod.F90 | 8 +- components/clm/src/main/ncdio_pio.F90.in | 95 + components/clm/src/main/paramUtilMod.F90 | 374 +- components/clm/src/main/pftvarcon.F90 | 7 +- components/clm/src/main/readParamsMod.F90 | 51 +- components/clm/src/main/restFileMod.F90 | 167 +- 41 files changed, 8397 insertions(+), 5071 deletions(-) rename {components/clm/cime_config/testdefs/testmods_dirs/clm/edTest => cime/config/acme/testmods_dirs/allactive/clm/fates}/user_nl_clm (88%) create mode 100644 components/clm/cime_config/testdefs/testmods_dirs/clm/fates/include_user_mods rename components/clm/cime_config/testdefs/testmods_dirs/clm/{edTest => fates}/shell_commands (100%) create mode 100644 components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm delete mode 100644 components/clm/src/ED/main/FatesInterfaceMod.F90 rename components/clm/src/biogeochem/{EDBGCDynMod.F90 => FatesBGCDynMod.F90} (52%) create mode 160000 components/clm/src/fates create mode 100644 components/clm/src/main/clmfates_interfaceMod.F90 create mode 100644 components/clm/src/main/clmfates_paraminterfaceMod.F90 diff --git a/.gitmodules b/.gitmodules index 4ddf3506edfe..a8aeb3c919f4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,3 +9,7 @@ path = components/mpas-cice/model url = git@github.com:ACME-Climate/MPAS.git branch = cice/develop +[submodule "components/clm/src/fates"] + path = components/clm/src/fates + url = git@github.com:ACME-Climate/fates.git + branch = release_head \ No newline at end of file diff --git a/components/clm/cime_config/testdefs/testmods_dirs/clm/edTest/user_nl_clm b/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm similarity index 88% rename from components/clm/cime_config/testdefs/testmods_dirs/clm/edTest/user_nl_clm rename to cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm index 2c11d3b5adf4..b829d58c8d8d 100644 --- a/components/clm/cime_config/testdefs/testmods_dirs/clm/edTest/user_nl_clm +++ b/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm @@ -6,5 +6,6 @@ hist_empty_htapes = .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', 'STORVEGC','FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', - 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','DISPVEGC','AREA_TREES','AREA_PLANT' + 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','DISPVEGC','AREA_TREES','AREA_PLANT', + 'HR','TOTLITC','TOTSOMC','AR' diff --git a/components/clm/bld/CLMBuildNamelist.pm b/components/clm/bld/CLMBuildNamelist.pm index 8b0925d9bd80..5adc1f09adb8 100755 --- a/components/clm/bld/CLMBuildNamelist.pm +++ b/components/clm/bld/CLMBuildNamelist.pm @@ -90,7 +90,7 @@ REQUIRED OPTIONS "-sim_year list" to list valid simulation years (default 2000) OPTIONS - -bgc "value" Build CLM with BGC package [ sp | cn | bgc ] + -bgc "value" Build CLM with BGC package [ sp | cn | bgc | ed ] (default is sp). CLM Biogeochemistry mode sp = Satellite Phenology (SP) @@ -101,9 +101,13 @@ OPTIONS (or CLM45BGC if phys=clm4_5/clm5_0, use_cn=true, use_vertsoilc=true, use_century_decomp=true, use_nitrif_denitrif=true, and use_lch4=true, use_dynroot) - This toggles on the namelist variables: + This toggles on the namelist variables: use_cn, use_lch4, use_nitrif_denitrif, use_vertsoilc, use_century_decomp, use_dynroot + ed = (fates) functionaly assembled terrestrial ecosystem simulator + with native below ground bgc + This toggles on the namelist variables: + use_ed, use_vertsoilc, use_century_decomp -bgc_spinup "on|off" CLM 4.5 Only. For CLM 4.0, spinup is controlled from configure. Turn on given spinup mode for BGC setting of CN @@ -161,8 +165,6 @@ OPTIONS -dynamic_vegetation Toggle for dynamic vegetation model. (default is off) (can ONLY be turned on when BGC type is 'cn' or 'bgc') This turns on the namelist variable: use_cndv - -ed_mode Turn ED (Ecosystem Demography) : [on | off] (default is off) - Sets the namelist variable use_ed and use_spit_fire. -fsnowoptics "opticalpropertiesfile" Snow optical properties input file -glc_present Set to true if the glc model is present (not sglc). This is used for error-checking, to make sure other options are @@ -295,7 +297,6 @@ sub process_commandline { bgc => "default", crop => 0, dynamic_vegetation => 0, - ed_mode => 0, envxml_dir => ".", vichydro => 0, maxpft => "default", @@ -345,7 +346,6 @@ sub process_commandline { "bgc=s" => \$opts{'bgc'}, "crop" => \$opts{'crop'}, "dynamic_vegetation" => \$opts{'dynamic_vegetation'}, - "ed_mode" => \$opts{'ed_mode'}, "vichydro" => \$opts{'vichydro'}, "maxpft=i" => \$opts{'maxpft'}, "v|verbose" => \$opts{'verbose'}, @@ -679,7 +679,7 @@ sub process_namelist_commandline_options { setup_cmdl_simulation_year($opts, $nl_flags, $definition, $defaults, $nl); setup_cmdl_run_type($opts, $nl_flags, $definition, $defaults, $nl); setup_cmdl_dynamic_vegetation($opts, $nl_flags, $definition, $defaults, $nl, $physv); - setup_cmdl_ed_mode($opts, $nl_flags, $definition, $defaults, $nl, $physv); + setup_cmdl_fates_mode($opts, $nl_flags, $definition, $defaults, $nl, $physv); setup_cmdl_vichydro($opts, $nl_flags, $definition, $defaults, $nl, $physv); setup_cmdl_betr_mode($opts, $nl_flags, $definition, $defaults, $nl, $physv); } @@ -750,54 +750,66 @@ sub setup_cmdl_mask { verbose_message("CLM land mask is $nl_flags->{'mask'}"); } -#------------------------------------------------------------------------------- -sub setup_cmdl_ed_mode { +sub setup_cmdl_fates_mode { # # call this at least after crop check is called # my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_; my $val; - my $var = "ed_mode"; - - $val = $opts->{$var}; - $nl_flags->{'ed_mode'} = $val; + my $var = "bgc_mode"; if ( $physv->as_long() == $physv->as_long("clm4_0") || $nl_flags->{'crop'} eq "on" ) { - if ( $nl_flags->{'ed_mode'} == 1 ) { + if ( $nl_flags->{$var} eq "ed" ) { # ED is not a clm4_0 option and should not be used with crop and not with clm4_0 fatal_error("** Cannot turn ed mode on with crop or with clm4_0 physics.\n" ); } + } elsif ($nl_flags->{"bgc_mode"} eq "ed" && $nl_flags->{"use_ed"} ne ".true.") { + fatal_error("DEV_ERROR: internal logic error: bgc_mode = ed and use_ed = false.\n"); + } else { $var = "use_ed"; - $nl_flags->{$var} = ".false."; - if ($nl_flags->{'ed_mode'} eq 1) { - message("Using ED (Ecosystem Demography)."); - $val = ".true."; - $nl_flags->{$var} = $val; - } - if ( defined($nl->get_value($var)) && $nl->get_value($var) ne $val ) { - fatal_error("$var is inconsistent with the commandline setting of -ed_mode"); - } if ( $nl_flags->{$var} eq ".true." ) { - my $group = $definition->get_group_name($var); - $nl->set_variable_value($group, $var, $val); - if ( ! $definition->is_valid_value( $var, $val ) ) { - my @valid_values = $definition->get_valid_values( $var ); - fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n"); - } + # This section is a place-holder to test for modules that are not allowed with ED + # the defaults which are set in the logic section of the namelist builder will + # automatically set these correctly (well that is the assumption), but here we + # want to set a catch to fail and warn users if they explicitly set incompatible user namelist + # options + +# my $var = "use_somevar"; +# $val = $nl_flags->{$var}; +# if ( defined($nl->get_value($var)) ) { +# if ( $nl->get_value($var) == ".true." ) { +# fatal_error("$var was set to .true., which is incompatible when -bgc ed option is used.\n"); +# } +# } + + + # The following variables may be set by the user and are compatible with use_ed + # no need to set defaults, covered in a different routine + my @list = ( "use_ed_spitfire", "use_vertsoilc", "use_century_decomp" ); + foreach my $var ( @list ) { + if ( defined($nl->get_value($var)) ) { + $nl_flags->{$var} = $nl->get_value($var); + $val = $nl_flags->{$var}; + my $group = $definition->get_group_name($var); + $nl->set_variable_value($group, $var, $val); + if ( ! $definition->is_valid_value( $var, $val ) ) { + my @valid_values = $definition->get_valid_values( $var ); + fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n"); + } + } + } + +# add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_vertsoilc', 'use_ed'=>$nl_flags->{'use_ed'} ); + - $var = "use_ed_spit_fire"; - $nl->set_variable_value($group, $var, $val); - if ( ! $definition->is_valid_value($var, $val) ) { - my @valid_values = $definition->get_valid_values( $var ); - fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n"); - } } else { - $var = "use_ed_spit_fire"; + # we only dis-allow ed_spitfire with non-ed runs + $var = "use_ed_spitfire"; if ( defined($nl->get_value($var)) ) { - fatal_error("$var is being set, but can ONLY be set when -ed_mode option is used.\n"); + fatal_error("$var is being set, but can ONLY be set when -bgc ed option is used.\n"); } } } @@ -817,10 +829,10 @@ sub setup_cmdl_betr_mode { $nl_flags->{'betr_mode'} = $val; if ( $physv->as_long() == $physv->as_long("clm4_0") || $nl_flags->{'crop'} eq "on" ) { - if ( $nl_flags->{'ed_mode'} == 1 ) { - # ED is not a clm4_0 option and should not be used with crop and not with clm4_0 - fatal_error("** Cannot turn betr mode on with crop or with clm4_0 physics.\n" ); - } +# if ( $nl_flags->{'ed_mode'} == 1 ) { +# # ED is not a clm4_0 option and should not be used with crop and not with clm4_0 +# fatal_error("** Cannot turn betr mode on with crop or with clm4_0 physics.\n" ); +# } } else { $var = "use_betr"; @@ -907,6 +919,7 @@ sub setup_cmdl_bgc { $val = $opts->{$var}; $nl_flags->{'bgc_mode'} = $val; + if ( $physv->as_long() == $physv->as_long("clm4_0") ) { if ( $nl_flags->{'bgc_mode'} ne "default" ) { fatal_error("-bgc option used with clm4_0 physics. -bgc can ONLY be used with clm4_5/clm5_0 physics"); @@ -929,15 +942,25 @@ sub setup_cmdl_bgc { my $setting = ".false."; if ($nl_flags->{$var} eq "cn") { $nl_flags->{'use_cn'} = ".true."; + $nl_flags->{'use_ed'} = ".false."; } elsif ($nl_flags->{$var} eq "bgc") { $nl_flags->{'use_cn'} = ".true."; + $nl_flags->{'use_ed'} = ".false."; $setting = ".true."; + } elsif ($nl_flags->{$var} eq "ed" ) { + $nl_flags->{'use_cn'} = ".false."; + $nl_flags->{'use_ed'} = ".true."; } else { $nl_flags->{'use_cn'} = ".false."; + $nl_flags->{'use_ed'} = ".false."; } if ( defined($nl->get_value("use_cn")) && ($nl_flags->{'use_cn'} ne $nl->get_value("use_cn")) ) { fatal_error("The namelist variable use_cn is inconsistent with the -bgc option"); } + if ( defined($nl->get_value("use_ed")) && ($nl_flags->{'use_ed'} ne $nl->get_value("use_ed")) ) { + fatal_error("The namelist variable use_ed is inconsistent with the -bgc option"); + } + # If the variable has already been set use it, if not set to the value defined by the bgc_mode my @list = ( "use_lch4", "use_nitrif_denitrif", "use_vertsoilc", "use_century_decomp" ); my $ndiff = 0; @@ -966,14 +989,18 @@ sub setup_cmdl_bgc { fatal_error("You are contradicting the -bgc setting with the namelist variables: @list" ); } - # Now set use_cn - $var = "use_cn"; - $val = $nl_flags->{'use_cn'}; - $group = $definition->get_group_name($var); - $nl->set_variable_value($group, $var, $val); - if ( ! $definition->is_valid_value( $var, $val ) ) { - my @valid_values = $definition->get_valid_values( $var ); - fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n"); +# # Now set use_cn +# $var = "use_cn"; + + # Now set use_cn and use_ed + foreach $var ( "use_cn", "use_ed" ) { + $val = $nl_flags->{$var}; + $group = $definition->get_group_name($var); + $nl->set_variable_value($group, $var, $val); + if ( ! $definition->is_valid_value( $var, $val ) ) { + my @valid_values = $definition->get_valid_values( $var ); + fatal_error("$var has a value ($val) that is NOT valid. Valid values are: @valid_values\n"); + } } # Now set use_dynroot @@ -1873,6 +1900,7 @@ sub process_namelist_inline_logic { setup_logic_bgc_spinup($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv); setup_logic_supplemental_nitrogen($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv); # setup_logic_snowpack($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv); + setup_logic_fates($opts->{'test'}, $nl_flags, $definition, $defaults, $nl, $physv); ######################################### # namelist group: clm_humanindex_inparm # @@ -2947,7 +2975,7 @@ sub setup_logic_nitrogen_deposition { 'bgc'=>$nl_flags->{'bgc_mode'}, 'rcp'=>$nl_flags->{'rcp'}, 'hgrid'=>"1.9x2.5" ); - } elsif ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) { + } elsif ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} =~/cn|bgc/ ) { add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndepmapalgo', 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'} ); add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_ndep', 'phys'=>$nl_flags->{'phys'}, @@ -3008,7 +3036,7 @@ sub setup_logic_phosphorus_deposition { # 'hgrid'=>"1.9x2.5" ); # } elsif ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) { - if ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) { + if ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} =~/cn|bgc/ ) { add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'pdepmapalgo', 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'} ); add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_pdep', 'phys'=>$nl_flags->{'phys'}, @@ -3046,7 +3074,7 @@ sub setup_logic_popd_streams { my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_; if ( $physv->as_long() >= $physv->as_long("clm4_5") ) { - if ( $nl_flags->{'bgc_mode'} ne "sp" ) { + if ( $nl_flags->{'bgc_mode'} =~/cn|bgc/ ) { add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'popdensmapalgo', 'hgrid'=>$nl_flags->{'res'} ); add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_popdens', 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, 'sim_year'=>$nl_flags->{'sim_year'}, @@ -3083,7 +3111,7 @@ sub setup_logic_lightning_streams { my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_; if ( $physv->as_long() >= $physv->as_long("clm4_5") ) { - if ( $nl_flags->{'bgc_mode'} ne "sp" ) { + if ( $nl_flags->{'bgc_mode'} =~/cn|bgc/ ) { add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'lightngmapalgo', 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'} ); add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, @@ -3138,7 +3166,7 @@ sub setup_logic_megan { if ($opts->{'megan'} ) { if ( value_is_true( $nl_flags->{'use_ed'} ) ) { fatal_error("MEGAN can NOT be on when ED is also on.\n" . - " Use the '-no-megan' option when '-ed_mode' is activated"); + " Use the '-no-megan' option when '-bgc ed' is activated"); } add_default($opts->{'test'}, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'megan_specifier'); check_megan_spec( $nl, $definition ); @@ -3230,6 +3258,19 @@ sub setup_logic_pflotran { } } # end setup_logic_pflotran +#------------------------------------------------------------------------------- + +sub setup_logic_fates { + # + # Set some default options related to Ecosystem Demography + # + my ($test_files, $nl_flags, $definition, $defaults, $nl, $physv) = @_; + + if ($physv->as_long() >= $physv->as_long("clm4_5") && value_is_true( $nl_flags->{'use_ed'}) ) { + add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_ed_spitfire', 'use_ed'=>$nl_flags->{'use_ed'} ); + add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); + } +} #------------------------------------------------------------------------------- diff --git a/components/clm/bld/configure b/components/clm/bld/configure index a7c3c5cbef97..3198e5f0e963 100755 --- a/components/clm/bld/configure +++ b/components/clm/bld/configure @@ -47,7 +47,7 @@ OPTIONS or double leading dashes. A consequence of this is that single letter options may NOT be bundled. - -bgc Build CLM with BGC package [ none | cn | cndv ] + -bgc Build CLM with BGC package [ none | cn | cndv | ed] (default is none). -cache Name of output cache file (default: config_cache.xml). -cachedir Name of directory where output cache file is written @@ -654,7 +654,10 @@ sub write_filepath_cesmbld "biogeophys/vsfm", "biogeochem", "dyn_subgrid", - "ED/main", + "fates/main", + "fates/biogeophys", + "fates/biogeochem", + "fates/fire", "utils", "cpl" ); diff --git a/components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml b/components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml index 5f2f4f974af1..4d91df52eca8 100644 --- a/components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml +++ b/components/clm/bld/namelist_files/namelist_defaults_clm4_5.xml @@ -44,6 +44,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). NONE +NONE 0.60,0.40 @@ -79,10 +80,12 @@ attributes from the config_cache.xml file (with keys converted to upper-case). for the CLM2 data in the CESM distribution --> lnd/clm2/paramdata/clm_params_c160822.nc -lnd/clm2/paramdata/clm_params.ED.c140115.nc lnd/clm2/paramdata/clm_params_c160822.nc lnd/clm2/paramdata/clm_params.c160709.nc +lnd/clm2/paramdata/fates_params.c170331.nc + + lnd/clm2/paramdata/CNP_parameters_c131108.nc @@ -555,6 +558,7 @@ this mask will have smb calculated over the entire global land surface nn nn + 2000 2000 @@ -1759,7 +1763,9 @@ this mask will have smb calculated over the entire global land surface .true. +.false. +.true. .true. @@ -1768,4 +1774,11 @@ this mask will have smb calculated over the entire global land surface pflotran pflotran_clm +.false. +.true. +.true. +.false. +.false. + + diff --git a/components/clm/bld/namelist_files/namelist_definition_clm4_5.xml b/components/clm/bld/namelist_files/namelist_definition_clm4_5.xml index c0ce345634ab..092c7236e222 100644 --- a/components/clm/bld/namelist_files/namelist_definition_clm4_5.xml +++ b/components/clm/bld/namelist_files/namelist_definition_clm4_5.xml @@ -227,13 +227,13 @@ Toggle to turn on the BeTR -Toggle to turn on the ED +Toggle to turn on the ED (fates) (ED = 'on' is EXPERIMENTAL NOT SUPPORTED!) - -Toggle to turn on spit fire (only relevant if ED is being used). +Toggle to turn on spitfire (only relevant if ED is being used). + +Full pathname datafile with fates parameters + + Full pathname datafile with soil order dependent constants @@ -1166,7 +1171,7 @@ Command line arguement for turning on CN spinup mode. + group="default_settings" valid_values="sp,cn,bgc,ed" > Command line arguement for biogeochemistry mode for CLM4.5 sp = Satellitte Phenology cn = Carbon Nitrogen model @@ -1175,6 +1180,7 @@ Command line arguement for biogeochemistry mode for CLM4.5 Nitrification/De-nitrification Methane model Vertically resolved Carbon + fates = functionally assembled terrestrial ecosystem simulator diff --git a/components/clm/bld/unit_testers/build-namelist_test.pl b/components/clm/bld/unit_testers/build-namelist_test.pl index 4e829aa67eb6..d139a874be9c 100755 --- a/components/clm/bld/unit_testers/build-namelist_test.pl +++ b/components/clm/bld/unit_testers/build-namelist_test.pl @@ -523,7 +523,7 @@ sub make_env_run { conopts=>"-phys clm4_0", }, "usespitfireButNOTED" =>{ options=>"-envxml_dir .", - namelst=>"use_ed_spit_fire=.true.", + namelst=>"use_ed_spitfire=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", conopts=>"-phys clm4_5", }, diff --git a/components/clm/cime_config/config_component.xml b/components/clm/cime_config/config_component.xml index dd5dfbccccb8..ee2293dde6d2 100644 --- a/components/clm/cime_config/config_component.xml +++ b/components/clm/cime_config/config_component.xml @@ -95,8 +95,7 @@ -bgc bgc -dynamic_vegetation -bgc cn -dynamic_vegetation -crop -bgc bgc -dynamic_vegetation -crop - -bgc cn -ed_mode - -bgc bgc -ed_mode + -bgc ed -no-megan -bgc cn -nutrient c -nutrient_comp_pathway rd -soil_decomp ctc -methane -nitrif_denitrif -bgc cn -nutrient cn -nutrient_comp_pathway rd -soil_decomp ctc -methane -nitrif_denitrif -bgc cn -nutrient cnp -nutrient_comp_pathway rd -soil_decomp ctc -methane -nitrif_denitrif @@ -207,7 +206,7 @@ clm4.5 bgc (cn and methane): clm4.5 prognostic crop: clm4.5 vic hydrology: - clm4.5 ED (Ecosystem Demography): (experimental) + clm4.5 ed (Functionally Assembled Terr. Ecosystem Simulator): (experimental) clm4.5 BGC (CN with vertically resolved soil BGC, based on Century with Methane) with dynamic veg alm1.0 C only, nutirent competition via relative demand, ctc soil cascade with black carbon deposition: alm1.0 C-N, nutirent competition via relative demand, ctc soil cascade with black carbon deposition: diff --git a/components/clm/cime_config/config_compsets.xml b/components/clm/cime_config/config_compsets.xml index 43e5f4316a44..cfef97a95eb2 100644 --- a/components/clm/cime_config/config_compsets.xml +++ b/components/clm/cime_config/config_compsets.xml @@ -171,11 +171,6 @@ 1850_SATM%QIA_CLM45%CN_SICE_SOCN_RTM_SGLC_SWAV - - I1850CLM45CNED - 1850_DATM%QIA_CLM45%CN-ED_SICE_SOCN_RTM_SGLC_SWAV - - I1850CLM45CNF 1850_DATM%QIA_CLM45%CN_SICE_SOCN_RTM%FLOOD_SGLC_SWAV @@ -553,11 +548,6 @@ 2000_DATM%QIA_CLM45%SP-VIC_SICE_SOCN_RTM_SGLC_SWAV - - ICLM45CNED - 2000_DATM%QIA_CLM45%CN-ED_SICE_SOCN_RTM_SGLC_SWAV - - ICLM45BGC 2000_DATM%QIA_CLM45%BGC_SICE_SOCN_RTM_SGLC_SWAV @@ -576,12 +566,12 @@ - ICLM45BGCED + ICLM45ED 2000_DATM%QIA_CLM45%BGC-ED_SICE_SOCN_RTM_SGLC_SWAV - I1850CLM45BGCED + I1850CLM45ED 1850_DATM%QIA_CLM45%BGC-ED_SICE_SOCN_RTM_SGLC_SWAV diff --git a/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/include_user_mods b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/include_user_mods new file mode 100644 index 000000000000..fe0e18cf8896 --- /dev/null +++ b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/include_user_mods @@ -0,0 +1 @@ +../default diff --git a/components/clm/cime_config/testdefs/testmods_dirs/clm/edTest/shell_commands b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/shell_commands similarity index 100% rename from components/clm/cime_config/testdefs/testmods_dirs/clm/edTest/shell_commands rename to components/clm/cime_config/testdefs/testmods_dirs/clm/fates/shell_commands diff --git a/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm new file mode 100644 index 000000000000..b829d58c8d8d --- /dev/null +++ b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm @@ -0,0 +1,11 @@ +use_cn = .false. +finidat = '' +hist_mfilt = 365 +hist_nhtfrq = -24 +hist_empty_htapes = .true. +hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', + 'STORVEGC','FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', + 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', + 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','DISPVEGC','AREA_TREES','AREA_PLANT', + 'HR','TOTLITC','TOTSOMC','AR' + diff --git a/components/clm/src/CMakeLists.txt b/components/clm/src/CMakeLists.txt index ce392f3a4b2f..78c6211d1d9f 100644 --- a/components/clm/src/CMakeLists.txt +++ b/components/clm/src/CMakeLists.txt @@ -18,6 +18,11 @@ add_subdirectory(${CLM_ROOT}/src/utils clm_utils) add_subdirectory(${CLM_ROOT}/src/biogeophys clm_biogeophys) add_subdirectory(${CLM_ROOT}/src/dyn_subgrid clm_dyn_subgrid) add_subdirectory(${CLM_ROOT}/src/main clm_main) +add_subdirectory(${CLM_ROOT}/src/fates/main ed_main) +add_subdirectory(${CLM_ROOT}/src/fates/biogeophys ed_biogeophys) +add_subdirectory(${CLM_ROOT}/src/fates/biogeochem ed_biogeochem) +add_subdirectory(${CLM_ROOT}/src/fates/fire ed_fire) + # Add general unit test directories (mocked out files, etc.) add_subdirectory(unit_test_mocks) diff --git a/components/clm/src/ED/main/FatesInterfaceMod.F90 b/components/clm/src/ED/main/FatesInterfaceMod.F90 deleted file mode 100644 index e67917515ceb..000000000000 --- a/components/clm/src/ED/main/FatesInterfaceMod.F90 +++ /dev/null @@ -1,54 +0,0 @@ -module FatesInterfaceMod - - ! ------------------------------------------------------------------------------------ - ! STUB STUB STUB - - ! This is the FATES public API - ! A host land model has defined and allocated a structure "fates" as - ! defined by fates_interface_type - ! - ! It is also likely/possible that this type is defined as a vector - ! which is allocated by thread - ! ------------------------------------------------------------------------------------ - - ! ------------------------------------------------------------------------------------- - ! Parameters that are dictated by FATES and known to be required knowledge - ! needed by the HLMs - ! ------------------------------------------------------------------------------------- - - ! Variables mostly used for dimensioning host land model (HLM) array spaces - - implicit none - - public :: set_fates_global_elements - - integer, protected :: fates_maxElementsPerPatch - integer, protected :: fates_maxElementsPerSite - - - contains - - subroutine set_fates_global_elements(use_fates) - implicit none - - logical,intent(in) :: use_fates ! Is fates turned on? - - if (use_fates) then - - fates_maxElementsPerPatch = 1 - fates_maxElementsPerSite = 1 - - else - ! If we are not using FATES, the cohort dimension is still - ! going to be initialized, lets set it to the smallest value - ! possible so that the dimensioning info takes up little space - - fates_maxElementsPerPatch = 1 - - fates_maxElementsPerSite = 1 - - - end if - end subroutine set_fates_global_elements - -end module FatesInterfaceMod diff --git a/components/clm/src/biogeochem/CNBalanceCheckMod.F90 b/components/clm/src/biogeochem/CNBalanceCheckMod.F90 index 8e5c302f67e3..3d6de26a0e99 100644 --- a/components/clm/src/biogeochem/CNBalanceCheckMod.F90 +++ b/components/clm/src/biogeochem/CNBalanceCheckMod.F90 @@ -237,7 +237,7 @@ subroutine CBalanceCheck(bounds, & end if end do ! end of columns loop - ! (FATES-INTERF) consider adapting this check to be fates compliant + ! Consider adapting this check to be fates compliant (rgk 04-2017) if (.not. use_ed) then if (err_found) then c = err_index diff --git a/components/clm/src/biogeochem/CNCarbonFluxType.F90 b/components/clm/src/biogeochem/CNCarbonFluxType.F90 index b31d46cfab1f..35e1335b30ba 100644 --- a/components/clm/src/biogeochem/CNCarbonFluxType.F90 +++ b/components/clm/src/biogeochem/CNCarbonFluxType.F90 @@ -794,2756 +794,2801 @@ subroutine InitAllocate(this, bounds) !------------------------------------------------------------------------ end subroutine InitAllocate; - !------------------------------------------------------------------------ - subroutine InitHistory(this, bounds, carbon_type) - ! - ! !DESCRIPTION: - ! add history fields for all CN variables, always set as default='inactive' - ! - ! !USES: - use clm_varpar , only : ndecomp_cascade_transitions, ndecomp_pools - use clm_varpar , only : nlevdecomp, nlevdecomp_full, crop_prog, nlevgrnd - use clm_varctl , only : hist_wrtch4diag - use histFileMod, only : hist_addfld1d, hist_addfld2d, hist_addfld_decomp - use tracer_varcon , only : is_active_betr_bgc - use clm_varctl, only : get_carbontag + !------------------------------------------------------------------------ + subroutine InitHistory(this, bounds, carbon_type) ! - ! !ARGUMENTS: - class(carbonflux_type) :: this - type(bounds_type) , intent(in) :: bounds - character(len=3) , intent(in) :: carbon_type ! one of ['c12', c13','c14'] - ! - ! !LOCAL VARIABLES: - integer :: k,l,ii,jj - character(8) :: vr_suffix - character(10) :: active - integer :: begp,endp - integer :: begc,endc - character(24) :: fieldname - character(100) :: longname - real(r8), pointer :: data1dptr(:) ! temp. pointer for slicing larger arrays - real(r8), pointer :: data2dptr(:,:) ! temp. pointer for slicing larger arrays - character(len=3) :: ctag - !--------------------------------------------------------------------- + ! !DESCRIPTION: + ! add history fields for all CN variables, always set as default='inactive' + ! + ! !USES: + use clm_varpar , only : ndecomp_cascade_transitions, ndecomp_pools + use clm_varpar , only : nlevdecomp, nlevdecomp_full, crop_prog, nlevgrnd + use clm_varctl , only : hist_wrtch4diag + use histFileMod, only : hist_addfld1d, hist_addfld2d, hist_addfld_decomp + use tracer_varcon , only : is_active_betr_bgc + use clm_varctl, only : get_carbontag + ! + ! !ARGUMENTS: + class(carbonflux_type) :: this + type(bounds_type) , intent(in) :: bounds + character(len=3) , intent(in) :: carbon_type ! one of ['c12', c13','c14'] + ! + ! !LOCAL VARIABLES: + integer :: k,l,ii,jj + character(8) :: vr_suffix + character(10) :: active + integer :: begp,endp + integer :: begc,endc + character(24) :: fieldname + character(100) :: longname + real(r8), pointer :: data1dptr(:) ! temp. pointer for slicing larger arrays + real(r8), pointer :: data2dptr(:,:) ! temp. pointer for slicing larger arrays + character(len=3) :: ctag + !--------------------------------------------------------------------- + + begp = bounds%begp; endp = bounds%endp + begc = bounds%begc; endc = bounds%endc + + if (nlevdecomp > 1) then + vr_suffix = "_vr" + else + vr_suffix = "" + endif - begp = bounds%begp; endp = bounds%endp - begc = bounds%begc; endc = bounds%endc + !------------------------------- + ! C flux variables - native to PFT + !------------------------------- - if (nlevdecomp > 1) then - vr_suffix = "_vr" - else - vr_suffix = "" - endif + ! add history fields for all CLAMP CN variables + + ! ------------------------------------------------------------------------------------ + ! History Diagnostics with FATES turned on is a very limited set, and only + ! operates on C12 right now. + ! ------------------------------------------------------------------------------------ + if (use_ed) then + if (carbon_type == 'c12') then + this%som_c_leached_col(begc:endc) = spval + call hist_addfld1d (fname='SOM_C_LEACHED', units='gC/m^2/s', & + avgflag='A', long_name='total flux of C from SOM pools due to leaching', & + ptr_col=this%som_c_leached_col)!, default='inactive') + + if ( nlevdecomp_full > 1 ) then + this%hr_vr_col(begc:endc,:) = spval + call hist_addfld2d (fname='HR_vr', units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name='total vertically resolved heterotrophic respiration', & + ptr_col=this%hr_vr_col) + end if - !------------------------------- - ! C flux variables - native to PFT - !------------------------------- + this%lithr_col(begc:endc) = spval + call hist_addfld1d (fname='LITHR', units='gC/m^2/s', & + avgflag='A', long_name='litter heterotrophic respiration', & + ptr_col=this%lithr_col) + + this%somhr_col(begc:endc) = spval + call hist_addfld1d (fname='SOMHR', units='gC/m^2/s', & + avgflag='A', long_name='soil organic matter heterotrophic respiration', & + ptr_col=this%somhr_col) + + this%hr_col(begc:endc) = spval + call hist_addfld1d (fname='HR', units='gC/m^2/s', & + avgflag='A', long_name='total heterotrophic respiration', & + ptr_col=this%hr_col) - ! add history fields for all CLAMP CN variables + end if - - if (.not.use_ed) then - if (carbon_type == 'c12') then - if (crop_prog) then - this%grainc_to_food_patch(begp:endp) = spval - call hist_addfld1d (fname='GRAINC_TO_FOOD', units='gC/m^2/s', & - avgflag='A', long_name='grain C to food', & - ptr_patch=this%grainc_to_food_patch, default='inactive') - end if - - this%woodc_alloc_patch(begp:endp) = spval - call hist_addfld1d (fname='WOODC_ALLOC', units='gC/m^2/s', & - avgflag='A', long_name='wood C eallocation', & - ptr_patch=this%woodc_alloc_patch) - - this%woodc_loss_patch(begp:endp) = spval - call hist_addfld1d (fname='WOODC_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='wood C loss', & - ptr_patch=this%woodc_loss_patch) - - this%leafc_loss_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFC_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='leaf C loss', & - ptr_patch=this%leafc_loss_patch) - - this%leafc_alloc_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFC_ALLOC', units='gC/m^2/s', & - avgflag='A', long_name='leaf C allocation', & - ptr_patch=this%leafc_alloc_patch) - - this%frootc_loss_patch(begp:endp) = spval - call hist_addfld1d (fname='FROOTC_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='fine root C loss', & - ptr_patch=this%frootc_loss_patch) - - this%frootc_alloc_patch(begp:endp) = spval - call hist_addfld1d (fname='FROOTC_ALLOC', units='gC/m^2/s', & - avgflag='A', long_name='fine root C allocation', & - ptr_patch=this%frootc_alloc_patch) - - this%m_leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='leaf C mortality', & - ptr_patch=this%m_leafc_to_litter_patch, default='inactive') - - this%m_frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='fine root C mortality', & - ptr_patch=this%m_frootc_to_litter_patch, default='inactive') - - this%m_leafc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='leaf C storage mortality', & - ptr_patch=this%m_leafc_storage_to_litter_patch, default='inactive') - - this%m_frootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='fine root C storage mortality', & - ptr_patch=this%m_frootc_storage_to_litter_patch, default='inactive') - - this%m_livestemc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='live stem C storage mortality', & - ptr_patch=this%m_livestemc_storage_to_litter_patch, default='inactive') - - this%m_deadstemc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C storage mortality', & - ptr_patch=this%m_deadstemc_storage_to_litter_patch, default='inactive') - - this%m_livecrootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVECROOTC_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C storage mortality', & - ptr_patch=this%m_livecrootc_storage_to_litter_patch, default='inactive') - - this%m_deadcrootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADCROOTC_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root C storage mortality', & - ptr_patch=this%m_deadcrootc_storage_to_litter_patch, default='inactive') - - this%m_leafc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='leaf C transfer mortality', & - ptr_patch=this%m_leafc_xfer_to_litter_patch, default='inactive') - - this%m_frootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='fine root C transfer mortality', & - ptr_patch=this%m_frootc_xfer_to_litter_patch, default='inactive') - - this%m_livestemc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='live stem C transfer mortality', & - ptr_patch=this%m_livestemc_xfer_to_litter_patch, default='inactive') - - this%m_deadstemc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C transfer mortality', & - ptr_patch=this%m_deadstemc_xfer_to_litter_patch, default='inactive') - - this%m_livecrootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVECROOTC_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C transfer mortality', & - ptr_patch=this%m_livecrootc_xfer_to_litter_patch, default='inactive') - - this%m_deadcrootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADCROOTC_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root C transfer mortality', & - ptr_patch=this%m_deadcrootc_xfer_to_litter_patch, default='inactive') - - this%m_livestemc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='live stem C mortality', & - ptr_patch=this%m_livestemc_to_litter_patch, default='inactive') - - this%m_deadstemc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C mortality', & - ptr_patch=this%m_deadstemc_to_litter_patch, default='inactive') - - this%m_livecrootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVECROOTC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C mortality', & - ptr_patch=this%m_livecrootc_to_litter_patch, default='inactive') - - this%m_deadcrootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADCROOTC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root C mortality', & - ptr_patch=this%m_deadcrootc_to_litter_patch, default='inactive') - - this%m_gresp_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_GRESP_STORAGE_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration storage mortality', & - ptr_patch=this%m_gresp_storage_to_litter_patch, default='inactive') - - this%m_gresp_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='M_GRESP_XFER_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration transfer mortality', & - ptr_patch=this%m_gresp_xfer_to_litter_patch, default='inactive') - - this%m_leafc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='leaf C fire loss', & - ptr_patch=this%m_leafc_to_fire_patch, default='inactive') - - this%m_leafc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='leaf C storage fire loss', & - ptr_patch=this%m_leafc_storage_to_fire_patch, default='inactive') - - this%m_leafc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='leaf C transfer fire loss', & - ptr_patch=this%m_leafc_xfer_to_fire_patch, default='inactive') - - this%m_livestemc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C fire loss', & - ptr_patch=this%m_livestemc_to_fire_patch, default='inactive') - - this%m_livestemc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C storage fire loss', & - ptr_patch=this%m_livestemc_storage_to_fire_patch, default='inactive') - - this%m_livestemc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C transfer fire loss', & - ptr_patch=this%m_livestemc_xfer_to_fire_patch, default='inactive') - - this%m_deadstemc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C fire loss', & - ptr_patch=this%m_deadstemc_to_fire_patch, default='inactive') - - this%m_deadstemc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C storage fire loss', & - ptr_patch=this%m_deadstemc_storage_to_fire_patch, default='inactive') - - this%m_deadstemc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C transfer fire loss', & - ptr_patch=this%m_deadstemc_xfer_to_fire_patch, default='inactive') - - this%m_frootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='fine root C fire loss', & - ptr_patch=this%m_frootc_to_fire_patch, default='inactive') - - this%m_frootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='fine root C storage fire loss', & - ptr_patch=this%m_frootc_storage_to_fire_patch, default='inactive') - - this%m_frootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='fine root C transfer fire loss', & - ptr_patch=this%m_frootc_xfer_to_fire_patch, default='inactive') - - this%m_livecrootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C fire loss', & - ptr_patch=this%m_livecrootc_to_fire_patch, default='inactive') - - this%m_livecrootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C storage fire loss', & - ptr_patch=this%m_livecrootc_storage_to_fire_patch, default='inactive') - - this%m_livecrootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C transfer fire loss', & - ptr_patch=this%m_livecrootc_xfer_to_fire_patch, default='inactive') - - this%m_deadcrootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADROOTC_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead root C fire loss', & - ptr_patch=this%m_deadcrootc_to_fire_patch, default='inactive') - - this%m_deadcrootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADROOTC_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead root C storage fire loss', & - ptr_patch=this%m_deadcrootc_storage_to_fire_patch, default='inactive') - - this%m_deadcrootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADROOTC_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead root C transfer fire loss', & - ptr_patch=this%m_deadcrootc_xfer_to_fire_patch, default='inactive') - - this%m_gresp_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_GRESP_STORAGE_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration storage fire loss', & - ptr_patch=this%m_gresp_storage_to_fire_patch, default='inactive') - - this%m_gresp_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_GRESP_XFER_TO_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration transfer fire loss', & - ptr_patch=this%m_gresp_xfer_to_fire_patch, default='inactive') - - this%m_leafc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='leaf C fire mortality to litter', & - ptr_patch=this%m_leafc_to_litter_fire_patch, default='inactive') - - ! add by F. Li and S. Levis - this%m_leafc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='leaf C fire mortality to litter', & - ptr_patch=this%m_leafc_storage_to_litter_fire_patch, default='inactive') - - this%m_leafc_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LEAFC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='leaf C transfer fire mortality to litter', & - ptr_patch=this%m_leafc_xfer_to_litter_fire_patch, default='inactive') - - this%m_livestemc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C fire mortality to litter', & - ptr_patch=this%m_livestemc_to_litter_fire_patch, default='inactive') - - this%m_livestemc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C storage fire mortality to litter', & - ptr_patch=this%m_livestemc_storage_to_litter_fire_patch, default='inactive') - - this%m_livestemc_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C transfer fire mortality to litter', & - ptr_patch=this%m_livestemc_xfer_to_litter_fire_patch, default='inactive') - - this%m_livestemc_to_deadstemc_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVESTEMC_TO_DEADSTEMC_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live stem C fire mortality to dead stem C', & - ptr_patch=this%m_livestemc_to_deadstemc_fire_patch, default='inactive') - - this%m_deadstemc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C fire mortality to litter', & - ptr_patch=this%m_deadstemc_to_litter_fire_patch, default='inactive') - - this%m_deadstemc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C storage fire mortality to litter', & - ptr_patch=this%m_deadstemc_storage_to_litter_fire_patch, default='inactive') - - this%m_deadstemc_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADSTEMC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C transfer fire mortality to litter', & - ptr_patch=this%m_deadstemc_xfer_to_litter_fire_patch, default='inactive') - - this%m_frootc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='fine root C fire mortality to litter', & - ptr_patch=this%m_frootc_to_litter_fire_patch, default='inactive') - - this%m_frootc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='fine root C storage fire mortality to litter', & - ptr_patch=this%m_frootc_storage_to_litter_fire_patch, default='inactive') - - this%m_frootc_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_FROOTC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='fine root C transfer fire mortality to litter', & - ptr_patch=this%m_frootc_xfer_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C fire mortality to litter', & - ptr_patch=this%m_livecrootc_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C storage fire mortality to litter', & - ptr_patch=this%m_livecrootc_storage_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C transfer fire mortality to litter', & - ptr_patch=this%m_livecrootc_xfer_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_to_deadcrootc_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVEROOTC_TO_DEADROOTC_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live root C fire mortality to dead root C', & - ptr_patch=this%m_livecrootc_to_deadcrootc_fire_patch, default='inactive') - - - this%m_deadcrootc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADROOTC_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead root C fire mortality to litter', & - ptr_patch=this%m_deadcrootc_to_litter_fire_patch, default='inactive') - - this%m_deadcrootc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead root C storage fire mortality to litter', & - ptr_patch=this%m_deadcrootc_storage_to_litter_fire_patch, default='inactive') - - this%m_deadcrootc_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADROOTC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead root C transfer fire mortality to litter', & - ptr_patch=this%m_deadcrootc_xfer_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_LIVECROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C fire mortality to litter', & - ptr_patch=this%m_livecrootc_storage_to_litter_fire_patch, default='inactive') - - this%m_deadcrootc_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_DEADCROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root C storage fire mortality to litter', & - ptr_patch=this%m_deadcrootc_storage_to_litter_fire_patch, default='inactive') - - this%m_gresp_storage_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_GRESP_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration storage fire mortality to litter', & - ptr_patch=this%m_gresp_storage_to_litter_fire_patch, default='inactive') - - this%m_gresp_xfer_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='M_GRESP_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration transfer fire mortality to litter', & - ptr_patch=this%m_gresp_xfer_to_litter_fire_patch, default='inactive') - - this%leafc_xfer_to_leafc_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFC_XFER_TO_LEAFC', units='gC/m^2/s', & - avgflag='A', long_name='leaf C growth from storage', & - ptr_patch=this%leafc_xfer_to_leafc_patch, default='inactive') - - this%frootc_xfer_to_frootc_patch(begp:endp) = spval - call hist_addfld1d (fname='FROOTC_XFER_TO_FROOTC', units='gC/m^2/s', & - avgflag='A', long_name='fine root C growth from storage', & - ptr_patch=this%frootc_xfer_to_frootc_patch, default='inactive') - - this%livestemc_xfer_to_livestemc_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVESTEMC_XFER_TO_LIVESTEMC', units='gC/m^2/s', & - avgflag='A', long_name='live stem C growth from storage', & - ptr_patch=this%livestemc_xfer_to_livestemc_patch, default='inactive') - - this%deadstemc_xfer_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='DEADSTEMC_XFER_TO_DEADSTEMC', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C growth from storage', & - ptr_patch=this%deadstemc_xfer_to_deadstemc_patch, default='inactive') - - this%livecrootc_xfer_to_livecrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVECROOTC_XFER_TO_LIVECROOTC', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C growth from storage', & - ptr_patch=this%livecrootc_xfer_to_livecrootc_patch, default='inactive') - - this%deadcrootc_xfer_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='DEADCROOTC_XFER_TO_DEADCROOTC', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root C growth from storage', & - ptr_patch=this%deadcrootc_xfer_to_deadcrootc_patch, default='inactive') - - this%leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='leaf C litterfall', & - ptr_patch=this%leafc_to_litter_patch, default='active') - - this%frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='FROOTC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='fine root C litterfall', & - ptr_patch=this%frootc_to_litter_patch, default='inactive') - - this%leaf_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAF_MR', units='gC/m^2/s', & - avgflag='A', long_name='leaf maintenance respiration', & - ptr_patch=this%leaf_mr_patch) - - this%froot_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='FROOT_MR', units='gC/m^2/s', & - avgflag='A', long_name='fine root maintenance respiration', & - ptr_patch=this%froot_mr_patch, default='inactive') - - this%livestem_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVESTEM_MR', units='gC/m^2/s', & - avgflag='A', long_name='live stem maintenance respiration', & - ptr_patch=this%livestem_mr_patch, default='inactive') - - this%livecroot_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVECROOT_MR', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root maintenance respiration', & - ptr_patch=this%livecroot_mr_patch, default='inactive') - - this%psnsun_to_cpool_patch(begp:endp) = spval - call hist_addfld1d (fname='PSNSUN_TO_CPOOL', units='gC/m^2/s', & - avgflag='A', long_name='C fixation from sunlit canopy', & - ptr_patch=this%psnsun_to_cpool_patch) - - this%psnshade_to_cpool_patch(begp:endp) = spval - call hist_addfld1d (fname='PSNSHADE_TO_CPOOL', units='gC/m^2/s', & - avgflag='A', long_name='C fixation from shaded canopy', & - ptr_patch=this%psnshade_to_cpool_patch) - - this%cpool_to_leafc_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_LEAFC', units='gC/m^2/s', & - avgflag='A', long_name='allocation to leaf C', & - ptr_patch=this%cpool_to_leafc_patch, default='inactive') - - this%cpool_to_leafc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_LEAFC_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to leaf C storage', & - ptr_patch=this%cpool_to_leafc_storage_patch, default='inactive') - - this%cpool_to_frootc_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_FROOTC', units='gC/m^2/s', & - avgflag='A', long_name='allocation to fine root C', & - ptr_patch=this%cpool_to_frootc_patch, default='inactive') - - this%cpool_to_frootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_FROOTC_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to fine root C storage', & - ptr_patch=this%cpool_to_frootc_storage_patch, default='inactive') - - this%cpool_to_livestemc_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_LIVESTEMC', units='gC/m^2/s', & - avgflag='A', long_name='allocation to live stem C', & - ptr_patch=this%cpool_to_livestemc_patch, default='inactive') - - this%cpool_to_livestemc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_LIVESTEMC_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to live stem C storage', & - ptr_patch=this%cpool_to_livestemc_storage_patch, default='inactive') - - this%cpool_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_DEADSTEMC', units='gC/m^2/s', & - avgflag='A', long_name='allocation to dead stem C', & - ptr_patch=this%cpool_to_deadstemc_patch, default='inactive') - - this%cpool_to_deadstemc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_DEADSTEMC_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to dead stem C storage', & - ptr_patch=this%cpool_to_deadstemc_storage_patch, default='inactive') - - this%cpool_to_livecrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_LIVECROOTC', units='gC/m^2/s', & - avgflag='A', long_name='allocation to live coarse root C', & - ptr_patch=this%cpool_to_livecrootc_patch, default='inactive') - - this%cpool_to_livecrootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_LIVECROOTC_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to live coarse root C storage', & - ptr_patch=this%cpool_to_livecrootc_storage_patch, default='inactive') - - this%cpool_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_DEADCROOTC', units='gC/m^2/s', & - avgflag='A', long_name='allocation to dead coarse root C', & - ptr_patch=this%cpool_to_deadcrootc_patch, default='inactive') - - this%cpool_to_deadcrootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_DEADCROOTC_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to dead coarse root C storage', & - ptr_patch=this%cpool_to_deadcrootc_storage_patch, default='inactive') - - this%cpool_to_gresp_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_TO_GRESP_STORAGE', units='gC/m^2/s', & - avgflag='A', long_name='allocation to growth respiration storage', & - ptr_patch=this%cpool_to_gresp_storage_patch, default='inactive') - - this%cpool_leaf_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_LEAF_GR', units='gC/m^2/s', & - avgflag='A', long_name='leaf growth respiration', & - ptr_patch=this%cpool_leaf_gr_patch, default='inactive') - - this%cpool_leaf_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_LEAF_STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='leaf growth respiration to storage', & - ptr_patch=this%cpool_leaf_storage_gr_patch, default='inactive') - - this%transfer_leaf_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_LEAF_GR', units='gC/m^2/s', & - avgflag='A', long_name='leaf growth respiration from storage', & - ptr_patch=this%transfer_leaf_gr_patch, default='inactive') - - this%cpool_froot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_FROOT_GR', units='gC/m^2/s', & - avgflag='A', long_name='fine root growth respiration', & - ptr_patch=this%cpool_froot_gr_patch, default='inactive') - - this%cpool_froot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_FROOT_STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='fine root growth respiration to storage', & - ptr_patch=this%cpool_froot_storage_gr_patch, default='inactive') - - this%transfer_froot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_FROOT_GR', units='gC/m^2/s', & - avgflag='A', long_name='fine root growth respiration from storage', & - ptr_patch=this%transfer_froot_gr_patch, default='inactive') - - this%cpool_livestem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_LIVESTEM_GR', units='gC/m^2/s', & - avgflag='A', long_name='live stem growth respiration', & - ptr_patch=this%cpool_livestem_gr_patch, default='inactive') - - this%cpool_livestem_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_LIVESTEM_STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='live stem growth respiration to storage', & - ptr_patch=this%cpool_livestem_storage_gr_patch, default='inactive') - - this%transfer_livestem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_LIVESTEM_GR', units='gC/m^2/s', & - avgflag='A', long_name='live stem growth respiration from storage', & - ptr_patch=this%transfer_livestem_gr_patch, default='inactive') - - this%cpool_deadstem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_DEADSTEM_GR', units='gC/m^2/s', & - avgflag='A', long_name='dead stem growth respiration', & - ptr_patch=this%cpool_deadstem_gr_patch, default='inactive') - - this%cpool_deadstem_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_DEADSTEM_STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='dead stem growth respiration to storage', & - ptr_patch=this%cpool_deadstem_storage_gr_patch, default='inactive') - - this%transfer_deadstem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_DEADSTEM_GR', units='gC/m^2/s', & - avgflag='A', long_name='dead stem growth respiration from storage', & - ptr_patch=this%transfer_deadstem_gr_patch, default='inactive') - - this%cpool_livecroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_LIVECROOT_GR', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root growth respiration', & - ptr_patch=this%cpool_livecroot_gr_patch, default='inactive') - - this%cpool_livecroot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_LIVECROOT_STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root growth respiration to storage', & - ptr_patch=this%cpool_livecroot_storage_gr_patch, default='inactive') - - this%transfer_livecroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_LIVECROOT_GR', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root growth respiration from storage', & - ptr_patch=this%transfer_livecroot_gr_patch, default='inactive') - - this%cpool_deadcroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_DEADCROOT_GR', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root growth respiration', & - ptr_patch=this%cpool_deadcroot_gr_patch, default='inactive') - - this%cpool_deadcroot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CPOOL_DEADCROOT_STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root growth respiration to storage', & - ptr_patch=this%cpool_deadcroot_storage_gr_patch, default='inactive') - - this%transfer_deadcroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_DEADCROOT_GR', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root growth respiration from storage', & - ptr_patch=this%transfer_deadcroot_gr_patch, default='inactive') - - this%leafc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFC_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='leaf C shift storage to transfer', & - ptr_patch=this%leafc_storage_to_xfer_patch, default='inactive') - - this%frootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='FROOTC_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='fine root C shift storage to transfer', & - ptr_patch=this%frootc_storage_to_xfer_patch, default='inactive') - - this%livestemc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVESTEMC_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='live stem C shift storage to transfer', & - ptr_patch=this%livestemc_storage_to_xfer_patch, default='inactive') - - this%deadstemc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='DEADSTEMC_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='dead stem C shift storage to transfer', & - ptr_patch=this%deadstemc_storage_to_xfer_patch, default='inactive') - - this%livecrootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVECROOTC_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C shift storage to transfer', & - ptr_patch=this%livecrootc_storage_to_xfer_patch, default='inactive') - - this%deadcrootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='DEADCROOTC_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='dead coarse root C shift storage to transfer', & - ptr_patch=this%deadcrootc_storage_to_xfer_patch, default='inactive') - - this%gresp_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='GRESP_STORAGE_TO_XFER', units='gC/m^2/s', & - avgflag='A', long_name='growth respiration shift storage to transfer', & - ptr_patch=this%gresp_storage_to_xfer_patch, default='inactive') - - this%livestemc_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVESTEMC_TO_DEADSTEMC', units='gC/m^2/s', & - avgflag='A', long_name='live stem C turnover', & - ptr_patch=this%livestemc_to_deadstemc_patch, default='inactive') - - this%livecrootc_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='LIVECROOTC_TO_DEADCROOTC', units='gC/m^2/s', & - avgflag='A', long_name='live coarse root C turnover', & - ptr_patch=this%livecrootc_to_deadcrootc_patch, default='inactive') - - this%gpp_patch(begp:endp) = spval - call hist_addfld1d (fname='GPP', units='gC/m^2/s', & - avgflag='A', long_name='gross primary production', & - ptr_patch=this%gpp_patch) - - this%gpp_before_downreg_patch(begp:endp) = spval - call hist_addfld1d (fname='INIT_GPP', units='gC/m^2/s', & - avgflag='A', long_name='GPP flux before downregulation', & - ptr_patch=this%gpp_before_downreg_patch, default='inactive') - - this%mr_patch(begp:endp) = spval - call hist_addfld1d (fname='MR', units='gC/m^2/s', & - avgflag='A', long_name='maintenance respiration', & - ptr_patch=this%mr_patch) - - this%current_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='CURRENT_GR', units='gC/m^2/s', & - avgflag='A', long_name='growth resp for new growth displayed in this timestep', & - ptr_patch=this%current_gr_patch, default='inactive') - - this%transfer_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='TRANSFER_GR', units='gC/m^2/s', & - avgflag='A', long_name='growth resp for transfer growth displayed in this timestep', & - ptr_patch=this%transfer_gr_patch, default='inactive') - - this%storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='STORAGE_GR', units='gC/m^2/s', & - avgflag='A', long_name='growth resp for growth sent to storage for later display', & - ptr_patch=this%storage_gr_patch, default='inactive') - - this%gr_patch(begp:endp) = spval - call hist_addfld1d (fname='GR', units='gC/m^2/s', & - avgflag='A', long_name='total growth respiration', & - ptr_patch=this%gr_patch) - - this%ar_patch(begp:endp) = spval - call hist_addfld1d (fname='AR', units='gC/m^2/s', & - avgflag='A', long_name='autotrophic respiration (MR + GR)', & - ptr_patch=this%ar_patch) - - this%rr_patch(begp:endp) = spval - call hist_addfld1d (fname='RR', units='gC/m^2/s', & - avgflag='A', long_name='root respiration (fine root MR + total root GR)', & - ptr_patch=this%rr_patch) - - this%npp_patch(begp:endp) = spval - call hist_addfld1d (fname='NPP', units='gC/m^2/s', & - avgflag='A', long_name='net primary production', & - ptr_patch=this%npp_patch) - - this%agnpp_patch(begp:endp) = spval - call hist_addfld1d (fname='AGNPP', units='gC/m^2/s', & - avgflag='A', long_name='aboveground NPP', & - ptr_patch=this%agnpp_patch) - - this%bgnpp_patch(begp:endp) = spval - call hist_addfld1d (fname='BGNPP', units='gC/m^2/s', & - avgflag='A', long_name='belowground NPP', & - ptr_patch=this%bgnpp_patch) - - this%litfall_patch(begp:endp) = spval - call hist_addfld1d (fname='LITFALL', units='gC/m^2/s', & - avgflag='A', long_name='litterfall (leaves and fine roots)', & - ptr_patch=this%litfall_patch) - - this%vegfire_patch(begp:endp) = spval - call hist_addfld1d (fname='VEGFIRE', units='gC/m^2/s', & - avgflag='A', long_name='patch-level fire loss', & - ptr_patch=this%vegfire_patch, default='inactive') - - this%wood_harvestc_patch(begp:endp) = spval - call hist_addfld1d (fname='WOOD_HARVESTC', units='gC/m^2/s', & - avgflag='A', long_name='wood harvest carbon (to product pools)', & - ptr_patch=this%wood_harvestc_patch) - - this%fire_closs_patch(begp:endp) = spval - call hist_addfld1d (fname='PFT_FIRE_CLOSS', units='gC/m^2/s', & - avgflag='A', long_name='total patch-level fire C loss for non-peat fires outside land-type converted region', & - ptr_patch=this%fire_closs_patch) - - this%availc_patch(begp:endp) = spval - call hist_addfld1d (fname='AVAILC', units='gC/m^2/s', & - avgflag='A', long_name='C flux available for allocation', & - ptr_patch=this%availc_patch, default='active') - - this%plant_calloc_patch(begp:endp) = spval - call hist_addfld1d (fname='PLANT_CALLOC', units='gC/m^2/s', & - avgflag='A', long_name='total allocated C flux', & - ptr_patch=this%plant_calloc_patch, default='active') - - this%excess_cflux_patch(begp:endp) = spval - call hist_addfld1d (fname='EXCESS_CFLUX', units='gC/m^2/s', & - avgflag='A', long_name='C flux not allocated due to downregulation', & - ptr_patch=this%excess_cflux_patch, default='inactive') - - this%prev_leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='PREV_LEAFC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='previous timestep leaf C litterfall flux', & - ptr_patch=this%prev_leafc_to_litter_patch, default='inactive') - - this%prev_frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='PREV_FROOTC_TO_LITTER', units='gC/m^2/s', & - avgflag='A', long_name='previous timestep froot C litterfall flux', & - ptr_patch=this%prev_frootc_to_litter_patch, default='inactive') - - this%xsmrpool_recover_patch(begp:endp) = spval - call hist_addfld1d (fname='XSMRPOOL_RECOVER', units='gC/m^2/s', & - avgflag='A', long_name='C flux assigned to recovery of negative xsmrpool', & - ptr_patch=this%xsmrpool_recover_patch, default='inactive') - - if (nu_com .ne. 'RD' ) then - this%allocation_leaf(begp:endp) = spval - call hist_addfld1d (fname='allocation_leaf', units='', & - avgflag='A', long_name='fraction of availc allocated to leaf', & - ptr_patch=this%allocation_leaf) - this%allocation_stem(begp:endp) = spval - call hist_addfld1d (fname='allocation_stem', units='', & - avgflag='A', long_name='fraction of availc allocated to stem', & - ptr_patch=this%allocation_stem) - this%allocation_froot(begp:endp) = spval - call hist_addfld1d (fname='allocation_froot', units='', & - avgflag='A', long_name='fraction of availc allocated to fine root', & - ptr_patch=this%allocation_froot) - end if - - end if ! end of if-c12 - - !------------------------------- - ! C13 flux variables - native to PFT - !------------------------------- - if ( carbon_type == 'c13') then - - this%m_leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LEAFC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C mortality', & - ptr_patch=this%m_leafc_to_litter_patch, default='inactive') - - this%m_frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_FROOTC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C mortality', & - ptr_patch=this%m_frootc_to_litter_patch, default='inactive') - - this%m_leafc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LEAFC_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C storage mortality', & - ptr_patch=this%m_leafc_storage_to_litter_patch, default='inactive') - - this%m_frootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_FROOTC_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C storage mortality', & - ptr_patch=this%m_frootc_storage_to_litter_patch, default='inactive') - - this%m_livestemc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVESTEMC_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C storage mortality', & - ptr_patch=this%m_livestemc_storage_to_litter_patch, default='inactive') - - this%m_deadstemc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C storage mortality', & - ptr_patch=this%m_deadstemc_storage_to_litter_patch, default='inactive') - - this%m_livecrootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVECROOTC_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C storage mortality', & - ptr_patch=this%m_livecrootc_storage_to_litter_patch, default='inactive') - - this%m_deadcrootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C storage mortality', & - ptr_patch=this%m_deadcrootc_storage_to_litter_patch, default='inactive') - - this%m_leafc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LEAFC_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C transfer mortality', & - ptr_patch=this%m_leafc_xfer_to_litter_patch, default='inactive') - - this%m_frootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_FROOTC_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C transfer mortality', & - ptr_patch=this%m_frootc_xfer_to_litter_patch, default='inactive') - - this%m_livestemc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVESTEMC_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C transfer mortality', & - ptr_patch=this%m_livestemc_xfer_to_litter_patch, default='inactive') - - this%m_deadstemc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C transfer mortality', & - ptr_patch=this%m_deadstemc_xfer_to_litter_patch, default='inactive') - - this%m_livecrootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVECROOTC_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C transfer mortality', & - ptr_patch=this%m_livecrootc_xfer_to_litter_patch, default='inactive') - - this%m_deadcrootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C transfer mortality', & - ptr_patch=this%m_deadcrootc_xfer_to_litter_patch, default='inactive') - - this%m_livestemc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVESTEMC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C mortality', & - ptr_patch=this%m_livestemc_to_litter_patch, default='inactive') - - this%m_deadstemc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C mortality', & - ptr_patch=this%m_deadstemc_to_litter_patch, default='inactive') - - this%m_livecrootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVECROOTC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C mortality', & - ptr_patch=this%m_livecrootc_to_litter_patch, default='inactive') - - this%m_deadcrootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C mortality', & - ptr_patch=this%m_deadcrootc_to_litter_patch, default='inactive') - - this%m_gresp_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_GRESP_STORAGE_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth respiration storage mortality', & - ptr_patch=this%m_gresp_storage_to_litter_patch, default='inactive') - - this%m_gresp_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_GRESP_XFER_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth respiration transfer mortality', & - ptr_patch=this%m_gresp_xfer_to_litter_patch, default='inactive') - - this%m_leafc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LEAFC_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C fire loss', & - ptr_patch=this%m_leafc_to_fire_patch, default='inactive') - - this%m_frootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_FROOTC_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C fire loss', & - ptr_patch=this%m_frootc_to_fire_patch, default='inactive') - - this%m_leafc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LEAFC_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C storage fire loss', & - ptr_patch=this%m_leafc_storage_to_fire_patch, default='inactive') - - this%m_frootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_FROOTC_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C storage fire loss', & - ptr_patch=this%m_frootc_storage_to_fire_patch, default='inactive') - - this%m_livestemc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVESTEMC_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C storage fire loss', & - ptr_patch=this%m_livestemc_storage_to_fire_patch, default='inactive') - - this%m_deadstemc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C storage fire loss', & - ptr_patch=this%m_deadstemc_storage_to_fire_patch, default='inactive') - - this%m_livecrootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVECROOTC_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C storage fire loss', & - ptr_patch=this%m_livecrootc_storage_to_fire_patch, default='inactive') - - this%m_deadcrootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C storage fire loss', & - ptr_patch=this%m_deadcrootc_storage_to_fire_patch, default='inactive') - - this%m_leafc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LEAFC_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C transfer fire loss', & - ptr_patch=this%m_leafc_xfer_to_fire_patch, default='inactive') - - this%m_frootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_FROOTC_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C transfer fire loss', & - ptr_patch=this%m_frootc_xfer_to_fire_patch, default='inactive') - - this%m_livestemc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVESTEMC_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C transfer fire loss', & - ptr_patch=this%m_livestemc_xfer_to_fire_patch, default='inactive') - - this%m_deadstemc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C transfer fire loss', & - ptr_patch=this%m_deadstemc_xfer_to_fire_patch, default='inactive') - - this%m_livecrootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVECROOTC_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C transfer fire loss', & - ptr_patch=this%m_livecrootc_xfer_to_fire_patch, default='inactive') - - this%m_deadcrootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C transfer fire loss', & - ptr_patch=this%m_deadcrootc_xfer_to_fire_patch, default='inactive') - - this%m_livestemc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVESTEMC_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C fire loss', & - ptr_patch=this%m_livestemc_to_fire_patch, default='inactive') - - this%m_deadstemc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C fire loss', & - ptr_patch=this%m_deadstemc_to_fire_patch, default='inactive') - - this%m_deadstemc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADSTEMC_TO_LITTER_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C fire mortality to litter', & - ptr_patch=this%m_deadstemc_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_LIVECROOTC_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C fire loss', & - ptr_patch=this%m_livecrootc_to_fire_patch, default='inactive') - - this%m_deadcrootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C fire loss', & - ptr_patch=this%m_deadcrootc_to_fire_patch, default='inactive') - - this%m_deadcrootc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_DEADCROOTC_TO_LITTER_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C fire mortality to litter', & - ptr_patch=this%m_deadcrootc_to_litter_fire_patch, default='inactive') - - this%m_gresp_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_GRESP_STORAGE_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth respiration storage fire loss', & - ptr_patch=this%m_gresp_storage_to_fire_patch, default='inactive') - - this%m_gresp_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_M_GRESP_XFER_TO_FIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth respiration transfer fire loss', & - ptr_patch=this%m_gresp_xfer_to_fire_patch, default='inactive') - - this%leafc_xfer_to_leafc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LEAFC_XFER_TO_LEAFC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C growth from storage', & - ptr_patch=this%leafc_xfer_to_leafc_patch, default='inactive') - - this%frootc_xfer_to_frootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_FROOTC_XFER_TO_FROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C growth from storage', & - ptr_patch=this%frootc_xfer_to_frootc_patch, default='inactive') - - this%livestemc_xfer_to_livestemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVESTEMC_XFER_TO_LIVESTEMC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C growth from storage', & - ptr_patch=this%livestemc_xfer_to_livestemc_patch, default='inactive') - - this%deadstemc_xfer_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_DEADSTEMC_XFER_TO_DEADSTEMC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C growth from storage', & - ptr_patch=this%deadstemc_xfer_to_deadstemc_patch, default='inactive') - - this%livecrootc_xfer_to_livecrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVECROOTC_XFER_TO_LIVECROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C growth from storage', & - ptr_patch=this%livecrootc_xfer_to_livecrootc_patch, default='inactive') - - this%deadcrootc_xfer_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_DEADCROOTC_XFER_TO_DEADCROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C growth from storage', & - ptr_patch=this%deadcrootc_xfer_to_deadcrootc_patch, default='inactive') - - this%leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LEAFC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C litterfall', & - ptr_patch=this%leafc_to_litter_patch, default='inactive') - - this%frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_FROOTC_TO_LITTER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C litterfall', & - ptr_patch=this%frootc_to_litter_patch, default='inactive') - - this%leaf_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LEAF_MR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf maintenance respiration', & - ptr_patch=this%leaf_mr_patch, default='inactive') - - this%froot_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_FROOT_MR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root maintenance respiration', & - ptr_patch=this%froot_mr_patch, default='inactive') - - this%livestem_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVESTEM_MR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem maintenance respiration', & - ptr_patch=this%livestem_mr_patch, default='inactive') - - this%livecroot_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVECROOT_MR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root maintenance respiration', & - ptr_patch=this%livecroot_mr_patch, default='inactive') - - this%psnsun_to_cpool_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_PSNSUN_TO_CPOOL', units='gC13/m^2/s', & - avgflag='A', long_name='C13 C fixation from sunlit canopy', & - ptr_patch=this%psnsun_to_cpool_patch) - - this%psnshade_to_cpool_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_PSNSHADE_TO_CPOOL', units='gC13/m^2/s', & - avgflag='A', long_name='C13 C fixation from shaded canopy', & - ptr_patch=this%psnshade_to_cpool_patch) - - this%cpool_to_leafc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_LEAFC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to leaf C', & - ptr_patch=this%cpool_to_leafc_patch, default='inactive') - - this%cpool_to_leafc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_LEAFC_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to leaf C storage', & - ptr_patch=this%cpool_to_leafc_storage_patch, default='inactive') - - this%cpool_to_frootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_FROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to fine root C', & - ptr_patch=this%cpool_to_frootc_patch, default='inactive') - - this%cpool_to_frootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_FROOTC_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to fine root C storage', & - ptr_patch=this%cpool_to_frootc_storage_patch, default='inactive') - - this%cpool_to_livestemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_LIVESTEMC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to live stem C', & - ptr_patch=this%cpool_to_livestemc_patch, default='inactive') - - this%cpool_to_livestemc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_LIVESTEMC_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to live stem C storage', & - ptr_patch=this%cpool_to_livestemc_storage_patch, default='inactive') - - this%cpool_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_DEADSTEMC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to dead stem C', & - ptr_patch=this%cpool_to_deadstemc_patch, default='inactive') - - this%cpool_to_deadstemc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_DEADSTEMC_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to dead stem C storage', & - ptr_patch=this%cpool_to_deadstemc_storage_patch, default='inactive') - - this%cpool_to_livecrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_LIVECROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to live coarse root C', & - ptr_patch=this%cpool_to_livecrootc_patch, default='inactive') - - this%cpool_to_livecrootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_LIVECROOTC_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to live coarse root C storage', & - ptr_patch=this%cpool_to_livecrootc_storage_patch, default='inactive') - - this%cpool_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_DEADCROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to dead coarse root C', & - ptr_patch=this%cpool_to_deadcrootc_patch, default='inactive') - - this%cpool_to_deadcrootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_DEADCROOTC_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to dead coarse root C storage', & - ptr_patch=this%cpool_to_deadcrootc_storage_patch, default='inactive') - - this%cpool_to_gresp_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_TO_GRESP_STORAGE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 allocation to growth respiration storage', & - ptr_patch=this%cpool_to_gresp_storage_patch, default='inactive') - - this%cpool_leaf_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_LEAF_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf growth respiration', & - ptr_patch=this%cpool_leaf_gr_patch, default='inactive') - - this%cpool_leaf_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_LEAF_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf growth respiration to storage', & - ptr_patch=this%cpool_leaf_storage_gr_patch, default='inactive') - - this%transfer_leaf_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_LEAF_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf growth respiration from storage', & - ptr_patch=this%transfer_leaf_gr_patch, default='inactive') - - this%cpool_froot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_FROOT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root growth respiration', & - ptr_patch=this%cpool_froot_gr_patch, default='inactive') - - this%cpool_froot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_FROOT_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root growth respiration to storage', & - ptr_patch=this%cpool_froot_storage_gr_patch, default='inactive') - - this%transfer_froot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_FROOT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root growth respiration from storage', & - ptr_patch=this%transfer_froot_gr_patch, default='inactive') - - this%cpool_livestem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_LIVESTEM_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem growth respiration', & - ptr_patch=this%cpool_livestem_gr_patch, default='inactive') - - this%cpool_livestem_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_LIVESTEM_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem growth respiration to storage', & - ptr_patch=this%cpool_livestem_storage_gr_patch, default='inactive') - - this%transfer_livestem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_LIVESTEM_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem growth respiration from storage', & - ptr_patch=this%transfer_livestem_gr_patch, default='inactive') - - this%cpool_deadstem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_DEADSTEM_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem growth respiration', & - ptr_patch=this%cpool_deadstem_gr_patch, default='inactive') - - this%cpool_deadstem_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_DEADSTEM_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem growth respiration to storage', & - ptr_patch=this%cpool_deadstem_storage_gr_patch, default='inactive') - - this%transfer_deadstem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_DEADSTEM_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem growth respiration from storage', & - ptr_patch=this%transfer_deadstem_gr_patch, default='inactive') - - this%cpool_livecroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_LIVECROOT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root growth respiration', & - ptr_patch=this%cpool_livecroot_gr_patch, default='inactive') - - this%cpool_livecroot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_LIVECROOT_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root growth respiration to storage', & - ptr_patch=this%cpool_livecroot_storage_gr_patch, default='inactive') - - this%transfer_livecroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_LIVECROOT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root growth respiration from storage', & - ptr_patch=this%transfer_livecroot_gr_patch, default='inactive') - - this%cpool_deadcroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_DEADCROOT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root growth respiration', & - ptr_patch=this%cpool_deadcroot_gr_patch, default='inactive') - - this%cpool_deadcroot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CPOOL_DEADCROOT_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root growth respiration to storage', & - ptr_patch=this%cpool_deadcroot_storage_gr_patch, default='inactive') - - this%transfer_deadcroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_DEADCROOT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root growth respiration from storage', & - ptr_patch=this%transfer_deadcroot_gr_patch, default='inactive') - - this%leafc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LEAFC_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 leaf C shift storage to transfer', & - ptr_patch=this%leafc_storage_to_xfer_patch, default='inactive') - - this%frootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_FROOTC_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C shift storage to transfer', & - ptr_patch=this%frootc_storage_to_xfer_patch, default='inactive') - - this%livestemc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVESTEMC_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C shift storage to transfer', & - ptr_patch=this%livestemc_storage_to_xfer_patch, default='inactive') - - this%deadstemc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_DEADSTEMC_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead stem C shift storage to transfer', & - ptr_patch=this%deadstemc_storage_to_xfer_patch, default='inactive') - - this%livecrootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVECROOTC_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C shift storage to transfer', & - ptr_patch=this%livecrootc_storage_to_xfer_patch, default='inactive') - - this%deadcrootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_DEADCROOTC_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 dead coarse root C shift storage to transfer', & - ptr_patch=this%deadcrootc_storage_to_xfer_patch, default='inactive') - - this%gresp_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_GRESP_STORAGE_TO_XFER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth respiration shift storage to transfer', & - ptr_patch=this%gresp_storage_to_xfer_patch, default='inactive') - - this%livestemc_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVESTEMC_TO_DEADSTEMC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live stem C turnover', & - ptr_patch=this%livestemc_to_deadstemc_patch, default='inactive') - - this%livecrootc_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LIVECROOTC_TO_DEADCROOTC', units='gC13/m^2/s', & - avgflag='A', long_name='C13 live coarse root C turnover', & - ptr_patch=this%livecrootc_to_deadcrootc_patch, default='inactive') - - this%gpp_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_GPP', units='gC13/m^2/s', & - avgflag='A', long_name='C13 gross primary production', & - ptr_patch=this%gpp_patch) - - this%mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_MR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 maintenance respiration', & - ptr_patch=this%mr_patch) - - this%current_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_CURRENT_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth resp for new growth displayed in this timestep', & - ptr_patch=this%current_gr_patch, default='inactive') - - this%transfer_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_TRANSFER_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth resp for transfer growth displayed in this timestep', & - ptr_patch=this%transfer_gr_patch, default='inactive') - - this%storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_STORAGE_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 growth resp for growth sent to storage for later display', & - ptr_patch=this%storage_gr_patch, default='inactive') - - this%gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_GR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total growth respiration', & - ptr_patch=this%gr_patch) - - this%ar_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_AR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 autotrophic respiration (MR + GR)', & - ptr_patch=this%ar_patch) - - this%rr_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_RR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 root respiration (fine root MR + total root GR)', & - ptr_patch=this%rr_patch) - - this%npp_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_NPP', units='gC13/m^2/s', & - avgflag='A', long_name='C13 net primary production', & - ptr_patch=this%npp_patch) - - this%agnpp_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_AGNPP', units='gC13/m^2/s', & - avgflag='A', long_name='C13 aboveground NPP', & - ptr_patch=this%agnpp_patch) - - this%bgnpp_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_BGNPP', units='gC13/m^2/s', & - avgflag='A', long_name='C13 belowground NPP', & - ptr_patch=this%bgnpp_patch) - - this%litfall_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_LITFALL', units='gC13/m^2/s', & - avgflag='A', long_name='C13 litterfall (leaves and fine roots)', & - ptr_patch=this%litfall_patch, default='inactive') - - this%vegfire_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_VEGFIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 patch-level fire loss', & - ptr_patch=this%vegfire_patch, default='inactive') - - this%fire_closs_patch(begp:endp) = spval - call hist_addfld1d (fname='C13_PFT_FIRE_CLOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total patch-level fire C loss', & - ptr_patch=this%fire_closs_patch) - endif - - !------------------------------- - ! C14 flux variables - native to PFT - !------------------------------- - if ( carbon_type == 'c14' ) then - - this%m_leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LEAFC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C mortality', & - ptr_patch=this%m_leafc_to_litter_patch, default='inactive') - - this%m_frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_FROOTC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C mortality', & - ptr_patch=this%m_frootc_to_litter_patch, default='inactive') - - this%m_leafc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LEAFC_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C storage mortality', & - ptr_patch=this%m_leafc_storage_to_litter_patch, default='inactive') - - this%m_frootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_FROOTC_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C storage mortality', & - ptr_patch=this%m_frootc_storage_to_litter_patch, default='inactive') - - this%m_livestemc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVESTEMC_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C storage mortality', & - ptr_patch=this%m_livestemc_storage_to_litter_patch, default='inactive') - - this%m_deadstemc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C storage mortality', & - ptr_patch=this%m_deadstemc_storage_to_litter_patch, default='inactive') - - this%m_livecrootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVECROOTC_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C storage mortality', & - ptr_patch=this%m_livecrootc_storage_to_litter_patch, default='inactive') - - this%m_deadcrootc_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C storage mortality', & - ptr_patch=this%m_deadcrootc_storage_to_litter_patch, default='inactive') - - this%m_leafc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LEAFC_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C transfer mortality', & - ptr_patch=this%m_leafc_xfer_to_litter_patch, default='inactive') - - this%m_frootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_FROOTC_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C transfer mortality', & - ptr_patch=this%m_frootc_xfer_to_litter_patch, default='inactive') - - this%m_livestemc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVESTEMC_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C transfer mortality', & - ptr_patch=this%m_livestemc_xfer_to_litter_patch, default='inactive') - - this%m_deadstemc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C transfer mortality', & - ptr_patch=this%m_deadstemc_xfer_to_litter_patch, default='inactive') - - this%m_livecrootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVECROOTC_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C transfer mortality', & - ptr_patch=this%m_livecrootc_xfer_to_litter_patch, default='inactive') - - this%m_deadcrootc_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C transfer mortality', & - ptr_patch=this%m_deadcrootc_xfer_to_litter_patch, default='inactive') - - this%m_livestemc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVESTEMC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C mortality', & - ptr_patch=this%m_livestemc_to_litter_patch, default='inactive') - - this%m_deadstemc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C mortality', & - ptr_patch=this%m_deadstemc_to_litter_patch, default='inactive') - - this%m_livecrootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVECROOTC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C mortality', & - ptr_patch=this%m_livecrootc_to_litter_patch, default='inactive') - - this%m_deadcrootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C mortality', & - ptr_patch=this%m_deadcrootc_to_litter_patch, default='inactive') - - this%m_gresp_storage_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_GRESP_STORAGE_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth respiration storage mortality', & - ptr_patch=this%m_gresp_storage_to_litter_patch, default='inactive') - - this%m_gresp_xfer_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_GRESP_XFER_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth respiration transfer mortality', & - ptr_patch=this%m_gresp_xfer_to_litter_patch, default='inactive') - - this%m_leafc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LEAFC_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C fire loss', & - ptr_patch=this%m_leafc_to_fire_patch, default='inactive') - - this%m_frootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_FROOTC_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C fire loss', & - ptr_patch=this%m_frootc_to_fire_patch, default='inactive') - - this%m_leafc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LEAFC_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C storage fire loss', & - ptr_patch=this%m_leafc_storage_to_fire_patch, default='inactive') - - this%m_frootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_FROOTC_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C storage fire loss', & - ptr_patch=this%m_frootc_storage_to_fire_patch, default='inactive') - - this%m_livestemc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVESTEMC_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C storage fire loss', & - ptr_patch=this%m_livestemc_storage_to_fire_patch, default='inactive') - - this%m_deadstemc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C storage fire loss', & - ptr_patch=this%m_deadstemc_storage_to_fire_patch, default='inactive') - - this%m_livecrootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVECROOTC_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C storage fire loss', & - ptr_patch=this%m_livecrootc_storage_to_fire_patch, default='inactive') - - this%m_deadcrootc_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C storage fire loss', & - ptr_patch=this%m_deadcrootc_storage_to_fire_patch, default='inactive') - - this%m_leafc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LEAFC_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C transfer fire loss', & - ptr_patch=this%m_leafc_xfer_to_fire_patch, default='inactive') - - this%m_frootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_FROOTC_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C transfer fire loss', & - ptr_patch=this%m_frootc_xfer_to_fire_patch, default='inactive') - - this%m_livestemc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVESTEMC_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C transfer fire loss', & - ptr_patch=this%m_livestemc_xfer_to_fire_patch, default='inactive') - - this%m_deadstemc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C transfer fire loss', & - ptr_patch=this%m_deadstemc_xfer_to_fire_patch, default='inactive') - - this%m_livecrootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVECROOTC_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C transfer fire loss', & - ptr_patch=this%m_livecrootc_xfer_to_fire_patch, default='inactive') - - this%m_deadcrootc_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C transfer fire loss', & - ptr_patch=this%m_deadcrootc_xfer_to_fire_patch, default='inactive') - - this%m_livestemc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVESTEMC_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C fire loss', & - ptr_patch=this%m_livestemc_to_fire_patch, default='inactive') - - this%m_deadstemc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C fire loss', & - ptr_patch=this%m_deadstemc_to_fire_patch, default='inactive') - - this%m_deadstemc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADSTEMC_TO_LITTER_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C fire mortality to litter', & - ptr_patch=this%m_deadstemc_to_litter_fire_patch, default='inactive') - - this%m_livecrootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_LIVECROOTC_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C fire loss', & - ptr_patch=this%m_livecrootc_to_fire_patch, default='inactive') - - this%m_deadcrootc_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C fire loss', & - ptr_patch=this%m_deadcrootc_to_fire_patch, default='inactive') - - this%m_deadcrootc_to_litter_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_DEADCROOTC_TO_LITTER_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C fire mortality to litter', & - ptr_patch=this%m_deadcrootc_to_litter_fire_patch, default='inactive') - - this%m_gresp_storage_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_GRESP_STORAGE_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth respiration storage fire loss', & - ptr_patch=this%m_gresp_storage_to_fire_patch, default='inactive') - - this%m_gresp_xfer_to_fire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_M_GRESP_XFER_TO_FIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth respiration transfer fire loss', & - ptr_patch=this%m_gresp_xfer_to_fire_patch, default='inactive') - - this%leafc_xfer_to_leafc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LEAFC_XFER_TO_LEAFC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C growth from storage', & - ptr_patch=this%leafc_xfer_to_leafc_patch, default='inactive') - - this%frootc_xfer_to_frootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_FROOTC_XFER_TO_FROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C growth from storage', & - ptr_patch=this%frootc_xfer_to_frootc_patch, default='inactive') - - this%livestemc_xfer_to_livestemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVESTEMC_XFER_TO_LIVESTEMC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C growth from storage', & - ptr_patch=this%livestemc_xfer_to_livestemc_patch, default='inactive') - - this%deadstemc_xfer_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_DEADSTEMC_XFER_TO_DEADSTEMC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C growth from storage', & - ptr_patch=this%deadstemc_xfer_to_deadstemc_patch, default='inactive') - - this%livecrootc_xfer_to_livecrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVECROOTC_XFER_TO_LIVECROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C growth from storage', & - ptr_patch=this%livecrootc_xfer_to_livecrootc_patch, default='inactive') - - this%deadcrootc_xfer_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_DEADCROOTC_XFER_TO_DEADCROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C growth from storage', & - ptr_patch=this%deadcrootc_xfer_to_deadcrootc_patch, default='inactive') - - this%leafc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LEAFC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C litterfall', & - ptr_patch=this%leafc_to_litter_patch, default='inactive') - - this%frootc_to_litter_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_FROOTC_TO_LITTER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C litterfall', & - ptr_patch=this%frootc_to_litter_patch, default='inactive') - - this%leaf_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LEAF_MR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf maintenance respiration', & - ptr_patch=this%leaf_mr_patch, default='inactive') - - this%froot_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_FROOT_MR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root maintenance respiration', & - ptr_patch=this%froot_mr_patch, default='inactive') - - this%livestem_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVESTEM_MR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem maintenance respiration', & - ptr_patch=this%livestem_mr_patch, default='inactive') - - this%livecroot_mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVECROOT_MR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root maintenance respiration', & - ptr_patch=this%livecroot_mr_patch, default='inactive') - - this%psnsun_to_cpool_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_PSNSUN_TO_CPOOL', units='gC14/m^2/s', & - avgflag='A', long_name='C14 C fixation from sunlit canopy', & - ptr_patch=this%psnsun_to_cpool_patch) - - this%psnshade_to_cpool_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_PSNSHADE_TO_CPOOL', units='gC14/m^2/s', & - avgflag='A', long_name='C14 C fixation from shaded canopy', & - ptr_patch=this%psnshade_to_cpool_patch) - - this%cpool_to_leafc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_LEAFC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to leaf C', & - ptr_patch=this%cpool_to_leafc_patch, default='inactive') - - this%cpool_to_leafc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_LEAFC_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to leaf C storage', & - ptr_patch=this%cpool_to_leafc_storage_patch, default='inactive') - - this%cpool_to_frootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_FROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to fine root C', & - ptr_patch=this%cpool_to_frootc_patch, default='inactive') - - this%cpool_to_frootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_FROOTC_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to fine root C storage', & - ptr_patch=this%cpool_to_frootc_storage_patch, default='inactive') - - this%cpool_to_livestemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_LIVESTEMC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to live stem C', & - ptr_patch=this%cpool_to_livestemc_patch, default='inactive') - - this%cpool_to_livestemc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_LIVESTEMC_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to live stem C storage', & - ptr_patch=this%cpool_to_livestemc_storage_patch, default='inactive') - - this%cpool_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_DEADSTEMC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to dead stem C', & - ptr_patch=this%cpool_to_deadstemc_patch, default='inactive') - - this%cpool_to_deadstemc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_DEADSTEMC_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to dead stem C storage', & - ptr_patch=this%cpool_to_deadstemc_storage_patch, default='inactive') - - this%cpool_to_livecrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_LIVECROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to live coarse root C', & - ptr_patch=this%cpool_to_livecrootc_patch, default='inactive') - - this%cpool_to_livecrootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_LIVECROOTC_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to live coarse root C storage', & - ptr_patch=this%cpool_to_livecrootc_storage_patch, default='inactive') - - this%cpool_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_DEADCROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to dead coarse root C', & - ptr_patch=this%cpool_to_deadcrootc_patch, default='inactive') - - this%cpool_to_deadcrootc_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_DEADCROOTC_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to dead coarse root C storage', & - ptr_patch=this%cpool_to_deadcrootc_storage_patch, default='inactive') - - this%cpool_to_gresp_storage_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_TO_GRESP_STORAGE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 allocation to growth respiration storage', & - ptr_patch=this%cpool_to_gresp_storage_patch, default='inactive') - - this%cpool_leaf_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_LEAF_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf growth respiration', & - ptr_patch=this%cpool_leaf_gr_patch, default='inactive') - - this%cpool_leaf_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_LEAF_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf growth respiration to storage', & - ptr_patch=this%cpool_leaf_storage_gr_patch, default='inactive') - - this%transfer_leaf_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_LEAF_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf growth respiration from storage', & - ptr_patch=this%transfer_leaf_gr_patch, default='inactive') - - this%cpool_froot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_FROOT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root growth respiration', & - ptr_patch=this%cpool_froot_gr_patch, default='inactive') - - this%cpool_froot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_FROOT_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root growth respiration to storage', & - ptr_patch=this%cpool_froot_storage_gr_patch, default='inactive') - - this%transfer_froot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_FROOT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root growth respiration from storage', & - ptr_patch=this%transfer_froot_gr_patch, default='inactive') - - this%cpool_livestem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_LIVESTEM_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem growth respiration', & - ptr_patch=this%cpool_livestem_gr_patch, default='inactive') - - this%cpool_livestem_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_LIVESTEM_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem growth respiration to storage', & - ptr_patch=this%cpool_livestem_storage_gr_patch, default='inactive') - - this%transfer_livestem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_LIVESTEM_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem growth respiration from storage', & - ptr_patch=this%transfer_livestem_gr_patch, default='inactive') - - this%cpool_deadstem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_DEADSTEM_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem growth respiration', & - ptr_patch=this%cpool_deadstem_gr_patch, default='inactive') - - this%cpool_deadstem_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_DEADSTEM_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem growth respiration to storage', & - ptr_patch=this%cpool_deadstem_storage_gr_patch, default='inactive') - - this%transfer_deadstem_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_DEADSTEM_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem growth respiration from storage', & - ptr_patch=this%transfer_deadstem_gr_patch, default='inactive') - - this%cpool_livecroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_LIVECROOT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root growth respiration', & - ptr_patch=this%cpool_livecroot_gr_patch, default='inactive') - - this%cpool_livecroot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_LIVECROOT_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root growth respiration to storage', & - ptr_patch=this%cpool_livecroot_storage_gr_patch, default='inactive') - - this%transfer_livecroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_LIVECROOT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root growth respiration from storage', & - ptr_patch=this%transfer_livecroot_gr_patch, default='inactive') - - this%cpool_deadcroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_DEADCROOT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root growth respiration', & - ptr_patch=this%cpool_deadcroot_gr_patch, default='inactive') - - this%cpool_deadcroot_storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CPOOL_DEADCROOT_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root growth respiration to storage', & - ptr_patch=this%cpool_deadcroot_storage_gr_patch, default='inactive') - - this%transfer_deadcroot_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_DEADCROOT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root growth respiration from storage', & - ptr_patch=this%transfer_deadcroot_gr_patch, default='inactive') - - this%leafc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LEAFC_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 leaf C shift storage to transfer', & - ptr_patch=this%leafc_storage_to_xfer_patch, default='inactive') - - this%frootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_FROOTC_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C shift storage to transfer', & - ptr_patch=this%frootc_storage_to_xfer_patch, default='inactive') - - this%livestemc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVESTEMC_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C shift storage to transfer', & - ptr_patch=this%livestemc_storage_to_xfer_patch, default='inactive') - - this%deadstemc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_DEADSTEMC_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead stem C shift storage to transfer', & - ptr_patch=this%deadstemc_storage_to_xfer_patch, default='inactive') - - this%livecrootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVECROOTC_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C shift storage to transfer', & - ptr_patch=this%livecrootc_storage_to_xfer_patch, default='inactive') - - this%deadcrootc_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_DEADCROOTC_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 dead coarse root C shift storage to transfer', & - ptr_patch=this%deadcrootc_storage_to_xfer_patch, default='inactive') - - this%gresp_storage_to_xfer_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_GRESP_STORAGE_TO_XFER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth respiration shift storage to transfer', & - ptr_patch=this%gresp_storage_to_xfer_patch, default='inactive') - - this%livestemc_to_deadstemc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVESTEMC_TO_DEADSTEMC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live stem C turnover', & - ptr_patch=this%livestemc_to_deadstemc_patch, default='inactive') - - this%livecrootc_to_deadcrootc_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LIVECROOTC_TO_DEADCROOTC', units='gC14/m^2/s', & - avgflag='A', long_name='C14 live coarse root C turnover', & - ptr_patch=this%livecrootc_to_deadcrootc_patch, default='inactive') - - this%gpp_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_GPP', units='gC14/m^2/s', & - avgflag='A', long_name='C14 gross primary production', & - ptr_patch=this%gpp_patch) - - this%mr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_MR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 maintenance respiration', & - ptr_patch=this%mr_patch) - - this%current_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_CURRENT_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth resp for new growth displayed in this timestep', & - ptr_patch=this%current_gr_patch, default='inactive') - - this%transfer_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_TRANSFER_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth resp for transfer growth displayed in this timestep', & - ptr_patch=this%transfer_gr_patch, default='inactive') - - this%storage_gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_STORAGE_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 growth resp for growth sent to storage for later display', & - ptr_patch=this%storage_gr_patch, default='inactive') - - this%gr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_GR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total growth respiration', & - ptr_patch=this%gr_patch) - - this%ar_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_AR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 autotrophic respiration (MR + GR)', & - ptr_patch=this%ar_patch) - - this%rr_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_RR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 root respiration (fine root MR + total root GR)', & - ptr_patch=this%rr_patch) - - this%npp_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_NPP', units='gC14/m^2/s', & - avgflag='A', long_name='C14 net primary production', & - ptr_patch=this%npp_patch) - - this%agnpp_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_AGNPP', units='gC14/m^2/s', & - avgflag='A', long_name='C14 aboveground NPP', & - ptr_patch=this%agnpp_patch) - - this%bgnpp_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_BGNPP', units='gC14/m^2/s', & - avgflag='A', long_name='C14 belowground NPP', & - ptr_patch=this%bgnpp_patch) - - this%litfall_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_LITFALL', units='gC14/m^2/s', & - avgflag='A', long_name='C14 litterfall (leaves and fine roots)', & - ptr_patch=this%litfall_patch, default='inactive') - - this%vegfire_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_VEGFIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 patch-level fire loss', & - ptr_patch=this%vegfire_patch, default='inactive') - - this%fire_closs_patch(begp:endp) = spval - call hist_addfld1d (fname='C14_PFT_FIRE_CLOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total patch-level fire C loss', & - ptr_patch=this%fire_closs_patch) - endif - end if !(.not.use_ed) - - !------------------------------- - ! C flux variables - native to column - !------------------------------- - - ! add history fields for all CLAMP CN variables - - if (carbon_type == 'c12') then - - if (hist_wrtch4diag) then - this%fphr_col(begc:endc,1:nlevgrnd) = spval - call hist_addfld_decomp (fname='FPHR'//trim(vr_suffix), units='unitless', type2d='levdcmp', & - avgflag='A', long_name='fraction of potential HR due to N limitation', & - ptr_col=this%fphr_col) - end if + return - this%cwdc_hr_col(begc:endc) = spval - call hist_addfld1d (fname='CWDC_HR', units='gC/m^2/s', & - avgflag='A', long_name='coarse woody debris C heterotrophic respiration', & - ptr_col=this%cwdc_hr_col) - - this%cwdc_loss_col(begc:endc) = spval - call hist_addfld1d (fname='CWDC_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='coarse woody debris C loss', & - ptr_col=this%cwdc_loss_col) - - this%lithr_col(begc:endc) = spval - call hist_addfld1d (fname='LITTERC_HR', units='gC/m^2/s', & - avgflag='A', long_name='litter C heterotrophic respiration', & - ptr_col=this%lithr_col) - - this%litterc_loss_col(begc:endc) = spval - call hist_addfld1d (fname='LITTERC_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='litter C loss', & - ptr_col=this%litterc_loss_col) - - this%somhr_col(begc:endc) = spval - call hist_addfld1d (fname='SOILC_HR', units='gC/m^2/s', & - avgflag='A', long_name='soil C heterotrophic respiration', & - ptr_col=this%somhr_col) - - this%somhr_col(begc:endc) = spval - call hist_addfld1d (fname='SOILC_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='soil C loss', & - ptr_col=this%somhr_col) - - ! F. Li and S. Levis - this%lf_conv_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='LF_CONV_CFLUX', units='gC/m^2/s', & - avgflag='A', long_name='conversion carbon due to BET and BDT area decreasing', & - ptr_col=this%lf_conv_cflux_col, default='inactive') - - this%somc_fire_col(begc:endc) = spval - call hist_addfld1d (fname='SOMC_FIRE', units='gC/m^2/s', & - avgflag='A', long_name='C loss due to peat burning', & - ptr_col=this%somc_fire_col, default='inactive') - - - this%m_decomp_cpools_to_fire_col(begc:endc,:) = spval - this%m_decomp_cpools_to_fire_vr_col(begc:endc,:,:) = spval - do k = 1, ndecomp_pools - if ( decomp_cascade_con%is_litter(k) .or. decomp_cascade_con%is_cwd(k) ) then - data1dptr => this%m_decomp_cpools_to_fire_col(:,k) - fieldname = 'M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE' - longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' - call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr, default='inactive') - - if ( nlevdecomp_full > 1 ) then - data2dptr => this%m_decomp_cpools_to_fire_vr_col(:,:,k) - fieldname = 'M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE'//trim(vr_suffix) - longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' - call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - endif - - ! decomposition k - data2dptr => this%decomp_k_col(:,:,k) - fieldname = 'K_'//trim(decomp_cascade_con%decomp_pool_name_history(k)) - longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' potential loss coefficient' - call hist_addfld_decomp (fname=fieldname, units='1/s', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - end do + end if - if(.not. is_active_betr_bgc)then - this%decomp_cascade_hr_col(begc:endc,:) = spval - this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval - this%decomp_cascade_ctransfer_col(begc:endc,:) = spval - this%decomp_cascade_ctransfer_vr_col(begc:endc,:,:) = spval - do l = 1, ndecomp_cascade_transitions - - ! output the vertically integrated fluxes only as default - !-- HR fluxes (none from CWD) - if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then - data1dptr => this%decomp_cascade_hr_col(:,l) - ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file - ii = 0 - do jj = 1, ndecomp_cascade_transitions - if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 - end do - if ( ii == 1 ) then - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_HR' - else - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_HR_'//& - trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l))) - endif - longname = 'Het. Resp. from '//& - trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) - call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr) - endif - - !-- transfer fluxes (none from terminal pool, if present) - if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then - data1dptr => this%decomp_cascade_ctransfer_col(:,l) - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'C_TO_'//& - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))//'C' - longname = 'decomp. of '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))//& - ' C to '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' - call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr) - endif - - ! output the vertically resolved fluxes - if ( nlevdecomp_full > 1 ) then - !-- HR fluxes (none from CWD) - if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then - data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) - ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file - ii = 0 - do jj = 1, ndecomp_cascade_transitions - if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 - end do - if ( ii == 1 ) then - fieldname = & - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'_HR'//trim(vr_suffix) - else - fieldname = & - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_HR_'//& - trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& - //trim(vr_suffix) - endif - longname = 'Het. Resp. from '//& - trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) - call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - - !-- transfer fluxes (none from terminal pool, if present) - if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then - data2dptr => this%decomp_cascade_ctransfer_vr_col(:,:,l) - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'C_TO_'//& - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))& - //'C'//trim(vr_suffix) - longname = 'decomp. of '//& - trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))//& - ' C to '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' - call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - end if - - end do - endif - - this%t_scalar_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='T_SCALAR', units='unitless', type2d='levdcmp', & - avgflag='A', long_name='temperature inhibition of decomposition', & - ptr_col=this%t_scalar_col) - - this%w_scalar_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='W_SCALAR', units='unitless', type2d='levdcmp', & - avgflag='A', long_name='Moisture (dryness) inhibition of decomposition', & - ptr_col=this%w_scalar_col) - - this%o_scalar_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='O_SCALAR', units='unitless', type2d='levdcmp', & - avgflag='A', long_name='fraction by which decomposition is reduced due to anoxia', & - ptr_col=this%o_scalar_col) - - this%som_c_leached_col(begc:endc) = spval - call hist_addfld1d (fname='SOM_C_LEACHED', units='gC/m^2/s', & - avgflag='A', long_name='total flux of C from SOM pools due to leaching', & - ptr_col=this%som_c_leached_col)!, default='inactive') - - if(.not. is_active_betr_bgc)then - this%decomp_cpools_leached_col(begc:endc,:) = spval - this%decomp_cpools_transport_tendency_col(begc:endc,:,:) = spval - do k = 1, ndecomp_pools - if ( .not. decomp_cascade_con%is_cwd(k) ) then - data1dptr => this%decomp_cpools_leached_col(:,k) - fieldname = 'M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_LEACHING' - longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C leaching loss' - call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr)!, default='inactive') - - data2dptr => this%decomp_cpools_transport_tendency_col(:,:,k) - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TNDNCY_VERT_TRANSPORT' - longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C tendency due to vertical transport' - call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - end do - endif - this%lithr_col(begc:endc) = spval - call hist_addfld1d (fname='LITHR', units='gC/m^2/s', & - avgflag='A', long_name='litter heterotrophic respiration', & - ptr_col=this%lithr_col) - - this%somhr_col(begc:endc) = spval - call hist_addfld1d (fname='SOMHR', units='gC/m^2/s', & - avgflag='A', long_name='soil organic matter heterotrophic respiration', & - ptr_col=this%somhr_col) - - if ( nlevdecomp_full > 1 ) then - this%hr_vr_col(begc:endc,:) = spval - call hist_addfld2d (fname='HR_vr', units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name='total vertically resolved heterotrophic respiration', & - ptr_col=this%hr_vr_col) - - ! pflotran - this%f_co2_soil_vr_col(begc:endc,:) = spval - call hist_addfld2d (fname='F_CO2_SOIL_vr', units='gC/m^3/s', type2d='levdcmp', & - avgflag='A', long_name='total vertically resolved soil-atm. CO2 exchange', & - ptr_col=this%f_co2_soil_vr_col) - endif - - this%hr_col(begc:endc) = spval - call hist_addfld1d (fname='HR', units='gC/m^2/s', & - avgflag='A', long_name='total heterotrophic respiration', & - ptr_col=this%hr_col) - - !pflotran - this%f_co2_soil_col(begc:endc) = spval - call hist_addfld1d (fname='F_CO2_SOIL', units='gC/m^2/s', & - avgflag='A', long_name='total soil-atm. CO2 exchange', & - ptr_col=this%f_co2_soil_col) - - this%sr_col(begc:endc) = spval - call hist_addfld1d (fname='SR', units='gC/m^2/s', & - avgflag='A', long_name='total soil respiration (HR + root resp)', & - ptr_col=this%sr_col) - - this%er_col(begc:endc) = spval - call hist_addfld1d (fname='ER', units='gC/m^2/s', & - avgflag='A', long_name='total ecosystem respiration, autotrophic + heterotrophic', & - ptr_col=this%er_col) - - this%litfire_col(begc:endc) = spval - call hist_addfld1d (fname='LITFIRE', units='gC/m^2/s', & - avgflag='A', long_name='litter fire losses', & - ptr_col=this%litfire_col, default='inactive') - - this%somfire_col(begc:endc) = spval - call hist_addfld1d (fname='SOMFIRE', units='gC/m^2/s', & - avgflag='A', long_name='soil organic matter fire losses', & - ptr_col=this%somfire_col, default='inactive') - - this%totfire_col(begc:endc) = spval - call hist_addfld1d (fname='TOTFIRE', units='gC/m^2/s', & - avgflag='A', long_name='total ecosystem fire losses', & - ptr_col=this%totfire_col, default='inactive') - - this%nep_col(begc:endc) = spval - call hist_addfld1d (fname='NEP', units='gC/m^2/s', & - avgflag='A', long_name='net ecosystem production, excludes fire, landuse, and harvest flux, positive for sink', & - ptr_col=this%nep_col) - - this%nbp_col(begc:endc) = spval - call hist_addfld1d (fname='NBP', units='gC/m^2/s', & - avgflag='A', long_name='net biome production, includes fire, landuse, and harvest flux, positive for sink', & - ptr_col=this%nbp_col) - - this%nee_col(begc:endc) = spval - call hist_addfld1d (fname='NEE', units='gC/m^2/s', & - avgflag='A', long_name='net ecosystem exchange of carbon, includes fire, landuse,'& - //' harvest, and hrv_xsmrpool flux, positive for source', & - ptr_col=this%nee_col) - - this%fire_closs_col(begc:endc) = spval - call hist_addfld1d (fname='COL_FIRE_CLOSS', units='gC/m^2/s', & - avgflag='A', long_name='total column-level fire C loss for non-peat fires outside land-type converted region', & - ptr_col=this%fire_closs_col, default='inactive') - - this%dwt_seedc_to_leaf_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_SEEDC_TO_LEAF', units='gC/m^2/s', & - avgflag='A', long_name='seed source to patch-level leaf', & - ptr_col=this%dwt_seedc_to_leaf_col, default='inactive') - - this%dwt_seedc_to_deadstem_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_SEEDC_TO_DEADSTEM', units='gC/m^2/s', & - avgflag='A', long_name='seed source to patch-level deadstem', & - ptr_col=this%dwt_seedc_to_deadstem_col, default='inactive') - - this%dwt_conv_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_CONV_CFLUX', units='gC/m^2/s', & - avgflag='A', long_name='conversion C flux (immediate loss to atm)', & - ptr_col=this%dwt_conv_cflux_col, default='inactive') - - this%dwt_prod10c_gain_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_PROD10C_GAIN', units='gC/m^2/s', & - avgflag='A', long_name='landcover change-driven addition to 10-yr wood product pool', & - ptr_col=this%dwt_prod10c_gain_col, default='inactive') - - this%prod10c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='PROD10C_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='loss from 10-yr wood product pool', & - ptr_col=this%prod10c_loss_col, default='inactive') - - this%dwt_prod100c_gain_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_PROD100C_GAIN', units='gC/m^2/s', & - avgflag='A', long_name='landcover change-driven addition to 100-yr wood product pool', & - ptr_col=this%dwt_prod100c_gain_col, default='inactive') - - this%prod100c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='PROD100C_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='loss from 100-yr wood product pool', & - ptr_col=this%prod100c_loss_col, default='inactive') - - this%prod1c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='PROD1C_LOSS', units='gC/m^2/s', & - avgflag='A', long_name='loss from 1-yr crop product pool', & - ptr_col=this%prod1c_loss_col, default='inactive') - - this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_MET_C', units='gC/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_met_c_col, default='inactive') - - this%dwt_frootc_to_litr_cel_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_CEL_C', units='gC/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_cel_c_col, default='inactive') - - this%dwt_frootc_to_litr_lig_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_LIG_C', units='gC/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_lig_c_col, default='inactive') - - this%dwt_livecrootc_to_cwdc_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='DWT_LIVECROOTC_TO_CWDC', units='gC/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='live coarse root to CWD due to landcover change', & - ptr_col=this%dwt_livecrootc_to_cwdc_col, default='inactive') - - this%dwt_deadcrootc_to_cwdc_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='DWT_DEADCROOTC_TO_CWDC', units='gC/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='dead coarse root to CWD due to landcover change', & - ptr_col=this%dwt_deadcrootc_to_cwdc_col, default='inactive') - - this%dwt_closs_col(begc:endc) = spval - call hist_addfld1d (fname='DWT_CLOSS', units='gC/m^2/s', & - avgflag='A', long_name='total carbon loss from land cover conversion', & - ptr_col=this%dwt_closs_col, default='inactive') - - this%product_closs_col(begc:endc) = spval - call hist_addfld1d (fname='PRODUCT_CLOSS', units='gC/m^2/s', & - avgflag='A', long_name='total carbon loss from wood product pools', & - ptr_col=this%product_closs_col, default='inactive') - - this%landuseflux_col(begc:endc) = spval - call hist_addfld1d (fname='LAND_USE_FLUX', units='gC/m^2/s', & - avgflag='A', long_name='total C emitted from land cover conversion and wood product pools', & - ptr_col=this%landuseflux_col) - - this%landuptake_col(begc:endc) = spval - call hist_addfld1d (fname='LAND_UPTAKE', units='gC/m^2/s', & - avgflag='A', long_name='NEE minus LAND_USE_FLUX, negative for update', & - ptr_col=this%landuptake_col) - - if(.not.use_ed) then - this%annsum_npp_patch(begp:endp) = spval - call hist_addfld1d (fname='ANNSUM_NPP', units='gC/m^2/yr', & - avgflag='A', long_name='annual sum of NPP', & - ptr_patch=this%annsum_npp_patch, default='inactive') - - this%annsum_npp_col(begc:endc) = spval - call hist_addfld1d (fname='CANNSUM_NPP', units='gC/m^2/s', & - avgflag='A', long_name='annual sum of column-level NPP', & - ptr_col=this%annsum_npp_col, default='inactive') - end if - end if - - ctag=get_carbontag(carbon_type) - do k = 1, ndecomp_pools - this%bgc_cpool_ext_inputs_vr_col(begc:endc, :, k) = spval - data2dptr => this%bgc_cpool_ext_inputs_vr_col(:,:,k) - fieldname='BGC_'//trim(ctag)//'POOL_EINPUT_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'_vr' - longname=trim(ctag)//' input to '//trim(decomp_cascade_con%decomp_pool_name_history(k)) - call hist_addfld_decomp (fname=fieldname, units='g'//ctag//'/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - - this%bgc_cpool_ext_loss_vr_col(begc:endc, :, k) = spval - data2dptr => this%bgc_cpool_ext_loss_vr_col(:,:,k) - fieldname='BGC_'//trim(ctag)//'POOL_ELOSS_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'_vr' - longname=trim(ctag)//' loss of '//trim(decomp_cascade_con%decomp_pool_name_history(k)) - call hist_addfld_decomp (fname=fieldname, units='g'//ctag//'/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - - enddo - - !------------------------------- - ! C13 flux variables - native to column - !------------------------------- - - if ( carbon_type == 'c13' ) then - - this%m_decomp_cpools_to_fire_col(begc:endc,:) = spval - this%m_decomp_cpools_to_fire_vr_col(begc:endc,:,:) = spval - do k = 1, ndecomp_pools - if ( decomp_cascade_con%is_litter(k) .or. decomp_cascade_con%is_cwd(k) ) then - data1dptr => this%m_decomp_cpools_to_fire_col(:,k) - fieldname = 'C13_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE' - longname = 'C13 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' - call hist_addfld1d (fname=fieldname, units='gC13/m^2', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr, default='inactive') - - if ( nlevdecomp_full > 1 ) then - data2dptr => this%m_decomp_cpools_to_fire_vr_col(:,:,k) - fieldname = 'C13_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE'//trim(vr_suffix) - longname = 'C13 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' - call hist_addfld_decomp (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - end if - endif - end do - if(.not. is_active_betr_bgc)then - this%decomp_cascade_hr_col(begc:endc,:) = spval - this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval - this%decomp_cascade_ctransfer_col(begc:endc,:) = spval - this%decomp_cascade_ctransfer_vr_col(begc:endc,:,:) = spval - do l = 1, ndecomp_cascade_transitions - !-- HR fluxes (none from CWD) - if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then - data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) - ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file - ii = 0 - do jj = 1, ndecomp_cascade_transitions - if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 - end do - if ( ii == 1 ) then - fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'_HR'//trim(vr_suffix) - else - fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'_HR_'//& - trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))//& - trim(vr_suffix) - endif - longname = 'C13 Het. Resp. from '& - //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) - call hist_addfld_decomp (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - !-- transfer fluxes (none from terminal pool, if present) - if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then - data2dptr => this%decomp_cascade_ctransfer_vr_col(:,:,l) - fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'C_TO_'//& - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))& - //'C'//trim(vr_suffix) - longname = 'C13 decomp. of '& - //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))& - //' C to '//& - trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' - call hist_addfld_decomp (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - end do - endif - - this%lithr_col(begc:endc) = spval - call hist_addfld1d (fname='C13_LITHR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 fine root C litterfall to litter 3 C', & - ptr_col=this%lithr_col) - - this%somhr_col(begc:endc) = spval - call hist_addfld1d (fname='C13_SOMHR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 soil organic matter heterotrophic respiration', & - ptr_col=this%somhr_col) - - this%hr_col(begc:endc) = spval - call hist_addfld1d (fname='C13_HR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total heterotrophic respiration', & - ptr_col=this%hr_col) - - this%sr_col(begc:endc) = spval - call hist_addfld1d (fname='C13_SR', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total soil respiration (HR + root resp)', & - ptr_col=this%sr_col) - - this%er_col(begc:endc) = spval - call hist_addfld1d (fname='C13_ER', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total ecosystem respiration, autotrophic + heterotrophic', & - ptr_col=this%er_col) - - this%litfire_col(begc:endc) = spval - call hist_addfld1d (fname='C13_LITFIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 litter fire losses', & - ptr_col=this%litfire_col, default='inactive') - - this%somfire_col(begc:endc) = spval - call hist_addfld1d (fname='C13_SOMFIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 soil organic matter fire losses', & - ptr_col=this%somfire_col, default='inactive') - - this%totfire_col(begc:endc) = spval - call hist_addfld1d (fname='C13_TOTFIRE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total ecosystem fire losses', & - ptr_col=this%totfire_col, default='inactive') - - this%nep_col(begc:endc) = spval - call hist_addfld1d (fname='C13_NEP', units='gC13/m^2/s', & - avgflag='A', long_name='C13 net ecosystem production, excludes fire flux, positive for sink', & - ptr_col=this%nep_col) - - this%nee_col(begc:endc) = spval - call hist_addfld1d (fname='C13_NEE', units='gC13/m^2/s', & - avgflag='A', long_name='C13 net ecosystem exchange of carbon, includes fire flux, positive for source', & - ptr_col=this%nee_col) - - this%fire_closs_col(begc:endc) = spval - call hist_addfld1d (fname='C13_COL_FIRE_CLOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total column-level fire C loss', & - ptr_col=this%fire_closs_col) - - this%dwt_seedc_to_leaf_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_SEEDC_TO_LEAF', units='gC13/m^2/s', & - avgflag='A', long_name='C13 seed source to patch-level leaf', & - ptr_col=this%dwt_seedc_to_leaf_col) - - this%dwt_seedc_to_deadstem_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_SEEDC_TO_DEADSTEM', units='gC13/m^2/s', & - avgflag='A', long_name='C13 seed source to patch-level deadstem', & - ptr_col=this%dwt_seedc_to_deadstem_col) - - this%dwt_conv_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_CONV_CFLUX', units='gC13/m^2/s', & - avgflag='A', long_name='C13 conversion C flux (immediate loss to atm)', & - ptr_col=this%dwt_conv_cflux_col) - - this%dwt_prod10c_gain_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_PROD10C_GAIN', units='gC13/m^2/s', & - avgflag='A', long_name='C13 addition to 10-yr wood product pool', & - ptr_col=this%dwt_prod10c_gain_col) - - this%prod10c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='C13_PROD10C_LOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 loss from 10-yr wood product pool', & - ptr_col=this%prod10c_loss_col) - - this%dwt_prod100c_gain_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_PROD100C_GAIN', units='gC13/m^2/s', & - avgflag='A', long_name='C13 addition to 100-yr wood product pool', & - ptr_col=this%dwt_prod100c_gain_col) - - this%prod100c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='C13_PROD100C_LOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 loss from 100-yr wood product pool', & - ptr_col=this%prod100c_loss_col) - - this%prod1c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='C13_PROD1C_LOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 loss from 1-yr crop product pool', & - ptr_col=this%prod1c_loss_col) - - this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_MET_C', units='gC13/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C13 fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_met_c_col, default='inactive') - - this%dwt_frootc_to_litr_cel_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_CEL_C', units='gC13/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C13 fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_cel_c_col, default='inactive') - - this%dwt_frootc_to_litr_lig_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_LIG_C', units='gC13/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C13 fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_lig_c_col, default='inactive') - - this%dwt_livecrootc_to_cwdc_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C13_DWT_LIVECROOTC_TO_CWDC', units='gC13/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C13 live coarse root to CWD due to landcover change', & - ptr_col=this%dwt_livecrootc_to_cwdc_col, default='inactive') - - this%dwt_deadcrootc_to_cwdc_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C13_DWT_DEADCROOTC_TO_CWDC', units='gC13/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C13 dead coarse root to CWD due to landcover change', & - ptr_col=this%dwt_deadcrootc_to_cwdc_col, default='inactive') - - this%dwt_closs_col(begc:endc) = spval - call hist_addfld1d (fname='C13_DWT_CLOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total carbon loss from land cover conversion', & - ptr_col=this%dwt_closs_col) - - this%product_closs_col(begc:endc) = spval - call hist_addfld1d (fname='C13_PRODUCT_CLOSS', units='gC13/m^2/s', & - avgflag='A', long_name='C13 total carbon loss from wood product pools', & - ptr_col=this%product_closs_col) - endif - - !------------------------------- - ! C14 flux variables - native to column - !------------------------------- - - if (carbon_type == 'c14') then - - this%m_decomp_cpools_to_fire_col(begc:endc,:) = spval - this%m_decomp_cpools_to_fire_vr_col(begc:endc,:,:) = spval - do k = 1, ndecomp_pools - if ( decomp_cascade_con%is_litter(k) .or. decomp_cascade_con%is_cwd(k) ) then - data1dptr => this%m_decomp_cpools_to_fire_col(:,k) - fieldname = 'C14_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE' - longname = 'C14 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' - call hist_addfld1d (fname=fieldname, units='gC14/m^2', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr, default='inactive') - - if ( nlevdecomp_full > 1 ) then - data2dptr => this%m_decomp_cpools_to_fire_vr_col(:,:,k) - fieldname = 'C14_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE'//trim(vr_suffix) - longname = 'C14 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' - call hist_addfld_decomp (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - end if - endif - end do - if(.not. is_active_betr_bgc)then - this%decomp_cascade_hr_col(begc:endc,:) = spval - this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval - this%decomp_cascade_ctransfer_col(begc:endc,:) = spval - this%decomp_cascade_ctransfer_vr_col(begc:endc,:,:) = spval - do l = 1, ndecomp_cascade_transitions - !-- HR fluxes (none from CWD) - if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then - data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) - ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file - ii = 0 - do jj = 1, ndecomp_cascade_transitions - if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 - end do - if ( ii == 1 ) then - fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'_HR'//trim(vr_suffix) - else - fieldname = 'C14_'//& - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'_HR_'//& - trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& - //trim(vr_suffix) - endif - longname = 'C14 Het. Resp. from '& - //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) - call hist_addfld_decomp (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - !-- transfer fluxes (none from terminal pool, if present) - if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then - data2dptr => this%decomp_cascade_ctransfer_vr_col(:,:,l) - fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& - //'C_TO_'//& - trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))& - //'C'//trim(vr_suffix) - longname = 'C14 decomp. of '& - //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))//& - ' C to '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' - call hist_addfld_decomp (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr, default='inactive') - endif - end do - endif - - this%lithr_col(begc:endc) = spval - call hist_addfld1d (fname='C14_LITHR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 fine root C litterfall to litter 3 C', & - ptr_col=this%lithr_col) - - this%somhr_col(begc:endc) = spval - call hist_addfld1d (fname='C14_SOMHR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 soil organic matter heterotrophic respiration', & - ptr_col=this%somhr_col) - - this%hr_col(begc:endc) = spval - call hist_addfld1d (fname='C14_HR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total heterotrophic respiration', & - ptr_col=this%hr_col) - - this%sr_col(begc:endc) = spval - call hist_addfld1d (fname='C14_SR', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total soil respiration (HR + root resp)', & - ptr_col=this%sr_col) - - this%er_col(begc:endc) = spval - call hist_addfld1d (fname='C14_ER', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total ecosystem respiration, autotrophic + heterotrophic', & - ptr_col=this%er_col) - - this%litfire_col(begc:endc) = spval - call hist_addfld1d (fname='C14_LITFIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 litter fire losses', & - ptr_col=this%litfire_col, default='inactive') - - this%somfire_col(begc:endc) = spval - call hist_addfld1d (fname='C14_SOMFIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 soil organic matter fire losses', & - ptr_col=this%somfire_col, default='inactive') - - this%totfire_col(begc:endc) = spval - call hist_addfld1d (fname='C14_TOTFIRE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total ecosystem fire losses', & - ptr_col=this%totfire_col, default='inactive') - - this%nep_col(begc:endc) = spval - call hist_addfld1d (fname='C14_NEP', units='gC14/m^2/s', & - avgflag='A', long_name='C14 net ecosystem production, excludes fire flux, positive for sink', & - ptr_col=this%nep_col) - - this%nee_col(begc:endc) = spval - call hist_addfld1d (fname='C14_NEE', units='gC14/m^2/s', & - avgflag='A', long_name='C14 net ecosystem exchange of carbon, includes fire flux, positive for source', & - ptr_col=this%nee_col) - - this%fire_closs_col(begc:endc) = spval - call hist_addfld1d (fname='C14_COL_FIRE_CLOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total column-level fire C loss', & - ptr_col=this%fire_closs_col) - - this%dwt_seedc_to_leaf_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_SEEDC_TO_LEAF', units='gC14/m^2/s', & - avgflag='A', long_name='C14 seed source to patch-level leaf', & - ptr_col=this%dwt_seedc_to_leaf_col) - - this%dwt_seedc_to_deadstem_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_SEEDC_TO_DEADSTEM', units='gC14/m^2/s', & - avgflag='A', long_name='C14 seed source to patch-level deadstem', & - ptr_col=this%dwt_seedc_to_deadstem_col) - - this%dwt_conv_cflux_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_CONV_CFLUX', units='gC14/m^2/s', & - avgflag='A', long_name='C14 conversion C flux (immediate loss to atm)', & - ptr_col=this%dwt_conv_cflux_col) - - this%dwt_prod10c_gain_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_PROD10C_GAIN', units='gC14/m^2/s', & - avgflag='A', long_name='C14 addition to 10-yr wood product pool', & - ptr_col=this%dwt_prod10c_gain_col) - - this%prod10c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='C14_PROD10C_LOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 loss from 10-yr wood product pool', & - ptr_col=this%prod10c_loss_col) - - this%dwt_prod100c_gain_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_PROD100C_GAIN', units='gC14/m^2/s', & - avgflag='A', long_name='C14 addition to 100-yr wood product pool', & - ptr_col=this%dwt_prod100c_gain_col) - - this%prod100c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='C14_PROD100C_LOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 loss from 100-yr wood product pool', & - ptr_col=this%prod100c_loss_col) - - this%prod1c_loss_col(begc:endc) = spval - call hist_addfld1d (fname='C14_PROD1C_LOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 loss from 1-yr crop product pool', & - ptr_col=this%prod1c_loss_col) - - this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_MET_C', units='gC14/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C14 fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_met_c_col, default='inactive') - - this%dwt_frootc_to_litr_cel_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_CEL_C', units='gC14/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C14 fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_cel_c_col, default='inactive') - - this%dwt_frootc_to_litr_lig_c_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_LIG_C', units='gC14/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C14 fine root to litter due to landcover change', & - ptr_col=this%dwt_frootc_to_litr_lig_c_col, default='inactive') - - this%dwt_livecrootc_to_cwdc_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C14_DWT_LIVECROOTC_TO_CWDC', units='gC14/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C14 live coarse root to CWD due to landcover change', & - ptr_col=this%dwt_livecrootc_to_cwdc_col, default='inactive') - - this%dwt_deadcrootc_to_cwdc_col(begc:endc,:) = spval - call hist_addfld_decomp (fname='C14_DWT_DEADCROOTC_TO_CWDC', units='gC14/m^2/s', type2d='levdcmp', & - avgflag='A', long_name='C14 dead coarse root to CWD due to landcover change', & - ptr_col=this%dwt_deadcrootc_to_cwdc_col, default='inactive') - - this%dwt_closs_col(begc:endc) = spval - call hist_addfld1d (fname='C14_DWT_CLOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total carbon loss from land cover conversion', & - ptr_col=this%dwt_closs_col) - - this%product_closs_col(begc:endc) = spval - call hist_addfld1d (fname='C14_PRODUCT_CLOSS', units='gC14/m^2/s', & - avgflag='A', long_name='C14 total carbon loss from wood product pools', & - ptr_col=this%product_closs_col) - endif - - if (carbon_type == 'c13' .and. .not.use_ed ) then - this%xsmrpool_c13ratio_patch(begp:endp) = spval - call hist_addfld1d (fname='XSMRPOOL_C13RATIO', units='proportion', & - avgflag='A', long_name='C13/C(12+13) ratio for xsmrpool', & - ptr_patch=this%xsmrpool_c13ratio_patch, default='inactive') - endif - - end subroutine InitHistory + + if (carbon_type == 'c12') then + if (crop_prog) then + this%grainc_to_food_patch(begp:endp) = spval + call hist_addfld1d (fname='GRAINC_TO_FOOD', units='gC/m^2/s', & + avgflag='A', long_name='grain C to food', & + ptr_patch=this%grainc_to_food_patch, default='inactive') + end if + + this%woodc_alloc_patch(begp:endp) = spval + call hist_addfld1d (fname='WOODC_ALLOC', units='gC/m^2/s', & + avgflag='A', long_name='wood C eallocation', & + ptr_patch=this%woodc_alloc_patch) + + this%woodc_loss_patch(begp:endp) = spval + call hist_addfld1d (fname='WOODC_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='wood C loss', & + ptr_patch=this%woodc_loss_patch) + + this%leafc_loss_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFC_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='leaf C loss', & + ptr_patch=this%leafc_loss_patch) + + this%leafc_alloc_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFC_ALLOC', units='gC/m^2/s', & + avgflag='A', long_name='leaf C allocation', & + ptr_patch=this%leafc_alloc_patch) + + this%frootc_loss_patch(begp:endp) = spval + call hist_addfld1d (fname='FROOTC_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='fine root C loss', & + ptr_patch=this%frootc_loss_patch) + + this%frootc_alloc_patch(begp:endp) = spval + call hist_addfld1d (fname='FROOTC_ALLOC', units='gC/m^2/s', & + avgflag='A', long_name='fine root C allocation', & + ptr_patch=this%frootc_alloc_patch) + + this%m_leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='leaf C mortality', & + ptr_patch=this%m_leafc_to_litter_patch, default='inactive') + + this%m_frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='fine root C mortality', & + ptr_patch=this%m_frootc_to_litter_patch, default='inactive') + + this%m_leafc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='leaf C storage mortality', & + ptr_patch=this%m_leafc_storage_to_litter_patch, default='inactive') + + this%m_frootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='fine root C storage mortality', & + ptr_patch=this%m_frootc_storage_to_litter_patch, default='inactive') + + this%m_livestemc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='live stem C storage mortality', & + ptr_patch=this%m_livestemc_storage_to_litter_patch, default='inactive') + + this%m_deadstemc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C storage mortality', & + ptr_patch=this%m_deadstemc_storage_to_litter_patch, default='inactive') + + this%m_livecrootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVECROOTC_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C storage mortality', & + ptr_patch=this%m_livecrootc_storage_to_litter_patch, default='inactive') + + this%m_deadcrootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADCROOTC_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root C storage mortality', & + ptr_patch=this%m_deadcrootc_storage_to_litter_patch, default='inactive') + + this%m_leafc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='leaf C transfer mortality', & + ptr_patch=this%m_leafc_xfer_to_litter_patch, default='inactive') + + this%m_frootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='fine root C transfer mortality', & + ptr_patch=this%m_frootc_xfer_to_litter_patch, default='inactive') + + this%m_livestemc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='live stem C transfer mortality', & + ptr_patch=this%m_livestemc_xfer_to_litter_patch, default='inactive') + + this%m_deadstemc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C transfer mortality', & + ptr_patch=this%m_deadstemc_xfer_to_litter_patch, default='inactive') + + this%m_livecrootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVECROOTC_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C transfer mortality', & + ptr_patch=this%m_livecrootc_xfer_to_litter_patch, default='inactive') + + this%m_deadcrootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADCROOTC_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root C transfer mortality', & + ptr_patch=this%m_deadcrootc_xfer_to_litter_patch, default='inactive') + + this%m_livestemc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='live stem C mortality', & + ptr_patch=this%m_livestemc_to_litter_patch, default='inactive') + + this%m_deadstemc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C mortality', & + ptr_patch=this%m_deadstemc_to_litter_patch, default='inactive') + + this%m_livecrootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVECROOTC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C mortality', & + ptr_patch=this%m_livecrootc_to_litter_patch, default='inactive') + + this%m_deadcrootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADCROOTC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root C mortality', & + ptr_patch=this%m_deadcrootc_to_litter_patch, default='inactive') + + this%m_gresp_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_GRESP_STORAGE_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration storage mortality', & + ptr_patch=this%m_gresp_storage_to_litter_patch, default='inactive') + + this%m_gresp_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='M_GRESP_XFER_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration transfer mortality', & + ptr_patch=this%m_gresp_xfer_to_litter_patch, default='inactive') + + this%m_leafc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='leaf C fire loss', & + ptr_patch=this%m_leafc_to_fire_patch, default='inactive') + + this%m_leafc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='leaf C storage fire loss', & + ptr_patch=this%m_leafc_storage_to_fire_patch, default='inactive') + + this%m_leafc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='leaf C transfer fire loss', & + ptr_patch=this%m_leafc_xfer_to_fire_patch, default='inactive') + + this%m_livestemc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C fire loss', & + ptr_patch=this%m_livestemc_to_fire_patch, default='inactive') + + this%m_livestemc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C storage fire loss', & + ptr_patch=this%m_livestemc_storage_to_fire_patch, default='inactive') + + this%m_livestemc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C transfer fire loss', & + ptr_patch=this%m_livestemc_xfer_to_fire_patch, default='inactive') + + this%m_deadstemc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C fire loss', & + ptr_patch=this%m_deadstemc_to_fire_patch, default='inactive') + + this%m_deadstemc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C storage fire loss', & + ptr_patch=this%m_deadstemc_storage_to_fire_patch, default='inactive') + + this%m_deadstemc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C transfer fire loss', & + ptr_patch=this%m_deadstemc_xfer_to_fire_patch, default='inactive') + + this%m_frootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='fine root C fire loss', & + ptr_patch=this%m_frootc_to_fire_patch, default='inactive') + + this%m_frootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='fine root C storage fire loss', & + ptr_patch=this%m_frootc_storage_to_fire_patch, default='inactive') + + this%m_frootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='fine root C transfer fire loss', & + ptr_patch=this%m_frootc_xfer_to_fire_patch, default='inactive') + + this%m_livecrootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C fire loss', & + ptr_patch=this%m_livecrootc_to_fire_patch, default='inactive') + + this%m_livecrootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C storage fire loss', & + ptr_patch=this%m_livecrootc_storage_to_fire_patch, default='inactive') + + this%m_livecrootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C transfer fire loss', & + ptr_patch=this%m_livecrootc_xfer_to_fire_patch, default='inactive') + + this%m_deadcrootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADROOTC_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead root C fire loss', & + ptr_patch=this%m_deadcrootc_to_fire_patch, default='inactive') + + this%m_deadcrootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADROOTC_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead root C storage fire loss', & + ptr_patch=this%m_deadcrootc_storage_to_fire_patch, default='inactive') + + this%m_deadcrootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADROOTC_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead root C transfer fire loss', & + ptr_patch=this%m_deadcrootc_xfer_to_fire_patch, default='inactive') + + this%m_gresp_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_GRESP_STORAGE_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration storage fire loss', & + ptr_patch=this%m_gresp_storage_to_fire_patch, default='inactive') + + this%m_gresp_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_GRESP_XFER_TO_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration transfer fire loss', & + ptr_patch=this%m_gresp_xfer_to_fire_patch, default='inactive') + + this%m_leafc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='leaf C fire mortality to litter', & + ptr_patch=this%m_leafc_to_litter_fire_patch, default='inactive') + + ! add by F. Li and S. Levis + this%m_leafc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='leaf C fire mortality to litter', & + ptr_patch=this%m_leafc_storage_to_litter_fire_patch, default='inactive') + + this%m_leafc_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LEAFC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='leaf C transfer fire mortality to litter', & + ptr_patch=this%m_leafc_xfer_to_litter_fire_patch, default='inactive') + + this%m_livestemc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C fire mortality to litter', & + ptr_patch=this%m_livestemc_to_litter_fire_patch, default='inactive') + + this%m_livestemc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C storage fire mortality to litter', & + ptr_patch=this%m_livestemc_storage_to_litter_fire_patch, default='inactive') + + this%m_livestemc_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C transfer fire mortality to litter', & + ptr_patch=this%m_livestemc_xfer_to_litter_fire_patch, default='inactive') + + this%m_livestemc_to_deadstemc_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVESTEMC_TO_DEADSTEMC_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live stem C fire mortality to dead stem C', & + ptr_patch=this%m_livestemc_to_deadstemc_fire_patch, default='inactive') + + this%m_deadstemc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C fire mortality to litter', & + ptr_patch=this%m_deadstemc_to_litter_fire_patch, default='inactive') + + this%m_deadstemc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C storage fire mortality to litter', & + ptr_patch=this%m_deadstemc_storage_to_litter_fire_patch, default='inactive') + + this%m_deadstemc_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADSTEMC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C transfer fire mortality to litter', & + ptr_patch=this%m_deadstemc_xfer_to_litter_fire_patch, default='inactive') + + this%m_frootc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='fine root C fire mortality to litter', & + ptr_patch=this%m_frootc_to_litter_fire_patch, default='inactive') + + this%m_frootc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='fine root C storage fire mortality to litter', & + ptr_patch=this%m_frootc_storage_to_litter_fire_patch, default='inactive') + + this%m_frootc_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_FROOTC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='fine root C transfer fire mortality to litter', & + ptr_patch=this%m_frootc_xfer_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C fire mortality to litter', & + ptr_patch=this%m_livecrootc_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C storage fire mortality to litter', & + ptr_patch=this%m_livecrootc_storage_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C transfer fire mortality to litter', & + ptr_patch=this%m_livecrootc_xfer_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_to_deadcrootc_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVEROOTC_TO_DEADROOTC_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live root C fire mortality to dead root C', & + ptr_patch=this%m_livecrootc_to_deadcrootc_fire_patch, default='inactive') + + + this%m_deadcrootc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADROOTC_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead root C fire mortality to litter', & + ptr_patch=this%m_deadcrootc_to_litter_fire_patch, default='inactive') + + this%m_deadcrootc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead root C storage fire mortality to litter', & + ptr_patch=this%m_deadcrootc_storage_to_litter_fire_patch, default='inactive') + + this%m_deadcrootc_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADROOTC_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead root C transfer fire mortality to litter', & + ptr_patch=this%m_deadcrootc_xfer_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_LIVECROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C fire mortality to litter', & + ptr_patch=this%m_livecrootc_storage_to_litter_fire_patch, default='inactive') + + this%m_deadcrootc_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_DEADCROOTC_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root C storage fire mortality to litter', & + ptr_patch=this%m_deadcrootc_storage_to_litter_fire_patch, default='inactive') + + this%m_gresp_storage_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_GRESP_STORAGE_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration storage fire mortality to litter', & + ptr_patch=this%m_gresp_storage_to_litter_fire_patch, default='inactive') + + this%m_gresp_xfer_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='M_GRESP_XFER_TO_LITTER_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration transfer fire mortality to litter', & + ptr_patch=this%m_gresp_xfer_to_litter_fire_patch, default='inactive') + + this%leafc_xfer_to_leafc_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFC_XFER_TO_LEAFC', units='gC/m^2/s', & + avgflag='A', long_name='leaf C growth from storage', & + ptr_patch=this%leafc_xfer_to_leafc_patch, default='inactive') + + this%frootc_xfer_to_frootc_patch(begp:endp) = spval + call hist_addfld1d (fname='FROOTC_XFER_TO_FROOTC', units='gC/m^2/s', & + avgflag='A', long_name='fine root C growth from storage', & + ptr_patch=this%frootc_xfer_to_frootc_patch, default='inactive') + + this%livestemc_xfer_to_livestemc_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVESTEMC_XFER_TO_LIVESTEMC', units='gC/m^2/s', & + avgflag='A', long_name='live stem C growth from storage', & + ptr_patch=this%livestemc_xfer_to_livestemc_patch, default='inactive') + + this%deadstemc_xfer_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='DEADSTEMC_XFER_TO_DEADSTEMC', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C growth from storage', & + ptr_patch=this%deadstemc_xfer_to_deadstemc_patch, default='inactive') + + this%livecrootc_xfer_to_livecrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVECROOTC_XFER_TO_LIVECROOTC', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C growth from storage', & + ptr_patch=this%livecrootc_xfer_to_livecrootc_patch, default='inactive') + + this%deadcrootc_xfer_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='DEADCROOTC_XFER_TO_DEADCROOTC', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root C growth from storage', & + ptr_patch=this%deadcrootc_xfer_to_deadcrootc_patch, default='inactive') + + this%leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='leaf C litterfall', & + ptr_patch=this%leafc_to_litter_patch, default='active') + + this%frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='FROOTC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='fine root C litterfall', & + ptr_patch=this%frootc_to_litter_patch, default='inactive') + + this%leaf_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAF_MR', units='gC/m^2/s', & + avgflag='A', long_name='leaf maintenance respiration', & + ptr_patch=this%leaf_mr_patch) + + this%froot_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='FROOT_MR', units='gC/m^2/s', & + avgflag='A', long_name='fine root maintenance respiration', & + ptr_patch=this%froot_mr_patch, default='inactive') + + this%livestem_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVESTEM_MR', units='gC/m^2/s', & + avgflag='A', long_name='live stem maintenance respiration', & + ptr_patch=this%livestem_mr_patch, default='inactive') + + this%livecroot_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVECROOT_MR', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root maintenance respiration', & + ptr_patch=this%livecroot_mr_patch, default='inactive') + + this%psnsun_to_cpool_patch(begp:endp) = spval + call hist_addfld1d (fname='PSNSUN_TO_CPOOL', units='gC/m^2/s', & + avgflag='A', long_name='C fixation from sunlit canopy', & + ptr_patch=this%psnsun_to_cpool_patch) + + this%psnshade_to_cpool_patch(begp:endp) = spval + call hist_addfld1d (fname='PSNSHADE_TO_CPOOL', units='gC/m^2/s', & + avgflag='A', long_name='C fixation from shaded canopy', & + ptr_patch=this%psnshade_to_cpool_patch) + + this%cpool_to_leafc_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_LEAFC', units='gC/m^2/s', & + avgflag='A', long_name='allocation to leaf C', & + ptr_patch=this%cpool_to_leafc_patch, default='inactive') + + this%cpool_to_leafc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_LEAFC_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to leaf C storage', & + ptr_patch=this%cpool_to_leafc_storage_patch, default='inactive') + + this%cpool_to_frootc_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_FROOTC', units='gC/m^2/s', & + avgflag='A', long_name='allocation to fine root C', & + ptr_patch=this%cpool_to_frootc_patch, default='inactive') + + this%cpool_to_frootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_FROOTC_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to fine root C storage', & + ptr_patch=this%cpool_to_frootc_storage_patch, default='inactive') + + this%cpool_to_livestemc_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_LIVESTEMC', units='gC/m^2/s', & + avgflag='A', long_name='allocation to live stem C', & + ptr_patch=this%cpool_to_livestemc_patch, default='inactive') + + this%cpool_to_livestemc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_LIVESTEMC_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to live stem C storage', & + ptr_patch=this%cpool_to_livestemc_storage_patch, default='inactive') + + this%cpool_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_DEADSTEMC', units='gC/m^2/s', & + avgflag='A', long_name='allocation to dead stem C', & + ptr_patch=this%cpool_to_deadstemc_patch, default='inactive') + + this%cpool_to_deadstemc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_DEADSTEMC_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to dead stem C storage', & + ptr_patch=this%cpool_to_deadstemc_storage_patch, default='inactive') + + this%cpool_to_livecrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_LIVECROOTC', units='gC/m^2/s', & + avgflag='A', long_name='allocation to live coarse root C', & + ptr_patch=this%cpool_to_livecrootc_patch, default='inactive') + + this%cpool_to_livecrootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_LIVECROOTC_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to live coarse root C storage', & + ptr_patch=this%cpool_to_livecrootc_storage_patch, default='inactive') + + this%cpool_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_DEADCROOTC', units='gC/m^2/s', & + avgflag='A', long_name='allocation to dead coarse root C', & + ptr_patch=this%cpool_to_deadcrootc_patch, default='inactive') + + this%cpool_to_deadcrootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_DEADCROOTC_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to dead coarse root C storage', & + ptr_patch=this%cpool_to_deadcrootc_storage_patch, default='inactive') + + this%cpool_to_gresp_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_TO_GRESP_STORAGE', units='gC/m^2/s', & + avgflag='A', long_name='allocation to growth respiration storage', & + ptr_patch=this%cpool_to_gresp_storage_patch, default='inactive') + + this%cpool_leaf_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_LEAF_GR', units='gC/m^2/s', & + avgflag='A', long_name='leaf growth respiration', & + ptr_patch=this%cpool_leaf_gr_patch, default='inactive') + + this%cpool_leaf_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_LEAF_STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='leaf growth respiration to storage', & + ptr_patch=this%cpool_leaf_storage_gr_patch, default='inactive') + + this%transfer_leaf_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_LEAF_GR', units='gC/m^2/s', & + avgflag='A', long_name='leaf growth respiration from storage', & + ptr_patch=this%transfer_leaf_gr_patch, default='inactive') + + this%cpool_froot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_FROOT_GR', units='gC/m^2/s', & + avgflag='A', long_name='fine root growth respiration', & + ptr_patch=this%cpool_froot_gr_patch, default='inactive') + + this%cpool_froot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_FROOT_STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='fine root growth respiration to storage', & + ptr_patch=this%cpool_froot_storage_gr_patch, default='inactive') + + this%transfer_froot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_FROOT_GR', units='gC/m^2/s', & + avgflag='A', long_name='fine root growth respiration from storage', & + ptr_patch=this%transfer_froot_gr_patch, default='inactive') + + this%cpool_livestem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_LIVESTEM_GR', units='gC/m^2/s', & + avgflag='A', long_name='live stem growth respiration', & + ptr_patch=this%cpool_livestem_gr_patch, default='inactive') + + this%cpool_livestem_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_LIVESTEM_STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='live stem growth respiration to storage', & + ptr_patch=this%cpool_livestem_storage_gr_patch, default='inactive') + + this%transfer_livestem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_LIVESTEM_GR', units='gC/m^2/s', & + avgflag='A', long_name='live stem growth respiration from storage', & + ptr_patch=this%transfer_livestem_gr_patch, default='inactive') + + this%cpool_deadstem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_DEADSTEM_GR', units='gC/m^2/s', & + avgflag='A', long_name='dead stem growth respiration', & + ptr_patch=this%cpool_deadstem_gr_patch, default='inactive') + + this%cpool_deadstem_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_DEADSTEM_STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='dead stem growth respiration to storage', & + ptr_patch=this%cpool_deadstem_storage_gr_patch, default='inactive') + + this%transfer_deadstem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_DEADSTEM_GR', units='gC/m^2/s', & + avgflag='A', long_name='dead stem growth respiration from storage', & + ptr_patch=this%transfer_deadstem_gr_patch, default='inactive') + + this%cpool_livecroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_LIVECROOT_GR', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root growth respiration', & + ptr_patch=this%cpool_livecroot_gr_patch, default='inactive') + + this%cpool_livecroot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_LIVECROOT_STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root growth respiration to storage', & + ptr_patch=this%cpool_livecroot_storage_gr_patch, default='inactive') + + this%transfer_livecroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_LIVECROOT_GR', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root growth respiration from storage', & + ptr_patch=this%transfer_livecroot_gr_patch, default='inactive') + + this%cpool_deadcroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_DEADCROOT_GR', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root growth respiration', & + ptr_patch=this%cpool_deadcroot_gr_patch, default='inactive') + + this%cpool_deadcroot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CPOOL_DEADCROOT_STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root growth respiration to storage', & + ptr_patch=this%cpool_deadcroot_storage_gr_patch, default='inactive') + + this%transfer_deadcroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_DEADCROOT_GR', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root growth respiration from storage', & + ptr_patch=this%transfer_deadcroot_gr_patch, default='inactive') + + this%leafc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFC_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='leaf C shift storage to transfer', & + ptr_patch=this%leafc_storage_to_xfer_patch, default='inactive') + + this%frootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='FROOTC_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='fine root C shift storage to transfer', & + ptr_patch=this%frootc_storage_to_xfer_patch, default='inactive') + + this%livestemc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVESTEMC_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='live stem C shift storage to transfer', & + ptr_patch=this%livestemc_storage_to_xfer_patch, default='inactive') + + this%deadstemc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='DEADSTEMC_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='dead stem C shift storage to transfer', & + ptr_patch=this%deadstemc_storage_to_xfer_patch, default='inactive') + + this%livecrootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVECROOTC_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C shift storage to transfer', & + ptr_patch=this%livecrootc_storage_to_xfer_patch, default='inactive') + + this%deadcrootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='DEADCROOTC_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='dead coarse root C shift storage to transfer', & + ptr_patch=this%deadcrootc_storage_to_xfer_patch, default='inactive') + + this%gresp_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='GRESP_STORAGE_TO_XFER', units='gC/m^2/s', & + avgflag='A', long_name='growth respiration shift storage to transfer', & + ptr_patch=this%gresp_storage_to_xfer_patch, default='inactive') + + this%livestemc_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVESTEMC_TO_DEADSTEMC', units='gC/m^2/s', & + avgflag='A', long_name='live stem C turnover', & + ptr_patch=this%livestemc_to_deadstemc_patch, default='inactive') + + this%livecrootc_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='LIVECROOTC_TO_DEADCROOTC', units='gC/m^2/s', & + avgflag='A', long_name='live coarse root C turnover', & + ptr_patch=this%livecrootc_to_deadcrootc_patch, default='inactive') + + this%gpp_patch(begp:endp) = spval + call hist_addfld1d (fname='GPP', units='gC/m^2/s', & + avgflag='A', long_name='gross primary production', & + ptr_patch=this%gpp_patch) + + this%gpp_before_downreg_patch(begp:endp) = spval + call hist_addfld1d (fname='INIT_GPP', units='gC/m^2/s', & + avgflag='A', long_name='GPP flux before downregulation', & + ptr_patch=this%gpp_before_downreg_patch, default='inactive') + + this%mr_patch(begp:endp) = spval + call hist_addfld1d (fname='MR', units='gC/m^2/s', & + avgflag='A', long_name='maintenance respiration', & + ptr_patch=this%mr_patch) + + this%current_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='CURRENT_GR', units='gC/m^2/s', & + avgflag='A', long_name='growth resp for new growth displayed in this timestep', & + ptr_patch=this%current_gr_patch, default='inactive') + + this%transfer_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='TRANSFER_GR', units='gC/m^2/s', & + avgflag='A', long_name='growth resp for transfer growth displayed in this timestep', & + ptr_patch=this%transfer_gr_patch, default='inactive') + + this%storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='STORAGE_GR', units='gC/m^2/s', & + avgflag='A', long_name='growth resp for growth sent to storage for later display', & + ptr_patch=this%storage_gr_patch, default='inactive') + + this%gr_patch(begp:endp) = spval + call hist_addfld1d (fname='GR', units='gC/m^2/s', & + avgflag='A', long_name='total growth respiration', & + ptr_patch=this%gr_patch) + + this%ar_patch(begp:endp) = spval + call hist_addfld1d (fname='AR', units='gC/m^2/s', & + avgflag='A', long_name='autotrophic respiration (MR + GR)', & + ptr_patch=this%ar_patch) + + this%rr_patch(begp:endp) = spval + call hist_addfld1d (fname='RR', units='gC/m^2/s', & + avgflag='A', long_name='root respiration (fine root MR + total root GR)', & + ptr_patch=this%rr_patch) + + this%npp_patch(begp:endp) = spval + call hist_addfld1d (fname='NPP', units='gC/m^2/s', & + avgflag='A', long_name='net primary production', & + ptr_patch=this%npp_patch) + + this%agnpp_patch(begp:endp) = spval + call hist_addfld1d (fname='AGNPP', units='gC/m^2/s', & + avgflag='A', long_name='aboveground NPP', & + ptr_patch=this%agnpp_patch) + + this%bgnpp_patch(begp:endp) = spval + call hist_addfld1d (fname='BGNPP', units='gC/m^2/s', & + avgflag='A', long_name='belowground NPP', & + ptr_patch=this%bgnpp_patch) + + this%litfall_patch(begp:endp) = spval + call hist_addfld1d (fname='LITFALL', units='gC/m^2/s', & + avgflag='A', long_name='litterfall (leaves and fine roots)', & + ptr_patch=this%litfall_patch) + + this%vegfire_patch(begp:endp) = spval + call hist_addfld1d (fname='VEGFIRE', units='gC/m^2/s', & + avgflag='A', long_name='patch-level fire loss', & + ptr_patch=this%vegfire_patch, default='inactive') + + this%wood_harvestc_patch(begp:endp) = spval + call hist_addfld1d (fname='WOOD_HARVESTC', units='gC/m^2/s', & + avgflag='A', long_name='wood harvest carbon (to product pools)', & + ptr_patch=this%wood_harvestc_patch) + + this%fire_closs_patch(begp:endp) = spval + call hist_addfld1d (fname='PFT_FIRE_CLOSS', units='gC/m^2/s', & + avgflag='A', long_name='total patch-level fire C loss for non-peat fires outside land-type converted region', & + ptr_patch=this%fire_closs_patch) + + this%availc_patch(begp:endp) = spval + call hist_addfld1d (fname='AVAILC', units='gC/m^2/s', & + avgflag='A', long_name='C flux available for allocation', & + ptr_patch=this%availc_patch, default='active') + + this%plant_calloc_patch(begp:endp) = spval + call hist_addfld1d (fname='PLANT_CALLOC', units='gC/m^2/s', & + avgflag='A', long_name='total allocated C flux', & + ptr_patch=this%plant_calloc_patch, default='active') + + this%excess_cflux_patch(begp:endp) = spval + call hist_addfld1d (fname='EXCESS_CFLUX', units='gC/m^2/s', & + avgflag='A', long_name='C flux not allocated due to downregulation', & + ptr_patch=this%excess_cflux_patch, default='inactive') + + this%prev_leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='PREV_LEAFC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='previous timestep leaf C litterfall flux', & + ptr_patch=this%prev_leafc_to_litter_patch, default='inactive') + + this%prev_frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='PREV_FROOTC_TO_LITTER', units='gC/m^2/s', & + avgflag='A', long_name='previous timestep froot C litterfall flux', & + ptr_patch=this%prev_frootc_to_litter_patch, default='inactive') + + this%xsmrpool_recover_patch(begp:endp) = spval + call hist_addfld1d (fname='XSMRPOOL_RECOVER', units='gC/m^2/s', & + avgflag='A', long_name='C flux assigned to recovery of negative xsmrpool', & + ptr_patch=this%xsmrpool_recover_patch, default='inactive') + + if (nu_com .ne. 'RD' ) then + this%allocation_leaf(begp:endp) = spval + call hist_addfld1d (fname='allocation_leaf', units='', & + avgflag='A', long_name='fraction of availc allocated to leaf', & + ptr_patch=this%allocation_leaf) + this%allocation_stem(begp:endp) = spval + call hist_addfld1d (fname='allocation_stem', units='', & + avgflag='A', long_name='fraction of availc allocated to stem', & + ptr_patch=this%allocation_stem) + this%allocation_froot(begp:endp) = spval + call hist_addfld1d (fname='allocation_froot', units='', & + avgflag='A', long_name='fraction of availc allocated to fine root', & + ptr_patch=this%allocation_froot) + end if + + end if ! end of if-c12 + + !------------------------------- + ! C13 flux variables - native to PFT + !------------------------------- + if ( carbon_type == 'c13') then + + this%m_leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LEAFC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C mortality', & + ptr_patch=this%m_leafc_to_litter_patch, default='inactive') + + this%m_frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_FROOTC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C mortality', & + ptr_patch=this%m_frootc_to_litter_patch, default='inactive') + + this%m_leafc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LEAFC_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C storage mortality', & + ptr_patch=this%m_leafc_storage_to_litter_patch, default='inactive') + + this%m_frootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_FROOTC_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C storage mortality', & + ptr_patch=this%m_frootc_storage_to_litter_patch, default='inactive') + + this%m_livestemc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVESTEMC_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C storage mortality', & + ptr_patch=this%m_livestemc_storage_to_litter_patch, default='inactive') + + this%m_deadstemc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C storage mortality', & + ptr_patch=this%m_deadstemc_storage_to_litter_patch, default='inactive') + + this%m_livecrootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVECROOTC_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C storage mortality', & + ptr_patch=this%m_livecrootc_storage_to_litter_patch, default='inactive') + + this%m_deadcrootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C storage mortality', & + ptr_patch=this%m_deadcrootc_storage_to_litter_patch, default='inactive') + + this%m_leafc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LEAFC_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C transfer mortality', & + ptr_patch=this%m_leafc_xfer_to_litter_patch, default='inactive') + + this%m_frootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_FROOTC_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C transfer mortality', & + ptr_patch=this%m_frootc_xfer_to_litter_patch, default='inactive') + + this%m_livestemc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVESTEMC_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C transfer mortality', & + ptr_patch=this%m_livestemc_xfer_to_litter_patch, default='inactive') + + this%m_deadstemc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C transfer mortality', & + ptr_patch=this%m_deadstemc_xfer_to_litter_patch, default='inactive') + + this%m_livecrootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVECROOTC_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C transfer mortality', & + ptr_patch=this%m_livecrootc_xfer_to_litter_patch, default='inactive') + + this%m_deadcrootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C transfer mortality', & + ptr_patch=this%m_deadcrootc_xfer_to_litter_patch, default='inactive') + + this%m_livestemc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVESTEMC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C mortality', & + ptr_patch=this%m_livestemc_to_litter_patch, default='inactive') + + this%m_deadstemc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C mortality', & + ptr_patch=this%m_deadstemc_to_litter_patch, default='inactive') + + this%m_livecrootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVECROOTC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C mortality', & + ptr_patch=this%m_livecrootc_to_litter_patch, default='inactive') + + this%m_deadcrootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C mortality', & + ptr_patch=this%m_deadcrootc_to_litter_patch, default='inactive') + + this%m_gresp_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_GRESP_STORAGE_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth respiration storage mortality', & + ptr_patch=this%m_gresp_storage_to_litter_patch, default='inactive') + + this%m_gresp_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_GRESP_XFER_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth respiration transfer mortality', & + ptr_patch=this%m_gresp_xfer_to_litter_patch, default='inactive') + + this%m_leafc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LEAFC_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C fire loss', & + ptr_patch=this%m_leafc_to_fire_patch, default='inactive') + + this%m_frootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_FROOTC_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C fire loss', & + ptr_patch=this%m_frootc_to_fire_patch, default='inactive') + + this%m_leafc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LEAFC_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C storage fire loss', & + ptr_patch=this%m_leafc_storage_to_fire_patch, default='inactive') + + this%m_frootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_FROOTC_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C storage fire loss', & + ptr_patch=this%m_frootc_storage_to_fire_patch, default='inactive') + + this%m_livestemc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVESTEMC_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C storage fire loss', & + ptr_patch=this%m_livestemc_storage_to_fire_patch, default='inactive') + + this%m_deadstemc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C storage fire loss', & + ptr_patch=this%m_deadstemc_storage_to_fire_patch, default='inactive') + + this%m_livecrootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVECROOTC_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C storage fire loss', & + ptr_patch=this%m_livecrootc_storage_to_fire_patch, default='inactive') + + this%m_deadcrootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C storage fire loss', & + ptr_patch=this%m_deadcrootc_storage_to_fire_patch, default='inactive') + + this%m_leafc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LEAFC_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C transfer fire loss', & + ptr_patch=this%m_leafc_xfer_to_fire_patch, default='inactive') + + this%m_frootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_FROOTC_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C transfer fire loss', & + ptr_patch=this%m_frootc_xfer_to_fire_patch, default='inactive') + + this%m_livestemc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVESTEMC_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C transfer fire loss', & + ptr_patch=this%m_livestemc_xfer_to_fire_patch, default='inactive') + + this%m_deadstemc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C transfer fire loss', & + ptr_patch=this%m_deadstemc_xfer_to_fire_patch, default='inactive') + + this%m_livecrootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVECROOTC_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C transfer fire loss', & + ptr_patch=this%m_livecrootc_xfer_to_fire_patch, default='inactive') + + this%m_deadcrootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C transfer fire loss', & + ptr_patch=this%m_deadcrootc_xfer_to_fire_patch, default='inactive') + + this%m_livestemc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVESTEMC_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C fire loss', & + ptr_patch=this%m_livestemc_to_fire_patch, default='inactive') + + this%m_deadstemc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C fire loss', & + ptr_patch=this%m_deadstemc_to_fire_patch, default='inactive') + + this%m_deadstemc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADSTEMC_TO_LITTER_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C fire mortality to litter', & + ptr_patch=this%m_deadstemc_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_LIVECROOTC_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C fire loss', & + ptr_patch=this%m_livecrootc_to_fire_patch, default='inactive') + + this%m_deadcrootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C fire loss', & + ptr_patch=this%m_deadcrootc_to_fire_patch, default='inactive') + + this%m_deadcrootc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_DEADCROOTC_TO_LITTER_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C fire mortality to litter', & + ptr_patch=this%m_deadcrootc_to_litter_fire_patch, default='inactive') + + this%m_gresp_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_GRESP_STORAGE_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth respiration storage fire loss', & + ptr_patch=this%m_gresp_storage_to_fire_patch, default='inactive') + + this%m_gresp_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_M_GRESP_XFER_TO_FIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth respiration transfer fire loss', & + ptr_patch=this%m_gresp_xfer_to_fire_patch, default='inactive') + + this%leafc_xfer_to_leafc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LEAFC_XFER_TO_LEAFC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C growth from storage', & + ptr_patch=this%leafc_xfer_to_leafc_patch, default='inactive') + + this%frootc_xfer_to_frootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_FROOTC_XFER_TO_FROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C growth from storage', & + ptr_patch=this%frootc_xfer_to_frootc_patch, default='inactive') + + this%livestemc_xfer_to_livestemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVESTEMC_XFER_TO_LIVESTEMC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C growth from storage', & + ptr_patch=this%livestemc_xfer_to_livestemc_patch, default='inactive') + + this%deadstemc_xfer_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_DEADSTEMC_XFER_TO_DEADSTEMC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C growth from storage', & + ptr_patch=this%deadstemc_xfer_to_deadstemc_patch, default='inactive') + + this%livecrootc_xfer_to_livecrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVECROOTC_XFER_TO_LIVECROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C growth from storage', & + ptr_patch=this%livecrootc_xfer_to_livecrootc_patch, default='inactive') + + this%deadcrootc_xfer_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_DEADCROOTC_XFER_TO_DEADCROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C growth from storage', & + ptr_patch=this%deadcrootc_xfer_to_deadcrootc_patch, default='inactive') + + this%leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LEAFC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C litterfall', & + ptr_patch=this%leafc_to_litter_patch, default='inactive') + + this%frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_FROOTC_TO_LITTER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C litterfall', & + ptr_patch=this%frootc_to_litter_patch, default='inactive') + + this%leaf_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LEAF_MR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf maintenance respiration', & + ptr_patch=this%leaf_mr_patch, default='inactive') + + this%froot_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_FROOT_MR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root maintenance respiration', & + ptr_patch=this%froot_mr_patch, default='inactive') + + this%livestem_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVESTEM_MR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem maintenance respiration', & + ptr_patch=this%livestem_mr_patch, default='inactive') + + this%livecroot_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVECROOT_MR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root maintenance respiration', & + ptr_patch=this%livecroot_mr_patch, default='inactive') + + this%psnsun_to_cpool_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_PSNSUN_TO_CPOOL', units='gC13/m^2/s', & + avgflag='A', long_name='C13 C fixation from sunlit canopy', & + ptr_patch=this%psnsun_to_cpool_patch) + + this%psnshade_to_cpool_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_PSNSHADE_TO_CPOOL', units='gC13/m^2/s', & + avgflag='A', long_name='C13 C fixation from shaded canopy', & + ptr_patch=this%psnshade_to_cpool_patch) + + this%cpool_to_leafc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_LEAFC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to leaf C', & + ptr_patch=this%cpool_to_leafc_patch, default='inactive') + + this%cpool_to_leafc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_LEAFC_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to leaf C storage', & + ptr_patch=this%cpool_to_leafc_storage_patch, default='inactive') + + this%cpool_to_frootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_FROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to fine root C', & + ptr_patch=this%cpool_to_frootc_patch, default='inactive') + + this%cpool_to_frootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_FROOTC_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to fine root C storage', & + ptr_patch=this%cpool_to_frootc_storage_patch, default='inactive') + + this%cpool_to_livestemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_LIVESTEMC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to live stem C', & + ptr_patch=this%cpool_to_livestemc_patch, default='inactive') + + this%cpool_to_livestemc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_LIVESTEMC_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to live stem C storage', & + ptr_patch=this%cpool_to_livestemc_storage_patch, default='inactive') + + this%cpool_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_DEADSTEMC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to dead stem C', & + ptr_patch=this%cpool_to_deadstemc_patch, default='inactive') + + this%cpool_to_deadstemc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_DEADSTEMC_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to dead stem C storage', & + ptr_patch=this%cpool_to_deadstemc_storage_patch, default='inactive') + + this%cpool_to_livecrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_LIVECROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to live coarse root C', & + ptr_patch=this%cpool_to_livecrootc_patch, default='inactive') + + this%cpool_to_livecrootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_LIVECROOTC_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to live coarse root C storage', & + ptr_patch=this%cpool_to_livecrootc_storage_patch, default='inactive') + + this%cpool_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_DEADCROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to dead coarse root C', & + ptr_patch=this%cpool_to_deadcrootc_patch, default='inactive') + + this%cpool_to_deadcrootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_DEADCROOTC_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to dead coarse root C storage', & + ptr_patch=this%cpool_to_deadcrootc_storage_patch, default='inactive') + + this%cpool_to_gresp_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_TO_GRESP_STORAGE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 allocation to growth respiration storage', & + ptr_patch=this%cpool_to_gresp_storage_patch, default='inactive') + + this%cpool_leaf_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_LEAF_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf growth respiration', & + ptr_patch=this%cpool_leaf_gr_patch, default='inactive') + + this%cpool_leaf_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_LEAF_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf growth respiration to storage', & + ptr_patch=this%cpool_leaf_storage_gr_patch, default='inactive') + + this%transfer_leaf_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_LEAF_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf growth respiration from storage', & + ptr_patch=this%transfer_leaf_gr_patch, default='inactive') + + this%cpool_froot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_FROOT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root growth respiration', & + ptr_patch=this%cpool_froot_gr_patch, default='inactive') + + this%cpool_froot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_FROOT_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root growth respiration to storage', & + ptr_patch=this%cpool_froot_storage_gr_patch, default='inactive') + + this%transfer_froot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_FROOT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root growth respiration from storage', & + ptr_patch=this%transfer_froot_gr_patch, default='inactive') + + this%cpool_livestem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_LIVESTEM_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem growth respiration', & + ptr_patch=this%cpool_livestem_gr_patch, default='inactive') + + this%cpool_livestem_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_LIVESTEM_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem growth respiration to storage', & + ptr_patch=this%cpool_livestem_storage_gr_patch, default='inactive') + + this%transfer_livestem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_LIVESTEM_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem growth respiration from storage', & + ptr_patch=this%transfer_livestem_gr_patch, default='inactive') + + this%cpool_deadstem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_DEADSTEM_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem growth respiration', & + ptr_patch=this%cpool_deadstem_gr_patch, default='inactive') + + this%cpool_deadstem_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_DEADSTEM_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem growth respiration to storage', & + ptr_patch=this%cpool_deadstem_storage_gr_patch, default='inactive') + + this%transfer_deadstem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_DEADSTEM_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem growth respiration from storage', & + ptr_patch=this%transfer_deadstem_gr_patch, default='inactive') + + this%cpool_livecroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_LIVECROOT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root growth respiration', & + ptr_patch=this%cpool_livecroot_gr_patch, default='inactive') + + this%cpool_livecroot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_LIVECROOT_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root growth respiration to storage', & + ptr_patch=this%cpool_livecroot_storage_gr_patch, default='inactive') + + this%transfer_livecroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_LIVECROOT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root growth respiration from storage', & + ptr_patch=this%transfer_livecroot_gr_patch, default='inactive') + + this%cpool_deadcroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_DEADCROOT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root growth respiration', & + ptr_patch=this%cpool_deadcroot_gr_patch, default='inactive') + + this%cpool_deadcroot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CPOOL_DEADCROOT_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root growth respiration to storage', & + ptr_patch=this%cpool_deadcroot_storage_gr_patch, default='inactive') + + this%transfer_deadcroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_DEADCROOT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root growth respiration from storage', & + ptr_patch=this%transfer_deadcroot_gr_patch, default='inactive') + + this%leafc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LEAFC_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 leaf C shift storage to transfer', & + ptr_patch=this%leafc_storage_to_xfer_patch, default='inactive') + + this%frootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_FROOTC_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C shift storage to transfer', & + ptr_patch=this%frootc_storage_to_xfer_patch, default='inactive') + + this%livestemc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVESTEMC_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C shift storage to transfer', & + ptr_patch=this%livestemc_storage_to_xfer_patch, default='inactive') + + this%deadstemc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_DEADSTEMC_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead stem C shift storage to transfer', & + ptr_patch=this%deadstemc_storage_to_xfer_patch, default='inactive') + + this%livecrootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVECROOTC_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C shift storage to transfer', & + ptr_patch=this%livecrootc_storage_to_xfer_patch, default='inactive') + + this%deadcrootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_DEADCROOTC_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 dead coarse root C shift storage to transfer', & + ptr_patch=this%deadcrootc_storage_to_xfer_patch, default='inactive') + + this%gresp_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_GRESP_STORAGE_TO_XFER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth respiration shift storage to transfer', & + ptr_patch=this%gresp_storage_to_xfer_patch, default='inactive') + + this%livestemc_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVESTEMC_TO_DEADSTEMC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live stem C turnover', & + ptr_patch=this%livestemc_to_deadstemc_patch, default='inactive') + + this%livecrootc_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LIVECROOTC_TO_DEADCROOTC', units='gC13/m^2/s', & + avgflag='A', long_name='C13 live coarse root C turnover', & + ptr_patch=this%livecrootc_to_deadcrootc_patch, default='inactive') + + this%gpp_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_GPP', units='gC13/m^2/s', & + avgflag='A', long_name='C13 gross primary production', & + ptr_patch=this%gpp_patch) + + this%mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_MR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 maintenance respiration', & + ptr_patch=this%mr_patch) + + this%current_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_CURRENT_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth resp for new growth displayed in this timestep', & + ptr_patch=this%current_gr_patch, default='inactive') + + this%transfer_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_TRANSFER_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth resp for transfer growth displayed in this timestep', & + ptr_patch=this%transfer_gr_patch, default='inactive') + + this%storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_STORAGE_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 growth resp for growth sent to storage for later display', & + ptr_patch=this%storage_gr_patch, default='inactive') + + this%gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_GR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total growth respiration', & + ptr_patch=this%gr_patch) + + this%ar_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_AR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 autotrophic respiration (MR + GR)', & + ptr_patch=this%ar_patch) + + this%rr_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_RR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 root respiration (fine root MR + total root GR)', & + ptr_patch=this%rr_patch) + + this%npp_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_NPP', units='gC13/m^2/s', & + avgflag='A', long_name='C13 net primary production', & + ptr_patch=this%npp_patch) + + this%agnpp_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_AGNPP', units='gC13/m^2/s', & + avgflag='A', long_name='C13 aboveground NPP', & + ptr_patch=this%agnpp_patch) + + this%bgnpp_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_BGNPP', units='gC13/m^2/s', & + avgflag='A', long_name='C13 belowground NPP', & + ptr_patch=this%bgnpp_patch) + + this%litfall_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_LITFALL', units='gC13/m^2/s', & + avgflag='A', long_name='C13 litterfall (leaves and fine roots)', & + ptr_patch=this%litfall_patch, default='inactive') + + this%vegfire_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_VEGFIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 patch-level fire loss', & + ptr_patch=this%vegfire_patch, default='inactive') + + this%fire_closs_patch(begp:endp) = spval + call hist_addfld1d (fname='C13_PFT_FIRE_CLOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total patch-level fire C loss', & + ptr_patch=this%fire_closs_patch) + endif + + !------------------------------- + ! C14 flux variables - native to PFT + !------------------------------- + if ( carbon_type == 'c14' ) then + + this%m_leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LEAFC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C mortality', & + ptr_patch=this%m_leafc_to_litter_patch, default='inactive') + + this%m_frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_FROOTC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C mortality', & + ptr_patch=this%m_frootc_to_litter_patch, default='inactive') + + this%m_leafc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LEAFC_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C storage mortality', & + ptr_patch=this%m_leafc_storage_to_litter_patch, default='inactive') + + this%m_frootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_FROOTC_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C storage mortality', & + ptr_patch=this%m_frootc_storage_to_litter_patch, default='inactive') + + this%m_livestemc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVESTEMC_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C storage mortality', & + ptr_patch=this%m_livestemc_storage_to_litter_patch, default='inactive') + + this%m_deadstemc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C storage mortality', & + ptr_patch=this%m_deadstemc_storage_to_litter_patch, default='inactive') + + this%m_livecrootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVECROOTC_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C storage mortality', & + ptr_patch=this%m_livecrootc_storage_to_litter_patch, default='inactive') + + this%m_deadcrootc_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C storage mortality', & + ptr_patch=this%m_deadcrootc_storage_to_litter_patch, default='inactive') + + this%m_leafc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LEAFC_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C transfer mortality', & + ptr_patch=this%m_leafc_xfer_to_litter_patch, default='inactive') + + this%m_frootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_FROOTC_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C transfer mortality', & + ptr_patch=this%m_frootc_xfer_to_litter_patch, default='inactive') + + this%m_livestemc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVESTEMC_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C transfer mortality', & + ptr_patch=this%m_livestemc_xfer_to_litter_patch, default='inactive') + + this%m_deadstemc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C transfer mortality', & + ptr_patch=this%m_deadstemc_xfer_to_litter_patch, default='inactive') + + this%m_livecrootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVECROOTC_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C transfer mortality', & + ptr_patch=this%m_livecrootc_xfer_to_litter_patch, default='inactive') + + this%m_deadcrootc_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C transfer mortality', & + ptr_patch=this%m_deadcrootc_xfer_to_litter_patch, default='inactive') + + this%m_livestemc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVESTEMC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C mortality', & + ptr_patch=this%m_livestemc_to_litter_patch, default='inactive') + + this%m_deadstemc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C mortality', & + ptr_patch=this%m_deadstemc_to_litter_patch, default='inactive') + + this%m_livecrootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVECROOTC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C mortality', & + ptr_patch=this%m_livecrootc_to_litter_patch, default='inactive') + + this%m_deadcrootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C mortality', & + ptr_patch=this%m_deadcrootc_to_litter_patch, default='inactive') + + this%m_gresp_storage_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_GRESP_STORAGE_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth respiration storage mortality', & + ptr_patch=this%m_gresp_storage_to_litter_patch, default='inactive') + + this%m_gresp_xfer_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_GRESP_XFER_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth respiration transfer mortality', & + ptr_patch=this%m_gresp_xfer_to_litter_patch, default='inactive') + + this%m_leafc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LEAFC_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C fire loss', & + ptr_patch=this%m_leafc_to_fire_patch, default='inactive') + + this%m_frootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_FROOTC_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C fire loss', & + ptr_patch=this%m_frootc_to_fire_patch, default='inactive') + + this%m_leafc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LEAFC_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C storage fire loss', & + ptr_patch=this%m_leafc_storage_to_fire_patch, default='inactive') + + this%m_frootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_FROOTC_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C storage fire loss', & + ptr_patch=this%m_frootc_storage_to_fire_patch, default='inactive') + + this%m_livestemc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVESTEMC_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C storage fire loss', & + ptr_patch=this%m_livestemc_storage_to_fire_patch, default='inactive') + + this%m_deadstemc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C storage fire loss', & + ptr_patch=this%m_deadstemc_storage_to_fire_patch, default='inactive') + + this%m_livecrootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVECROOTC_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C storage fire loss', & + ptr_patch=this%m_livecrootc_storage_to_fire_patch, default='inactive') + + this%m_deadcrootc_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C storage fire loss', & + ptr_patch=this%m_deadcrootc_storage_to_fire_patch, default='inactive') + + this%m_leafc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LEAFC_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C transfer fire loss', & + ptr_patch=this%m_leafc_xfer_to_fire_patch, default='inactive') + + this%m_frootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_FROOTC_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C transfer fire loss', & + ptr_patch=this%m_frootc_xfer_to_fire_patch, default='inactive') + + this%m_livestemc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVESTEMC_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C transfer fire loss', & + ptr_patch=this%m_livestemc_xfer_to_fire_patch, default='inactive') + + this%m_deadstemc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C transfer fire loss', & + ptr_patch=this%m_deadstemc_xfer_to_fire_patch, default='inactive') + + this%m_livecrootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVECROOTC_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C transfer fire loss', & + ptr_patch=this%m_livecrootc_xfer_to_fire_patch, default='inactive') + + this%m_deadcrootc_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C transfer fire loss', & + ptr_patch=this%m_deadcrootc_xfer_to_fire_patch, default='inactive') + + this%m_livestemc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVESTEMC_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C fire loss', & + ptr_patch=this%m_livestemc_to_fire_patch, default='inactive') + + this%m_deadstemc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C fire loss', & + ptr_patch=this%m_deadstemc_to_fire_patch, default='inactive') + + this%m_deadstemc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADSTEMC_TO_LITTER_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C fire mortality to litter', & + ptr_patch=this%m_deadstemc_to_litter_fire_patch, default='inactive') + + this%m_livecrootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_LIVECROOTC_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C fire loss', & + ptr_patch=this%m_livecrootc_to_fire_patch, default='inactive') + + this%m_deadcrootc_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C fire loss', & + ptr_patch=this%m_deadcrootc_to_fire_patch, default='inactive') + + this%m_deadcrootc_to_litter_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_DEADCROOTC_TO_LITTER_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C fire mortality to litter', & + ptr_patch=this%m_deadcrootc_to_litter_fire_patch, default='inactive') + + this%m_gresp_storage_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_GRESP_STORAGE_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth respiration storage fire loss', & + ptr_patch=this%m_gresp_storage_to_fire_patch, default='inactive') + + this%m_gresp_xfer_to_fire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_M_GRESP_XFER_TO_FIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth respiration transfer fire loss', & + ptr_patch=this%m_gresp_xfer_to_fire_patch, default='inactive') + + this%leafc_xfer_to_leafc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LEAFC_XFER_TO_LEAFC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C growth from storage', & + ptr_patch=this%leafc_xfer_to_leafc_patch, default='inactive') + + this%frootc_xfer_to_frootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_FROOTC_XFER_TO_FROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C growth from storage', & + ptr_patch=this%frootc_xfer_to_frootc_patch, default='inactive') + + this%livestemc_xfer_to_livestemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVESTEMC_XFER_TO_LIVESTEMC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C growth from storage', & + ptr_patch=this%livestemc_xfer_to_livestemc_patch, default='inactive') + + this%deadstemc_xfer_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_DEADSTEMC_XFER_TO_DEADSTEMC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C growth from storage', & + ptr_patch=this%deadstemc_xfer_to_deadstemc_patch, default='inactive') + + this%livecrootc_xfer_to_livecrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVECROOTC_XFER_TO_LIVECROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C growth from storage', & + ptr_patch=this%livecrootc_xfer_to_livecrootc_patch, default='inactive') + + this%deadcrootc_xfer_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_DEADCROOTC_XFER_TO_DEADCROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C growth from storage', & + ptr_patch=this%deadcrootc_xfer_to_deadcrootc_patch, default='inactive') + + this%leafc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LEAFC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C litterfall', & + ptr_patch=this%leafc_to_litter_patch, default='inactive') + + this%frootc_to_litter_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_FROOTC_TO_LITTER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C litterfall', & + ptr_patch=this%frootc_to_litter_patch, default='inactive') + + this%leaf_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LEAF_MR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf maintenance respiration', & + ptr_patch=this%leaf_mr_patch, default='inactive') + + this%froot_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_FROOT_MR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root maintenance respiration', & + ptr_patch=this%froot_mr_patch, default='inactive') + + this%livestem_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVESTEM_MR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem maintenance respiration', & + ptr_patch=this%livestem_mr_patch, default='inactive') + + this%livecroot_mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVECROOT_MR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root maintenance respiration', & + ptr_patch=this%livecroot_mr_patch, default='inactive') + + this%psnsun_to_cpool_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_PSNSUN_TO_CPOOL', units='gC14/m^2/s', & + avgflag='A', long_name='C14 C fixation from sunlit canopy', & + ptr_patch=this%psnsun_to_cpool_patch) + + this%psnshade_to_cpool_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_PSNSHADE_TO_CPOOL', units='gC14/m^2/s', & + avgflag='A', long_name='C14 C fixation from shaded canopy', & + ptr_patch=this%psnshade_to_cpool_patch) + + this%cpool_to_leafc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_LEAFC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to leaf C', & + ptr_patch=this%cpool_to_leafc_patch, default='inactive') + + this%cpool_to_leafc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_LEAFC_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to leaf C storage', & + ptr_patch=this%cpool_to_leafc_storage_patch, default='inactive') + + this%cpool_to_frootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_FROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to fine root C', & + ptr_patch=this%cpool_to_frootc_patch, default='inactive') + + this%cpool_to_frootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_FROOTC_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to fine root C storage', & + ptr_patch=this%cpool_to_frootc_storage_patch, default='inactive') + + this%cpool_to_livestemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_LIVESTEMC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to live stem C', & + ptr_patch=this%cpool_to_livestemc_patch, default='inactive') + + this%cpool_to_livestemc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_LIVESTEMC_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to live stem C storage', & + ptr_patch=this%cpool_to_livestemc_storage_patch, default='inactive') + + this%cpool_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_DEADSTEMC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to dead stem C', & + ptr_patch=this%cpool_to_deadstemc_patch, default='inactive') + + this%cpool_to_deadstemc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_DEADSTEMC_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to dead stem C storage', & + ptr_patch=this%cpool_to_deadstemc_storage_patch, default='inactive') + + this%cpool_to_livecrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_LIVECROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to live coarse root C', & + ptr_patch=this%cpool_to_livecrootc_patch, default='inactive') + + this%cpool_to_livecrootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_LIVECROOTC_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to live coarse root C storage', & + ptr_patch=this%cpool_to_livecrootc_storage_patch, default='inactive') + + this%cpool_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_DEADCROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to dead coarse root C', & + ptr_patch=this%cpool_to_deadcrootc_patch, default='inactive') + + this%cpool_to_deadcrootc_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_DEADCROOTC_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to dead coarse root C storage', & + ptr_patch=this%cpool_to_deadcrootc_storage_patch, default='inactive') + + this%cpool_to_gresp_storage_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_TO_GRESP_STORAGE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 allocation to growth respiration storage', & + ptr_patch=this%cpool_to_gresp_storage_patch, default='inactive') + + this%cpool_leaf_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_LEAF_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf growth respiration', & + ptr_patch=this%cpool_leaf_gr_patch, default='inactive') + + this%cpool_leaf_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_LEAF_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf growth respiration to storage', & + ptr_patch=this%cpool_leaf_storage_gr_patch, default='inactive') + + this%transfer_leaf_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_LEAF_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf growth respiration from storage', & + ptr_patch=this%transfer_leaf_gr_patch, default='inactive') + + this%cpool_froot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_FROOT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root growth respiration', & + ptr_patch=this%cpool_froot_gr_patch, default='inactive') + + this%cpool_froot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_FROOT_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root growth respiration to storage', & + ptr_patch=this%cpool_froot_storage_gr_patch, default='inactive') + + this%transfer_froot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_FROOT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root growth respiration from storage', & + ptr_patch=this%transfer_froot_gr_patch, default='inactive') + + this%cpool_livestem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_LIVESTEM_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem growth respiration', & + ptr_patch=this%cpool_livestem_gr_patch, default='inactive') + + this%cpool_livestem_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_LIVESTEM_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem growth respiration to storage', & + ptr_patch=this%cpool_livestem_storage_gr_patch, default='inactive') + + this%transfer_livestem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_LIVESTEM_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem growth respiration from storage', & + ptr_patch=this%transfer_livestem_gr_patch, default='inactive') + + this%cpool_deadstem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_DEADSTEM_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem growth respiration', & + ptr_patch=this%cpool_deadstem_gr_patch, default='inactive') + + this%cpool_deadstem_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_DEADSTEM_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem growth respiration to storage', & + ptr_patch=this%cpool_deadstem_storage_gr_patch, default='inactive') + + this%transfer_deadstem_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_DEADSTEM_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem growth respiration from storage', & + ptr_patch=this%transfer_deadstem_gr_patch, default='inactive') + + this%cpool_livecroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_LIVECROOT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root growth respiration', & + ptr_patch=this%cpool_livecroot_gr_patch, default='inactive') + + this%cpool_livecroot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_LIVECROOT_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root growth respiration to storage', & + ptr_patch=this%cpool_livecroot_storage_gr_patch, default='inactive') + + this%transfer_livecroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_LIVECROOT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root growth respiration from storage', & + ptr_patch=this%transfer_livecroot_gr_patch, default='inactive') + + this%cpool_deadcroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_DEADCROOT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root growth respiration', & + ptr_patch=this%cpool_deadcroot_gr_patch, default='inactive') + + this%cpool_deadcroot_storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CPOOL_DEADCROOT_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root growth respiration to storage', & + ptr_patch=this%cpool_deadcroot_storage_gr_patch, default='inactive') + + this%transfer_deadcroot_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_DEADCROOT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root growth respiration from storage', & + ptr_patch=this%transfer_deadcroot_gr_patch, default='inactive') + + this%leafc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LEAFC_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 leaf C shift storage to transfer', & + ptr_patch=this%leafc_storage_to_xfer_patch, default='inactive') + + this%frootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_FROOTC_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C shift storage to transfer', & + ptr_patch=this%frootc_storage_to_xfer_patch, default='inactive') + + this%livestemc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVESTEMC_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C shift storage to transfer', & + ptr_patch=this%livestemc_storage_to_xfer_patch, default='inactive') + + this%deadstemc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_DEADSTEMC_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead stem C shift storage to transfer', & + ptr_patch=this%deadstemc_storage_to_xfer_patch, default='inactive') + + this%livecrootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVECROOTC_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C shift storage to transfer', & + ptr_patch=this%livecrootc_storage_to_xfer_patch, default='inactive') + + this%deadcrootc_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_DEADCROOTC_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 dead coarse root C shift storage to transfer', & + ptr_patch=this%deadcrootc_storage_to_xfer_patch, default='inactive') + + this%gresp_storage_to_xfer_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_GRESP_STORAGE_TO_XFER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth respiration shift storage to transfer', & + ptr_patch=this%gresp_storage_to_xfer_patch, default='inactive') + + this%livestemc_to_deadstemc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVESTEMC_TO_DEADSTEMC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live stem C turnover', & + ptr_patch=this%livestemc_to_deadstemc_patch, default='inactive') + + this%livecrootc_to_deadcrootc_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LIVECROOTC_TO_DEADCROOTC', units='gC14/m^2/s', & + avgflag='A', long_name='C14 live coarse root C turnover', & + ptr_patch=this%livecrootc_to_deadcrootc_patch, default='inactive') + + this%gpp_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_GPP', units='gC14/m^2/s', & + avgflag='A', long_name='C14 gross primary production', & + ptr_patch=this%gpp_patch) + + this%mr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_MR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 maintenance respiration', & + ptr_patch=this%mr_patch) + + this%current_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_CURRENT_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth resp for new growth displayed in this timestep', & + ptr_patch=this%current_gr_patch, default='inactive') + + this%transfer_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_TRANSFER_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth resp for transfer growth displayed in this timestep', & + ptr_patch=this%transfer_gr_patch, default='inactive') + + this%storage_gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_STORAGE_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 growth resp for growth sent to storage for later display', & + ptr_patch=this%storage_gr_patch, default='inactive') + + this%gr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_GR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total growth respiration', & + ptr_patch=this%gr_patch) + + this%ar_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_AR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 autotrophic respiration (MR + GR)', & + ptr_patch=this%ar_patch) + + this%rr_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_RR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 root respiration (fine root MR + total root GR)', & + ptr_patch=this%rr_patch) + + this%npp_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_NPP', units='gC14/m^2/s', & + avgflag='A', long_name='C14 net primary production', & + ptr_patch=this%npp_patch) + + this%agnpp_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_AGNPP', units='gC14/m^2/s', & + avgflag='A', long_name='C14 aboveground NPP', & + ptr_patch=this%agnpp_patch) + + this%bgnpp_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_BGNPP', units='gC14/m^2/s', & + avgflag='A', long_name='C14 belowground NPP', & + ptr_patch=this%bgnpp_patch) + + this%litfall_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_LITFALL', units='gC14/m^2/s', & + avgflag='A', long_name='C14 litterfall (leaves and fine roots)', & + ptr_patch=this%litfall_patch, default='inactive') + + this%vegfire_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_VEGFIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 patch-level fire loss', & + ptr_patch=this%vegfire_patch, default='inactive') + + this%fire_closs_patch(begp:endp) = spval + call hist_addfld1d (fname='C14_PFT_FIRE_CLOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total patch-level fire C loss', & + ptr_patch=this%fire_closs_patch) + endif + + !------------------------------- + ! C flux variables - native to column + !------------------------------- + + ! add history fields for all CLAMP CN variables + + if (carbon_type == 'c12') then + + if (hist_wrtch4diag) then + this%fphr_col(begc:endc,1:nlevgrnd) = spval + call hist_addfld_decomp (fname='FPHR'//trim(vr_suffix), units='unitless', type2d='levdcmp', & + avgflag='A', long_name='fraction of potential HR due to N limitation', & + ptr_col=this%fphr_col) + end if + + this%cwdc_hr_col(begc:endc) = spval + call hist_addfld1d (fname='CWDC_HR', units='gC/m^2/s', & + avgflag='A', long_name='coarse woody debris C heterotrophic respiration', & + ptr_col=this%cwdc_hr_col) + + this%cwdc_loss_col(begc:endc) = spval + call hist_addfld1d (fname='CWDC_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='coarse woody debris C loss', & + ptr_col=this%cwdc_loss_col) + + this%lithr_col(begc:endc) = spval + call hist_addfld1d (fname='LITTERC_HR', units='gC/m^2/s', & + avgflag='A', long_name='litter C heterotrophic respiration', & + ptr_col=this%lithr_col) + + this%litterc_loss_col(begc:endc) = spval + call hist_addfld1d (fname='LITTERC_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='litter C loss', & + ptr_col=this%litterc_loss_col) + + this%somhr_col(begc:endc) = spval + call hist_addfld1d (fname='SOILC_HR', units='gC/m^2/s', & + avgflag='A', long_name='soil C heterotrophic respiration', & + ptr_col=this%somhr_col) + + this%somhr_col(begc:endc) = spval + call hist_addfld1d (fname='SOILC_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='soil C loss', & + ptr_col=this%somhr_col) + + ! F. Li and S. Levis + this%lf_conv_cflux_col(begc:endc) = spval + call hist_addfld1d (fname='LF_CONV_CFLUX', units='gC/m^2/s', & + avgflag='A', long_name='conversion carbon due to BET and BDT area decreasing', & + ptr_col=this%lf_conv_cflux_col, default='inactive') + + this%somc_fire_col(begc:endc) = spval + call hist_addfld1d (fname='SOMC_FIRE', units='gC/m^2/s', & + avgflag='A', long_name='C loss due to peat burning', & + ptr_col=this%somc_fire_col, default='inactive') + + + this%m_decomp_cpools_to_fire_col(begc:endc,:) = spval + this%m_decomp_cpools_to_fire_vr_col(begc:endc,:,:) = spval + do k = 1, ndecomp_pools + if ( decomp_cascade_con%is_litter(k) .or. decomp_cascade_con%is_cwd(k) ) then + data1dptr => this%m_decomp_cpools_to_fire_col(:,k) + fieldname = 'M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE' + longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' + call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr, default='inactive') + + if ( nlevdecomp_full > 1 ) then + data2dptr => this%m_decomp_cpools_to_fire_vr_col(:,:,k) + fieldname = 'M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE'//trim(vr_suffix) + longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' + call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + endif + + ! decomposition k + data2dptr => this%decomp_k_col(:,:,k) + fieldname = 'K_'//trim(decomp_cascade_con%decomp_pool_name_history(k)) + longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' potential loss coefficient' + call hist_addfld_decomp (fname=fieldname, units='1/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + end do + + + if(.not. is_active_betr_bgc )then + this%decomp_cascade_hr_col(begc:endc,:) = spval + this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval + this%decomp_cascade_ctransfer_col(begc:endc,:) = spval + this%decomp_cascade_ctransfer_vr_col(begc:endc,:,:) = spval + do l = 1, ndecomp_cascade_transitions + + ! output the vertically integrated fluxes only as default + !-- HR fluxes (none from CWD) + if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then + data1dptr => this%decomp_cascade_hr_col(:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_HR' + else + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_HR_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l))) + endif + longname = 'Het. Resp. from '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr) + endif + + !-- transfer fluxes (none from terminal pool, if present) + if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then + data1dptr => this%decomp_cascade_ctransfer_col(:,l) + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'C_TO_'//& + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))//'C' + longname = 'decomp. of '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))//& + ' C to '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' + call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr) + endif + + ! output the vertically resolved fluxes + if ( nlevdecomp_full > 1 ) then + !-- HR fluxes (none from CWD) + if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then + data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_HR'//trim(vr_suffix) + else + fieldname = & + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'_HR_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& + //trim(vr_suffix) + endif + longname = 'Het. Resp. from '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + + !-- transfer fluxes (none from terminal pool, if present) + if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then + data2dptr => this%decomp_cascade_ctransfer_vr_col(:,:,l) + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))//'C_TO_'//& + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))& + //'C'//trim(vr_suffix) + longname = 'decomp. of '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))//& + ' C to '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' + call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + end if + + end do + endif + + this%t_scalar_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='T_SCALAR', units='unitless', type2d='levdcmp', & + avgflag='A', long_name='temperature inhibition of decomposition', & + ptr_col=this%t_scalar_col) + + this%w_scalar_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='W_SCALAR', units='unitless', type2d='levdcmp', & + avgflag='A', long_name='Moisture (dryness) inhibition of decomposition', & + ptr_col=this%w_scalar_col) + + this%o_scalar_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='O_SCALAR', units='unitless', type2d='levdcmp', & + avgflag='A', long_name='fraction by which decomposition is reduced due to anoxia', & + ptr_col=this%o_scalar_col) + + this%som_c_leached_col(begc:endc) = spval + call hist_addfld1d (fname='SOM_C_LEACHED', units='gC/m^2/s', & + avgflag='A', long_name='total flux of C from SOM pools due to leaching', & + ptr_col=this%som_c_leached_col)!, default='inactive') + + if(.not. is_active_betr_bgc )then + this%decomp_cpools_leached_col(begc:endc,:) = spval + this%decomp_cpools_transport_tendency_col(begc:endc,:,:) = spval + do k = 1, ndecomp_pools + if ( .not. decomp_cascade_con%is_cwd(k) ) then + data1dptr => this%decomp_cpools_leached_col(:,k) + fieldname = 'M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_LEACHING' + longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C leaching loss' + call hist_addfld1d (fname=fieldname, units='gC/m^2/s', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr)!, default='inactive') + + data2dptr => this%decomp_cpools_transport_tendency_col(:,:,k) + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TNDNCY_VERT_TRANSPORT' + longname = trim(decomp_cascade_con%decomp_pool_name_long(k))//' C tendency due to vertical transport' + call hist_addfld_decomp (fname=fieldname, units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + end do + endif + + this%lithr_col(begc:endc) = spval + call hist_addfld1d (fname='LITHR', units='gC/m^2/s', & + avgflag='A', long_name='litter heterotrophic respiration', & + ptr_col=this%lithr_col) + + this%somhr_col(begc:endc) = spval + call hist_addfld1d (fname='SOMHR', units='gC/m^2/s', & + avgflag='A', long_name='soil organic matter heterotrophic respiration', & + ptr_col=this%somhr_col) + + if ( nlevdecomp_full > 1 ) then + this%hr_vr_col(begc:endc,:) = spval + call hist_addfld2d (fname='HR_vr', units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name='total vertically resolved heterotrophic respiration', & + ptr_col=this%hr_vr_col) + + ! pflotran + this%f_co2_soil_vr_col(begc:endc,:) = spval + call hist_addfld2d (fname='F_CO2_SOIL_vr', units='gC/m^3/s', type2d='levdcmp', & + avgflag='A', long_name='total vertically resolved soil-atm. CO2 exchange', & + ptr_col=this%f_co2_soil_vr_col) + endif + + this%hr_col(begc:endc) = spval + call hist_addfld1d (fname='HR', units='gC/m^2/s', & + avgflag='A', long_name='total heterotrophic respiration', & + ptr_col=this%hr_col) + + !pflotran + this%f_co2_soil_col(begc:endc) = spval + call hist_addfld1d (fname='F_CO2_SOIL', units='gC/m^2/s', & + avgflag='A', long_name='total soil-atm. CO2 exchange', & + ptr_col=this%f_co2_soil_col) + + this%sr_col(begc:endc) = spval + call hist_addfld1d (fname='SR', units='gC/m^2/s', & + avgflag='A', long_name='total soil respiration (HR + root resp)', & + ptr_col=this%sr_col) + + this%er_col(begc:endc) = spval + call hist_addfld1d (fname='ER', units='gC/m^2/s', & + avgflag='A', long_name='total ecosystem respiration, autotrophic + heterotrophic', & + ptr_col=this%er_col) + + this%litfire_col(begc:endc) = spval + call hist_addfld1d (fname='LITFIRE', units='gC/m^2/s', & + avgflag='A', long_name='litter fire losses', & + ptr_col=this%litfire_col, default='inactive') + + this%somfire_col(begc:endc) = spval + call hist_addfld1d (fname='SOMFIRE', units='gC/m^2/s', & + avgflag='A', long_name='soil organic matter fire losses', & + ptr_col=this%somfire_col, default='inactive') + + this%totfire_col(begc:endc) = spval + call hist_addfld1d (fname='TOTFIRE', units='gC/m^2/s', & + avgflag='A', long_name='total ecosystem fire losses', & + ptr_col=this%totfire_col, default='inactive') + + this%nep_col(begc:endc) = spval + call hist_addfld1d (fname='NEP', units='gC/m^2/s', & + avgflag='A', long_name='net ecosystem production, excludes fire, landuse, and harvest flux, positive for sink', & + ptr_col=this%nep_col) + + this%nbp_col(begc:endc) = spval + call hist_addfld1d (fname='NBP', units='gC/m^2/s', & + avgflag='A', long_name='net biome production, includes fire, landuse, and harvest flux, positive for sink', & + ptr_col=this%nbp_col) + + this%nee_col(begc:endc) = spval + call hist_addfld1d (fname='NEE', units='gC/m^2/s', & + avgflag='A', long_name='net ecosystem exchange of carbon, includes fire, landuse,'& + //' harvest, and hrv_xsmrpool flux, positive for source', & + ptr_col=this%nee_col) + + + this%fire_closs_col(begc:endc) = spval + call hist_addfld1d (fname='COL_FIRE_CLOSS', units='gC/m^2/s', & + avgflag='A', long_name='total column-level fire C loss for non-peat fires outside land-type converted region', & + ptr_col=this%fire_closs_col, default='inactive') + + this%dwt_seedc_to_leaf_col(begc:endc) = spval + call hist_addfld1d (fname='DWT_SEEDC_TO_LEAF', units='gC/m^2/s', & + avgflag='A', long_name='seed source to patch-level leaf', & + ptr_col=this%dwt_seedc_to_leaf_col, default='inactive') + + this%dwt_seedc_to_deadstem_col(begc:endc) = spval + call hist_addfld1d (fname='DWT_SEEDC_TO_DEADSTEM', units='gC/m^2/s', & + avgflag='A', long_name='seed source to patch-level deadstem', & + ptr_col=this%dwt_seedc_to_deadstem_col, default='inactive') + + this%dwt_conv_cflux_col(begc:endc) = spval + call hist_addfld1d (fname='DWT_CONV_CFLUX', units='gC/m^2/s', & + avgflag='A', long_name='conversion C flux (immediate loss to atm)', & + ptr_col=this%dwt_conv_cflux_col, default='inactive') + + this%dwt_prod10c_gain_col(begc:endc) = spval + call hist_addfld1d (fname='DWT_PROD10C_GAIN', units='gC/m^2/s', & + avgflag='A', long_name='landcover change-driven addition to 10-yr wood product pool', & + ptr_col=this%dwt_prod10c_gain_col, default='inactive') + + this%prod10c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='PROD10C_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='loss from 10-yr wood product pool', & + ptr_col=this%prod10c_loss_col, default='inactive') + + this%dwt_prod100c_gain_col(begc:endc) = spval + call hist_addfld1d (fname='DWT_PROD100C_GAIN', units='gC/m^2/s', & + avgflag='A', long_name='landcover change-driven addition to 100-yr wood product pool', & + ptr_col=this%dwt_prod100c_gain_col, default='inactive') + + this%prod100c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='PROD100C_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='loss from 100-yr wood product pool', & + ptr_col=this%prod100c_loss_col, default='inactive') + + this%prod1c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='PROD1C_LOSS', units='gC/m^2/s', & + avgflag='A', long_name='loss from 1-yr crop product pool', & + ptr_col=this%prod1c_loss_col, default='inactive') + + this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_MET_C', units='gC/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_met_c_col, default='inactive') + + this%dwt_frootc_to_litr_cel_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_CEL_C', units='gC/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_cel_c_col, default='inactive') + + this%dwt_frootc_to_litr_lig_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='DWT_FROOTC_TO_LITR_LIG_C', units='gC/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_lig_c_col, default='inactive') + + this%dwt_livecrootc_to_cwdc_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='DWT_LIVECROOTC_TO_CWDC', units='gC/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='live coarse root to CWD due to landcover change', & + ptr_col=this%dwt_livecrootc_to_cwdc_col, default='inactive') + + this%dwt_deadcrootc_to_cwdc_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='DWT_DEADCROOTC_TO_CWDC', units='gC/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='dead coarse root to CWD due to landcover change', & + ptr_col=this%dwt_deadcrootc_to_cwdc_col, default='inactive') + + this%dwt_closs_col(begc:endc) = spval + call hist_addfld1d (fname='DWT_CLOSS', units='gC/m^2/s', & + avgflag='A', long_name='total carbon loss from land cover conversion', & + ptr_col=this%dwt_closs_col, default='inactive') + + this%product_closs_col(begc:endc) = spval + call hist_addfld1d (fname='PRODUCT_CLOSS', units='gC/m^2/s', & + avgflag='A', long_name='total carbon loss from wood product pools', & + ptr_col=this%product_closs_col, default='inactive') + + this%landuseflux_col(begc:endc) = spval + call hist_addfld1d (fname='LAND_USE_FLUX', units='gC/m^2/s', & + avgflag='A', long_name='total C emitted from land cover conversion and wood product pools', & + ptr_col=this%landuseflux_col) + + this%landuptake_col(begc:endc) = spval + call hist_addfld1d (fname='LAND_UPTAKE', units='gC/m^2/s', & + avgflag='A', long_name='NEE minus LAND_USE_FLUX, negative for update', & + ptr_col=this%landuptake_col) + + + this%annsum_npp_patch(begp:endp) = spval + call hist_addfld1d (fname='ANNSUM_NPP', units='gC/m^2/yr', & + avgflag='A', long_name='annual sum of NPP', & + ptr_patch=this%annsum_npp_patch, default='inactive') + + this%annsum_npp_col(begc:endc) = spval + call hist_addfld1d (fname='CANNSUM_NPP', units='gC/m^2/s', & + avgflag='A', long_name='annual sum of column-level NPP', & + ptr_col=this%annsum_npp_col, default='inactive') + + + end if + + ctag=get_carbontag(carbon_type) + do k = 1, ndecomp_pools + this%bgc_cpool_ext_inputs_vr_col(begc:endc, :, k) = spval + data2dptr => this%bgc_cpool_ext_inputs_vr_col(:,:,k) + fieldname='BGC_'//trim(ctag)//'POOL_EINPUT_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'_vr' + longname=trim(ctag)//' input to '//trim(decomp_cascade_con%decomp_pool_name_history(k)) + call hist_addfld_decomp (fname=fieldname, units='g'//ctag//'/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + + this%bgc_cpool_ext_loss_vr_col(begc:endc, :, k) = spval + data2dptr => this%bgc_cpool_ext_loss_vr_col(:,:,k) + fieldname='BGC_'//trim(ctag)//'POOL_ELOSS_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'_vr' + longname=trim(ctag)//' loss of '//trim(decomp_cascade_con%decomp_pool_name_history(k)) + call hist_addfld_decomp (fname=fieldname, units='g'//ctag//'/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + + enddo + + !------------------------------- + ! C13 flux variables - native to column + !------------------------------- + + if ( carbon_type == 'c13' ) then + + this%m_decomp_cpools_to_fire_col(begc:endc,:) = spval + this%m_decomp_cpools_to_fire_vr_col(begc:endc,:,:) = spval + do k = 1, ndecomp_pools + if ( decomp_cascade_con%is_litter(k) .or. decomp_cascade_con%is_cwd(k) ) then + data1dptr => this%m_decomp_cpools_to_fire_col(:,k) + fieldname = 'C13_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE' + longname = 'C13 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' + call hist_addfld1d (fname=fieldname, units='gC13/m^2', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr, default='inactive') + + if ( nlevdecomp_full > 1 ) then + data2dptr => this%m_decomp_cpools_to_fire_vr_col(:,:,k) + fieldname = 'C13_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE'//trim(vr_suffix) + longname = 'C13 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' + call hist_addfld_decomp (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + end if + endif + end do + if(.not. is_active_betr_bgc)then + this%decomp_cascade_hr_col(begc:endc,:) = spval + this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval + this%decomp_cascade_ctransfer_col(begc:endc,:) = spval + this%decomp_cascade_ctransfer_vr_col(begc:endc,:,:) = spval + do l = 1, ndecomp_cascade_transitions + !-- HR fluxes (none from CWD) + if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then + data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_HR'//trim(vr_suffix) + else + fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_HR_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))//& + trim(vr_suffix) + endif + longname = 'C13 Het. Resp. from '& + //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld_decomp (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + !-- transfer fluxes (none from terminal pool, if present) + if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then + data2dptr => this%decomp_cascade_ctransfer_vr_col(:,:,l) + fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'C_TO_'//& + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))& + //'C'//trim(vr_suffix) + longname = 'C13 decomp. of '& + //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))& + //' C to '//& + trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' + call hist_addfld_decomp (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + end do + endif + + this%lithr_col(begc:endc) = spval + call hist_addfld1d (fname='C13_LITHR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 fine root C litterfall to litter 3 C', & + ptr_col=this%lithr_col) + + this%somhr_col(begc:endc) = spval + call hist_addfld1d (fname='C13_SOMHR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 soil organic matter heterotrophic respiration', & + ptr_col=this%somhr_col) + + this%hr_col(begc:endc) = spval + call hist_addfld1d (fname='C13_HR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total heterotrophic respiration', & + ptr_col=this%hr_col) + + + this%sr_col(begc:endc) = spval + call hist_addfld1d (fname='C13_SR', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total soil respiration (HR + root resp)', & + ptr_col=this%sr_col) + + this%er_col(begc:endc) = spval + call hist_addfld1d (fname='C13_ER', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total ecosystem respiration, autotrophic + heterotrophic', & + ptr_col=this%er_col) + + this%litfire_col(begc:endc) = spval + call hist_addfld1d (fname='C13_LITFIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 litter fire losses', & + ptr_col=this%litfire_col, default='inactive') + + this%somfire_col(begc:endc) = spval + call hist_addfld1d (fname='C13_SOMFIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 soil organic matter fire losses', & + ptr_col=this%somfire_col, default='inactive') + + this%totfire_col(begc:endc) = spval + call hist_addfld1d (fname='C13_TOTFIRE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total ecosystem fire losses', & + ptr_col=this%totfire_col, default='inactive') + + this%nep_col(begc:endc) = spval + call hist_addfld1d (fname='C13_NEP', units='gC13/m^2/s', & + avgflag='A', long_name='C13 net ecosystem production, excludes fire flux, positive for sink', & + ptr_col=this%nep_col) + + this%nee_col(begc:endc) = spval + call hist_addfld1d (fname='C13_NEE', units='gC13/m^2/s', & + avgflag='A', long_name='C13 net ecosystem exchange of carbon, includes fire flux, positive for source', & + ptr_col=this%nee_col) + + this%fire_closs_col(begc:endc) = spval + call hist_addfld1d (fname='C13_COL_FIRE_CLOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total column-level fire C loss', & + ptr_col=this%fire_closs_col) + + this%dwt_seedc_to_leaf_col(begc:endc) = spval + call hist_addfld1d (fname='C13_DWT_SEEDC_TO_LEAF', units='gC13/m^2/s', & + avgflag='A', long_name='C13 seed source to patch-level leaf', & + ptr_col=this%dwt_seedc_to_leaf_col) + + this%dwt_seedc_to_deadstem_col(begc:endc) = spval + call hist_addfld1d (fname='C13_DWT_SEEDC_TO_DEADSTEM', units='gC13/m^2/s', & + avgflag='A', long_name='C13 seed source to patch-level deadstem', & + ptr_col=this%dwt_seedc_to_deadstem_col) + + this%dwt_conv_cflux_col(begc:endc) = spval + call hist_addfld1d (fname='C13_DWT_CONV_CFLUX', units='gC13/m^2/s', & + avgflag='A', long_name='C13 conversion C flux (immediate loss to atm)', & + ptr_col=this%dwt_conv_cflux_col) + + this%dwt_prod10c_gain_col(begc:endc) = spval + call hist_addfld1d (fname='C13_DWT_PROD10C_GAIN', units='gC13/m^2/s', & + avgflag='A', long_name='C13 addition to 10-yr wood product pool', & + ptr_col=this%dwt_prod10c_gain_col) + + this%prod10c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='C13_PROD10C_LOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 loss from 10-yr wood product pool', & + ptr_col=this%prod10c_loss_col) + + this%dwt_prod100c_gain_col(begc:endc) = spval + call hist_addfld1d (fname='C13_DWT_PROD100C_GAIN', units='gC13/m^2/s', & + avgflag='A', long_name='C13 addition to 100-yr wood product pool', & + ptr_col=this%dwt_prod100c_gain_col) + + this%prod100c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='C13_PROD100C_LOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 loss from 100-yr wood product pool', & + ptr_col=this%prod100c_loss_col) + + this%prod1c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='C13_PROD1C_LOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 loss from 1-yr crop product pool', & + ptr_col=this%prod1c_loss_col) + + this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_MET_C', units='gC13/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C13 fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_met_c_col, default='inactive') + + this%dwt_frootc_to_litr_cel_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_CEL_C', units='gC13/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C13 fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_cel_c_col, default='inactive') + + this%dwt_frootc_to_litr_lig_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C13_DWT_FROOTC_TO_LITR_LIG_C', units='gC13/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C13 fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_lig_c_col, default='inactive') + + this%dwt_livecrootc_to_cwdc_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C13_DWT_LIVECROOTC_TO_CWDC', units='gC13/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C13 live coarse root to CWD due to landcover change', & + ptr_col=this%dwt_livecrootc_to_cwdc_col, default='inactive') + + this%dwt_deadcrootc_to_cwdc_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C13_DWT_DEADCROOTC_TO_CWDC', units='gC13/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C13 dead coarse root to CWD due to landcover change', & + ptr_col=this%dwt_deadcrootc_to_cwdc_col, default='inactive') + + this%dwt_closs_col(begc:endc) = spval + call hist_addfld1d (fname='C13_DWT_CLOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total carbon loss from land cover conversion', & + ptr_col=this%dwt_closs_col) + + this%product_closs_col(begc:endc) = spval + call hist_addfld1d (fname='C13_PRODUCT_CLOSS', units='gC13/m^2/s', & + avgflag='A', long_name='C13 total carbon loss from wood product pools', & + ptr_col=this%product_closs_col) + + endif + + !------------------------------- + ! C14 flux variables - native to column + !------------------------------- + + if (carbon_type == 'c14') then + + this%m_decomp_cpools_to_fire_col(begc:endc,:) = spval + this%m_decomp_cpools_to_fire_vr_col(begc:endc,:,:) = spval + do k = 1, ndecomp_pools + if ( decomp_cascade_con%is_litter(k) .or. decomp_cascade_con%is_cwd(k) ) then + data1dptr => this%m_decomp_cpools_to_fire_col(:,k) + fieldname = 'C14_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE' + longname = 'C14 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' + call hist_addfld1d (fname=fieldname, units='gC14/m^2', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr, default='inactive') + + if ( nlevdecomp_full > 1 ) then + data2dptr => this%m_decomp_cpools_to_fire_vr_col(:,:,k) + fieldname = 'C14_M_'//trim(decomp_cascade_con%decomp_pool_name_history(k))//'C_TO_FIRE'//trim(vr_suffix) + longname = 'C14 '//trim(decomp_cascade_con%decomp_pool_name_long(k))//' C fire loss' + call hist_addfld_decomp (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + end if + endif + end do + if(.not. is_active_betr_bgc)then + this%decomp_cascade_hr_col(begc:endc,:) = spval + this%decomp_cascade_hr_vr_col(begc:endc,:,:) = spval + this%decomp_cascade_ctransfer_col(begc:endc,:) = spval + this%decomp_cascade_ctransfer_vr_col(begc:endc,:,:) = spval + do l = 1, ndecomp_cascade_transitions + !-- HR fluxes (none from CWD) + if ( .not. decomp_cascade_con%is_cwd(decomp_cascade_con%cascade_donor_pool(l)) ) then + data2dptr => this%decomp_cascade_hr_vr_col(:,:,l) + ! check to see if there are multiple pathways that include respiration, and if so, note that in the history file + ii = 0 + do jj = 1, ndecomp_cascade_transitions + if ( decomp_cascade_con%cascade_donor_pool(jj) == decomp_cascade_con%cascade_donor_pool(l) ) ii = ii+1 + end do + if ( ii == 1 ) then + fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_HR'//trim(vr_suffix) + else + fieldname = 'C14_'//& + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'_HR_'//& + trim(decomp_cascade_con%decomp_pool_name_short(decomp_cascade_con%cascade_receiver_pool(l)))& + //trim(vr_suffix) + endif + longname = 'C14 Het. Resp. from '& + //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l))) + call hist_addfld_decomp (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + !-- transfer fluxes (none from terminal pool, if present) + if ( decomp_cascade_con%cascade_receiver_pool(l) /= 0 ) then + data2dptr => this%decomp_cascade_ctransfer_vr_col(:,:,l) + fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_donor_pool(l)))& + //'C_TO_'//& + trim(decomp_cascade_con%decomp_pool_name_history(decomp_cascade_con%cascade_receiver_pool(l)))& + //'C'//trim(vr_suffix) + longname = 'C14 decomp. of '& + //trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_donor_pool(l)))//& + ' C to '//trim(decomp_cascade_con%decomp_pool_name_long(decomp_cascade_con%cascade_receiver_pool(l)))//' C' + call hist_addfld_decomp (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr, default='inactive') + endif + end do + endif + + this%lithr_col(begc:endc) = spval + call hist_addfld1d (fname='C14_LITHR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 fine root C litterfall to litter 3 C', & + ptr_col=this%lithr_col) + + this%somhr_col(begc:endc) = spval + call hist_addfld1d (fname='C14_SOMHR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 soil organic matter heterotrophic respiration', & + ptr_col=this%somhr_col) + + this%hr_col(begc:endc) = spval + call hist_addfld1d (fname='C14_HR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total heterotrophic respiration', & + ptr_col=this%hr_col) + + + this%sr_col(begc:endc) = spval + call hist_addfld1d (fname='C14_SR', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total soil respiration (HR + root resp)', & + ptr_col=this%sr_col) + + this%er_col(begc:endc) = spval + call hist_addfld1d (fname='C14_ER', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total ecosystem respiration, autotrophic + heterotrophic', & + ptr_col=this%er_col) + + this%litfire_col(begc:endc) = spval + call hist_addfld1d (fname='C14_LITFIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 litter fire losses', & + ptr_col=this%litfire_col, default='inactive') + + this%somfire_col(begc:endc) = spval + call hist_addfld1d (fname='C14_SOMFIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 soil organic matter fire losses', & + ptr_col=this%somfire_col, default='inactive') + + this%totfire_col(begc:endc) = spval + call hist_addfld1d (fname='C14_TOTFIRE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total ecosystem fire losses', & + ptr_col=this%totfire_col, default='inactive') + + this%nep_col(begc:endc) = spval + call hist_addfld1d (fname='C14_NEP', units='gC14/m^2/s', & + avgflag='A', long_name='C14 net ecosystem production, excludes fire flux, positive for sink', & + ptr_col=this%nep_col) + + this%nee_col(begc:endc) = spval + call hist_addfld1d (fname='C14_NEE', units='gC14/m^2/s', & + avgflag='A', long_name='C14 net ecosystem exchange of carbon, includes fire flux, positive for source', & + ptr_col=this%nee_col) + + this%fire_closs_col(begc:endc) = spval + call hist_addfld1d (fname='C14_COL_FIRE_CLOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total column-level fire C loss', & + ptr_col=this%fire_closs_col) + + this%dwt_seedc_to_leaf_col(begc:endc) = spval + call hist_addfld1d (fname='C14_DWT_SEEDC_TO_LEAF', units='gC14/m^2/s', & + avgflag='A', long_name='C14 seed source to patch-level leaf', & + ptr_col=this%dwt_seedc_to_leaf_col) + + this%dwt_seedc_to_deadstem_col(begc:endc) = spval + call hist_addfld1d (fname='C14_DWT_SEEDC_TO_DEADSTEM', units='gC14/m^2/s', & + avgflag='A', long_name='C14 seed source to patch-level deadstem', & + ptr_col=this%dwt_seedc_to_deadstem_col) + + this%dwt_conv_cflux_col(begc:endc) = spval + call hist_addfld1d (fname='C14_DWT_CONV_CFLUX', units='gC14/m^2/s', & + avgflag='A', long_name='C14 conversion C flux (immediate loss to atm)', & + ptr_col=this%dwt_conv_cflux_col) + + this%dwt_prod10c_gain_col(begc:endc) = spval + call hist_addfld1d (fname='C14_DWT_PROD10C_GAIN', units='gC14/m^2/s', & + avgflag='A', long_name='C14 addition to 10-yr wood product pool', & + ptr_col=this%dwt_prod10c_gain_col) + + this%prod10c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='C14_PROD10C_LOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 loss from 10-yr wood product pool', & + ptr_col=this%prod10c_loss_col) + + this%dwt_prod100c_gain_col(begc:endc) = spval + call hist_addfld1d (fname='C14_DWT_PROD100C_GAIN', units='gC14/m^2/s', & + avgflag='A', long_name='C14 addition to 100-yr wood product pool', & + ptr_col=this%dwt_prod100c_gain_col) + + this%prod100c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='C14_PROD100C_LOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 loss from 100-yr wood product pool', & + ptr_col=this%prod100c_loss_col) + + this%prod1c_loss_col(begc:endc) = spval + call hist_addfld1d (fname='C14_PROD1C_LOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 loss from 1-yr crop product pool', & + ptr_col=this%prod1c_loss_col) + + this%dwt_frootc_to_litr_met_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_MET_C', units='gC14/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C14 fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_met_c_col, default='inactive') + + this%dwt_frootc_to_litr_cel_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_CEL_C', units='gC14/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C14 fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_cel_c_col, default='inactive') + + this%dwt_frootc_to_litr_lig_c_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C14_DWT_FROOTC_TO_LITR_LIG_C', units='gC14/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C14 fine root to litter due to landcover change', & + ptr_col=this%dwt_frootc_to_litr_lig_c_col, default='inactive') + + this%dwt_livecrootc_to_cwdc_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C14_DWT_LIVECROOTC_TO_CWDC', units='gC14/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C14 live coarse root to CWD due to landcover change', & + ptr_col=this%dwt_livecrootc_to_cwdc_col, default='inactive') + + this%dwt_deadcrootc_to_cwdc_col(begc:endc,:) = spval + call hist_addfld_decomp (fname='C14_DWT_DEADCROOTC_TO_CWDC', units='gC14/m^2/s', type2d='levdcmp', & + avgflag='A', long_name='C14 dead coarse root to CWD due to landcover change', & + ptr_col=this%dwt_deadcrootc_to_cwdc_col, default='inactive') + + this%dwt_closs_col(begc:endc) = spval + call hist_addfld1d (fname='C14_DWT_CLOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total carbon loss from land cover conversion', & + ptr_col=this%dwt_closs_col) + + this%product_closs_col(begc:endc) = spval + call hist_addfld1d (fname='C14_PRODUCT_CLOSS', units='gC14/m^2/s', & + avgflag='A', long_name='C14 total carbon loss from wood product pools', & + ptr_col=this%product_closs_col) + + endif + + if (carbon_type == 'c13' .and. .not.use_ed ) then + this%xsmrpool_c13ratio_patch(begp:endp) = spval + call hist_addfld1d (fname='XSMRPOOL_C13RATIO', units='proportion', & + avgflag='A', long_name='C13/C(12+13) ratio for xsmrpool', & + ptr_patch=this%xsmrpool_c13ratio_patch, default='inactive') + endif + + end subroutine InitHistory !----------------------------------------------------------------------- subroutine InitCold(this, bounds) @@ -3729,8 +3774,6 @@ subroutine Restart ( this, bounds, ncid, flag ) ! Prognostic crop variables !------------------------------- - - if (crop_prog) then call restartvar(ncid=ncid, flag=flag, varname='grainc_xfer_to_grainc', xtype=ncd_double, & @@ -4345,376 +4388,381 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil !----------------------------------------------------------------------- associate(& - is_litter => decomp_cascade_con%is_litter , & ! Input: [logical (:) ] TRUE => pool is a litter pool - is_soil => decomp_cascade_con%is_soil , & ! Input: [logical (:) ] TRUE => pool is a soil pool - is_cwd => decomp_cascade_con%is_cwd & ! Input: [logical (:) ] TRUE => pool is a cwd pool - ) - + is_litter => decomp_cascade_con%is_litter , & ! Input: [logical (:) ] TRUE => pool is a litter pool + is_soil => decomp_cascade_con%is_soil , & ! Input: [logical (:) ] TRUE => pool is a soil pool + is_cwd => decomp_cascade_con%is_cwd & ! Input: [logical (:) ] TRUE => pool is a cwd pool + ) + + ! Note that some of these variables and summary statistics are relevant to fates + ! yet the great majority are not, and instead of riddling this subroutine + ! with .not.use_ed filters, a wrapper will be created that selects the variables that should + ! be used. + if (use_ed) return + + ! patch loop - if (.not.use_ed) then - do fp = 1,num_soilp - p = filter_soilp(fp) - - ! calculate pft-level summary carbon fluxes and states - - ! gross primary production (GPP) - this%gpp_patch(p) = & - this%psnsun_to_cpool_patch(p) + & - this%psnshade_to_cpool_patch(p) - - ! maintenance respiration (MR) - if ( trim(isotope) == 'c13' .or. trim(isotope) == 'c14') then - this%leaf_mr_patch(p) = this%leaf_curmr_patch(p) + this%leaf_xsmr_patch(p) - this%froot_mr_patch(p) = this%froot_curmr_patch(p) + this%froot_xsmr_patch(p) - this%livestem_mr_patch(p) = this%livestem_curmr_patch(p) + this%livestem_xsmr_patch(p) - this%livecroot_mr_patch(p) = this%livecroot_curmr_patch(p) + this%livecroot_xsmr_patch(p) - endif - - this%mr_patch(p) = & - this%leaf_mr_patch(p) + & - this%froot_mr_patch(p) + & - this%livestem_mr_patch(p) + & - this%livecroot_mr_patch(p) - - ! growth respiration (GR) - ! current GR is respired this time step for new growth displayed in this timestep - this%current_gr_patch(p) = & - this%cpool_leaf_gr_patch(p) + & - this%cpool_froot_gr_patch(p) + & - this%cpool_livestem_gr_patch(p) + & - this%cpool_deadstem_gr_patch(p) + & - this%cpool_livecroot_gr_patch(p) + & - this%cpool_deadcroot_gr_patch(p) - - ! transfer GR is respired this time step for transfer growth displayed in this timestep - this%transfer_gr_patch(p) = & - this%transfer_leaf_gr_patch(p) + & - this%transfer_froot_gr_patch(p) + & - this%transfer_livestem_gr_patch(p) + & - this%transfer_deadstem_gr_patch(p) + & - this%transfer_livecroot_gr_patch(p) + & - this%transfer_deadcroot_gr_patch(p) - - ! storage GR is respired this time step for growth sent to storage for later display - this%storage_gr_patch(p) = & - this%cpool_leaf_storage_gr_patch(p) + & - this%cpool_froot_storage_gr_patch(p) + & - this%cpool_livestem_storage_gr_patch(p) + & - this%cpool_deadstem_storage_gr_patch(p) + & - this%cpool_livecroot_storage_gr_patch(p) + & - this%cpool_deadcroot_storage_gr_patch(p) - - if ( crop_prog .and. pft%itype(p) >= npcropmin )then - this%mr_patch(p) = & - this%mr_patch(p) + & - this%grain_mr_patch(p) - - this%current_gr_patch(p) = & - this%current_gr_patch(p) + & - this%cpool_grain_gr_patch(p) - - this%transfer_gr_patch(p) = & - this%transfer_gr_patch(p) + & - this%transfer_grain_gr_patch(p) - - this%storage_gr_patch(p) = & - this%storage_gr_patch(p) + & - this%cpool_grain_storage_gr_patch(p) - end if - - ! GR is the sum of current + transfer + storage GR - this%gr_patch(p) = & - this%current_gr_patch(p) + & - this%transfer_gr_patch(p) + & - this%storage_gr_patch(p) - - ! autotrophic respiration (AR) - if ( crop_prog .and. pft%itype(p) >= npcropmin )then - this%ar_patch(p) = & - this%mr_patch(p) + & - this%gr_patch(p) + & - this%xsmrpool_to_atm_patch(p) ! xsmr... is -ve (slevis) - if (nu_com .ne. 'RD' ) then - this%ar_patch(p) = this%ar_patch(p) + & - this%xsmrpool_turnover_patch(p) - end if - else - this%ar_patch(p) = & - this%mr_patch(p) + & - this%gr_patch(p) - if (nu_com .ne. 'RD' ) then - this%ar_patch(p) = this%ar_patch(p) + & - this%xsmrpool_turnover_patch(p) - end if - end if - - - - ! net primary production (NPP) - this%npp_patch(p) = & - this%gpp_patch(p) - & - this%ar_patch(p) - - ! update the annual NPP accumulator, for use in allocation code - if (trim(isotope) == 'bulk') then - this%tempsum_npp_patch(p) = & - this%tempsum_npp_patch(p) + & - this%npp_patch(p) - end if - - ! litterfall (LITFALL) - - this%litfall_patch(p) = & - this%leafc_to_litter_patch(p) + & - this%frootc_to_litter_patch(p) + & - this%m_leafc_to_litter_patch(p) + & - this%m_leafc_storage_to_litter_patch(p) + & - this%m_leafc_xfer_to_litter_patch(p) + & - this%m_frootc_to_litter_patch(p) + & - this%m_frootc_storage_to_litter_patch(p) + & - this%m_frootc_xfer_to_litter_patch(p) + & - this%m_livestemc_to_litter_patch(p) + & - this%m_livestemc_storage_to_litter_patch(p) + & - this%m_livestemc_xfer_to_litter_patch(p) + & - this%m_deadstemc_to_litter_patch(p) + & - this%m_deadstemc_storage_to_litter_patch(p) + & - this%m_deadstemc_xfer_to_litter_patch(p) + & - this%m_livecrootc_to_litter_patch(p) + & - this%m_livecrootc_storage_to_litter_patch(p) + & - this%m_livecrootc_xfer_to_litter_patch(p) + & - this%m_deadcrootc_to_litter_patch(p) + & - this%m_deadcrootc_storage_to_litter_patch(p) + & - this%m_deadcrootc_xfer_to_litter_patch(p) + & - this%m_gresp_storage_to_litter_patch(p) + & - this%m_gresp_xfer_to_litter_patch(p) + & - - this%m_leafc_to_litter_fire_patch(p) + & - this%m_leafc_storage_to_litter_fire_patch(p) + & - this%m_leafc_xfer_to_litter_fire_patch(p) + & - this%m_livestemc_to_litter_fire_patch(p) + & - this%m_livestemc_storage_to_litter_fire_patch(p) + & - this%m_livestemc_xfer_to_litter_fire_patch(p) + & - this%m_deadstemc_to_litter_fire_patch(p) + & - this%m_deadstemc_storage_to_litter_fire_patch(p) + & - this%m_deadstemc_xfer_to_litter_fire_patch(p) + & - this%m_frootc_to_litter_fire_patch(p) + & - this%m_frootc_storage_to_litter_fire_patch(p) + & - this%m_frootc_xfer_to_litter_fire_patch(p) + & - this%m_livecrootc_to_litter_fire_patch(p) + & - this%m_livecrootc_storage_to_litter_fire_patch(p) + & - this%m_livecrootc_xfer_to_litter_fire_patch(p) + & - this%m_deadcrootc_to_litter_fire_patch(p) + & - this%m_deadcrootc_storage_to_litter_fire_patch(p) + & - this%m_deadcrootc_xfer_to_litter_fire_patch(p) + & - this%m_gresp_storage_to_litter_fire_patch(p) + & - this%m_gresp_xfer_to_litter_fire_patch(p) + & - - this%hrv_leafc_to_litter_patch(p) + & - this%hrv_leafc_storage_to_litter_patch(p) + & - this%hrv_leafc_xfer_to_litter_patch(p) + & - this%hrv_frootc_to_litter_patch(p) + & - this%hrv_frootc_storage_to_litter_patch(p) + & - this%hrv_frootc_xfer_to_litter_patch(p) + & - this%hrv_livestemc_to_litter_patch(p) + & - this%hrv_livestemc_storage_to_litter_patch(p) + & - this%hrv_livestemc_xfer_to_litter_patch(p) + & - this%hrv_deadstemc_storage_to_litter_patch(p) + & - this%hrv_deadstemc_xfer_to_litter_patch(p) + & - this%hrv_livecrootc_to_litter_patch(p) + & - this%hrv_livecrootc_storage_to_litter_patch(p) + & - this%hrv_livecrootc_xfer_to_litter_patch(p) + & - this%hrv_deadcrootc_to_litter_patch(p) + & - this%hrv_deadcrootc_storage_to_litter_patch(p) + & - this%hrv_deadcrootc_xfer_to_litter_patch(p) + & - this%hrv_gresp_storage_to_litter_patch(p) + & - this%hrv_gresp_xfer_to_litter_patch(p) - - ! update the annual litfall accumulator, for use in mortality code - if (use_cndv) then - this%tempsum_litfall_patch(p) = & - this%tempsum_litfall_patch(p) + & - this%leafc_to_litter_patch(p) + & - this%frootc_to_litter_patch(p) - end if - - ! patch-level fire losses (VEGFIRE) - this%vegfire_patch(p) = 0._r8 - - ! patch-level wood harvest - this%wood_harvestc_patch(p) = & - this%hrv_deadstemc_to_prod10c_patch(p) + & - this%hrv_deadstemc_to_prod100c_patch(p) - if ( crop_prog .and. pft%itype(p) >= npcropmin )then - this%wood_harvestc_patch(p) = & - this%wood_harvestc_patch(p) + & - this%hrv_cropc_to_prod1c_patch(p) - end if - - ! patch-level carbon losses to fire changed by F. Li and S. Levis - this%fire_closs_patch(p) = & - this%m_leafc_to_fire_patch(p) + & - this%m_leafc_storage_to_fire_patch(p) + & - this%m_leafc_xfer_to_fire_patch(p) + & - this%m_frootc_to_fire_patch(p) + & - this%m_frootc_storage_to_fire_patch(p) + & - this%m_frootc_xfer_to_fire_patch(p) + & - this%m_livestemc_to_fire_patch(p) + & - this%m_livestemc_storage_to_fire_patch(p) + & - this%m_livestemc_xfer_to_fire_patch(p) + & - this%m_deadstemc_to_fire_patch(p) + & - this%m_deadstemc_storage_to_fire_patch(p) + & - this%m_deadstemc_xfer_to_fire_patch(p) + & - this%m_livecrootc_to_fire_patch(p) + & - this%m_livecrootc_storage_to_fire_patch(p) + & - this%m_livecrootc_xfer_to_fire_patch(p) + & - this%m_deadcrootc_to_fire_patch(p) + & - this%m_deadcrootc_storage_to_fire_patch(p) + & - this%m_deadcrootc_xfer_to_fire_patch(p) + & - this%m_gresp_storage_to_fire_patch(p) + & - this%m_gresp_xfer_to_fire_patch(p) - - if ( crop_prog .and. pft%itype(p) >= npcropmin )then - - this%litfall_patch(p) = & - this%litfall_patch(p) + & - this%livestemc_to_litter_patch(p) + & - this%grainc_to_food_patch(p) - end if - - ! new summary variables for CLAMP - - ! (FROOTC_ALLOC) - fine root C allocation - this%frootc_alloc_patch(p) = & - this%frootc_xfer_to_frootc_patch(p) + & - this%cpool_to_frootc_patch(p) - - ! (FROOTC_LOSS) - fine root C loss changed by F. Li and S. Levis - this%frootc_loss_patch(p) = & - this%m_frootc_to_litter_patch(p) + & - this%m_frootc_to_fire_patch(p) + & - this%m_frootc_to_litter_fire_patch(p) + & - this%hrv_frootc_to_litter_patch(p) + & - this%frootc_to_litter_patch(p) - - ! (LEAFC_ALLOC) - leaf C allocation - this%leafc_alloc_patch(p) = & - this%leafc_xfer_to_leafc_patch(p) + & - this%cpool_to_leafc_patch(p) - - ! (LEAFC_LOSS) - leaf C loss changed by F. Li and S. Levis - this%leafc_loss_patch(p) = & - this%m_leafc_to_litter_patch(p) + & - this%m_leafc_to_fire_patch(p) + & - this%m_leafc_to_litter_fire_patch(p) + & - this%hrv_leafc_to_litter_patch(p) + & - this%leafc_to_litter_patch(p) - - if ( crop_prog .and. pft%itype(p) >= npcropmin )then - this%leafc_loss_patch(p) = & - this%leafc_loss_patch(p) + & - this%hrv_leafc_to_prod1c_patch(p) - end if - - - ! (WOODC_ALLOC) - wood C allocation - this%woodc_alloc_patch(p) = & - this%livestemc_xfer_to_livestemc_patch(p) + & - this%deadstemc_xfer_to_deadstemc_patch(p) + & - this%livecrootc_xfer_to_livecrootc_patch(p) + & - this%deadcrootc_xfer_to_deadcrootc_patch(p) + & - this%cpool_to_livestemc_patch(p) + & - this%cpool_to_deadstemc_patch(p) + & - this%cpool_to_livecrootc_patch(p) + & - this%cpool_to_deadcrootc_patch(p) - - ! (WOODC_LOSS) - wood C loss - this%woodc_loss_patch(p) = & - this%m_livestemc_to_litter_patch(p) + & - this%m_deadstemc_to_litter_patch(p) + & - this%m_livecrootc_to_litter_patch(p) + & - this%m_deadcrootc_to_litter_patch(p) + & - this%m_livestemc_to_fire_patch(p) + & - this%m_deadstemc_to_fire_patch(p) + & - this%m_livecrootc_to_fire_patch(p) + & - this%m_deadcrootc_to_fire_patch(p) + & - this%hrv_livestemc_to_litter_patch(p) + & - this%hrv_livestemc_storage_to_litter_patch(p) + & - this%hrv_livestemc_xfer_to_litter_patch(p) + & - this%hrv_deadstemc_to_prod10c_patch(p) + & - this%hrv_deadstemc_to_prod100c_patch(p) + & - this%hrv_deadstemc_storage_to_litter_patch(p) + & - this%hrv_deadstemc_xfer_to_litter_patch(p) + & - this%hrv_livecrootc_to_litter_patch(p) + & - this%hrv_livecrootc_storage_to_litter_patch(p) + & - this%hrv_livecrootc_xfer_to_litter_patch(p) + & - this%hrv_deadcrootc_to_litter_patch(p) + & - this%hrv_deadcrootc_storage_to_litter_patch(p) + & - this%hrv_deadcrootc_xfer_to_litter_patch(p) - ! putting the harvested crop stem and grain in the wood loss bdrewniak - if ( crop_prog .and. pft%itype(p) >= npcropmin )then - this%woodc_loss_patch(p) = & - this%woodc_loss_patch(p) + & - this%hrv_grainc_to_prod1c_patch(p) + & - this%hrv_livestemc_to_prod1c_patch(p) - end if - - end do ! end of patches loop - - ! use p2c routine to get selected column-average patch-level fluxes and states - - call p2c(bounds, num_soilc, filter_soilc, & - this%gpp_patch(bounds%begp:bounds%endp), & - this%gpp_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%ar_patch(bounds%begp:bounds%endp), & - this%ar_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%npp_patch(bounds%begp:bounds%endp), & - this%npp_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%vegfire_patch(bounds%begp:bounds%endp), & - this%vegfire_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%wood_harvestc_patch(bounds%begp:bounds%endp), & - this%wood_harvestc_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%fire_closs_patch(bounds%begp:bounds%endp), & - this%fire_closs_p2c_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%litfall_patch(bounds%begp:bounds%endp), & - this%litfall_col(bounds%begc:bounds%endc)) - - call p2c(bounds, num_soilc, filter_soilc, & - this%hrv_xsmrpool_to_atm_patch(bounds%begp:bounds%endp), & - this%hrv_xsmrpool_to_atm_col(bounds%begc:bounds%endc)) - - if ( trim(isotope) == 'bulk') then - if (nfix_timeconst > 0._r8 .and. nfix_timeconst < 500._r8 ) then - - ! this code is to calculate an exponentially-relaxed npp value for use in NDynamics code - dtime = get_step_size() - nfixlags = nfix_timeconst * secspday - - do fc = 1,num_soilc - c = filter_soilc(fc) - if ( this%lag_npp_col(c) /= spval ) then - this%lag_npp_col(c) = & - this%lag_npp_col(c) * exp(-dtime/nfixlags) + & - this%npp_col(c) * (1._r8 - exp(-dtime/nfixlags)) - else - ! first timestep - this%lag_npp_col(c) = this%npp_col(c) - endif - end do - endif - endif - end if ! if(.not.use_ed)then + do fp = 1,num_soilp + p = filter_soilp(fp) + + ! calculate pft-level summary carbon fluxes and states + + ! gross primary production (GPP) + this%gpp_patch(p) = & + this%psnsun_to_cpool_patch(p) + & + this%psnshade_to_cpool_patch(p) + + ! maintenance respiration (MR) + if ( trim(isotope) == 'c13' .or. trim(isotope) == 'c14') then + this%leaf_mr_patch(p) = this%leaf_curmr_patch(p) + this%leaf_xsmr_patch(p) + this%froot_mr_patch(p) = this%froot_curmr_patch(p) + this%froot_xsmr_patch(p) + this%livestem_mr_patch(p) = this%livestem_curmr_patch(p) + this%livestem_xsmr_patch(p) + this%livecroot_mr_patch(p) = this%livecroot_curmr_patch(p) + this%livecroot_xsmr_patch(p) + endif + + this%mr_patch(p) = & + this%leaf_mr_patch(p) + & + this%froot_mr_patch(p) + & + this%livestem_mr_patch(p) + & + this%livecroot_mr_patch(p) + + ! growth respiration (GR) + ! current GR is respired this time step for new growth displayed in this timestep + this%current_gr_patch(p) = & + this%cpool_leaf_gr_patch(p) + & + this%cpool_froot_gr_patch(p) + & + this%cpool_livestem_gr_patch(p) + & + this%cpool_deadstem_gr_patch(p) + & + this%cpool_livecroot_gr_patch(p) + & + this%cpool_deadcroot_gr_patch(p) + + ! transfer GR is respired this time step for transfer growth displayed in this timestep + this%transfer_gr_patch(p) = & + this%transfer_leaf_gr_patch(p) + & + this%transfer_froot_gr_patch(p) + & + this%transfer_livestem_gr_patch(p) + & + this%transfer_deadstem_gr_patch(p) + & + this%transfer_livecroot_gr_patch(p) + & + this%transfer_deadcroot_gr_patch(p) + + ! storage GR is respired this time step for growth sent to storage for later display + this%storage_gr_patch(p) = & + this%cpool_leaf_storage_gr_patch(p) + & + this%cpool_froot_storage_gr_patch(p) + & + this%cpool_livestem_storage_gr_patch(p) + & + this%cpool_deadstem_storage_gr_patch(p) + & + this%cpool_livecroot_storage_gr_patch(p) + & + this%cpool_deadcroot_storage_gr_patch(p) + + if ( crop_prog .and. pft%itype(p) >= npcropmin )then + this%mr_patch(p) = & + this%mr_patch(p) + & + this%grain_mr_patch(p) + + this%current_gr_patch(p) = & + this%current_gr_patch(p) + & + this%cpool_grain_gr_patch(p) + + this%transfer_gr_patch(p) = & + this%transfer_gr_patch(p) + & + this%transfer_grain_gr_patch(p) + + this%storage_gr_patch(p) = & + this%storage_gr_patch(p) + & + this%cpool_grain_storage_gr_patch(p) + end if + + ! GR is the sum of current + transfer + storage GR + this%gr_patch(p) = & + this%current_gr_patch(p) + & + this%transfer_gr_patch(p) + & + this%storage_gr_patch(p) + + ! autotrophic respiration (AR) + if ( crop_prog .and. pft%itype(p) >= npcropmin )then + this%ar_patch(p) = & + this%mr_patch(p) + & + this%gr_patch(p) + & + this%xsmrpool_to_atm_patch(p) ! xsmr... is -ve (slevis) + if (nu_com .ne. 'RD' ) then + this%ar_patch(p) = this%ar_patch(p) + & + this%xsmrpool_turnover_patch(p) + end if + else + this%ar_patch(p) = & + this%mr_patch(p) + & + this%gr_patch(p) + if (nu_com .ne. 'RD' ) then + this%ar_patch(p) = this%ar_patch(p) + & + this%xsmrpool_turnover_patch(p) + end if + end if + + + + ! net primary production (NPP) + this%npp_patch(p) = & + this%gpp_patch(p) - & + this%ar_patch(p) + + ! update the annual NPP accumulator, for use in allocation code + if (trim(isotope) == 'bulk') then + this%tempsum_npp_patch(p) = & + this%tempsum_npp_patch(p) + & + this%npp_patch(p) + end if + + ! litterfall (LITFALL) + + this%litfall_patch(p) = & + this%leafc_to_litter_patch(p) + & + this%frootc_to_litter_patch(p) + & + this%m_leafc_to_litter_patch(p) + & + this%m_leafc_storage_to_litter_patch(p) + & + this%m_leafc_xfer_to_litter_patch(p) + & + this%m_frootc_to_litter_patch(p) + & + this%m_frootc_storage_to_litter_patch(p) + & + this%m_frootc_xfer_to_litter_patch(p) + & + this%m_livestemc_to_litter_patch(p) + & + this%m_livestemc_storage_to_litter_patch(p) + & + this%m_livestemc_xfer_to_litter_patch(p) + & + this%m_deadstemc_to_litter_patch(p) + & + this%m_deadstemc_storage_to_litter_patch(p) + & + this%m_deadstemc_xfer_to_litter_patch(p) + & + this%m_livecrootc_to_litter_patch(p) + & + this%m_livecrootc_storage_to_litter_patch(p) + & + this%m_livecrootc_xfer_to_litter_patch(p) + & + this%m_deadcrootc_to_litter_patch(p) + & + this%m_deadcrootc_storage_to_litter_patch(p) + & + this%m_deadcrootc_xfer_to_litter_patch(p) + & + this%m_gresp_storage_to_litter_patch(p) + & + this%m_gresp_xfer_to_litter_patch(p) + & + + this%m_leafc_to_litter_fire_patch(p) + & + this%m_leafc_storage_to_litter_fire_patch(p) + & + this%m_leafc_xfer_to_litter_fire_patch(p) + & + this%m_livestemc_to_litter_fire_patch(p) + & + this%m_livestemc_storage_to_litter_fire_patch(p) + & + this%m_livestemc_xfer_to_litter_fire_patch(p) + & + this%m_deadstemc_to_litter_fire_patch(p) + & + this%m_deadstemc_storage_to_litter_fire_patch(p) + & + this%m_deadstemc_xfer_to_litter_fire_patch(p) + & + this%m_frootc_to_litter_fire_patch(p) + & + this%m_frootc_storage_to_litter_fire_patch(p) + & + this%m_frootc_xfer_to_litter_fire_patch(p) + & + this%m_livecrootc_to_litter_fire_patch(p) + & + this%m_livecrootc_storage_to_litter_fire_patch(p) + & + this%m_livecrootc_xfer_to_litter_fire_patch(p) + & + this%m_deadcrootc_to_litter_fire_patch(p) + & + this%m_deadcrootc_storage_to_litter_fire_patch(p) + & + this%m_deadcrootc_xfer_to_litter_fire_patch(p) + & + this%m_gresp_storage_to_litter_fire_patch(p) + & + this%m_gresp_xfer_to_litter_fire_patch(p) + & + + this%hrv_leafc_to_litter_patch(p) + & + this%hrv_leafc_storage_to_litter_patch(p) + & + this%hrv_leafc_xfer_to_litter_patch(p) + & + this%hrv_frootc_to_litter_patch(p) + & + this%hrv_frootc_storage_to_litter_patch(p) + & + this%hrv_frootc_xfer_to_litter_patch(p) + & + this%hrv_livestemc_to_litter_patch(p) + & + this%hrv_livestemc_storage_to_litter_patch(p) + & + this%hrv_livestemc_xfer_to_litter_patch(p) + & + this%hrv_deadstemc_storage_to_litter_patch(p) + & + this%hrv_deadstemc_xfer_to_litter_patch(p) + & + this%hrv_livecrootc_to_litter_patch(p) + & + this%hrv_livecrootc_storage_to_litter_patch(p) + & + this%hrv_livecrootc_xfer_to_litter_patch(p) + & + this%hrv_deadcrootc_to_litter_patch(p) + & + this%hrv_deadcrootc_storage_to_litter_patch(p) + & + this%hrv_deadcrootc_xfer_to_litter_patch(p) + & + this%hrv_gresp_storage_to_litter_patch(p) + & + this%hrv_gresp_xfer_to_litter_patch(p) + + ! update the annual litfall accumulator, for use in mortality code + if (use_cndv) then + this%tempsum_litfall_patch(p) = & + this%tempsum_litfall_patch(p) + & + this%leafc_to_litter_patch(p) + & + this%frootc_to_litter_patch(p) + end if + + ! patch-level fire losses (VEGFIRE) + this%vegfire_patch(p) = 0._r8 + + ! patch-level wood harvest + this%wood_harvestc_patch(p) = & + this%hrv_deadstemc_to_prod10c_patch(p) + & + this%hrv_deadstemc_to_prod100c_patch(p) + if ( crop_prog .and. pft%itype(p) >= npcropmin )then + this%wood_harvestc_patch(p) = & + this%wood_harvestc_patch(p) + & + this%hrv_cropc_to_prod1c_patch(p) + end if + + ! patch-level carbon losses to fire changed by F. Li and S. Levis + this%fire_closs_patch(p) = & + this%m_leafc_to_fire_patch(p) + & + this%m_leafc_storage_to_fire_patch(p) + & + this%m_leafc_xfer_to_fire_patch(p) + & + this%m_frootc_to_fire_patch(p) + & + this%m_frootc_storage_to_fire_patch(p) + & + this%m_frootc_xfer_to_fire_patch(p) + & + this%m_livestemc_to_fire_patch(p) + & + this%m_livestemc_storage_to_fire_patch(p) + & + this%m_livestemc_xfer_to_fire_patch(p) + & + this%m_deadstemc_to_fire_patch(p) + & + this%m_deadstemc_storage_to_fire_patch(p) + & + this%m_deadstemc_xfer_to_fire_patch(p) + & + this%m_livecrootc_to_fire_patch(p) + & + this%m_livecrootc_storage_to_fire_patch(p) + & + this%m_livecrootc_xfer_to_fire_patch(p) + & + this%m_deadcrootc_to_fire_patch(p) + & + this%m_deadcrootc_storage_to_fire_patch(p) + & + this%m_deadcrootc_xfer_to_fire_patch(p) + & + this%m_gresp_storage_to_fire_patch(p) + & + this%m_gresp_xfer_to_fire_patch(p) + + if ( crop_prog .and. pft%itype(p) >= npcropmin )then + + this%litfall_patch(p) = & + this%litfall_patch(p) + & + this%livestemc_to_litter_patch(p) + & + this%grainc_to_food_patch(p) + end if + + ! new summary variables for CLAMP + + ! (FROOTC_ALLOC) - fine root C allocation + this%frootc_alloc_patch(p) = & + this%frootc_xfer_to_frootc_patch(p) + & + this%cpool_to_frootc_patch(p) + + ! (FROOTC_LOSS) - fine root C loss changed by F. Li and S. Levis + this%frootc_loss_patch(p) = & + this%m_frootc_to_litter_patch(p) + & + this%m_frootc_to_fire_patch(p) + & + this%m_frootc_to_litter_fire_patch(p) + & + this%hrv_frootc_to_litter_patch(p) + & + this%frootc_to_litter_patch(p) + + ! (LEAFC_ALLOC) - leaf C allocation + this%leafc_alloc_patch(p) = & + this%leafc_xfer_to_leafc_patch(p) + & + this%cpool_to_leafc_patch(p) + + ! (LEAFC_LOSS) - leaf C loss changed by F. Li and S. Levis + this%leafc_loss_patch(p) = & + this%m_leafc_to_litter_patch(p) + & + this%m_leafc_to_fire_patch(p) + & + this%m_leafc_to_litter_fire_patch(p) + & + this%hrv_leafc_to_litter_patch(p) + & + this%leafc_to_litter_patch(p) + + if ( crop_prog .and. pft%itype(p) >= npcropmin )then + this%leafc_loss_patch(p) = & + this%leafc_loss_patch(p) + & + this%hrv_leafc_to_prod1c_patch(p) + end if + + + ! (WOODC_ALLOC) - wood C allocation + this%woodc_alloc_patch(p) = & + this%livestemc_xfer_to_livestemc_patch(p) + & + this%deadstemc_xfer_to_deadstemc_patch(p) + & + this%livecrootc_xfer_to_livecrootc_patch(p) + & + this%deadcrootc_xfer_to_deadcrootc_patch(p) + & + this%cpool_to_livestemc_patch(p) + & + this%cpool_to_deadstemc_patch(p) + & + this%cpool_to_livecrootc_patch(p) + & + this%cpool_to_deadcrootc_patch(p) + + ! (WOODC_LOSS) - wood C loss + this%woodc_loss_patch(p) = & + this%m_livestemc_to_litter_patch(p) + & + this%m_deadstemc_to_litter_patch(p) + & + this%m_livecrootc_to_litter_patch(p) + & + this%m_deadcrootc_to_litter_patch(p) + & + this%m_livestemc_to_fire_patch(p) + & + this%m_deadstemc_to_fire_patch(p) + & + this%m_livecrootc_to_fire_patch(p) + & + this%m_deadcrootc_to_fire_patch(p) + & + this%hrv_livestemc_to_litter_patch(p) + & + this%hrv_livestemc_storage_to_litter_patch(p) + & + this%hrv_livestemc_xfer_to_litter_patch(p) + & + this%hrv_deadstemc_to_prod10c_patch(p) + & + this%hrv_deadstemc_to_prod100c_patch(p) + & + this%hrv_deadstemc_storage_to_litter_patch(p) + & + this%hrv_deadstemc_xfer_to_litter_patch(p) + & + this%hrv_livecrootc_to_litter_patch(p) + & + this%hrv_livecrootc_storage_to_litter_patch(p) + & + this%hrv_livecrootc_xfer_to_litter_patch(p) + & + this%hrv_deadcrootc_to_litter_patch(p) + & + this%hrv_deadcrootc_storage_to_litter_patch(p) + & + this%hrv_deadcrootc_xfer_to_litter_patch(p) + ! putting the harvested crop stem and grain in the wood loss bdrewniak + if ( crop_prog .and. pft%itype(p) >= npcropmin )then + this%woodc_loss_patch(p) = & + this%woodc_loss_patch(p) + & + this%hrv_grainc_to_prod1c_patch(p) + & + this%hrv_livestemc_to_prod1c_patch(p) + end if + + end do ! end of patches loop + + ! use p2c routine to get selected column-average patch-level fluxes and states + + call p2c(bounds, num_soilc, filter_soilc, & + this%gpp_patch(bounds%begp:bounds%endp), & + this%gpp_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%ar_patch(bounds%begp:bounds%endp), & + this%ar_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%npp_patch(bounds%begp:bounds%endp), & + this%npp_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%vegfire_patch(bounds%begp:bounds%endp), & + this%vegfire_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%wood_harvestc_patch(bounds%begp:bounds%endp), & + this%wood_harvestc_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%fire_closs_patch(bounds%begp:bounds%endp), & + this%fire_closs_p2c_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%litfall_patch(bounds%begp:bounds%endp), & + this%litfall_col(bounds%begc:bounds%endc)) + + call p2c(bounds, num_soilc, filter_soilc, & + this%hrv_xsmrpool_to_atm_patch(bounds%begp:bounds%endp), & + this%hrv_xsmrpool_to_atm_col(bounds%begc:bounds%endc)) + + if ( trim(isotope) == 'bulk') then + if (nfix_timeconst > 0._r8 .and. nfix_timeconst < 500._r8 ) then + + ! this code is to calculate an exponentially-relaxed npp value for use in NDynamics code + dtime = get_step_size() + nfixlags = nfix_timeconst * secspday + + do fc = 1,num_soilc + c = filter_soilc(fc) + if ( this%lag_npp_col(c) /= spval ) then + this%lag_npp_col(c) = & + this%lag_npp_col(c) * exp(-dtime/nfixlags) + & + this%npp_col(c) * (1._r8 - exp(-dtime/nfixlags)) + else + ! first timestep + this%lag_npp_col(c) = this%npp_col(c) + endif + end do + endif + endif ! column soil variables @@ -4728,47 +4776,47 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil if ( (.not. is_active_betr_bgc ) .and. & (.not. (use_pflotran .and. pf_cmode))) then - ! vertically integrate HR and decomposition cascade fluxes - do k = 1, ndecomp_cascade_transitions + ! vertically integrate HR and decomposition cascade fluxes + do k = 1, ndecomp_cascade_transitions - do j = 1,nlevdecomp - do fc = 1,num_soilc - c = filter_soilc(fc) + do j = 1,nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) - this%decomp_cascade_ctransfer_col(c,k) = & - this%decomp_cascade_ctransfer_col(c,k) + & - this%decomp_cascade_ctransfer_vr_col(c,j,k) * dzsoi_decomp(j) + this%decomp_cascade_ctransfer_col(c,k) = & + this%decomp_cascade_ctransfer_col(c,k) + & + this%decomp_cascade_ctransfer_vr_col(c,j,k) * dzsoi_decomp(j) + end do end do end do - end do - ! total heterotrophic respiration (HR) - do fc = 1,num_soilc - c = filter_soilc(fc) - this%hr_col(c) = & - this%lithr_col(c) + & - this%somhr_col(c) - end do + ! total heterotrophic respiration (HR) + do fc = 1,num_soilc + c = filter_soilc(fc) + this%hr_col(c) = & + this%lithr_col(c) + & + this%somhr_col(c) + end do elseif (is_active_betr_bgc) then do fc = 1, num_soilc - c = filter_soilc(fc) - this%hr_col(c) = dot_sum(this%hr_vr_col(c,1:nlevdecomp),dzsoi_decomp(1:nlevdecomp)) - enddo + c = filter_soilc(fc) + this%hr_col(c) = dot_sum(this%hr_vr_col(c,1:nlevdecomp),dzsoi_decomp(1:nlevdecomp)) + enddo endif - + ! bgc interface & pflotran: !---------------------------------------------------------------- if (use_bgc_interface) then - call CSummary_interface(this, bounds, num_soilc, filter_soilc) + call CSummary_interface(this, bounds, num_soilc, filter_soilc) end if !! CSummary_interface: hr_col(c) will be used below !---------------------------------------------------------------- - + do fc = 1,num_soilc c = filter_soilc(fc) ! total soil respiration, heterotrophic + root respiration (SR) @@ -4843,7 +4891,7 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil ! net ecosystem exchange of carbon, includes fire flux, landcover change flux, loss ! from wood products pools, and hrv_xsmrpool flux, positive for source (NEE) this%nee_col(c) = & - -this%nep_col(c) + & + -this%nep_col(c) + & this%fire_closs_col(c) + & this%dwt_closs_col(c) + & this%product_closs_col(c) + & @@ -4859,124 +4907,120 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil this%landuseflux_col(c) end do - ! (FATES-INTERF) to-do: identify which variables are left when fates bgc light is running - ! and only summarize on those. Several of the variables below this statement are relevant - ! but many are not. Also: find out where these summary products are used and evaluate the meaning - ! of not setting /or setting here (rgk 04-2017) - ! for vertically-resolved soil biogeochemistry, calculate some diagnostics of carbon pools to a given depth if ( (.not. is_active_betr_bgc) .and. & (.not.(use_pflotran .and. pf_cmode)) ) then - ! _col(cWDC_HR) - coarse woody debris heterotrophic respiration - do fc = 1,num_soilc - c = filter_soilc(fc) - this%cwdc_hr_col(c) = 0._r8 - end do + ! _col(cWDC_HR) - coarse woody debris heterotrophic respiration + do fc = 1,num_soilc + c = filter_soilc(fc) + this%cwdc_hr_col(c) = 0._r8 + end do - ! _col(cWDC_LOSS) - coarse woody debris C loss - do l = 1, ndecomp_pools - if ( is_cwd(l) ) then - do fc = 1,num_soilc - c = filter_soilc(fc) - this%cwdc_loss_col(c) = & - this%cwdc_loss_col(c) + & - this%m_decomp_cpools_to_fire_col(c,l) - end do - end if - end do + ! _col(cWDC_LOSS) - coarse woody debris C loss + do l = 1, ndecomp_pools + if ( is_cwd(l) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + this%cwdc_loss_col(c) = & + this%cwdc_loss_col(c) + & + this%m_decomp_cpools_to_fire_col(c,l) + end do + end if + end do - do k = 1, ndecomp_cascade_transitions - if ( is_cwd(decomp_cascade_con%cascade_donor_pool(k)) ) then - do fc = 1,num_soilc - c = filter_soilc(fc) - this%cwdc_loss_col(c) = & - this%cwdc_loss_col(c) + & - this%decomp_cascade_ctransfer_col(c,k) - end do - end if - end do + do k = 1, ndecomp_cascade_transitions + if ( is_cwd(decomp_cascade_con%cascade_donor_pool(k)) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + this%cwdc_loss_col(c) = & + this%cwdc_loss_col(c) + & + this%decomp_cascade_ctransfer_col(c,k) + end do + end if + end do - ! (LITTERC_LOSS) - litter C loss - do fc = 1,num_soilc - c = filter_soilc(fc) - this%litterc_loss_col(c) = this%lithr_col(c) - end do - do l = 1, ndecomp_pools - if ( is_litter(l) ) then + ! (LITTERC_LOSS) - litter C loss + do fc = 1,num_soilc + c = filter_soilc(fc) + this%litterc_loss_col(c) = this%lithr_col(c) + end do + do l = 1, ndecomp_pools + if ( is_litter(l) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + this%litterc_loss_col(c) = & + this%litterc_loss_col(c) + & + this%m_decomp_cpools_to_fire_col(c,l) + end do + end if + end do + + + do k = 1, ndecomp_cascade_transitions + if ( is_litter(decomp_cascade_con%cascade_donor_pool(k)) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + this%litterc_loss_col(c) = & + this%litterc_loss_col(c) + & + this%decomp_cascade_ctransfer_col(c,k) + end do + end if + end do + + else if ((use_pflotran .and. pf_cmode)) then + + ! add up all vertical transport tendency terms and calculate total som leaching loss as the sum of these + do l = 1, ndecomp_pools do fc = 1,num_soilc c = filter_soilc(fc) - this%litterc_loss_col(c) = & - this%litterc_loss_col(c) + & - this%m_decomp_cpools_to_fire_col(c,l) + this%decomp_cpools_leached_col(c,l) = 0._r8 end do - end if - end do - - - do k = 1, ndecomp_cascade_transitions - if ( is_litter(decomp_cascade_con%cascade_donor_pool(k)) ) then - do fc = 1,num_soilc - c = filter_soilc(fc) - this%litterc_loss_col(c) = & - this%litterc_loss_col(c) + & - this%decomp_cascade_ctransfer_col(c,k) + do j = 1, nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + this%decomp_cpools_leached_col(c,l) = & + this%decomp_cpools_leached_col(c,l) + & + this%decomp_cpools_transport_tendency_col(c,j,l) * dzsoi_decomp(j) + end do end do - end if - end do - - else if ((use_pflotran .and. pf_cmode)) then - - ! add up all vertical transport tendency terms and calculate total som leaching loss as the sum of these - do l = 1, ndecomp_pools - do fc = 1,num_soilc - c = filter_soilc(fc) - this%decomp_cpools_leached_col(c,l) = 0._r8 - end do - do j = 1, nlevdecomp do fc = 1,num_soilc c = filter_soilc(fc) - this%decomp_cpools_leached_col(c,l) = & - this%decomp_cpools_leached_col(c,l) + & - this%decomp_cpools_transport_tendency_col(c,j,l) * dzsoi_decomp(j) + this%som_c_leached_col(c) = & + this%som_c_leached_col(c) + & + this%decomp_cpools_leached_col(c,l) end do end do - do fc = 1,num_soilc - c = filter_soilc(fc) - this%som_c_leached_col(c) = & - this%som_c_leached_col(c) + & - this%decomp_cpools_leached_col(c,l) - end do - end do - endif - + endif + ! debug do fc = 1,num_soilc - c = filter_soilc(fc) - this%plant_to_litter_cflux(c) = 0._r8 - this%plant_to_cwd_cflux(c) = 0._r8 - do j = 1, nlevdecomp - this%plant_to_litter_cflux(c) = & - this%plant_to_litter_cflux(c) + & - this%phenology_c_to_litr_met_c_col(c,j)* dzsoi_decomp(j) + & - this%phenology_c_to_litr_cel_c_col(c,j)* dzsoi_decomp(j) + & - this%phenology_c_to_litr_lig_c_col(c,j)* dzsoi_decomp(j) + & - this%gap_mortality_c_to_litr_met_c_col(c,j)* dzsoi_decomp(j) + & - this%gap_mortality_c_to_litr_cel_c_col(c,j)* dzsoi_decomp(j) + & - this%gap_mortality_c_to_litr_lig_c_col(c,j)* dzsoi_decomp(j) + & - this%m_c_to_litr_met_fire_col(c,j)* dzsoi_decomp(j) + & - this%m_c_to_litr_cel_fire_col(c,j)* dzsoi_decomp(j) + & - this%m_c_to_litr_lig_fire_col(c,j)* dzsoi_decomp(j) - this%plant_to_cwd_cflux(c) = & - this%plant_to_cwd_cflux(c) + & - this%gap_mortality_c_to_cwdc_col(c,j)* dzsoi_decomp(j) + & - this%fire_mortality_c_to_cwdc_col(c,j)* dzsoi_decomp(j) - end do + c = filter_soilc(fc) + this%plant_to_litter_cflux(c) = 0._r8 + this%plant_to_cwd_cflux(c) = 0._r8 + do j = 1, nlevdecomp + this%plant_to_litter_cflux(c) = & + this%plant_to_litter_cflux(c) + & + this%phenology_c_to_litr_met_c_col(c,j)* dzsoi_decomp(j) + & + this%phenology_c_to_litr_cel_c_col(c,j)* dzsoi_decomp(j) + & + this%phenology_c_to_litr_lig_c_col(c,j)* dzsoi_decomp(j) + & + this%gap_mortality_c_to_litr_met_c_col(c,j)* dzsoi_decomp(j) + & + this%gap_mortality_c_to_litr_cel_c_col(c,j)* dzsoi_decomp(j) + & + this%gap_mortality_c_to_litr_lig_c_col(c,j)* dzsoi_decomp(j) + & + this%m_c_to_litr_met_fire_col(c,j)* dzsoi_decomp(j) + & + this%m_c_to_litr_cel_fire_col(c,j)* dzsoi_decomp(j) + & + this%m_c_to_litr_lig_fire_col(c,j)* dzsoi_decomp(j) + this%plant_to_cwd_cflux(c) = & + this%plant_to_cwd_cflux(c) + & + this%gap_mortality_c_to_cwdc_col(c,j)* dzsoi_decomp(j) + & + this%fire_mortality_c_to_cwdc_col(c,j)* dzsoi_decomp(j) + end do end do - + + end associate - end subroutine Summary +end subroutine Summary !!------------------------------------------------------------------------------------------------- ! !INTERFACE: diff --git a/components/clm/src/biogeochem/CNCarbonStateType.F90 b/components/clm/src/biogeochem/CNCarbonStateType.F90 index afff8d889227..52104745fef9 100644 --- a/components/clm/src/biogeochem/CNCarbonStateType.F90 +++ b/components/clm/src/biogeochem/CNCarbonStateType.F90 @@ -19,7 +19,7 @@ module CNCarbonStateType use LandunitType , only : lun use ColumnType , only : col use PatchType , only : pft - use clm_varctl , only : nu_com + use clm_varctl , only : nu_com, use_ed ! ! !PUBLIC TYPES: @@ -87,8 +87,6 @@ module CNCarbonStateType real(r8), pointer :: decomp_cpools_1m_col (:,:) ! col (gC/m2) Diagnostic: decomposing (litter, cwd, soil) c pools to 1 meter real(r8), pointer :: decomp_cpools_col (:,:) ! col (gC/m2) decomposing (litter, cwd, soil) c pools - ! (FATES-INTERF) cwdc_col is prevented from allocation in fates-clm - ! waiting for discussion with cdk to determin its ... fate ... here real(r8), pointer :: cwdc_col (:) ! col (gC/m2) Diagnostic: coarse woody debris C real(r8), pointer :: ctrunc_col (:) ! col (gC/m2) column-level sink for C truncation real(r8), pointer :: totlitc_col (:) ! col (gC/m2) total litter carbon @@ -167,39 +165,40 @@ subroutine InitAllocate(this, bounds) begp = bounds%begp; endp = bounds%endp begc = bounds%begc; endc = bounds%endc - allocate(this%leafc_patch (begp :endp)) ; this%leafc_patch (:) = nan - allocate(this%leafc_storage_patch (begp :endp)) ; this%leafc_storage_patch (:) = nan - allocate(this%leafc_xfer_patch (begp :endp)) ; this%leafc_xfer_patch (:) = nan - allocate(this%frootc_patch (begp :endp)) ; this%frootc_patch (:) = nan - allocate(this%frootc_storage_patch (begp :endp)) ; this%frootc_storage_patch (:) = nan - allocate(this%frootc_xfer_patch (begp :endp)) ; this%frootc_xfer_patch (:) = nan - allocate(this%livestemc_patch (begp :endp)) ; this%livestemc_patch (:) = nan - allocate(this%livestemc_storage_patch (begp :endp)) ; this%livestemc_storage_patch (:) = nan - allocate(this%livestemc_xfer_patch (begp :endp)) ; this%livestemc_xfer_patch (:) = nan - allocate(this%deadstemc_patch (begp :endp)) ; this%deadstemc_patch (:) = nan - allocate(this%deadstemc_storage_patch (begp :endp)) ; this%deadstemc_storage_patch (:) = nan - allocate(this%deadstemc_xfer_patch (begp :endp)) ; this%deadstemc_xfer_patch (:) = nan - allocate(this%livecrootc_patch (begp :endp)) ; this%livecrootc_patch (:) = nan - allocate(this%livecrootc_storage_patch (begp :endp)) ; this%livecrootc_storage_patch (:) = nan - allocate(this%livecrootc_xfer_patch (begp :endp)) ; this%livecrootc_xfer_patch (:) = nan - allocate(this%deadcrootc_patch (begp :endp)) ; this%deadcrootc_patch (:) = nan - allocate(this%deadcrootc_storage_patch (begp :endp)) ; this%deadcrootc_storage_patch (:) = nan - allocate(this%deadcrootc_xfer_patch (begp :endp)) ; this%deadcrootc_xfer_patch (:) = nan - allocate(this%gresp_storage_patch (begp :endp)) ; this%gresp_storage_patch (:) = nan - allocate(this%gresp_xfer_patch (begp :endp)) ; this%gresp_xfer_patch (:) = nan - allocate(this%cpool_patch (begp :endp)) ; this%cpool_patch (:) = nan - allocate(this%xsmrpool_patch (begp :endp)) ; this%xsmrpool_patch (:) = nan - allocate(this%ctrunc_patch (begp :endp)) ; this%ctrunc_patch (:) = nan - allocate(this%dispvegc_patch (begp :endp)) ; this%dispvegc_patch (:) = nan - allocate(this%storvegc_patch (begp :endp)) ; this%storvegc_patch (:) = nan - allocate(this%totvegc_patch (begp :endp)) ; this%totvegc_patch (:) = nan - allocate(this%totpftc_patch (begp :endp)) ; this%totpftc_patch (:) = nan - allocate(this%leafcmax_patch (begp :endp)) ; this%leafcmax_patch (:) = nan - allocate(this%grainc_patch (begp :endp)) ; this%grainc_patch (:) = nan - allocate(this%grainc_storage_patch (begp :endp)) ; this%grainc_storage_patch (:) = nan - allocate(this%grainc_xfer_patch (begp :endp)) ; this%grainc_xfer_patch (:) = nan - allocate(this%woodc_patch (begp :endp)) ; this%woodc_patch (:) = nan - + if ( .not. use_ed ) then + allocate(this%leafc_patch (begp :endp)) ; this%leafc_patch (:) = nan + allocate(this%leafc_storage_patch (begp :endp)) ; this%leafc_storage_patch (:) = nan + allocate(this%leafc_xfer_patch (begp :endp)) ; this%leafc_xfer_patch (:) = nan + allocate(this%frootc_patch (begp :endp)) ; this%frootc_patch (:) = nan + allocate(this%frootc_storage_patch (begp :endp)) ; this%frootc_storage_patch (:) = nan + allocate(this%frootc_xfer_patch (begp :endp)) ; this%frootc_xfer_patch (:) = nan + allocate(this%livestemc_patch (begp :endp)) ; this%livestemc_patch (:) = nan + allocate(this%livestemc_storage_patch (begp :endp)) ; this%livestemc_storage_patch (:) = nan + allocate(this%livestemc_xfer_patch (begp :endp)) ; this%livestemc_xfer_patch (:) = nan + allocate(this%deadstemc_patch (begp :endp)) ; this%deadstemc_patch (:) = nan + allocate(this%deadstemc_storage_patch (begp :endp)) ; this%deadstemc_storage_patch (:) = nan + allocate(this%deadstemc_xfer_patch (begp :endp)) ; this%deadstemc_xfer_patch (:) = nan + allocate(this%livecrootc_patch (begp :endp)) ; this%livecrootc_patch (:) = nan + allocate(this%livecrootc_storage_patch (begp :endp)) ; this%livecrootc_storage_patch (:) = nan + allocate(this%livecrootc_xfer_patch (begp :endp)) ; this%livecrootc_xfer_patch (:) = nan + allocate(this%deadcrootc_patch (begp :endp)) ; this%deadcrootc_patch (:) = nan + allocate(this%deadcrootc_storage_patch (begp :endp)) ; this%deadcrootc_storage_patch (:) = nan + allocate(this%deadcrootc_xfer_patch (begp :endp)) ; this%deadcrootc_xfer_patch (:) = nan + allocate(this%gresp_storage_patch (begp :endp)) ; this%gresp_storage_patch (:) = nan + allocate(this%gresp_xfer_patch (begp :endp)) ; this%gresp_xfer_patch (:) = nan + allocate(this%cpool_patch (begp :endp)) ; this%cpool_patch (:) = nan + allocate(this%xsmrpool_patch (begp :endp)) ; this%xsmrpool_patch (:) = nan + allocate(this%ctrunc_patch (begp :endp)) ; this%ctrunc_patch (:) = nan + allocate(this%dispvegc_patch (begp :endp)) ; this%dispvegc_patch (:) = nan + allocate(this%storvegc_patch (begp :endp)) ; this%storvegc_patch (:) = nan + allocate(this%totvegc_patch (begp :endp)) ; this%totvegc_patch (:) = nan + allocate(this%totpftc_patch (begp :endp)) ; this%totpftc_patch (:) = nan + allocate(this%leafcmax_patch (begp :endp)) ; this%leafcmax_patch (:) = nan + allocate(this%grainc_patch (begp :endp)) ; this%grainc_patch (:) = nan + allocate(this%grainc_storage_patch (begp :endp)) ; this%grainc_storage_patch (:) = nan + allocate(this%grainc_xfer_patch (begp :endp)) ; this%grainc_xfer_patch (:) = nan + allocate(this%woodc_patch (begp :endp)) ; this%woodc_patch (:) = nan + endif allocate(this%cwdc_col (begc :endc)) ; this%cwdc_col (:) = nan allocate(this%ctrunc_col (begc :endc)) ; this%ctrunc_col (:) = nan allocate(this%ctrunc_vr_col (begc :endc,1:nlevdecomp_full)) ; this%ctrunc_vr_col (:,:) = nan @@ -281,6 +280,39 @@ subroutine InitHistory(this, bounds, carbon_type) begc = bounds%begc; endc = bounds%endc begg = bounds%begg; endg = bounds%endg + ! Note (RGK 04-2017) - I am taking the ultra-conservative + ! approach to identifying which carbon state variables should + ! be output when FATES is turned on. Over time we should relax + ! this restriction and identify which output state variables + ! have all the required information. + + if ( use_ed ) then + if (carbon_type == 'c12') then + if ( nlevdecomp_full > 1 ) then + this%totlitc_1m_col(begc:endc) = spval + call hist_addfld1d (fname='TOTLITC_1m', units='gC/m^2', & + avgflag='A', long_name='total litter carbon to 1 meter depth', & + ptr_col=this%totlitc_1m_col) + + this%totsomc_1m_col(begc:endc) = spval + call hist_addfld1d (fname='TOTSOMC_1m', units='gC/m^2', & + avgflag='A', long_name='total soil organic matter carbon to 1 meter depth', & + ptr_col=this%totsomc_1m_col) + end if + + this%totlitc_col(begc:endc) = spval + call hist_addfld1d (fname='TOTLITC', units='gC/m^2', & + avgflag='A', long_name='total litter carbon', & + ptr_col=this%totlitc_col) + + this%totsomc_col(begc:endc) = spval + call hist_addfld1d (fname='TOTSOMC', units='gC/m^2', & + avgflag='A', long_name='total soil organic matter carbon', & + ptr_col=this%totsomc_col) + + end if + return + end if !------------------------------- ! C12 state variables !------------------------------- @@ -290,149 +322,149 @@ subroutine InitHistory(this, bounds, carbon_type) if (crop_prog) then this%grainc_patch(begp:endp) = spval call hist_addfld1d (fname='GRAINC', units='gC/m^2', & - avgflag='A', long_name='grain C', & - ptr_patch=this%grainc_patch, default='inactive') + avgflag='A', long_name='grain C', & + ptr_patch=this%grainc_patch, default='inactive') end if - + this%woodc_patch(begp:endp) = spval call hist_addfld1d (fname='WOODC', units='gC/m^2', & - avgflag='A', long_name='wood C', & - ptr_patch=this%woodc_patch) + avgflag='A', long_name='wood C', & + ptr_patch=this%woodc_patch) this%leafc_patch(begp:endp) = spval call hist_addfld1d (fname='LEAFC', units='gC/m^2', & - avgflag='A', long_name='leaf C', & - ptr_patch=this%leafc_patch) + avgflag='A', long_name='leaf C', & + ptr_patch=this%leafc_patch) this%leafc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='LEAFC_STORAGE', units='gC/m^2', & - avgflag='A', long_name='leaf C storage', & - ptr_patch=this%leafc_storage_patch, default='inactive') + avgflag='A', long_name='leaf C storage', & + ptr_patch=this%leafc_storage_patch, default='inactive') this%leafc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='LEAFC_XFER', units='gC/m^2', & - avgflag='A', long_name='leaf C transfer', & - ptr_patch=this%leafc_xfer_patch, default='inactive') + avgflag='A', long_name='leaf C transfer', & + ptr_patch=this%leafc_xfer_patch, default='inactive') this%frootc_patch(begp:endp) = spval call hist_addfld1d (fname='FROOTC', units='gC/m^2', & - avgflag='A', long_name='fine root C', & - ptr_patch=this%frootc_patch) + avgflag='A', long_name='fine root C', & + ptr_patch=this%frootc_patch) this%frootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='FROOTC_STORAGE', units='gC/m^2', & - avgflag='A', long_name='fine root C storage', & - ptr_patch=this%frootc_storage_patch, default='inactive') + avgflag='A', long_name='fine root C storage', & + ptr_patch=this%frootc_storage_patch, default='inactive') this%frootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='FROOTC_XFER', units='gC/m^2', & - avgflag='A', long_name='fine root C transfer', & - ptr_patch=this%frootc_xfer_patch, default='inactive') + avgflag='A', long_name='fine root C transfer', & + ptr_patch=this%frootc_xfer_patch, default='inactive') this%livestemc_patch(begp:endp) = spval call hist_addfld1d (fname='LIVESTEMC', units='gC/m^2', & - avgflag='A', long_name='live stem C', & - ptr_patch=this%livestemc_patch) + avgflag='A', long_name='live stem C', & + ptr_patch=this%livestemc_patch) this%livestemc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='LIVESTEMC_STORAGE', units='gC/m^2', & - avgflag='A', long_name='live stem C storage', & - ptr_patch=this%livestemc_storage_patch, default='inactive') + avgflag='A', long_name='live stem C storage', & + ptr_patch=this%livestemc_storage_patch, default='inactive') this%livestemc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='LIVESTEMC_XFER', units='gC/m^2', & - avgflag='A', long_name='live stem C transfer', & - ptr_patch=this%livestemc_xfer_patch, default='inactive') + avgflag='A', long_name='live stem C transfer', & + ptr_patch=this%livestemc_xfer_patch, default='inactive') this%deadstemc_patch(begp:endp) = spval call hist_addfld1d (fname='DEADSTEMC', units='gC/m^2', & - avgflag='A', long_name='dead stem C', & - ptr_patch=this%deadstemc_patch) + avgflag='A', long_name='dead stem C', & + ptr_patch=this%deadstemc_patch) this%deadstemc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='DEADSTEMC_STORAGE', units='gC/m^2', & - avgflag='A', long_name='dead stem C storage', & - ptr_patch=this%deadstemc_storage_patch, default='inactive') + avgflag='A', long_name='dead stem C storage', & + ptr_patch=this%deadstemc_storage_patch, default='inactive') this%deadstemc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='DEADSTEMC_XFER', units='gC/m^2', & - avgflag='A', long_name='dead stem C transfer', & - ptr_patch=this%deadstemc_xfer_patch, default='inactive') + avgflag='A', long_name='dead stem C transfer', & + ptr_patch=this%deadstemc_xfer_patch, default='inactive') this%livecrootc_patch(begp:endp) = spval call hist_addfld1d (fname='LIVECROOTC', units='gC/m^2', & - avgflag='A', long_name='live coarse root C', & - ptr_patch=this%livecrootc_patch) + avgflag='A', long_name='live coarse root C', & + ptr_patch=this%livecrootc_patch) this%livecrootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='LIVECROOTC_STORAGE', units='gC/m^2', & - avgflag='A', long_name='live coarse root C storage', & - ptr_patch=this%livecrootc_storage_patch, default='inactive') + avgflag='A', long_name='live coarse root C storage', & + ptr_patch=this%livecrootc_storage_patch, default='inactive') this%livecrootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='LIVECROOTC_XFER', units='gC/m^2', & - avgflag='A', long_name='live coarse root C transfer', & - ptr_patch=this%livecrootc_xfer_patch, default='inactive') + avgflag='A', long_name='live coarse root C transfer', & + ptr_patch=this%livecrootc_xfer_patch, default='inactive') this%deadcrootc_patch(begp:endp) = spval call hist_addfld1d (fname='DEADCROOTC', units='gC/m^2', & - avgflag='A', long_name='dead coarse root C', & - ptr_patch=this%deadcrootc_patch) + avgflag='A', long_name='dead coarse root C', & + ptr_patch=this%deadcrootc_patch) this%deadcrootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='DEADCROOTC_STORAGE', units='gC/m^2', & - avgflag='A', long_name='dead coarse root C storage', & - ptr_patch=this%deadcrootc_storage_patch, default='inactive') + avgflag='A', long_name='dead coarse root C storage', & + ptr_patch=this%deadcrootc_storage_patch, default='inactive') this%deadcrootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='DEADCROOTC_XFER', units='gC/m^2', & - avgflag='A', long_name='dead coarse root C transfer', & - ptr_patch=this%deadcrootc_xfer_patch, default='inactive') + avgflag='A', long_name='dead coarse root C transfer', & + ptr_patch=this%deadcrootc_xfer_patch, default='inactive') this%gresp_storage_patch(begp:endp) = spval call hist_addfld1d (fname='GRESP_STORAGE', units='gC/m^2', & - avgflag='A', long_name='growth respiration storage', & - ptr_patch=this%gresp_storage_patch, default='inactive') + avgflag='A', long_name='growth respiration storage', & + ptr_patch=this%gresp_storage_patch, default='inactive') this%gresp_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='GRESP_XFER', units='gC/m^2', & - avgflag='A', long_name='growth respiration transfer', & - ptr_patch=this%gresp_xfer_patch, default='inactive') + avgflag='A', long_name='growth respiration transfer', & + ptr_patch=this%gresp_xfer_patch, default='inactive') this%cpool_patch(begp:endp) = spval call hist_addfld1d (fname='CPOOL', units='gC/m^2', & - avgflag='A', long_name='temporary photosynthate C pool', & - ptr_patch=this%cpool_patch) + avgflag='A', long_name='temporary photosynthate C pool', & + ptr_patch=this%cpool_patch) this%xsmrpool_patch(begp:endp) = spval call hist_addfld1d (fname='XSMRPOOL', units='gC/m^2', & - avgflag='A', long_name='temporary photosynthate C pool', & - ptr_patch=this%xsmrpool_patch, default='active') + avgflag='A', long_name='temporary photosynthate C pool', & + ptr_patch=this%xsmrpool_patch, default='active') this%ctrunc_patch(begp:endp) = spval call hist_addfld1d (fname='PFT_CTRUNC', units='gC/m^2', & - avgflag='A', long_name='patch-level sink for C truncation', & - ptr_patch=this%ctrunc_patch, default='inactive') + avgflag='A', long_name='patch-level sink for C truncation', & + ptr_patch=this%ctrunc_patch, default='inactive') this%dispvegc_patch(begp:endp) = spval call hist_addfld1d (fname='DISPVEGC', units='gC/m^2', & - avgflag='A', long_name='displayed veg carbon, excluding storage and cpool', & - ptr_patch=this%dispvegc_patch) + avgflag='A', long_name='displayed veg carbon, excluding storage and cpool', & + ptr_patch=this%dispvegc_patch) this%storvegc_patch(begp:endp) = spval call hist_addfld1d (fname='STORVEGC', units='gC/m^2', & - avgflag='A', long_name='stored vegetation carbon, excluding cpool', & - ptr_patch=this%storvegc_patch) + avgflag='A', long_name='stored vegetation carbon, excluding cpool', & + ptr_patch=this%storvegc_patch) this%totvegc_patch(begp:endp) = spval call hist_addfld1d (fname='TOTVEGC', units='gC/m^2', & - avgflag='A', long_name='total vegetation carbon, excluding cpool', & - ptr_patch=this%totvegc_patch) + avgflag='A', long_name='total vegetation carbon, excluding cpool', & + ptr_patch=this%totvegc_patch) this%totpftc_patch(begp:endp) = spval call hist_addfld1d (fname='TOTPFTC', units='gC/m^2', & - avgflag='A', long_name='total patch-level carbon, including cpool', & - ptr_patch=this%totpftc_patch) + avgflag='A', long_name='total patch-level carbon, including cpool', & + ptr_patch=this%totpftc_patch) end if @@ -444,138 +476,138 @@ subroutine InitHistory(this, bounds, carbon_type) this%leafc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LEAFC', units='gC13/m^2', & - avgflag='A', long_name='C13 leaf C', & - ptr_patch=this%leafc_patch) + avgflag='A', long_name='C13 leaf C', & + ptr_patch=this%leafc_patch) this%leafc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LEAFC_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 leaf C storage', & - ptr_patch=this%leafc_storage_patch, default='inactive') + avgflag='A', long_name='C13 leaf C storage', & + ptr_patch=this%leafc_storage_patch, default='inactive') this%leafc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LEAFC_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 leaf C transfer', & - ptr_patch=this%leafc_xfer_patch, default='inactive') + avgflag='A', long_name='C13 leaf C transfer', & + ptr_patch=this%leafc_xfer_patch, default='inactive') this%frootc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_FROOTC', units='gC13/m^2', & - avgflag='A', long_name='C13 fine root C', & - ptr_patch=this%frootc_patch) + avgflag='A', long_name='C13 fine root C', & + ptr_patch=this%frootc_patch) this%frootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_FROOTC_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 fine root C storage', & - ptr_patch=this%frootc_storage_patch, default='inactive') + avgflag='A', long_name='C13 fine root C storage', & + ptr_patch=this%frootc_storage_patch, default='inactive') this%frootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_FROOTC_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 fine root C transfer', & - ptr_patch=this%frootc_xfer_patch, default='inactive') + avgflag='A', long_name='C13 fine root C transfer', & + ptr_patch=this%frootc_xfer_patch, default='inactive') this%livestemc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LIVESTEMC', units='gC13/m^2', & - avgflag='A', long_name='C13 live stem C', & - ptr_patch=this%livestemc_patch) + avgflag='A', long_name='C13 live stem C', & + ptr_patch=this%livestemc_patch) this%livestemc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LIVESTEMC_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 live stem C storage', & - ptr_patch=this%livestemc_storage_patch, default='inactive') + avgflag='A', long_name='C13 live stem C storage', & + ptr_patch=this%livestemc_storage_patch, default='inactive') this%livestemc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LIVESTEMC_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 live stem C transfer', & - ptr_patch=this%livestemc_xfer_patch, default='inactive') + avgflag='A', long_name='C13 live stem C transfer', & + ptr_patch=this%livestemc_xfer_patch, default='inactive') this%deadstemc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DEADSTEMC', units='gC13/m^2', & - avgflag='A', long_name='C13 dead stem C', & - ptr_patch=this%deadstemc_patch) + avgflag='A', long_name='C13 dead stem C', & + ptr_patch=this%deadstemc_patch) this%deadstemc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DEADSTEMC_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 dead stem C storage', & - ptr_patch=this%deadstemc_storage_patch, default='inactive') + avgflag='A', long_name='C13 dead stem C storage', & + ptr_patch=this%deadstemc_storage_patch, default='inactive') this%deadstemc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DEADSTEMC_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 dead stem C transfer', & - ptr_patch=this%deadstemc_xfer_patch, default='inactive') + avgflag='A', long_name='C13 dead stem C transfer', & + ptr_patch=this%deadstemc_xfer_patch, default='inactive') this%livecrootc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LIVECROOTC', units='gC13/m^2', & - avgflag='A', long_name='C13 live coarse root C', & - ptr_patch=this%livecrootc_patch) + avgflag='A', long_name='C13 live coarse root C', & + ptr_patch=this%livecrootc_patch) this%livecrootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LIVECROOTC_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 live coarse root C storage', & - ptr_patch=this%livecrootc_storage_patch, default='inactive') + avgflag='A', long_name='C13 live coarse root C storage', & + ptr_patch=this%livecrootc_storage_patch, default='inactive') this%livecrootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_LIVECROOTC_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 live coarse root C transfer', & - ptr_patch=this%livecrootc_xfer_patch, default='inactive') + avgflag='A', long_name='C13 live coarse root C transfer', & + ptr_patch=this%livecrootc_xfer_patch, default='inactive') this%deadcrootc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DEADCROOTC', units='gC13/m^2', & - avgflag='A', long_name='C13 dead coarse root C', & - ptr_patch=this%deadcrootc_patch) + avgflag='A', long_name='C13 dead coarse root C', & + ptr_patch=this%deadcrootc_patch) this%deadcrootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DEADCROOTC_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 dead coarse root C storage', & - ptr_patch=this%deadcrootc_storage_patch, default='inactive') + avgflag='A', long_name='C13 dead coarse root C storage', & + ptr_patch=this%deadcrootc_storage_patch, default='inactive') this%deadcrootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DEADCROOTC_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 dead coarse root C transfer', & - ptr_patch=this%deadcrootc_xfer_patch, default='inactive') + avgflag='A', long_name='C13 dead coarse root C transfer', & + ptr_patch=this%deadcrootc_xfer_patch, default='inactive') this%gresp_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C13_GRESP_STORAGE', units='gC13/m^2', & - avgflag='A', long_name='C13 growth respiration storage', & - ptr_patch=this%gresp_storage_patch, default='inactive') + avgflag='A', long_name='C13 growth respiration storage', & + ptr_patch=this%gresp_storage_patch, default='inactive') this%gresp_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C13_GRESP_XFER', units='gC13/m^2', & - avgflag='A', long_name='C13 growth respiration transfer', & - ptr_patch=this%gresp_xfer_patch, default='inactive') + avgflag='A', long_name='C13 growth respiration transfer', & + ptr_patch=this%gresp_xfer_patch, default='inactive') this%cpool_patch(begp:endp) = spval call hist_addfld1d (fname='C13_CPOOL', units='gC13/m^2', & - avgflag='A', long_name='C13 temporary photosynthate C pool', & - ptr_patch=this%cpool_patch) + avgflag='A', long_name='C13 temporary photosynthate C pool', & + ptr_patch=this%cpool_patch) this%xsmrpool_patch(begp:endp) = spval call hist_addfld1d (fname='C13_XSMRPOOL', units='gC13/m^2', & - avgflag='A', long_name='C13 temporary photosynthate C pool', & - ptr_patch=this%xsmrpool_patch) + avgflag='A', long_name='C13 temporary photosynthate C pool', & + ptr_patch=this%xsmrpool_patch) this%ctrunc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_PFT_CTRUNC', units='gC13/m^2', & - avgflag='A', long_name='C13 patch-level sink for C truncation', & - ptr_patch=this%ctrunc_patch) + avgflag='A', long_name='C13 patch-level sink for C truncation', & + ptr_patch=this%ctrunc_patch) this%dispvegc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_DISPVEGC', units='gC13/m^2', & - avgflag='A', long_name='C13 displayed veg carbon, excluding storage and cpool', & - ptr_patch=this%dispvegc_patch) + avgflag='A', long_name='C13 displayed veg carbon, excluding storage and cpool', & + ptr_patch=this%dispvegc_patch) this%storvegc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_STORVEGC', units='gC13/m^2', & - avgflag='A', long_name='C13 stored vegetation carbon, excluding cpool', & - ptr_patch=this%storvegc_patch) + avgflag='A', long_name='C13 stored vegetation carbon, excluding cpool', & + ptr_patch=this%storvegc_patch) this%totvegc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_TOTVEGC', units='gC13/m^2', & - avgflag='A', long_name='C13 total vegetation carbon, excluding cpool', & - ptr_patch=this%totvegc_patch) + avgflag='A', long_name='C13 total vegetation carbon, excluding cpool', & + ptr_patch=this%totvegc_patch) this%totpftc_patch(begp:endp) = spval call hist_addfld1d (fname='C13_TOTPFTC', units='gC13/m^2', & - avgflag='A', long_name='C13 total patch-level carbon, including cpool', & - ptr_patch=this%totpftc_patch) + avgflag='A', long_name='C13 total patch-level carbon, including cpool', & + ptr_patch=this%totpftc_patch) endif !------------------------------- @@ -586,138 +618,138 @@ subroutine InitHistory(this, bounds, carbon_type) this%leafc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LEAFC', units='gC14/m^2', & - avgflag='A', long_name='C14 leaf C', & - ptr_patch=this%leafc_patch) + avgflag='A', long_name='C14 leaf C', & + ptr_patch=this%leafc_patch) this%leafc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LEAFC_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 leaf C storage', & - ptr_patch=this%leafc_storage_patch, default='inactive') + avgflag='A', long_name='C14 leaf C storage', & + ptr_patch=this%leafc_storage_patch, default='inactive') this%leafc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LEAFC_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 leaf C transfer', & - ptr_patch=this%leafc_xfer_patch, default='inactive') + avgflag='A', long_name='C14 leaf C transfer', & + ptr_patch=this%leafc_xfer_patch, default='inactive') this%frootc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_FROOTC', units='gC14/m^2', & - avgflag='A', long_name='C14 fine root C', & - ptr_patch=this%frootc_patch) + avgflag='A', long_name='C14 fine root C', & + ptr_patch=this%frootc_patch) this%frootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_FROOTC_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 fine root C storage', & - ptr_patch=this%frootc_storage_patch, default='inactive') + avgflag='A', long_name='C14 fine root C storage', & + ptr_patch=this%frootc_storage_patch, default='inactive') this%frootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_FROOTC_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 fine root C transfer', & - ptr_patch=this%frootc_xfer_patch, default='inactive') + avgflag='A', long_name='C14 fine root C transfer', & + ptr_patch=this%frootc_xfer_patch, default='inactive') this%livestemc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LIVESTEMC', units='gC14/m^2', & - avgflag='A', long_name='C14 live stem C', & - ptr_patch=this%livestemc_patch) + avgflag='A', long_name='C14 live stem C', & + ptr_patch=this%livestemc_patch) this%livestemc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LIVESTEMC_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 live stem C storage', & - ptr_patch=this%livestemc_storage_patch, default='inactive') + avgflag='A', long_name='C14 live stem C storage', & + ptr_patch=this%livestemc_storage_patch, default='inactive') this%livestemc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LIVESTEMC_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 live stem C transfer', & - ptr_patch=this%livestemc_xfer_patch, default='inactive') + avgflag='A', long_name='C14 live stem C transfer', & + ptr_patch=this%livestemc_xfer_patch, default='inactive') this%deadstemc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DEADSTEMC', units='gC14/m^2', & - avgflag='A', long_name='C14 dead stem C', & - ptr_patch=this%deadstemc_patch) + avgflag='A', long_name='C14 dead stem C', & + ptr_patch=this%deadstemc_patch) this%deadstemc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DEADSTEMC_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 dead stem C storage', & - ptr_patch=this%deadstemc_storage_patch, default='inactive') + avgflag='A', long_name='C14 dead stem C storage', & + ptr_patch=this%deadstemc_storage_patch, default='inactive') this%deadstemc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DEADSTEMC_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 dead stem C transfer', & - ptr_patch=this%deadstemc_xfer_patch, default='inactive') + avgflag='A', long_name='C14 dead stem C transfer', & + ptr_patch=this%deadstemc_xfer_patch, default='inactive') this%livecrootc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LIVECROOTC', units='gC14/m^2', & - avgflag='A', long_name='C14 live coarse root C', & - ptr_patch=this%livecrootc_patch) + avgflag='A', long_name='C14 live coarse root C', & + ptr_patch=this%livecrootc_patch) this%livecrootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LIVECROOTC_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 live coarse root C storage', & - ptr_patch=this%livecrootc_storage_patch, default='inactive') + avgflag='A', long_name='C14 live coarse root C storage', & + ptr_patch=this%livecrootc_storage_patch, default='inactive') this%livecrootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_LIVECROOTC_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 live coarse root C transfer', & - ptr_patch=this%livecrootc_xfer_patch, default='inactive') + avgflag='A', long_name='C14 live coarse root C transfer', & + ptr_patch=this%livecrootc_xfer_patch, default='inactive') this%deadcrootc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DEADCROOTC', units='gC14/m^2', & - avgflag='A', long_name='C14 dead coarse root C', & - ptr_patch=this%deadcrootc_patch) + avgflag='A', long_name='C14 dead coarse root C', & + ptr_patch=this%deadcrootc_patch) this%deadcrootc_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DEADCROOTC_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 dead coarse root C storage', & - ptr_patch=this%deadcrootc_storage_patch, default='inactive') + avgflag='A', long_name='C14 dead coarse root C storage', & + ptr_patch=this%deadcrootc_storage_patch, default='inactive') this%deadcrootc_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DEADCROOTC_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 dead coarse root C transfer', & - ptr_patch=this%deadcrootc_xfer_patch, default='inactive') + avgflag='A', long_name='C14 dead coarse root C transfer', & + ptr_patch=this%deadcrootc_xfer_patch, default='inactive') this%gresp_storage_patch(begp:endp) = spval call hist_addfld1d (fname='C14_GRESP_STORAGE', units='gC14/m^2', & - avgflag='A', long_name='C14 growth respiration storage', & - ptr_patch=this%gresp_storage_patch, default='inactive') + avgflag='A', long_name='C14 growth respiration storage', & + ptr_patch=this%gresp_storage_patch, default='inactive') this%gresp_xfer_patch(begp:endp) = spval call hist_addfld1d (fname='C14_GRESP_XFER', units='gC14/m^2', & - avgflag='A', long_name='C14 growth respiration transfer', & - ptr_patch=this%gresp_xfer_patch, default='inactive') + avgflag='A', long_name='C14 growth respiration transfer', & + ptr_patch=this%gresp_xfer_patch, default='inactive') this%cpool_patch(begp:endp) = spval call hist_addfld1d (fname='C14_CPOOL', units='gC14/m^2', & - avgflag='A', long_name='C14 temporary photosynthate C pool', & - ptr_patch=this%cpool_patch) + avgflag='A', long_name='C14 temporary photosynthate C pool', & + ptr_patch=this%cpool_patch) this%xsmrpool_patch(begp:endp) = spval call hist_addfld1d (fname='C14_XSMRPOOL', units='gC14/m^2', & - avgflag='A', long_name='C14 temporary photosynthate C pool', & - ptr_patch=this%xsmrpool_patch) + avgflag='A', long_name='C14 temporary photosynthate C pool', & + ptr_patch=this%xsmrpool_patch) this%ctrunc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_PFT_CTRUNC', units='gC14/m^2', & - avgflag='A', long_name='C14 patch-level sink for C truncation', & - ptr_patch=this%ctrunc_patch) + avgflag='A', long_name='C14 patch-level sink for C truncation', & + ptr_patch=this%ctrunc_patch) this%dispvegc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_DISPVEGC', units='gC14/m^2', & - avgflag='A', long_name='C14 displayed veg carbon, excluding storage and cpool', & - ptr_patch=this%dispvegc_patch) + avgflag='A', long_name='C14 displayed veg carbon, excluding storage and cpool', & + ptr_patch=this%dispvegc_patch) this%storvegc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_STORVEGC', units='gC14/m^2', & - avgflag='A', long_name='C14 stored vegetation carbon, excluding cpool', & - ptr_patch=this%storvegc_patch) + avgflag='A', long_name='C14 stored vegetation carbon, excluding cpool', & + ptr_patch=this%storvegc_patch) this%totvegc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_TOTVEGC', units='gC14/m^2', & - avgflag='A', long_name='C14 total vegetation carbon, excluding cpool', & - ptr_patch=this%totvegc_patch) + avgflag='A', long_name='C14 total vegetation carbon, excluding cpool', & + ptr_patch=this%totvegc_patch) this%totpftc_patch(begp:endp) = spval call hist_addfld1d (fname='C14_TOTPFTC', units='gC14/m^2', & - avgflag='A', long_name='C14 total patch-level carbon, including cpool', & - ptr_patch=this%totpftc_patch) + avgflag='A', long_name='C14 total patch-level carbon, including cpool', & + ptr_patch=this%totpftc_patch) endif !------------------------------- @@ -726,111 +758,116 @@ subroutine InitHistory(this, bounds, carbon_type) ! add history fields for all CLAMP CN variables + + if (carbon_type == 'c12') then - !those variables are now ouput in betr - this%decomp_cpools_col(begc:endc,:) = spval - do l = 1, ndecomp_pools - if ( nlevdecomp_full > 1 ) then - data2dptr => this%decomp_cpools_vr_col(:,:,l) - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(l))//'C_vr' - longname = trim(decomp_cascade_con%decomp_pool_name_history(l))//' C (vertically resolved)' - - call hist_addfld2d (fname=fieldname, units='gC/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr) - endif - - data1dptr => this%decomp_cpools_col(:,l) - fieldname = trim(decomp_cascade_con%decomp_pool_name_history(l))//'C' - longname = trim(decomp_cascade_con%decomp_pool_name_history(l))//' C' - call hist_addfld1d (fname=fieldname, units='gC/m^2', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr) - - if ( nlevdecomp_full > 1 ) then + !those variables are now ouput in betr + this%decomp_cpools_col(begc:endc,:) = spval + do l = 1, ndecomp_pools + if ( nlevdecomp_full > 1 ) then + data2dptr => this%decomp_cpools_vr_col(:,:,l) + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(l))//'C_vr' + longname = trim(decomp_cascade_con%decomp_pool_name_history(l))//' C (vertically resolved)' + + call hist_addfld2d (fname=fieldname, units='gC/m^3', type2d='levdcmp', & + avgflag='A', long_name=longname, & + ptr_col=data2dptr) + endif + + data1dptr => this%decomp_cpools_col(:,l) + fieldname = trim(decomp_cascade_con%decomp_pool_name_history(l))//'C' + longname = trim(decomp_cascade_con%decomp_pool_name_history(l))//' C' + call hist_addfld1d (fname=fieldname, units='gC/m^2', & + avgflag='A', long_name=longname, & + ptr_col=data1dptr) + + if ( nlevdecomp_full > 1 ) then data1dptr => this%decomp_cpools_1m_col(:,l) fieldname = trim(decomp_cascade_con%decomp_pool_name_history(l))//'C_1m' longname = trim(decomp_cascade_con%decomp_pool_name_history(l))//' C to 1 meter' call hist_addfld1d (fname=fieldname, units='gC/m^2', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr, default = 'inactive') - endif - end do + avgflag='A', long_name=longname, & + ptr_col=data1dptr, default = 'inactive') + endif + end do if ( nlevdecomp_full > 1 ) then + this%totlitc_1m_col(begc:endc) = spval call hist_addfld1d (fname='TOTLITC_1m', units='gC/m^2', & - avgflag='A', long_name='total litter carbon to 1 meter depth', & - ptr_col=this%totlitc_1m_col) + avgflag='A', long_name='total litter carbon to 1 meter depth', & + ptr_col=this%totlitc_1m_col) this%totsomc_1m_col(begc:endc) = spval call hist_addfld1d (fname='TOTSOMC_1m', units='gC/m^2', & - avgflag='A', long_name='total soil organic matter carbon to 1 meter depth', & - ptr_col=this%totsomc_1m_col) + avgflag='A', long_name='total soil organic matter carbon to 1 meter depth', & + ptr_col=this%totsomc_1m_col) end if + this%ctrunc_col(begc:endc) = spval call hist_addfld1d (fname='COL_CTRUNC', units='gC/m^2', & - avgflag='A', long_name='column-level sink for C truncation', & - ptr_col=this%ctrunc_col, default='inactive') + avgflag='A', long_name='column-level sink for C truncation', & + ptr_col=this%ctrunc_col, default='inactive') this%seedc_col(begc:endc) = spval call hist_addfld1d (fname='SEEDC', units='gC/m^2', & - avgflag='A', long_name='pool for seeding new Patches', & - ptr_col=this%seedc_col, default='inactive') + avgflag='A', long_name='pool for seeding new Patches', & + ptr_col=this%seedc_col, default='inactive') this%totlitc_col(begc:endc) = spval call hist_addfld1d (fname='LITTERC', units='gC/m^2', & - avgflag='A', long_name='litter C', & - ptr_col=this%totlitc_col) + avgflag='A', long_name='litter C', & + ptr_col=this%totlitc_col) call hist_addfld1d (fname='TOTLITC', units='gC/m^2', & - avgflag='A', long_name='total litter carbon', & - ptr_col=this%totlitc_col) + avgflag='A', long_name='total litter carbon', & + ptr_col=this%totlitc_col) this%totsomc_col(begc:endc) = spval call hist_addfld1d (fname='TOTSOMC', units='gC/m^2', & - avgflag='A', long_name='total soil organic matter carbon', & - ptr_col=this%totsomc_col) + avgflag='A', long_name='total soil organic matter carbon', & + ptr_col=this%totsomc_col) + call hist_addfld1d (fname='SOILC', units='gC/m^2', & - avgflag='A', long_name='soil C', & - ptr_col=this%totsomc_col) + avgflag='A', long_name='soil C', & + ptr_col=this%totsomc_col) this%totecosysc_col(begc:endc) = spval call hist_addfld1d (fname='TOTECOSYSC', units='gC/m^2', & - avgflag='A', long_name='total ecosystem carbon, incl veg but excl cpool', & - ptr_col=this%totecosysc_col) + avgflag='A', long_name='total ecosystem carbon, incl veg but excl cpool', & + ptr_col=this%totecosysc_col) this%totcolc_col(begc:endc) = spval call hist_addfld1d (fname='TOTCOLC', units='gC/m^2', & - avgflag='A', long_name='total column carbon, incl veg and cpool', & - ptr_col=this%totcolc_col) + avgflag='A', long_name='total column carbon, incl veg and cpool', & + ptr_col=this%totcolc_col) this%prod10c_col(begc:endc) = spval call hist_addfld1d (fname='PROD10C', units='gC/m^2', & - avgflag='A', long_name='10-yr wood product C', & - ptr_col=this%prod10c_col, default='inactive') + avgflag='A', long_name='10-yr wood product C', & + ptr_col=this%prod10c_col, default='inactive') this%prod100c_col(begc:endc) = spval call hist_addfld1d (fname='PROD100C', units='gC/m^2', & - avgflag='A', long_name='100-yr wood product C', & - ptr_col=this%prod100c_col, default='inactive') + avgflag='A', long_name='100-yr wood product C', & + ptr_col=this%prod100c_col, default='inactive') this%prod1c_col(begc:endc) = spval call hist_addfld1d (fname='PROD1C', units='gC/m^2', & - avgflag='A', long_name='1-yr crop product C', & - ptr_col=this%prod1c_col, default='inactive') + avgflag='A', long_name='1-yr crop product C', & + ptr_col=this%prod1c_col, default='inactive') this%totprodc_col(begc:endc) = spval call hist_addfld1d (fname='TOTPRODC', units='gC/m^2', & - avgflag='A', long_name='total wood product C', & - ptr_col=this%totprodc_col, default='inactive') + avgflag='A', long_name='total wood product C', & + ptr_col=this%totprodc_col, default='inactive') this%fuelc_col(begc:endc) = spval call hist_addfld1d (fname='FUELC', units='gC/m^2', & - avgflag='A', long_name='fuel load', & - ptr_col=this%fuelc_col, default='inactive') + avgflag='A', long_name='fuel load', & + ptr_col=this%fuelc_col, default='inactive') end if @@ -841,86 +878,86 @@ subroutine InitHistory(this, bounds, carbon_type) if ( carbon_type == 'c13' ) then - this%decomp_cpools_vr_col(begc:endc,:,:) = spval - do l = 1, ndecomp_pools + this%decomp_cpools_vr_col(begc:endc,:,:) = spval + do l = 1, ndecomp_pools if ( nlevdecomp_full > 1 ) then data2dptr => this%decomp_cpools_vr_col(:,:,l) fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(l))//'C_vr' longname = 'C13 '//trim(decomp_cascade_con%decomp_pool_name_history(l))//' C (vertically resolved)' call hist_addfld2d (fname=fieldname, units='gC13/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, & - ptr_col=data2dptr) + avgflag='A', long_name=longname, & + ptr_col=data2dptr) endif data1dptr => this%decomp_cpools_col(:,l) fieldname = 'C13_'//trim(decomp_cascade_con%decomp_pool_name_history(l))//'C' longname = 'C13 '//trim(decomp_cascade_con%decomp_pool_name_history(l))//' C' call hist_addfld1d (fname=fieldname, units='gC13/m^2', & - avgflag='A', long_name=longname, & - ptr_col=data1dptr) - end do + avgflag='A', long_name=longname, & + ptr_col=data1dptr) + end do this%seedc_col(begc:endc) = spval call hist_addfld1d (fname='C13_SEEDC', units='gC13/m^2', & - avgflag='A', long_name='C13 pool for seeding new Patches', & - ptr_col=this%seedc_col) + avgflag='A', long_name='C13 pool for seeding new Patches', & + ptr_col=this%seedc_col) this%ctrunc_col(begc:endc) = spval call hist_addfld1d (fname='C13_COL_CTRUNC', units='gC13/m^2', & - avgflag='A', long_name='C13 column-level sink for C truncation', & - ptr_col=this%ctrunc_col) + avgflag='A', long_name='C13 column-level sink for C truncation', & + ptr_col=this%ctrunc_col) this%totlitc_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTLITC', units='gC13/m^2', & - avgflag='A', long_name='C13 total litter carbon', & - ptr_col=this%totlitc_col) + avgflag='A', long_name='C13 total litter carbon', & + ptr_col=this%totlitc_col) this%totsomc_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTSOMC', units='gC13/m^2', & - avgflag='A', long_name='C13 total soil organic matter carbon', & - ptr_col=this%totsomc_col) + avgflag='A', long_name='C13 total soil organic matter carbon', & + ptr_col=this%totsomc_col) if ( nlevdecomp_full > 1 ) then this%totlitc_1m_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTLITC_1m', units='gC13/m^2', & - avgflag='A', long_name='C13 total litter carbon to 1 meter', & - ptr_col=this%totlitc_1m_col) + avgflag='A', long_name='C13 total litter carbon to 1 meter', & + ptr_col=this%totlitc_1m_col) this%totsomc_1m_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTSOMC_1m', units='gC13/m^2', & - avgflag='A', long_name='C13 total soil organic matter carbon to 1 meter', & - ptr_col=this%totsomc_1m_col) + avgflag='A', long_name='C13 total soil organic matter carbon to 1 meter', & + ptr_col=this%totsomc_1m_col) endif this%totecosysc_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTECOSYSC', units='gC13/m^2', & - avgflag='A', long_name='C13 total ecosystem carbon, incl veg but excl cpool', & - ptr_col=this%totecosysc_col) + avgflag='A', long_name='C13 total ecosystem carbon, incl veg but excl cpool', & + ptr_col=this%totecosysc_col) this%totcolc_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTCOLC', units='gC13/m^2', & - avgflag='A', long_name='C13 total column carbon, incl veg and cpool', & - ptr_col=this%totcolc_col) + avgflag='A', long_name='C13 total column carbon, incl veg and cpool', & + ptr_col=this%totcolc_col) this%prod10c_col(begc:endc) = spval call hist_addfld1d (fname='C13_PROD10C', units='gC13/m^2', & - avgflag='A', long_name='C13 10-yr wood product C', & - ptr_col=this%prod10c_col) + avgflag='A', long_name='C13 10-yr wood product C', & + ptr_col=this%prod10c_col) this%prod100c_col(begc:endc) = spval call hist_addfld1d (fname='C13_PROD100C', units='gC13/m^2', & - avgflag='A', long_name='C13 100-yr wood product C', & - ptr_col=this%prod100c_col) + avgflag='A', long_name='C13 100-yr wood product C', & + ptr_col=this%prod100c_col) this%prod1c_col(begc:endc) = spval call hist_addfld1d (fname='C13_PROD1C', units='gC13/m^2', & - avgflag='A', long_name='C13 1-yr crop product C', & - ptr_col=this%prod1c_col) + avgflag='A', long_name='C13 1-yr crop product C', & + ptr_col=this%prod1c_col) this%totprodc_col(begc:endc) = spval call hist_addfld1d (fname='C13_TOTPRODC', units='gC13/m^2', & - avgflag='A', long_name='C13 total wood product C', & - ptr_col=this%totprodc_col) + avgflag='A', long_name='C13 total wood product C', & + ptr_col=this%totprodc_col) endif !------------------------------- @@ -936,88 +973,88 @@ subroutine InitHistory(this, bounds, carbon_type) fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(l))//'C_vr' longname = 'C14 '//trim(decomp_cascade_con%decomp_pool_name_history(l))//' C (vertically resolved)' call hist_addfld2d (fname=fieldname, units='gC14/m^3', type2d='levdcmp', & - avgflag='A', long_name=longname, ptr_col=data2dptr) + avgflag='A', long_name=longname, ptr_col=data2dptr) endif data1dptr => this%decomp_cpools_col(:,l) fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(l))//'C' longname = 'C14 '//trim(decomp_cascade_con%decomp_pool_name_history(l))//' C' call hist_addfld1d (fname=fieldname, units='gC14/m^2', & - avgflag='A', long_name=longname, ptr_col=data1dptr) + avgflag='A', long_name=longname, ptr_col=data1dptr) if ( nlevdecomp_full > 1 ) then data1dptr => this%decomp_cpools_1m_col(:,l) fieldname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(l))//'C_1m' longname = 'C14_'//trim(decomp_cascade_con%decomp_pool_name_history(l))//' C to 1 meter' call hist_addfld1d (fname=fieldname, units='gC/m^2', & - avgflag='A', long_name=longname, ptr_col=data1dptr, default='inactive') + avgflag='A', long_name=longname, ptr_col=data1dptr, default='inactive') endif end do this%seedc_col(begc:endc) = spval call hist_addfld1d (fname='C14_SEEDC', units='gC14/m^2', & - avgflag='A', long_name='C14 pool for seeding new Patches', & - ptr_col=this%seedc_col) + avgflag='A', long_name='C14 pool for seeding new Patches', & + ptr_col=this%seedc_col) this%ctrunc_col(begc:endc) = spval call hist_addfld1d (fname='C14_COL_CTRUNC', units='gC14/m^2', & - avgflag='A', long_name='C14 column-level sink for C truncation', & - ptr_col=this%ctrunc_col) + avgflag='A', long_name='C14 column-level sink for C truncation', & + ptr_col=this%ctrunc_col) this%totlitc_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTLITC', units='gC14/m^2', & - avgflag='A', long_name='C14 total litter carbon', & - ptr_col=this%totlitc_col) + avgflag='A', long_name='C14 total litter carbon', & + ptr_col=this%totlitc_col) this%totsomc_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTSOMC', units='gC14/m^2', & - avgflag='A', long_name='C14 total soil organic matter carbon', & - ptr_col=this%totsomc_col) + avgflag='A', long_name='C14 total soil organic matter carbon', & + ptr_col=this%totsomc_col) if ( nlevdecomp_full > 1 ) then this%totlitc_1m_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTLITC_1m', units='gC14/m^2', & - avgflag='A', long_name='C14 total litter carbon to 1 meter', & - ptr_col=this%totlitc_1m_col) + avgflag='A', long_name='C14 total litter carbon to 1 meter', & + ptr_col=this%totlitc_1m_col) this%totsomc_1m_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTSOMC_1m', units='gC14/m^2', & - avgflag='A', long_name='C14 total soil organic matter carbon to 1 meter', & - ptr_col=this%totsomc_1m_col) + avgflag='A', long_name='C14 total soil organic matter carbon to 1 meter', & + ptr_col=this%totsomc_1m_col) endif this%totecosysc_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTECOSYSC', units='gC14/m^2', & - avgflag='A', long_name='C14 total ecosystem carbon, incl veg but excl cpool', & - ptr_col=this%totecosysc_col) + avgflag='A', long_name='C14 total ecosystem carbon, incl veg but excl cpool', & + ptr_col=this%totecosysc_col) this%totcolc_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTCOLC', units='gC14/m^2', & - avgflag='A', long_name='C14 total column carbon, incl veg and cpool', & - ptr_col=this%totcolc_col) + avgflag='A', long_name='C14 total column carbon, incl veg and cpool', & + ptr_col=this%totcolc_col) this%prod10c_col(begc:endc) = spval call hist_addfld1d (fname='C14_PROD10C', units='gC14/m^2', & - avgflag='A', long_name='C14 10-yr wood product C', & - ptr_col=this%prod10c_col) + avgflag='A', long_name='C14 10-yr wood product C', & + ptr_col=this%prod10c_col) this%prod100c_col(begc:endc) = spval call hist_addfld1d (fname='C14_PROD100C', units='gC14/m^2', & - avgflag='A', long_name='C14 100-yr wood product C', & - ptr_col=this%prod100c_col) + avgflag='A', long_name='C14 100-yr wood product C', & + ptr_col=this%prod100c_col) this%prod1c_col(begc:endc) = spval call hist_addfld1d (fname='C14_PROD1C', units='gC14/m^2', & - avgflag='A', long_name='C14 1-yr crop product C', & - ptr_col=this%prod1c_col) + avgflag='A', long_name='C14 1-yr crop product C', & + ptr_col=this%prod1c_col) this%totprodc_col(begc:endc) = spval call hist_addfld1d (fname='C14_TOTPRODC', units='gC14/m^2', & - avgflag='A', long_name='C14 total wood product C', & - ptr_col=this%totprodc_col) + avgflag='A', long_name='C14 total wood product C', & + ptr_col=this%totprodc_col) endif - end subroutine InitHistory + end subroutine InitHistory !----------------------------------------------------------------------- subroutine InitCold(this, bounds, ratio, c12_carbonstate_vars) @@ -1066,129 +1103,132 @@ subroutine InitCold(this, bounds, ratio, c12_carbonstate_vars) end if end do - !----------------------------------------------- - ! initialize patch-level carbon state variables - !----------------------------------------------- - - do p = bounds%begp,bounds%endp - this%leafcmax_patch(p) = 0._r8 + if ( .not. use_ed ) then + !----------------------------------------------- + ! initialize patch-level carbon state variables + !----------------------------------------------- - l = pft%landunit(p) - if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then + do p = bounds%begp,bounds%endp - if (pft%itype(p) == noveg) then - this%leafc_patch(p) = 0._r8 - this%leafc_storage_patch(p) = 0._r8 - else - if (ecophyscon%evergreen(pft%itype(p)) == 1._r8) then - this%leafc_patch(p) = 1._r8 * ratio - this%leafc_storage_patch(p) = 0._r8 - else if (pft%itype(p) >= npcropmin) then ! prognostic crop types - this%leafc_patch(p) = 0._r8 + this%leafcmax_patch(p) = 0._r8 + + l = pft%landunit(p) + if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then + + if (pft%itype(p) == noveg) then + this%leafc_patch(p) = 0._r8 this%leafc_storage_patch(p) = 0._r8 else - this%leafc_patch(p) = 0._r8 - this%leafc_storage_patch(p) = 1._r8 * ratio + if (ecophyscon%evergreen(pft%itype(p)) == 1._r8) then + this%leafc_patch(p) = 1._r8 * ratio + this%leafc_storage_patch(p) = 0._r8 + else if (pft%itype(p) >= npcropmin) then ! prognostic crop types + this%leafc_patch(p) = 0._r8 + this%leafc_storage_patch(p) = 0._r8 + else + this%leafc_patch(p) = 0._r8 + this%leafc_storage_patch(p) = 1._r8 * ratio + end if end if - end if - this%leafc_xfer_patch(p) = 0._r8 + this%leafc_xfer_patch(p) = 0._r8 - this%frootc_patch(p) = 0._r8 - this%frootc_storage_patch(p) = 0._r8 - this%frootc_xfer_patch(p) = 0._r8 + this%frootc_patch(p) = 0._r8 + this%frootc_storage_patch(p) = 0._r8 + this%frootc_xfer_patch(p) = 0._r8 - this%livestemc_patch(p) = 0._r8 - this%livestemc_storage_patch(p) = 0._r8 - this%livestemc_xfer_patch(p) = 0._r8 + this%livestemc_patch(p) = 0._r8 + this%livestemc_storage_patch(p) = 0._r8 + this%livestemc_xfer_patch(p) = 0._r8 - if (ecophyscon%woody(pft%itype(p)) == 1._r8) then - this%deadstemc_patch(p) = 0.1_r8 * ratio - else - this%deadstemc_patch(p) = 0._r8 - end if - this%deadstemc_storage_patch(p) = 0._r8 - this%deadstemc_xfer_patch(p) = 0._r8 - - if (nu_com .ne. 'RD') then - ! ECA competition calculate root NP uptake as a function of fine root biomass - ! better to initialize root CNP pools with a non-zero value - if (pft%itype(p) .ne. noveg) then - if (ecophyscon%evergreen(pft%itype(p)) == 1._r8) then - this%leafc_patch(p) = 20._r8 * ratio - this%leafc_storage_patch(p) = 0._r8 - this%frootc_patch(p) = 20._r8 * ratio - this%frootc_storage_patch(p) = 0._r8 - else - this%leafc_patch(p) = 0._r8 - this%leafc_storage_patch(p) = 20._r8 * ratio - this%frootc_patch(p) = 0._r8 - this%frootc_storage_patch(p) = 20._r8 * ratio - end if - end if - end if + if (ecophyscon%woody(pft%itype(p)) == 1._r8) then + this%deadstemc_patch(p) = 0.1_r8 * ratio + else + this%deadstemc_patch(p) = 0._r8 + end if + this%deadstemc_storage_patch(p) = 0._r8 + this%deadstemc_xfer_patch(p) = 0._r8 + + if (nu_com .ne. 'RD') then + ! ECA competition calculate root NP uptake as a function of fine root biomass + ! better to initialize root CNP pools with a non-zero value + if (pft%itype(p) .ne. noveg) then + if (ecophyscon%evergreen(pft%itype(p)) == 1._r8) then + this%leafc_patch(p) = 20._r8 * ratio + this%leafc_storage_patch(p) = 0._r8 + this%frootc_patch(p) = 20._r8 * ratio + this%frootc_storage_patch(p) = 0._r8 + else + this%leafc_patch(p) = 0._r8 + this%leafc_storage_patch(p) = 20._r8 * ratio + this%frootc_patch(p) = 0._r8 + this%frootc_storage_patch(p) = 20._r8 * ratio + end if + end if + end if - this%livecrootc_patch(p) = 0._r8 - this%livecrootc_storage_patch(p) = 0._r8 - this%livecrootc_xfer_patch(p) = 0._r8 - - this%deadcrootc_patch(p) = 0._r8 - this%deadcrootc_storage_patch(p) = 0._r8 - this%deadcrootc_xfer_patch(p) = 0._r8 - - this%gresp_storage_patch(p) = 0._r8 - this%gresp_xfer_patch(p) = 0._r8 - - this%cpool_patch(p) = 0._r8 - this%xsmrpool_patch(p) = 0._r8 - this%ctrunc_patch(p) = 0._r8 - this%dispvegc_patch(p) = 0._r8 - this%storvegc_patch(p) = 0._r8 - this%totpftc_patch(p) = 0._r8 - this%woodc_patch(p) = 0._r8 - - if ( crop_prog )then - this%grainc_patch(p) = 0._r8 - this%grainc_storage_patch(p) = 0._r8 - this%grainc_xfer_patch(p) = 0._r8 - end if + this%livecrootc_patch(p) = 0._r8 + this%livecrootc_storage_patch(p) = 0._r8 + this%livecrootc_xfer_patch(p) = 0._r8 + + this%deadcrootc_patch(p) = 0._r8 + this%deadcrootc_storage_patch(p) = 0._r8 + this%deadcrootc_xfer_patch(p) = 0._r8 + + this%gresp_storage_patch(p) = 0._r8 + this%gresp_xfer_patch(p) = 0._r8 + + this%cpool_patch(p) = 0._r8 + this%xsmrpool_patch(p) = 0._r8 + this%ctrunc_patch(p) = 0._r8 + this%dispvegc_patch(p) = 0._r8 + this%storvegc_patch(p) = 0._r8 + this%totpftc_patch(p) = 0._r8 + this%woodc_patch(p) = 0._r8 + + if ( crop_prog )then + this%grainc_patch(p) = 0._r8 + this%grainc_storage_patch(p) = 0._r8 + this%grainc_xfer_patch(p) = 0._r8 + end if - ! calculate totvegc explicitly so that it is available for the isotope - ! code on the first time step. - - this%totvegc_patch(p) = & - this%leafc_patch(p) + & - this%leafc_storage_patch(p) + & - this%leafc_xfer_patch(p) + & - this%frootc_patch(p) + & - this%frootc_storage_patch(p) + & - this%frootc_xfer_patch(p) + & - this%livestemc_patch(p) + & - this%livestemc_storage_patch(p) + & - this%livestemc_xfer_patch(p) + & - this%deadstemc_patch(p) + & - this%deadstemc_storage_patch(p) + & - this%deadstemc_xfer_patch(p) + & - this%livecrootc_patch(p) + & - this%livecrootc_storage_patch(p) + & - this%livecrootc_xfer_patch(p) + & - this%deadcrootc_patch(p) + & - this%deadcrootc_storage_patch(p) + & - this%deadcrootc_xfer_patch(p) + & - this%gresp_storage_patch(p) + & - this%gresp_xfer_patch(p) + & - this%cpool_patch(p) - - if ( crop_prog )then - this%totvegc_patch(p) = this%totvegc_patch(p) + & - this%grainc_patch(p) + & - this%grainc_storage_patch(p) + & - this%grainc_xfer_patch(p) - end if - endif - - end do + ! calculate totvegc explicitly so that it is available for the isotope + ! code on the first time step. + + this%totvegc_patch(p) = & + this%leafc_patch(p) + & + this%leafc_storage_patch(p) + & + this%leafc_xfer_patch(p) + & + this%frootc_patch(p) + & + this%frootc_storage_patch(p) + & + this%frootc_xfer_patch(p) + & + this%livestemc_patch(p) + & + this%livestemc_storage_patch(p) + & + this%livestemc_xfer_patch(p) + & + this%deadstemc_patch(p) + & + this%deadstemc_storage_patch(p) + & + this%deadstemc_xfer_patch(p) + & + this%livecrootc_patch(p) + & + this%livecrootc_storage_patch(p) + & + this%livecrootc_xfer_patch(p) + & + this%deadcrootc_patch(p) + & + this%deadcrootc_storage_patch(p) + & + this%deadcrootc_xfer_patch(p) + & + this%gresp_storage_patch(p) + & + this%gresp_xfer_patch(p) + & + this%cpool_patch(p) + + if ( crop_prog )then + this%totvegc_patch(p) = this%totvegc_patch(p) + & + this%grainc_patch(p) + & + this%grainc_storage_patch(p) + & + this%grainc_xfer_patch(p) + end if + endif + end do + endif ! .not. use_ed + ! initialize column-level variables do c = bounds%begc, bounds%endc l = col%landunit(c) @@ -1338,952 +1378,956 @@ subroutine Restart ( this, bounds, ncid, flag, carbon_type, c12_carbonstate_var end if end if - !-------------------------------- - ! patch carbon state variables (c12) - !-------------------------------- + if ( .not. use_ed ) then + + !-------------------------------- + ! patch carbon state variables (c12) + !-------------------------------- + + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='leafc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='leafc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='frootc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='frootc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='gresp_storage', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%gresp_storage_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='gresp_storage', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%gresp_storage_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='gresp_xfer', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%gresp_xfer_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='gresp_xfer', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%gresp_xfer_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='cpool', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%cpool_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='cpool', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%cpool_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='xsmrpool', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%xsmrpool_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='xsmrpool', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%xsmrpool_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='pft_ctrunc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%ctrunc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='pft_ctrunc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%ctrunc_patch) - end if + if (carbon_type == 'c12') then + call restartvar(ncid=ncid, flag=flag, varname='totvegc', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%totvegc_patch) + end if - if (carbon_type == 'c12') then - call restartvar(ncid=ncid, flag=flag, varname='totvegc', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%totvegc_patch) - end if + if (carbon_type == 'c12' .and. use_cndv) then + call restartvar(ncid=ncid, flag=flag, varname='leafcmax', xtype=ncd_double, & + dim1name='pft', & + long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafcmax_patch) + end if - if (carbon_type == 'c12' .and. use_cndv) then - call restartvar(ncid=ncid, flag=flag, varname='leafcmax', xtype=ncd_double, & - dim1name='pft', & - long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafcmax_patch) - end if + !-------------------------------- + ! C13 pft carbon state variables + !-------------------------------- - !-------------------------------- - ! C13 pft carbon state variables - !-------------------------------- + if ( carbon_type == 'c13') then + if (.not. present(c12_carbonstate_vars)) then + call endrun(msg=' ERROR: for C13 must pass in c12_carbonstate_vars as argument' // errMsg(__FILE__, __LINE__)) + end if - if ( carbon_type == 'c13') then - if (.not. present(c12_carbonstate_vars)) then - call endrun(msg=' ERROR: for C13 must pass in c12_carbonstate_vars as argument' // errMsg(__FILE__, __LINE__)) - end if - - if ( .not. is_restart() .and. get_nstep() == 1 ) then - c3_del13c = -28._r8 - c4_del13c = -13._r8 - c3_r1 = SHR_CONST_PDB + ((c3_del13c*SHR_CONST_PDB)/1000._r8) - c3_r2 = c3_r1/(1._r8 + c3_r1) - c4_r1 = SHR_CONST_PDB + ((c4_del13c*SHR_CONST_PDB)/1000._r8) - c4_r2 = c4_r1/(1._r8 + c4_r1) - - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%grainc_patch(i) = c12_carbonstate_vars%grainc_patch(i) * c3_r2 - this%grainc_storage_patch(i) = c12_carbonstate_vars%grainc_storage_patch(i) * c3_r2 - this%grainc_xfer_patch(i) = c12_carbonstate_vars%grainc_xfer_patch(i) * c3_r2 - this%dispvegc_patch(i) = c12_carbonstate_vars%dispvegc_patch(i) * c3_r2 - this%storvegc_patch(i) = c12_carbonstate_vars%storvegc_patch(i) * c3_r2 - this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c3_r2 - this%totpftc_patch(i) = c12_carbonstate_vars%totpftc_patch(i) * c3_r2 - this%woodc_patch(i) = c12_carbonstate_vars%woodc_patch(i) * c3_r2 - else - this%grainc_patch(i) = c12_carbonstate_vars%grainc_patch(i) * c4_r2 - this%grainc_storage_patch(i) = c12_carbonstate_vars%grainc_storage_patch(i) * c4_r2 - this%grainc_xfer_patch(i) = c12_carbonstate_vars%grainc_xfer_patch(i) * c4_r2 - this%dispvegc_patch(i) = c12_carbonstate_vars%dispvegc_patch(i) * c4_r2 - this%storvegc_patch(i) = c12_carbonstate_vars%storvegc_patch(i) * c4_r2 - this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c4_r2 - this%totpftc_patch(i) = c12_carbonstate_vars%totpftc_patch(i) * c4_r2 - this%woodc_patch(i) = c12_carbonstate_vars%woodc_patch(i) * c4_r2 - end if - end do + if ( .not. is_restart() .and. get_nstep() == 1 ) then + c3_del13c = -28._r8 + c4_del13c = -13._r8 + c3_r1 = SHR_CONST_PDB + ((c3_del13c*SHR_CONST_PDB)/1000._r8) + c3_r2 = c3_r1/(1._r8 + c3_r1) + c4_r1 = SHR_CONST_PDB + ((c4_del13c*SHR_CONST_PDB)/1000._r8) + c4_r2 = c4_r1/(1._r8 + c4_r1) + + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%grainc_patch(i) = c12_carbonstate_vars%grainc_patch(i) * c3_r2 + this%grainc_storage_patch(i) = c12_carbonstate_vars%grainc_storage_patch(i) * c3_r2 + this%grainc_xfer_patch(i) = c12_carbonstate_vars%grainc_xfer_patch(i) * c3_r2 + this%dispvegc_patch(i) = c12_carbonstate_vars%dispvegc_patch(i) * c3_r2 + this%storvegc_patch(i) = c12_carbonstate_vars%storvegc_patch(i) * c3_r2 + this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c3_r2 + this%totpftc_patch(i) = c12_carbonstate_vars%totpftc_patch(i) * c3_r2 + this%woodc_patch(i) = c12_carbonstate_vars%woodc_patch(i) * c3_r2 + else + this%grainc_patch(i) = c12_carbonstate_vars%grainc_patch(i) * c4_r2 + this%grainc_storage_patch(i) = c12_carbonstate_vars%grainc_storage_patch(i) * c4_r2 + this%grainc_xfer_patch(i) = c12_carbonstate_vars%grainc_xfer_patch(i) * c4_r2 + this%dispvegc_patch(i) = c12_carbonstate_vars%dispvegc_patch(i) * c4_r2 + this%storvegc_patch(i) = c12_carbonstate_vars%storvegc_patch(i) * c4_r2 + this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c4_r2 + this%totpftc_patch(i) = c12_carbonstate_vars%totpftc_patch(i) * c4_r2 + this%woodc_patch(i) = c12_carbonstate_vars%woodc_patch(i) * c4_r2 + end if + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%leafc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%leafc_patch(i) = c12_carbonstate_vars%leafc_patch(i) * c3_r2 - else - this%leafc_patch(i) = c12_carbonstate_vars%leafc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%leafc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%leafc_patch(i) = c12_carbonstate_vars%leafc_patch(i) * c3_r2 + else + this%leafc_patch(i) = c12_carbonstate_vars%leafc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%leafc_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%leafc_storage_patch(i) = c12_carbonstate_vars%leafc_storage_patch(i) * c3_r2 - else - this%leafc_storage_patch(i) = c12_carbonstate_vars%leafc_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%leafc_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%leafc_storage_patch(i) = c12_carbonstate_vars%leafc_storage_patch(i) * c3_r2 + else + this%leafc_storage_patch(i) = c12_carbonstate_vars%leafc_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_xfer_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%leafc_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%leafc_xfer_patch(i) = c12_carbonstate_vars%leafc_xfer_patch(i) * c3_r2 - else - this%leafc_xfer_patch(i) = c12_carbonstate_vars%leafc_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_xfer_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%leafc_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%leafc_xfer_patch(i) = c12_carbonstate_vars%leafc_xfer_patch(i) * c3_r2 + else + this%leafc_xfer_patch(i) = c12_carbonstate_vars%leafc_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%frootc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%frootc_patch(i) = c12_carbonstate_vars%frootc_patch(i) * c3_r2 - else - this%frootc_patch(i) = c12_carbonstate_vars%frootc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%frootc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%frootc_patch(i) = c12_carbonstate_vars%frootc_patch(i) * c3_r2 + else + this%frootc_patch(i) = c12_carbonstate_vars%frootc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%frootc_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%frootc_storage_patch(i) = c12_carbonstate_vars%frootc_storage_patch(i) * c3_r2 - else - this%frootc_storage_patch(i) = c12_carbonstate_vars%frootc_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%frootc_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%frootc_storage_patch(i) = c12_carbonstate_vars%frootc_storage_patch(i) * c3_r2 + else + this%frootc_storage_patch(i) = c12_carbonstate_vars%frootc_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_xfer_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%frootc_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%frootc_xfer_patch(i) = c12_carbonstate_vars%frootc_xfer_patch(i) * c3_r2 - else - this%frootc_xfer_patch(i) = c12_carbonstate_vars%frootc_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_xfer_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%frootc_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%frootc_xfer_patch(i) = c12_carbonstate_vars%frootc_xfer_patch(i) * c3_r2 + else + this%frootc_xfer_patch(i) = c12_carbonstate_vars%frootc_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livestemc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%livestemc_patch(i) = c12_carbonstate_vars%livestemc_patch(i) * c3_r2 - else - this%livestemc_patch(i) = c12_carbonstate_vars%livestemc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livestemc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%livestemc_patch(i) = c12_carbonstate_vars%livestemc_patch(i) * c3_r2 + else + this%livestemc_patch(i) = c12_carbonstate_vars%livestemc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livestemc_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%livestemc_storage_patch(i) = c12_carbonstate_vars%livestemc_storage_patch(i) * c3_r2 - else - this%livestemc_storage_patch(i) = c12_carbonstate_vars%livestemc_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livestemc_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%livestemc_storage_patch(i) = c12_carbonstate_vars%livestemc_storage_patch(i) * c3_r2 + else + this%livestemc_storage_patch(i) = c12_carbonstate_vars%livestemc_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_xfer_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livestemc_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%livestemc_xfer_patch(i) = c12_carbonstate_vars%livestemc_xfer_patch(i) * c3_r2 - else - this%livestemc_xfer_patch(i) = c12_carbonstate_vars%livestemc_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_xfer_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livestemc_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%livestemc_xfer_patch(i) = c12_carbonstate_vars%livestemc_xfer_patch(i) * c3_r2 + else + this%livestemc_xfer_patch(i) = c12_carbonstate_vars%livestemc_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadstemc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%deadstemc_patch(i) = c12_carbonstate_vars%deadstemc_patch(i) * c3_r2 - else - this%deadstemc_patch(i) = c12_carbonstate_vars%deadstemc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadstemc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%deadstemc_patch(i) = c12_carbonstate_vars%deadstemc_patch(i) * c3_r2 + else + this%deadstemc_patch(i) = c12_carbonstate_vars%deadstemc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadstemc_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%deadstemc_storage_patch(i) = c12_carbonstate_vars%deadstemc_storage_patch(i) * c3_r2 - else - this%deadstemc_storage_patch(i) = c12_carbonstate_vars%deadstemc_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadstemc_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%deadstemc_storage_patch(i) = c12_carbonstate_vars%deadstemc_storage_patch(i) * c3_r2 + else + this%deadstemc_storage_patch(i) = c12_carbonstate_vars%deadstemc_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_xfer_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadstemc_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%deadstemc_xfer_patch(i) = c12_carbonstate_vars%deadstemc_xfer_patch(i) * c3_r2 - else - this%deadstemc_xfer_patch(i) = c12_carbonstate_vars%deadstemc_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_xfer_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadstemc_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%deadstemc_xfer_patch(i) = c12_carbonstate_vars%deadstemc_xfer_patch(i) * c3_r2 + else + this%deadstemc_xfer_patch(i) = c12_carbonstate_vars%deadstemc_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livecrootc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%livecrootc_patch(i) = c12_carbonstate_vars%livecrootc_patch(i) * c3_r2 - else - this%livecrootc_patch(i) = c12_carbonstate_vars%livecrootc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livecrootc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%livecrootc_patch(i) = c12_carbonstate_vars%livecrootc_patch(i) * c3_r2 + else + this%livecrootc_patch(i) = c12_carbonstate_vars%livecrootc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livecrootc_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%livecrootc_storage_patch(i) = c12_carbonstate_vars%livecrootc_storage_patch(i) * c3_r2 - else - this%livecrootc_storage_patch(i) = c12_carbonstate_vars%livecrootc_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livecrootc_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%livecrootc_storage_patch(i) = c12_carbonstate_vars%livecrootc_storage_patch(i) * c3_r2 + else + this%livecrootc_storage_patch(i) = c12_carbonstate_vars%livecrootc_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_xfer_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livecrootc_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%livecrootc_xfer_patch(i) = c12_carbonstate_vars%livecrootc_xfer_patch(i) * c3_r2 - else - this%livecrootc_xfer_patch(i) = c12_carbonstate_vars%livecrootc_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_xfer_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livecrootc_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%livecrootc_xfer_patch(i) = c12_carbonstate_vars%livecrootc_xfer_patch(i) * c3_r2 + else + this%livecrootc_xfer_patch(i) = c12_carbonstate_vars%livecrootc_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadcrootc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%deadcrootc_patch(i) = c12_carbonstate_vars%deadcrootc_patch(i) * c3_r2 - else - this%deadcrootc_patch(i) = c12_carbonstate_vars%deadcrootc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadcrootc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%deadcrootc_patch(i) = c12_carbonstate_vars%deadcrootc_patch(i) * c3_r2 + else + this%deadcrootc_patch(i) = c12_carbonstate_vars%deadcrootc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadcrootc_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%deadcrootc_storage_patch(i) = c12_carbonstate_vars%deadcrootc_storage_patch(i) * c3_r2 - else - this%deadcrootc_storage_patch(i) = c12_carbonstate_vars%deadcrootc_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadcrootc_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%deadcrootc_storage_patch(i) = c12_carbonstate_vars%deadcrootc_storage_patch(i) * c3_r2 + else + this%deadcrootc_storage_patch(i) = c12_carbonstate_vars%deadcrootc_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_xfer_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadcrootc_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%deadcrootc_xfer_patch(i) = c12_carbonstate_vars%deadcrootc_xfer_patch(i) * c3_r2 - else - this%deadcrootc_xfer_patch(i) = c12_carbonstate_vars%deadcrootc_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_xfer_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadcrootc_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%deadcrootc_xfer_patch(i) = c12_carbonstate_vars%deadcrootc_xfer_patch(i) * c3_r2 + else + this%deadcrootc_xfer_patch(i) = c12_carbonstate_vars%deadcrootc_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='gresp_storage_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%gresp_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%gresp_storage with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%gresp_storage_patch(i) = c12_carbonstate_vars%gresp_storage_patch(i) * c3_r2 - else - this%gresp_storage_patch(i) = c12_carbonstate_vars%gresp_storage_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='gresp_storage_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%gresp_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%gresp_storage with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%gresp_storage_patch(i) = c12_carbonstate_vars%gresp_storage_patch(i) * c3_r2 + else + this%gresp_storage_patch(i) = c12_carbonstate_vars%gresp_storage_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='gresp_xfer_13', xtype=ncd_double, & - dim1name='pft', & - long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%gresp_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%gresp_xfer with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%gresp_xfer_patch(i) = c12_carbonstate_vars%gresp_xfer_patch(i) * c3_r2 - else - this%gresp_xfer_patch(i) = c12_carbonstate_vars%gresp_xfer_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='gresp_xfer_13', xtype=ncd_double, & + dim1name='pft', & + long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%gresp_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%gresp_xfer with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%gresp_xfer_patch(i) = c12_carbonstate_vars%gresp_xfer_patch(i) * c3_r2 + else + this%gresp_xfer_patch(i) = c12_carbonstate_vars%gresp_xfer_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='cpool_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%cpool_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%cpool with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%cpool_patch(i) = c12_carbonstate_vars%cpool_patch(i) * c3_r2 - else - this%cpool_patch(i) = c12_carbonstate_vars%cpool_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='cpool_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%cpool_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%cpool with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%cpool_patch(i) = c12_carbonstate_vars%cpool_patch(i) * c3_r2 + else + this%cpool_patch(i) = c12_carbonstate_vars%cpool_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='xsmrpool_13', xtype=ncd_double, & - dim1name='pft', & - long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%xsmrpool_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%xsmrpool with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%xsmrpool_patch(i) = c12_carbonstate_vars%xsmrpool_patch(i) * c3_r2 - else - this%xsmrpool_patch(i) = c12_carbonstate_vars%xsmrpool_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='xsmrpool_13', xtype=ncd_double, & + dim1name='pft', & + long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%xsmrpool_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%xsmrpool with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%xsmrpool_patch(i) = c12_carbonstate_vars%xsmrpool_patch(i) * c3_r2 + else + this%xsmrpool_patch(i) = c12_carbonstate_vars%xsmrpool_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='pft_ctrunc_13', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%ctrunc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%ctrunc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%ctrunc_patch(i) = c12_carbonstate_vars%ctrunc_patch(i) * c3_r2 - else - this%ctrunc_patch(i) = c12_carbonstate_vars%ctrunc_patch(i) * c4_r2 - endif - end do + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='pft_ctrunc_13', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%ctrunc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%ctrunc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%ctrunc_patch(i) = c12_carbonstate_vars%ctrunc_patch(i) * c3_r2 + else + this%ctrunc_patch(i) = c12_carbonstate_vars%ctrunc_patch(i) * c4_r2 + endif + end do + end if end if - end if - if ( carbon_type == 'c13') then - call restartvar(ncid=ncid, flag=flag, varname='totvegc_13', xtype=ncd_double, & - dim1name='pft', & - long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%totvegc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing carbonstate_vars %totvegc with atmospheric c13 value' - do i = bounds%begp,bounds%endp - if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then - this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c3_r2 - else - this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c4_r2 - endif - end do - end if - endif + if ( carbon_type == 'c13') then + call restartvar(ncid=ncid, flag=flag, varname='totvegc_13', xtype=ncd_double, & + dim1name='pft', & + long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%totvegc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing carbonstate_vars %totvegc with atmospheric c13 value' + do i = bounds%begp,bounds%endp + if (ecophyscon%c3psn(pft%itype(i)) == 1._r8) then + this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c3_r2 + else + this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c4_r2 + endif + end do + end if + endif - !-------------------------------- - ! C14 pft carbon state variables - !-------------------------------- + !-------------------------------- + ! C14 pft carbon state variables + !-------------------------------- - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%leafc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%leafc_patch(i) /= spval .and. & - .not. isnan(this%leafc_patch(i)) ) then - this%leafc_patch(i) = c12_carbonstate_vars%leafc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%leafc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%leafc_patch(i) /= spval .and. & + .not. isnan(this%leafc_patch(i)) ) then + this%leafc_patch(i) = c12_carbonstate_vars%leafc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%leafc_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%leafc_storage_patch(i) /= spval .and. & - .not. isnan(this%leafc_storage_patch(i)) ) then - this%leafc_storage_patch(i) = c12_carbonstate_vars%leafc_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%leafc_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%leafc_storage_patch(i) /= spval .and. & + .not. isnan(this%leafc_storage_patch(i)) ) then + this%leafc_storage_patch(i) = c12_carbonstate_vars%leafc_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='leafc_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%leafc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%leafc_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%leafc_xfer_patch(i) /= spval .and. .not. isnan(this%leafc_xfer_patch(i)) ) then - this%leafc_xfer_patch(i) = c12_carbonstate_vars%leafc_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='leafc_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%leafc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%leafc_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%leafc_xfer_patch(i) /= spval .and. .not. isnan(this%leafc_xfer_patch(i)) ) then + this%leafc_xfer_patch(i) = c12_carbonstate_vars%leafc_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%frootc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%frootc_patch(i) /= spval .and. & - .not. isnan(this%frootc_patch(i)) ) then - this%frootc_patch(i) = c12_carbonstate_vars%frootc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%frootc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%frootc_patch(i) /= spval .and. & + .not. isnan(this%frootc_patch(i)) ) then + this%frootc_patch(i) = c12_carbonstate_vars%frootc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%frootc_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%frootc_storage_patch(i) /= spval .and. & - .not. isnan(this%frootc_storage_patch(i)) ) then - this%frootc_storage_patch(i) = c12_carbonstate_vars%frootc_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%frootc_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%frootc_storage_patch(i) /= spval .and. & + .not. isnan(this%frootc_storage_patch(i)) ) then + this%frootc_storage_patch(i) = c12_carbonstate_vars%frootc_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='frootc_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%frootc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%frootc_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%frootc_xfer_patch(i) /= spval .and. & - .not. isnan(this%frootc_xfer_patch(i)) ) then - this%frootc_xfer_patch(i) = c12_carbonstate_vars%frootc_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='frootc_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%frootc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%frootc_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%frootc_xfer_patch(i) /= spval .and. & + .not. isnan(this%frootc_xfer_patch(i)) ) then + this%frootc_xfer_patch(i) = c12_carbonstate_vars%frootc_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livestemc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%livestemc_patch(i) /= spval .and. .not. isnan(this%livestemc_patch(i)) ) then - this%livestemc_patch(i) = c12_carbonstate_vars%livestemc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livestemc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%livestemc_patch(i) /= spval .and. .not. isnan(this%livestemc_patch(i)) ) then + this%livestemc_patch(i) = c12_carbonstate_vars%livestemc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livestemc_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%livestemc_storage_patch(i) /= spval .and. .not. isnan(this%livestemc_storage_patch(i)) ) then - this%livestemc_storage_patch(i) = c12_carbonstate_vars%livestemc_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livestemc_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%livestemc_storage_patch(i) /= spval .and. .not. isnan(this%livestemc_storage_patch(i)) ) then + this%livestemc_storage_patch(i) = c12_carbonstate_vars%livestemc_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='livestemc_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livestemc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livestemc_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%livestemc_xfer_patch(i) /= spval .and. .not. isnan(this%livestemc_xfer_patch(i)) ) then - this%livestemc_xfer_patch(i) = c12_carbonstate_vars%livestemc_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='livestemc_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livestemc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livestemc_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%livestemc_xfer_patch(i) /= spval .and. .not. isnan(this%livestemc_xfer_patch(i)) ) then + this%livestemc_xfer_patch(i) = c12_carbonstate_vars%livestemc_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadstemc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%deadstemc_patch(i) /= spval .and. .not. isnan(this%deadstemc_patch(i)) ) then - this%deadstemc_patch(i) = c12_carbonstate_vars%deadstemc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadstemc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%deadstemc_patch(i) /= spval .and. .not. isnan(this%deadstemc_patch(i)) ) then + this%deadstemc_patch(i) = c12_carbonstate_vars%deadstemc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadstemc_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%deadstemc_storage_patch(i) /= spval .and. .not. isnan(this%deadstemc_storage_patch(i)) ) then - this%deadstemc_storage_patch(i) = c12_carbonstate_vars%deadstemc_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadstemc_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%deadstemc_storage_patch(i) /= spval .and. .not. isnan(this%deadstemc_storage_patch(i)) ) then + this%deadstemc_storage_patch(i) = c12_carbonstate_vars%deadstemc_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='deadstemc_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadstemc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadstemc_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%deadstemc_xfer_patch(i) /= spval .and. .not. isnan(this%deadstemc_xfer_patch(i)) ) then - this%deadstemc_xfer_patch(i) = c12_carbonstate_vars%deadstemc_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='deadstemc_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadstemc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadstemc_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%deadstemc_xfer_patch(i) /= spval .and. .not. isnan(this%deadstemc_xfer_patch(i)) ) then + this%deadstemc_xfer_patch(i) = c12_carbonstate_vars%deadstemc_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livecrootc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%livecrootc_patch(i) /= spval .and. .not. isnan(this%livecrootc_patch(i)) ) then - this%livecrootc_patch(i) = c12_carbonstate_vars%livecrootc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livecrootc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%livecrootc_patch(i) /= spval .and. .not. isnan(this%livecrootc_patch(i)) ) then + this%livecrootc_patch(i) = c12_carbonstate_vars%livecrootc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livecrootc_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%livecrootc_storage_patch(i) /= spval .and. .not. isnan(this%livecrootc_storage_patch(i)) ) then - this%livecrootc_storage_patch(i) = c12_carbonstate_vars%livecrootc_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livecrootc_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%livecrootc_storage_patch(i) /= spval .and. .not. isnan(this%livecrootc_storage_patch(i)) ) then + this%livecrootc_storage_patch(i) = c12_carbonstate_vars%livecrootc_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='livecrootc_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%livecrootc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%livecrootc_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%livecrootc_xfer_patch(i) /= spval .and. .not. isnan(this%livecrootc_xfer_patch(i)) ) then - this%livecrootc_xfer_patch(i) = c12_carbonstate_vars%livecrootc_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='livecrootc_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%livecrootc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%livecrootc_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%livecrootc_xfer_patch(i) /= spval .and. .not. isnan(this%livecrootc_xfer_patch(i)) ) then + this%livecrootc_xfer_patch(i) = c12_carbonstate_vars%livecrootc_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadcrootc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%deadcrootc_patch(i) /= spval .and. .not. isnan(this%deadcrootc_patch(i)) ) then - this%deadcrootc_patch(i) = c12_carbonstate_vars%deadcrootc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadcrootc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%deadcrootc_patch(i) /= spval .and. .not. isnan(this%deadcrootc_patch(i)) ) then + this%deadcrootc_patch(i) = c12_carbonstate_vars%deadcrootc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%deadcrootc_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%deadcrootc_storage_patch(i) /= spval .and. .not. isnan(this%deadcrootc_storage_patch(i)) ) then - this%deadcrootc_storage_patch(i) = c12_carbonstate_vars%deadcrootc_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%deadcrootc_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%deadcrootc_storage_patch(i) /= spval .and. .not. isnan(this%deadcrootc_storage_patch(i)) ) then + this%deadcrootc_storage_patch(i) = c12_carbonstate_vars%deadcrootc_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog) 'initializing this%deadcrootc_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%deadcrootc_xfer_patch(i) /= spval .and. .not. isnan(this%deadcrootc_xfer_patch(i)) ) then - this%deadcrootc_xfer_patch(i) = c12_carbonstate_vars%deadcrootc_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='deadcrootc_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%deadcrootc_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog) 'initializing this%deadcrootc_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%deadcrootc_xfer_patch(i) /= spval .and. .not. isnan(this%deadcrootc_xfer_patch(i)) ) then + this%deadcrootc_xfer_patch(i) = c12_carbonstate_vars%deadcrootc_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='gresp_storage_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%gresp_storage_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%gresp_storage_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%gresp_storage_patch(i) /= spval .and. .not. isnan(this%gresp_storage_patch(i)) ) then - this%gresp_storage_patch(i) = c12_carbonstate_vars%gresp_storage_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='gresp_storage_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%gresp_storage_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%gresp_storage_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%gresp_storage_patch(i) /= spval .and. .not. isnan(this%gresp_storage_patch(i)) ) then + this%gresp_storage_patch(i) = c12_carbonstate_vars%gresp_storage_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='gresp_xfer_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%gresp_xfer_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%gresp_xfer_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%gresp_xfer_patch(i) /= spval .and. .not. isnan(this%gresp_xfer_patch(i)) ) then - this%gresp_xfer_patch(i) = c12_carbonstate_vars%gresp_xfer_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='gresp_xfer_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%gresp_xfer_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%gresp_xfer_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%gresp_xfer_patch(i) /= spval .and. .not. isnan(this%gresp_xfer_patch(i)) ) then + this%gresp_xfer_patch(i) = c12_carbonstate_vars%gresp_xfer_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='cpool_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%cpool_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%cpool_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%cpool_patch(i) /= spval .and. .not. isnan(this%cpool_patch(i)) ) then - this%cpool_patch(i) = c12_carbonstate_vars%cpool_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='cpool_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%cpool_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%cpool_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%cpool_patch(i) /= spval .and. .not. isnan(this%cpool_patch(i)) ) then + this%cpool_patch(i) = c12_carbonstate_vars%cpool_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='xsmrpool_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%xsmrpool_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%xsmrpool_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%xsmrpool_patch(i) /= spval .and. .not. isnan(this%xsmrpool_patch(i)) ) then - this%xsmrpool_patch(i) = c12_carbonstate_vars%xsmrpool_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='xsmrpool_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%xsmrpool_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%xsmrpool_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%xsmrpool_patch(i) /= spval .and. .not. isnan(this%xsmrpool_patch(i)) ) then + this%xsmrpool_patch(i) = c12_carbonstate_vars%xsmrpool_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='pft_ctrunc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%ctrunc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%ctrunc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%ctrunc_patch(i) /= spval .and. .not. isnan(this%ctrunc_patch(i)) ) then - this%ctrunc_patch(i) = c12_carbonstate_vars%ctrunc_patch(i) * c14ratio - endif - end do + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='pft_ctrunc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%ctrunc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%ctrunc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%ctrunc_patch(i) /= spval .and. .not. isnan(this%ctrunc_patch(i)) ) then + this%ctrunc_patch(i) = c12_carbonstate_vars%ctrunc_patch(i) * c14ratio + endif + end do + end if end if - end if - if ( carbon_type == 'c14') then - call restartvar(ncid=ncid, flag=flag, varname='totvegc_14', xtype=ncd_double, & - dim1name='pft', long_name='', units='', & - interpinic_flag='interp', readvar=readvar, data=this%totvegc_patch) - if (flag=='read' .and. .not. readvar) then - write(iulog,*) 'initializing this%totvegc_patch with atmospheric c14 value' - do i = bounds%begp,bounds%endp - if (this%totvegc_patch(i) /= spval .and. .not. isnan(this%totvegc_patch(i)) ) then - this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c14ratio - endif - end do - end if - endif + if ( carbon_type == 'c14') then + call restartvar(ncid=ncid, flag=flag, varname='totvegc_14', xtype=ncd_double, & + dim1name='pft', long_name='', units='', & + interpinic_flag='interp', readvar=readvar, data=this%totvegc_patch) + if (flag=='read' .and. .not. readvar) then + write(iulog,*) 'initializing this%totvegc_patch with atmospheric c14 value' + do i = bounds%begp,bounds%endp + if (this%totvegc_patch(i) /= spval .and. .not. isnan(this%totvegc_patch(i)) ) then + this%totvegc_patch(i) = c12_carbonstate_vars%totvegc_patch(i) * c14ratio + endif + end do + end if + endif - !-------------------------------- - ! patch prognostic crop variables - !-------------------------------- + !-------------------------------- + ! patch prognostic crop variables + !-------------------------------- - if (crop_prog) then - call restartvar(ncid=ncid, flag=flag, varname='grainc', xtype=ncd_double, & - dim1name='pft', long_name='grain C', units='gC/m2', & - interpinic_flag='interp', readvar=readvar, data=this%grainc_patch) + if (crop_prog) then + call restartvar(ncid=ncid, flag=flag, varname='grainc', xtype=ncd_double, & + dim1name='pft', long_name='grain C', units='gC/m2', & + interpinic_flag='interp', readvar=readvar, data=this%grainc_patch) - call restartvar(ncid=ncid, flag=flag, varname='grainc_storage', xtype=ncd_double, & - dim1name='pft', long_name='grain C storage', units='gC/m2', & - interpinic_flag='interp', readvar=readvar, data=this%grainc_storage_patch) + call restartvar(ncid=ncid, flag=flag, varname='grainc_storage', xtype=ncd_double, & + dim1name='pft', long_name='grain C storage', units='gC/m2', & + interpinic_flag='interp', readvar=readvar, data=this%grainc_storage_patch) - call restartvar(ncid=ncid, flag=flag, varname='grainc_xfer', xtype=ncd_double, & - dim1name='pft', long_name='grain C transfer', units='gC/m2', & - interpinic_flag='interp', readvar=readvar, data=this%grainc_xfer_patch) - end if + call restartvar(ncid=ncid, flag=flag, varname='grainc_xfer', xtype=ncd_double, & + dim1name='pft', long_name='grain C transfer', units='gC/m2', & + interpinic_flag='interp', readvar=readvar, data=this%grainc_xfer_patch) + end if + endif ! .not. use_ed + !-------------------------------- ! column carbon state variables !-------------------------------- @@ -2721,48 +2765,50 @@ subroutine SetValues ( this, & integer :: fi,i,j,k,l ! loop index !------------------------------------------------------------------------ - do fi = 1,num_patch - i = filter_patch(fi) - - this%leafc_patch(i) = value_patch - this%leafc_storage_patch(i) = value_patch - this%leafc_xfer_patch(i) = value_patch - this%frootc_patch(i) = value_patch - this%frootc_storage_patch(i) = value_patch - this%frootc_xfer_patch(i) = value_patch - this%livestemc_patch(i) = value_patch - this%livestemc_storage_patch(i) = value_patch - this%livestemc_xfer_patch(i) = value_patch - this%deadstemc_patch(i) = value_patch - this%deadstemc_storage_patch(i) = value_patch - this%deadstemc_xfer_patch(i) = value_patch - this%livecrootc_patch(i) = value_patch - this%livecrootc_storage_patch(i) = value_patch - this%livecrootc_xfer_patch(i) = value_patch - this%deadcrootc_patch(i) = value_patch - this%deadcrootc_storage_patch(i) = value_patch - this%deadcrootc_xfer_patch(i) = value_patch - this%gresp_storage_patch(i) = value_patch - this%gresp_xfer_patch(i) = value_patch - this%cpool_patch(i) = value_patch - this%xsmrpool_patch(i) = value_patch - this%ctrunc_patch(i) = value_patch - this%dispvegc_patch(i) = value_patch - this%storvegc_patch(i) = value_patch - this%totvegc_patch(i) = value_patch - this%totpftc_patch(i) = value_patch - this%woodc_patch(i) = value_patch - - end do - if ( crop_prog ) then + if ( .not. use_ed ) then do fi = 1,num_patch i = filter_patch(fi) - this%grainc_patch(i) = value_patch - this%grainc_storage_patch(i) = value_patch - this%grainc_xfer_patch(i) = value_patch - end do - endif + this%leafc_patch(i) = value_patch + this%leafc_storage_patch(i) = value_patch + this%leafc_xfer_patch(i) = value_patch + this%frootc_patch(i) = value_patch + this%frootc_storage_patch(i) = value_patch + this%frootc_xfer_patch(i) = value_patch + this%livestemc_patch(i) = value_patch + this%livestemc_storage_patch(i) = value_patch + this%livestemc_xfer_patch(i) = value_patch + this%deadstemc_patch(i) = value_patch + this%deadstemc_storage_patch(i) = value_patch + this%deadstemc_xfer_patch(i) = value_patch + this%livecrootc_patch(i) = value_patch + this%livecrootc_storage_patch(i) = value_patch + this%livecrootc_xfer_patch(i) = value_patch + this%deadcrootc_patch(i) = value_patch + this%deadcrootc_storage_patch(i) = value_patch + this%deadcrootc_xfer_patch(i) = value_patch + this%gresp_storage_patch(i) = value_patch + this%gresp_xfer_patch(i) = value_patch + this%cpool_patch(i) = value_patch + this%xsmrpool_patch(i) = value_patch + this%ctrunc_patch(i) = value_patch + this%dispvegc_patch(i) = value_patch + this%storvegc_patch(i) = value_patch + this%totvegc_patch(i) = value_patch + this%totpftc_patch(i) = value_patch + this%woodc_patch(i) = value_patch + + end do + if ( crop_prog ) then + do fi = 1,num_patch + i = filter_patch(fi) + this%grainc_patch(i) = value_patch + this%grainc_storage_patch(i) = value_patch + this%grainc_xfer_patch(i) = value_patch + end do + endif + endif ! .not. use_ed + do fi = 1,num_column i = filter_column(fi) this%cwdc_col(i) = value_column @@ -2858,6 +2904,8 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil ! calculate patch -level summary of carbon state + if (use_ed) return + do fp = 1,num_soilp p = filter_soilp(fp) @@ -2928,6 +2976,7 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil this%totvegc_patch(bounds%begp:bounds%endp), & this%totvegc_col(bounds%begc:bounds%endc)) + ! column level summary @@ -3046,6 +3095,7 @@ subroutine Summary(this, bounds, num_soilc, filter_soilc, num_soilp, filter_soil end if end do + ! coarse woody debris carbon do fc = 1,num_soilc c = filter_soilc(fc) diff --git a/components/clm/src/biogeochem/CNDecompCascadeCNMod.F90 b/components/clm/src/biogeochem/CNDecompCascadeCNMod.F90 index c4e9ec95e503..c6ca6d3fa675 100644 --- a/components/clm/src/biogeochem/CNDecompCascadeCNMod.F90 +++ b/components/clm/src/biogeochem/CNDecompCascadeCNMod.F90 @@ -888,7 +888,7 @@ subroutine decomp_rate_constants_cn(bounds, & deallocate(fr) else - + ! calculate rate constant scalar for soil temperature ! assuming that the base rate constants are assigned for non-moisture ! limiting conditions at 25 C. @@ -1047,9 +1047,11 @@ subroutine decomp_rate_constants_cn(bounds, & if ( decomp_cascade_con%spinup_factor(i_litr2) > 1._r8) decomp_k(c,j,i_litr2) = decomp_k(c,j,i_litr2) & / cnstate_vars%scalaravg_col(c) if ( decomp_cascade_con%spinup_factor(i_litr3) > 1._r8) decomp_k(c,j,i_litr3) = decomp_k(c,j,i_litr3) & - / cnstate_vars%scalaravg_col(c) - if ( decomp_cascade_con%spinup_factor(i_cwd) > 1._r8) decomp_k(c,j,i_cwd) = decomp_k(c,j,i_cwd) & - / cnstate_vars%scalaravg_col(c) + / cnstate_vars%scalaravg_col(c) + if ( .not. use_ed ) then + if ( decomp_cascade_con%spinup_factor(i_cwd) > 1._r8) decomp_k(c,j,i_cwd) = decomp_k(c,j,i_cwd) & + / cnstate_vars%scalaravg_col(c) + endif if ( decomp_cascade_con%spinup_factor(i_soil1) > 1._r8) decomp_k(c,j,i_soil1) = decomp_k(c,j,i_soil1) & / cnstate_vars%scalaravg_col(c) if ( decomp_cascade_con%spinup_factor(i_soil2) > 1._r8) decomp_k(c,j,i_soil2) = decomp_k(c,j,i_soil2) & diff --git a/components/clm/src/biogeochem/EDBGCDynMod.F90 b/components/clm/src/biogeochem/FatesBGCDynMod.F90 similarity index 52% rename from components/clm/src/biogeochem/EDBGCDynMod.F90 rename to components/clm/src/biogeochem/FatesBGCDynMod.F90 index 5866f0da42c8..e72aa8374086 100644 --- a/components/clm/src/biogeochem/EDBGCDynMod.F90 +++ b/components/clm/src/biogeochem/FatesBGCDynMod.F90 @@ -1,8 +1,8 @@ -module EDBGCDynMod +module FatesBGCDynMod ! ============================================================================================== ! This module creates a pathway to call the belowground biogeochemistry - ! code as driven by the ED vegetation model but bypassing the aboveground + ! code as driven by the FATES vegetation model but bypassing the aboveground ! CN vegetation code. It is modeled after the CNDriverMod in its call sequence and ! functionality. ! ============================================================================================== @@ -14,7 +14,7 @@ module EDBGCDynMod implicit none - public :: EDBGCDyn + public :: FatesBGCDyn character(len=*), parameter, private :: sourcefile = & __FILE__ @@ -23,14 +23,15 @@ module EDBGCDynMod !----------------------------------------------------------------------- - subroutine EDBGCDyn(bounds, & + subroutine FatesBGCDyn(bounds, & num_soilc, filter_soilc, num_soilp, filter_soilp, & carbonflux_vars, carbonstate_vars, cnstate_vars, & c13_carbonflux_vars, c13_carbonstate_vars, & c14_carbonflux_vars, c14_carbonstate_vars, & canopystate_vars, soilstate_vars, temperature_vars, & ch4_vars, nitrogenflux_vars, nitrogenstate_vars, & - phosphorusstate_vars, phosphorusflux_vars) + phosphorusstate_vars, phosphorusflux_vars, & + clm_fates) use clm_varctl , only : use_c13, use_c14, use_ed use decompMod , only : bounds_type @@ -54,6 +55,7 @@ subroutine EDBGCDyn(bounds, & use PhosphorusStateType , only : phosphorusstate_type use PhosphorusFluxType , only : phosphorusflux_type use CNDecompCascadeConType , only : decomp_cascade_con + use CLMFatesInterfaceMod , only : hlm_fates_interface_type ! ! !ARGUMENTS: @@ -77,7 +79,8 @@ subroutine EDBGCDyn(bounds, & type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars type(phosphorusstate_type), intent(inout) :: phosphorusstate_vars type(phosphorusflux_type) , intent(inout) :: phosphorusflux_vars - + type(hlm_fates_interface_type),intent(inout) :: clm_fates + ! ! !LOCAL VARIABLES: integer :: k,j,fc,c @@ -206,18 +209,18 @@ subroutine EDBGCDyn(bounds, & ! call SoilBiogeochemDecomp() in CLM call t_startf('SoilBiogeochemDecomp') - do k = 1, ndecomp_cascade_transitions - do j = 1,nlevdecomp - do fc = 1,num_soilc - c = filter_soilc(fc) - ! - decomp_cascade_hr_vr(c,j,k) = rf_decomp_cascade(c,j,k) * p_decomp_cpool_loss(c,j,k) - ! - decomp_cascade_ctransfer_vr(c,j,k) = (1._r8 - rf_decomp_cascade(c,j,k)) * p_decomp_cpool_loss(c,j,k) - ! - end do - end do - end do + do k = 1, ndecomp_cascade_transitions + do j = 1,nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + ! + decomp_cascade_hr_vr(c,j,k) = rf_decomp_cascade(c,j,k) * p_decomp_cpool_loss(c,j,k) + ! + decomp_cascade_ctransfer_vr(c,j,k) = (1._r8 - rf_decomp_cascade(c,j,k)) * p_decomp_cpool_loss(c,j,k) + ! + end do + end do + end do call t_stopf('SoilBiogeochemDecomp') @@ -228,11 +231,12 @@ subroutine EDBGCDyn(bounds, & call t_startf('BNGCUpdate1') - !! (FATES-INTERF) - !! call clm_fates%UpdateLitterFluxes(carbonflux_vars) - !! cf_soil%decomp_cpools_sourcesink_col(c,j,i_met_lit) = cf_soil%FATES_c_to_litr_lab_c_col(c,j) * dt - !! cf_soil%decomp_cpools_sourcesink_col(c,j,i_cel_lit) = cf_soil%FATES_c_to_litr_cel_c_col(c,j) * dt - !! cf_soil%decomp_cpools_sourcesink_col(c,j,i_lig_lit) = cf_soil%FATES_c_to_litr_lig_c_col(c,j) * dt + + ! ------------------------------------------------------- + ! Pass in FATES boundary conditions, ie litter fluxes + ! ------------------------------------------------------- + + call clm_fates%UpdateLitterFluxes(bounds,carbonflux_vars) ! Update all prognostic carbon state variables (except for gap-phase mortality and fire fluxes) @@ -260,45 +264,288 @@ subroutine EDBGCDyn(bounds, & call t_startf('BGCsum') ! Set controls on very low values in critical state variables - ! (FATES-INTERF) Added some new logical filters to prevent + ! Added some new logical filters to prevent ! above ground precision control calculations with use_ed, as well ! bypass on nitrogen calculations call CNPrecisionControl(num_soilc, filter_soilc, num_soilp, filter_soilp, & carbonstate_vars, c13_carbonstate_vars, c14_carbonstate_vars, & nitrogenstate_vars,phosphorusstate_vars) - ! ---------------------------------------------- - ! soilbiogeochem carbon/nitrogen state summary - ! ---------------------------------------------- - call carbonflux_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, 'bulk') - call carbonstate_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) - if ( use_c13 ) then - call c13_carbonflux_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, 'c13') - call c13_carbonstate_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) - end if - if ( use_c14 ) then - call c14_carbonflux_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, 'c14') - call c14_carbonstate_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) - end if - - !call nitrogenflux_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) - !call nitrogenstate_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) - - !call phosphorusflux_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) - !call phosphorusstate_vars%Summary(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp) + call FatesBGCSummary(bounds, num_soilc, filter_soilc,carbonflux_vars, carbonstate_vars) + ! ---------------------------------------------- ! calculate balance checks on entire carbon cycle (FATES + BGC) ! ---------------------------------------------- -!! call clm_fates%wrap_bgc_summary(nc, soilbiogeochem_carbonflux_inst, & -!! soilbiogeochem_carbonstate_inst) + call clm_fates%wrap_bgc_summary( bounds, carbonflux_vars, carbonstate_vars) call t_stopf('BGCsum') end associate - end subroutine EDBGCDyn + end subroutine FatesBGCDyn + + ! ====================================================================================== + + subroutine FatesBGCSummary(bounds, num_soilc, filter_soilc, carbonflux_vars, carbonstate_vars ) + + use decompMod , only : bounds_type + use CNCarbonFluxType , only : carbonflux_type + use CNCarbonStateType , only : carbonstate_type + use clm_varcon , only : dzsoi_decomp, zisoi + use clm_varpar , only : nlevdecomp, ndecomp_cascade_transitions, ndecomp_pools + use CNDecompCascadeConType , only : decomp_cascade_con + + type(bounds_type) , intent(in) :: bounds + integer , intent(in) :: num_soilc ! number of soil columns in filter + integer , intent(in) :: filter_soilc(:) ! filter for soil columns + type(carbonflux_type) , intent(inout) :: carbonflux_vars + type(carbonstate_type) , intent(inout) :: carbonstate_vars + + real(r8) :: maxdepth + integer :: k,j,fc,c,l + + + ! ------------------------------------------------------------------------------------ + ! + ! Summarize Carbon Fluxes + ! + ! ------------------------------------------------------------------------------------ + + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%som_c_leached_col(c) = 0._r8 + end do + + ! vertically integrate HR and decomposition cascade fluxes + do k = 1, ndecomp_cascade_transitions + do j = 1,nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%decomp_cascade_hr_col(c,k) = & + carbonflux_vars%decomp_cascade_hr_col(c,k) + & + carbonflux_vars%decomp_cascade_hr_vr_col(c,j,k) * dzsoi_decomp(j) + + carbonflux_vars%decomp_cascade_ctransfer_col(c,k) = & + carbonflux_vars%decomp_cascade_ctransfer_col(c,k) + & + carbonflux_vars%decomp_cascade_ctransfer_vr_col(c,j,k) * dzsoi_decomp(j) + end do + end do + end do + + ! total heterotrophic respiration, vertically resolved (HR) + do j = 1,nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%hr_vr_col(c,j) = 0._r8 + end do + end do + do k = 1, ndecomp_cascade_transitions + do j = 1,nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%hr_vr_col(c,j) = & + carbonflux_vars%hr_vr_col(c,j) + & + carbonflux_vars%decomp_cascade_hr_vr_col(c,j,k) + end do + end do + end do + + ! add up all vertical transport tendency terms and calculate total som leaching loss as the sum of these + do l = 1, ndecomp_pools + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%decomp_cpools_leached_col(c,l) = 0._r8 + end do + do j = 1, nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%decomp_cpools_leached_col(c,l) = carbonflux_vars%decomp_cpools_leached_col(c,l) + & + carbonflux_vars%decomp_cpools_transport_tendency_col(c,j,l) * dzsoi_decomp(j) + end do + end do + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%som_c_leached_col(c) = carbonflux_vars%som_c_leached_col(c) + & + carbonflux_vars%decomp_cpools_leached_col(c,l) + end do + end do + + ! soil organic matter heterotrophic respiration + associate(is_soil => decomp_cascade_con%is_soil) ! TRUE => pool is a soil pool + do k = 1, ndecomp_cascade_transitions + if ( is_soil(decomp_cascade_con%cascade_donor_pool(k)) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%somhr_col(c) = carbonflux_vars%somhr_col(c) + & + carbonflux_vars%decomp_cascade_hr_col(c,k) + end do + end if + end do + end associate + + ! litter heterotrophic respiration (LITHR) + associate(is_litter => decomp_cascade_con%is_litter) ! TRUE => pool is a litter pool + do k = 1, ndecomp_cascade_transitions + if ( is_litter(decomp_cascade_con%cascade_donor_pool(k)) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonflux_vars%lithr_col(c) = carbonflux_vars%lithr_col(c) + & + carbonflux_vars%decomp_cascade_hr_col(c,k) + end do + end if + end do + end associate + + ! total heterotrophic respiration (HR) + do fc = 1,num_soilc + c = filter_soilc(fc) + + carbonflux_vars%hr_col(c) = & + carbonflux_vars%lithr_col(c) + & + carbonflux_vars%somhr_col(c) + + end do + + + ! ------------------------------------------------------------------------------------ + ! + ! Summarize Carbon States + ! + ! ------------------------------------------------------------------------------------ + + ! vertically integrate each of the decomposing C pools + do l = 1, ndecomp_pools + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%decomp_cpools_col(c,l) = 0._r8 + end do + end do + do l = 1, ndecomp_pools + do j = 1, nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%decomp_cpools_col(c,l) = & + carbonstate_vars%decomp_cpools_col(c,l) + & + carbonstate_vars%decomp_cpools_vr_col(c,j,l) * dzsoi_decomp(j) + end do + end do + end do + + if ( nlevdecomp > 1) then + + ! vertically integrate each of the decomposing C pools to 1 meter + maxdepth = 1._r8 + do l = 1, ndecomp_pools + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%decomp_cpools_1m_col(c,l) = 0._r8 + end do + end do + do l = 1, ndecomp_pools + do j = 1, nlevdecomp + if ( zisoi(j) <= maxdepth ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%decomp_cpools_1m_col(c,l) = & + carbonstate_vars%decomp_cpools_1m_col(c,l) + & + carbonstate_vars%decomp_cpools_vr_col(c,j,l) * dzsoi_decomp(j) + end do + elseif ( zisoi(j-1) < maxdepth ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%decomp_cpools_1m_col(c,l) = & + carbonstate_vars%decomp_cpools_1m_col(c,l) + & + carbonstate_vars%decomp_cpools_vr_col(c,j,l) * (maxdepth - zisoi(j-1)) + end do + endif + end do + end do + + endif + + ! truncation carbon + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%ctrunc_col(c) = 0._r8 + end do + do j = 1, nlevdecomp + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%ctrunc_col(c) = & + carbonstate_vars%ctrunc_col(c) + & + carbonstate_vars%ctrunc_vr_col(c,j) * dzsoi_decomp(j) + end do + end do + + ! total litter carbon in the top meter (TOTLITC_1m) + if ( nlevdecomp > 1) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totlitc_1m_col(c) = 0._r8 + end do + do l = 1, ndecomp_pools + if ( decomp_cascade_con%is_litter(l) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totlitc_1m_col(c) = carbonstate_vars%totlitc_1m_col(c) + & + carbonstate_vars%decomp_cpools_1m_col(c,l) + end do + endif + end do + end if + + ! total soil organic matter carbon in the top meter (TOTSOMC_1m) + if ( nlevdecomp > 1) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totsomc_1m_col(c) = 0._r8 + end do + do l = 1, ndecomp_pools + if ( decomp_cascade_con%is_soil(l) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totsomc_1m_col(c) = carbonstate_vars%totsomc_1m_col(c) + & + carbonstate_vars%decomp_cpools_1m_col(c,l) + end do + end if + end do + end if + + ! total litter carbon (TOTLITC) + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totlitc_col(c) = 0._r8 + end do + do l = 1, ndecomp_pools + if ( decomp_cascade_con%is_litter(l) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totlitc_col(c) = carbonstate_vars%totlitc_col(c) + & + carbonstate_vars%decomp_cpools_col(c,l) + end do + endif + end do + + ! total soil organic matter carbon (TOTSOMC) + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totsomc_col(c) = 0._r8 + end do + do l = 1, ndecomp_pools + if ( decomp_cascade_con%is_soil(l) ) then + do fc = 1,num_soilc + c = filter_soilc(fc) + carbonstate_vars%totsomc_col(c) = carbonstate_vars%totsomc_col(c) + & + carbonstate_vars%decomp_cpools_col(c,l) + end do + end if + end do + + return + end subroutine FatesBGCSummary + -end module EDBGCDynMod +end module FatesBGCDynMod diff --git a/components/clm/src/biogeophys/CanopyFluxesMod.F90 b/components/clm/src/biogeophys/CanopyFluxesMod.F90 index a182a9494fbf..af7b422790e4 100644 --- a/components/clm/src/biogeophys/CanopyFluxesMod.F90 +++ b/components/clm/src/biogeophys/CanopyFluxesMod.F90 @@ -42,6 +42,7 @@ module CanopyFluxesMod use PatchType , only : pft use PhosphorusStateType , only : phosphorusstate_type use CNNitrogenStateType , only : nitrogenstate_type + use CLMFatesInterfaceMod , only : hlm_fates_interface_type ! ! !PUBLIC TYPES: implicit none @@ -66,7 +67,8 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & atm2lnd_vars, canopystate_vars, cnstate_vars, energyflux_vars, & frictionvel_vars, soilstate_vars, solarabs_vars, surfalb_vars, & temperature_vars, waterflux_vars, waterstate_vars, ch4_vars, photosyns_vars, & - soil_water_retention_curve, nitrogenstate_vars, phosphorusstate_vars) + soil_water_retention_curve, nitrogenstate_vars, phosphorusstate_vars, & + clm_fates) ! ! !DESCRIPTION: ! 1. Calculates the leaf temperature: @@ -129,7 +131,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars type(phosphorusstate_type), intent(inout) :: phosphorusstate_vars - + type(hlm_fates_interface_type) , intent(inout) :: clm_fates ! ! !LOCAL VARIABLES: real(r8), parameter :: btran0 = 0.0_r8 ! initial value @@ -483,9 +485,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & if (use_ed) then - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) -!! call clm_fates%prep_canopyfluxes(nc, fn, filterp, photosyns_inst) + call clm_fates%prep_canopyfluxes( bounds ) end if @@ -561,10 +561,8 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! -------------------------------------------------------------------------- if(use_ed)then - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) -!! call clm_fates%wrap_btran(nc, fn, filterc_tmp(1:fn), soilstate_inst, waterstate_inst, & -!! temperature_inst, energyflux_inst, soil_water_retention_curve) + call clm_fates%wrap_btran(bounds, fn, filterc_tmp(1:fn), soilstate_vars, waterstate_vars, & + temperature_vars, energyflux_vars, soil_water_retention_curve) else @@ -774,7 +772,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! Use pft parameter for leaf characteristic width ! dleaf_patch if this is not an ed patch. ! Otherwise, the value has already been loaded - ! during the FATES dynamics call + ! during the FATES dynamics and/or initialization call if(.not.pft%is_fates(p)) then dleaf_patch(p) = dleaf(pft%itype(p)) end if @@ -851,12 +849,10 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & if ( use_ed ) then - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) -!! call clm_fates%wrap_photosynthesis(nc, bounds, fn, filterp(1:fn), & -!! svpts(begp:endp), eah(begp:endp), o2(begp:endp), & -!! co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), & -!! atm2lnd_inst, temperature_inst, canopystate_inst, photosyns_inst) + call clm_fates%wrap_photosynthesis(bounds, fn, filterp(1:fn), & + svpts(begp:endp), eah(begp:endp), o2(begp:endp), & + co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), & + atm2lnd_vars, temperature_vars, canopystate_vars, photosyns_vars) else ! not use_ed @@ -1201,11 +1197,9 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & end do if ( use_ed ) then - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) -!! call clm_fates%wrap_accumulatefluxes(nc,fn,filterp(1:fn)) -!! call clm_fates%wrap_hydraulics_drive(bounds,nc,soilstate_inst, & -!! waterstate_inst,waterflux_inst,solarabs_inst,energyflux_inst) + call clm_fates%wrap_accumulatefluxes(bounds,fn,filterp(1:fn)) + call clm_fates%wrap_hydraulics_drive(bounds,soilstate_vars, & + waterstate_vars,waterflux_vars,solarabs_vars,energyflux_vars) else diff --git a/components/clm/src/biogeophys/CanopyTemperatureMod.F90 b/components/clm/src/biogeophys/CanopyTemperatureMod.F90 index 126d432c1c2d..54455cb59c5b 100644 --- a/components/clm/src/biogeophys/CanopyTemperatureMod.F90 +++ b/components/clm/src/biogeophys/CanopyTemperatureMod.F90 @@ -17,7 +17,8 @@ module CanopyTemperatureMod use decompMod , only : bounds_type use abortutils , only : endrun use clm_varctl , only : iulog, use_ed - use PhotosynthesisMod , only : Photosynthesis, PhotosynthesisTotal, Fractionation + use PhotosynthesisMod , only : Photosynthesis, PhotosynthesisTotal, Fractionation + use CLMFatesInterfaceMod , only : hlm_fates_interface_type use SurfaceResistanceMod , only : calc_soilevap_stress use EcophysConType , only : ecophyscon use atm2lndType , only : atm2lnd_type @@ -46,7 +47,8 @@ module CanopyTemperatureMod subroutine CanopyTemperature(bounds, & num_nolakec, filter_nolakec, num_nolakep, filter_nolakep, & atm2lnd_vars, canopystate_vars, soilstate_vars, frictionvel_vars, & - waterstate_vars, waterflux_vars, energyflux_vars, temperature_vars) + waterstate_vars, waterflux_vars, energyflux_vars, temperature_vars, & + clm_fates) ! ! !DESCRIPTION: ! This is the main subroutine to execute the calculation of leaf temperature @@ -91,6 +93,7 @@ subroutine CanopyTemperature(bounds, & type(waterflux_type) , intent(inout) :: waterflux_vars type(energyflux_type) , intent(inout) :: energyflux_vars type(temperature_type) , intent(inout) :: temperature_vars + type(hlm_fates_interface_type) , intent(inout) :: clm_fates ! ! !LOCAL VARIABLES: integer :: g,l,c,p ! indices @@ -398,8 +401,7 @@ subroutine CanopyTemperature(bounds, & ! enabled simultaneously with FATES, we will ! have to apply a filter here. if(use_ed) then - ! (FATES-INTERF) - ! call clm_fates%TransferZ0mDisp(bounds,frictionvel_inst,canopystate_inst) + call clm_fates%TransferZ0mDisp(bounds,frictionvel_vars,canopystate_vars) end if do fp = 1,num_nolakep diff --git a/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 b/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 index dc2e7ae1c9d9..713504c05262 100644 --- a/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 +++ b/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 @@ -40,7 +40,8 @@ subroutine HydrologyNoDrainage(bounds, & atm2lnd_vars, soilstate_vars, energyflux_vars, temperature_vars, & waterflux_vars, waterstate_vars, & soilhydrology_vars, aerosol_vars, & - soil_water_retention_curve, betrtracer_vars, tracerflux_vars, tracerstate_vars) + soil_water_retention_curve, betrtracer_vars, tracerflux_vars, tracerstate_vars, & + clm_fates) ! ! !DESCRIPTION: ! This is the main subroutine to execute the calculation of soil/snow @@ -61,7 +62,7 @@ subroutine HydrologyNoDrainage(bounds, & use landunit_varcon , only : istice, istwet, istsoil, istice_mec, istcrop, istdlak use column_varcon , only : icol_roof, icol_road_imperv, icol_road_perv, icol_sunwall use column_varcon , only : icol_shadewall - use clm_varctl , only : use_cn, use_betr + use clm_varctl , only : use_cn, use_betr, use_ed use clm_varpar , only : nlevgrnd, nlevsno, nlevsoi, nlevurb use clm_time_manager , only : get_step_size, get_nstep use SnowHydrologyMod , only : SnowCompaction, CombineSnowLayers, DivideSnowLayers @@ -77,6 +78,7 @@ subroutine HydrologyNoDrainage(bounds, & use clm_varctl , only : use_vsfm use SoilHydrologyMod , only : DrainageVSFM use SoilWaterMovementMod, only : Compute_EffecRootFrac_And_VertTranSink_Default + use CLMFatesInterfaceMod , only : hlm_fates_interface_type ! ! !ARGUMENTS: type(bounds_type) , intent(in) :: bounds @@ -102,6 +104,7 @@ subroutine HydrologyNoDrainage(bounds, & type(betrtracer_type) , intent(in) :: betrtracer_vars ! betr configuration information type(tracerflux_type) , intent(inout) :: tracerflux_vars ! tracer flux type(tracerstate_type) , intent(inout) :: tracerstate_vars ! tracer state variables data structure + type(hlm_fates_interface_type) , intent(inout) :: clm_fates ! ! !LOCAL VARIABLES: integer :: g,l,c,j,fc ! indices @@ -215,8 +218,8 @@ subroutine HydrologyNoDrainage(bounds, & filter_hydrologyc, soilstate_vars, waterflux_vars) ! If FATES plant hydraulics is turned on, over-ride default transpiration sink calculation - ! (INTERF-FATES) - !if( use_ed ) call clm_fates%ComputeRootSoilFlux(bounds, num_hydrologyc, filter_hydrologyc, soilstate_inst, waterflux_inst) + if( use_ed ) call clm_fates%ComputeRootSoilFlux(bounds, num_hydrologyc, filter_hydrologyc, & + soilstate_vars, waterflux_vars) call SoilWater(bounds, num_hydrologyc, filter_hydrologyc, num_urbanc, filter_urbanc, & soilhydrology_vars, soilstate_vars, waterflux_vars, waterstate_vars, temperature_vars, & @@ -407,7 +410,7 @@ subroutine HydrologyNoDrainage(bounds, & end do end do - if (use_cn) then + if (use_cn .or. use_ed) then ! Update soilpsi. ! ZMS: Note this could be merged with the following loop updating smp_l in the future. do j = 1, nlevgrnd @@ -433,7 +436,7 @@ subroutine HydrologyNoDrainage(bounds, & end do end if - if (use_cn) then + if (use_cn .or. use_ed) then ! Available soil water up to a depth of 0.05 m. ! Potentially available soil water (=whc) up to a depth of 0.05 m. ! Water content as fraction of whc up to a depth of 0.05 m. diff --git a/components/clm/src/biogeophys/SoilStateType.F90 b/components/clm/src/biogeophys/SoilStateType.F90 index 1ef0af72153d..fa4e91139c2f 100644 --- a/components/clm/src/biogeophys/SoilStateType.F90 +++ b/components/clm/src/biogeophys/SoilStateType.F90 @@ -16,7 +16,7 @@ module SoilStateType use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall, icol_road_perv, icol_road_imperv use clm_varcon , only : zsoi, dzsoi, zisoi, spval use clm_varcon , only : secspday, pc, mu, denh2o, denice, grlnd - use clm_varctl , only : use_cn, use_lch4,use_dynroot + use clm_varctl , only : use_cn, use_lch4,use_dynroot, use_ed use clm_varctl , only : iulog, fsurdat, hist_wrtch4diag use ch4varcon , only : allowlakeprod use LandunitType , only : lun @@ -242,7 +242,7 @@ subroutine InitHistory(this, bounds) ptr_patch=this%root_depth_patch, default='inactive' ) end if - if (use_cn) then + if (use_cn .or. use_ed) then this%soilpsi_col(begc:endc,:) = spval call hist_addfld2d (fname='SOILPSI', units='MPa', type2d='levgrnd', & avgflag='A', long_name='soil water potential in each soil layer', & diff --git a/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 b/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 index 74c1e9240d1a..0d86a7c3e4b9 100644 --- a/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 +++ b/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 @@ -171,7 +171,8 @@ subroutine SurfaceAlbedo(bounds, & num_urbanp , filter_urbanp, & nextsw_cday , declinp1, & aerosol_vars, canopystate_vars, waterstate_vars, & - lakestate_vars, temperature_vars, surfalb_vars) + lakestate_vars, temperature_vars, surfalb_vars, & + clm_fates) ! ! !DESCRIPTION: ! Surface albedo and two-stream fluxes @@ -198,7 +199,7 @@ subroutine SurfaceAlbedo(bounds, & use clm_time_manager , only : get_nstep use abortutils , only : endrun use clm_varctl , only : iulog, subgridflag, use_snicar_frc, use_ed - + use CLMFatesInterfaceMod, only : hlm_fates_interface_type ! ! !ARGUMENTS: @@ -219,6 +220,7 @@ subroutine SurfaceAlbedo(bounds, & type(lakestate_type) , intent(in) :: lakestate_vars type(temperature_type) , intent(in) :: temperature_vars type(surfalb_type) , intent(inout) :: surfalb_vars + type(hlm_fates_interface_type), intent(inout) :: clm_fates ! ! !LOCAL VARIABLES: integer :: i ! index for layers [idx] @@ -914,9 +916,9 @@ subroutine SurfaceAlbedo(bounds, & ! Only perform on vegetated pfts where coszen > 0 if(use_ed)then - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) - + call clm_fates%wrap_canopy_radiation(bounds, & + num_vegsol, filter_vegsol, & + coszen_patch(bounds%begp:bounds%endp), surfalb_vars) else call TwoStream (bounds, filter_vegsol, num_vegsol, & diff --git a/components/clm/src/dyn_subgrid/dynSubgridDriverMod.F90 b/components/clm/src/dyn_subgrid/dynSubgridDriverMod.F90 index f7929feea16b..a4e5a7d36ffc 100644 --- a/components/clm/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/components/clm/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -212,7 +212,7 @@ subroutine dynSubgrid_driver(bounds_proc, & end if if (use_ed) then - call dyn_ED(bounds_clump) ! (FATES-INTERF) Verified (RGK 04-2017) + call dyn_ED(bounds_clump) end if if (create_glacier_mec_landunit) then diff --git a/components/clm/src/fates b/components/clm/src/fates new file mode 160000 index 000000000000..defc5bbb24b1 --- /dev/null +++ b/components/clm/src/fates @@ -0,0 +1 @@ +Subproject commit defc5bbb24b1c8ea9d4c0f097590e3a257965204 diff --git a/components/clm/src/main/clm_driver.F90 b/components/clm/src/main/clm_driver.F90 index fc7b53cafcbd..d1b7dc02dbc2 100644 --- a/components/clm/src/main/clm_driver.F90 +++ b/components/clm/src/main/clm_driver.F90 @@ -65,7 +65,7 @@ module clm_driver use ch4Mod , only : ch4 use DUSTMod , only : DustDryDep, DustEmission use VOCEmissionMod , only : VOCEmission - use EDBGCDynMod , only : EDBGCDyn + use FatesBGCDynMod , only : FatesBGCDyn ! use filterMod , only : setFilters ! @@ -114,6 +114,7 @@ module clm_driver use clm_instMod , only : lnd2glc_vars use clm_instMod , only : soil_water_retention_curve use clm_instMod , only : chemstate_vars + use clm_instMod , only : clm_fates use betr_initializeMod , only : betrtracer_vars use betr_initializeMod , only : tracercoeff_vars use betr_initializeMod , only : tracerflux_vars @@ -338,8 +339,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) call t_stopf('begcnbal') end if - ! (FATES-INTERF) Initiate limited carbon balance on below ground C BGC? - end do !$OMP END PARALLEL DO @@ -476,9 +475,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) ! over the patch index range defined by bounds_clump%begp:bounds_proc%endp if(use_ed) then - ! (FATES-INTERF) - ! call clm_fates%wrap_sunfrac(nc,atm2lnd_inst, canopystate_inst) - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) + call clm_fates%wrap_sunfrac(bounds_clump,atm2lnd_vars, canopystate_vars) else call CanopySunShadeFractions(filter(nc)%num_nourbanp, filter(nc)%nourbanp, & atm2lnd_vars, surfalb_vars, canopystate_vars, & @@ -514,7 +511,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) filter(nc)%num_nolakec, filter(nc)%nolakec, & filter(nc)%num_nolakep, filter(nc)%nolakep, & atm2lnd_vars, canopystate_vars, soilstate_vars, frictionvel_vars, & - waterstate_vars, waterflux_vars, energyflux_vars, temperature_vars) + waterstate_vars, waterflux_vars, energyflux_vars, temperature_vars, & + clm_fates) call t_stopf('bgp1') ! ============================================================================ @@ -543,7 +541,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) atm2lnd_vars, canopystate_vars, cnstate_vars, energyflux_vars, & frictionvel_vars, soilstate_vars, solarabs_vars, surfalb_vars, & temperature_vars, waterflux_vars, waterstate_vars, ch4_vars, photosyns_vars, & - soil_water_retention_curve, nitrogenstate_vars,phosphorusstate_vars) + soil_water_retention_curve, nitrogenstate_vars,phosphorusstate_vars, & + clm_fates) call t_stopf('canflux') ! Fluxes for all urban landunits @@ -655,7 +654,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) filter(nc)%num_nosnowc, filter(nc)%nosnowc, & atm2lnd_vars, soilstate_vars, energyflux_vars, temperature_vars, & waterflux_vars, waterstate_vars, soilhydrology_vars, aerosol_vars, & - soil_water_retention_curve, betrtracer_vars, tracerflux_vars, tracerstate_vars) + soil_water_retention_curve, betrtracer_vars, tracerflux_vars, & + tracerstate_vars, clm_fates) ! Calculate column-integrated aerosol masses, and ! mass concentrations for radiative calculations and output @@ -926,51 +926,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) end if ! end of if-use_cn - else ! use_ed - - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) - - - if ( is_beg_curr_day() ) then ! run ED at the start of each day - - if ( masterproc ) then - write(iulog,*) 'clm: calling FATES model ', get_nstep() - end if - -!! call clm_fates%dynamics_driv( nc, bounds_clump, & -!! atm2lnd_inst, soilstate_inst, temperature_inst, & -!! waterstate_inst, canopystate_inst, soilbiogeochem_carbonflux_inst,& -!! frictionvel_inst) - - ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a - ! call to reweight_wrapup, if it's needed at all. - ! (FATES-INTERF) Note that setFilters is commented out - !! call setFilters( bounds_clump, glc_behavior ) - - end if - end if ! end of if-use_ed - ! ------------------------------------------------------------------------------ - ! Perform reduced capacity soil-bgc only calculations when FATES/ED is on - ! ------------------------------------------------------------------------------ - if ( use_ed ) then - - ! (FATES-INTERF) put error call, flag for development - call endrun(msg='FATES inoperable'//errMsg(__FILE__, __LINE__)) - - call EDBGCDyn(bounds_clump, & - filter(nc)%num_soilc, filter(nc)%soilc, & - filter(nc)%num_soilp, filter(nc)%soilp, & - carbonflux_vars, carbonstate_vars, cnstate_vars, & - c13_carbonflux_vars, c13_carbonstate_vars, & - c14_carbonflux_vars, c14_carbonstate_vars, & - canopystate_vars, soilstate_vars, temperature_vars, & - ch4_vars, nitrogenflux_vars, nitrogenstate_vars, & - phosphorusstate_vars, phosphorusflux_vars) - - end if + call t_stopf('ecosysdyn') @@ -1064,6 +1022,44 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) tracerstate_vars, tracerflux_vars, betrtracer_vars) endif + ! Execute FATES dynamics + if ( use_ed ) then + if ( is_beg_curr_day() ) then ! run ED at the start of each day + + if ( masterproc ) then + write(iulog,*) 'clm: calling FATES model ', get_nstep() + end if + + call clm_fates%dynamics_driv( bounds_clump, & + atm2lnd_vars, soilstate_vars, temperature_vars, & + waterstate_vars, canopystate_vars, carbonflux_vars, & + frictionvel_vars) + + + ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a + ! call to reweight_wrapup, if it's needed at all. + ! (FATES-INTERF) Note that setFilters is commented out + !! call setFilters( bounds_clump, glc_behavior ) + + end if + + ! ------------------------------------------------------------------------------ + ! Perform reduced capacity soil-bgc only calculations when FATES/ED is on + ! ------------------------------------------------------------------------------ + + call FatesBGCDyn(bounds_clump, & + filter(nc)%num_soilc, filter(nc)%soilc, & + filter(nc)%num_soilp, filter(nc)%soilp, & + carbonflux_vars, carbonstate_vars, cnstate_vars, & + c13_carbonflux_vars, c13_carbonstate_vars, & + c14_carbonflux_vars, c14_carbonstate_vars, & + canopystate_vars, soilstate_vars, temperature_vars, & + ch4_vars, nitrogenflux_vars, nitrogenstate_vars, & + phosphorusstate_vars, phosphorusflux_vars, & + clm_fates) + + end if + ! ============================================================================ ! Check the energy and water balance, also carbon and nitrogen balance ! ============================================================================ @@ -1161,7 +1157,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) filter_inactive_and_active(nc)%urbanp, & nextsw_cday, declinp1, & aerosol_vars, canopystate_vars, waterstate_vars, & - lakestate_vars, temperature_vars, surfalb_vars) + lakestate_vars, temperature_vars, surfalb_vars, & + clm_fates) call t_stopf('surfalb') ! Albedos for urban columns @@ -1344,7 +1341,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, & - tracercoeff_vars, rdate=rdate ) + tracercoeff_vars, clm_fates, rdate=rdate ) call t_stopf('clm_drv_io_wrest') end if diff --git a/components/clm/src/main/clm_initializeMod.F90 b/components/clm/src/main/clm_initializeMod.F90 index 7af4374a5d7d..08d7c0c54eb0 100644 --- a/components/clm/src/main/clm_initializeMod.F90 +++ b/components/clm/src/main/clm_initializeMod.F90 @@ -60,6 +60,7 @@ subroutine initialize1( ) use initGridCellsMod , only: initGridCells use ch4varcon , only: ch4conrd use UrbanParamsType , only: UrbanInput + use CLMFatesParamInterfaceMod, only : FatesReadPFTs ! ! !LOCAL VARIABLES: integer :: ier ! error status @@ -182,6 +183,14 @@ subroutine initialize1( ) call pftconrd() call soilorder_conrd() + ! Read in FATES parameter values early in the call sequence as well + ! The PFT file, specifically, will dictate how many pfts are used + ! in fates, and this will influence the amount of memory we + ! request from the model, which is relevant in set_fates_global_elements() + if (use_ed) then + call FatesReadPFTs() + end if + ! Read surface dataset and set up subgrid weight arrays call surfrd_get_data(begg, endg, ldomain, fsurdat) @@ -486,13 +495,13 @@ subroutine initialize2( ) ! Read in private parameters files, this should be preferred for mulitphysics ! implementation, jinyun Tang, Feb. 11, 2015 ! ------------------------------------------------------------------------ - if(use_cn) then + if(use_cn .or. use_ed) then call init_decomp_cascade_constants() endif !read bgc implementation specific parameters when needed call readPrivateParameters() - if (use_cn) then + if (use_cn .or. use_ed) then if (.not. is_active_betr_bgc)then if (use_century_decomp) then ! Note that init_decompcascade_bgc needs cnstate_vars to be initialized @@ -606,7 +615,8 @@ subroutine initialize2( ) soilstate_vars, solarabs_vars, surfalb_vars, temperature_vars, & waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & - betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars ) + betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & + clm_fates) end if else if ((nsrest == nsrContinue) .or. (nsrest == nsrBranch)) then @@ -621,7 +631,8 @@ subroutine initialize2( ) soilstate_vars, solarabs_vars, surfalb_vars, temperature_vars, & waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & - betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars) + betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & + clm_fates) end if @@ -666,7 +677,8 @@ subroutine initialize2( ) soilstate_vars, solarabs_vars, surfalb_vars, temperature_vars, & waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & - betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars) + betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & + clm_fates) ! Interpolate finidat onto new template file call getfil( finidat_interp_source, fnamer, 0 ) @@ -681,7 +693,8 @@ subroutine initialize2( ) soilstate_vars, solarabs_vars, surfalb_vars, temperature_vars, & waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & - betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars) + betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & + clm_fates) ! Reset finidat to now be finidat_interp_dest ! (to be compatible with routines still using finidat) @@ -806,13 +819,12 @@ subroutine initialize2( ) deallocate(wt_nat_patch) ! -------------------------------------------------------------- - ! Initialise the FATES model state structure + ! Initialise the FATES model state structure cold-start ! -------------------------------------------------------------- if ( use_ed .and. .not.is_restart() .and. finidat == ' ') then -!! (FATES-INTERF) - -!! call clm_fates%init_coldstart(waterstate_vars,canopystate_vars,soilstate_vars, frictionvel_vars) + call clm_fates%init_coldstart(waterstate_vars,canopystate_vars, & + soilstate_vars, frictionvel_vars) end if ! topo_glc_mec was allocated in initialize1, but needed to be kept around through diff --git a/components/clm/src/main/clm_instMod.F90 b/components/clm/src/main/clm_instMod.F90 index 2f300a2e3111..db2442279927 100644 --- a/components/clm/src/main/clm_instMod.F90 +++ b/components/clm/src/main/clm_instMod.F90 @@ -58,7 +58,7 @@ module clm_instMod use clm_bgc_interface_data , only : clm_bgc_interface_data_type use ChemStateType , only : chemstate_type ! structure for chemical indices of the soil, such as pH and Eh -! use CLMFatesInterfaceMod , only : hlm_fates_interface_type + use CLMFatesInterfaceMod , only : hlm_fates_interface_type ! @@ -111,13 +111,11 @@ module clm_instMod type(phosphorusflux_type) :: phosphorusflux_vars type(clm_bgc_interface_data_type) :: clm_bgc_data type(chemstate_type) :: chemstate_vars -! (FATES-INTERF) -! type(hlm_fates_interface_type) :: clm_fates (FATES-INTERF) + type(hlm_fates_interface_type) :: clm_fates public :: clm_inst_biogeochem public :: clm_inst_biogeophys -! (FATES-INTERF) -! public :: clm_fates + public :: clm_fates contains @@ -145,7 +143,7 @@ subroutine clm_inst_biogeochem(bounds_proc) if (use_voc ) then call vocemis_vars%Init(bounds_proc) end if - if (use_cn) then + if (use_cn .or. use_ed) then ! Note - always initialize the memory for the c13_carbonstate_vars and ! c14_carbonstate_vars data structure so that they can be used in @@ -172,7 +170,9 @@ subroutine clm_inst_biogeochem(bounds_proc) if (use_c14) then call c14_carbonflux_vars%Init(bounds_proc, carbon_type='c14') end if + endif + if (use_cn) then call nitrogenstate_vars%Init(bounds_proc, & carbonstate_vars%leafc_patch(begp:endp), & carbonstate_vars%leafc_storage_patch(begp:endp), & @@ -204,10 +204,10 @@ subroutine clm_inst_biogeochem(bounds_proc) call crop_vars%Init(bounds_proc) end if - + ! Initialize the Functionaly Assembled Terrestrial Ecosystem Simulator (FATES) if (use_ed) then - !! call clm_fates%Init(bounds_proc) (FATES-INTERF) + call clm_fates%Init(bounds_proc) end if call hist_printflds() diff --git a/components/clm/src/main/clm_varctl.F90 b/components/clm/src/main/clm_varctl.F90 index 67f45d54d85f..0dacda5ac4f6 100644 --- a/components/clm/src/main/clm_varctl.F90 +++ b/components/clm/src/main/clm_varctl.F90 @@ -190,8 +190,7 @@ module clm_varctl !---------------------------------------------------------- logical, public :: use_ed = .false. ! true => use ED - ! (FATES-INTERF) CHANGE TO USE_ED_SPITFIRE - logical, public :: use_ed_spit_fire = .false. ! true => use spitfire model + logical, public :: use_ed_spitfire = .false. ! true => use spitfire model !---------------------------------------------------------- ! BeTR switches @@ -277,6 +276,11 @@ module clm_varctl ! moved hist_wrtch4diag from histFileMod.F90 to here - caused compiler error with intel ! namelist: write CH4 extra diagnostic output logical, public :: hist_wrtch4diag = .false. + + !---------------------------------------------------------- + ! ED/FATES + !---------------------------------------------------------- + character(len=fname_len), public :: fates_paramfile = ' ' !---------------------------------------------------------- ! Migration of CPP variables diff --git a/components/clm/src/main/clm_varpar.F90 b/components/clm/src/main/clm_varpar.F90 index dfe5232fa5d0..d5090d3f122a 100644 --- a/components/clm/src/main/clm_varpar.F90 +++ b/components/clm/src/main/clm_varpar.F90 @@ -36,9 +36,6 @@ module clm_varpar integer, parameter :: nlevsno = 5 ! maximum number of snow layers integer, parameter :: ngases = 3 ! CH4, O2, & CO2 integer, parameter :: nlevcan = 1 ! number of leaf layers in canopy layer - !ED variables - integer, parameter :: nlevcan_ed = 40 ! number of leaf layers in canopy layer - integer, parameter :: nclmax = 2 ! max number of canopy layers integer, parameter :: numwat = 5 ! number of water types (soil, ice, 2 lakes, wetland) integer, parameter :: numrad = 2 ! number of solar radiation bands: vis, nir integer, parameter :: ivis = 1 ! index for visible band diff --git a/components/clm/src/main/clmfates_interfaceMod.F90 b/components/clm/src/main/clmfates_interfaceMod.F90 new file mode 100644 index 000000000000..fa1ea30a3303 --- /dev/null +++ b/components/clm/src/main/clmfates_interfaceMod.F90 @@ -0,0 +1,2360 @@ +module CLMFatesInterfaceMod + + ! ------------------------------------------------------------------------------------- + ! This module contains various functions and definitions to aid in the + ! coupling of the FATES library/API with the CLM/ALM/ATS/etc model driver. + ! All connections between the two models should occur in this file alone. + ! + ! This is also the only location where CLM code is allowed to see FATES memory + ! structures. + ! The routines here, that call FATES library routines, will not pass any types defined + ! by the driving land model (HLM). + ! + ! either native type arrays (int,real,log, etc) or packed into ED boundary condition + ! structures. + ! + ! Note that CLM/ALM does use Shared Memory Parallelism (SMP), where processes such as + ! the update of state variables are forked. However, IO is not assumed to be + ! threadsafe and therefore memory spaces reserved for IO must be continuous vectors, + ! and moreover they must be pushed/pulled from history IO for each individual + ! bounds_proc memory space as a unit. + ! + ! Therefore, the state variables in the clm_fates communicator is vectorized by + ! threadcount, and the IO communication arrays are not. + ! + ! + ! Conventions: + ! keep line widths within 90 spaces + ! HLM acronym = Host Land Model + ! + ! ------------------------------------------------------------------------------------- + + ! use ed_driver_interface, only: + + ! Used CLM Modules + use PatchType , only : pft + use shr_kind_mod , only : r8 => shr_kind_r8 + use decompMod , only : bounds_type + use WaterStateType , only : waterstate_type + use WaterFluxType , only : waterflux_type + use CanopyStateType , only : canopystate_type + use TemperatureType , only : temperature_type + use EnergyFluxType , only : energyflux_type + + use SoilStateType , only : soilstate_type + use clm_varctl , only : iulog + use clm_varctl , only : use_vertsoilc + use clm_varctl , only : use_ed_spitfire + use clm_varcon , only : tfrz + use clm_varcon , only : spval + use clm_varcon , only : denice + use clm_varcon , only : ispval + + use clm_varpar , only : numpft + use clm_varpar , only : numrad + use clm_varpar , only : ivis + use clm_varpar , only : inir + use clm_varpar , only : nlevgrnd + use clm_varpar , only : nlevsoi + use clm_varpar , only : nlevdecomp + use clm_varpar , only : nlevdecomp_full + use clm_varpar , only : i_met_lit, i_cel_lit, i_lig_lit + use PhotosynthesisType , only : photosyns_type + use atm2lndType , only : atm2lnd_type + use SurfaceAlbedoType , only : surfalb_type + use SolarAbsorbedType , only : solarabs_type + use CNCarbonFluxType , only : carbonflux_type + use CNCarbonStateType , only : carbonstate_type + use FrictionVelocityType , only : frictionvel_type + use clm_time_manager , only : is_restart + use ncdio_pio , only : file_desc_t, ncd_int, ncd_double + use restUtilMod, only : restartvar + use clm_time_manager , only : get_days_per_year, & + get_curr_date, & + get_ref_date, & + timemgr_datediff, & + is_beg_curr_day, & + get_step_size, & + get_nstep + use spmdMod , only : masterproc + use decompMod , only : get_proc_bounds, & + get_proc_clumps, & + get_clump_bounds + use GridCellType , only : grc + use ColumnType , only : col + use LandunitType , only : lun + use landunit_varcon , only : istsoil + use abortutils , only : endrun + use shr_log_mod , only : errMsg => shr_log_errMsg + use clm_varcon , only : dzsoi_decomp + use FuncPedotransferMod, only: get_ipedof + + + ! Used FATES Modules + use FatesInterfaceMod , only : fates_interface_type + use FatesInterfaceMod , only : allocate_bcin + use FatesInterfaceMod , only : allocate_bcout + use FatesInterfaceMod , only : SetFatesTime + use FatesInterfaceMod , only : set_fates_ctrlparms + + use FatesHistoryInterfaceMod, only : fates_history_interface_type + use FatesRestartInterfaceMod, only : fates_restart_interface_type + + use ChecksBalancesMod , only : SummarizeNetFluxes, FATES_BGC_Carbon_BalanceCheck + use EDTypesMod , only : ed_patch_type + use EDTypesMod , only : ed_hist_scpfmaps + use FatesHydraulicsMemMod , only : nlevsoi_hyd + use EDTypesMod , only : use_fates_plant_hydro + use FatesInterfaceMod , only : hlm_numlevgrnd, hlm_numlevsoil, hlm_numlevdecomp_full + use EDMainMod , only : ed_ecosystem_dynamics + use EDMainMod , only : ed_update_site + use EDInitMod , only : zero_site + use EDInitMod , only : init_patches + use EDInitMod , only : set_site_properties + use EDPftVarcon , only : EDpftvarcon_inst + use EDEcophysConType , only : EDecophysconInit + use EDSurfaceRadiationMod , only : ED_SunShadeFracs, ED_Norman_Radiation + use EDBtranMod , only : btran_ed, & + get_active_suction_layers + use EDCanopyStructureMod , only : canopy_summarization, update_hlm_dynamics + use FatesPlantRespPhotosynthMod, only : FatesPlantRespPhotosynthDrive + use EDAccumulateFluxesMod , only : AccumulateFluxes_ED + use EDPhysiologyMod , only : flux_into_litter_pools + use FatesPlantHydraulicsMod, only : hydraulics_drive + use FatesPlantHydraulicsMod, only : HydrSiteColdStart + use FatesPlantHydraulicsMod, only : InitHydrSites + use FatesPlantHydraulicsMod, only : UpdateH2OVeg + + implicit none + + type, public :: f2hmap_type + + ! This is the associated column index of each FATES site + integer, allocatable :: fcolumn (:) + + ! This is the associated site index of any HLM columns + ! This vector may be sparse, and non-sites have index 0 + integer, allocatable :: hsites (:) + + end type f2hmap_type + + + type, public :: hlm_fates_interface_type + + ! See above for descriptions of the sub-types populated + ! by thread. This type is somewhat self-explanatory, in that it simply + ! breaks up memory and process by thread. Each thread will have its + ! own list of sites, and boundary conditions for those sites + + type(fates_interface_type), allocatable :: fates (:) + + + ! This memory structure is used to map fates sites + ! into the host model. Currently, the FATES site + ! and its column number matching are its only members + + type(f2hmap_type), allocatable :: f2hmap(:) + + ! fates_hist is the interface class for the history output + type(fates_history_interface_type) :: fates_hist + + ! fates_restart is the inteface calss for restarting the model + type(fates_restart_interface_type) :: fates_restart + + contains + + procedure, public :: init + procedure, public :: check_hlm_active + procedure, public :: restart + procedure, public :: init_coldstart + procedure, public :: dynamics_driv + procedure, public :: wrap_sunfrac + procedure, public :: wrap_btran + procedure, public :: wrap_photosynthesis + procedure, public :: wrap_accumulatefluxes + procedure, public :: prep_canopyfluxes + procedure, public :: wrap_canopy_radiation + procedure, public :: wrap_bgc_summary + procedure, public :: TransferZ0mDisp + procedure, public :: UpdateLitterFluxes + procedure, private :: init_history_io + procedure, private :: wrap_update_hlmfates_dyn + procedure, private :: init_soil_depths + procedure, public :: ComputeRootSoilFlux + procedure, public :: wrap_hydraulics_drive + + end type hlm_fates_interface_type + + ! hlm_bounds_to_fates_bounds is not currently called outside the interface. + ! Although there may be good reasons to, I privatized it so that the next + ! developer will at least question its usage (RGK) + private :: hlm_bounds_to_fates_bounds + + logical :: DEBUG = .false. + + character(len=*), parameter, private :: sourcefile = & + __FILE__ + +contains + + ! ==================================================================================== + + subroutine init(this, bounds_proc ) + + ! --------------------------------------------------------------------------------- + ! This initializes the hlm_fates_interface_type + ! + ! sites is the root of the ED state hierarchy (instantaneous info on + ! the state of the ecosystem). As such, it governs the connection points between + ! the host (which also dictates its allocation) and its patch structures. + ! + ! sites may associate with different scales in different models. In + ! CLM, it is being designed to relate to column scale. + ! + ! This global may become relegated to this module. + ! + ! Note: CLM/ALM currently wants sites to be allocated even if ed + ! is not turned on + ! --------------------------------------------------------------------------------- + + use FatesInterfaceMod, only : FatesInterfaceInit + use EDTypesMod , only : numpft_ed + use FatesParameterDerivedMod, only : param_derived + + implicit none + + ! Input Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_proc + + ! local variables + integer :: nclumps ! Number of threads + logical :: verbose_output + integer :: pass_masterproc + integer :: pass_vertsoilc + integer :: pass_spitfire + integer :: pass_is_restart + integer :: nc ! thread index + integer :: s ! FATES site index + integer :: c ! HLM column index + integer :: l ! HLM LU index + integer :: g ! HLM grid index + integer :: pi,pf + integer, allocatable :: collist (:) + type(bounds_type) :: bounds_clump + integer :: nmaxcol + + ! Initialize the FATES communicators with the HLM + ! This involves to stages + ! 1) allocate the vectors + ! 2) add the history variables defined in clm_inst to the history machinery + call EDecophysconInit( EDpftvarcon_inst, numpft ) + call param_derived%Init( numpft_ed ) + + verbose_output = .false. + call FatesInterfaceInit(iulog, verbose_output) + + nclumps = get_proc_clumps() + allocate(this%fates(nclumps)) + allocate(this%f2hmap(nclumps)) + + ! --------------------------------------------------------------------------------- + ! Send dimensions and other model controling parameters to FATES. These + ! are obviously only those parameters that are dictated by the host + ! --------------------------------------------------------------------------------- + + ! Force FATES parameters that are recieve type, to the unset value + call set_fates_ctrlparms('flush_to_unset') + + ! Send parameters individually + call set_fates_ctrlparms('num_sw_bbands',ival=numrad) + call set_fates_ctrlparms('vis_sw_index',ival=ivis) + call set_fates_ctrlparms('nir_sw_index',ival=inir) + + call set_fates_ctrlparms('num_lev_ground',ival=nlevgrnd) + call set_fates_ctrlparms('num_lev_soil',ival=nlevsoi) + call set_fates_ctrlparms('num_levdecomp',ival=nlevdecomp) + call set_fates_ctrlparms('num_levdecomp_full',ival=nlevdecomp_full) + call set_fates_ctrlparms('hlm_name',cval='CLM') + call set_fates_ctrlparms('hio_ignore_val',rval=spval) + call set_fates_ctrlparms('soilwater_ipedof',ival=get_ipedof(0)) + + if(is_restart()) then + pass_is_restart = 1 + else + pass_is_restart = 0 + end if + call set_fates_ctrlparms('is_restart',ival=pass_is_restart) + + if(use_vertsoilc) then + pass_vertsoilc = 1 + else + pass_vertsoilc = 0 + end if + call set_fates_ctrlparms('use_vertsoilc',ival=pass_vertsoilc) + + if(use_ed_spitfire) then + pass_spitfire = 1 + else + pass_spitfire = 0 + end if + call set_fates_ctrlparms('use_spitfire',ival=pass_spitfire) + + if(masterproc)then + pass_masterproc = 1 + else + pass_masterproc = 0 + end if + call set_fates_ctrlparms('masterproc',ival=pass_masterproc) + + ! Check through FATES parameters to see if all have been set + call set_fates_ctrlparms('check_allset') + + if(DEBUG)then + write(iulog,*) 'clm_fates%init(): allocating for ',nclumps,' threads' + end if + + + nclumps = get_proc_clumps() + + !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,nmaxcol,s,c,l,g,collist,pi,pf) + do nc = 1,nclumps + + call get_clump_bounds(nc, bounds_clump) + nmaxcol = bounds_clump%endc - bounds_clump%begc + 1 + + allocate(collist(1:nmaxcol)) + + ! Allocate the mapping that points columns to FATES sites, 0 is NA + allocate(this%f2hmap(nc)%hsites(bounds_clump%begc:bounds_clump%endc)) + + ! Initialize all columns with a zero index, which indicates no FATES site + this%f2hmap(nc)%hsites(:) = 0 + + s = 0 + do c = bounds_clump%begc,bounds_clump%endc + l = col%landunit(c) + + ! These are the key constraints that determine if this column + ! will have a FATES site associated with it + + ! INTERF-TODO: WE HAVE NOT FILTERED OUT FATES SITES ON INACTIVE COLUMNS.. YET + ! NEED A RUN-TIME ROUTINE THAT CLEARS AND REWRITES THE SITE LIST + + if (lun%itype(l) == istsoil ) then + s = s + 1 + collist(s) = c + this%f2hmap(nc)%hsites(c) = s + if(DEBUG)then + write(iulog,*) 'clm_fates%init(): thread',nc,': found column',c,'with lu',l + write(iulog,*) 'LU type:', lun%itype(l) + end if + endif + + enddo + + if(DEBUG)then + write(iulog,*) 'clm_fates%init(): thread',nc,': allocated ',s,' sites' + end if + + ! Allocate vectors that match FATES sites with HLM columns + ! RGK: Sites and fcolumns are forced as args during clm_driv() as of 6/4/2016 + ! We may have to give these a dummy allocation of 1, which should + ! not be a problem since we always iterate on nsites. + + allocate(this%f2hmap(nc)%fcolumn(s)) + + ! Assign the h2hmap indexing + this%f2hmap(nc)%fcolumn(1:s) = collist(1:s) + + ! Deallocate the temporary arrays + deallocate(collist) + + ! Set the number of FATES sites + this%fates(nc)%nsites = s + + ! Allocate the FATES sites + allocate (this%fates(nc)%sites(this%fates(nc)%nsites)) + + ! Allocate the FATES boundary arrays (in) + allocate(this%fates(nc)%bc_in(this%fates(nc)%nsites)) + + ! Allocate the FATES boundary arrays (out) + allocate(this%fates(nc)%bc_out(this%fates(nc)%nsites)) + + ! Allocate and Initialize the Boundary Condition Arrays + ! These are staticaly allocated at maximums, so + ! No information about the patch or cohort structure is needed at this step + + do s = 1, this%fates(nc)%nsites + call allocate_bcin(this%fates(nc)%bc_in(s)) + call allocate_bcout(this%fates(nc)%bc_out(s)) + call this%fates(nc)%zero_bcs(s) + + ! Pass any grid-cell derived attributes to the site + ! --------------------------------------------------------------------------- + c = this%f2hmap(nc)%fcolumn(s) + g = col%gridcell(c) + this%fates(nc)%sites(s)%lat = grc%latdeg(g) + this%fates(nc)%sites(s)%lon = grc%londeg(g) + + end do + + + ! Initialize site-level static quantities dictated by the HLM + ! currently ground layering depth + + call this%init_soil_depths(nc) + + if (use_fates_plant_hydro) call InitHydrSites(this%fates(nc)%sites) + + + if( this%fates(nc)%nsites == 0 ) then + write(iulog,*) 'Clump ',nc,' had no valid FATES sites' + write(iulog,*) 'This will likely cause problems until code is improved' + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + + + ! Set patch itypes on natural veg columns to nonsense + ! This will force a crash if the model outside of FATES tries to think + ! of the patch as a PFT. + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + pi = col%pfti(c)+1 + pf = col%pftf(c) + pft%is_fates(pi:pf) = .true. + end do + + end do + !$OMP END PARALLEL DO + + ! Initialize some dimensioning and mapping tables + call ed_hist_scpfmaps() + + + call this%init_history_io(bounds_proc) + + + + + + end subroutine init + + ! =================================================================================== + + subroutine check_hlm_active(this, nc, bounds_clump) + + ! --------------------------------------------------------------------------------- + ! This subroutine is not currently used. It is just a utility that may come + ! in handy when we have dynamic sites in FATES + ! --------------------------------------------------------------------------------- + + implicit none + class(hlm_fates_interface_type), intent(inout) :: this + integer :: nc + type(bounds_type),intent(in) :: bounds_clump + + ! local variables + integer :: c + + do c = bounds_clump%begc,bounds_clump%endc + + ! FATES ACTIVE BUT HLM IS NOT + if(this%f2hmap(nc)%hsites(c)>0 .and. .not.col%active(c)) then + + write(iulog,*) 'INACTIVE COLUMN WITH ACTIVE FATES SITE' + write(iulog,*) 'c = ',c + call endrun(msg=errMsg(sourcefile, __LINE__)) + + elseif (this%f2hmap(nc)%hsites(c)==0 .and. col%active(c)) then + + write(iulog,*) 'ACTIVE COLUMN WITH INACTIVE FATES SITE' + write(iulog,*) 'c = ',c + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + end do + + end subroutine check_hlm_active + + ! ------------------------------------------------------------------------------------ + + subroutine dynamics_driv(this, bounds_clump, & + atm2lnd_inst, soilstate_inst, temperature_inst, & + waterstate_inst, canopystate_inst, carbonflux_inst, & + frictionvel_inst ) + + ! This wrapper is called daily from clm_driver + ! This wrapper calls ed_driver, which is the daily dynamics component of FATES + ! ed_driver is not a hlm_fates_inst_type procedure because we need an extra step + ! to process array bounding information + + implicit none + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_clump + type(atm2lnd_type) , intent(in) :: atm2lnd_inst + type(soilstate_type) , intent(in) :: soilstate_inst + type(temperature_type) , intent(in) :: temperature_inst + type(waterstate_type) , intent(inout) :: waterstate_inst + type(canopystate_type) , intent(inout) :: canopystate_inst + type(carbonflux_type) , intent(inout) :: carbonflux_inst + type(frictionvel_type) , intent(inout) :: frictionvel_inst + + ! !LOCAL VARIABLES: + integer :: s ! site index + integer :: c ! column index (HLM) + integer :: ifp ! patch index + integer :: p ! HLM patch index + integer :: nc ! clump index + integer :: yr ! year (0, ...) + integer :: mon ! month (1, ..., 12) + integer :: day ! day of month (1, ..., 31) + integer :: sec ! seconds of the day + integer :: current_year + integer :: current_month + integer :: current_day + integer :: current_tod + integer :: current_date + integer :: jan01_curr_year + integer :: reference_date + integer :: days_per_year + real(r8) :: model_day + real(r8) :: day_of_year + !----------------------------------------------------------------------- + + nc = bounds_clump%clump_index + + ! --------------------------------------------------------------------------------- + ! Part I. + ! Prepare input boundary conditions for FATES dynamics + ! Note that timing information is the same across all sites, this may + ! seem redundant, but it is possible that we may have asynchronous site simulations + ! one day. The cost of holding site level boundary conditions is minimal + ! and it keeps all the boundaries in one location + ! --------------------------------------------------------------------------------- + + days_per_year = get_days_per_year() + call get_curr_date(current_year,current_month,current_day,current_tod) + current_date = current_year*10000 + current_month*100 + current_day + jan01_curr_year = current_year*10000 + 100 + 1 + + call get_ref_date(yr, mon, day, sec) + reference_date = yr*10000 + mon*100 + day + + call timemgr_datediff(reference_date, sec, current_date, current_tod, model_day) + + call timemgr_datediff(jan01_curr_year,0,current_date,sec,day_of_year) + + call SetFatesTime(current_year, current_month, & + current_day, current_tod, & + current_date, reference_date, & + model_day, floor(day_of_year), & + days_per_year, 1.0_r8/dble(days_per_year)) + + + do s=1,this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates(nc)%bc_in(s)%h2o_liqvol_gl(1:nlevsoi) = & + waterstate_inst%h2osoi_vol_col(c,1:nlevsoi) + + ! TO-DO: SHOULD THIS BE LIQVOL OR IS VOL OK? (RGK-02-2017) + + this%fates(nc)%bc_in(s)%t_veg24_si = & + temperature_inst%t_veg24_patch(col%pfti(c)) + + this%fates(nc)%bc_in(s)%max_rooting_depth_index_col = canopystate_inst%altmax_lastyear_indx_col(c) + + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + p = ifp+col%pfti(c) + this%fates(nc)%bc_in(s)%t_veg24_pa(ifp) = & + temperature_inst%t_veg24_patch(p) + + this%fates(nc)%bc_in(s)%precip24_pa(ifp) = & + atm2lnd_inst%prec24_patch(p) + + this%fates(nc)%bc_in(s)%relhumid24_pa(ifp) = & + atm2lnd_inst%rh24_patch(p) + + this%fates(nc)%bc_in(s)%wind24_pa(ifp) = & + atm2lnd_inst%wind24_patch(p) + + end do + + + if(use_fates_plant_hydro)then + this%fates(nc)%bc_in(s)%hksat_sisl(1:nlevsoi) = soilstate_inst%hksat_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%watsat_sisl(1:nlevsoi) = soilstate_inst%watsat_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%watres_sisl(1:nlevsoi) = spval !soilstate_inst%watres_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%sucsat_sisl(1:nlevsoi) = soilstate_inst%sucsat_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%bsw_sisl(1:nlevsoi) = soilstate_inst%bsw_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%h2o_liq_sisl(1:nlevsoi) = waterstate_inst%h2osoi_liq_col(c,1:nlevsoi) + end if + + + end do + + ! --------------------------------------------------------------------------------- + ! Part II: Call the FATES model now that input boundary conditions have been + ! provided. + ! --------------------------------------------------------------------------------- + + do s = 1,this%fates(nc)%nsites + + call ed_ecosystem_dynamics(this%fates(nc)%sites(s), & + this%fates(nc)%bc_in(s)) + + call ed_update_site(this%fates(nc)%sites(s), & + this%fates(nc)%bc_in(s)) + + enddo + + ! call subroutine to aggregate ED litter output fluxes and + ! package them for handing across interface + call flux_into_litter_pools(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out) + + ! --------------------------------------------------------------------------------- + ! Part III: Process FATES output into the dimensions and structures that are part + ! of the HLMs API. (column, depth, and litter fractions) + ! --------------------------------------------------------------------------------- + call this%UpdateLitterFluxes(bounds_clump,carbonflux_inst) + + ! --------------------------------------------------------------------------------- + ! Part III.2 (continued). + ! Update diagnostics of the FATES ecosystem structure that are used in the HLM. + ! --------------------------------------------------------------------------------- + call this%wrap_update_hlmfates_dyn(nc, & + bounds_clump, & + waterstate_inst, & + canopystate_inst, & + frictionvel_inst) + + ! --------------------------------------------------------------------------------- + ! Part IV: + ! Update history IO fields that depend on ecosystem dynamics + ! --------------------------------------------------------------------------------- + call this%fates_hist%update_history_dyn( nc, & + this%fates(nc)%nsites, & + this%fates(nc)%sites) + + if (masterproc) then + write(iulog, *) 'clm: leaving ED model', bounds_clump%begg, & + bounds_clump%endg + end if + + + return + end subroutine dynamics_driv + + ! ------------------------------------------------------------------------------------ + subroutine UpdateLitterFluxes(this,bounds_clump,carbonflux_inst) + + implicit none + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_clump + type(carbonflux_type) , intent(inout) :: carbonflux_inst + + ! !LOCAL VARIABLES: + integer :: s ! site index + integer :: c ! column index (HLM) + integer :: nc ! clump index + real(r8) :: dtime + + dtime = real(get_step_size(),r8) + nc = bounds_clump%clump_index + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + carbonflux_inst%decomp_cpools_sourcesink_col(c,:,i_met_lit) = & + this%fates(nc)%bc_out(s)%FATES_c_to_litr_lab_c_col(:) * dtime + carbonflux_inst%decomp_cpools_sourcesink_col(c,:,i_cel_lit) = & + this%fates(nc)%bc_out(s)%FATES_c_to_litr_cel_c_col(:) * dtime + carbonflux_inst%decomp_cpools_sourcesink_col(c,:,i_lig_lit) = & + this%fates(nc)%bc_out(s)%FATES_c_to_litr_lig_c_col(:) * dtime + end do + + end subroutine UpdateLitterFluxes + + !-------------------------------------------------------------------------------------- + + subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & + waterstate_inst, canopystate_inst, frictionvel_inst ) + + ! --------------------------------------------------------------------------------- + ! This routine handles the updating of vegetation canopy diagnostics, (such as lai) + ! that either requires HLM boundary conditions (like snow accumulation) or + ! provides boundary conditions (such as vegetation fractional coverage) + ! --------------------------------------------------------------------------------- + + implicit none + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_clump + integer , intent(in) :: nc + type(waterstate_type) , intent(inout) :: waterstate_inst + type(canopystate_type) , intent(inout) :: canopystate_inst + type(frictionvel_type) , intent(inout) :: frictionvel_inst + + integer :: npatch ! number of patches in each site + integer :: ifp ! index FATES patch + integer :: p ! HLM patch index + integer :: s ! site index + integer :: c ! column index + + associate( & + tlai => canopystate_inst%tlai_patch , & + elai => canopystate_inst%elai_patch , & + tsai => canopystate_inst%tsai_patch , & + esai => canopystate_inst%esai_patch , & + htop => canopystate_inst%htop_patch , & + hbot => canopystate_inst%hbot_patch , & + z0m => frictionvel_inst%z0m_patch , & ! Output: [real(r8) (:) ] momentum roughness length (m) + displa => canopystate_inst%displa_patch, & + dleaf_patch => canopystate_inst%dleaf_patch, & + snow_depth => waterstate_inst%snow_depth_col, & + frac_sno_eff => waterstate_inst%frac_sno_eff_col, & + frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch) + + + ! Process input boundary conditions to FATES + ! -------------------------------------------------------------------------------- + do s=1,this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates(nc)%bc_in(s)%snow_depth_si = snow_depth(c) + this%fates(nc)%bc_in(s)%frac_sno_eff_si = frac_sno_eff(c) + end do + + ! Canopy diagnostics for FATES + call canopy_summarization(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in) + + ! Canopy diagnostic outputs for HLM + call update_hlm_dynamics(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%f2hmap(nc)%fcolumn, & + this%fates(nc)%bc_out ) + + !--------------------------------------------------------------------------------- + ! CHANGING STORED WATER DURING PLANT DYNAMICS IS NOT FULLY IMPLEMENTED + ! LEAVING AS A PLACE-HOLDER FOR NOW. + ! ! Diagnose water storage in canopy if hydraulics is on + ! ! This updates the internal value and the bc_out value. + ! ! If hydraulics is off, it returns 0 storage + ! if ( use_fates_plant_hydro ) then + ! call UpdateH2OVeg(this%fates(nc)%nsites, & + ! this%fates(nc)%sites, & + ! this%fates(nc)%bc_out) + ! + ! do s = 1, this%fates(nc)%nsites + ! c = this%f2hmap(nc)%fcolumn(s) + ! waterstate_inst%total_plant_stored_h2o_col(c) = & + ! this%fates(nc)%bc_out(s)%plant_stored_h2o_si + ! end do + ! end if + !--------------------------------------------------------------------------------- + + ! Convert FATES dynamics into HLM usable information + ! Initialize weighting variables (note FATES is the only HLM module + ! that uses "is_veg" and "is_bareground". The entire purpose of these + ! variables is to inform patch%wtcol(p). wt_ed is imposed on wtcol, + ! but only for FATES columns. + + pft%is_veg(bounds_clump%begp:bounds_clump%endp) = .false. + pft%is_bareground(bounds_clump%begp:bounds_clump%endp) = .false. + pft%wt_ed(bounds_clump%begp:bounds_clump%endp) = 0.0_r8 + + do s = 1,this%fates(nc)%nsites + + c = this%f2hmap(nc)%fcolumn(s) + + ! Other modules may have AI's we only flush values + ! that are on the naturally vegetated columns + elai(col%pfti(c):col%pftf(c)) = 0.0_r8 + tlai(col%pfti(c):col%pftf(c)) = 0.0_r8 + esai(col%pfti(c):col%pftf(c)) = 0.0_r8 + tsai(col%pfti(c):col%pftf(c)) = 0.0_r8 + htop(col%pfti(c):col%pftf(c)) = 0.0_r8 + hbot(col%pfti(c):col%pftf(c)) = 0.0_r8 + + ! FATES does not dictate bare-ground so turbulent + ! variables are not over-written. + z0m(col%pfti(c)+1:col%pftf(c)) = 0.0_r8 + displa(col%pfti(c)+1:col%pftf(c)) = 0.0_r8 + dleaf_patch(col%pfti(c)+1:col%pftf(c)) = 0.0_r8 + + frac_veg_nosno_alb(col%pfti(c):col%pftf(c)) = 0.0_r8 + + ! Set the bareground patch indicator + pft%is_bareground(col%pfti(c)) = .true. + npatch = this%fates(nc)%sites(s)%youngest_patch%patchno + pft%wt_ed(col%pfti(c)) = 1.0-sum(this%fates(nc)%bc_out(s)%canopy_fraction_pa(1:npatch)) + + if(sum(this%fates(nc)%bc_out(s)%canopy_fraction_pa(1:npatch))>1.0_r8)then + write(iulog,*)'Projected Canopy Area of all FATES patches' + write(iulog,*)'cannot exceed 1.0' + !end_run() + end if + + do ifp = 1, npatch + + p = ifp+col%pfti(c) + + ! bc_out(s)%canopy_fraction_pa(ifp) is the area fraction + ! the site's total ground area that is occupied by the + ! area footprint of the current patch's vegetation canopy + + pft%is_veg(p) = .true. + pft%wt_ed(p) = this%fates(nc)%bc_out(s)%canopy_fraction_pa(ifp) + elai(p) = this%fates(nc)%bc_out(s)%elai_pa(ifp) + tlai(p) = this%fates(nc)%bc_out(s)%tlai_pa(ifp) + esai(p) = this%fates(nc)%bc_out(s)%esai_pa(ifp) + tsai(p) = this%fates(nc)%bc_out(s)%tsai_pa(ifp) + hbot(p) = this%fates(nc)%bc_out(s)%hbot_pa(ifp) + htop(p) = this%fates(nc)%bc_out(s)%htop_pa(ifp) + frac_veg_nosno_alb(p) = this%fates(nc)%bc_out(s)%frac_veg_nosno_alb_pa(ifp) + + ! Note that while we pass the following values at this point + ! we have to send the same values after each time-step because + ! the HLM keeps changing the value and re-setting, so we + ! re-send instead of re-set. See clm_fates%TransferZ0mDisp() + z0m(p) = this%fates(nc)%bc_out(s)%z0m_pa(ifp) + displa(p) = this%fates(nc)%bc_out(s)%displa_pa(ifp) + dleaf_patch(p) = this%fates(nc)%bc_out(s)%dleaf_pa(ifp) + + + end do + + end do + end associate + end subroutine wrap_update_hlmfates_dyn + + ! ==================================================================================== + + subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & + canopystate_inst, frictionvel_inst ) + + ! --------------------------------------------------------------------------------- + ! The ability to restart the model is handled through three different types of calls + ! "Define" the variables in the restart file, we "read" those variables into memory + ! or "write" data into the file from memory. This subroutine accomodates all three + ! of those modes through the "flag" argument. FATES as an external model also + ! requires an initialization step, where we set-up the dimensions, allocate and + ! flush the memory space that is used to transfer data in and out of the file. This + ! Only occurs once, where as the define step occurs every time a file is opened. + ! + ! Note: waterstate_inst and canopystate_inst are arguments only because following + ! the reading of variables, it is necessary to update diagnostics of the canopy + ! throug the interface call clm_fates%wrap_update_hlmfates_dyn() which requires + ! this information from the HLM. + ! --------------------------------------------------------------------------------- + + + use FatesConstantsMod, only : fates_long_string_length + use FatesIODimensionsMod, only: fates_bounds_type + use FatesIOVariableKindMod, only : site_r8, site_int, cohort_r8, cohort_int + use EDMainMod, only : ed_update_site + use FatesInterfaceMod, only: fates_maxElementsPerSite + + implicit none + + ! Arguments + + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_proc + type(file_desc_t) , intent(inout) :: ncid ! netcdf id + character(len=*) , intent(in) :: flag + type(waterstate_type) , intent(inout) :: waterstate_inst + type(canopystate_type) , intent(inout) :: canopystate_inst + type(frictionvel_type) , intent(inout) :: frictionvel_inst + + ! Locals + type(bounds_type) :: bounds_clump + integer :: nc + integer :: nclumps + type(fates_bounds_type) :: fates_bounds + type(fates_bounds_type) :: fates_clump + integer :: c ! HLM column index + integer :: s ! Fates site index + integer :: dk_index + character(len=fates_long_string_length) :: ioname + integer :: nvar + integer :: ivar + logical :: readvar + + logical, save :: initialized = .false. + + + nclumps = get_proc_clumps() + + ! --------------------------------------------------------------------------------- + ! note (rgk: 11-2016) The history and restart intialization process assumes + ! that the number of site/columns active is a static entity. Thus + ! we only allocate the mapping tables for the column/sites we start with. + ! If/when we start having dynamic column/sites (for reasons uknown as of yet) + ! we will need to re-evaluate the allocation of the mapping tables so they + ! can be unallocated,reallocated and set every time a new column/site is spawned + ! --------------------------------------------------------------------------------- + + ! --------------------------------------------------------------------------------- + ! Only initialize the FATES restart structures the first time it is called + ! Note that the allocations involved with initialization are static. + ! This is because the array spaces for IO span the entire column, patch and cohort + ! range on the proc. + ! With DYNAMIC LANDUNITS or SPAWNING NEW OR CULLING OLD SITES: + ! we will in that case have to de-allocate, reallocate and then re-set the mapping + ! tables: this%fates_restart%restart_map(nc) + ! I think that is it... + ! --------------------------------------------------------------------------------- + + if(.not.initialized) then + + initialized=.true. + + ! ------------------------------------------------------------------------------ + ! PART I: Set FATES DIMENSIONING INFORMATION + ! ------------------------------------------------------------------------------ + + call hlm_bounds_to_fates_bounds(bounds_proc, fates_bounds) + + call this%fates_restart%Init(nclumps, fates_bounds) + + ! Define the bounds on the first dimension for each thread + !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,fates_clump) + do nc = 1,nclumps + call get_clump_bounds(nc, bounds_clump) + + ! thread bounds for patch + call hlm_bounds_to_fates_bounds(bounds_clump, fates_clump) + call this%fates_restart%SetThreadBoundsEach(nc, fates_clump) + end do + !$OMP END PARALLEL DO + + !$OMP PARALLEL DO PRIVATE (nc,s,c) + do nc = 1,nclumps + + allocate(this%fates_restart%restart_map(nc)%site_index(this%fates(nc)%nsites)) + allocate(this%fates_restart%restart_map(nc)%cohort1_index(this%fates(nc)%nsites)) + do s=1,this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates_restart%restart_map(nc)%site_index(s) = c + this%fates_restart%restart_map(nc)%cohort1_index(s) = & + bounds_proc%begCohort + (c-bounds_proc%begc)*fates_maxElementsPerSite + 1 + end do + + end do + !$OMP END PARALLEL DO + + ! ------------------------------------------------------------------------------------ + ! PART II: USE THE JUST DEFINED DIMENSIONS TO ASSEMBLE THE VALID IO TYPES + ! INTERF-TODO: THESE CAN ALL BE EMBEDDED INTO A SUBROUTINE IN HISTORYIOMOD + ! ------------------------------------------------------------------------------------ + call this%fates_restart%assemble_restart_output_types() + + + ! ------------------------------------------------------------------------------------ + ! PART III: DEFINE THE LIST OF OUTPUT VARIABLE OBJECTS, AND REGISTER THEM WITH THE + ! HLM ACCORDING TO THEIR TYPES + ! ------------------------------------------------------------------------------------ + call this%fates_restart%initialize_restart_vars() + + end if + + ! --------------------------------------------------------------------------------- + ! If we are writing, we must loop through our linked list structures and transfer the + ! information in the linked lists (FATES state memory) to the output vectors. + ! --------------------------------------------------------------------------------- + + if(flag=='write')then + !$OMP PARALLEL DO PRIVATE (nc) + do nc = 1, nclumps + if (this%fates(nc)%nsites>0) then + call this%fates_restart%set_restart_vectors(nc,this%fates(nc)%nsites, & + this%fates(nc)%sites) + end if + end do + !$OMP END PARALLEL DO + end if + + ! --------------------------------------------------------------------------------- + ! In all cases, iterate through the list of variable objects + ! and either define, write or read to the NC buffer + ! This seems strange, but keep in mind that the call to restartvar() + ! has a different function in all three cases. + ! --------------------------------------------------------------------------------- + + nvar = this%fates_restart%num_restart_vars() + do ivar = 1, nvar + + associate( vname => this%fates_restart%rvars(ivar)%vname, & + vunits => this%fates_restart%rvars(ivar)%units, & + vlong => this%fates_restart%rvars(ivar)%long ) + + dk_index = this%fates_restart%rvars(ivar)%dim_kinds_index + ioname = trim(this%fates_restart%dim_kinds(dk_index)%name) + + select case(trim(ioname)) + case(cohort_r8) + + call restartvar(ncid=ncid, flag=flag, varname=trim(vname), & + xtype=ncd_double,dim1name=trim('cohort'),long_name=trim(vlong), & + units=trim(vunits),interpinic_flag='interp', & + data=this%fates_restart%rvars(ivar)%r81d,readvar=readvar) + + case(site_r8) + + call restartvar(ncid=ncid, flag=flag, varname=trim(vname), & + xtype=ncd_double,dim1name=trim('column'),long_name=trim(vlong), & + units=trim(vunits),interpinic_flag='interp', & + data=this%fates_restart%rvars(ivar)%r81d,readvar=readvar) + + case(cohort_int) + + call restartvar(ncid=ncid, flag=flag, varname=trim(vname), & + xtype=ncd_int,dim1name=trim('cohort'),long_name=trim(vlong), & + units=trim(vunits),interpinic_flag='interp', & + data=this%fates_restart%rvars(ivar)%int1d,readvar=readvar) + + case(site_int) + + call restartvar(ncid=ncid, flag=flag, varname=trim(vname), & + xtype=ncd_int,dim1name=trim('column'),long_name=trim(vlong), & + units=trim(vunits),interpinic_flag='interp', & + data=this%fates_restart%rvars(ivar)%int1d,readvar=readvar) + + case default + write(iulog,*) 'A FATES iotype was created that was not registerred' + write(iulog,*) 'in CLM.:',trim(ioname) + call endrun(msg=errMsg(sourcefile, __LINE__)) + end select + + end associate + end do + + ! --------------------------------------------------------------------------------- + ! If we are in a read mode, then we have just populated the sparse vectors + ! in the IO object list. The data in these vectors needs to be transferred + ! to the linked lists to populate the state memory. + ! --------------------------------------------------------------------------------- + + if(flag=='read')then + + !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,s) + do nc = 1, nclumps + if (this%fates(nc)%nsites>0) then + + call get_clump_bounds(nc, bounds_clump) + + ! ------------------------------------------------------------------------ + ! Convert newly read-in vectors into the FATES namelist state variables + ! ------------------------------------------------------------------------ + call this%fates_restart%create_patchcohort_structure(nc, & + this%fates(nc)%nsites, this%fates(nc)%sites, this%fates(nc)%bc_in) + + call this%fates_restart%get_restart_vectors(nc, this%fates(nc)%nsites, & + this%fates(nc)%sites ) + + ! I think ed_update_site and update_hlmfates_dyn are doing some similar + ! update type stuff, should consolidate (rgk 11-2016) + do s = 1,this%fates(nc)%nsites + call ed_update_site( this%fates(nc)%sites(s), & + this%fates(nc)%bc_in(s) ) + end do + + ! ------------------------------------------------------------------------ + ! Update diagnostics of FATES ecosystem structure used in HLM. + ! ------------------------------------------------------------------------ + call this%wrap_update_hlmfates_dyn(nc,bounds_clump, & + waterstate_inst,canopystate_inst,frictionvel_inst) + + ! ------------------------------------------------------------------------ + ! Update history IO fields that depend on ecosystem dynamics + ! ------------------------------------------------------------------------ + call this%fates_hist%update_history_dyn( nc, & + this%fates(nc)%nsites, & + this%fates(nc)%sites) + + + end if + end do + !$OMP END PARALLEL DO + + end if + + return + end subroutine restart + + !===================================================================================== + + subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_inst, frictionvel_inst) + + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(waterstate_type) , intent(inout) :: waterstate_inst + type(canopystate_type) , intent(inout) :: canopystate_inst + type(soilstate_type) , intent(inout) :: soilstate_inst + type(frictionvel_type) , intent(inout) :: frictionvel_inst + + ! locals + integer :: nclumps + integer :: nc + type(bounds_type) :: bounds_clump + ! locals + real(r8) :: vol_ice + real(r8) :: eff_porosity + integer :: j + integer :: s + integer :: c + + nclumps = get_proc_clumps() + + !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,s,c,j,vol_ice,eff_porosity) + do nc = 1, nclumps + + if ( this%fates(nc)%nsites>0 ) then + + call get_clump_bounds(nc, bounds_clump) + + do s = 1,this%fates(nc)%nsites + call zero_site(this%fates(nc)%sites(s)) + end do + + call set_site_properties(this%fates(nc)%nsites, this%fates(nc)%sites) + + ! ---------------------------------------------------------------------------- + ! Initialize Hydraulics Code if turned on + ! Called prior to init_patches(). Site level rhizosphere shells must + ! be set prior to cohort initialization. + ! ---------------------------------------------------------------------------- + if (use_fates_plant_hydro) then + + do s = 1,this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + + this%fates(nc)%bc_in(s)%watsat_sisl(1:nlevsoi) = & + soilstate_inst%watsat_col(c,1:nlevsoi) + + this%fates(nc)%bc_in(s)%watres_sisl(1:nlevsoi) = spval !& +! soilstate_inst%watres_col(c,1:nlevsoi) + + this%fates(nc)%bc_in(s)%sucsat_sisl(1:nlevsoi) = & + soilstate_inst%sucsat_col(c,1:nlevsoi) + + this%fates(nc)%bc_in(s)%bsw_sisl(1:nlevsoi) = & + soilstate_inst%bsw_col(c,1:nlevsoi) + + this%fates(nc)%bc_in(s)%h2o_liq_sisl(1:nlevsoi) = & + waterstate_inst%h2osoi_liq_col(c,1:nlevsoi) + + this%fates(nc)%bc_in(s)%hksat_sisl(1:nlevsoi) = & + soilstate_inst%hksat_col(c,1:nlevsoi) + + do j = 1, nlevsoi + vol_ice = min(soilstate_inst%watsat_col(c,j), & + waterstate_inst%h2osoi_ice_col(c,j)/(col%dz(c,j)*denice)) + eff_porosity = max(0.01_r8,soilstate_inst%watsat_col(c,j)-vol_ice) + this%fates(nc)%bc_in(s)%eff_porosity_gl(j) = eff_porosity + end do + + end do + + if (use_fates_plant_hydro) call HydrSiteColdStart(this%fates(nc)%sites,this%fates(nc)%bc_in) + end if + + call init_patches(this%fates(nc)%nsites, this%fates(nc)%sites, & + this%fates(nc)%bc_in) + + do s = 1,this%fates(nc)%nsites + call ed_update_site(this%fates(nc)%sites(s), & + this%fates(nc)%bc_in(s)) + end do + + ! ------------------------------------------------------------------------ + ! Update diagnostics of FATES ecosystem structure used in HLM. + ! ------------------------------------------------------------------------ + call this%wrap_update_hlmfates_dyn(nc,bounds_clump, & + waterstate_inst,canopystate_inst,frictionvel_inst) + + ! ------------------------------------------------------------------------ + ! Update history IO fields that depend on ecosystem dynamics + ! ------------------------------------------------------------------------ + call this%fates_hist%update_history_dyn( nc, & + this%fates(nc)%nsites, & + this%fates(nc)%sites) + + + + end if + end do + !$OMP END PARALLEL DO + + end subroutine init_coldstart + + ! ====================================================================================== + + subroutine wrap_sunfrac(this,bounds_clump,atm2lnd_inst,canopystate_inst) + + ! --------------------------------------------------------------------------------- + ! This interface function is a wrapper call on ED_SunShadeFracs. The only + ! returned variable is a patch vector, fsun_patch, which describes the fraction + ! of the canopy that is exposed to sun. + ! --------------------------------------------------------------------------------- + + implicit none + + ! Input Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_clump + + ! direct and diffuse downwelling radiation (W/m2) + type(atm2lnd_type),intent(in) :: atm2lnd_inst + + ! Input/Output Arguments to CLM + type(canopystate_type),intent(inout) :: canopystate_inst + + ! Local Variables + integer :: p ! global index of the host patch + integer :: g ! global index of the host gridcell + integer :: c ! global index of the host column + + integer :: s ! FATES site index + integer :: ifp ! FATEs patch index + ! this is the order increment of patch + ! on the site + integer :: nc ! clump index + + type(ed_patch_type), pointer :: cpatch ! c"urrent" patch INTERF-TODO: SHOULD + ! BE HIDDEN AS A FATES PRIVATE + + associate( forc_solad => atm2lnd_inst%forc_solad_grc, & + forc_solai => atm2lnd_inst%forc_solai_grc, & + fsun => canopystate_inst%fsun_patch, & + laisun => canopystate_inst%laisun_patch, & + laisha => canopystate_inst%laisha_patch ) + + nc = bounds_clump%clump_index + ! ------------------------------------------------------------------------------- + ! Convert input BC's + ! The sun-shade calculations are performed only on FATES patches + ! ------------------------------------------------------------------------------- + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + g = col%gridcell(c) + + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + !do ifp = 1, this%fates(nc)%bc_in(s)%npatches + + p = ifp+col%pfti(c) + + this%fates(nc)%bc_in(s)%solad_parb(ifp,:) = forc_solad(g,:) + this%fates(nc)%bc_in(s)%solai_parb(ifp,:) = forc_solai(g,:) + + end do + end do + + ! ------------------------------------------------------------------------------- + ! Call FATES public function to calculate internal sun/shade structures + ! as well as total patch sun/shade fraction output boundary condition + ! ------------------------------------------------------------------------------- + + call ED_SunShadeFracs(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out) + + ! ------------------------------------------------------------------------------- + ! Transfer the FATES output boundary condition for canopy sun/shade fraction + ! to the HLM + ! ------------------------------------------------------------------------------- + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + p = ifp+col%pfti(c) + fsun(p) = this%fates(nc)%bc_out(s)%fsun_pa(ifp) + laisun(p) = this%fates(nc)%bc_out(s)%laisun_pa(ifp) + laisha(p) = this%fates(nc)%bc_out(s)%laisha_pa(ifp) + end do + end do + + end associate + + end subroutine wrap_sunfrac + + ! =================================================================================== + + subroutine prep_canopyfluxes(this, bounds_clump ) + + ! ---------------------------------------------------------------------- + ! the main function for calculating photosynthesis is called within a + ! loop based on convergence. Some intitializations, including + ! canopy resistance must be intitialized before the loop + ! The photosyns_ structure is currently unused, leaving it for now + ! in case we want to do any value initializing in future. + ! ---------------------------------------------------------------------- + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_clump + + ! locals + integer :: c,s + integer :: nc + + nc = bounds_clump%clump_index + do s = 1, this%fates(nc)%nsites + ! filter flag == 1 means that this patch has not been called for photosynthesis + this%fates(nc)%bc_in(s)%filter_photo_pa(:) = 1 + end do + end subroutine prep_canopyfluxes + + ! ==================================================================================== + + subroutine wrap_btran(this,bounds_clump,fn,filterc,soilstate_inst, waterstate_inst, & + temperature_inst, energyflux_inst, & + soil_water_retention_curve) + + ! --------------------------------------------------------------------------------- + ! This subroutine calculates btran for FATES, this will be an input boundary + ! condition for FATES photosynthesis/transpiration. + ! + ! This subroutine also calculates rootr + ! + ! --------------------------------------------------------------------------------- + + use SoilWaterRetentionCurveMod, only : soil_water_retention_curve_type + + implicit none + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_clump + integer , intent(in) :: fn + integer , intent(in) :: filterc(fn) ! This is a list of + ! columns with exposed veg + type(soilstate_type) , intent(inout) :: soilstate_inst + type(waterstate_type) , intent(in) :: waterstate_inst + type(temperature_type) , intent(in) :: temperature_inst + type(energyflux_type) , intent(inout) :: energyflux_inst + class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve + + ! local variables + real(r8) :: smp_node ! Soil suction potential, negative, [mm] + real(r8) :: s_node + integer :: s + integer :: c + integer :: j + integer :: ifp + integer :: p + integer :: nc + + associate(& + sucsat => soilstate_inst%sucsat_col , & ! Input: [real(r8) (:,:) ] minimum soil suction (mm) + watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation (porosity) + bsw => soilstate_inst%bsw_col , & ! Input: [real(r8) (:,:) ] Clapp and Hornberger "b" + eff_porosity => soilstate_inst%eff_porosity_col , & ! Input: [real(r8) (:,:) ] effective porosity = porosity - vol_ice + t_soisno => temperature_inst%t_soisno_col , & ! Input: [real(r8) (:,:) ] soil temperature (Kelvin) + h2osoi_liqvol => waterstate_inst%h2osoi_liqvol_col , & ! Input: [real(r8) (:,:) ] liquid volumetric moisture, will be used for BeTR + btran => energyflux_inst%btran_patch , & ! Output: [real(r8) (:) ] transpiration wetness factor (0 to 1) + btran2 => energyflux_inst%btran2_patch , & ! Output: [real(r8) (:) ] + rresis => energyflux_inst%rresis_patch , & ! Output: [real(r8) (:,:) ] root resistance by layer (0-1) (nlevgrnd) + rootr => soilstate_inst%rootr_patch & ! Output: [real(r8) (:,:) ] Fraction of water uptake in each layer + ) + + + nc = bounds_clump%clump_index + + ! ------------------------------------------------------------------------------- + ! Convert input BC's + ! Critical step: a filter is being passed in that dictates which columns have + ! exposed vegetation (above snow). This is necessary, because various hydrologic + ! variables like h2osoi_liqvol are not calculated and will have uninitialized + ! values outside this list. + ! + ! bc_in(s)%filter_btran (this is in, but is also used in this subroutine) + ! + ! We also filter a second time within this list by determining which soil layers + ! have conditions for active uptake based on soil moisture and temperature. This + ! must be determined by FATES (science stuff). But the list of layers and patches + ! needs to be passed back to the interface, because it then needs to request + ! suction on these layers via CLM/ALM functions. We cannot wide-swath calculate + ! this on all layers, because values with no moisture or low temps will generate + ! unstable values and cause sigtraps. + ! ------------------------------------------------------------------------------- + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + + ! Check to see if this column is in the exposed veg filter + if( any(filterc==c) )then + + this%fates(nc)%bc_in(s)%filter_btran = .true. + do j = 1,nlevgrnd + this%fates(nc)%bc_in(s)%tempk_gl(j) = t_soisno(c,j) + this%fates(nc)%bc_in(s)%h2o_liqvol_gl(j) = h2osoi_liqvol(c,j) + this%fates(nc)%bc_in(s)%eff_porosity_gl(j) = eff_porosity(c,j) + this%fates(nc)%bc_in(s)%watsat_gl(j) = watsat(c,j) + end do + + else + this%fates(nc)%bc_in(s)%filter_btran = .false. + this%fates(nc)%bc_in(s)%tempk_gl(:) = -999._r8 + this%fates(nc)%bc_in(s)%h2o_liqvol_gl(:) = -999._r8 + this%fates(nc)%bc_in(s)%eff_porosity_gl(:) = -999._r8 + this%fates(nc)%bc_in(s)%watsat_gl(:) = -999._r8 + end if + + end do + + ! ------------------------------------------------------------------------------- + ! This function evaluates the ground layer to determine if + ! root water uptake can happen, and soil suction should even + ! be calculated. We ask FATES for a boundary condition output + ! logical because we don't want science calculations in the interface + ! yet... hydrology (suction calculation) is provided by the host + ! so we need fates to tell us where to calculate suction + ! but not calculate it itself. Yeah, complicated, but thats life. + ! ------------------------------------------------------------------------------- + call get_active_suction_layers(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out) + + ! Now that the active layers of water uptake have been decided by fates + ! Calculate the suction that is passed back to fates + ! Note that the filter_btran is unioned with active_suction_gl + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + do j = 1,nlevgrnd + if(this%fates(nc)%bc_out(s)%active_suction_gl(j)) then + s_node = max(h2osoi_liqvol(c,j)/eff_porosity(c,j),0.01_r8) + call soil_water_retention_curve%soil_suction( soilstate_inst%sucsat_col(c,j), & + s_node, & + soilstate_inst%bsw_col(c,j), & + smp_node) + + ! Non-fates places a maximum (which is a negative upper bound) on smp + + this%fates(nc)%bc_in(s)%smp_gl(j) = smp_node + end if + end do + end do + + ! ------------------------------------------------------------------------------- + ! Suction and active uptake layers calculated, lets calculate uptake (btran) + ! This will calculate internals, as well as output boundary conditions: + ! btran, rootr + ! ------------------------------------------------------------------------------- + + call btran_ed(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out) + + ! ------------------------------------------------------------------------------- + ! Convert output BC's + ! For CLM/ALM this wrapper provides return variables that should + ! be similar to that of calc_root_moist_stress(). However, + ! CLM/ALM-FATES simulations will no make use of rresis, btran or btran2 + ! outside of FATES. We do not have code in place to calculate btran2 or + ! rresis right now, so we force to bad. We have btran calculated so we + ! pass it in case people want diagnostics. rootr is actually the only + ! variable that will be used, as it is needed to help distribute the + ! the transpiration sink to the appropriate layers. (RGK) + ! ------------------------------------------------------------------------------- + + do s = 1, this%fates(nc)%nsites + + c = this%f2hmap(nc)%fcolumn(s) + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + + p = ifp+col%pfti(c) + + do j = 1,nlevgrnd + + rresis(p,j) = -999.9 ! We do not calculate this correctly + ! it should not thought of as valid output until we decide to. + rootr(p,j) = this%fates(nc)%bc_out(s)%rootr_pagl(ifp,j) + btran(p) = this%fates(nc)%bc_out(s)%btran_pa(ifp) + btran2(p) = -999.9 ! Not available, force to nonsense + + end do + end do + end do + end associate + + end subroutine wrap_btran + + ! ==================================================================================== + + subroutine wrap_photosynthesis(this, bounds_clump, fn, filterp, & + esat_tv, eair, oair, cair, rb, dayl_factor, & + atm2lnd_inst, temperature_inst, canopystate_inst, photosyns_inst) + + use shr_log_mod , only : errMsg => shr_log_errMsg + use abortutils , only : endrun + use decompMod , only : bounds_type + use clm_varcon , only : rgas, tfrz, namep + use clm_varpar , only : nlevsoi + use clm_varctl , only : iulog + use perf_mod , only : t_startf, t_stopf + use quadraticMod , only : quadratic + use EDTypesMod , only : numpft_ed, dinc_ed + use EDtypesMod , only : ed_patch_type, ed_cohort_type, ed_site_type, numpft_ed + use EDEcophysContype , only : EDecophyscon + + ! + ! !ARGUMENTS: + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_clump + integer , intent(in) :: fn ! size of pft filter + integer , intent(in) :: filterp(fn) ! pft filter + real(r8) , intent(in) :: esat_tv(bounds_clump%begp: ) ! saturation vapor pressure at t_veg (Pa) + real(r8) , intent(in) :: eair( bounds_clump%begp: ) ! vapor pressure of canopy air (Pa) + real(r8) , intent(in) :: oair( bounds_clump%begp: ) ! Atmospheric O2 partial pressure (Pa) + real(r8) , intent(in) :: cair( bounds_clump%begp: ) ! Atmospheric CO2 partial pressure (Pa) + real(r8) , intent(in) :: rb( bounds_clump%begp: ) ! boundary layer resistance (s/m) + real(r8) , intent(in) :: dayl_factor( bounds_clump%begp: ) ! scalar (0-1) for daylength + type(atm2lnd_type) , intent(in) :: atm2lnd_inst + type(temperature_type) , intent(in) :: temperature_inst + type(canopystate_type) , intent(inout) :: canopystate_inst + type(photosyns_type) , intent(inout) :: photosyns_inst + + integer :: s,c,p,ifp,j,icp,nc + real(r8) :: dtime + + call t_startf('edpsn') + associate(& + t_soisno => temperature_inst%t_soisno_col , & + t_veg => temperature_inst%t_veg_patch , & + tgcm => temperature_inst%thm_patch , & + forc_pbot => atm2lnd_inst%forc_pbot_downscaled_col, & + rssun => photosyns_inst%rssun_patch , & + rssha => photosyns_inst%rssha_patch, & + psnsun => photosyns_inst%psnsun_patch, & + psnsha => photosyns_inst%psnsha_patch) + + + nc = bounds_clump%clump_index + + do s = 1, this%fates(nc)%nsites + + c = this%f2hmap(nc)%fcolumn(s) + + do j = 1,nlevsoi + this%fates(nc)%bc_in(s)%t_soisno_gl(j) = t_soisno(c,j) ! soil temperature (Kelvin) + end do + this%fates(nc)%bc_in(s)%forc_pbot = forc_pbot(c) ! atmospheric pressure (Pa) + + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + + p = ifp+col%pfti(c) + + ! Check to see if this patch is in the filter + ! Note that this filter is most likely changing size, and getting smaller + ! and smaller as more patch have converged on solution + if( any(filterp==p) )then + + ! This filter is flushed to 1 before the canopyflux stability iterator + ! It is set to status 2 if it is an active patch within the iterative loop + ! After photosynthesis is called, it is upgraded to 3 if it was called. + ! After all iterations we can evaluate which patches have a final flag + ! of 3 to check if we missed any. + + this%fates(nc)%bc_in(s)%filter_photo_pa(ifp) = 2 + this%fates(nc)%bc_in(s)%dayl_factor_pa(ifp) = dayl_factor(p) ! scalar (0-1) for daylength + this%fates(nc)%bc_in(s)%esat_tv_pa(ifp) = esat_tv(p) ! saturation vapor pressure at t_veg (Pa) + this%fates(nc)%bc_in(s)%eair_pa(ifp) = eair(p) ! vapor pressure of canopy air (Pa) + this%fates(nc)%bc_in(s)%oair_pa(ifp) = oair(p) ! Atmospheric O2 partial pressure (Pa) + this%fates(nc)%bc_in(s)%cair_pa(ifp) = cair(p) ! Atmospheric CO2 partial pressure (Pa) + this%fates(nc)%bc_in(s)%rb_pa(ifp) = rb(p) ! boundary layer resistance (s/m) + this%fates(nc)%bc_in(s)%t_veg_pa(ifp) = t_veg(p) ! vegetation temperature (Kelvin) + this%fates(nc)%bc_in(s)%tgcm_pa(ifp) = tgcm(p) ! air temperature at agcm reference height (kelvin) + end if + end do + end do + + dtime = get_step_size() + + ! Call photosynthesis + + call FatesPlantRespPhotosynthDrive (this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out, & + dtime) + + ! Perform a double check to see if all patches on naturally vegetated columns + ! were activated for photosynthesis + ! --------------------------------------------------------------------------------- + do icp = 1,fn + p = filterp(icp) + c = pft%column(p) + s = this%f2hmap(nc)%hsites(c) + ! do if structure here and only pass natveg columns + ifp = p-col%pfti(c) + if(this%fates(nc)%bc_in(s)%filter_photo_pa(ifp) /= 2)then + write(iulog,*) 'Not all patches on the natveg column in the photosynthesis' + write(iulog,*) 'filter ran photosynthesis' + call endrun(msg=errMsg(sourcefile, __LINE__)) + else + this%fates(nc)%bc_in(s)%filter_photo_pa(ifp) = 3 + rssun(p) = this%fates(nc)%bc_out(s)%rssun_pa(ifp) + rssha(p) = this%fates(nc)%bc_out(s)%rssha_pa(ifp) + + ! These fields are marked with a bad-value flag + photosyns_inst%psnsun_patch(p) = spval + photosyns_inst%psnsha_patch(p) = spval + end if + end do + + end associate + call t_stopf('edpsn') + + end subroutine wrap_photosynthesis + + ! ====================================================================================== + + subroutine wrap_accumulatefluxes(this, bounds_clump, fn, filterp) + + ! !ARGUMENTS: + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type) , intent(in) :: bounds_clump + integer , intent(in) :: fn ! size of pft filter + integer , intent(in) :: filterp(fn) ! pft filter + + ! Locals + integer :: s,c,p,ifp,icp + real(r8) :: dtime + integer :: nc + + nc = bounds_clump%clump_index + ! Run a check on the filter + do icp = 1,fn + p = filterp(icp) + c = pft%column(p) + s = this%f2hmap(nc)%hsites(c) + ifp = p-col%pfti(c) + if(this%fates(nc)%bc_in(s)%filter_photo_pa(ifp) /= 3)then + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + end do + + + dtime = get_step_size() + call AccumulateFluxes_ED(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out, & + dtime) + + + call this%fates_hist%update_history_prod(nc, & + this%fates(nc)%nsites, & + this%fates(nc)%sites, & + dtime) + + end subroutine wrap_accumulatefluxes + + ! ====================================================================================== + + subroutine wrap_canopy_radiation(this, bounds_clump, & + num_vegsol, filter_vegsol, coszen, surfalb_inst) + + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds_clump + ! filter for vegetated pfts with coszen>0 + integer , intent(in) :: num_vegsol + integer , intent(in) :: filter_vegsol(num_vegsol) + ! cosine solar zenith angle for next time step + real(r8) , intent(in) :: coszen( bounds_clump%begp: ) + type(surfalb_type) , intent(inout) :: surfalb_inst + + ! locals + integer :: s,c,p,ifp,icp,nc + + associate(& + albgrd_col => surfalb_inst%albgrd_col , & !in + albgri_col => surfalb_inst%albgri_col , & !in + albd => surfalb_inst%albd_patch , & !out + albi => surfalb_inst%albi_patch , & !out + fabd => surfalb_inst%fabd_patch , & !out + fabi => surfalb_inst%fabi_patch , & !out + ftdd => surfalb_inst%ftdd_patch , & !out + ftid => surfalb_inst%ftid_patch , & !out + ftii => surfalb_inst%ftii_patch) !out + + nc = bounds_clump%clump_index + + do s = 1, this%fates(nc)%nsites + + c = this%f2hmap(nc)%fcolumn(s) + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + + p = ifp+col%pfti(c) + + if( any(filter_vegsol==p) )then + + this%fates(nc)%bc_in(s)%filter_vegzen_pa(ifp) = .true. + this%fates(nc)%bc_in(s)%coszen_pa(ifp) = coszen(p) + this%fates(nc)%bc_in(s)%albgr_dir_rb(:) = albgrd_col(c,:) + this%fates(nc)%bc_in(s)%albgr_dif_rb(:) = albgri_col(c,:) + + else + + this%fates(nc)%bc_in(s)%filter_vegzen_pa(ifp) = .false. + + end if + + end do + end do + + call ED_Norman_Radiation(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out) + + ! Pass FATES BC's back to HLM + ! ----------------------------------------------------------------------------------- + do icp = 1,num_vegsol + p = filter_vegsol(icp) + c = pft%column(p) + s = this%f2hmap(nc)%hsites(c) + ! do if structure here and only pass natveg columns + ifp = p-col%pfti(c) + + if(.not.this%fates(nc)%bc_in(s)%filter_vegzen_pa(ifp) )then + write(iulog,*) 'Not all patches on the natveg column were passed to canrad' + call endrun(msg=errMsg(sourcefile, __LINE__)) + else + albd(p,:) = this%fates(nc)%bc_out(s)%albd_parb(ifp,:) + albi(p,:) = this%fates(nc)%bc_out(s)%albi_parb(ifp,:) + fabd(p,:) = this%fates(nc)%bc_out(s)%fabd_parb(ifp,:) + fabi(p,:) = this%fates(nc)%bc_out(s)%fabi_parb(ifp,:) + ftdd(p,:) = this%fates(nc)%bc_out(s)%ftdd_parb(ifp,:) + ftid(p,:) = this%fates(nc)%bc_out(s)%ftid_parb(ifp,:) + ftii(p,:) = this%fates(nc)%bc_out(s)%ftii_parb(ifp,:) + end if + end do + + end associate + + end subroutine wrap_canopy_radiation + + ! ====================================================================================== + + subroutine wrap_bgc_summary(this, bounds_clump, carbonflux_inst, carbonstate_inst) + + + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds_clump + type(carbonflux_type), intent(in) :: carbonflux_inst + type(carbonstate_type), intent(in) :: carbonstate_inst + + ! locals + real(r8) :: dtime + integer :: nstep + logical :: is_beg_day + integer :: s,c,nc + + associate(& + hr => carbonflux_inst%hr_col, & ! (gC/m2/s) total heterotrophic respiration + totsomc => carbonstate_inst%totsomc_col, & ! (gC/m2) total soil organic matter carbon + totlitc => carbonstate_inst%totlitc_col) ! (gC/m2) total litter carbon in BGC pools + + nc = bounds_clump%clump_index + + ! Summarize Net Fluxes + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates(nc)%bc_in(s)%tot_het_resp = hr(c) + this%fates(nc)%bc_in(s)%tot_somc = totsomc(c) + this%fates(nc)%bc_in(s)%tot_litc = totlitc(c) + end do + + is_beg_day = is_beg_curr_day() + dtime = get_step_size() + nstep = get_nstep() + + call SummarizeNetFluxes(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + is_beg_day) + + + call FATES_BGC_Carbon_Balancecheck(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + is_beg_day, & + dtime, nstep) + + + ! Update history variables that track these variables + call this%fates_hist%update_history_cbal(nc, & + this%fates(nc)%nsites, & + this%fates(nc)%sites) + + + end associate + end subroutine wrap_bgc_summary + + ! ====================================================================================== + + + subroutine TransferZ0mDisp(this,bounds_clump,frictionvel_inst,canopystate_inst) + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_clump + type(canopystate_type) , intent(inout) :: canopystate_inst + type(frictionvel_type) , intent(inout) :: frictionvel_inst + + ! Locals + integer :: ci ! Current clump index + integer :: s ! Site index + integer :: c ! Column index + integer :: ifp ! Fates patch index + integer :: p ! CLM patch index + + ci = bounds_clump%clump_index + + do s = 1, this%fates(ci)%nsites + c = this%f2hmap(ci)%fcolumn(s) + + frictionvel_inst%z0m_patch(col%pfti(c)+1:col%pftf(c)) = 0.0_r8 + canopystate_inst%displa_patch(col%pfti(c)+1:col%pftf(c)) = 0.0_r8 + + do ifp = 1, this%fates(ci)%sites(s)%youngest_patch%patchno + p = ifp+col%pfti(c) + frictionvel_inst%z0m_patch(p) = this%fates(ci)%bc_out(s)%z0m_pa(ifp) + canopystate_inst%displa_patch(p) = this%fates(ci)%bc_out(s)%displa_pa(ifp) + end do + end do + + return + end subroutine TransferZ0mDisp + + ! ====================================================================================== + + subroutine init_history_io(this,bounds_proc) + + use histFileMod, only : hist_addfld1d, hist_addfld2d, hist_addfld_decomp + + use FatesConstantsMod, only : fates_short_string_length, fates_long_string_length + use FatesIOVariableKindMod, only : patch_r8, patch_ground_r8, patch_size_pft_r8 + use FatesIOVariableKindMod, only : site_r8, site_ground_r8, site_size_pft_r8 + use FatesIOVariableKindMod, only : site_size_r8, site_pft_r8, site_age_r8 + use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8 + use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8 + use FatesIODimensionsMod, only : fates_bounds_type + + + ! Arguments + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_proc ! Currently "proc" + + + ! Locals + type(bounds_type) :: bounds_clump + integer :: nvar ! number of IO variables found + integer :: ivar ! variable index 1:nvar + integer :: nc ! thread counter 1:nclumps + integer :: nclumps ! number of threads on this proc + integer :: s ! FATES site index + integer :: c ! ALM/CLM column index + character(len=fates_short_string_length) :: dim2name + character(len=fates_long_string_length) :: ioname + integer :: d_index, dk_index + + type(fates_bounds_type) :: fates_bounds + type(fates_bounds_type) :: fates_clump + + ! This routine initializes the types of output variables + ! not the variables themselves, just the types + ! --------------------------------------------------------------------------------- + + nclumps = get_proc_clumps() + + ! ------------------------------------------------------------------------------------ + ! PART I: Set FATES DIMENSIONING INFORMATION + ! + ! ------------------------------------------------------------------------------- + ! Those who wish add variables that require new dimensions, please + ! see FATES: FatesHistoryInterfaceMod.F90. Dimension types are defined at the top of the + ! module, and a new explicitly named instance of that type should be created. + ! With this new dimension, a new output type/kind can contain that dimension. + ! A new type/kind can be added to the dim_kinds structure, which defines its members + ! in created in init_dim_kinds_maps(). Make sure to increase the size of fates_num_dim_kinds. + ! A type/kind of output is defined by the data type (ie r8,int,..) + ! and the dimensions. Keep in mind that 3D variables (or 4D if you include time) + ! are not really supported in CLM/ALM right now. There are ways around this + ! limitations by creating combined dimensions, for instance the size+pft dimension + ! "scpf" + ! ------------------------------------------------------------------------------------ + + call hlm_bounds_to_fates_bounds(bounds_proc, fates_bounds) + + call this%fates_hist%Init(nclumps, fates_bounds) + + ! Define the bounds on the first dimension for each thread + !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,fates_clump) + do nc = 1,nclumps + + call get_clump_bounds(nc, bounds_clump) + + ! thread bounds for patch + call hlm_bounds_to_fates_bounds(bounds_clump, fates_clump) + call this%fates_hist%SetThreadBoundsEach(nc, fates_clump) + end do + !$OMP END PARALLEL DO + + ! ------------------------------------------------------------------------------------ + ! PART I.5: SET SOME INDEX MAPPINGS SPECIFICALLY FOR SITE<->COLUMN AND PATCH + ! ------------------------------------------------------------------------------------ + + !$OMP PARALLEL DO PRIVATE (nc,s,c) + do nc = 1,nclumps + + allocate(this%fates_hist%iovar_map(nc)%site_index(this%fates(nc)%nsites)) + allocate(this%fates_hist%iovar_map(nc)%patch1_index(this%fates(nc)%nsites)) + + do s=1,this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates_hist%iovar_map(nc)%site_index(s) = c + this%fates_hist%iovar_map(nc)%patch1_index(s) = col%pfti(c)+1 + end do + + end do + !$OMP END PARALLEL DO + + ! ------------------------------------------------------------------------------------ + ! PART II: USE THE JUST DEFINED DIMENSIONS TO ASSEMBLE THE VALID IO TYPES + ! INTERF-TODO: THESE CAN ALL BE EMBEDDED INTO A SUBROUTINE IN HISTORYIOMOD + ! ------------------------------------------------------------------------------------ + call this%fates_hist%assemble_history_output_types() + + ! ------------------------------------------------------------------------------------ + ! PART III: DEFINE THE LIST OF OUTPUT VARIABLE OBJECTS, AND REGISTER THEM WITH THE + ! HLM ACCORDING TO THEIR TYPES + ! ------------------------------------------------------------------------------------ + call this%fates_hist%initialize_history_vars() + nvar = this%fates_hist%num_history_vars() + + do ivar = 1, nvar + + associate( vname => this%fates_hist%hvars(ivar)%vname, & + vunits => this%fates_hist%hvars(ivar)%units, & + vlong => this%fates_hist%hvars(ivar)%long, & + vdefault => this%fates_hist%hvars(ivar)%use_default, & + vavgflag => this%fates_hist%hvars(ivar)%avgflag) + + dk_index = this%fates_hist%hvars(ivar)%dim_kinds_index + ioname = trim(this%fates_hist%dim_kinds(dk_index)%name) + + select case(trim(ioname)) + case(patch_r8) + call hist_addfld1d(fname=trim(vname),units=trim(vunits), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_patch=this%fates_hist%hvars(ivar)%r81d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + + case(site_r8) + call hist_addfld1d(fname=trim(vname),units=trim(vunits), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r81d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + + case(patch_ground_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & ! <--- addfld2d + type2d=trim(dim2name), & ! <--- type2d + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_patch=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + + case(patch_size_pft_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_patch=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_ground_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_size_pft_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_size_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_pft_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_age_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_fuel_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_cwdsc_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_can_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_cnlf_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_cnlfpft_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + case(site_scag_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index + dim2name = this%fates_hist%dim_bounds(d_index)%name + call hist_addfld2d(fname=trim(vname),units=trim(vunits), & + type2d=trim(dim2name), & + avgflag=trim(vavgflag),long_name=trim(vlong), & + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault), & + set_lake=0._r8,set_urb=0._r8) + + + case default + write(iulog,*) 'A FATES iotype was created that was not registerred' + write(iulog,*) 'in CLM.:',trim(ioname) + call endrun(msg=errMsg(sourcefile, __LINE__)) + end select + + end associate + end do + end subroutine init_history_io + + ! ====================================================================================== + + subroutine init_soil_depths(this, nc) + + ! Input Arguments + class(hlm_fates_interface_type), intent(inout) :: this + integer,intent(in) :: nc ! Clump + + ! Locals + integer :: s ! site index + integer :: c ! column index + integer :: j ! Depth index + + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates(nc)%bc_in(s)%zi_sisl(0:hlm_numlevsoil) = col%zi(c,0:hlm_numlevsoil) + this%fates(nc)%bc_in(s)%dz_sisl(1:hlm_numlevsoil) = col%dz(c,1:hlm_numlevsoil) + this%fates(nc)%bc_in(s)%z_sisl(1:hlm_numlevsoil) = col%z(c,1:hlm_numlevsoil) + this%fates(nc)%bc_in(s)%dz_decomp_sisl(1:hlm_numlevdecomp_full) = & + dzsoi_decomp(1:hlm_numlevdecomp_full) + end do + + return + end subroutine init_soil_depths + + ! ====================================================================================== + + subroutine ComputeRootSoilFlux(this, bounds_clump, num_filterc, filterc, & + soilstate_inst, waterflux_inst) + + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_clump + integer,intent(in) :: num_filterc + integer,intent(in) :: filterc(num_filterc) + type(soilstate_type), intent(inout) :: soilstate_inst + type(waterflux_type), intent(inout) :: waterflux_inst + + ! locals + integer :: s + integer :: c + integer :: l + integer :: nc + integer :: num_filter_fates + + + if( .not. use_fates_plant_hydro ) return + + nc = bounds_clump%clump_index + + ! Perform a check that the number of columns submitted to fates for + ! root water sink is the same that was expected in the hydrology filter + num_filter_fates = 0 + do s = 1,num_filterc + l = col%landunit(filterc(s)) + if (lun%itype(l) == istsoil ) then + num_filter_fates = num_filter_fates + 1 + end if + end do + + if(num_filter_fates .ne. this%fates(nc)%nsites )then + write(iulog,*) 'The HLM list of natural veg columns during root water transfer' + write(iulog,*) 'is not the same size as the fates site list?' + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + waterflux_inst%qflx_rootsoi_col(c,:) = this%fates(nc)%bc_out(s)%qflx_soil2root_sisl(:) + end do + + end subroutine ComputeRootSoilFlux + + ! ====================================================================================== +! +! THIS WAS MOVED TO WRAP_HYDRAULICS_DRIVE() +! +! subroutine TransferPlantWaterStorage(this, bounds_clump, nc, waterstate_inst) +! +! implicit none +! class(hlm_fates_interface_type), intent(inout) :: this +! type(bounds_type),intent(in) :: bounds_clump +! integer,intent(in) :: nc +! type(waterstate_type) , intent(inout) :: waterstate_inst +! +! ! locals +! integer :: s +! integer :: c +! +! if (.not. (use_ed .and. use_fates_plant_hydro) ) return +! +! do s = 1, this%fates(nc)%nsites +! c = this%f2hmap(nc)%fcolumn(s) +! waterstate_inst%total_plant_stored_h2o_col(c) = & +! this%fates(nc)%bc_out(s)%plant_stored_h2o_si +! end do +! return +!end subroutine TransferPlantWaterStorage + + + + + ! ====================================================================================== + + subroutine wrap_hydraulics_drive(this, bounds_clump, & + soilstate_inst, waterstate_inst, waterflux_inst, & + solarabs_inst, energyflux_inst) + + + implicit none + class(hlm_fates_interface_type), intent(inout) :: this + type(bounds_type),intent(in) :: bounds_clump + type(soilstate_type) , intent(inout) :: soilstate_inst + type(waterstate_type) , intent(inout) :: waterstate_inst + type(waterflux_type) , intent(inout) :: waterflux_inst + type(solarabs_type) , intent(in) :: solarabs_inst + type(energyflux_type) , intent(inout) :: energyflux_inst + + ! locals + integer :: s + integer :: c + integer :: j + integer :: ifp + integer :: p + integer :: nc + real(r8) :: dtime + + + if ( .not.use_fates_plant_hydro ) return + + nc = bounds_clump%clump_index + dtime = get_step_size() + + ! Prepare Input Boundary Conditions + ! ------------------------------------------------------------------------------------ + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + this%fates(nc)%bc_in(s)%smpmin_si = & + soilstate_inst%smpmin_col(c) + this%fates(nc)%bc_in(s)%watsat_sisl(1:nlevsoi) = & + soilstate_inst%watsat_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%watres_sisl(1:nlevsoi) = spval !& +! soilstate_inst%watres_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%sucsat_sisl(1:nlevsoi) = & + soilstate_inst%sucsat_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%bsw_sisl(1:nlevsoi) = & + soilstate_inst%bsw_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%h2o_liq_sisl(1:nlevsoi) = & + waterstate_inst%h2osoi_liq_col(c,1:nlevsoi) + this%fates(nc)%bc_in(s)%eff_porosity_gl(1:nlevsoi) = & + soilstate_inst%eff_porosity_col(c,1:nlevsoi) + + do ifp = 1, this%fates(nc)%sites(s)%youngest_patch%patchno + p = ifp+col%pfti(c) + this%fates(nc)%bc_in(s)%swrad_net_pa(ifp) = solarabs_inst%fsa_patch(p) + this%fates(nc)%bc_in(s)%lwrad_net_pa(ifp) = energyflux_inst%eflx_lwrad_net_patch(p) + this%fates(nc)%bc_in(s)%qflx_transp_pa(ifp) = waterflux_inst%qflx_tran_veg_patch(p) + end do + end do + + ! Call Fates Hydraulics + ! ------------------------------------------------------------------------------------ + + + call hydraulics_drive(this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in, & + this%fates(nc)%bc_out, & + dtime) + + ! Prepare Output Boundary Conditions + ! ------------------------------------------------------------------------------------ + + do s = 1, this%fates(nc)%nsites + c = this%f2hmap(nc)%fcolumn(s) + waterstate_inst%total_plant_stored_h2o_col(c) = & + this%fates(nc)%bc_out(s)%plant_stored_h2o_si + end do + + + ! Update History Buffers that need to be updated after hydraulics calls + + call this%fates_hist%update_history_hydraulics(nc, & + this%fates(nc)%nsites, & + this%fates(nc)%sites, & + dtime) + + + return + end subroutine wrap_hydraulics_drive + + ! ====================================================================================== + + subroutine hlm_bounds_to_fates_bounds(hlm, fates) + + use FatesIODimensionsMod, only : fates_bounds_type + use EDtypesMod, only : nlevsclass_ed, nlevage_ed + use EDtypesMod, only : nfsc, ncwd + use EDtypesMod, only : nlevleaf, nclmax, numpft_ed + use EDTypesMod, only : maxpft + use clm_varpar, only : nlevgrnd + + implicit none + + type(bounds_type), intent(in) :: hlm + type(fates_bounds_type), intent(out) :: fates + + fates%cohort_begin = hlm%begcohort + fates%cohort_end = hlm%endcohort + + fates%patch_begin = hlm%begp + fates%patch_end = hlm%endp + + fates%column_begin = hlm%begc + fates%column_end = hlm%endc + + fates%ground_begin = 1 + fates%ground_end = nlevgrnd + + fates%sizepft_class_begin = 1 + fates%sizepft_class_end = nlevsclass_ed * maxpft + + fates%size_class_begin = 1 + fates%size_class_end = nlevsclass_ed + + fates%pft_class_begin = 1 + fates%pft_class_end = maxpft + + fates%age_class_begin = 1 + fates%age_class_end = nlevage_ed + + fates%sizeage_class_begin = 1 + fates%sizeage_class_end = nlevsclass_ed * nlevage_ed + + fates%fuel_begin = 1 + fates%fuel_end = nfsc + + fates%cwdsc_begin = 1 + fates%cwdsc_end = ncwd + + fates%can_begin = 1 + fates%can_end = nclmax + + fates%cnlf_begin = 1 + fates%cnlf_end = nlevleaf * nclmax + + fates%cnlfpft_begin = 1 + fates%cnlfpft_end = nlevleaf * nclmax * numpft_ed + + end subroutine hlm_bounds_to_fates_bounds + +end module CLMFatesInterfaceMod diff --git a/components/clm/src/main/clmfates_paraminterfaceMod.F90 b/components/clm/src/main/clmfates_paraminterfaceMod.F90 new file mode 100644 index 000000000000..edddbd130bd4 --- /dev/null +++ b/components/clm/src/main/clmfates_paraminterfaceMod.F90 @@ -0,0 +1,238 @@ +module CLMFatesParamInterfaceMod + ! NOTE(bja, 2017-01) this code can not go into the main clm-fates + ! interface module because of circular dependancies with pftvarcon. + + use FatesGlobals, only : fates_log + + implicit none + + ! NOTE(bja, 2017-01) these methods can NOT be part of the clmi-fates + ! nterface type because they are called before the instance is + ! initialized. + public :: FatesReadParameters + public :: FatesReadPFTs + private :: ParametersFromNetCDF + private :: SetParameterDimensions + private :: GetUsedDimensionSizes + + logical :: DEBUG = .false. + + character(len=*), parameter, private :: sourcefile = & + __FILE__ + +contains + + !----------------------------------------------------------------------- + subroutine FatesReadParameters() + + use clm_varctl, only : use_ed, paramfile, fates_paramfile + use spmdMod, only : masterproc + + use FatesParametersInterface, only : fates_parameters_type + + use EDParamsMod, only : FatesRegisterParams, FatesReceiveParams + use SFParamsMod, only : SpitFireRegisterParams, SpitFireReceiveParams + use FatesSynchronizedParamsMod, only : FatesSynchronizedParamsInst + + implicit none + + character(len=32) :: subname = 'FatesReadParameters' + class(fates_parameters_type), allocatable :: fates_params + logical :: is_host_file + + if (use_ed) then + if (masterproc) then + write(fates_log(), *) 'clmfates_parameterinterfaceMod.F90::'//trim(subname)//' :: CLM reading ED/FATES '//' parameters ' + end if + + allocate(fates_params) + call fates_params%Init() + call FatesRegisterParams(fates_params) + call SpitFireRegisterParams(fates_params) + call FatesSynchronizedParamsInst%RegisterParams(fates_params) + + is_host_file = .false. + call ParametersFromNetCDF(fates_paramfile, is_host_file, fates_params) + + is_host_file = .true. + call ParametersFromNetCDF(paramfile, is_host_file, fates_params) + + call FatesReceiveParams(fates_params) + call SpitFireReceiveParams(fates_params) + call FatesSynchronizedParamsInst%ReceiveParams(fates_params) + + call fates_params%Destroy() + deallocate(fates_params) + end if + + end subroutine FatesReadParameters + + !----------------------------------------------------------------------- + subroutine FatesReadPFTs() + + use clm_varctl, only : use_ed, paramfile, fates_paramfile + use spmdMod, only : masterproc + + use FatesParametersInterface, only : fates_parameters_type + use EDPftvarcon , only : EDPftvarcon_inst + + use fileutils , only : getfil + use ncdio_pio , only : file_desc_t, ncd_pio_closefile, ncd_pio_openfile + + implicit none + + character(len=32) :: subname = 'FatesReadPFTs' + class(fates_parameters_type), allocatable :: fates_params + logical :: is_host_file + + character(len=256) :: locfn ! local file name + type(file_desc_t) :: ncid ! pio netCDF file id + + if (use_ed) then + if (masterproc) then + write(fates_log(), *) 'clmfates_interfaceMod.F90::'//trim(subname)//' :: CLM reading ED/FATES '//' PFTs ' + end if + + allocate(fates_params) + call fates_params%Init() + call EDPftvarcon_inst%Init() + + call EDPftvarcon_inst%Register(fates_params) + + is_host_file = .false. + call ParametersFromNetCDF(fates_paramfile, is_host_file, fates_params) + + is_host_file = .true. + call ParametersFromNetCDF(paramfile, is_host_file, fates_params) + + call EDPftvarcon_inst%Receive(fates_params) + + call fates_params%Destroy() + deallocate(fates_params) + end if + + end subroutine FatesReadPFTs + + !----------------------------------------------------------------------- + subroutine SetParameterDimensions(ncid, is_host_file, fates_params) + ! Get the list of dimensions used by the fates parameters, + ! retreive them from the parameter file, then give the information + ! back to fates. + use FatesParametersInterface, only : fates_parameters_type, param_string_length, max_dimensions, max_used_dimensions + use ncdio_pio , only : file_desc_t + + implicit none + + type(file_desc_t), intent(inout) :: ncid + logical, intent(in) :: is_host_file + class(fates_parameters_type), intent(inout) :: fates_params + + integer :: num_used_dimensions + character(len=param_string_length) :: used_dimension_names(max_used_dimensions) + integer :: used_dimension_sizes(max_used_dimensions) + + call fates_params%GetUsedDimensions(is_host_file, num_used_dimensions, used_dimension_names) + + call GetUsedDimensionSizes(ncid, num_used_dimensions, used_dimension_names, used_dimension_sizes) + + call fates_params%SetDimensionSizes(is_host_file, num_used_dimensions, used_dimension_names, used_dimension_sizes) + + end subroutine SetParameterDimensions + + !----------------------------------------------------------------------- + subroutine GetUsedDimensionSizes(ncid, num_used_dimensions, dimension_names, dimension_sizes) + + use ncdio_pio , only : ncd_inqdid, ncd_inqdlen + use FatesParametersInterface, only : param_string_length + use ncdio_pio, only : file_desc_t + + + implicit none + + type(file_desc_t), intent(inout) :: ncid + integer, intent(in) :: num_used_dimensions + character(len=param_string_length), intent(in) :: dimension_names(:) + integer, intent(out) :: dimension_sizes(:) + + integer :: d, max_dim_size, num_dims + integer :: dim_len, dim_id + + dimension_sizes(:) = 0 + max_dim_size = 0 + + do d = 1, num_used_dimensions + call ncd_inqdid(ncid, dimension_names(d), dim_id) + call ncd_inqdlen(ncid, dim_id, dim_len) + dimension_sizes(d) = dim_len + !write(*, *) '--> ', trim(dimension_names(d)), ' setting size ', dimension_sizes(d) + end do + + end subroutine GetUsedDimensionSizes + + !----------------------------------------------------------------------- + subroutine ParametersFromNetCDF(filename, is_host_file, fates_params) + + use shr_kind_mod, only: r8 => shr_kind_r8 + use abortutils, only : endrun + use fileutils , only : getfil + use ncdio_pio , only : file_desc_t, ncd_pio_closefile, ncd_pio_openfile + use paramUtilMod, only : readNcdio + + use FatesParametersInterface, only : fates_parameters_type + use FatesParametersInterface, only : param_string_length, max_dimensions, max_used_dimensions + use FatesParametersInterface, only : dimension_shape_scalar, dimension_shape_1d, dimension_shape_2d + + implicit none + + character(len=*), intent(in) :: filename + logical, intent(in) :: is_host_file + class(fates_parameters_type), intent(inout) :: fates_params + + character(len=32) :: subname = 'clmfates_interface::ReadParameters' + character(len=256) :: locfn ! local file name + type(file_desc_t) :: ncid ! pio netCDF file id + integer :: dimid ! netCDF dimension id + integer :: i, num_params, dimension_shape + integer :: max_dim_size + real(r8), allocatable :: data(:, :) + character(len=param_string_length) :: name + integer :: dimension_sizes(max_dimensions) + character(len=param_string_length) :: dimension_names(max_dimensions) + integer :: size_dim_1, size_dim_2 + logical :: is_host_param + + call getfil (filename, locfn, 0) + call ncd_pio_openfile (ncid, trim(locfn), 0) + + call SetParameterDimensions(ncid, is_host_file, fates_params) + max_dim_size = fates_params%GetMaxDimensionSize() + allocate(data(max_dim_size, max_dim_size)) + + num_params = fates_params%num_params() + do i = 1, num_params + call fates_params%GetMetaData(i, name, dimension_shape, dimension_sizes, dimension_names, is_host_param) + if (is_host_file .eqv. is_host_param) then + select case(dimension_shape) + case(dimension_shape_scalar) + size_dim_1 = 1 + size_dim_2 = 1 + case(dimension_shape_1d) + size_dim_1 = dimension_sizes(1) + size_dim_2 = 1 + case(dimension_shape_2d) + size_dim_1 = dimension_sizes(1) + size_dim_2 = dimension_sizes(2) + case default + call endrun(msg='unsupported number of dimensions reading parameters.') + end select + write(fates_log(), *) 'clmfates_interfaceMod.F90:: reading '//trim(name) + call readNcdio(ncid, name, dimension_shape, dimension_names, subname, data(1:size_dim_1, 1:size_dim_2)) + call fates_params%SetData(i, data(1:size_dim_1, 1:size_dim_2)) + end if + end do + deallocate(data) + call ncd_pio_closefile(ncid) + end subroutine ParametersFromNetCDF + !----------------------------------------------------------------------- + +end module CLMFatesParamInterfaceMod diff --git a/components/clm/src/main/controlMod.F90 b/components/clm/src/main/controlMod.F90 index 6963b005d94a..668404eaafdd 100644 --- a/components/clm/src/main/controlMod.F90 +++ b/components/clm/src/main/controlMod.F90 @@ -214,7 +214,7 @@ subroutine control_init( ) namelist /clm_inparm / use_c13, use_c14 - namelist /clm_inparm / use_ed, use_ed_spit_fire + namelist /clm_inparm / fates_paramfile, use_ed, use_ed_spitfire namelist /clm_inparm / use_betr @@ -601,7 +601,8 @@ subroutine control_spmd() call mpi_bcast (use_c14, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_ed, 1, MPI_LOGICAL, 0, mpicom, ier) - call mpi_bcast (use_ed_spit_fire, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_ed_spitfire, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (fates_paramfile, len(fates_paramfile) , MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (use_betr, 1, MPI_LOGICAL, 0, mpicom, ier) diff --git a/components/clm/src/main/histFileMod.F90 b/components/clm/src/main/histFileMod.F90 index c0ba68b8b566..59b69dfd6ef8 100644 --- a/components/clm/src/main/histFileMod.F90 +++ b/components/clm/src/main/histFileMod.F90 @@ -12,7 +12,7 @@ module histFileMod use shr_sys_mod , only : shr_sys_flush use spmdMod , only : masterproc use abortutils , only : endrun - use clm_varctl , only : iulog, use_vertsoilc + use clm_varctl , only : iulog, use_vertsoilc, use_ed use clm_varcon , only : spval, ispval, dzsoi_decomp use clm_varcon , only : grlnd, nameg, namel, namec, namep use decompMod , only : get_proc_bounds, get_proc_global, bounds_type @@ -20,7 +20,11 @@ module histFileMod use LandunitType , only : lun use ColumnType , only : col use PatchType , only : pft - use ncdio_pio + use ncdio_pio + use EDtypesMod , only : nlevsclass_ed, nlevage_ed + use EDtypesMod , only : nfsc, ncwd + use EDtypesMod , only : nlevleaf, nclmax, numpft_ed + use EDTypesMod , only : maxpft ! implicit none save @@ -33,6 +37,7 @@ module histFileMod integer , public, parameter :: max_tapes = 6 ! max number of history tapes integer , public, parameter :: max_flds = 2500 ! max number of history fields integer , public, parameter :: max_namlen = 64 ! maximum number of characters for field name + integer , private, parameter :: hist_dim_name_length = 16 ! lenngth of character strings in dimension names ! Possible ways to treat multi-layer snow fields at times when no snow is present in a ! given layer. Note that the public parameters are the only ones that can be used by @@ -150,9 +155,9 @@ module histFileMod character(len=max_namlen) :: name ! field name character(len=max_chars) :: long_name ! long name character(len=max_chars) :: units ! units - character(len=8) :: type1d ! pointer to first dimension type from data type (nameg, etc) - character(len=8) :: type1d_out ! hbuf first dimension type from data type (nameg, etc) - character(len=8) :: type2d ! hbuf second dimension type ["levgrnd","levlak","numrad","ltype","natpft","cft","glc_nec","elevclas","subname(n)"] + character(len=hist_dim_name_length) :: type1d ! pointer to first dimension type from data type (nameg, etc) + character(len=hist_dim_name_length) :: type1d_out ! hbuf first dimension type from data type (nameg, etc) + character(len=hist_dim_name_length) :: type2d ! hbuf second dimension type ["levgrnd","levlak","numrad","ltype","natpft","cft","glc_nec","elevclas","subname(n)"] integer :: beg1d ! on-node 1d clm pointer start index integer :: end1d ! on-node 1d clm pointer end index integer :: num1d ! size of clm pointer first dimension (all nodes) @@ -812,8 +817,8 @@ subroutine htape_addfld (t, f, avgflag) ! ! !LOCAL VARIABLES: integer :: n ! field index on defined tape - character(len=8) :: type1d ! clm pointer 1d type - character(len=8) :: type1d_out ! history buffer 1d type + character(len=hist_dim_name_length) :: type1d ! clm pointer 1d type + character(len=hist_dim_name_length) :: type1d_out ! history buffer 1d type integer :: numa ! total number of atm cells across all processors integer :: numg ! total number of gridcells across all processors integer :: numl ! total number of landunits across all processors @@ -1003,8 +1008,8 @@ subroutine hist_update_hbuf_field_1d (t, f, bounds) logical :: check_active ! true => check 'active' flag of each point (this refers to a point being active, NOT a history field being active) logical :: valid ! true => history operation is valid logical :: map2gcell ! true => map clm pointer field to gridcell - character(len=8) :: type1d ! 1d clm pointerr type ["gridcell","landunit","column","pft"] - character(len=8) :: type1d_out ! 1d history buffer type ["gridcell","landunit","column","pft"] + character(len=hist_dim_name_length) :: type1d ! 1d clm pointerr type ["gridcell","landunit","column","pft"] + character(len=hist_dim_name_length) :: type1d_out ! 1d history buffer type ["gridcell","landunit","column","pft"] character(len=1) :: avgflag ! time averaging flag character(len=8) :: p2c_scale_type ! scale type for subgrid averaging of pfts to column character(len=8) :: c2l_scale_type ! scale type for subgrid averaging of columns to landunits @@ -1244,8 +1249,8 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d) logical :: check_active ! true => check 'active' flag of each point (this refers to a point being active, NOT a history field being active) logical :: valid ! true => history operation is valid logical :: map2gcell ! true => map clm pointer field to gridcell - character(len=8) :: type1d ! 1d clm pointerr type ["gridcell","landunit","column","pft"] - character(len=8) :: type1d_out ! 1d history buffer type ["gridcell","landunit","column","pft"] + character(len=hist_dim_name_length) :: type1d ! 1d clm pointerr type ["gridcell","landunit","column","pft"] + character(len=hist_dim_name_length) :: type1d_out ! 1d history buffer type ["gridcell","landunit","column","pft"] character(len=1) :: avgflag ! time averaging flag character(len=8) :: p2c_scale_type ! scale type for subgrid averaging of pfts to column character(len=8) :: c2l_scale_type ! scale type for subgrid averaging of columns to landunits @@ -1833,9 +1838,23 @@ subroutine htape_create (t, histrest) do n = 1,num_subs call ncd_defdim(lnfid, subs_name(n), subs_dim(n), dimid) end do - call ncd_defdim(lnfid, 'string_length', 8, strlen_dimid) + call ncd_defdim(lnfid, 'string_length', hist_dim_name_length, strlen_dimid) call ncd_defdim( lnfid, 'levdcmp', nlevdecomp_full, dimid) call ncd_defdim( lnfid, 'levtrc', nlevtrc_full, dimid) + + if(use_ed)then + call ncd_defdim(lnfid, 'fates_levscag', nlevsclass_ed * nlevage_ed, dimid) + call ncd_defdim(lnfid, 'fates_levscls', nlevsclass_ed, dimid) + call ncd_defdim(lnfid, 'fates_levpft', maxpft, dimid) + call ncd_defdim(lnfid, 'fates_levage', nlevage_ed, dimid) + call ncd_defdim(lnfid, 'fates_levfuel', nfsc, dimid) + call ncd_defdim(lnfid, 'fates_levcwdsc', ncwd, dimid) + call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass_ed*maxpft, dimid) + call ncd_defdim(lnfid, 'fates_levcan', nclmax, dimid) + call ncd_defdim(lnfid, 'fates_levcnlf', nlevleaf * nclmax, dimid) + call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * numpft_ed, dimid) + end if + if ( .not. lhistrest )then call ncd_defdim(lnfid, 'hist_interval', 2, hist_interval_dimid) call ncd_defdim(lnfid, 'time', ncd_unlimited, time_dimid) @@ -2226,6 +2245,12 @@ subroutine htape_timeconst(t, mode) use domainMod , only : ldomain, lon1d, lat1d use clm_time_manager, only : get_nstep, get_curr_date, get_curr_time use clm_time_manager, only : get_ref_date, get_calendar, NO_LEAP_C, GREGORIAN_C + use EDTypesMod, only : fates_hdim_levsclass, fates_hdim_pfmap_levscpf, fates_hdim_scmap_levscpf + use EDTypesMod, only : fates_hdim_levage, fates_hdim_levpft + use EDTypesMod, only : fates_hdim_scmap_levscag, fates_hdim_agmap_levscag + use EDTypesMod, only : fates_hdim_levfuel, fates_hdim_levcwdsc + use EDTypesMod, only : fates_hdim_levcan, fates_hdim_canmap_levcnlf, fates_hdim_lfmap_levcnlf + use EDTypesMod, only : fates_hdim_canmap_levcnlfpf, fates_hdim_lfmap_levcnlfpf, fates_hdim_pftmap_levcnlfpf ! ! !ARGUMENTS: integer, intent(in) :: t ! tape index @@ -2268,13 +2293,48 @@ subroutine htape_timeconst(t, mode) if (tape(t)%ntimes == 1) then if (mode == 'define') then call ncd_defvar(varname='levgrnd', xtype=tape(t)%ncprec, & - dim1name='levgrnd', & - long_name='coordinate soil levels', units='m', ncid=nfid(t)) + dim1name='levgrnd', & + long_name='coordinate soil levels', units='m', ncid=nfid(t)) call ncd_defvar(varname='levlak', xtype=tape(t)%ncprec, & - dim1name='levlak', & - long_name='coordinate lake levels', units='m', ncid=nfid(t)) + dim1name='levlak', & + long_name='coordinate lake levels', units='m', ncid=nfid(t)) call ncd_defvar(varname='levdcmp', xtype=tape(t)%ncprec, dim1name='levdcmp', & - long_name='coordinate soil levels', units='m', ncid=nfid(t)) + long_name='coordinate soil levels', units='m', ncid=nfid(t)) + + if(use_ed)then + + call ncd_defvar(varname='fates_levscls', xtype=tape(t)%ncprec, dim1name='fates_levscls', & + long_name='FATES diameter size class lower bound', units='cm', ncid=nfid(t)) + call ncd_defvar(varname='fates_scmap_levscag', xtype=ncd_int, dim1name='fates_levscag', & + long_name='FATES size-class map into size x patch age', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_agmap_levscag', xtype=ncd_int, dim1name='fates_levscag', & + long_name='FATES age-class map into size x patch age', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_pftmap_levscpf',xtype=ncd_int, dim1name='fates_levscpf', & + long_name='FATES pft index of the combined pft-size class dimension', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_scmap_levscpf',xtype=ncd_int, dim1name='fates_levscpf', & + long_name='FATES size index of the combined pft-size class dimension', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_levage',xtype=tape(t)%ncprec, dim1name='fates_levage', & + long_name='FATES patch age (yr)', ncid=nfid(t)) + call ncd_defvar(varname='fates_levpft',xtype=ncd_int, dim1name='fates_levpft', & + long_name='FATES pft number', ncid=nfid(t)) + call ncd_defvar(varname='fates_levfuel',xtype=ncd_int, dim1name='fates_levfuel', & + long_name='FATES fuel index', ncid=nfid(t)) + call ncd_defvar(varname='fates_levcwdsc',xtype=ncd_int, dim1name='fates_levcwdsc', & + long_name='FATES cwd size class', ncid=nfid(t)) + call ncd_defvar(varname='fates_levcan',xtype=ncd_int, dim1name='fates_levcan', & + long_name='FATES canopy level', ncid=nfid(t)) + call ncd_defvar(varname='fates_canmap_levcnlf',xtype=ncd_int, dim1name='fates_levcnlf', & + long_name='FATES canopy level of combined canopy-leaf dimension', ncid=nfid(t)) + call ncd_defvar(varname='fates_lfmap_levcnlf',xtype=ncd_int, dim1name='fates_levcnlf', & + long_name='FATES leaf level of combined canopy-leaf dimension', ncid=nfid(t)) + call ncd_defvar(varname='fates_canmap_levcnlfpf',xtype=ncd_int, dim1name='fates_levcnlfpf', & + long_name='FATES canopy level of combined canopy x leaf x pft dimension', ncid=nfid(t)) + call ncd_defvar(varname='fates_lfmap_levcnlfpf',xtype=ncd_int, dim1name='fates_levcnlfpf', & + long_name='FATES leaf level of combined canopy x leaf x pft dimension', ncid=nfid(t)) + call ncd_defvar(varname='fates_pftmap_levcnlfpf',xtype=ncd_int, dim1name='fates_levcnlfpf', & + long_name='FATES PFT level of combined canopy x leaf x pft dimension', ncid=nfid(t)) + end if + elseif (mode == 'write') then if ( masterproc ) write(iulog, *) ' zsoi:',zsoi call ncd_io(varname='levgrnd', data=zsoi, ncid=nfid(t), flag='write') @@ -2285,6 +2345,24 @@ subroutine htape_timeconst(t, mode) zsoi_1d(1) = 1._r8 call ncd_io(varname='levdcmp', data=zsoi_1d, ncid=nfid(t), flag='write') end if + if(use_ed)then + call ncd_io(varname='fates_scmap_levscag',data=fates_hdim_scmap_levscag, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_agmap_levscag',data=fates_hdim_agmap_levscag, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levscls',data=fates_hdim_levsclass, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_pftmap_levscpf',data=fates_hdim_pfmap_levscpf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_scmap_levscpf',data=fates_hdim_scmap_levscpf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levage',data=fates_hdim_levage, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levpft',data=fates_hdim_levpft, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levfuel',data=fates_hdim_levfuel, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levcwdsc',data=fates_hdim_levcwdsc, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levcan',data=fates_hdim_levcan, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_canmap_levcnlf',data=fates_hdim_canmap_levcnlf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_lfmap_levcnlf',data=fates_hdim_lfmap_levcnlf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_canmap_levcnlfpf',data=fates_hdim_canmap_levcnlfpf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_lfmap_levcnlfpf',data=fates_hdim_lfmap_levcnlfpf, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_pftmap_levcnlfpf',data=fates_hdim_pftmap_levcnlfpf, ncid=nfid(t), flag='write') + end if + endif endif @@ -2504,8 +2582,8 @@ subroutine hfields_write(t, mode) character(len=max_chars) :: units ! units character(len=max_namlen):: varname ! variable name character(len=32) :: avgstr ! time averaging type - character(len=8) :: type1d_out ! history output 1d type - character(len=8) :: type2d ! history output 2d type + character(len=hist_dim_name_length) :: type1d_out ! history output 1d type + character(len=hist_dim_name_length) :: type2d ! history output 2d type character(len=32) :: dim1name ! temporary character(len=32) :: dim2name ! temporary real(r8), pointer :: histo(:,:) ! temporary @@ -3189,14 +3267,14 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) character(len=max_namlen),allocatable :: tname(:) character(len=max_chars), allocatable :: tunits(:),tlongname(:) - character(len=8), allocatable :: tmpstr(:,:) + character(len=hist_dim_name_length), allocatable :: tmpstr(:,:) character(len=1), allocatable :: tavgflag(:) integer :: start(2) character(len=1) :: hnum ! history file index - character(len=8) :: type1d ! clm pointer 1d type - character(len=8) :: type1d_out ! history buffer 1d type - character(len=8) :: type2d ! history buffer 2d type + character(len=hist_dim_name_length) :: type1d ! clm pointer 1d type + character(len=hist_dim_name_length) :: type1d_out ! history buffer 1d type + character(len=hist_dim_name_length) :: type2d ! history buffer 2d type character(len=32) :: dim1name ! temporary character(len=32) :: dim2name ! temporary type(var_desc_t) :: name_desc ! variable descriptor for name @@ -4066,8 +4144,8 @@ subroutine hist_addfld1d (fname, units, avgflag, long_name, type1d_out, & ! !LOCAL VARIABLES: integer :: p,c,l,g ! indices integer :: hpindex ! history buffer pointer index - character(len=8) :: l_type1d ! 1d data type - character(len=8) :: l_type1d_out ! 1d output type + character(len=hist_dim_name_length) :: l_type1d ! 1d data type + character(len=hist_dim_name_length) :: l_type1d_out ! 1d output type character(len=8) :: scale_type_p2c ! scale type for subgrid averaging of pfts to column character(len=8) :: scale_type_c2l ! scale type for subgrid averaging of columns to landunits character(len=8) :: scale_type_l2g ! scale type for subgrid averaging of landunits to gridcells @@ -4292,8 +4370,8 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, integer :: p,c,l,g ! indices integer :: num2d ! size of second dimension (e.g. number of vertical levels) integer :: hpindex ! history buffer index - character(len=8) :: l_type1d ! 1d data type - character(len=8) :: l_type1d_out ! 1d output type + character(len=hist_dim_name_length) :: l_type1d ! 1d data type + character(len=hist_dim_name_length) :: l_type1d_out ! 1d output type character(len=8) :: scale_type_p2c ! scale type for subgrid averaging of pfts to column character(len=8) :: scale_type_c2l ! scale type for subgrid averaging of columns to landunits character(len=8) :: scale_type_l2g ! scale type for subgrid averaging of landunits to gridcells @@ -4373,6 +4451,26 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, end if case ('levsno') num2d = nlevsno + case ('fates_levscls') + num2d = nlevsclass_ed + case ('fates_levpft') + num2d = maxpft + case ('fates_levage') + num2d = nlevage_ed + case ('fates_levfuel') + num2d = nfsc + case ('fates_levcwdsc') + num2d = ncwd + case ('fates_levscpf') + num2d = nlevsclass_ed*maxpft + case ('fates_levscag') + num2d = nlevsclass_ed*nlevage_ed + case ('fates_levcan') + num2d = nclmax + case ('fates_levcnlf') + num2d = nlevleaf * nclmax + case ('fates_levcnlfpf') + num2d = nlevleaf * nclmax * numpft_ed case default write(iulog,*) trim(subname),' ERROR: unsupported 2d type ',type2d, & ' currently supported types for multi level fields are: ', & diff --git a/components/clm/src/main/initVerticalMod.F90 b/components/clm/src/main/initVerticalMod.F90 index 1e7fb2f5e2b1..5e532b8aeacf 100644 --- a/components/clm/src/main/initVerticalMod.F90 +++ b/components/clm/src/main/initVerticalMod.F90 @@ -174,10 +174,10 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof) end if - ! (FATES-ITERF) Move this call to inside alm_fates%init() - ! if(use_ed) then - ! call ed_hist_scpfmaps() - ! end if +! ! (FATES-INTERF) Move this call to inside alm_fates%init() +! if(use_ed) then +! call ed_hist_scpfmaps() +! end if ! Column level initialization for urban wall and roof layers and interfaces do l = bounds%begl,bounds%endl diff --git a/components/clm/src/main/ncdio_pio.F90.in b/components/clm/src/main/ncdio_pio.F90.in index 63ba7df8c103..3585742862d7 100644 --- a/components/clm/src/main/ncdio_pio.F90.in +++ b/components/clm/src/main/ncdio_pio.F90.in @@ -62,6 +62,7 @@ module ncdio_pio public :: ncd_inqvdims ! inquire variable ndims public :: ncd_inqvdids ! inquire variable dimids public :: ncd_inqvdlen ! inquire variable dimension size + public :: ncd_inqvdname ! inquire variable dimension name public :: ncd_io ! write local data integer,parameter,public :: ncd_int = pio_int @@ -127,6 +128,12 @@ module ncdio_pio module procedure ncd_inqvdlen_byName end interface + interface ncd_inqvdname + module procedure ncd_inqvdname_byDesc + module procedure ncd_inqvdname_byName + end interface ncd_inqvdname + + private :: ncd_getiodesc ! obtain iodesc private :: scam_field_offsets ! get offset to proper lat/lon gridcell for SCAM @@ -694,7 +701,95 @@ contains end if end subroutine ncd_inqvdlen_byName + + !----------------------------------------------------------------------- + subroutine ncd_inqvdname_byDesc(ncid,vardesc,dimnum,dname,err_code) + ! + ! !DESCRIPTION: + ! Inquire name of one of a variable's dimensions, given a vardesc + ! + ! If the variable has n dimensions, then dimnum should be between 1 and n; this + ! routine returns the name of the dimnum'th dimension. + ! + ! If there is an error condition, dname will be ' ', and err_code will hold the error + ! code; possible error codes are: + ! 0: no error + ! 1: dimnum out of range + ! + ! !ARGUMENTS: + class(file_desc_t),intent(inout) :: ncid ! netcdf file id + type(Var_desc_t) ,intent(inout) :: vardesc ! variable descriptor + integer ,intent(in) :: dimnum ! dimension number to query + character(len=*) ,intent(out) :: dname ! name of the dimension + integer ,intent(out) :: err_code ! error code (0 means no error) + ! + ! !LOCAL VARIABLES: + integer :: ndims ! number of dimensions + integer, allocatable :: dimids(:) ! dimension IDs + + character(len=*), parameter :: dname_invalid = ' ' + integer, parameter :: error_none = 0 + integer, parameter :: error_dimnum_out_of_range = 1 + + character(len=*), parameter :: subname = 'ncd_inqvdname_byDesc' + !----------------------------------------------------------------------- + + err_code = error_none + + call ncd_inqvdims(ncid, ndims, vardesc) + + if (dimnum > 0 .and. dimnum <= ndims) then + allocate(dimids(ndims)) + call ncd_inqvdids(ncid, dimids, vardesc) + call ncd_inqdname(ncid, dimids(dimnum), dname) + deallocate(dimids) + else + dname = dname_invalid + err_code = error_dimnum_out_of_range + end if + + end subroutine ncd_inqvdname_byDesc + !----------------------------------------------------------------------- + subroutine ncd_inqvdname_byName(ncid,varname,dimnum,dname,err_code) + ! + ! !DESCRIPTION: + ! Inquire name of one of a variable's dimensions, given a variable name + ! + ! If the variable has n dimensions, then dimnum should be between 1 and n; this + ! routine returns the name of the dimnum'th dimension. + ! + ! If there is an error condition, dname will be ' ', and err_code will hold the error + ! code; possible error codes are: + ! 0: no error + ! 1: dimnum out of range + ! 11: variable not found + ! + ! !ARGUMENTS: + class(file_desc_t),intent(inout) :: ncid ! netcdf file id + character(len=*) ,intent(in) :: varname ! variable name + integer ,intent(in) :: dimnum ! dimension number to query + character(len=*) ,intent(out) :: dname ! name of the dimension + integer ,intent(out) :: err_code ! error code (0 means no error) + ! + ! !LOCAL VARIABLES: + type(Var_desc_t) :: vardesc ! variable descriptor + logical :: readvar ! whether the variable was found + character(len=*), parameter :: dname_invalid = ' ' + integer, parameter :: error_variable_not_found = 11 + + character(len=*), parameter :: subname = 'ncd_inqvdname_byName' + !----------------------------------------------------------------------- + + call check_var(ncid, varname, vardesc, readvar) + if (readvar) then + call ncd_inqvdname_byDesc(ncid, vardesc, dimnum, dname, err_code) + else + dname = dname_invalid + err_code = error_variable_not_found + end if + + end subroutine ncd_inqvdname_byName !----------------------------------------------------------------------- subroutine ncd_putatt_int(ncid,varid,attrib,value,xtype) diff --git a/components/clm/src/main/paramUtilMod.F90 b/components/clm/src/main/paramUtilMod.F90 index 75a85e3e6c03..8c973af73512 100644 --- a/components/clm/src/main/paramUtilMod.F90 +++ b/components/clm/src/main/paramUtilMod.F90 @@ -10,122 +10,278 @@ module paramUtilMod interface readNcdio module procedure readNcdioScalar module procedure readNcdioArray1d - module procedure readNcdioArray2d - end interface + module procedure readNcdioArray2d + module procedure readNcdioScalarCheckDimensions + module procedure readNcdioArray1dCheckDimensions + module procedure readNcdioArray2dCheckDimensions + end interface readNcdio public :: readNcdioScalar public :: readNcdioArray1d public :: readNcdioArray2d + public :: readNcdioScalarCheckDimensions + public :: readNcdioArray1dCheckDimensions + public :: readNcdioArray2dCheckDimensions public :: readNcdio contains - !----------------------------------------------------------------------- - ! - !----------------------------------------------------------------------- - subroutine readNcdioScalar(ncid, varName, callingName, retVal) - ! - ! read the netcdf file...generic, could be used for any parameter read - ! - use abortutils , only : endrun - use ncdio_pio , only : file_desc_t,ncd_io - - implicit none - - ! arguments - type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id - character(len=*), intent(in) :: varName ! variable we are reading - character(len=*), intent(in) :: callingName ! calling routine - real(r8), intent(inout) :: retVal - - ! local vars - character(len=32) :: subname = 'readNcdio::' - character(len=100) :: errCode = ' - Error reading. Var: ' - logical :: readv ! has variable been read in or not - - ! - ! netcdf read here - ! - - call ncd_io(varname=trim(varName),data=retVal, flag='read', ncid=ncid, readvar=readv) - - if ( .not. readv ) then - call endrun(trim(callingName)//trim(subname)//trim(errCode)//trim(varName)) - endif - - end subroutine readNcdioScalar - !----------------------------------------------------------------------- - - !----------------------------------------------------------------------- - ! - !----------------------------------------------------------------------- - subroutine readNcdioArray1d(ncid, varName, callingName, retVal) - ! - ! read the netcdf file...generic, could be used for any parameter read - ! - use abortutils , only : endrun - use ncdio_pio , only : file_desc_t,ncd_io - - implicit none - - ! arguments - type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id - character(len=*), intent(in) :: varName ! variable we are reading - character(len=*), intent(in) :: callingName ! calling routine - real(r8), intent(inout) :: retVal( 1: ) - - ! local vars - character(len=32) :: subname = 'readNcdio::' - character(len=100) :: errCode = ' - Error reading. Var: ' - logical :: readv ! has variable been read in or not - - ! - ! netcdf read here - ! - - call ncd_io(varname=trim(varName),data=retVal, flag='read', ncid=ncid, readvar=readv) - - if ( .not. readv ) then - call endrun(trim(callingName)//trim(subname)//trim(errCode)//trim(varName)) - endif - - end subroutine readNcdioArray1d - !----------------------------------------------------------------------- - - !----------------------------------------------------------------------- - ! - !----------------------------------------------------------------------- - subroutine readNcdioArray2d(ncid, varName, callingName, retVal) - ! - ! read the netcdf file...generic, could be used for any parameter read - ! - use abortutils , only : endrun - use ncdio_pio , only : file_desc_t,ncd_io - - implicit none - - ! arguments - type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id - character(len=*), intent(in) :: varName ! variable we are reading - character(len=*), intent(in) :: callingName ! calling routine - real(r8), intent(inout) :: retVal( 1: , :) - - ! local vars - character(len=32) :: subname = 'readNcdio::' - character(len=100) :: errCode = ' - Error reading. Var: ' - logical :: readv ! has variable been read in or not - - ! - ! netcdf read here - ! - - call ncd_io(varname=trim(varName),data=retVal, flag='read', ncid=ncid, readvar=readv) - - if ( .not. readv ) then - call endrun(trim(callingName)//trim(subname)//trim(errCode)//trim(varName)) - endif - - end subroutine readNcdioArray2d - !----------------------------------------------------------------------- + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine readNcdioScalar(ncid, varName, callingName, retVal) + ! + ! read the netcdf file...generic, could be used for any parameter read + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t,ncd_io + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + character(len=*), intent(in) :: callingName ! calling routine + real(r8), intent(inout) :: retVal + + ! local vars + character(len=32) :: subname = 'readNcdio::' + character(len=100) :: errCode = ' - Error reading. Var: ' + logical :: readv ! has variable been read in or not + + ! + ! netcdf read here + ! + + call ncd_io(varname=trim(varName),data=retVal, flag='read', ncid=ncid, readvar=readv) + + if ( .not. readv ) then + call endrun(trim(callingName)//trim(subname)//trim(errCode)//trim(varName)) + endif + + end subroutine readNcdioScalar + !----------------------------------------------------------------------- + + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine readNcdioArray1d(ncid, varName, callingName, retVal) + ! + ! read the netcdf file...generic, could be used for any parameter read + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t,ncd_io + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + character(len=*), intent(in) :: callingName ! calling routine + real(r8), intent(inout) :: retVal( 1: ) + + ! local vars + character(len=32) :: subname = 'readNcdio::' + character(len=100) :: errCode = ' - Error reading. Var: ' + logical :: readv ! has variable been read in or not + + ! + ! netcdf read here + ! + + call ncd_io(varname=trim(varName),data=retVal, flag='read', ncid=ncid, readvar=readv) + + if ( .not. readv ) then + call endrun(trim(callingName)//trim(subname)//trim(errCode)//trim(varName)) + endif + + end subroutine readNcdioArray1d + !----------------------------------------------------------------------- + + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine readNcdioArray2d(ncid, varName, callingName, retVal) + ! + ! read the netcdf file...generic, could be used for any parameter read + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t,ncd_io + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + character(len=*), intent(in) :: callingName ! calling routine + real(r8), intent(inout) :: retVal( 1: , :) + + ! local vars + character(len=32) :: subname = 'readNcdio::' + character(len=100) :: errCode = ' - Error reading. Var: ' + logical :: readv ! has variable been read in or not + + ! + ! netcdf read here + ! + + call ncd_io(varname=trim(varName),data=retVal, flag='read', ncid=ncid, readvar=readv) + + if ( .not. readv ) then + call endrun(trim(callingName)//trim(subname)//trim(errCode)//trim(varName)) + endif + + end subroutine readNcdioArray2d + !----------------------------------------------------------------------- + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine readNcdioScalarCheckDimensions(ncid, varName, expected_numDims, expected_dimNames, & + callingName, retVal) + ! + ! read the netcdf file...generic, could be used for any parameter read + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + integer, intent(in) :: expected_numDims + character(len=*), intent(in) :: expected_dimNames(:) ! expected dimension name + character(len=*), intent(in) :: callingName ! calling routine + real(r8), intent(inout) :: retVal + + ! local vars + character(len=32) :: subname = 'readNcdio::' + character(len=100) :: errCode = ' - Error reading. Var: ' + + ! + ! netcdf read here + ! + call checkDimensions(ncid, varName, expected_numDims, expected_dimNames, subname) + call readNcdio(ncid, varName, callingName, retVal) + + end subroutine readNcdioScalarCheckDimensions + !----------------------------------------------------------------------- + + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine readNcdioArray1dCheckDimensions(ncid, varName, expected_numDims, expected_dimNames, & + callingName, retVal) + ! + ! read the netcdf file...generic, could be used for any parameter read + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + integer, intent(in) :: expected_numDims + character(len=*), intent(in) :: expected_dimNames(:) ! expected dimension name + character(len=*), intent(in) :: callingName ! calling routine + real(r8), intent(inout) :: retVal( 1: ) + + ! local vars + character(len=32) :: subname = 'readNcdio::' + character(len=100) :: errCode = ' - Error reading. Var: ' + ! + ! netcdf read here + ! + call checkDimensions(ncid, varName, expected_numDims, expected_dimNames, subname) + call readNcdio(ncid, varName, callingName, retVal) + + end subroutine readNcdioArray1dCheckDimensions + !----------------------------------------------------------------------- + + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine readNcdioArray2dCheckDimensions(ncid, varName, expected_numDims, expected_dimNames, & + callingName, retVal) + ! + ! read the netcdf file...generic, could be used for any parameter read + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + integer, intent(in) :: expected_numDims + character(len=*), intent(in) :: expected_dimNames(:) ! expected dimension name + character(len=*), intent(in) :: callingName ! calling routine + real(r8), intent(inout) :: retVal(1:, : ) + + ! local vars + character(len=32) :: subname = 'readNcdio::' + character(len=100) :: errCode = ' - Error reading. Var: ' + ! + ! netcdf read here + ! + call checkDimensions(ncid, varName, expected_numDims, expected_dimNames, subname) + call readNcdio(ncid, varName, callingName, retVal) + + end subroutine readNcdioArray2dCheckDimensions + !----------------------------------------------------------------------- + + !----------------------------------------------------------------------- + ! + !----------------------------------------------------------------------- + subroutine checkDimensions(ncid, varName, expected_numDims, expected_dimNames, callingName) + ! + ! Assert that the expected number of dimensions and dimension + ! names for a variable match the actual names on the file. + ! + use abortutils , only : endrun + use ncdio_pio , only : file_desc_t, var_desc_t, check_var, ncd_inqvdname, ncd_inqvdims + + implicit none + + ! arguments + type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id + character(len=*), intent(in) :: varName ! variable we are reading + integer, intent(in) :: expected_numDims ! number of expected dimensions on the variable + character(len=*), intent(in) :: expected_dimNames(:) ! expected dimension names + character(len=*), intent(in) :: callingName ! calling routine + integer :: error_num + + ! local vars + character(len=32) :: subname = 'checkDimensions::' + type(Var_desc_t) :: var_desc ! variable descriptor + logical :: readvar ! whether the variable was found + character(len=100) :: received_dimName + integer :: d, num_dims + character(len=256) :: msg + + call check_var(ncid, varName, var_desc, readvar) + if (readvar) then + call ncd_inqvdims(ncid, num_dims, var_desc) + if (num_dims /= expected_numDims) then + write(msg, *) trim(callingName)//trim(subname)//trim(varname)//":: expected number of dimensions = ", & + expected_numDims, " num dimensions received from file = ", num_dims + call endrun(msg) + end if + do d = 1, num_dims + received_dimName = '' + call ncd_inqvdname(ncid, varname=trim(varName), dimnum=d, dname=received_dimName, err_code=error_num) + if (trim(expected_dimNames(d)) /= trim(received_dimName)) then + write(msg, *) trim(callingName)//trim(subname)//trim(varname)//":: dimension ", d, & + " expected dimension name '"//trim(expected_dimNames(d))//& + "' dimension name received from file '"//trim(received_dimName)//"'." + call endrun(msg) + end if + end do + end if + end subroutine checkDimensions + !----------------------------------------------------------------------- end module paramUtilMod diff --git a/components/clm/src/main/pftvarcon.F90 b/components/clm/src/main/pftvarcon.F90 index e9043bd91d09..ad1937cc91b5 100644 --- a/components/clm/src/main/pftvarcon.F90 +++ b/components/clm/src/main/pftvarcon.F90 @@ -484,9 +484,6 @@ subroutine pftconrd allocate( mbbopt (0:mxpft) ) allocate( nstor (0:mxpft) ) - ! (FATES-INTERF) check .not.use_ed logic after converting to new fates parameter system - ! these logic checks should probably be removed - ! Set specific vegetation type values if (masterproc) then @@ -869,7 +866,7 @@ subroutine pftconrd ! (FATES-INTERF) Later, depending on how the team plans to structure the crop model ! or other modules that co-exist while FATES is on, we may want to preserve these pft definitions - ! on non-fates columns. For now, they are incompatible (rgk 04-2017) + ! on non-fates columns. For now, they are incompatible, and this check is warranted (rgk 04-2017) if(.not. use_ed)then if ( trim(adjustl(pftname(i))) /= trim(expected_pftnames(i)) )then write(iulog,*)'pftconrd: pftname is NOT what is expected, name = ', & @@ -913,8 +910,6 @@ subroutine pftconrd fcur(:) = fcurdv(:) end if - ! (FATES-INTERF) FATES will not change mxpft, it has its own pft list and maximums - ! so this logic should not be necessary. Leaving it for now. (rgk 04-2017) if( .not. use_ed ) then if ( npcropmax /= mxpft )then call endrun(msg=' ERROR: npcropmax is NOT the last value'//errMsg(__FILE__, __LINE__)) diff --git a/components/clm/src/main/readParamsMod.F90 b/components/clm/src/main/readParamsMod.F90 index 0ae9258a441a..8f62c5a29393 100644 --- a/components/clm/src/main/readParamsMod.F90 +++ b/components/clm/src/main/readParamsMod.F90 @@ -76,25 +76,26 @@ end subroutine CNParamsSharedReadFile subroutine readPrivateParameters ! read CN and BGC shared parameters ! - use CNAllocationBetrMod , only : readCNAllocBetrParams - use CNAllocationMod , only : readCNAllocParams - use CNDecompMod , only : readCNDecompParams - use CNDecompCascadeBGCMod , only : readCNDecompBgcParams - use CNDecompCascadeCNMod , only : readCNDecompCnParams - use CNPhenologyMod , only : readCNPhenolParams - use CNMRespMod , only : readCNMRespParams - use CNNDynamicsMod , only : readCNNDynamicsParams - use CNGapMortalityMod , only : readCNGapMortParams - use CNNitrifDenitrifMod , only : readCNNitrifDenitrifParams - use CNSoilLittVertTranspMod , only : readCNSoilLittVertTranspParams - use ch4Mod , only : readCH4Params - use clm_varctl , only : paramfile, iulog, use_betr - use spmdMod , only : masterproc - use fileutils , only : getfil - use ncdio_pio , only : ncd_pio_closefile, ncd_pio_openfile, & - file_desc_t, ncd_inqdid, ncd_inqdlen - use tracer_varcon , only : is_active_betr_bgc - use betr_initializeMod , only : bgc_reaction, betrtracer_vars + use CNAllocationBetrMod , only : readCNAllocBetrParams + use CNAllocationMod , only : readCNAllocParams + use CNDecompMod , only : readCNDecompParams + use CNDecompCascadeBGCMod , only : readCNDecompBgcParams + use CNDecompCascadeCNMod , only : readCNDecompCnParams + use CNPhenologyMod , only : readCNPhenolParams + use CNMRespMod , only : readCNMRespParams + use CNNDynamicsMod , only : readCNNDynamicsParams + use CNGapMortalityMod , only : readCNGapMortParams + use CNNitrifDenitrifMod , only : readCNNitrifDenitrifParams + use CNSoilLittVertTranspMod , only : readCNSoilLittVertTranspParams + use ch4Mod , only : readCH4Params + use clm_varctl , only : paramfile, iulog, use_betr + use spmdMod , only : masterproc + use fileutils , only : getfil + use ncdio_pio , only : ncd_pio_closefile, ncd_pio_openfile, & + file_desc_t, ncd_inqdid, ncd_inqdlen + use tracer_varcon , only : is_active_betr_bgc + use betr_initializeMod , only : bgc_reaction, betrtracer_vars + use CLMFatesParamInterfaceMod, only : FatesReadParameters ! ! !ARGUMENTS: @@ -139,7 +140,6 @@ subroutine readPrivateParameters call readCNDecompCnParams(ncid) end if - if (use_nitrif_denitrif) then call readCNNitrifDenitrifParams(ncid) end if @@ -151,10 +151,7 @@ subroutine readPrivateParameters end if end if - if (use_ed) then - !! (FATES-INTERF) - !! call FatesReadParameters() - end if + if (use_cn) then call readCNPhenolParams(ncid) @@ -168,5 +165,11 @@ subroutine readPrivateParameters ! call ncd_pio_closefile(ncid) + ! FATES has its own file, therefore we close the exiting file + ! before continuing + if (use_ed) then + call FatesReadParameters() + end if + end subroutine readPrivateParameters end module readParamsMod diff --git a/components/clm/src/main/restFileMod.F90 b/components/clm/src/main/restFileMod.F90 index 64c0e921559f..ebe276e62ab5 100644 --- a/components/clm/src/main/restFileMod.F90 +++ b/components/clm/src/main/restFileMod.F90 @@ -26,10 +26,12 @@ module restFileMod use CNStateType , only : cnstate_type use CNNitrogenFluxType , only : nitrogenflux_type use CNNitrogenStateType , only : nitrogenstate_type - + use PhosphorusFluxType , only : phosphorusflux_type use PhosphorusStateType , only : phosphorusstate_type + use CLMFatesInterfaceMod , only : hlm_fates_interface_type + use AerosolType , only : aerosol_type use CanopyStateType , only : canopystate_type use EnergyFluxType , only : energyflux_type @@ -98,45 +100,47 @@ subroutine restFile_write( bounds, file, waterflux_vars, waterstate_vars, & phosphorusstate_vars, phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & + clm_fates, & rdate, noptr) ! ! !DESCRIPTION: ! Define/write CLM restart file. ! ! !ARGUMENTS: - type(bounds_type) , intent(in) :: bounds - character(len=*) , intent(in) :: file ! output netcdf restart file - type(atm2lnd_type) , intent(in) :: atm2lnd_vars - type(aerosol_type) , intent(in) :: aerosol_vars - type(canopystate_type) , intent(inout) :: canopystate_vars ! due to EDrest call - type(cnstate_type) , intent(inout) :: cnstate_vars - type(carbonstate_type) , intent(inout) :: carbonstate_vars - type(carbonstate_type) , intent(in) :: c13_carbonstate_vars - type(carbonstate_type) , intent(in) :: c14_carbonstate_vars - type(carbonflux_type) , intent(inout) :: carbonflux_vars - type(ch4_type) , intent(in) :: ch4_vars - type(dgvs_type) , intent(in) :: dgvs_vars - type(energyflux_type) , intent(in) :: energyflux_vars - type(frictionvel_type) , intent(in) :: frictionvel_vars - type(lakestate_type) , intent(in) :: lakestate_vars - type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars - type(nitrogenflux_type) , intent(in) :: nitrogenflux_vars - type(photosyns_type) , intent(in) :: photosyns_vars - type(soilhydrology_type) , intent(in) :: soilhydrology_vars - type(soilstate_type) , intent(in) :: soilstate_vars - type(solarabs_type) , intent(in) :: solarabs_vars - type(surfalb_type) , intent(in) :: surfalb_vars - type(temperature_type) , intent(in) :: temperature_vars - type(waterstate_type) , intent(inout) :: waterstate_vars ! due to EDrest call - type(waterflux_type) , intent(in) :: waterflux_vars - type(phosphorusstate_type),intent(inout) :: phosphorusstate_vars - type(phosphorusflux_type) ,intent(in) :: phosphorusflux_vars - type(tracerstate_type) , intent(inout) :: tracerstate_vars ! due to Betrrest call - type(BeTRTracer_Type) , intent(in) :: betrtracer_vars - type(tracerflux_type) , intent(inout) :: tracerflux_vars - type(tracercoeff_type) , intent(inout) :: tracercoeff_vars - character(len=*) , intent(in), optional :: rdate ! restart file time stamp for name - logical , intent(in), optional :: noptr ! if should NOT write to the restart pointer file + type(bounds_type) , intent(in) :: bounds + character(len=*) , intent(in) :: file ! output netcdf restart file + type(atm2lnd_type) , intent(in) :: atm2lnd_vars + type(aerosol_type) , intent(in) :: aerosol_vars + type(canopystate_type) , intent(inout) :: canopystate_vars ! due to EDrest call + type(cnstate_type) , intent(inout) :: cnstate_vars + type(carbonstate_type) , intent(inout) :: carbonstate_vars + type(carbonstate_type) , intent(in) :: c13_carbonstate_vars + type(carbonstate_type) , intent(in) :: c14_carbonstate_vars + type(carbonflux_type) , intent(inout) :: carbonflux_vars + type(ch4_type) , intent(in) :: ch4_vars + type(dgvs_type) , intent(in) :: dgvs_vars + type(energyflux_type) , intent(in) :: energyflux_vars + type(frictionvel_type) , intent(inout) :: frictionvel_vars + type(lakestate_type) , intent(in) :: lakestate_vars + type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars + type(nitrogenflux_type) , intent(in) :: nitrogenflux_vars + type(photosyns_type) , intent(in) :: photosyns_vars + type(soilhydrology_type) , intent(in) :: soilhydrology_vars + type(soilstate_type) , intent(in) :: soilstate_vars + type(solarabs_type) , intent(in) :: solarabs_vars + type(surfalb_type) , intent(in) :: surfalb_vars + type(temperature_type) , intent(in) :: temperature_vars + type(waterstate_type) , intent(inout) :: waterstate_vars ! due to EDrest call + type(waterflux_type) , intent(in) :: waterflux_vars + type(phosphorusstate_type) , intent(inout) :: phosphorusstate_vars + type(phosphorusflux_type) , intent(in) :: phosphorusflux_vars + type(tracerstate_type) , intent(inout) :: tracerstate_vars ! due to Betrrest call + type(BeTRTracer_Type) , intent(in) :: betrtracer_vars + type(tracerflux_type) , intent(inout) :: tracerflux_vars + type(tracercoeff_type) , intent(inout) :: tracercoeff_vars + type(hlm_fates_interface_type) , intent(inout) :: clm_fates + character(len=*) , intent(in), optional :: rdate ! restart file time stamp for name + logical , intent(in), optional :: noptr ! if should NOT write to the restart pointer file ! ! !LOCAL VARIABLES: type(file_desc_t) :: ncid ! netcdf id @@ -245,11 +249,10 @@ subroutine restFile_write( bounds, file, end if call carbonflux_vars%restart(bounds, ncid, flag='define') -! (FATES-INTERF) -! call clm_fates%restart(bounds, ncid, flag='define', & -! waterstate_vars=waterstate_vars, & -! canopystate_vars=canopystate_vars, & -! frictionvel_vars=frictionvel_vars) + call clm_fates%restart(bounds, ncid, flag='define', & + waterstate_inst=waterstate_vars, & + canopystate_inst=canopystate_vars, & + frictionvel_inst=frictionvel_vars) end if @@ -356,11 +359,11 @@ subroutine restFile_write( bounds, file, cnstate_vars=cnstate_vars ) end if call carbonflux_vars%restart(bounds, ncid, flag='write') -! (FATES-INTERF) -! call clm_fates%restart(bounds, ncid, flag='write', & -! waterstate_vars=waterstate_vars, & -! canopystate_vars=canopystate_vars, & -! frictionvel_vars=frictionvel_vars) + + call clm_fates%restart(bounds, ncid, flag='write', & + waterstate_inst=waterstate_vars, & + canopystate_inst=canopystate_vars, & + frictionvel_inst=frictionvel_vars) end if @@ -405,7 +408,8 @@ subroutine restFile_read( bounds, file, soilstate_vars, solarabs_vars, surfalb_vars, temperature_vars, & waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & - betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars) + betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & + clm_fates) ! ! !DESCRIPTION: ! Read a CLM restart file. @@ -416,37 +420,38 @@ subroutine restFile_read( bounds, file, use histFileMod , only : hist_restart_ncd ! ! !ARGUMENTS: - character(len=*) , intent(in) :: file ! output netcdf restart file - type(bounds_type) , intent(in) :: bounds - type(atm2lnd_type) , intent(inout) :: atm2lnd_vars - type(aerosol_type) , intent(inout) :: aerosol_vars - type(canopystate_type) , intent(inout) :: canopystate_vars - type(cnstate_type) , intent(inout) :: cnstate_vars - type(carbonstate_type) , intent(inout) :: carbonstate_vars - type(carbonstate_type) , intent(inout) :: c13_carbonstate_vars - type(carbonstate_type) , intent(inout) :: c14_carbonstate_vars - type(carbonflux_type) , intent(inout) :: carbonflux_vars - type(ch4_type) , intent(inout) :: ch4_vars - type(dgvs_type) , intent(inout) :: dgvs_vars - type(energyflux_type) , intent(inout) :: energyflux_vars - type(frictionvel_type) , intent(inout) :: frictionvel_vars - type(lakestate_type) , intent(inout) :: lakestate_vars - type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars - type(nitrogenflux_type) , intent(inout) :: nitrogenflux_vars - type(photosyns_type) , intent(inout) :: photosyns_vars - type(soilhydrology_type) , intent(inout) :: soilhydrology_vars - type(soilstate_type) , intent(inout) :: soilstate_vars - type(solarabs_type) , intent(inout) :: solarabs_vars - type(temperature_type) , intent(inout) :: temperature_vars - type(surfalb_type) , intent(inout) :: surfalb_vars - type(waterstate_type) , intent(inout) :: waterstate_vars - type(waterflux_type) , intent(inout) :: waterflux_vars - type(phosphorusstate_type) , intent(inout) :: phosphorusstate_vars - type(phosphorusflux_type) , intent(inout) :: phosphorusflux_vars - type(tracerstate_type) , intent(inout) :: tracerstate_vars ! due to Betrrest call - type(BeTRTracer_Type) , intent(in) :: betrtracer_vars - type(tracerflux_type) , intent(inout) :: tracerflux_vars - type(tracercoeff_type) , intent(inout) :: tracercoeff_vars + character(len=*) , intent(in) :: file ! output netcdf restart file + type(bounds_type) , intent(in) :: bounds + type(atm2lnd_type) , intent(inout) :: atm2lnd_vars + type(aerosol_type) , intent(inout) :: aerosol_vars + type(canopystate_type) , intent(inout) :: canopystate_vars + type(cnstate_type) , intent(inout) :: cnstate_vars + type(carbonstate_type) , intent(inout) :: carbonstate_vars + type(carbonstate_type) , intent(inout) :: c13_carbonstate_vars + type(carbonstate_type) , intent(inout) :: c14_carbonstate_vars + type(carbonflux_type) , intent(inout) :: carbonflux_vars + type(ch4_type) , intent(inout) :: ch4_vars + type(dgvs_type) , intent(inout) :: dgvs_vars + type(energyflux_type) , intent(inout) :: energyflux_vars + type(frictionvel_type) , intent(inout) :: frictionvel_vars + type(lakestate_type) , intent(inout) :: lakestate_vars + type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars + type(nitrogenflux_type) , intent(inout) :: nitrogenflux_vars + type(photosyns_type) , intent(inout) :: photosyns_vars + type(soilhydrology_type) , intent(inout) :: soilhydrology_vars + type(soilstate_type) , intent(inout) :: soilstate_vars + type(solarabs_type) , intent(inout) :: solarabs_vars + type(temperature_type) , intent(inout) :: temperature_vars + type(surfalb_type) , intent(inout) :: surfalb_vars + type(waterstate_type) , intent(inout) :: waterstate_vars + type(waterflux_type) , intent(inout) :: waterflux_vars + type(phosphorusstate_type) , intent(inout) :: phosphorusstate_vars + type(phosphorusflux_type) , intent(inout) :: phosphorusflux_vars + type(tracerstate_type) , intent(inout) :: tracerstate_vars ! due to Betrrest call + type(BeTRTracer_Type) , intent(in) :: betrtracer_vars + type(tracerflux_type) , intent(inout) :: tracerflux_vars + type(tracercoeff_type) , intent(inout) :: tracercoeff_vars + type(hlm_fates_interface_type) , intent(inout) :: clm_fates ! ! !LOCAL VARIABLES: type(file_desc_t) :: ncid ! netcdf id @@ -542,11 +547,11 @@ subroutine restFile_read( bounds, file, cnstate_vars=cnstate_vars) end if call carbonflux_vars%restart(bounds, ncid, flag='read') -! (FATES-INTERF) -! call clm_fates%restart(bounds, ncid, flag='read', & -! waterstate_vars=waterstate_vars, & -! canopystate_vars=canopystate_vars, & -! frictionvel_vars=frictionvel_vars) + + call clm_fates%restart(bounds, ncid, flag='read', & + waterstate_inst=waterstate_vars, & + canopystate_inst=canopystate_vars, & + frictionvel_inst=frictionvel_vars) end if From 9bcd820714cda58dcb8c5ade024c612015f108a6 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 10 May 2017 19:26:19 -0700 Subject: [PATCH 02/12] fates-interface: Added an SMS test to acme_land_developer: SMS_lm1.f45_f45.ICLM45ED --- cime/scripts/lib/update_acme_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cime/scripts/lib/update_acme_tests.py b/cime/scripts/lib/update_acme_tests.py index 37d03bbc061f..2959fc723d29 100644 --- a/cime/scripts/lib/update_acme_tests.py +++ b/cime/scripts/lib/update_acme_tests.py @@ -68,6 +68,7 @@ ("ERS.f19_g16.I1850CNECACNTBC" ,"clm-eca"), ("ERS.f19_g16.I1850CNECACTCBC" ,"clm-eca"), ("SMS_Ly2_P1x1.1x1_smallvilleIA.ICLM45CNCROP", "force_netcdf_pio"), + ("SMS_Lm1.f45_f45.ICLM45ED","clm-fates"), ("ERS.f19_g16.I1850CLM45","clm-betr"), "ERS.ne11_oQU240.I20TRCLM45", "ERS.f09_g16.IMCLM45BC") From 7468b1bc3e1c522f68b29c9e13fabd2d2245c61a Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 10 May 2017 20:15:45 -0700 Subject: [PATCH 03/12] fates-interface: changed user_nl_clm settings for fates tests, removed deprecated variables --- .../config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm | 4 ++-- .../cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm b/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm index b829d58c8d8d..8b928f698738 100644 --- a/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm +++ b/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm @@ -4,8 +4,8 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', - 'STORVEGC','FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', + 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', - 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','DISPVEGC','AREA_TREES','AREA_PLANT', + 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','AREA_TREES','AREA_PLANT', 'HR','TOTLITC','TOTSOMC','AR' diff --git a/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm index b829d58c8d8d..8b928f698738 100644 --- a/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm +++ b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm @@ -4,8 +4,8 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', - 'STORVEGC','FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', + 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', - 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','DISPVEGC','AREA_TREES','AREA_PLANT', + 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','AREA_TREES','AREA_PLANT', 'HR','TOTLITC','TOTSOMC','AR' From e24a3f5b3056c4a4d8df48c795ab3f2e225c967e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 11 May 2017 15:12:26 -0700 Subject: [PATCH 04/12] fates-interface: added some ncd_io functions tot he ncdio_pio.F90.in preprocessor file. These new functions are required for the fates parameter interface. --- components/clm/src/main/ncdio_pio.F90.in | 183 +++++++++++------------ 1 file changed, 91 insertions(+), 92 deletions(-) diff --git a/components/clm/src/main/ncdio_pio.F90.in b/components/clm/src/main/ncdio_pio.F90.in index 3585742862d7..b32255a112ff 100644 --- a/components/clm/src/main/ncdio_pio.F90.in +++ b/components/clm/src/main/ncdio_pio.F90.in @@ -132,7 +132,6 @@ module ncdio_pio module procedure ncd_inqvdname_byDesc module procedure ncd_inqvdname_byName end interface ncd_inqvdname - private :: ncd_getiodesc ! obtain iodesc private :: scam_field_offsets ! get offset to proper lat/lon gridcell for SCAM @@ -662,8 +661,6 @@ contains end subroutine ncd_inqvdlen_byDesc - - !----------------------------------------------------------------------- subroutine ncd_inqvdlen_byName(ncid,varname,dimnum,dlen,err_code) ! ! !DESCRIPTION: @@ -700,98 +697,100 @@ contains err_code = error_variable_not_found end if - end subroutine ncd_inqvdlen_byName - - !----------------------------------------------------------------------- - subroutine ncd_inqvdname_byDesc(ncid,vardesc,dimnum,dname,err_code) - ! - ! !DESCRIPTION: - ! Inquire name of one of a variable's dimensions, given a vardesc - ! - ! If the variable has n dimensions, then dimnum should be between 1 and n; this - ! routine returns the name of the dimnum'th dimension. - ! - ! If there is an error condition, dname will be ' ', and err_code will hold the error - ! code; possible error codes are: - ! 0: no error - ! 1: dimnum out of range - ! - ! !ARGUMENTS: - class(file_desc_t),intent(inout) :: ncid ! netcdf file id - type(Var_desc_t) ,intent(inout) :: vardesc ! variable descriptor - integer ,intent(in) :: dimnum ! dimension number to query - character(len=*) ,intent(out) :: dname ! name of the dimension - integer ,intent(out) :: err_code ! error code (0 means no error) - ! - ! !LOCAL VARIABLES: - integer :: ndims ! number of dimensions - integer, allocatable :: dimids(:) ! dimension IDs - - character(len=*), parameter :: dname_invalid = ' ' - integer, parameter :: error_none = 0 - integer, parameter :: error_dimnum_out_of_range = 1 - - character(len=*), parameter :: subname = 'ncd_inqvdname_byDesc' - !----------------------------------------------------------------------- - - err_code = error_none - - call ncd_inqvdims(ncid, ndims, vardesc) - - if (dimnum > 0 .and. dimnum <= ndims) then - allocate(dimids(ndims)) - call ncd_inqvdids(ncid, dimids, vardesc) - call ncd_inqdname(ncid, dimids(dimnum), dname) - deallocate(dimids) - else - dname = dname_invalid - err_code = error_dimnum_out_of_range - end if - - end subroutine ncd_inqvdname_byDesc + end subroutine ncd_inqvdlen_byName - !----------------------------------------------------------------------- - subroutine ncd_inqvdname_byName(ncid,varname,dimnum,dname,err_code) - ! - ! !DESCRIPTION: - ! Inquire name of one of a variable's dimensions, given a variable name - ! - ! If the variable has n dimensions, then dimnum should be between 1 and n; this - ! routine returns the name of the dimnum'th dimension. - ! - ! If there is an error condition, dname will be ' ', and err_code will hold the error - ! code; possible error codes are: - ! 0: no error - ! 1: dimnum out of range - ! 11: variable not found - ! - ! !ARGUMENTS: - class(file_desc_t),intent(inout) :: ncid ! netcdf file id - character(len=*) ,intent(in) :: varname ! variable name - integer ,intent(in) :: dimnum ! dimension number to query - character(len=*) ,intent(out) :: dname ! name of the dimension - integer ,intent(out) :: err_code ! error code (0 means no error) - ! - ! !LOCAL VARIABLES: - type(Var_desc_t) :: vardesc ! variable descriptor - logical :: readvar ! whether the variable was found - character(len=*), parameter :: dname_invalid = ' ' - integer, parameter :: error_variable_not_found = 11 - - character(len=*), parameter :: subname = 'ncd_inqvdname_byName' - !----------------------------------------------------------------------- - - call check_var(ncid, varname, vardesc, readvar) - if (readvar) then - call ncd_inqvdname_byDesc(ncid, vardesc, dimnum, dname, err_code) - else - dname = dname_invalid - err_code = error_variable_not_found - end if - - end subroutine ncd_inqvdname_byName + + !----------------------------------------------------------------------- + subroutine ncd_inqvdname_byDesc(ncid,vardesc,dimnum,dname,err_code) + ! + ! !DESCRIPTION: + ! Inquire name of one of a variable's dimensions, given a vardesc + ! + ! If the variable has n dimensions, then dimnum should be between 1 and n; this + ! routine returns the name of the dimnum'th dimension. + ! + ! If there is an error condition, dname will be ' ', and err_code will hold the error + ! code; possible error codes are: + ! 0: no error + ! 1: dimnum out of range + ! + ! !ARGUMENTS: + class(file_desc_t),intent(inout) :: ncid ! netcdf file id + type(Var_desc_t) ,intent(inout) :: vardesc ! variable descriptor + integer ,intent(in) :: dimnum ! dimension number to query + character(len=*) ,intent(out) :: dname ! name of the dimension + integer ,intent(out) :: err_code ! error code (0 means no error) + ! + ! !LOCAL VARIABLES: + integer :: ndims ! number of dimensions + integer, allocatable :: dimids(:) ! dimension IDs + + character(len=*), parameter :: dname_invalid = ' ' + integer, parameter :: error_none = 0 + integer, parameter :: error_dimnum_out_of_range = 1 + + character(len=*), parameter :: subname = 'ncd_inqvdname_byDesc' + !----------------------------------------------------------------------- + err_code = error_none + + call ncd_inqvdims(ncid, ndims, vardesc) + + if (dimnum > 0 .and. dimnum <= ndims) then + allocate(dimids(ndims)) + call ncd_inqvdids(ncid, dimids, vardesc) + call ncd_inqdname(ncid, dimids(dimnum), dname) + deallocate(dimids) + else + dname = dname_invalid + err_code = error_dimnum_out_of_range + end if + + end subroutine ncd_inqvdname_byDesc + + !----------------------------------------------------------------------- + + subroutine ncd_inqvdname_byName(ncid,varname,dimnum,dname,err_code) + ! + ! !DESCRIPTION: + ! Inquire name of one of a variable's dimensions, given a variable name + ! + ! If the variable has n dimensions, then dimnum should be between 1 and n; this + ! routine returns the name of the dimnum'th dimension. + ! + ! If there is an error condition, dname will be ' ', and err_code will hold the error + ! code; possible error codes are: + ! 0: no error + ! 1: dimnum out of range + ! 11: variable not found + ! + ! !ARGUMENTS: + class(file_desc_t),intent(inout) :: ncid ! netcdf file id + character(len=*) ,intent(in) :: varname ! variable name + integer ,intent(in) :: dimnum ! dimension number to query + character(len=*) ,intent(out) :: dname ! name of the dimension + integer ,intent(out) :: err_code ! error code (0 means no error) + ! + ! !LOCAL VARIABLES: + type(Var_desc_t) :: vardesc ! variable descriptor + logical :: readvar ! whether the variable was found + character(len=*), parameter :: dname_invalid = ' ' + integer, parameter :: error_variable_not_found = 11 + + character(len=*), parameter :: subname = 'ncd_inqvdname_byName' + !----------------------------------------------------------------------- + + call check_var(ncid, varname, vardesc, readvar) + if (readvar) then + call ncd_inqvdname_byDesc(ncid, vardesc, dimnum, dname, err_code) + else + dname = dname_invalid + err_code = error_variable_not_found + end if + + end subroutine ncd_inqvdname_byName !----------------------------------------------------------------------- + subroutine ncd_putatt_int(ncid,varid,attrib,value,xtype) ! ! !DESCRIPTION: From 3dd73283c15d6af6344db242c1ae2c214fc4062c Mon Sep 17 00:00:00 2001 From: rgknox Date: Thu, 11 May 2017 15:22:19 -0700 Subject: [PATCH 05/12] fates-interface: updated machine entries for lawrencium --- cime/config/acme/machines/config_machines.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cime/config/acme/machines/config_machines.xml b/cime/config/acme/machines/config_machines.xml index f54c464dd5ca..1c2128ae452f 100644 --- a/cime/config/acme/machines/config_machines.xml +++ b/cime/config/acme/machines/config_machines.xml @@ -2273,6 +2273,7 @@ Lawrencium LR3 cluster at LBL, OS is Linux (intel), batch system is SLURM LINUX + n000* intel openmpi,mpi-serial /global/scratch/$ENV{USER} @@ -2336,6 +2337,7 @@ Lawrencium LR2 cluster at LBL, OS is Linux (intel), batch system is SLURM LINUX + n000* intel openmpi,mpi-serial /global/scratch/$ENV{USER} From 58ed9e62aec933cb0d07434512988204b765fe13 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 May 2017 00:39:27 -0700 Subject: [PATCH 06/12] fates-interface: removed deprecated history variable. --- cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm | 2 +- .../cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm b/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm index 8b928f698738..ecee5dcba9ad 100644 --- a/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm +++ b/cime/config/acme/testmods_dirs/allactive/clm/fates/user_nl_clm @@ -6,6 +6,6 @@ hist_empty_htapes = .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', - 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','AREA_TREES','AREA_PLANT', + 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', 'HR','TOTLITC','TOTSOMC','AR' diff --git a/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm index 8b928f698738..ecee5dcba9ad 100644 --- a/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm +++ b/components/clm/cime_config/testdefs/testmods_dirs/clm/fates/user_nl_clm @@ -6,6 +6,6 @@ hist_empty_htapes = .true. hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', - 'PFTleafbiomass','FIRE_ROS','WIND','TFC_ROS','AREA_TREES','AREA_PLANT', + 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', 'HR','TOTLITC','TOTSOMC','AR' From 89205f62c1c28e7349520f75cf84c30391440dfb Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 May 2017 12:07:20 -0700 Subject: [PATCH 07/12] Removed existing fates submodule. Prepping to dock it in new location. --- .gitmodules | 4 ---- components/clm/src/fates | 1 - 2 files changed, 5 deletions(-) delete mode 160000 components/clm/src/fates diff --git a/.gitmodules b/.gitmodules index a8aeb3c919f4..4ddf3506edfe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,3 @@ path = components/mpas-cice/model url = git@github.com:ACME-Climate/MPAS.git branch = cice/develop -[submodule "components/clm/src/fates"] - path = components/clm/src/fates - url = git@github.com:ACME-Climate/fates.git - branch = release_head \ No newline at end of file diff --git a/components/clm/src/fates b/components/clm/src/fates deleted file mode 160000 index defc5bbb24b1..000000000000 --- a/components/clm/src/fates +++ /dev/null @@ -1 +0,0 @@ -Subproject commit defc5bbb24b1c8ea9d4c0f097590e3a257965204 From 5ac6154025ac7801bc25e2581bf67b17fb100a19 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 May 2017 12:20:45 -0700 Subject: [PATCH 08/12] fates-interface: added fates submodule to the external_models directory. --- .gitmodules | 3 +++ components/clm/src/external_models/fates | 1 + 2 files changed, 4 insertions(+) create mode 160000 components/clm/src/external_models/fates diff --git a/.gitmodules b/.gitmodules index 4ddf3506edfe..34e9caca4393 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,3 +9,6 @@ path = components/mpas-cice/model url = git@github.com:ACME-Climate/MPAS.git branch = cice/develop +[submodule "components/clm/src/external_models/fates"] + path = components/clm/src/external_models/fates + url = git@github.com:ACME-Climate/fates.git diff --git a/components/clm/src/external_models/fates b/components/clm/src/external_models/fates new file mode 160000 index 000000000000..defc5bbb24b1 --- /dev/null +++ b/components/clm/src/external_models/fates @@ -0,0 +1 @@ +Subproject commit defc5bbb24b1c8ea9d4c0f097590e3a257965204 From f5757b3d2d17dbebc7295bd087ab099b35aaf230 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 May 2017 12:25:50 -0700 Subject: [PATCH 09/12] fates-interface: set default submodule branch to release_head. --- .gitmodules | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitmodules b/.gitmodules index 34e9caca4393..590695ca9de2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,3 +12,4 @@ [submodule "components/clm/src/external_models/fates"] path = components/clm/src/external_models/fates url = git@github.com:ACME-Climate/fates.git + branch = release_head From 162fc1454f4f2e4abe9e3f26bf0b825fe4c61ae3 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 May 2017 12:31:38 -0700 Subject: [PATCH 10/12] fates-interface: Reverted branch specification. --- .gitmodules | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 590695ca9de2..34e9caca4393 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,4 +12,3 @@ [submodule "components/clm/src/external_models/fates"] path = components/clm/src/external_models/fates url = git@github.com:ACME-Climate/fates.git - branch = release_head From ae0571fa09bd2eaf91b1cf5374dc5a5f34fd5c5f Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 May 2017 13:34:09 -0700 Subject: [PATCH 11/12] fates-interface: Changed some build paths for fates to reflect new submodule path. --- components/clm/bld/configure | 8 ++++---- components/clm/src/CMakeLists.txt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/clm/bld/configure b/components/clm/bld/configure index 3198e5f0e963..4f0f8918d152 100755 --- a/components/clm/bld/configure +++ b/components/clm/bld/configure @@ -654,10 +654,10 @@ sub write_filepath_cesmbld "biogeophys/vsfm", "biogeochem", "dyn_subgrid", - "fates/main", - "fates/biogeophys", - "fates/biogeochem", - "fates/fire", + "external_models/fates/main", + "external_models/fates/biogeophys", + "external_models/fates/biogeochem", + "external_models/fates/fire", "utils", "cpl" ); diff --git a/components/clm/src/CMakeLists.txt b/components/clm/src/CMakeLists.txt index 78c6211d1d9f..c9672564e05c 100644 --- a/components/clm/src/CMakeLists.txt +++ b/components/clm/src/CMakeLists.txt @@ -18,10 +18,10 @@ add_subdirectory(${CLM_ROOT}/src/utils clm_utils) add_subdirectory(${CLM_ROOT}/src/biogeophys clm_biogeophys) add_subdirectory(${CLM_ROOT}/src/dyn_subgrid clm_dyn_subgrid) add_subdirectory(${CLM_ROOT}/src/main clm_main) -add_subdirectory(${CLM_ROOT}/src/fates/main ed_main) -add_subdirectory(${CLM_ROOT}/src/fates/biogeophys ed_biogeophys) -add_subdirectory(${CLM_ROOT}/src/fates/biogeochem ed_biogeochem) -add_subdirectory(${CLM_ROOT}/src/fates/fire ed_fire) +add_subdirectory(${CLM_ROOT}/src/external_models/fates/main ed_main) +add_subdirectory(${CLM_ROOT}/src/external_models/fates/biogeophys ed_biogeophys) +add_subdirectory(${CLM_ROOT}/src/external_models/fates/biogeochem ed_biogeochem) +add_subdirectory(${CLM_ROOT}/src/external_models/fates/fire ed_fire) # Add general unit test directories (mocked out files, etc.) From 87dead60a9443be635964516b82cdcb108742f1d Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 17 May 2017 12:29:01 -0700 Subject: [PATCH 12/12] Converted clm_fates structure to alm_fates. Fixed some format issues. --- components/clm/bld/CLMBuildNamelist.pm | 8 ++++---- .../clm/src/biogeochem/FatesBGCDynMod.F90 | 8 ++++---- .../clm/src/biogeophys/CanopyFluxesMod.F90 | 14 +++++++------- .../src/biogeophys/CanopyTemperatureMod.F90 | 6 +++--- .../src/biogeophys/HydrologyNoDrainageMod.F90 | 6 +++--- .../clm/src/biogeophys/SurfaceAlbedoMod.F90 | 6 +++--- components/clm/src/main/clm_driver.F90 | 18 +++++++++--------- components/clm/src/main/clm_initializeMod.F90 | 10 +++++----- components/clm/src/main/clm_instMod.F90 | 6 +++--- .../clm/src/main/clmfates_interfaceMod.F90 | 14 +++++++------- components/clm/src/main/ncdio_pio.F90.in | 2 ++ components/clm/src/main/restFileMod.F90 | 14 +++++++------- 12 files changed, 57 insertions(+), 55 deletions(-) diff --git a/components/clm/bld/CLMBuildNamelist.pm b/components/clm/bld/CLMBuildNamelist.pm index 5adc1f09adb8..b14b2227aa97 100755 --- a/components/clm/bld/CLMBuildNamelist.pm +++ b/components/clm/bld/CLMBuildNamelist.pm @@ -829,10 +829,10 @@ sub setup_cmdl_betr_mode { $nl_flags->{'betr_mode'} = $val; if ( $physv->as_long() == $physv->as_long("clm4_0") || $nl_flags->{'crop'} eq "on" ) { -# if ( $nl_flags->{'ed_mode'} == 1 ) { -# # ED is not a clm4_0 option and should not be used with crop and not with clm4_0 -# fatal_error("** Cannot turn betr mode on with crop or with clm4_0 physics.\n" ); -# } + if ( $nl_flags->{$var} == 1 ) { + # BeTR is not a clm4_0 option and should not be used with crop and not with clm4_0 + fatal_error("** Cannot turn betr mode on with crop or with clm4_0 physics.\n" ); + } } else { $var = "use_betr"; diff --git a/components/clm/src/biogeochem/FatesBGCDynMod.F90 b/components/clm/src/biogeochem/FatesBGCDynMod.F90 index e72aa8374086..044e0ea417f7 100644 --- a/components/clm/src/biogeochem/FatesBGCDynMod.F90 +++ b/components/clm/src/biogeochem/FatesBGCDynMod.F90 @@ -31,7 +31,7 @@ subroutine FatesBGCDyn(bounds, & canopystate_vars, soilstate_vars, temperature_vars, & ch4_vars, nitrogenflux_vars, nitrogenstate_vars, & phosphorusstate_vars, phosphorusflux_vars, & - clm_fates) + alm_fates) use clm_varctl , only : use_c13, use_c14, use_ed use decompMod , only : bounds_type @@ -79,7 +79,7 @@ subroutine FatesBGCDyn(bounds, & type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars type(phosphorusstate_type), intent(inout) :: phosphorusstate_vars type(phosphorusflux_type) , intent(inout) :: phosphorusflux_vars - type(hlm_fates_interface_type),intent(inout) :: clm_fates + type(hlm_fates_interface_type),intent(inout) :: alm_fates ! ! !LOCAL VARIABLES: @@ -236,7 +236,7 @@ subroutine FatesBGCDyn(bounds, & ! Pass in FATES boundary conditions, ie litter fluxes ! ------------------------------------------------------- - call clm_fates%UpdateLitterFluxes(bounds,carbonflux_vars) + call alm_fates%UpdateLitterFluxes(bounds,carbonflux_vars) ! Update all prognostic carbon state variables (except for gap-phase mortality and fire fluxes) @@ -278,7 +278,7 @@ subroutine FatesBGCDyn(bounds, & ! calculate balance checks on entire carbon cycle (FATES + BGC) ! ---------------------------------------------- - call clm_fates%wrap_bgc_summary( bounds, carbonflux_vars, carbonstate_vars) + call alm_fates%wrap_bgc_summary( bounds, carbonflux_vars, carbonstate_vars) call t_stopf('BGCsum') diff --git a/components/clm/src/biogeophys/CanopyFluxesMod.F90 b/components/clm/src/biogeophys/CanopyFluxesMod.F90 index af7b422790e4..8f6be2a0d18b 100644 --- a/components/clm/src/biogeophys/CanopyFluxesMod.F90 +++ b/components/clm/src/biogeophys/CanopyFluxesMod.F90 @@ -68,7 +68,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & frictionvel_vars, soilstate_vars, solarabs_vars, surfalb_vars, & temperature_vars, waterflux_vars, waterstate_vars, ch4_vars, photosyns_vars, & soil_water_retention_curve, nitrogenstate_vars, phosphorusstate_vars, & - clm_fates) + alm_fates) ! ! !DESCRIPTION: ! 1. Calculates the leaf temperature: @@ -131,7 +131,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & class(soil_water_retention_curve_type), intent(in) :: soil_water_retention_curve type(nitrogenstate_type) , intent(inout) :: nitrogenstate_vars type(phosphorusstate_type), intent(inout) :: phosphorusstate_vars - type(hlm_fates_interface_type) , intent(inout) :: clm_fates + type(hlm_fates_interface_type) , intent(inout) :: alm_fates ! ! !LOCAL VARIABLES: real(r8), parameter :: btran0 = 0.0_r8 ! initial value @@ -485,7 +485,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & if (use_ed) then - call clm_fates%prep_canopyfluxes( bounds ) + call alm_fates%prep_canopyfluxes( bounds ) end if @@ -561,7 +561,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! -------------------------------------------------------------------------- if(use_ed)then - call clm_fates%wrap_btran(bounds, fn, filterc_tmp(1:fn), soilstate_vars, waterstate_vars, & + call alm_fates%wrap_btran(bounds, fn, filterc_tmp(1:fn), soilstate_vars, waterstate_vars, & temperature_vars, energyflux_vars, soil_water_retention_curve) else @@ -849,7 +849,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & if ( use_ed ) then - call clm_fates%wrap_photosynthesis(bounds, fn, filterp(1:fn), & + call alm_fates%wrap_photosynthesis(bounds, fn, filterp(1:fn), & svpts(begp:endp), eah(begp:endp), o2(begp:endp), & co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), & atm2lnd_vars, temperature_vars, canopystate_vars, photosyns_vars) @@ -1197,8 +1197,8 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & end do if ( use_ed ) then - call clm_fates%wrap_accumulatefluxes(bounds,fn,filterp(1:fn)) - call clm_fates%wrap_hydraulics_drive(bounds,soilstate_vars, & + call alm_fates%wrap_accumulatefluxes(bounds,fn,filterp(1:fn)) + call alm_fates%wrap_hydraulics_drive(bounds,soilstate_vars, & waterstate_vars,waterflux_vars,solarabs_vars,energyflux_vars) else diff --git a/components/clm/src/biogeophys/CanopyTemperatureMod.F90 b/components/clm/src/biogeophys/CanopyTemperatureMod.F90 index 54455cb59c5b..9f7d0c8cbfcd 100644 --- a/components/clm/src/biogeophys/CanopyTemperatureMod.F90 +++ b/components/clm/src/biogeophys/CanopyTemperatureMod.F90 @@ -48,7 +48,7 @@ subroutine CanopyTemperature(bounds, & num_nolakec, filter_nolakec, num_nolakep, filter_nolakep, & atm2lnd_vars, canopystate_vars, soilstate_vars, frictionvel_vars, & waterstate_vars, waterflux_vars, energyflux_vars, temperature_vars, & - clm_fates) + alm_fates) ! ! !DESCRIPTION: ! This is the main subroutine to execute the calculation of leaf temperature @@ -93,7 +93,7 @@ subroutine CanopyTemperature(bounds, & type(waterflux_type) , intent(inout) :: waterflux_vars type(energyflux_type) , intent(inout) :: energyflux_vars type(temperature_type) , intent(inout) :: temperature_vars - type(hlm_fates_interface_type) , intent(inout) :: clm_fates + type(hlm_fates_interface_type) , intent(inout) :: alm_fates ! ! !LOCAL VARIABLES: integer :: g,l,c,p ! indices @@ -401,7 +401,7 @@ subroutine CanopyTemperature(bounds, & ! enabled simultaneously with FATES, we will ! have to apply a filter here. if(use_ed) then - call clm_fates%TransferZ0mDisp(bounds,frictionvel_vars,canopystate_vars) + call alm_fates%TransferZ0mDisp(bounds,frictionvel_vars,canopystate_vars) end if do fp = 1,num_nolakep diff --git a/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 b/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 index 713504c05262..f3062340c6a6 100644 --- a/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 +++ b/components/clm/src/biogeophys/HydrologyNoDrainageMod.F90 @@ -41,7 +41,7 @@ subroutine HydrologyNoDrainage(bounds, & waterflux_vars, waterstate_vars, & soilhydrology_vars, aerosol_vars, & soil_water_retention_curve, betrtracer_vars, tracerflux_vars, tracerstate_vars, & - clm_fates) + alm_fates) ! ! !DESCRIPTION: ! This is the main subroutine to execute the calculation of soil/snow @@ -104,7 +104,7 @@ subroutine HydrologyNoDrainage(bounds, & type(betrtracer_type) , intent(in) :: betrtracer_vars ! betr configuration information type(tracerflux_type) , intent(inout) :: tracerflux_vars ! tracer flux type(tracerstate_type) , intent(inout) :: tracerstate_vars ! tracer state variables data structure - type(hlm_fates_interface_type) , intent(inout) :: clm_fates + type(hlm_fates_interface_type) , intent(inout) :: alm_fates ! ! !LOCAL VARIABLES: integer :: g,l,c,j,fc ! indices @@ -218,7 +218,7 @@ subroutine HydrologyNoDrainage(bounds, & filter_hydrologyc, soilstate_vars, waterflux_vars) ! If FATES plant hydraulics is turned on, over-ride default transpiration sink calculation - if( use_ed ) call clm_fates%ComputeRootSoilFlux(bounds, num_hydrologyc, filter_hydrologyc, & + if( use_ed ) call alm_fates%ComputeRootSoilFlux(bounds, num_hydrologyc, filter_hydrologyc, & soilstate_vars, waterflux_vars) call SoilWater(bounds, num_hydrologyc, filter_hydrologyc, num_urbanc, filter_urbanc, & diff --git a/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 b/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 index 0d86a7c3e4b9..7a13764cd800 100644 --- a/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 +++ b/components/clm/src/biogeophys/SurfaceAlbedoMod.F90 @@ -172,7 +172,7 @@ subroutine SurfaceAlbedo(bounds, & nextsw_cday , declinp1, & aerosol_vars, canopystate_vars, waterstate_vars, & lakestate_vars, temperature_vars, surfalb_vars, & - clm_fates) + alm_fates) ! ! !DESCRIPTION: ! Surface albedo and two-stream fluxes @@ -220,7 +220,7 @@ subroutine SurfaceAlbedo(bounds, & type(lakestate_type) , intent(in) :: lakestate_vars type(temperature_type) , intent(in) :: temperature_vars type(surfalb_type) , intent(inout) :: surfalb_vars - type(hlm_fates_interface_type), intent(inout) :: clm_fates + type(hlm_fates_interface_type), intent(inout) :: alm_fates ! ! !LOCAL VARIABLES: integer :: i ! index for layers [idx] @@ -916,7 +916,7 @@ subroutine SurfaceAlbedo(bounds, & ! Only perform on vegetated pfts where coszen > 0 if(use_ed)then - call clm_fates%wrap_canopy_radiation(bounds, & + call alm_fates%wrap_canopy_radiation(bounds, & num_vegsol, filter_vegsol, & coszen_patch(bounds%begp:bounds%endp), surfalb_vars) else diff --git a/components/clm/src/main/clm_driver.F90 b/components/clm/src/main/clm_driver.F90 index d1b7dc02dbc2..d931c8214963 100644 --- a/components/clm/src/main/clm_driver.F90 +++ b/components/clm/src/main/clm_driver.F90 @@ -114,7 +114,7 @@ module clm_driver use clm_instMod , only : lnd2glc_vars use clm_instMod , only : soil_water_retention_curve use clm_instMod , only : chemstate_vars - use clm_instMod , only : clm_fates + use clm_instMod , only : alm_fates use betr_initializeMod , only : betrtracer_vars use betr_initializeMod , only : tracercoeff_vars use betr_initializeMod , only : tracerflux_vars @@ -475,7 +475,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) ! over the patch index range defined by bounds_clump%begp:bounds_proc%endp if(use_ed) then - call clm_fates%wrap_sunfrac(bounds_clump,atm2lnd_vars, canopystate_vars) + call alm_fates%wrap_sunfrac(bounds_clump,atm2lnd_vars, canopystate_vars) else call CanopySunShadeFractions(filter(nc)%num_nourbanp, filter(nc)%nourbanp, & atm2lnd_vars, surfalb_vars, canopystate_vars, & @@ -512,7 +512,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) filter(nc)%num_nolakep, filter(nc)%nolakep, & atm2lnd_vars, canopystate_vars, soilstate_vars, frictionvel_vars, & waterstate_vars, waterflux_vars, energyflux_vars, temperature_vars, & - clm_fates) + alm_fates) call t_stopf('bgp1') ! ============================================================================ @@ -542,7 +542,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) frictionvel_vars, soilstate_vars, solarabs_vars, surfalb_vars, & temperature_vars, waterflux_vars, waterstate_vars, ch4_vars, photosyns_vars, & soil_water_retention_curve, nitrogenstate_vars,phosphorusstate_vars, & - clm_fates) + alm_fates) call t_stopf('canflux') ! Fluxes for all urban landunits @@ -655,7 +655,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) atm2lnd_vars, soilstate_vars, energyflux_vars, temperature_vars, & waterflux_vars, waterstate_vars, soilhydrology_vars, aerosol_vars, & soil_water_retention_curve, betrtracer_vars, tracerflux_vars, & - tracerstate_vars, clm_fates) + tracerstate_vars, alm_fates) ! Calculate column-integrated aerosol masses, and ! mass concentrations for radiative calculations and output @@ -1030,7 +1030,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) write(iulog,*) 'clm: calling FATES model ', get_nstep() end if - call clm_fates%dynamics_driv( bounds_clump, & + call alm_fates%dynamics_driv( bounds_clump, & atm2lnd_vars, soilstate_vars, temperature_vars, & waterstate_vars, canopystate_vars, carbonflux_vars, & frictionvel_vars) @@ -1056,7 +1056,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) canopystate_vars, soilstate_vars, temperature_vars, & ch4_vars, nitrogenflux_vars, nitrogenstate_vars, & phosphorusstate_vars, phosphorusflux_vars, & - clm_fates) + alm_fates) end if @@ -1158,7 +1158,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) nextsw_cday, declinp1, & aerosol_vars, canopystate_vars, waterstate_vars, & lakestate_vars, temperature_vars, surfalb_vars, & - clm_fates) + alm_fates) call t_stopf('surfalb') ! Albedos for urban columns @@ -1341,7 +1341,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, & - tracercoeff_vars, clm_fates, rdate=rdate ) + tracercoeff_vars, alm_fates, rdate=rdate ) call t_stopf('clm_drv_io_wrest') end if diff --git a/components/clm/src/main/clm_initializeMod.F90 b/components/clm/src/main/clm_initializeMod.F90 index 08d7c0c54eb0..b6cd675ed5bf 100644 --- a/components/clm/src/main/clm_initializeMod.F90 +++ b/components/clm/src/main/clm_initializeMod.F90 @@ -616,7 +616,7 @@ subroutine initialize2( ) waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & - clm_fates) + alm_fates) end if else if ((nsrest == nsrContinue) .or. (nsrest == nsrBranch)) then @@ -632,7 +632,7 @@ subroutine initialize2( ) waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & - clm_fates) + alm_fates) end if @@ -678,7 +678,7 @@ subroutine initialize2( ) waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & - clm_fates) + alm_fates) ! Interpolate finidat onto new template file call getfil( finidat_interp_source, fnamer, 0 ) @@ -694,7 +694,7 @@ subroutine initialize2( ) waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & - clm_fates) + alm_fates) ! Reset finidat to now be finidat_interp_dest ! (to be compatible with routines still using finidat) @@ -823,7 +823,7 @@ subroutine initialize2( ) ! -------------------------------------------------------------- if ( use_ed .and. .not.is_restart() .and. finidat == ' ') then - call clm_fates%init_coldstart(waterstate_vars,canopystate_vars, & + call alm_fates%init_coldstart(waterstate_vars,canopystate_vars, & soilstate_vars, frictionvel_vars) end if diff --git a/components/clm/src/main/clm_instMod.F90 b/components/clm/src/main/clm_instMod.F90 index db2442279927..f47aaafa3fd7 100644 --- a/components/clm/src/main/clm_instMod.F90 +++ b/components/clm/src/main/clm_instMod.F90 @@ -111,11 +111,11 @@ module clm_instMod type(phosphorusflux_type) :: phosphorusflux_vars type(clm_bgc_interface_data_type) :: clm_bgc_data type(chemstate_type) :: chemstate_vars - type(hlm_fates_interface_type) :: clm_fates + type(hlm_fates_interface_type) :: alm_fates public :: clm_inst_biogeochem public :: clm_inst_biogeophys - public :: clm_fates + public :: alm_fates contains @@ -207,7 +207,7 @@ subroutine clm_inst_biogeochem(bounds_proc) ! Initialize the Functionaly Assembled Terrestrial Ecosystem Simulator (FATES) if (use_ed) then - call clm_fates%Init(bounds_proc) + call alm_fates%Init(bounds_proc) end if call hist_printflds() diff --git a/components/clm/src/main/clmfates_interfaceMod.F90 b/components/clm/src/main/clmfates_interfaceMod.F90 index fa1ea30a3303..7f51d1d9278d 100644 --- a/components/clm/src/main/clmfates_interfaceMod.F90 +++ b/components/clm/src/main/clmfates_interfaceMod.F90 @@ -19,7 +19,7 @@ module CLMFatesInterfaceMod ! and moreover they must be pushed/pulled from history IO for each individual ! bounds_proc memory space as a unit. ! - ! Therefore, the state variables in the clm_fates communicator is vectorized by + ! Therefore, the state variables in the alm_fates communicator is vectorized by ! threadcount, and the IO communication arrays are not. ! ! @@ -311,7 +311,7 @@ subroutine init(this, bounds_proc ) call set_fates_ctrlparms('check_allset') if(DEBUG)then - write(iulog,*) 'clm_fates%init(): allocating for ',nclumps,' threads' + write(iulog,*) 'alm_fates%init(): allocating for ',nclumps,' threads' end if @@ -346,7 +346,7 @@ subroutine init(this, bounds_proc ) collist(s) = c this%f2hmap(nc)%hsites(c) = s if(DEBUG)then - write(iulog,*) 'clm_fates%init(): thread',nc,': found column',c,'with lu',l + write(iulog,*) 'alm_fates%init(): thread',nc,': found column',c,'with lu',l write(iulog,*) 'LU type:', lun%itype(l) end if endif @@ -354,7 +354,7 @@ subroutine init(this, bounds_proc ) enddo if(DEBUG)then - write(iulog,*) 'clm_fates%init(): thread',nc,': allocated ',s,' sites' + write(iulog,*) 'alm_fates%init(): thread',nc,': allocated ',s,' sites' end if ! Allocate vectors that match FATES sites with HLM columns @@ -819,7 +819,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & ! Note that while we pass the following values at this point ! we have to send the same values after each time-step because ! the HLM keeps changing the value and re-setting, so we - ! re-send instead of re-set. See clm_fates%TransferZ0mDisp() + ! re-send instead of re-set. See alm_fates%TransferZ0mDisp() z0m(p) = this%fates(nc)%bc_out(s)%z0m_pa(ifp) displa(p) = this%fates(nc)%bc_out(s)%displa_pa(ifp) dleaf_patch(p) = this%fates(nc)%bc_out(s)%dleaf_pa(ifp) @@ -847,7 +847,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & ! ! Note: waterstate_inst and canopystate_inst are arguments only because following ! the reading of variables, it is necessary to update diagnostics of the canopy - ! throug the interface call clm_fates%wrap_update_hlmfates_dyn() which requires + ! throug the interface call alm_fates%wrap_update_hlmfates_dyn() which requires ! this information from the HLM. ! --------------------------------------------------------------------------------- @@ -941,7 +941,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & c = this%f2hmap(nc)%fcolumn(s) this%fates_restart%restart_map(nc)%site_index(s) = c this%fates_restart%restart_map(nc)%cohort1_index(s) = & - bounds_proc%begCohort + (c-bounds_proc%begc)*fates_maxElementsPerSite + 1 + bounds_proc%begCohort + (c-bounds_proc%begc)*fates_maxElementsPerSite end do end do diff --git a/components/clm/src/main/ncdio_pio.F90.in b/components/clm/src/main/ncdio_pio.F90.in index b32255a112ff..82b13ca46a26 100644 --- a/components/clm/src/main/ncdio_pio.F90.in +++ b/components/clm/src/main/ncdio_pio.F90.in @@ -661,6 +661,8 @@ contains end subroutine ncd_inqvdlen_byDesc + + !------------------------------------------------------------------------- subroutine ncd_inqvdlen_byName(ncid,varname,dimnum,dlen,err_code) ! ! !DESCRIPTION: diff --git a/components/clm/src/main/restFileMod.F90 b/components/clm/src/main/restFileMod.F90 index ebe276e62ab5..bcf53cebf574 100644 --- a/components/clm/src/main/restFileMod.F90 +++ b/components/clm/src/main/restFileMod.F90 @@ -100,7 +100,7 @@ subroutine restFile_write( bounds, file, waterflux_vars, waterstate_vars, & phosphorusstate_vars, phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & - clm_fates, & + alm_fates, & rdate, noptr) ! ! !DESCRIPTION: @@ -138,7 +138,7 @@ subroutine restFile_write( bounds, file, type(BeTRTracer_Type) , intent(in) :: betrtracer_vars type(tracerflux_type) , intent(inout) :: tracerflux_vars type(tracercoeff_type) , intent(inout) :: tracercoeff_vars - type(hlm_fates_interface_type) , intent(inout) :: clm_fates + type(hlm_fates_interface_type) , intent(inout) :: alm_fates character(len=*) , intent(in), optional :: rdate ! restart file time stamp for name logical , intent(in), optional :: noptr ! if should NOT write to the restart pointer file ! @@ -249,7 +249,7 @@ subroutine restFile_write( bounds, file, end if call carbonflux_vars%restart(bounds, ncid, flag='define') - call clm_fates%restart(bounds, ncid, flag='define', & + call alm_fates%restart(bounds, ncid, flag='define', & waterstate_inst=waterstate_vars, & canopystate_inst=canopystate_vars, & frictionvel_inst=frictionvel_vars) @@ -360,7 +360,7 @@ subroutine restFile_write( bounds, file, end if call carbonflux_vars%restart(bounds, ncid, flag='write') - call clm_fates%restart(bounds, ncid, flag='write', & + call alm_fates%restart(bounds, ncid, flag='write', & waterstate_inst=waterstate_vars, & canopystate_inst=canopystate_vars, & frictionvel_inst=frictionvel_vars) @@ -409,7 +409,7 @@ subroutine restFile_read( bounds, file, waterflux_vars, waterstate_vars, & phosphorusstate_vars,phosphorusflux_vars, & betrtracer_vars, tracerstate_vars, tracerflux_vars, tracercoeff_vars, & - clm_fates) + alm_fates) ! ! !DESCRIPTION: ! Read a CLM restart file. @@ -451,7 +451,7 @@ subroutine restFile_read( bounds, file, type(BeTRTracer_Type) , intent(in) :: betrtracer_vars type(tracerflux_type) , intent(inout) :: tracerflux_vars type(tracercoeff_type) , intent(inout) :: tracercoeff_vars - type(hlm_fates_interface_type) , intent(inout) :: clm_fates + type(hlm_fates_interface_type) , intent(inout) :: alm_fates ! ! !LOCAL VARIABLES: type(file_desc_t) :: ncid ! netcdf id @@ -548,7 +548,7 @@ subroutine restFile_read( bounds, file, end if call carbonflux_vars%restart(bounds, ncid, flag='read') - call clm_fates%restart(bounds, ncid, flag='read', & + call alm_fates%restart(bounds, ncid, flag='read', & waterstate_inst=waterstate_vars, & canopystate_inst=canopystate_vars, & frictionvel_inst=frictionvel_vars)