Skip to content

Commit

Permalink
IceModelVec2T::init() will deduce period length
Browse files Browse the repository at this point in the history
  • Loading branch information
ckhroulev committed Aug 30, 2021
1 parent c43288d commit 92e79e9
Show file tree
Hide file tree
Showing 31 changed files with 221 additions and 507 deletions.
5 changes: 2 additions & 3 deletions src/basalstrength/MohrCoulombYieldStress.cc
Expand Up @@ -117,7 +117,6 @@ MohrCoulombYieldStress::MohrCoulombYieldStress(IceGrid::ConstPtr grid)

unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -127,7 +126,7 @@ MohrCoulombYieldStress::MohrCoulombYieldStress(IceGrid::ConstPtr grid)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic, LINEAR);
opt.periodic, LINEAR);
m_delta->set_attrs("", "minimum effective pressure on till as a fraction of overburden pressure",
"1", "1", "", 0);
}
Expand Down Expand Up @@ -201,7 +200,7 @@ void MohrCoulombYieldStress::finish_initialization(const YieldStressInputs &inpu
if (m_delta) {
ForcingOptions opt(*m_grid->ctx(), "basal_yield_stress.mohr_coulomb.delta");

m_delta->init(opt.filename, opt.period, opt.reference_time);
m_delta->init(opt.filename, opt.periodic);
}

// We use a short time step length because we can get away with it here, but we can
Expand Down
9 changes: 4 additions & 5 deletions src/coupler/atmosphere/Anomaly.cc
Expand Up @@ -34,7 +34,6 @@ Anomaly::Anomaly(IceGrid::ConstPtr g, std::shared_ptr<AtmosphereModel> in)
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -44,7 +43,7 @@ Anomaly::Anomaly(IceGrid::ConstPtr g, std::shared_ptr<AtmosphereModel> in)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);

m_precipitation_anomaly = IceModelVec2T::ForcingField(m_grid,
Expand All @@ -53,7 +52,7 @@ Anomaly::Anomaly(IceGrid::ConstPtr g, std::shared_ptr<AtmosphereModel> in)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);
}

m_air_temp_anomaly->set_attrs("climate_forcing",
Expand Down Expand Up @@ -85,8 +84,8 @@ void Anomaly::init_impl(const Geometry &geometry) {
" reading anomalies from %s ...\n",
opt.filename.c_str());

m_air_temp_anomaly->init(opt.filename, opt.period, opt.reference_time);
m_precipitation_anomaly->init(opt.filename, opt.period, opt.reference_time);
m_air_temp_anomaly->init(opt.filename, opt.periodic);
m_precipitation_anomaly->init(opt.filename, opt.periodic);
}

void Anomaly::update_impl(const Geometry &geometry, double t, double dt) {
Expand Down
5 changes: 2 additions & 3 deletions src/coupler/atmosphere/ElevationChange.cc
Expand Up @@ -52,7 +52,6 @@ ElevationChange::ElevationChange(IceGrid::ConstPtr grid, std::shared_ptr<Atmosph

unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -62,7 +61,7 @@ ElevationChange::ElevationChange(IceGrid::ConstPtr grid, std::shared_ptr<Atmosph
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);
m_reference_surface->set_attrs("climate_forcing", "ice surface elevation",
"m", "m", "surface_altitude", 0);
Expand Down Expand Up @@ -100,7 +99,7 @@ void ElevationChange::init_impl(const Geometry &geometry) {

ForcingOptions opt(*m_grid->ctx(), "atmosphere.elevation_change");

m_reference_surface->init(opt.filename, opt.period, opt.reference_time);
m_reference_surface->init(opt.filename, opt.periodic);
}

void ElevationChange::update_impl(const Geometry &geometry, double t, double dt) {
Expand Down
5 changes: 2 additions & 3 deletions src/coupler/atmosphere/Frac_P.cc
Expand Up @@ -53,15 +53,14 @@ Frac_P::Frac_P(IceGrid::ConstPtr grid, std::shared_ptr<AtmosphereModel> in)
} else {
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

m_2d_scaling = IceModelVec2T::ForcingField(m_grid,
input,
variable_name,
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);

m_2d_scaling->set_attrs("climate_forcing",
long_name, units, units, "", 0);
Expand All @@ -81,7 +80,7 @@ void Frac_P::init_impl(const Geometry &geometry) {

if (m_2d_scaling) {
ForcingOptions opt(*m_grid->ctx(), "atmosphere.frac_P");
m_2d_scaling->init(opt.filename, opt.period, opt.reference_time);
m_2d_scaling->init(opt.filename, opt.periodic);
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/coupler/atmosphere/GivenClimate.cc
Expand Up @@ -33,7 +33,6 @@ Given::Given(IceGrid::ConstPtr g)
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -43,7 +42,7 @@ Given::Given(IceGrid::ConstPtr g)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);

m_precipitation = IceModelVec2T::ForcingField(m_grid,
Expand All @@ -52,7 +51,7 @@ Given::Given(IceGrid::ConstPtr g)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);
}

{
Expand All @@ -77,8 +76,8 @@ void Given::init_impl(const Geometry &geometry) {

ForcingOptions opt(*m_grid->ctx(), "atmosphere.given");

m_air_temp->init(opt.filename, opt.period, opt.reference_time);
m_precipitation->init(opt.filename, opt.period, opt.reference_time);
m_air_temp->init(opt.filename, opt.periodic);
m_precipitation->init(opt.filename, opt.periodic);

// read time-independent data right away:
if (m_air_temp->n_records() == 1 && m_precipitation->n_records() == 1) {
Expand Down
9 changes: 4 additions & 5 deletions src/coupler/frontalmelt/DischargeGiven.cc
Expand Up @@ -66,7 +66,6 @@ void DischargeGiven::init_impl(const Geometry &geometry) {
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -76,28 +75,28 @@ void DischargeGiven::init_impl(const Geometry &geometry) {
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);

m_subglacial_discharge = IceModelVec2T::ForcingField(m_grid,
file,
"subglacial_discharge",
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);
}

m_theta_ocean->set_attrs("climate_forcing",
"potential temperature of the adjacent ocean",
"Celsius", "Celsius", "", 0);

m_theta_ocean->init(opt.filename, opt.period, opt.reference_time);
m_theta_ocean->init(opt.filename, opt.periodic);

m_subglacial_discharge->set_attrs("climate_forcing",
"subglacial discharge",
"kg m-2 s-1", "kg m-2 year-1", "", 0);

m_subglacial_discharge->init(opt.filename, opt.period, opt.reference_time);
m_subglacial_discharge->init(opt.filename, opt.periodic);
}

/*!
Expand Down
5 changes: 2 additions & 3 deletions src/coupler/frontalmelt/DischargeRouting.cc
Expand Up @@ -58,7 +58,6 @@ void DischargeRouting::init_impl(const Geometry &geometry) {
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -68,15 +67,15 @@ void DischargeRouting::init_impl(const Geometry &geometry) {
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);
}

m_theta_ocean->set_attrs("climate_forcing",
"potential temperature of the adjacent ocean",
"Celsius", "Celsius", "", 0);

m_theta_ocean->init(opt.filename, opt.period, opt.reference_time);
m_theta_ocean->init(opt.filename, opt.periodic);
}

/*!
Expand Down
5 changes: 2 additions & 3 deletions src/coupler/frontalmelt/Given.cc
Expand Up @@ -51,7 +51,6 @@ void Given::init_impl(const Geometry &geometry) {
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -61,13 +60,13 @@ void Given::init_impl(const Geometry &geometry) {
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);
}

m_frontal_melt_rate->set_attrs("climate_forcing", "frontal melt rate",
"m s-1", "m year-1", "", 0);

m_frontal_melt_rate->init(opt.filename, opt.period, opt.reference_time);
m_frontal_melt_rate->init(opt.filename, opt.periodic);
}

void Given::update_impl(const FrontalMeltInputs &inputs, double t, double dt) {
Expand Down
5 changes: 2 additions & 3 deletions src/coupler/ocean/Anomaly.cc
Expand Up @@ -32,7 +32,6 @@ Anomaly::Anomaly(IceGrid::ConstPtr g, std::shared_ptr<OceanModel> in)
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -42,7 +41,7 @@ Anomaly::Anomaly(IceGrid::ConstPtr g, std::shared_ptr<OceanModel> in)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);
}

m_shelf_base_mass_flux_anomaly->set_attrs("climate_forcing",
Expand Down Expand Up @@ -72,7 +71,7 @@ void Anomaly::init_impl(const Geometry &geometry) {
m_log->message(2,
" reading anomalies from %s ...\n", opt.filename.c_str());

m_shelf_base_mass_flux_anomaly->init(opt.filename, opt.period, opt.reference_time);
m_shelf_base_mass_flux_anomaly->init(opt.filename, opt.periodic);
}

void Anomaly::update_impl(const Geometry &geometry, double t, double dt) {
Expand Down
9 changes: 4 additions & 5 deletions src/coupler/ocean/GivenClimate.cc
Expand Up @@ -37,7 +37,6 @@ Given::Given(IceGrid::ConstPtr g)
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -47,7 +46,7 @@ Given::Given(IceGrid::ConstPtr g)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);

m_shelfbmassflux = IceModelVec2T::ForcingField(m_grid,
Expand All @@ -56,7 +55,7 @@ Given::Given(IceGrid::ConstPtr g)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic);
opt.periodic);
}

m_shelfbtemp->set_attrs("climate_forcing",
Expand All @@ -79,8 +78,8 @@ void Given::init_impl(const Geometry &geometry) {

ForcingOptions opt(*m_grid->ctx(), "ocean.given");

m_shelfbtemp->init(opt.filename, opt.period, opt.reference_time);
m_shelfbmassflux->init(opt.filename, opt.period, opt.reference_time);
m_shelfbtemp->init(opt.filename, opt.periodic);
m_shelfbmassflux->init(opt.filename, opt.periodic);

// read time-independent data right away:
if (m_shelfbtemp->n_records() == 1 && m_shelfbmassflux->n_records() == 1) {
Expand Down
9 changes: 4 additions & 5 deletions src/coupler/ocean/GivenTH.cc
Expand Up @@ -65,7 +65,6 @@ GivenTH::GivenTH(IceGrid::ConstPtr g)
{
unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -75,7 +74,7 @@ GivenTH::GivenTH(IceGrid::ConstPtr g)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);

m_salinity_ocean = IceModelVec2T::ForcingField(m_grid,
Expand All @@ -84,7 +83,7 @@ GivenTH::GivenTH(IceGrid::ConstPtr g)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);
}

Expand All @@ -110,7 +109,7 @@ void GivenTH::init_impl(const Geometry &geometry) {
ForcingOptions opt(*m_grid->ctx(), "ocean.th");

// potential temperature is required
m_theta_ocean->init(opt.filename, opt.period, opt.reference_time);
m_theta_ocean->init(opt.filename, opt.periodic);

// read ocean salinity from a file if present, otherwise use a constant
{
Expand All @@ -119,7 +118,7 @@ void GivenTH::init_impl(const Geometry &geometry) {
auto variable_name = m_salinity_ocean->metadata().get_name();

if (input.find_variable(variable_name)) {
m_salinity_ocean->init(opt.filename, opt.period, opt.reference_time);
m_salinity_ocean->init(opt.filename, opt.periodic);
} else {
double salinity = m_config->get_number("constants.sea_water.salinity", "g / kg");

Expand Down
9 changes: 4 additions & 5 deletions src/coupler/ocean/Pico.cc
Expand Up @@ -67,7 +67,6 @@ Pico::Pico(IceGrid::ConstPtr grid)
{
auto buffer_size = static_cast<int>(m_config->get_number("input.forcing.buffer_size"));
auto evaluations_per_year = static_cast<int>(m_config->get_number("input.forcing.evaluations_per_year"));
bool periodic = opt.period > 0;

File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);

Expand All @@ -77,7 +76,7 @@ Pico::Pico(IceGrid::ConstPtr grid)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);

m_salinity_ocean = IceModelVec2T::ForcingField(m_grid,
Expand All @@ -86,7 +85,7 @@ Pico::Pico(IceGrid::ConstPtr grid)
"", // no standard name
buffer_size,
evaluations_per_year,
periodic,
opt.periodic,
LINEAR);
}

Expand Down Expand Up @@ -142,8 +141,8 @@ void Pico::init_impl(const Geometry &geometry) {

ForcingOptions opt(*m_grid->ctx(), "ocean.pico");

m_theta_ocean->init(opt.filename, opt.period, opt.reference_time);
m_salinity_ocean->init(opt.filename, opt.period, opt.reference_time);
m_theta_ocean->init(opt.filename, opt.periodic);
m_salinity_ocean->init(opt.filename, opt.periodic);

// This initializes the basin_mask
m_geometry.init(geometry.cell_type);
Expand Down

0 comments on commit 92e79e9

Please sign in to comment.