@@ -346,7 +346,7 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
346
346
integer (i8), allocatable :: my_state_indx(:)
347
347
integer (i8), allocatable :: my_obs_indx(:)
348
348
349
- integer :: my_num_obs, i, j, owner, owners_index, my_num_state
349
+ integer :: my_num_obs, i, j, owner, owners_index, my_num_state, ierr
350
350
integer :: obs_mean_index, obs_var_index
351
351
integer :: grp_beg(num_groups), grp_end(num_groups), grp_size, grp_bot, grp_top, group
352
352
integer :: num_close_obs, obs_index, num_close_states
@@ -373,6 +373,7 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
373
373
type (obs_def_type) :: obs_def
374
374
type (time_type) :: obs_time
375
375
376
+ logical , allocatable :: obs_probit_trans_ok(:), state_probit_trans_ok(:)
376
377
logical :: allow_missing_in_state
377
378
logical :: local_single_ss_inflate
378
379
logical :: local_varying_ss_inflate
@@ -395,13 +396,15 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
395
396
my_obs_indx( obs_ens_handle% my_num_vars), &
396
397
my_obs_kind( obs_ens_handle% my_num_vars), &
397
398
my_obs_type( obs_ens_handle% my_num_vars), &
398
- my_obs_loc( obs_ens_handle% my_num_vars))
399
+ my_obs_loc( obs_ens_handle% my_num_vars), &
400
+ obs_probit_trans_ok(obs_ens_handle% my_num_vars))
399
401
400
402
allocate (close_state_dist( ens_handle% my_num_vars), &
401
403
close_state_ind( ens_handle% my_num_vars), &
402
404
my_state_indx( ens_handle% my_num_vars), &
403
405
my_state_kind( ens_handle% my_num_vars), &
404
- my_state_loc( ens_handle% my_num_vars))
406
+ my_state_loc( ens_handle% my_num_vars), &
407
+ state_probit_trans_ok(ens_handle% my_num_vars))
405
408
! end alloc
406
409
407
410
! Initialize assim_tools_module if needed
@@ -503,8 +506,9 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
503
506
! Convert all my state variables to appropriate probit space
504
507
call transform_to_probit(ens_size, ens_handle% copies(1 :ens_size, i), dist_for_state, &
505
508
state_dist_params(i), probit_ens, .false. , &
506
- bounded_below, bounded_above, lower_bound, upper_bound)
507
- ens_handle% copies(1 :ens_size, i) = probit_ens
509
+ bounded_below, bounded_above, lower_bound, upper_bound, ierr)
510
+ state_probit_trans_ok(i) = (ierr == 0 )
511
+ if (state_probit_trans_ok(i)) ens_handle% copies(1 :ens_size, i) = probit_ens
508
512
end do
509
513
510
514
! > optionally convert all state location verticals
@@ -541,8 +545,9 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
541
545
! Convert all my obs (extended state) variables to appropriate probit space
542
546
call transform_to_probit(ens_size, obs_ens_handle% copies(1 :ens_size, i), dist_for_obs, &
543
547
obs_dist_params(i), probit_ens, .false. , &
544
- bounded_below, bounded_above, lower_bound, upper_bound)
545
- obs_ens_handle% copies(1 :ens_size, i) = probit_ens
548
+ bounded_below, bounded_above, lower_bound, upper_bound, ierr)
549
+ obs_probit_trans_ok(i) = (ierr == 0 )
550
+ if (obs_probit_trans_ok(i)) obs_ens_handle% copies(1 :ens_size, i) = probit_ens
546
551
endif
547
552
end do
548
553
@@ -635,9 +640,11 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
635
640
orig_obs_prior_var = obs_ens_handle% copies(OBS_PRIOR_VAR_START: &
636
641
OBS_PRIOR_VAR_END, owners_index)
637
642
638
- ! If QC is okay, convert this observation ensemble from probit to regular space
639
- call transform_from_probit(ens_size, obs_ens_handle% copies(1 :ens_size, owners_index) , &
640
- obs_dist_params(owners_index), obs_ens_handle% copies(1 :ens_size, owners_index))
643
+ ! Convert this observation ensemble from probit back to regular space if to_probit was successful
644
+ if (obs_probit_trans_ok(owners_index)) then
645
+ call transform_from_probit(ens_size, obs_ens_handle% copies(1 :ens_size, owners_index) , &
646
+ obs_dist_params(owners_index), obs_ens_handle% copies(1 :ens_size, owners_index))
647
+ endif
641
648
642
649
obs_prior = obs_ens_handle% copies(1 :ens_size, owners_index)
643
650
endif IF_QC_IS_OKAY
@@ -698,10 +705,14 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
698
705
! Convert the prior and posterior for this observation to probit space
699
706
call transform_to_probit(grp_size, obs_prior(grp_bot:grp_top), dist_for_obs, &
700
707
temp_dist_params, probit_obs_prior(grp_bot:grp_top), .false. , &
701
- bounded_below, bounded_above, lower_bound, upper_bound)
708
+ bounded_below, bounded_above, lower_bound, upper_bound, ierr)
709
+ ! If probit transform fails for any group, this observation cannot be assimimlated
710
+ if (ierr /= 0 ) cycle SEQUENTIAL_OBS
702
711
call transform_to_probit(grp_size, obs_post(grp_bot:grp_top), dist_for_obs, &
703
712
temp_dist_params, probit_obs_post(grp_bot:grp_top), .true. , &
704
- bounded_below, bounded_above, lower_bound, upper_bound)
713
+ bounded_below, bounded_above, lower_bound, upper_bound, ierr)
714
+ ! If probit transform fails for any group, this observation cannot be assimimlated
715
+ if (ierr /= 0 ) cycle SEQUENTIAL_OBS
705
716
! Free up the storage used for this transform
706
717
call deallocate_distribution_params(temp_dist_params)
707
718
@@ -761,6 +772,9 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
761
772
STATE_UPDATE: do j = 1 , num_close_states
762
773
state_index = close_state_ind(j)
763
774
775
+ ! If transform to probit failed for this state variable, don't update it
776
+ if (.not. state_probit_trans_ok(state_index)) cycle STATE_UPDATE
777
+
764
778
if ( allow_missing_in_state ) then
765
779
! Don't allow update of state ensemble with any missing values
766
780
if (any (ens_handle% copies(1 :ens_size, state_index) == MISSING_R8 )) cycle STATE_UPDATE
@@ -796,6 +810,9 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
796
810
OBS_UPDATE: do j = 1 , num_close_obs
797
811
obs_index = close_obs_ind(j)
798
812
813
+ ! If transform to probit failed for this observed variable, don't update it
814
+ if (.not. obs_probit_trans_ok(obs_index)) cycle OBS_UPDATE
815
+
799
816
! Only have to update obs that have not yet been used
800
817
if (my_obs_indx(obs_index) > i) then
801
818
@@ -820,7 +837,7 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
820
837
821
838
! Do the inverse probit transform for state variables
822
839
call transform_all_from_probit(ens_size, ens_handle% my_num_vars, ens_handle% copies, &
823
- state_dist_params, ens_handle% copies)
840
+ state_dist_params, ens_handle% copies, state_probit_trans_ok )
824
841
825
842
! Every pe needs to get the current my_inflate and my_inflate_sd back
826
843
if (local_single_ss_inflate) then
@@ -876,13 +893,15 @@ subroutine filter_assim(ens_handle, obs_ens_handle, obs_seq, keys, &
876
893
my_obs_type, &
877
894
close_obs_ind, &
878
895
vstatus, &
879
- my_obs_loc)
896
+ my_obs_loc, &
897
+ state_probit_trans_ok)
880
898
881
899
deallocate (close_state_dist, &
882
900
my_state_indx, &
883
901
close_state_ind, &
884
902
my_state_kind, &
885
- my_state_loc)
903
+ my_state_loc, &
904
+ obs_probit_trans_ok)
886
905
887
906
! end dealloc
888
907
0 commit comments