[Dart-dev] [5635] DART/branches/development: fix the date of the ensemble mean if written out in dart restart file format .

nancy at ucar.edu nancy at ucar.edu
Fri Mar 30 13:18:58 MDT 2012


Revision: 5635
Author:   nancy
Date:     2012-03-30 13:18:58 -0600 (Fri, 30 Mar 2012)
Log Message:
-----------
fix the date of the ensemble mean if written out in dart restart file format.
the current ensemble time was never set for the auxiliary copies (mean, sd,
inflation, etc) in the ensemble_handle structure, only for the actual
ensemble members.  add a routine to the ensemble_manager to allow set_time
as well as get_time for any copy.  have the move_ahead() routine not overwrite
the current ensemble time, and then in filter have it update the time on
the ensemble mean.  now when we call the write-restart routine, the time
is correct and it goes into the restart file as it should.  this patch maybe
should be migrated to the trunk and kodiak branches after code review by tim.

Modified Paths:
--------------
    DART/branches/development/ensemble_manager/ensemble_manager_mod.f90
    DART/branches/development/filter/filter.dopplerfold.f90
    DART/branches/development/filter/filter.f90
    DART/branches/development/obs_model/obs_model_mod.f90

-------------- next part --------------
Modified: DART/branches/development/ensemble_manager/ensemble_manager_mod.f90
===================================================================
--- DART/branches/development/ensemble_manager/ensemble_manager_mod.f90	2012-03-30 17:44:17 UTC (rev 5634)
+++ DART/branches/development/ensemble_manager/ensemble_manager_mod.f90	2012-03-30 19:18:58 UTC (rev 5635)
@@ -49,7 +49,7 @@
           get_my_vars,                compute_copy_mean,        compute_copy_mean_sd,   &
           get_copy,                   put_copy,                 all_vars_to_all_copies, &
           all_copies_to_all_vars,     read_ensemble_restart,    write_ensemble_restart, &
-          compute_copy_mean_var,      get_copy_owner_index
+          compute_copy_mean_var,      get_copy_owner_index,     set_ensemble_time
 
 type ensemble_type
    !DIRECT ACCESS INTO STORAGE IS USED TO REDUCE COPYING: BE CAREFUL
@@ -477,6 +477,25 @@
 
 !-----------------------------------------------------------------
 
+subroutine set_ensemble_time(ens_handle, indx, mtime)
+
+! Sets the time of an ensemble member indexed by local storage on this pe.
+
+type(ensemble_type), intent(inout) :: ens_handle
+integer,             intent(in)    :: indx
+type(time_type),     intent(in)    :: mtime
+
+if(indx < 1 .or. indx > ens_handle%my_num_copies) then
+   write(errstring, *) 'indx: ', indx, ' cannot exceed ', ens_handle%my_num_copies
+   call error_handler(E_ERR,'get_ensemble_time', errstring, source, revision, revdate)
+endif
+
+ens_handle%time(indx) = mtime
+
+end subroutine set_ensemble_time
+
+!-----------------------------------------------------------------
+
 subroutine get_ensemble_time(ens_handle, indx, mtime)
 
 ! Returns the time of an ensemble member indexed by local storage on this pe.

Modified: DART/branches/development/filter/filter.dopplerfold.f90
===================================================================
--- DART/branches/development/filter/filter.dopplerfold.f90	2012-03-30 17:44:17 UTC (rev 5634)
+++ DART/branches/development/filter/filter.dopplerfold.f90	2012-03-30 19:18:58 UTC (rev 5635)
@@ -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,7 +418,6 @@
    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
 
@@ -440,6 +441,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 +515,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
@@ -1619,6 +1624,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/branches/development/filter/filter.f90
===================================================================
--- DART/branches/development/filter/filter.f90	2012-03-30 17:44:17 UTC (rev 5634)
+++ DART/branches/development/filter/filter.f90	2012-03-30 19:18:58 UTC (rev 5635)
@@ -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,7 +414,6 @@
    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
 
@@ -436,6 +437,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 +511,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
@@ -1598,6 +1603,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/branches/development/obs_model/obs_model_mod.f90
===================================================================
--- DART/branches/development/obs_model/obs_model_mod.f90	2012-03-30 17:44:17 UTC (rev 5634)
+++ DART/branches/development/obs_model/obs_model_mod.f90	2012-03-30 19:18:58 UTC (rev 5635)
@@ -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