From 690d098f7fa328a249de2dd964c952e1d8cbbc5e Mon Sep 17 00:00:00 2001 From: langevin-usgs Date: Thu, 28 Sep 2023 07:52:22 -0500 Subject: [PATCH] fix(VirtualDataManager): allow new model to work without virtual support (#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 --- src/Distributed/VirtualDataManager.f90 | 30 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Distributed/VirtualDataManager.f90 b/src/Distributed/VirtualDataManager.f90 index 1505298932e..a91b5e7eabe 100644 --- a/src/Distributed/VirtualDataManager.f90 +++ b/src/Distributed/VirtualDataManager.f90 @@ -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 @@ -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) @@ -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