Skip to content

Commit

Permalink
Merge branch 'jonbob/mpaso/support-salinity-restoring' into next (PR #…
Browse files Browse the repository at this point in the history
…1419)

This PR adds salinity restoring to C- and G-cases, when the appropriate data
file is available, through namelist and streams modifications. It adds a new
ocean bld variable, ocn_forcing, that has three valid options: active_atm;
core_forced; and core_forced_restoring. For grids with a valid monthly
salinity-restoring file (currently oEC60to30v3 and oRRS18to6v3), modifications
are made to mpas-o_in, streams.ocean, and mpas-o.input_data_list files. For
grids which do not yet have the required file, a warning is issued during the
case setup and the namelist/streams/input_data changes are not applied. This PR
also turns on the diurnal cycle for all C- and G-cases, regardless of the
availability of salinity-restoring files.

Note: because this codebase fails exact restart tests, it is off by default,
      even for situations in which it is fully supported. It will be made
      active by default once it does restart correctly (to be tracked by a
      separate issue).

Scripts tested with SMS.T62_oEC60to30v3.GMPAS-IAF.edison_intel and SMS.T62_oQU240.GMPAS-IAF.edison_intel.

Salinity-restoring namelist parameters tested for 250+ years with 20170320.beta0.GMPAS-IAF.T62_oECv3.anvil.

[NML]
[BFB]
  • Loading branch information
jonbob committed May 11, 2017
2 parents 5e90b1b + 85a01ab commit 7fefbd6
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,7 @@
steps, which is undesirable unless we truly want linear interpolation
between multiple input values -->
<value stream="topo.observed">lower</value>
<value stream="CORE2_IAF.GISS.SWDN">coszen</value>
</values>
</entry>

Expand Down
2 changes: 1 addition & 1 deletion components/mpas-cice/bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ my %opts = ( help => 0,
preview => 0,
caseroot => undef,
casebuild => undef,
cimeroot => undef,
cimeroot => undef,
inst_string => undef,
ice_grid => undef,
date_stamp => undef,
Expand Down
27 changes: 20 additions & 7 deletions components/mpas-o/bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ OPTIONS
-casebuild CASEBUILD directory variable
-cimeroot CIMEROOT directory variable
-ocn_grid OCN_GRID variable
-ocn_forcing variable for defining if the ocn model is forced with an active atm
or using CORE forcing.
Options are: active_atm, core_forced, core_forced_restoring
-date_stamp date_stamp variable
-cfg_grid Directory containing MPAS-O configuration scripts.
If not defined, location is set as \$ProgDir or \$cwd
Expand Down Expand Up @@ -87,10 +90,11 @@ my %opts = ( help => 0,
preview => 0,
caseroot => undef,
casebuild => undef,
cimeroot => undef,
cimeroot => undef,
inst_string => undef,
ocn_grid => undef,
date_stamp => undef,
ocn_forcing => undef,
date_stamp => undef,
cfg_dir => $cfgdir,
);

Expand All @@ -104,6 +108,7 @@ GetOptions(
"cimeroot=s" => \$opts{'cimeroot'},
"inst_string=s" => \$opts{'inst_string'},
"ocn_grid=s" => \$opts{'ocn_grid'},
"ocn_forcing=s" => \$opts{'ocn_forcing'},
"date_stamp=s" => \$opts{'date_stamp'},
"cfg_dir=s" => \$opts{'cfg_dir'},
"preview" => \$opts{'preview'},
Expand Down Expand Up @@ -132,9 +137,10 @@ if ($print>=2) { print "Setting MPAS-O configuration script directory to $cfgdir

my $CASEROOT = $opts{'caseroot'};
my $CASEBUILD = $opts{'casebuild'};
my $CIMEROOT = $opts{'cimeroot'};
my $CIMEROOT = $opts{'cimeroot'};
my $inst_string = $opts{'inst_string'};
my $OCN_GRID = $opts{'ocn_grid'};
my $OCN_FORCING = $opts{'ocn_forcing'};
my $date_stamp = $opts{'date_stamp'};
$cfgdir = $opts{'cfg_dir'};

Expand Down Expand Up @@ -1292,14 +1298,21 @@ add_default($nl, 'config_isomip_plus_effective_density');

add_default($nl, 'config_use_activeTracers');
add_default($nl, 'config_use_activeTracers_surface_bulk_forcing');
add_default($nl, 'config_use_activeTracers_surface_restoring');
if ($OCN_FORCING eq 'core_forced_restoring') {
add_default($nl, 'config_use_activeTracers_surface_restoring', 'val'=>".false.");
add_default($nl, 'config_use_surface_salinity_monthly_restoring', 'val'=>".false.");
add_default($nl, 'config_salinity_restoring_constant_piston_velocity', 'val'=>"1.585e-6");
add_default($nl, 'config_salinity_restoring_max_difference', 'val'=>"100.");
} else {
add_default($nl, 'config_use_activeTracers_surface_restoring');
add_default($nl, 'config_use_surface_salinity_monthly_restoring');
add_default($nl, 'config_salinity_restoring_constant_piston_velocity');
add_default($nl, 'config_salinity_restoring_max_difference');
}
add_default($nl, 'config_use_activeTracers_interior_restoring');
add_default($nl, 'config_use_activeTracers_exponential_decay');
add_default($nl, 'config_use_activeTracers_idealAge_forcing');
add_default($nl, 'config_use_activeTracers_ttd_forcing');
add_default($nl, 'config_use_surface_salinity_monthly_restoring');
add_default($nl, 'config_salinity_restoring_constant_piston_velocity');
add_default($nl, 'config_salinity_restoring_max_difference');

###############################################
# Namelist group: tracer_forcing_debugTracers #
Expand Down
48 changes: 41 additions & 7 deletions components/mpas-o/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ if ($#ARGV == -1) {
my ($CASEROOT) = @ARGV;
chdir "${CASEROOT}";

my $CIMEROOT = `./xmlquery CIMEROOT -value`;
my $CIMEROOT = `./xmlquery CIMEROOT -value`;
my $CASEROOT = `./xmlquery CASEROOT -value`;
my $CASEBUILD = `./xmlquery CASEBUILD -value`;
my $SRCROOT = `./xmlquery SRCROOT -value`;
my $OBJROOT = `./xmlquery OBJROOT -value`;
my $COMP_INTERFACE = `./xmlquery COMP_INTERFACE -value`;
my $DIN_LOC_ROOT = `./xmlquery DIN_LOC_ROOT -value`;
my $OBJROOT = `./xmlquery OBJROOT -value`;
my $COMP_INTERFACE = `./xmlquery COMP_INTERFACE -value`;
my $DIN_LOC_ROOT = `./xmlquery DIN_LOC_ROOT -value`;
my $OCN_GRID = `./xmlquery OCN_GRID -value`;
my $OCN_MASK = `./xmlquery MASK_GRID -value`;
my $OCN_MASK = `./xmlquery MASK_GRID -value`;
my $OCN_FORCING = `./xmlquery MPASO_FORCING -value`;
my $NTASKS_OCN = `./xmlquery NTASKS_OCN -value`;
#my $NINST_OCN = `./xmlquery NINST_OCN -value`;
my $NINST_OCN = 1; # Change if you want multiple instances... though this isn't coded yet.
my $RUNDIR = `./xmlquery RUNDIR -value`;
my $STREAM_NAME = 'streams.ocean';
my $RUNDIR = `./xmlquery RUNDIR -value`;
my $STREAM_NAME = 'streams.ocean';

my @dirs = ("$CIMEROOT/utils/perl5lib");
unshift @INC, @dirs;
Expand All @@ -42,6 +43,7 @@ my $grid_prefix = '';
my $decomp_prefix = '';
my $ic_date = '';
my $ic_prefix = '';
my $restoring_file = '';

if ( $OCN_GRID eq 'oEC60to30' ) {
$grid_date .= '151031';
Expand All @@ -61,6 +63,7 @@ if ( $OCN_GRID eq 'oEC60to30' ) {
$ic_date .= '161222';
$ic_prefix .= 'oEC60to30v3';
$decomp_prefix .= 'mpas-o.graph.info.';
$restoring_file .= 'sss.monthlyClimatology.PHC2_salx_040803.oEC60to30v3.nc';
} elsif ( $OCN_GRID eq 'oEC60to30v3_ICG' ) {
$grid_date .= '161222';
$grid_prefix .= 'oEC60to30v3';
Expand Down Expand Up @@ -127,6 +130,7 @@ if ( $OCN_GRID eq 'oEC60to30' ) {
$ic_date .= '170111';
$ic_prefix .= 'oRRS18to6v3';
$decomp_prefix .= 'mpas-o.graph.info.';
$restoring_file .= 'sss.monthlyClimatology.PHC2_salx_040803.oRRS18to6v3.nc';
} elsif ( $OCN_GRID eq 'oRRS18to6v3_ICG' ) {
$grid_date .= '170111';
$grid_prefix .= 'oRRS18to6v3';
Expand All @@ -143,13 +147,28 @@ if ( $OCN_GRID eq 'oEC60to30' ) {

chdir "$CASEBUILD/mpas-oconf";

#--------------------------------------------------------------------
# Set OCN_FORCING = core_forced_restoring if restoring file is available
#--------------------------------------------------------------------
if ($OCN_FORCING eq 'core_forced') {
if ($restoring_file ne '') {
$OCN_FORCING = 'core_forced_restoring';
} else {
print "WARNING: Should be running with salinity restoring on!\n";
print " But no file available for this grid.\n";
}
}

#--------------------------------------------------------------------
# Generate input data file
#--------------------------------------------------------------------

open(my $input_list, "+>", "$CASEBUILD/mpas-o.input_data_list");
print $input_list "mesh = $DIN_LOC_ROOT/ocn/mpas-o/$OCN_MASK/$grid_prefix.$grid_date.nc\n";
print $input_list "ic = $DIN_LOC_ROOT/ocn/mpas-o/$OCN_MASK/$ic_prefix.$ic_date.nc\n";
if ( $OCN_FORCING eq 'core_forced_restoring' ) {
print $input_list "sss = $DIN_LOC_ROOT/ocn/mpas-o/$OCN_MASK/$restoring_file\n";
}
#print $input_list "full_graph = $DIN_LOC_ROOT/ocn/mpas-o/$OCN_MASK/$decomp_prefix$grid_date\n";
print $input_list "graph$NTASKS_OCN = $DIN_LOC_ROOT/ocn/mpas-o/$OCN_MASK/$decomp_prefix$grid_date.part.$NTASKS_OCN\n";
close($input_list);
Expand Down Expand Up @@ -208,6 +227,7 @@ while ($inst_counter <= $NINST_OCN) {
$sysmod .= " -inst_string '$inst_string'";
$sysmod .= " -date_stamp '$grid_date'";
$sysmod .= " -ocn_grid '$OCN_MASK'";
$sysmod .= " -ocn_forcing '$OCN_FORCING'";
# pass in OCN_MASK for now as a short-cut for the grid
# at some point, we may want to pass both -- but for now this is simpler

Expand Down Expand Up @@ -376,6 +396,20 @@ if ( -e "$CASEROOT/SourceMods/src.mpaso/$STREAM_NAME" ) {
print $stream_file 'the analysis data.' . "\n";
print $stream_file '-->' . "\n";
print $stream_file '' . "\n";
if ($OCN_FORCING eq 'core_forced_restoring') {
print $stream_file '<stream name="surface_salinity_monthly_data"' . "\n";
print $stream_file ' type="input"' . "\n";
print $stream_file " filename_template=" . '"'
. "$DIN_LOC_ROOT/ocn/mpas-o/$OCN_MASK/$restoring_file"
. '"' . "\n";
print $stream_file ' input_interval="none"' . "\n";
print $stream_file ' packages="activeTracersBulkRestoringPKG">' . "\n";
print $stream_file '' . "\n";
print $stream_file ' <var name="xtime"/>' . "\n";
print $stream_file ' <var name="surfaceSalinityMonthlyClimatologyValue"/>' . "\n";
print $stream_file '</stream>' . "\n";
print $stream_file '' . "\n";
}
print $stream_file '<stream name="globalStatsOutput"' . "\n";
print $stream_file ' type="output"' . "\n";
print $stream_file ' filename_template="mpaso.hist.am.globalStats.$Y-$M-$D.nc"' . "\n";
Expand Down
15 changes: 14 additions & 1 deletion components/mpas-o/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@
<desc>Name of ocean component</desc>
</entry>

<entry id="MPASO_FORCING">
<type>char</type>
<valid_values>active_atm,core_forced</valid_values>
<default_value>active_atm</default_value>
<values>
<value compset="MPASO_">active_atm</value>
<value compset="_MPASO%COREFORCED">core_forced</value>
</values>
<group>case_comp</group>
<file>env_case.xml</file>
<desc>Option to describe the MPASO surface forcing</desc>
</entry>

<description>
<desc compset="_MPASO">mpas ocean default:</desc>
</description>

<help>
=========================================
POP naming conventions
MPAS-O naming conventions
=========================================
</help>

Expand Down
8 changes: 4 additions & 4 deletions components/mpas-o/cime_config/config_compsets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@

<compset>
<alias>CMPASO-NYF</alias>
<lname>2000_DATM%NYF_SLND_DICE%SSMI_MPASO_DROF%NYF_SGLC_SWAV</lname>
<lname>2000_DATM%NYF_SLND_DICE%SSMI_MPASO%COREFORCED_DROF%NYF_SGLC_SWAV</lname>
<support_level>"Experimental, under development"</support_level>
</compset>

<compset>
<alias>CMPASO-IAF</alias>
<lname>2000_DATM%IAF_SLND_DICE%SIAF_MPASO_DROF%IAF_SGLC_SWAV</lname>
<lname>2000_DATM%IAF_SLND_DICE%SIAF_MPASO%COREFORCED_DROF%IAF_SGLC_SWAV</lname>
<support_level>Experimental, under development</support_level>
</compset>

<compset>
<alias>GMPAS-NYF</alias>
<lname>2000_DATM%NYF_SLND_MPASCICE_MPASO_DROF%NYF_SGLC_SWAV</lname>
<lname>2000_DATM%NYF_SLND_MPASCICE_MPASO%COREFORCED_DROF%NYF_SGLC_SWAV</lname>
</compset>

<compset>
<alias>GMPAS-IAF</alias>
<lname>2000_DATM%IAF_SLND_MPASCICE_MPASO_DROF%IAF_SGLC_SWAV</lname>
<lname>2000_DATM%IAF_SLND_MPASCICE_MPASO%COREFORCED_DROF%IAF_SGLC_SWAV</lname>
</compset>

</compsets>
42 changes: 42 additions & 0 deletions components/mpas-o/driver/ocn_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module ocn_comp_mct
use ocn_frazil_forcing
use ocn_surface_land_ice_fluxes
use ocn_diagnostics
use ocn_tracer_surface_restoring

!
! !PUBLIC MEMBER FUNCTIONS:
Expand Down Expand Up @@ -195,6 +196,9 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )!{{{
logical, pointer :: tempLogicalConfig
character(len=StrKIND), pointer :: tempCharConfig

logical, pointer :: config_use_activeTracers_surface_restoring
logical, pointer :: config_use_surface_salinity_monthly_restoring

real (kind=RKIND) :: dt
type (MPAS_timeInterval_type) :: timeStep

Expand Down Expand Up @@ -731,6 +735,17 @@ end subroutine xml_stream_get_attributes
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
call mpas_log_write( 'Initial time '//trim(timeStamp))

! read initial data required for monthly surface salinity restoring
call mpas_pool_get_config(domain % configs, 'config_use_activeTracers_surface_restoring', &
config_use_activeTracers_surface_restoring)
call mpas_pool_get_config(domain % configs, 'config_use_surface_salinity_monthly_restoring', &
config_use_surface_salinity_monthly_restoring)
if (config_use_activeTracers_surface_restoring .and. config_use_surface_salinity_monthly_restoring) then
call mpas_timer_start('io_monthly_surface_salinity',.false.)
call ocn_get_surfaceSalinityData(domain_ptr % streamManager, domain, domain % clock, .true.)
call mpas_timer_stop('io_monthly_surface_salinity')
endif

itimestep = 0

! Reset all output alarms, to prevent intial time step from writing any output, unless it's ringing.
Expand Down Expand Up @@ -799,7 +814,10 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
integer :: iam, ierr, streamDirection
logical :: streamActive, debugOn
logical, pointer :: config_write_output_on_startup
logical, pointer :: config_use_activeTracers_surface_restoring
logical, pointer :: config_use_surface_salinity_monthly_restoring
character (len=StrKIND), pointer :: config_restart_timestamp_name
character (len=StrKIND), pointer :: config_forcing_restart_file
! Added for coupling interval initialization
integer, pointer :: index_avgZonalSSHGradient, index_avgMeridionalSSHGradient
Expand All @@ -822,6 +840,7 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
if (debugOn) call mpas_log_write("=== Beginning ocn_run_mct ===")
call mpas_pool_get_config(domain_ptr % configs, 'config_restart_timestamp_name', config_restart_timestamp_name)
call mpas_pool_get_config(domain_ptr % configs, 'config_forcing_restart_file', config_forcing_restart_file)
! Setup log information.
call shr_file_getLogUnit (shrlogunit)
Expand Down Expand Up @@ -944,8 +963,24 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
call mpas_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_OUTPUT, ierr=ierr)
if (iam==0.and.debugOn) then
call mpas_log_write(' Finished writing output streams')
call mpas_log_write(' Reading forcing streams')
endif

! read next time level data required for monthly surface salinity restoring
call mpas_pool_get_config(domain % configs, 'config_use_activeTracers_surface_restoring', &
config_use_activeTracers_surface_restoring)
call mpas_pool_get_config(domain % configs, 'config_use_surface_salinity_monthly_restoring', &
config_use_surface_salinity_monthly_restoring)
if (config_use_activeTracers_surface_restoring .and. config_use_surface_salinity_monthly_restoring) then
call mpas_timer_start('io_monthly_surface_salinity',.false.)
call ocn_get_surfaceSalinityData(domain % streamManager, domain, domain % clock, .false.)
call mpas_timer_stop('io_monthly_surface_salinity')
endif
if (iam==0.and.debugOn) then
call mpas_log_write(' Finished reading forcing streams')
call mpas_log_write(' Validating ocean state')
endif

call ocn_validate_state(domain, timeLevel=1)
if (debugOn) call mpas_log_write(' Completed validating ocean state')
if (debugOn) call mpas_log_write('Completed timestep '//trim(timeStamp))
Expand Down Expand Up @@ -997,7 +1032,14 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
open(22, file=config_restart_timestamp_name, form='formatted', status='replace')
write(22, *) trim(timeStamp)
close(22)

open(22, file=config_forcing_restart_file, form='formatted', status='replace')
close(22)
end if

if (config_use_activeTracers_surface_restoring .and. config_use_surface_salinity_monthly_restoring) &
call ocn_salinity_restoring_forcing_write_restart(domain_ptr)

if (debugOn) call mpas_log_write('Finished writing restart streams')
end if

Expand Down

0 comments on commit 7fefbd6

Please sign in to comment.