Skip to content

Commit

Permalink
add trim when selecting by varname
Browse files Browse the repository at this point in the history
  • Loading branch information
amfox37 committed Feb 19, 2024
1 parent bc0cef5 commit 7e5b3c8
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4419,20 +4419,24 @@ subroutine cat_enkf_increments( &

N_select_varnames = 0

if (any(obs_param%varname == 'Tb')) then
N_select_varnames = N_select_varnames + 1
select_varnames(N_select_varnames) = 'Tb'
end if

if (any(obs_param%varname == 'sfmc')) then
N_select_varnames = N_select_varnames + 1
select_varnames(N_select_varnames) = 'sfmc'
end if
do ii = 1,N_obs_param

This comment has been minimized.

Copy link
@gmao-rreichle

gmao-rreichle Feb 20, 2024

Contributor

@amfox37 : Is this the correct logic? If there are two different species that have varname 'Tb', then the loop would result in N_select_varnames=2, whereas the old logic (with "any()") would have resulted in N_select_varnames=1. At least this is what it looks like to me late in the day. Maybe I'm getting it wrong. I suppose the loop needs to be around each of the varnames, with an exit from the loop after the if statement is true for the first time?

This comment has been minimized.

Copy link
@amfox37

amfox37 Feb 20, 2024

Author Contributor

Yes I broke things here. Repeated 1,N_obs_param loops around each varname seems to be the simplest solution. I think a single 1,N_obs_param loop would require an additional logical array to record what had been found already.


if (trim(obs_param(ii)%varname) == 'Tb') then
N_select_varnames = N_select_varnames + 1
select_varnames(N_select_varnames) = 'Tb'
end if

if (trim(obs_param(ii)%varname) == 'sfmc') then
N_select_varnames = N_select_varnames + 1
select_varnames(N_select_varnames) = 'sfmc'
end if

if (trim(obs_param(ii)%varname) == 'sfds') then
N_select_varnames = N_select_varnames + 1
select_varnames(N_select_varnames) = 'sfds'
end if

if (any(obs_param%varname == 'sfds')) then
N_select_varnames = N_select_varnames + 1
select_varnames(N_select_varnames) = 'sfds'
end if
end do

! Will get all species associated with Tb or sfds observations

Expand Down

0 comments on commit 7e5b3c8

Please sign in to comment.