Skip to content

Commit

Permalink
fix(VirtualDataManager): allow new model to work without virtual supp…
Browse files Browse the repository at this point in the history
…ort (#1371)

* Prior to this change, it was not possible to add a new type of numerical model and have the simulation complete unless the new model also had a corresponding virtual data container
* This fix allows the program to run to completion if a new model type does not yet have a virtual data container
  • Loading branch information
langevin-usgs authored Sep 28, 2023
1 parent 440a868 commit 690d098
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/Distributed/VirtualDataManager.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module VirtualDataManagerModule
use STLVecIntModule
use VirtualDataListsModule, only: virtual_model_list, virtual_exchange_list
use VirtualBaseModule, only: MAP_NODE_TYPE, MAP_CONN_TYPE
use VirtualModelModule, only: get_virtual_model
use VirtualExchangeModule, only: get_virtual_exchange
use VirtualModelModule, only: get_virtual_model, get_virtual_model_from_list
use VirtualExchangeModule, only: get_virtual_exchange, &
get_virtual_exchange_from_list
use VirtualSolutionModule
use VirtualDataContainerModule
use RouterBaseModule
Expand Down Expand Up @@ -92,6 +93,7 @@ subroutine vds_add_solution(this, num_sol)
integer(I4B) :: model_id, exg_id
type(STLVecInt) :: model_ids, exchange_ids
class(VirtualDataContainerType), pointer :: vdc
logical :: found

this%nr_solutions = this%nr_solutions + 1
virt_sol => this%virtual_solutions(this%nr_solutions)
Expand All @@ -104,16 +106,34 @@ subroutine vds_add_solution(this, num_sol)
virt_sol%solution_id = num_sol%id
virt_sol%numerical_solution => num_sol

! 1) adding all local models from the solution
! 1) adding all local models with a virtual model counterpart from the solution
do im = 1, num_sol%modellist%Count()
num_mod => GetNumericalModelFromList(num_sol%modellist, im)
call model_ids%push_back(num_mod%id)
found = .false.
do i = 1, virtual_model_list%Count()
vdc => get_virtual_model_from_list(virtual_model_list, i)
if (num_mod%id == vdc%id) then
found = .true.
exit
end if
end do
if (found) then
call model_ids%push_back(num_mod%id)
end if
end do

! 2) adding all local exchanges
! 2) adding all local exchanges with a virtual exchange counterpart
do ix = 1, num_sol%exchangelist%Count()
exg => GetDisConnExchangeFromList(num_sol%exchangelist, ix)
if (.not. associated(exg)) cycle ! interface model is handled separately
found = .false.
do i = 1, virtual_exchange_list%Count()
vdc => get_virtual_exchange_from_list(virtual_exchange_list, i)
if (exg%id == vdc%id) then
found = .true.
exit
end if
end do
call exchange_ids%push_back_unique(exg%id)
end do

Expand Down

0 comments on commit 690d098

Please sign in to comment.