Skip to content

Commit

Permalink
removed smoother code and docs
Browse files Browse the repository at this point in the history
See NCAR#479 for discussion
&smoother_nml is still in a bunch of input.nmls
  • Loading branch information
hkershaw-brown committed May 25, 2023
1 parent 72e5740 commit 5ecb81c
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 1,265 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ References
assimilation_code/modules/observations/obs_kind_mod
assimilation_code/modules/observations/DEFAULT_obs_kind_mod
assimilation_code/modules/observations/obs_sequence_mod
assimilation_code/modules/assimilation/smoother_mod
assimilation_code/modules/assimilation/assim_readme
assimilation_code/modules/assimilation/assim_tools_mod
assimilation_code/modules/assimilation/cov_cutoff_mod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ module filter_mod
use mpi_utilities_mod, only : my_task_id, task_sync, broadcast_send, broadcast_recv, &
task_count

use smoother_mod, only : smoother_read_restart, advance_smoother, &
smoother_gen_copy_meta_data, smoother_write_restart, &
init_smoother, do_smoothing, smoother_mean_spread, &
smoother_assim, smoother_ss_diagnostics, &
smoother_end, set_smoother_trace

use random_seq_mod, only : random_seq_type, init_random_seq, random_gaussian

use state_vector_io_mod, only : state_vector_io_init, read_state, write_state, &
Expand Down Expand Up @@ -358,9 +352,8 @@ subroutine filter_main()
type(file_info_type) :: file_info_output
type(file_info_type) :: file_info_all

logical :: ds, all_gone, allow_missing
logical :: all_gone, allow_missing

! real(r8), allocatable :: temp_ens(:) ! for smoother
real(r8), allocatable :: prior_qc_copy(:)

call filter_initialize_modules_used() ! static_init_model called in here
Expand Down Expand Up @@ -392,8 +385,6 @@ subroutine filter_main()
write(msgstring, '(A,I5)') 'running with an ensemble size of ', ens_size
call error_handler(E_MSG,'filter_main:', msgstring, source)

! See if smoothing is turned on
ds = do_smoothing()

call set_missing_ok_status(allow_missing_clm)
allow_missing = get_missing_ok_status()
Expand Down Expand Up @@ -551,13 +542,6 @@ subroutine filter_main()
! Set a time type for initial time if namelist inputs are not negative
call filter_set_initial_time(init_time_days, init_time_seconds, time1, read_time_from_file)

! Moved this. Not doing anything with it, but when we do it should be before the read
! Read in or initialize smoother restarts as needed
if(ds) then
call init_smoother(state_ens_handle, POST_INF_COPY, POST_INF_SD_COPY)
call smoother_read_restart(state_ens_handle, ens_size, model_size, time1, init_time_days)
endif

call trace_message('Before reading in ensemble restart files')
call timestamp_message('Before reading in ensemble restart files')

Expand Down Expand Up @@ -613,11 +597,6 @@ subroutine filter_main()
prior_obs_spread_index, posterior_obs_spread_index, &
compute_posterior)

if(ds) call error_handler(E_ERR, 'filter', 'smoother broken by Helen')

!>@todo fudge
if(ds) call smoother_gen_copy_meta_data(num_output_state_members, output_inflation=.true.)

call timestamp_message('After initializing output files')
call trace_message('After initializing output files')

Expand Down Expand Up @@ -735,15 +714,6 @@ subroutine filter_main()

! if model state data not at required time, advance model
if (curr_ens_time /= next_ens_time) then
! Advance the lagged distribution, if needed.
! Must be done before the model runs and updates the data.
if(ds) then
call trace_message('Before advancing smoother')
call timestamp_message('Before advancing smoother')
call advance_smoother(state_ens_handle)
call timestamp_message('After advancing smoother')
call trace_message('After advancing smoother')
endif

! we are going to advance the model - make sure we're doing single file output
if (.not. has_cycling) then
Expand Down Expand Up @@ -928,24 +898,6 @@ subroutine filter_main()
call timestamp_message('After observation assimilation')
call trace_message('After observation assimilation')

! Do the update for the smoother lagged fields, too.
! Would be more efficient to do these all at once inside filter_assim
! in the future
if(ds) then
write(msgstring, '(A,I8,A)') 'Ready to reassimilate up to', size(keys), ' observations in the smoother'
call trace_message(msgstring, 'filter:', -1)

call trace_message('Before smoother assimilation')
call timestamp_message('Before smoother assimilation')
call smoother_assim(obs_fwd_op_ens_handle, seq, keys, ens_size, num_groups, &
obs_val_index, ENS_MEAN_COPY, ENS_SD_COPY, &
PRIOR_INF_COPY, PRIOR_INF_SD_COPY, OBS_KEY_COPY, OBS_GLOBAL_QC_COPY, &
OBS_MEAN_START, OBS_MEAN_END, OBS_VAR_START, &
OBS_VAR_END)
call timestamp_message('After smoother assimilation')
call trace_message('After smoother assimilation')
endif

! Already transformed, so compute mean and spread for state diag as needed
call compute_copy_mean_sd(state_ens_handle, 1, ens_size, ENS_MEAN_COPY, ENS_SD_COPY)

Expand Down Expand Up @@ -982,11 +934,6 @@ subroutine filter_main()
call write_state(state_ens_handle, file_info_postassim)
endif

!>@todo What to do here?
!call smoother_ss_diagnostics(model_size, num_output_state_members, &
! output_inflation, temp_ens, ENS_MEAN_COPY, ENS_SD_COPY, &
! POST_INF_COPY, POST_INF_SD_COPY)

call timestamp_message('After postassim state space output')
call trace_message('After postassim state space output')

Expand Down Expand Up @@ -1035,12 +982,6 @@ subroutine filter_main()
call timestamp_message('After computing posterior observation values')
call trace_message('After computing posterior observation values')

if(ds) then
call trace_message('Before computing smoother means/spread')
call smoother_mean_spread(ens_size, ENS_MEAN_COPY, ENS_SD_COPY)
call trace_message('After computing smoother means/spread')
endif

call trace_message('Before posterior obs space diagnostics')

! Write posterior observation space diagnostics
Expand Down Expand Up @@ -1104,11 +1045,6 @@ subroutine filter_main()
call write_state(state_ens_handle, file_info_analysis)
endif

!>@todo What to do here?
!call smoother_ss_diagnostics(model_size, num_output_state_members, &
! output_inflation, temp_ens, ENS_MEAN_COPY, ENS_SD_COPY, &
! POST_INF_COPY, POST_INF_SD_COPY)

call timestamp_message('After analysis state space output')
call trace_message('After analysis state space output')

Expand Down Expand Up @@ -1153,9 +1089,6 @@ subroutine filter_main()
if (.not. write_all_stages_at_end) &
call write_state(state_ens_handle, file_info_output)

!>@todo need to fix smoother
!if(ds) call smoother_write_restart(1, ens_size)

call timestamp_message('After state space output')
call trace_message('After state space output')

Expand Down Expand Up @@ -1215,12 +1148,6 @@ subroutine filter_main()
call destroy_obs_sequence(seq)
call trace_message('After ensemble and obs memory cleanup')

if(ds) then
call trace_message('Before smoother memory cleanup')
call smoother_end()
call trace_message('After smoother memory cleanup')
endif

call trace_message('Filter done')
call timestamp_message('Filter done')
if(my_task_id() == 0) then
Expand Down Expand Up @@ -1875,7 +1802,6 @@ subroutine set_trace(trace_execution, output_timestamps, silence)
timestamp_level = -1
endif

call set_smoother_trace(trace_level, timestamp_level)
call set_obs_model_trace(trace_level, timestamp_level)
call set_assim_tools_trace(trace_level, timestamp_level)

Expand Down
76 changes: 1 addition & 75 deletions assimilation_code/modules/assimilation/filter_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ module filter_mod
use mpi_utilities_mod, only : my_task_id, task_sync, broadcast_send, broadcast_recv, &
task_count

use smoother_mod, only : smoother_read_restart, advance_smoother, &
smoother_gen_copy_meta_data, smoother_write_restart, &
init_smoother, do_smoothing, smoother_mean_spread, &
smoother_assim, smoother_ss_diagnostics, &
smoother_end, set_smoother_trace

use random_seq_mod, only : random_seq_type, init_random_seq, random_gaussian

use state_vector_io_mod, only : state_vector_io_init, read_state, write_state, &
Expand Down Expand Up @@ -353,9 +347,8 @@ subroutine filter_main()
type(file_info_type) :: file_info_output
type(file_info_type) :: file_info_all

logical :: ds, all_gone, allow_missing
logical :: all_gone, allow_missing

! real(r8), allocatable :: temp_ens(:) ! for smoother
real(r8), allocatable :: prior_qc_copy(:)

call filter_initialize_modules_used() ! static_init_model called in here
Expand Down Expand Up @@ -387,9 +380,6 @@ subroutine filter_main()
write(msgstring, '(A,I5)') 'running with an ensemble size of ', ens_size
call error_handler(E_MSG,'filter_main:', msgstring, source)

! See if smoothing is turned on
ds = do_smoothing()

call set_missing_ok_status(allow_missing_clm)
allow_missing = get_missing_ok_status()

Expand Down Expand Up @@ -546,13 +536,6 @@ subroutine filter_main()
! Set a time type for initial time if namelist inputs are not negative
call filter_set_initial_time(init_time_days, init_time_seconds, time1, read_time_from_file)

! Moved this. Not doing anything with it, but when we do it should be before the read
! Read in or initialize smoother restarts as needed
if(ds) then
call init_smoother(state_ens_handle, POST_INF_COPY, POST_INF_SD_COPY)
call smoother_read_restart(state_ens_handle, ens_size, model_size, time1, init_time_days)
endif

call trace_message('Before reading in ensemble restart files')
call timestamp_message('Before reading in ensemble restart files')

Expand Down Expand Up @@ -608,11 +591,6 @@ subroutine filter_main()
prior_obs_spread_index, posterior_obs_spread_index, &
compute_posterior)

if(ds) call error_handler(E_ERR, 'filter', 'smoother broken by Helen')

!>@todo fudge
if(ds) call smoother_gen_copy_meta_data(num_output_state_members, output_inflation=.true.)

call timestamp_message('After initializing output files')
call trace_message('After initializing output files')

Expand Down Expand Up @@ -730,15 +708,6 @@ subroutine filter_main()

! if model state data not at required time, advance model
if (curr_ens_time /= next_ens_time) then
! Advance the lagged distribution, if needed.
! Must be done before the model runs and updates the data.
if(ds) then
call trace_message('Before advancing smoother')
call timestamp_message('Before advancing smoother')
call advance_smoother(state_ens_handle)
call timestamp_message('After advancing smoother')
call trace_message('After advancing smoother')
endif

! we are going to advance the model - make sure we're doing single file output
if (.not. has_cycling) then
Expand Down Expand Up @@ -923,24 +892,6 @@ subroutine filter_main()
call timestamp_message('After observation assimilation')
call trace_message('After observation assimilation')

! Do the update for the smoother lagged fields, too.
! Would be more efficient to do these all at once inside filter_assim
! in the future
if(ds) then
write(msgstring, '(A,I8,A)') 'Ready to reassimilate up to', size(keys), ' observations in the smoother'
call trace_message(msgstring, 'filter:', -1)

call trace_message('Before smoother assimilation')
call timestamp_message('Before smoother assimilation')
call smoother_assim(obs_fwd_op_ens_handle, seq, keys, ens_size, num_groups, &
obs_val_index, ENS_MEAN_COPY, ENS_SD_COPY, &
PRIOR_INF_COPY, PRIOR_INF_SD_COPY, OBS_KEY_COPY, OBS_GLOBAL_QC_COPY, &
OBS_MEAN_START, OBS_MEAN_END, OBS_VAR_START, &
OBS_VAR_END)
call timestamp_message('After smoother assimilation')
call trace_message('After smoother assimilation')
endif

! Already transformed, so compute mean and spread for state diag as needed
call compute_copy_mean_sd(state_ens_handle, 1, ens_size, ENS_MEAN_COPY, ENS_SD_COPY)

Expand Down Expand Up @@ -977,11 +928,6 @@ subroutine filter_main()
call write_state(state_ens_handle, file_info_postassim)
endif

!>@todo What to do here?
!call smoother_ss_diagnostics(model_size, num_output_state_members, &
! output_inflation, temp_ens, ENS_MEAN_COPY, ENS_SD_COPY, &
! POST_INF_COPY, POST_INF_SD_COPY)

call timestamp_message('After postassim state space output')
call trace_message('After postassim state space output')

Expand Down Expand Up @@ -1030,11 +976,6 @@ subroutine filter_main()
call timestamp_message('After computing posterior observation values')
call trace_message('After computing posterior observation values')

if(ds) then
call trace_message('Before computing smoother means/spread')
call smoother_mean_spread(ens_size, ENS_MEAN_COPY, ENS_SD_COPY)
call trace_message('After computing smoother means/spread')
endif

call trace_message('Before posterior obs space diagnostics')

Expand Down Expand Up @@ -1103,11 +1044,6 @@ subroutine filter_main()
call write_state(state_ens_handle, file_info_analysis)
endif

!>@todo What to do here?
!call smoother_ss_diagnostics(model_size, num_output_state_members, &
! output_inflation, temp_ens, ENS_MEAN_COPY, ENS_SD_COPY, &
! POST_INF_COPY, POST_INF_SD_COPY)

call timestamp_message('After analysis state space output')
call trace_message('After analysis state space output')

Expand Down Expand Up @@ -1152,9 +1088,6 @@ subroutine filter_main()
if (.not. write_all_stages_at_end) &
call write_state(state_ens_handle, file_info_output)

!>@todo need to fix smoother
!if(ds) call smoother_write_restart(1, ens_size)

call timestamp_message('After state space output')
call trace_message('After state space output')

Expand Down Expand Up @@ -1214,12 +1147,6 @@ subroutine filter_main()
call destroy_obs_sequence(seq)
call trace_message('After ensemble and obs memory cleanup')

if(ds) then
call trace_message('Before smoother memory cleanup')
call smoother_end()
call trace_message('After smoother memory cleanup')
endif

call trace_message('Filter done')
call timestamp_message('Filter done')
if(my_task_id() == 0) then
Expand Down Expand Up @@ -1910,7 +1837,6 @@ subroutine set_trace(trace_execution, output_timestamps, silence)
timestamp_level = -1
endif

call set_smoother_trace(trace_level, timestamp_level)
call set_obs_model_trace(trace_level, timestamp_level)
call set_assim_tools_trace(trace_level, timestamp_level)

Expand Down
1 change: 0 additions & 1 deletion assimilation_code/modules/assimilation/filter_mod.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ Modules used
ensemble_manager_mod
adaptive_inflate_mod
mpi_utilities_mod
smoother_mod
random_seq_mod
state_vector_io_mod
io_filenames_mod
Expand Down
Loading

0 comments on commit 5ecb81c

Please sign in to comment.