Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow processors without tiles (N_catl=0) #309

Merged
merged 6 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ subroutine get_enkf_increments( &
N_obsl, Observations_l, Obs_pred_l, obsbias_ok, &
fcsterr_inflation_fac )

deallocate(obsbias_ok)
if (allocated(obsbias_ok)) deallocate(obsbias_ok)


! IF NEEDED, INCLUDE WITHHOLDING SUBROUTINE HERE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ subroutine get_obs_pred( &

real, parameter :: EASE_max_water_frac = 0.05 ! [-]

integer :: N_catlH, n_e, i, j, k, N_tmp, ii, jj
integer :: N_catlH, n_e, i, j, k, N_tmp, ii, jj, kk
integer :: N_fields, N_Tbspecies, N_TbuniqFreqAngRTMid
integer :: this_species, this_tilenum, this_pol
integer :: this_Tbspecies, this_TbuniqFreqAngRTMid, RTM_id
Expand Down Expand Up @@ -1094,7 +1094,7 @@ subroutine get_obs_pred( &
else

obsbias_ok_tmp = .false.

end if

if (present(fcsterr_inflation_fac) .and. beforeEnKFupdate) then
Expand All @@ -1118,7 +1118,7 @@ subroutine get_obs_pred( &

allocate(Obs_pred_l(N_obsl,N_ens))

Obs_pred_l = nodata_generic
if (N_obsl > 0) Obs_pred_l = nodata_generic

! get_*_l : may include additional fields needed to compute observed fields

Expand All @@ -1141,78 +1141,83 @@ subroutine get_obs_pred( &

ind_obsparam2Tbspecies = -999

j = 0

do i=1,N_obs_param

select case (trim(obs_param(i)%varname))

case ('sfmc')

get_sfmc_l = .true.
get_sfmc_lH = .true.
get_tsurf_l = .true. ! needed for model-based QC

case ('rzmc')

get_rzmc_l = .true.
get_rzmc_lH = .true.
get_tsurf_l = .true. ! needed for model-based QC

case ('tsurf')

get_tsurf_l = .true.
get_tsurf_lH = .true.
get_tp_l = .true. ! needed for model-based QC
get_sfmc_l = .true. ! needed to get ar1, ar2, and ar4
j = 0 ! initialize
N_Tbspecies = 0 ! initialize

case ('FT')

get_FT_l = .true.
get_FT_lH = .true.
get_sfmc_l = .true. ! needed to get ar1, ar2, and ar4
get_tp_l = .true. ! needed as input to calc_FT

case ('Tb')

j=j+1 ! count number of Tb species

ind_obsparam2Tbspecies(i) = j

Tb_freq_ang_RTMid(j,1) = obs_param(i)%freq
Tb_freq_ang_RTMid(j,2) = obs_param(i)%ang(1)
Tb_freq_ang_RTMid(j,3) = real(obs_param(i)%RTM_ID)

get_sfmc_l = .true.
get_tsurf_l = .true.
get_tp_l = .true.
get_Tb_l = .true.
if (N_catl > 0) then

do i=1,N_obs_param

get_Tb_lH = .true.
select case (trim(obs_param(i)%varname))

case default
case ('sfmc')

call ldas_abort(LDAS_GENERIC_ERROR, Iam, 'unknown obs_param%varname')
get_sfmc_l = .true.
get_sfmc_lH = .true.
get_tsurf_l = .true. ! needed for model-based QC

case ('rzmc')

get_rzmc_l = .true.
get_rzmc_lH = .true.
get_tsurf_l = .true. ! needed for model-based QC

case ('tsurf')

get_tsurf_l = .true.
get_tsurf_lH = .true.
get_tp_l = .true. ! needed for model-based QC
get_sfmc_l = .true. ! needed to get ar1, ar2, and ar4

case ('FT')

get_FT_l = .true.
get_FT_lH = .true.
get_sfmc_l = .true. ! needed to get ar1, ar2, and ar4
get_tp_l = .true. ! needed as input to calc_FT

case ('Tb')

j=j+1 ! count number of Tb species

ind_obsparam2Tbspecies(i) = j

Tb_freq_ang_RTMid(j,1) = obs_param(i)%freq
Tb_freq_ang_RTMid(j,2) = obs_param(i)%ang(1)
Tb_freq_ang_RTMid(j,3) = real(obs_param(i)%RTM_ID)

get_sfmc_l = .true.
get_tsurf_l = .true.
get_tp_l = .true.
get_Tb_l = .true.

get_Tb_lH = .true.

case default

call ldas_abort(LDAS_GENERIC_ERROR, Iam, 'unknown obs_param%varname')

end select

end select

end do
end do

N_Tbspecies = j

! determine unique combinations of Tb frequency, angle, and RTM_ID
!
! Step 1:
! determine unique combinations of Tb frequency and angle
! (obs_param usually has separate species for H- and V-pol and
! for ascending and descending orbits, but the mwRTM model
! always provides both polarizations and does not depend on the
! orbit direction --> avoid computing and communicating redundant
! information)

call unique_rows_3col( &
N_Tbspecies, Tb_freq_ang_RTMid(1:N_Tbspecies,:), &
N_TbuniqFreqAngRTMid, ind_Tbspecies2TbuniqFreqAngRTMid(1:N_Tbspecies) )
N_Tbspecies = j

! determine unique combinations of Tb frequency, angle, and RTM_ID
!
! Step 1:
! determine unique combinations of Tb frequency and angle
! (obs_param usually has separate species for H- and V-pol and
! for ascending and descending orbits, but the mwRTM model
! always provides both polarizations and does not depend on the
! orbit direction --> avoid computing and communicating redundant
! information)

call unique_rows_3col( &
N_Tbspecies, Tb_freq_ang_RTMid(1:N_Tbspecies,:), &
N_TbuniqFreqAngRTMid, ind_Tbspecies2TbuniqFreqAngRTMid(1:N_Tbspecies) )

endif ! N_catl > 0

if (get_Tb_l) allocate(Tb_h_l(N_catl,N_TbuniqFreqAngRTMid,N_ens))
if (get_Tb_l) allocate(Tb_v_l(N_catl,N_TbuniqFreqAngRTMid,N_ens))
Expand All @@ -1226,44 +1231,53 @@ subroutine get_obs_pred( &

! for FOV_units in 'km', all processors need to know the xhalo of each processor,
! which in turn depends on latitude


kk = 0 ! counter to facilitate skipping over processors that have no tiles (N_catl_vec(jj)=0)

do jj=1,numprocs


if (N_catl_vec(jj) <=0 ) cycle ! nothing to do for this processor

istart = low_ind(jj)
iend = istart + N_catl_vec(jj) - 1

! largest abs(lat) will have largest FOV

tmplatvec(jj) = maxval( abs( tile_coord_f(istart:iend)%com_lat ))
kk = kk + 1
tmplatvec(kk) = maxval( abs( tile_coord_f(istart:iend)%com_lat ))

end do

! find maximum FOV in units of [deg] across all obs params
do ii=1,N_obs_param

if (N_catl > 0) then

if ( trim(obs_param(ii)%FOV_units)=='deg' ) then

xhalo = max( xhalo, obs_param(ii)%FOV )
yhalo = max( yhalo, obs_param(ii)%FOV )

elseif ( trim(obs_param(ii)%FOV_units)=='km' ) then

! convert from [km] (FOV) to [deg]

call dist_km2deg( obs_param(ii)%FOV, numprocs, tmplatvec, tmprx, r_y )

xhalo = max( xhalo, tmprx )
yhalo = max( yhalo, r_y )

else
do ii=1,N_obs_param

call ldas_abort(LDAS_GENERIC_ERROR, Iam, 'unknown FOV_units (i)')
if ( trim(obs_param(ii)%FOV_units)=='deg' ) then

xhalo = max( xhalo, obs_param(ii)%FOV )
yhalo = max( yhalo, obs_param(ii)%FOV )

elseif ( trim(obs_param(ii)%FOV_units)=='km' ) then

! convert from [km] (FOV) to [deg]

call dist_km2deg( obs_param(ii)%FOV, kk, tmplatvec(1:kk), tmprx(1:kk), r_y )

xhalo = max( xhalo, tmprx(1:kk) )
yhalo = max( yhalo, r_y )

else

call ldas_abort(LDAS_GENERIC_ERROR, Iam, 'unknown FOV_units (i)')

end if

end if
end do

end do
endif ! N_catl > 0

! FOV is *radius*, leave some room

xhalo = 2.5 * xhalo
Expand Down Expand Up @@ -1816,7 +1830,7 @@ subroutine get_obs_pred( &

! potentially eliminate obs (except if "bias_Npar>0" and "obsbias_ok==FALSE")

if ( obs_param(this_species)%bias_Npar>0 .and. (.not. obsbias_ok(i)) ) then
if ( obs_param(this_species)%bias_Npar>0 .and. (.not. obsbias_ok_tmp(i)) ) then

! do nothing (ie, keep obs), obs bias estimate is spinning up

Expand Down Expand Up @@ -2872,6 +2886,8 @@ subroutine get_tiles_in_halo( N_catl, N_fields, N_ens, tile_data_l, tile_coord_l
! crosses the dateline!

do i=1,numprocs

if (N_catl_vec(i) <=0 ) cycle ! nothing to do for this processor

istart = low_ind(i)
iend = istart + N_catl_vec(i) - 1
Expand Down Expand Up @@ -2905,7 +2921,9 @@ subroutine get_tiles_in_halo( N_catl, N_fields, N_ens, tile_data_l, tile_coord_l

end do

do i=1,numprocs
do i=1,numprocs

if (N_catl_vec(i) <=0 ) cycle ! nothing to do for this processor

! all tiles within the following rectangle are needed by proc i

Expand Down