MODULE smoother_mod¶
Overview¶
assim_tools_mod:filter_assim()
for each lag.smoother_nml
section
of your input.nml
file and run filter
as before.&smoother_nml
num_lags = 10,
start_from_restart = .false.,
output_restart = .true.,
restart_in_file_name = "ics",
restart_out_file_name = "restart" /
preassim.nc
and analysis.nc
files, files of the form Lag_NNNNN_Diag.nc
will be
generated. Each of these has N fewer timesteps than the lag=0 run, starting at the same time but ending N timesteps
sooner. The obs_seq.final
file and the preassim.nc
and analysis.nc
files will be the same as the
non-lagged version; the new output will be in each of the Lag_NNNNN_Diag.nc
files.Example¶
true_state.nc
file and want to use the plot_total_err
matlab function to plot the error, you
must do the following steps to generate analogs of lagged true_state.nc
files to use as a comparison. (The logic
is not currently implemented in the matlab scripts to be able to compare netCDF files with unequal time coordinates.)ncks -d time,0,998 true_state.nc True_Lag01.nc
Note that the first time is at index 0, so the last timestep is index 999 in the full file, and 998 in the truncated file. Repeat this step for all N lags. Here are NCO commands to generate 10 truth files for num_lags = 10, 1000 time steps in true_state.nc:
ncks -d time,0,998 true_state.nc True_Lag01.nc ncks -d time,0,997 true_state.nc True_Lag02.nc ncks -d time,0,996 true_state.nc True_Lag03.nc ncks -d time,0,995 true_state.nc True_Lag04.nc ncks -d time,0,994 true_state.nc True_Lag05.nc ncks -d time,0,993 true_state.nc True_Lag06.nc ncks -d time,0,992 true_state.nc True_Lag07.nc ncks -d time,0,991 true_state.nc True_Lag08.nc ncks -d time,0,990 true_state.nc True_Lag09.nc ncks -d time,0,989 true_state.nc True_Lag10.nc
Here is an example matlab session which plots the lag=0 results and then odd numbered lags from 1 to 9. It uses the
plot_total_err
function from the $DART/matlab directory:
datadir = '.';
truth_file = fullfile(datadir,'true_state.nc');
diagn_file = fullfile(datadir,'preassim.nc');
plot_total_err
reply = input('original data. hit enter to continue ');
truth_file = fullfile(datadir,'True_Lag01.nc');
diagn_file = fullfile(datadir,'Lag_00001_Diag.nc');
plot_total_err
reply = input('Lag 01. hit enter to continue ');
truth_file = fullfile(datadir,'True_Lag03.nc');
diagn_file = fullfile(datadir,'Lag_00003_Diag.nc');
plot_total_err
reply = input('Lag 03. hit enter to continue ');
truth_file = fullfile(datadir,'True_Lag05.nc');
diagn_file = fullfile(datadir,'Lag_00005_Diag.nc');
plot_total_err
reply = input('Lag 05. hit enter to continue ');
truth_file = fullfile(datadir,'True_Lag07.nc');
diagn_file = fullfile(datadir,'Lag_00007_Diag.nc');
plot_total_err
reply = input('Lag 07. hit enter to continue ');
truth_file = fullfile(datadir,'True_Lag09.nc');
diagn_file = fullfile(datadir,'Lag_00009_Diag.nc');
plot_total_err
reply = input('Lag 09. hit enter to continue ');
Namelist¶
This namelist is read from the file input.nml
. Namelists start with an ampersand ‘&’ and terminate with a slash ‘/’.
Character strings that contain a ‘/’ must be enclosed in quotes to prevent them from prematurely terminating the
namelist.
&smoother_nml
num_lags = 0,
start_from_restart = .false.,
output_restart = .false.,
restart_in_file_name = 'ics',
restart_out_file_name = 'restart'
/
Item |
Type |
Description |
---|---|---|
num_lags |
integer |
Number of smoother lags; < 1 means no smoother. |
start_from_restart |
logical |
True if smoother states are to come from restart file(s). False if they are to be spun up from scratch. |
output_restart |
logical |
True if restart file(s) are to be written, else false. |
restart_in_file_name |
character(len=129) |
String used to construct the file name from which to read restart
data. |
restart_out_file_name |
character(len=129) |
String used to construct the file name to which to write restart
data. |
Other modules used¶
types_mod
mpi_utilities_mod
utilities_mod
ensemble_manager_mod
time_manager_mod
assim_model_mod
assim_tools_mod
obs_sequence_mod
adaptive_inflate_mod
Public interfaces¶
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 |
|
filter_state_space_diagnostics |
|
smoother_ss_diagnostics |
|
smoother_end |
A note about documentation style. Optional arguments are enclosed in brackets [like this].
call smoother_read_restart(ens_handle, ens_size, model_size, time1, init_time_days)
type(ensemble_type), intent(inout) :: ens_handle
integer, intent(in) :: ens_size
integer, intent(in) :: model_size
type(time_type), intent(inout) :: time1
integer, intent(in) :: init_time_days
Reads in ensemble of states for all lag estimates from a restart file.
|
Handle of ensemble manager structure of single state; copied into all lags for startup. |
|
Size of the ensemble. |
|
Size of the model state vector. |
|
Overwrite the time in the restart file with this value if init_time_days is non-negative. |
|
If non-negative, use time1 instead of time in restart file. |
call advance_smoother(ens_handle)
type(ensemble_type), intent(in) :: ens_handle
Advances smoother state estimates at all lags forward in time. This entails copying the most recent smoother state, contained in ens_handle, into the lag 1 smoother state and pushing back all other lags by 1 (i.e. lag 1 becomes lag 2, etc.).
|
Ensemble handle with most recent filtered state. |
call smoother_gen_copy_meta_data(num_output_state_members, output_inflation)
integer, intent(in) :: num_output_state_members
logical, intent(in) :: output_inflation
Initializes the metadata required for the smoother state space diagnostic files.
|
Number of copies of smoother state vector that should be in state space diagnostic output. |
|
True if smoother state space output should include inflation values. |
call smoother_write_restart(start_copy, end_copy)
integer, intent(in) :: start_copy
integer, intent(in) :: end_copy
Outputs restart files for all lags of smoother state. Integer arguments specify the start and end global indices of a continguous set of copies that contain the ensemble members.
|
Global index of ensemble copy that starts the actual ensemble members for smoother. |
|
Global index of ensemble copy that ends the actual ensemble members for smoother. |
call init_smoother(ens_handle, POST_INF_COPY, POST_INF_SD_COPY)
type(ensemble_type), intent(inout) :: ens_handle
integer, intent(in) :: POST_INF_COPY
integer, intent(in) :: POST_INF_SD_COPY
Initializes the storage needed for a smoother. Also initializes an adaptive inflation type that does NO inflation (not currently supported for smoothers).
|
An ensemble handle for the filter that contains information about ensemble and model size. |
|
Global index of ensemble copy that holds posterior state space inflation values. |
|
Global index of ensemble copy that holds posterior inflation standard deviation values. |
var = do_smoothing()
logical, intent(out) :: do_smoothing
Returns true if smoothing is to be done, else false.
|
Returns true if smoothing is to be done. |
call smoother_mean_spread(ens_size,ENS_MEAN_COPY,ENS_SD_COPY, output_state_ens_mean,output_state_ens_spread)
integer, intent(in) :: ens_size
integer, intent(in) :: ENS_MEAN_COPY
integer, intent(in) :: ENS_SD_COPY
logical, intent(in) :: output_state_ens_mean
logical, intent(in) :: output_state_ens_spread
Computes the ensemble mean (and spread if required) of all state variables for all lagged ensembles. Spread is only computed if it is required for output.
|
Size of ensemble. |
|
Global index of copy that stores ensemble mean. |
|
Global index of copy that stores ensemble spread. |
|
True if the ensemble mean is to be output to state diagnostic file. |
|
True if ensemble spread is to be output to state diagnostic file. |
call smoother_assim(obs_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_PRIOR_MEAN_START, OBS_PRIOR_MEAN_END, OBS_PRIOR_VAR_START, OBS_PRIOR_VAR_END)
type(ensemble_type), intent(inout) :: obs_ens_handle
type(obs_sequence_type), intent(in) :: seq
integer, dimension(:), intent(in) :: keys
integer, intent(in) :: ens_size
integer, intent(in) :: num_groups
integer, intent(in) :: obs_val_index
integer, intent(in) :: ENS_MEAN_COPY
integer, intent(in) :: ENS_SD_COPY
integer, intent(in) :: PRIOR_INF_COPY
integer, intent(in) :: PRIOR_INF_SD_COPY
integer, intent(in) :: OBS_KEY_COPY
integer, intent(in) :: OBS_GLOBAL_QC_COPY
integer, intent(in) :: OBS_PRIOR_MEAN_START
integer, intent(in) :: OBS_PRIOR_MEAN_END
integer, intent(in) :: OBS_PRIOR_VAR_START
integer, intent(in) :: OBS_PRIOR_VAR_END
Does assimilation of a set of observations for each smoother lag.
|
Handle for ensemble manager holding prior estimates of observations. |
|
Observation sequence being assimilated. |
|
A one dimensional array containing indices in seq of observations to as similate at current time. |
|
Ensemble size. |
|
Number of groups in filter. |
|
Integer index of copy of data in seq that contains the observed value from instruments. |
|
Global index in smoother’s state ensemble that holds ensemble mean. |
|
Global index in smoother’s state ensemble that holds ensemble standard deviation. |
|
Global index in obs_ens_handle that holds inflation values (not used for smoother). |
|
Global index in obs_ens_handle that holds inflation sd values (not used for smoother). |
|
Global index in obs_ens_handle that holds the key for the observation. |
|
Global index in obs_ens_handle that holds the quality control value. |
|
Global index in obs_ens_handle that holds the first group’s prior mean. |
|
Global index in obs_ens_handle that holds the last group’s prior mean. |
|
Global index in obs_ens_handle that holds the first group’s prior variance. |
|
Global index in obs_ens_handle that holds the last group’s prior variance. |
call filter_state_space_diagnostics(out_unit, ens_handle, model_size, num_output_state_members, output_state_mean_index, output_state_spread_index, output_inflation, temp_ens, ENS_MEAN_COPY, ENS_SD_COPY, inflate, INF_COPY, INF_SD_COPY)
type(netcdf_file_type), intent(inout) :: out_unit
type(ensemble_type), intent(inout) :: ens_handle
integer, intent(in) :: model_size
integer, intent(in) :: num_output_state_members
integer, intent(in) :: output_state_mean_index
integer, intent(in) :: output_state_spread_index
logical, intent(in) :: output_inflation
real(r8), intent(out) :: temp_ens(model_size)
integer, intent(in) :: ENS_MEAN_COPY
integer, intent(in) :: ENS_SD_COPY
type(adaptive_inflate_type), intent(in) :: inflate
integer, intent(in) :: INF_COPY
integer, intent(in) :: INF_SD_COPY
Writes state space diagnostic values including ensemble members, mean and spread, and inflation mean and spread to a netcdf file.
|
Descriptor for the netcdf file being written. |
|
Ensemble handle whose state space values are to be written. |
|
Size of the model state vector. |
|
Number of individual state members to be output. |
|
Index in netcdf file for ensemble mean. |
|
Index in netcdf file for ensemble spread. |
|
True if the inflation values are to be output. Default is .TRUE. |
|
Storage passed in to avoid having to allocate extra space. |
|
Global index in ens_handle for ensemble mean. |
|
Global index in ens_handle for ensemble spread. |
|
Contains description and values of state space inflation. |
|
Global index in ens_handle of inflation values. |
|
Global index in ens_handle of inflation standard deviation values. |
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)
integer, intent(in) :: model_size
integer, intent(in) :: num_output_state_members
logical, intent(in) :: output_inflation
real(r8), intent(out) :: temp_ens(model_size)
integer, intent(in) :: ENS_MEAN_COPY
integer, intent(in) :: ENS_SD_COPY
integer, intent(in) :: POST_INF_COPY
integer, intent(in) :: POST_INF_SD_COPY
Outputs state space diagnostics files for all smoother lags.
|
Size of the model state vector. |
|
Number of state copies to be output in the state space diagnostics file. |
|
True if the inflation values are to be output. Default is .TRUE. |
|
Storage passed in to avoid having to allocate extra space. |
|
Global index of the ensemble mean in the lag smoother ensemble handles. |
|
Global index of the ensemble spread in the lag smoother ensemble handles. |
|
Global index of the inflation value in the lag smoother ensemble handles (not currently used). |
|
Global index of the inflation spread in the lag smoother ensemble handles (not currently used). |
call smoother_end()
Releases storage allocated for smoother.
call smoother_inc_lags()
Increments the number of lags that are in use for smoother. Used when a smoother is being started up and there have not been enough times to propagate the state to all requested lags.
Files¶
input.nml
smoother initial condition files
smoother restart files
References¶
none
Private components¶
N/A