Skip to content

Commit

Permalink
Merge pull request #450 from NCAR/bugfix-QC
Browse files Browse the repository at this point in the history
Bugfix QC8
  • Loading branch information
hkershaw-brown committed Feb 9, 2023
2 parents 16595ca + c886fba commit 224698d
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ individual files.

The changes are now listed with the most recent at the top.

**February 9 2023 :: Bug-fix for vertical conversion QC 8. Tag v10.6.3**

- QC 8 values now correctly recorded. Previously this info was lost if
the posterior FO was skipped.
- Fixes QC overwrite for forward operators when running distributed_state = .false.
- WRF tutorial bug fix for setting paramfile.

**January 27 2023 :: Documentation update for porting new models. Tag v10.6.2**

- Improved 'porting new models to DART' documentation.
Expand Down
52 changes: 51 additions & 1 deletion assimilation_code/modules/assimilation/filter_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,10 @@ subroutine filter_main()

call trace_message('After posterior obs space diagnostics')
else
! call this alternate routine to collect any updated QC values that may
! have been set in the assimilation loop and copy them to the outgoing obs seq
call obs_space_sync_QCs(obs_fwd_op_ens_handle, seq, keys, num_obs_in_set, &
OBS_GLOBAL_QC_COPY, DART_qc_index)
call deallocate_single_copy(obs_fwd_op_ens_handle, prior_qc_copy)
endif

Expand Down Expand Up @@ -1663,7 +1667,7 @@ subroutine obs_space_diagnostics(obs_fwd_op_ens_handle, qc_ens_handle, ens_size,
OBS_MEAN_START, OBS_VAR_START, OBS_GLOBAL_QC_COPY, OBS_VAL_COPY, &
OBS_ERR_VAR_COPY, DART_qc_index, do_post)

! Do prior observation space diagnostics on the set of obs corresponding to keys
! Do observation space diagnostics on the set of obs corresponding to keys

type(ensemble_type), intent(inout) :: obs_fwd_op_ens_handle, qc_ens_handle
integer, intent(in) :: ens_size
Expand Down Expand Up @@ -1761,6 +1765,52 @@ end subroutine obs_space_diagnostics

!-------------------------------------------------------------------------

subroutine obs_space_sync_QCs(obs_fwd_op_ens_handle, &
seq, keys, num_obs_in_set, OBS_GLOBAL_QC_COPY, DART_qc_index)


type(ensemble_type), intent(inout) :: obs_fwd_op_ens_handle
integer, intent(in) :: num_obs_in_set
integer, intent(in) :: keys(num_obs_in_set)
type(obs_sequence_type), intent(inout) :: seq
integer, intent(in) :: OBS_GLOBAL_QC_COPY
integer, intent(in) :: DART_qc_index

integer :: j
integer :: io_task, my_task
real(r8), allocatable :: obs_temp(:)
real(r8) :: rvalue(1)

! this is a query routine to return which task has
! logical processing element 0 in this ensemble.
io_task = map_pe_to_task(obs_fwd_op_ens_handle, 0)
my_task = my_task_id()

! write the obs_seq.final file
if (my_task == io_task) then
allocate(obs_temp(num_obs_in_set))
else
allocate(obs_temp(1))
endif

! Optimize: Could we use a gather instead of a transpose and get copy?
call all_copies_to_all_vars(obs_fwd_op_ens_handle)

! Update the qc global value
call get_copy(io_task, obs_fwd_op_ens_handle, OBS_GLOBAL_QC_COPY, obs_temp)
if(my_task == io_task) then
do j = 1, obs_fwd_op_ens_handle%num_vars
rvalue(1) = obs_temp(j)
call replace_qc(seq, keys(j), rvalue, DART_qc_index)
end do
endif

deallocate(obs_temp)

end subroutine obs_space_sync_QCs

!-------------------------------------------------------------------------

subroutine filter_sync_keys_time(ens_handle, key_bounds, num_obs_in_set, time1, time2)

integer, intent(inout) :: key_bounds(2), num_obs_in_set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ subroutine get_obs_ens_distrib_state(ens_handle, obs_fwd_op_ens_handle, &
! call prepare_to_read_from_vars(ens_handle)

! Set up access to the state
call create_state_window(ens_handle)
call create_state_window(ens_handle, obs_fwd_op_ens_handle, qc_ens_handle)

ens_size = ens_handle%num_copies - ens_handle%num_extras

Expand Down Expand Up @@ -323,8 +323,6 @@ subroutine get_obs_ens_distrib_state(ens_handle, obs_fwd_op_ens_handle, &
! each ensemble member into global_qc_value
allocate(var_istatus(qc_ens_handle%num_copies))

if (.not. isprior) call put_single_copy(obs_fwd_op_ens_handle, OBS_GLOBAL_QC_COPY, prior_qc_copy)

MY_OBS: do j = 1, obs_fwd_op_ens_handle%my_num_vars
! collect dart qc
var_istatus = qc_ens_handle%copies(:,j)
Expand Down
10 changes: 9 additions & 1 deletion assimilation_code/modules/utilities/cray_win_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ module window_mod
!-------------------------------------------------------------
!> Create the window for the ensemble complete state vector
!> I think you have to pass it the state ensemble handle
subroutine create_state_window(state_ens_handle)
subroutine create_state_window(state_ens_handle, fwd_op_ens_handle, qc_ens_handle)

type(ensemble_type), intent(inout) :: state_ens_handle !< state ensemble handle
type(ensemble_type), intent(inout), optional :: fwd_op_ens_handle
type(ensemble_type), intent(inout), optional :: qc_ens_handle

integer :: ii, jj, count, ierr
integer :: bytesize !< size in bytes of each element in the window
Expand All @@ -68,6 +70,12 @@ subroutine create_state_window(state_ens_handle)

if (get_allow_transpose(state_ens_handle)) then
call all_copies_to_all_vars(state_ens_handle)
if (present(fwd_op_ens_handle)) then
call all_copies_to_all_vars(fwd_op_ens_handle)
endif
if (present(qc_ens_handle)) then
call all_copies_to_all_vars(qc_ens_handle)
endif
else
! find how many variables I have
my_num_vars = state_ens_handle%my_num_vars
Expand Down
10 changes: 9 additions & 1 deletion assimilation_code/modules/utilities/no_cray_win_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ module window_mod
!> For the non-distributed case this is simply a transpose
!> For the distributed case memory is allocated in this module
!> then an mpi window is attached to this memory.
subroutine create_state_window(state_ens_handle)
subroutine create_state_window(state_ens_handle, fwd_op_ens_handle, qc_ens_handle)

type(ensemble_type), intent(inout) :: state_ens_handle
type(ensemble_type), intent(inout), optional :: fwd_op_ens_handle
type(ensemble_type), intent(inout), optional :: qc_ens_handle

integer :: ierr
integer :: bytesize !< size in bytes of each element in the window
Expand All @@ -69,6 +71,12 @@ subroutine create_state_window(state_ens_handle)

if (get_allow_transpose(state_ens_handle)) then
call all_copies_to_all_vars(state_ens_handle)
if (present(fwd_op_ens_handle)) then
call all_copies_to_all_vars(fwd_op_ens_handle)
endif
if (present(qc_ens_handle)) then
call all_copies_to_all_vars(qc_ens_handle)
endif
else
! find how many variables I have
my_num_vars = state_ens_handle%my_num_vars
Expand Down
4 changes: 3 additions & 1 deletion assimilation_code/modules/utilities/null_win_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ module window_mod

!-------------------------------------------------------------
!> Always using distributed in non-mpi case
subroutine create_state_window(state_ens_handle)
subroutine create_state_window(state_ens_handle, fwd_op_ens_handle, qc_ens_handle)

type(ensemble_type), intent(inout) :: state_ens_handle
type(ensemble_type), intent(inout), optional :: fwd_op_ens_handle
type(ensemble_type), intent(inout), optional :: qc_ens_handle

! Find out how many copies to put in the window
! copies_in_window is not necessarily equal to ens_handle%num_copies
Expand Down
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = 'Data Assimilation Research Section'

# The full version, including alpha/beta/rc tags
release = '10.6.2'
release = '10.6.3'
master_doc = 'README'

# -- General configuration ---------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion models/wrf/shell_scripts/gen_retro_icbc.csh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ echo "gen_retro_icbc.csh is running in `pwd`"
set datea = 2017042700
set datefnl = 2017042712 # set this appropriately #%%%#
set paramfile = /glade2/scratch2/USERNAME/WORK_DIR/scripts/param.csh # set this appropriately #%%%#
set paramfile = /glade/work/thoar/DART/clean_rma_trunk/models/wrf/tutorial/scripts/param.csh

source $paramfile

Expand Down

0 comments on commit 224698d

Please sign in to comment.