Skip to content

Commit

Permalink
Merge pull request #712 from NCAR/fix-get_close_init-0
Browse files Browse the repository at this point in the history
Catch and error out if max dist or max dist_list is <=0 for location mods:3d sphere and 3d cartesian
  • Loading branch information
hkershaw-brown authored Aug 29, 2024
2 parents 7d5fd79 + 9d61fe9 commit 6a905aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions assimilation_code/location/threed_cartesian/location_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1046,10 +1046,21 @@ subroutine get_close_init(gc, num, maxdist, locs, maxdist_list)

if ( .not. module_initialized ) call initialize_module

if (maxdist <= 0.0_r8) then
write(msgstring, *) 'bad maxdist value ', maxdist, ' , must be > 0'
call error_handler(E_ERR, 'get_close_init', msgstring, source)
endif

typecount = get_num_types_of_obs()
allocate(gc%type_to_cutoff_map(typecount))

if (present(maxdist_list)) then

if (any(maxdist_list <= 0.0_r8)) then
write(msgstring, *) 'bad maxdist_list value ', maxdist_list, ' , must be > 0'
call error_handler(E_ERR, 'get_close_init', msgstring, source)
endif

if (size(maxdist_list) .ne. typecount) then
write(msgstring,'(A,I8,A,I8)')'maxdist_list len must equal number of specific types, ', &
size(maxdist_list), ' /= ', typecount
Expand Down
13 changes: 13 additions & 0 deletions assimilation_code/location/threed_sphere/location_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1161,11 +1161,24 @@ subroutine get_close_init(gc, num, maxdist, locs, maxdist_list)

if ( .not. module_initialized ) call initialize_module()


if (maxdist <= 0.0_r8) then
write(msgstring, *) 'bad maxdist value ', maxdist, ' , must be > 0'
call error_handler(E_ERR, 'get_close_init', msgstring, source)
endif


! Support per-loc-type localization more efficiently.
typecount = get_num_types_of_obs() ! ignore function name, this is specific type count
allocate(gc%type_to_cutoff_map(typecount))

if (present(maxdist_list)) then

if (any(maxdist_list <= 0.0_r8)) then
write(msgstring, *) 'bad maxdist_list value ', maxdist_list, ' , must be > 0'
call error_handler(E_ERR, 'get_close_init', msgstring, source)
endif

if (size(maxdist_list) .ne. typecount) then
write(msgstring,'(A,I8,A,I8)')'maxdist_list len must equal number of specific types, ', &
size(maxdist_list), ' /= ', typecount
Expand Down

0 comments on commit 6a905aa

Please sign in to comment.