Skip to content

Commit

Permalink
merge changes from trunk:
Browse files Browse the repository at this point in the history
minor changes to update the timestamp on the ensemble mean copy
in the ensemble manager.  if you select the name list option to
write out the ensemble mean, without these changes it won't have
the correct timestamp.

git-svn-id: https://svn-dares-dart.cgd.ucar.edu/DART/releases/Kodiak@5991 dfa8782c-da17-4c45-ba5c-5625b50a00d6

Former-commit-id: 93faf3f3526aa0200424b7ad37650e3a9b27fd2b
  • Loading branch information
nancycollins committed Mar 11, 2013
1 parent da64705 commit 72748c7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
27 changes: 21 additions & 6 deletions filter/filter.dopplerfold.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ program filter
open_file, close_file, do_nml_file, do_nml_term
use assim_model_mod, only : static_init_assim_model, get_model_size, &
netcdf_file_type, init_diag_output, finalize_diag_output, &
aoutput_diagnostics, ens_mean_for_model
aoutput_diagnostics, ens_mean_for_model, end_assim_model
use assim_tools_mod, only : filter_assim, set_assim_tools_trace
use obs_model_mod, only : move_ahead, advance_state, set_obs_model_trace
use ensemble_manager_mod, only : init_ensemble_manager, end_ensemble_manager, &
Expand All @@ -40,7 +40,7 @@ program filter
read_ensemble_restart, write_ensemble_restart, &
compute_copy_mean, compute_copy_mean_sd, &
compute_copy_mean_var, duplicate_ens, get_copy_owner_index, &
get_ensemble_time
get_ensemble_time, set_ensemble_time
use adaptive_inflate_mod, only : adaptive_inflate_end, do_varying_ss_inflate, &
do_single_ss_inflate, inflate_ens, adaptive_inflate_init, &
do_obs_inflate, adaptive_inflate_type, &
Expand Down Expand Up @@ -400,7 +400,9 @@ subroutine filter_main()
! these cases, we must not advance the times on the lags.

! Figure out how far model needs to move data to make the window
! include the next available observation.
! include the next available observation. recent change is
! curr_ens_time in move_ahead() is intent(inout) and doesn't get changed
! even if there are no more obs.
call trace_message('Before move_ahead checks time of data and next obs')

call move_ahead(ens_handle, ens_size, seq, last_key_used, window_time, &
Expand All @@ -416,10 +418,10 @@ subroutine filter_main()
call filter_sync_keys_time(key_bounds, num_obs_in_set, curr_ens_time, next_ens_time)
if(key_bounds(1) < 0) then
call trace_message('No more obs to assimilate, exiting main loop', 'filter:', -1)
!call trace_message('No more obs to assimilate, exiting main loop')
exit AdvanceTime
endif


! if model state data not at required time, advance model
if (curr_ens_time /= next_ens_time) then
! Advance the lagged distribution, if needed.
Expand All @@ -440,6 +442,9 @@ subroutine filter_main()
call advance_state(ens_handle, ens_size, next_ens_time, async, &
adv_ens_command, tasks_per_model_advance)

! update so curr time is accurate.
curr_ens_time = next_ens_time

! only need to sync here since we want to wait for the
! slowest task to finish before outputting the time.
call timestamp_message('After running model', sync=.true.)
Expand Down Expand Up @@ -511,11 +516,12 @@ subroutine filter_main()
call put_copy(0, obs_ens_handle, OBS_KEY_COPY, keys * 1.0_r8)

! Ship the ensemble mean to the model; some models need this for
! computing distances
! Who stores the ensemble mean copy
! computing distances. find out who stores the ensemble mean copy.
call get_copy_owner_index(ENS_MEAN_COPY, mean_owner, mean_owners_index)
! Broadcast it to everybody else
if(my_task_id() == mean_owner) then
! Make sure the timestamp for the mean is the current time.
call set_ensemble_time(ens_handle, mean_owners_index, curr_ens_time)
ens_mean = ens_handle%vars(:, mean_owners_index)
call broadcast_send(mean_owner, ens_mean)
else
Expand Down Expand Up @@ -755,6 +761,13 @@ subroutine filter_main()
if(ds) call smoother_write_restart(1, ens_size)
call trace_message('After writing state restart files if requested')

! The code *should* do this, but it is a change that isn't absolutely
! required to fix any reported bugs, so i'm leaving it commented out
! in the interests of not breaking anything that isn't expecting to
! have the cleanup routine called. next release of dart will certainly
! call this to match the call to static_init_assim_model().
!call end_assim_model()

call trace_message('Before ensemble and obs memory cleanup')
call end_ensemble_manager(ens_handle)

Expand Down Expand Up @@ -1619,6 +1632,8 @@ subroutine filter_sync_keys_time(key_bounds, num_obs_in_set, time1, time2)
real(r8) :: rtime(4)
integer :: days, secs

! this should be 'do i own member 1' and not assume that task 0 gets
! member 1.
if(my_task_id() == 0) then
rkey_bounds = key_bounds
rnum_obs_in_set(1) = num_obs_in_set
Expand Down
27 changes: 21 additions & 6 deletions filter/filter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ program filter
open_file, close_file, do_nml_file, do_nml_term
use assim_model_mod, only : static_init_assim_model, get_model_size, &
netcdf_file_type, init_diag_output, finalize_diag_output, &
aoutput_diagnostics, ens_mean_for_model
aoutput_diagnostics, ens_mean_for_model, end_assim_model
use assim_tools_mod, only : filter_assim, set_assim_tools_trace
use obs_model_mod, only : move_ahead, advance_state, set_obs_model_trace
use ensemble_manager_mod, only : init_ensemble_manager, end_ensemble_manager, &
Expand All @@ -40,7 +40,7 @@ program filter
read_ensemble_restart, write_ensemble_restart, &
compute_copy_mean, compute_copy_mean_sd, &
compute_copy_mean_var, duplicate_ens, get_copy_owner_index, &
get_ensemble_time
get_ensemble_time, set_ensemble_time
use adaptive_inflate_mod, only : adaptive_inflate_end, do_varying_ss_inflate, &
do_single_ss_inflate, inflate_ens, adaptive_inflate_init, &
do_obs_inflate, adaptive_inflate_type, &
Expand Down Expand Up @@ -396,7 +396,9 @@ subroutine filter_main()
! these cases, we must not advance the times on the lags.

! Figure out how far model needs to move data to make the window
! include the next available observation.
! include the next available observation. recent change is
! curr_ens_time in move_ahead() is intent(inout) and doesn't get changed
! even if there are no more obs.
call trace_message('Before move_ahead checks time of data and next obs')

call move_ahead(ens_handle, ens_size, seq, last_key_used, window_time, &
Expand All @@ -412,10 +414,10 @@ subroutine filter_main()
call filter_sync_keys_time(key_bounds, num_obs_in_set, curr_ens_time, next_ens_time)
if(key_bounds(1) < 0) then
call trace_message('No more obs to assimilate, exiting main loop', 'filter:', -1)
!call trace_message('No more obs to assimilate, exiting main loop')
exit AdvanceTime
endif


! if model state data not at required time, advance model
if (curr_ens_time /= next_ens_time) then
! Advance the lagged distribution, if needed.
Expand All @@ -436,6 +438,9 @@ subroutine filter_main()
call advance_state(ens_handle, ens_size, next_ens_time, async, &
adv_ens_command, tasks_per_model_advance)

! update so curr time is accurate.
curr_ens_time = next_ens_time

! only need to sync here since we want to wait for the
! slowest task to finish before outputting the time.
call timestamp_message('After running model', sync=.true.)
Expand Down Expand Up @@ -507,11 +512,12 @@ subroutine filter_main()
call put_copy(0, obs_ens_handle, OBS_KEY_COPY, keys * 1.0_r8)

! Ship the ensemble mean to the model; some models need this for
! computing distances
! Who stores the ensemble mean copy
! computing distances. find out who stores the ensemble mean copy.
call get_copy_owner_index(ENS_MEAN_COPY, mean_owner, mean_owners_index)
! Broadcast it to everybody else
if(my_task_id() == mean_owner) then
! Make sure the timestamp for the mean is the current time.
call set_ensemble_time(ens_handle, mean_owners_index, curr_ens_time)
ens_mean = ens_handle%vars(:, mean_owners_index)
call broadcast_send(mean_owner, ens_mean)
else
Expand Down Expand Up @@ -749,6 +755,13 @@ subroutine filter_main()
if(ds) call smoother_write_restart(1, ens_size)
call trace_message('After writing state restart files if requested')

! The code *should* do this, but it is a change that isn't absolutely
! required to fix any reported bugs, so i'm leaving it commented out
! in the interests of not breaking anything that isn't expecting to
! have the cleanup routine called. next release of dart will certainly
! call this to match the call to static_init_assim_model().
!call end_assim_model()

call trace_message('Before ensemble and obs memory cleanup')
call end_ensemble_manager(ens_handle)

Expand Down Expand Up @@ -1598,6 +1611,8 @@ subroutine filter_sync_keys_time(key_bounds, num_obs_in_set, time1, time2)
real(r8) :: rtime(4)
integer :: days, secs

! this should be 'do i own member 1' and not assume that task 0 gets
! member 1.
if(my_task_id() == 0) then
rkey_bounds = key_bounds
rnum_obs_in_set(1) = num_obs_in_set
Expand Down
5 changes: 3 additions & 2 deletions obs_model/obs_model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ subroutine move_ahead(ens_handle, ens_size, seq, last_key_used, window_time, &
integer, intent(in) :: last_key_used
type(time_type), intent(in) :: window_time
integer, intent(out) :: key_bounds(2), num_obs_in_set
type(time_type), intent(out) :: curr_ens_time, next_ens_time
type(time_type), intent(inout) :: curr_ens_time
type(time_type), intent(out) :: next_ens_time

type(time_type) :: next_time, time2, start_time, end_time, delta_time, ens_time
type(obs_type) :: observation
Expand All @@ -107,7 +108,7 @@ subroutine move_ahead(ens_handle, ens_size, seq, last_key_used, window_time, &
num_obs_in_set = 0
key_bounds(1:2) = -99
leaving_early = .false.
curr_ens_time = set_time(0,0)
!curr_ens_time = set_time(0,0)
next_ens_time = set_time(0,0)


Expand Down

0 comments on commit 72748c7

Please sign in to comment.