Skip to content

Commit

Permalink
Merge branch 'sbrus89/ocn/improve-harmonic-analysis-options' (PR #4586)
Browse files Browse the repository at this point in the history
Modify harmonic analysis AM namelist options and output stream

The start and end dates for harmonic analysis period have been replaced
by a config_AM_harmonicAnalysis_start_delay and a
config_AM_harmonicAnalysis_duration option (with units of days). This
makes it easier to change the start/end date of the simulation without
having to change harmonic analysis AM options.

Stream output is now controlled by the AM compute routine. The HA output
stream is written following the least squares solve. The output_interval
in the streams file should be set for a long time interval (i.e. 1000
years) so it is not written by the AM driver routine. This means the
output_interval no longer needs to be changed when the simulation length
or harmonic analysis period changes.

[NML]
[BFB]
  • Loading branch information
jonbob committed Nov 3, 2021
2 parents 3a87fa1 + 2105c90 commit 417b03f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions components/mpas-ocean/bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,8 @@ add_default($nl, 'config_AM_sedimentTransport_use_lat_lon_coords');

add_default($nl, 'config_AM_harmonicAnalysis_enable');
add_default($nl, 'config_AM_harmonicAnalysis_compute_interval');
add_default($nl, 'config_AM_harmonicAnalysis_start');
add_default($nl, 'config_AM_harmonicAnalysis_end');
add_default($nl, 'config_AM_harmonicAnalysis_start_delay');
add_default($nl, 'config_AM_harmonicAnalysis_duration');
add_default($nl, 'config_AM_harmonicAnalysis_output_stream');
add_default($nl, 'config_AM_harmonicAnalysis_restart_stream');
add_default($nl, 'config_AM_harmonicAnalysis_compute_on_startup');
Expand Down
4 changes: 2 additions & 2 deletions components/mpas-ocean/bld/build-namelist-section
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,8 @@ add_default($nl, 'config_AM_sedimentTransport_use_lat_lon_coords');

add_default($nl, 'config_AM_harmonicAnalysis_enable');
add_default($nl, 'config_AM_harmonicAnalysis_compute_interval');
add_default($nl, 'config_AM_harmonicAnalysis_start');
add_default($nl, 'config_AM_harmonicAnalysis_end');
add_default($nl, 'config_AM_harmonicAnalysis_start_delay');
add_default($nl, 'config_AM_harmonicAnalysis_duration');
add_default($nl, 'config_AM_harmonicAnalysis_output_stream');
add_default($nl, 'config_AM_harmonicAnalysis_restart_stream');
add_default($nl, 'config_AM_harmonicAnalysis_compute_on_startup');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,8 @@
<!-- AM_harmonicAnalysis -->
<config_AM_harmonicAnalysis_enable>.false.</config_AM_harmonicAnalysis_enable>
<config_AM_harmonicAnalysis_compute_interval>'output_interval'</config_AM_harmonicAnalysis_compute_interval>
<config_AM_harmonicAnalysis_start>'0001-01-01_00:00:00'</config_AM_harmonicAnalysis_start>
<config_AM_harmonicAnalysis_end>'0001-01-01_00:00:00'</config_AM_harmonicAnalysis_end>
<config_AM_harmonicAnalysis_start_delay>20</config_AM_harmonicAnalysis_start_delay>
<config_AM_harmonicAnalysis_duration>90</config_AM_harmonicAnalysis_duration>
<config_AM_harmonicAnalysis_output_stream>'harmonicAnalysisOutput'</config_AM_harmonicAnalysis_output_stream>
<config_AM_harmonicAnalysis_restart_stream>'harmonicAnalysisRestart'</config_AM_harmonicAnalysis_restart_stream>
<config_AM_harmonicAnalysis_compute_on_startup>.false.</config_AM_harmonicAnalysis_compute_on_startup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5843,19 +5843,19 @@ Valid values: Any valid time stamp, 'dt', or 'output_interval'
Default: Defined in namelist_defaults.xml
</entry>

<entry id="config_AM_harmonicAnalysis_start" type="char*1024"
<entry id="config_AM_harmonicAnalysis_start_delay" type="real"
category="AM_harmonicAnalysis" group="AM_harmonicAnalysis">
Timestamp determining when harmonic analysis begins
Number of days after start of simulation when harmonic analysis begins. This is referenced relative to the start of the original simulation, not the restart date.

Valid values: 'YYYY-MM-DD_HH:MM:SS'
Valid values: any positive real number
Default: Defined in namelist_defaults.xml
</entry>

<entry id="config_AM_harmonicAnalysis_end" type="char*1024"
<entry id="config_AM_harmonicAnalysis_duration" type="real"
category="AM_harmonicAnalysis" group="AM_harmonicAnalysis">
Timestamp determining when harmonic analysis ends
Length of harmonic analysis period. The analysis begins after config_AM_harmonicAnalysis_start_delay days and ends after config_AM_harmonicAnalysis_start_delay + config_AM_harmonicAnalysis_duration days relative to the start of the original simulation, not the restart date.

Valid values: 'YYYY-MM-DD_HH:MM:SS'
Valid values: any positive real number
Default: Defined in namelist_defaults.xml
</entry>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
description="Timestamp determining how often harmonic analysis computation should be performed."
possible_values="Any valid time stamp, 'dt', or 'output_interval'"
/>
<nml_option name="config_AM_harmonicAnalysis_start" type="character" default_value="0001-01-01_00:00:00" units="unitless"
description="Timestamp determining when harmonic analysis begins"
possible_values="'YYYY-MM-DD_HH:MM:SS'"
<nml_option name="config_AM_harmonicAnalysis_start_delay" type="real" default_value="20" units="days"
description="Number of days after start of simulation when harmonic analysis begins. This is referenced relative to the start of the original simulation, not the restart date."
possible_values="any positive real number"
/>
<nml_option name="config_AM_harmonicAnalysis_end" type="character" default_value="0001-01-01_00:00:00" units="unitless"
description="Timestamp determining when harmonic analysis ends"
possible_values="'YYYY-MM-DD_HH:MM:SS'"
<nml_option name="config_AM_harmonicAnalysis_duration" type="real" default_value="90" units="days"
description="Length of harmonic analysis period. The analysis begins after config_AM_harmonicAnalysis_start_delay days and ends after config_AM_harmonicAnalysis_start_delay + config_AM_harmonicAnalysis_duration days relative to the start of the original simulation, not the restart date."
possible_values="any positive real number"
/>
<nml_option name="config_AM_harmonicAnalysis_output_stream" type="character" default_value="harmonicAnalysisOutput" units="unitless"
description="Name of the stream that the harmonicAnalysis analysis member should be tied to."
Expand Down Expand Up @@ -160,9 +160,9 @@
<stream name="harmonicAnalysisOutput" type="output"
mode="forward;analysis"
precision="single"
filename_template="analysis_members/harmonicAnalysis.$Y-$M-$D.nc"
filename_template="analysis_members/harmonicAnalysis.nc"
filename_interval="01-00-00_00:00:00"
output_interval="00-00-01_00:00:00"
output_interval="10000-00-00_00:00:00"
reference_time="0001-01-01_00:00:00"
packages="harmonicAnalysisAMPKG"
clobber_mode="truncate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ subroutine ocn_compute_harmonic_analysis(domain, timeLevel, err)!{{{
type (mpas_pool_type), pointer :: meshPool
type (mpas_pool_type), pointer :: scratchPool
type (mpas_pool_type), pointer :: harmonicAnalysisAMPool
type (mpas_time_type) :: current_time
type (mpas_time_type) :: harmonicAnalysisStart
type (mpas_time_type) :: harmonicAnalysisEnd

integer, pointer :: nCellsSolve
integer, pointer :: nAnalysisConstituents
Expand Down Expand Up @@ -321,7 +318,9 @@ subroutine ocn_compute_harmonic_analysis(domain, timeLevel, err)!{{{

integer :: iCell
integer :: iCon
integer :: err_tmp
real (kind=RKIND) :: time
real (kind=RKIND) :: harmonicAnalysisEnd

err = 0

Expand All @@ -346,18 +345,16 @@ subroutine ocn_compute_harmonic_analysis(domain, timeLevel, err)!{{{

! get relevant time information
time = daysSinceStartOfSim*86400_RKIND
current_time = mpas_get_clock_time(domain % clock, MPAS_NOW, err)
call mpas_set_time(harmonicAnalysisStart, dateTimeString=config_AM_harmonicAnalysis_start)
call mpas_set_time(harmonicAnalysisEnd, dateTimeString=config_AM_harmonicAnalysis_end)
harmonicAnalysisEnd = config_AM_harmonicAnalysis_start_delay + config_AM_harmonicAnalysis_duration

! exit if harmonic analysis period has not begun yet
if (current_time .lt. harmonicAnalysisStart) then
if (daysSinceStartOfSim .lt. config_AM_harmonicAnalysis_start_delay) then
call mpas_log_write('harmonicAnalysisAM exit: before HA period')
return
end if

! update if within harmonic analysis period
if (current_time .le. harmonicAnalysisEnd) then
if (daysSinceStartOfSim .le. harmonicAnalysisEnd) then
CALL update_least_squares_LHS_matrix(nAnalysisConstituents, &
time, &
analysisConstituentFrequency, &
Expand All @@ -373,7 +370,7 @@ subroutine ocn_compute_harmonic_analysis(domain, timeLevel, err)!{{{
end if

! solve harmonic analysis least squares system if harmonic analysis period is over
if ((current_time .ge. harmonicAnalysisEnd) .and. (leastSquaresSolution == 0)) then
if ((daysSinceStartOfSim .ge. harmonicAnalysisEnd) .and. (leastSquaresSolution == 0)) then
call harmonic_analysis_solve(nCellsSolve, &
nAnalysisConstituents, &
leastSquaresLHSMatrix, &
Expand Down Expand Up @@ -435,11 +432,13 @@ subroutine ocn_compute_harmonic_analysis(domain, timeLevel, err)!{{{
endif
enddo

call mpas_stream_mgr_write(domain % streamManager, streamID=config_AM_harmonicAnalysis_output_stream, forceWriteNow=.true., ierr=err_tmp)

! increment to indicate the system has been solved
leastSquaresSolution = leastSquaresSolution + 1
call mpas_log_write('harmonicAnalysisAM solve')

else if ((current_time .ge. harmonicAnalysisEnd) .and. (leastSquaresSolution > 0)) then
else if ((daysSinceStartOfSim .ge. harmonicAnalysisEnd) .and. (leastSquaresSolution > 0)) then
call mpas_log_write('harmonicAnalysisAM exit: past HA period')
end if

Expand Down

0 comments on commit 417b03f

Please sign in to comment.