[Dart-dev] [5990] DART/trunk: minor changes to update the timestamp on the ensemble mean copy

nancy at ucar.edu nancy at ucar.edu
Mon Mar 11 11:30:47 MDT 2013


Revision: 5990
Author:   nancy
Date:     2013-03-11 11:30:46 -0600 (Mon, 11 Mar 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    DART/trunk/filter/filter.dopplerfold.f90
    DART/trunk/filter/filter.f90
    DART/trunk/obs_model/obs_model_mod.f90

-------------- next part --------------
Modified: DART/trunk/filter/filter.dopplerfold.f90
===================================================================
--- DART/trunk/filter/filter.dopplerfold.f90	2013-03-06 23:13:22 UTC (rev 5989)
+++ DART/trunk/filter/filter.dopplerfold.f90	2013-03-11 17:30:46 UTC (rev 5990)
@@ -31,7 +31,7 @@
                                  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,                &
@@ -40,7 +40,7 @@
                                  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,                      &
@@ -400,7 +400,9 @@
    ! 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, &
@@ -416,10 +418,10 @@
    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.
@@ -440,6 +442,9 @@
       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.)
@@ -511,11 +516,12 @@
    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
@@ -755,6 +761,13 @@
 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)
 
@@ -1619,6 +1632,8 @@
 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

Modified: DART/trunk/filter/filter.f90
===================================================================
--- DART/trunk/filter/filter.f90	2013-03-06 23:13:22 UTC (rev 5989)
+++ DART/trunk/filter/filter.f90	2013-03-11 17:30:46 UTC (rev 5990)
@@ -31,7 +31,7 @@
                                  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,                &
@@ -40,7 +40,7 @@
                                  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,                      &
@@ -396,7 +396,9 @@
    ! 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, &
@@ -412,10 +414,10 @@
    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.
@@ -436,6 +438,9 @@
       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.)
@@ -507,11 +512,12 @@
    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
@@ -749,6 +755,13 @@
 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)
 
@@ -1598,6 +1611,8 @@
 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

Modified: DART/trunk/obs_model/obs_model_mod.f90
===================================================================
--- DART/trunk/obs_model/obs_model_mod.f90	2013-03-06 23:13:22 UTC (rev 5989)
+++ DART/trunk/obs_model/obs_model_mod.f90	2013-03-11 17:30:46 UTC (rev 5990)
@@ -90,7 +90,8 @@
 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
@@ -107,7 +108,7 @@
 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)
 
 


More information about the Dart-dev mailing list