Skip to content

Commit

Permalink
Merge branch 'jinyuntang/lnd/betr' into next (PR #367)
Browse files Browse the repository at this point in the history
This merge brings in BeTR to facilitate reactive transport based land BGC modeling in ALM.
By default, BeTR is turned off.
BeTR has been tested with simulations with different bgc configurations for about 10000 years, and some modules was evaluated analytically.
The merge does not requires new parameter files nor affect any other existing land components.

[BFB]
LG-108

Conflicts:
	cime/machines-acme/env_mach_specific.edison
	components/clm/bld/CLMBuildNamelist.pm
	components/clm/bld/configure
	components/clm/src/biogeochem/CNCStateUpdate1Mod.F90
	components/clm/src/biogeochem/CNCStateUpdate2Mod.F90
	components/clm/src/biogeochem/CNCStateUpdate3Mod.F90
	components/clm/src/biogeochem/CNCarbonFluxType.F90
	components/clm/src/biogeochem/CNEcosystemDynMod.F90
	components/clm/src/biogeochem/CNNStateUpdate1Mod.F90
	components/clm/src/biogeochem/CNNStateUpdate2Mod.F90
	components/clm/src/biogeochem/CNNStateUpdate3Mod.F90
	components/clm/src/biogeochem/CNNitrogenFluxType.F90
	components/clm/src/biogeochem/CNNitrogenStateType.F90
	components/clm/src/biogeochem/CNPrecisionControlMod.F90
	components/clm/src/biogeochem/CNStateType.F90
	components/clm/src/main/clm_driver.F90
	components/clm/src/main/clm_initializeMod.F90
	components/clm/src/main/clm_varctl.F90
	components/clm/src/main/controlMod.F90
	components/clm/src/main/restFileMod.F90
  • Loading branch information
Gautam Bisht committed Oct 24, 2015
2 parents 20e6611 + be0d6ed commit 4d29a66
Show file tree
Hide file tree
Showing 86 changed files with 24,626 additions and 1,155 deletions.
10 changes: 5 additions & 5 deletions cime/machines-acme/env_mach_specific.edison
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ echo "DEBUG=$DEBUG"
if (-e /opt/modules/default/init/csh) then
source /opt/modules/default/init/csh
module rm PrgEnv-intel
module rm PrgEnv-cray
module rm PrgEnv-cray
module rm PrgEnv-gnu
module rm intel
module rm cce
module rm cray-parallel-netcdf
module rm cray-parallel-hdf5
module rm cray-parallel-hdf5
module rm pmi
module rm cray-libsci
module rm cray-mpich2
Expand All @@ -46,16 +46,16 @@ if ( $COMPILER == "intel" ) then
module load esmf/6.2.0-defio-mpi-g
else
module load esmf/6.2.0-defio-mpi-O
endif
endif
endif
endif
if ( $COMPILER == "cray" ) then
module load PrgEnv-cray
module switch cce cce/8.3.7
endif
if ( $COMPILER == "gnu" ) then
module load PrgEnv-gnu
module switch gcc gcc/4.8.0
endif
endif

module load papi/5.3.2
module swap craype craype/2.1.1
Expand Down
49 changes: 48 additions & 1 deletion components/clm/bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ OPTIONS
-version Echo the SVN tag name used to check out this CLM distribution.
-vichydro Toggle to turn on VIC hydrologic parameterizations (default is off)
This turns on the namelist variable: use_vichydro
-betr_mode Turn on betr model for tracer transport in soil. [on|off] default is off.
Note: The precedence for setting the values of namelist variables is (highest to lowest):
Expand Down Expand Up @@ -278,6 +279,7 @@ sub process_commandline {
envxml_dir => ".",
vichydro => 0,
maxpft => "default",
betr_mode => "default",
);

GetOptions(
Expand Down Expand Up @@ -322,6 +324,7 @@ sub process_commandline {
"maxpft=i" => \$opts{'maxpft'},
"v|verbose" => \$opts{'verbose'},
"version" => \$opts{'version'},
"betr_mode=s" => \$opts{'betr_mode'},
) or usage();

# Give usage message.
Expand Down Expand Up @@ -641,6 +644,7 @@ sub process_namelist_commandline_options {
setup_cmdl_dynamic_vegetation($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_cmdl_ed_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);
}

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -762,6 +766,49 @@ sub setup_cmdl_ed_mode {
}
}

#-------------------------------------------------------------------------------
sub setup_cmdl_betr_mode {
#
# call this at least after crop check is called
#
my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

my $val;
my $var = "betr_mode";

$val = $opts->{$var};
$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" );
}
} else {

$var = "use_betr";
$nl_flags->{$var} = ".false.";
if ($nl_flags->{'betr_mode'} eq "on") {
message("Using BETR (Reactive Transport).");
$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 -betr_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");
}

}
}
}


#-------------------------------------------------------------------------------
sub setup_cmdl_bgc {
# BGC - alias for group of biogeochemistry related use_XXX namelists
Expand Down Expand Up @@ -2759,7 +2806,7 @@ sub write_output_files {
} else {
@groups = qw(clm_inparm ndepdyn_nml popd_streams light_streams lai_streams clm_canopyhydrology_inparm
clm_soilhydrology_inparm dynamic_subgrid finidat_consistency_checks dynpft_consistency_checks
clmu_inparm clm_soilstate_inparm clm_pflotran_inparm );
clmu_inparm clm_soilstate_inparm clm_pflotran_inparm betr_inparm);
#@groups = qw(clm_inparm clm_canopyhydrology_inparm clm_soilhydrology_inparm
# finidat_consistency_checks dynpft_consistency_checks);
# Eventually only list namelists that are actually used when CN on
Expand Down
7 changes: 6 additions & 1 deletion components/clm/bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,12 @@ sub write_filepath_cesmbld

# source directories under root
my @dirs = ( "main",
"biogeophys",
"betr",
"betr/betr_math",
"betr/betr_core",
"betr/bgc_century",
"betr/bgc_sminn",
"biogeophys",
"biogeochem",
"dyn_subgrid",
"ED",
Expand Down
13 changes: 13 additions & 0 deletions components/clm/bld/namelist_files/namelist_definition_clm4_5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ This downscaling is conservative.
<default>Default: .true.</default>
</entry>

<entry id="use_betr" type="logical" category="physics"
group="clm_inparm" valid_values="" value=".false.">
Toggle to turn on the BeTR
(BETR = 'on' is EXPERIMENTAL NOT SUPPORTED!)
</entry>

<entry id="use_ed" type="logical" category="physics"
group="clm_inparm" valid_values="" value=".false.">
Expand Down Expand Up @@ -1275,6 +1280,14 @@ reaches melting when ice is present with no snow layers. Represents puddling, ic
Set to alblak values (0.6, 0.4) to keep albedo constant for ice-covered lakes without snow layers.
</entry>

<!-- ======================================================================================== -->
<!-- namelist elements associated with the betr_initializeMod -->
<!-- ======================================================================================== -->
<entry id="bgc_method" type="char*256" category="clm_betr"
group="betr_inparm" valid_values="" >
Specify what bgc module will be used within the betr framework.
</entry>

<!-- ======================================================================================== -->
<!-- namelist elements associated with the Hydrology1Mod -->
<!-- ======================================================================================== -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,14 @@ reaches melting when ice is present with no snow layers. Represents puddling, ic
Set to alblak values (0.6, 0.4) to keep albedo constant for ice-covered lakes without snow layers.
</entry>

<!-- ======================================================================================== -->
<!-- namelist elements associated with the betr_initializeMod -->
<!-- ======================================================================================== -->
<entry id="bgc_method" type="char*256" category="clm_betr"
group="betr_inparm" valid_values="" >
Specify what bgc module will be used within the betr framework.
</entry>

<!-- ======================================================================================== -->
<!-- namelist elements associated with the Hydrology1Mod -->
<!-- ======================================================================================== -->
Expand Down
5 changes: 5 additions & 0 deletions components/clm/bld/unit_testers/build-namelist_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ sub make_env_run {
GLC_TWO_WAY_COUPLING=>"FALSE",
conopts=>"-phys clm4_5",
},
"useBETRContradict" =>{ options=>"-betr_mode -envxml_dir .",
namelst=>"use_betr=.false.",
GLC_TWO_WAY_COUPLING=>"FALSE",
conopts=>"-phys clm4_5",
},
"useEDContradict2" =>{ options=>"-envxml_dir .",
namelst=>"use_ed=.true.",
GLC_TWO_WAY_COUPLING=>"FALSE",
Expand Down
76 changes: 76 additions & 0 deletions components/clm/src/betr/BGCReactionsFactoryMod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module BGCReactionsFactoryMod
!
! !DESCRIPTION:
! factory to load the specific bgc reaction modules
!
! History:
! Created by Jinyun Tang, Oct 2, 2014
!
!
! !USES:
!
use shr_kind_mod , only : r8 => shr_kind_r8
use decompMod , only : bounds_type
use shr_log_mod , only : errMsg => shr_log_errMsg
implicit none
save
private
public :: ctreate_bgc_reaction_type


contains

function ctreate_bgc_reaction_type(method) result(bgc_reaction)
!
! !DESCRIPTION:
! create and return an object of bgc_reaction
!
! !USES:
use BGCReactionsMod , only : bgc_reaction_type
use BGCReactionsMockRunType , only : bgc_reaction_mock_run_type
use BGCReactionsCenturyType , only : bgc_reaction_CENTURY_type
use BGCReactionsCenturyCLMType , only : bgc_reaction_CENTURY_clm_type
use BGCReactionsCenturyECAType , only : bgc_reaction_CENTURY_ECA_type
use BGCReactionsSminNType , only : bgc_reaction_sminn_type
use BGCReactionsCenturyCLM3Type , only : bgc_reaction_CENTURY_clm3_type
use BGCReactionsCenturyCLMOType , only : bgc_reaction_CENTURY_clmo_type
use abortutils , only : endrun
use clm_varctl , only : iulog
use tracer_varcon , only : is_active_betr_bgc, do_betr_leaching

! !ARGUMENTS:
class(bgc_reaction_type), allocatable :: bgc_reaction
character(len=*), intent(in) :: method
character(len=*), parameter :: subname = 'ctreate_bgc_reaction_type'

select case(trim(method))
case ("mock_run")
allocate(bgc_reaction, source=bgc_reaction_mock_run_type())
case ("century_bgc")
is_active_betr_bgc = .true.
allocate(bgc_reaction, source=bgc_reaction_CENTURY_type())
case ("century_bgcclm")
is_active_betr_bgc = .true.
allocate(bgc_reaction, source=bgc_reaction_CENTURY_clm_type())
case ("century_bgcECA")
is_active_betr_bgc = .true.
allocate(bgc_reaction, source=bgc_reaction_CENTURY_ECA_type())
case ("century_bgcclm3")
is_active_betr_bgc=.true.
allocate(bgc_reaction, source=bgc_reaction_CENTURY_clm3_type())
case ("century_bgcclmo")
is_active_betr_bgc=.true.
allocate(bgc_reaction, source=bgc_reaction_CENTURY_clmo_type())
case ("betr_sminn")
!this must be used together with clm45bgc
do_betr_leaching = .true.
allocate(bgc_reaction, source=bgc_reaction_sminn_type())
!case ("o18_istope") ! on hold
! allocate(bgc_reaction, source=bgc_reaction_O18ISO_type())
case default
write(iulog,*)subname //' ERROR: unknown method: ', method
call endrun(msg=errMsg(__FILE__, __LINE__))
end select
end function ctreate_bgc_reaction_type

end module BGCReactionsFactoryMod
Loading

0 comments on commit 4d29a66

Please sign in to comment.