Skip to content

Commit b275b24

Browse files
committed
refactor: introduce model and exchange factories
* pull Model/ExchangeFactory modules out of SimulationCreate module * add noop virtual PRT and SWF models and exchanges * prep for templating for build-time model selection
1 parent a666ed4 commit b275b24

19 files changed

+984
-307
lines changed

msvs/mf6core.vfproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
<File RelativePath="..\src\Distributed\VirtualGwfModel.f90"/>
102102
<File RelativePath="..\src\Distributed\VirtualGwtExchange.f90"/>
103103
<File RelativePath="..\src\Distributed\VirtualGwtModel.f90"/>
104+
<File RelativePath="..\src\Distributed\VirtualPrtExchange.f90"/>
105+
<File RelativePath="..\src\Distributed\VirtualPrtModel.f90"/>
106+
<File RelativePath="..\src\Distributed\VirtualSwfExchange.f90"/>
107+
<File RelativePath="..\src\Distributed\VirtualSwfModel.f90"/>
104108
<File RelativePath="..\src\Distributed\VirtualModel.f90"/>
105109
<File RelativePath="..\src\Distributed\VirtualSolution.f90"/></Filter>
106110
<Filter Name="Idm">
@@ -531,6 +535,8 @@
531535
<File RelativePath="..\src\mf6core.f90"/>
532536
<File RelativePath="..\src\mf6lists.f90"/>
533537
<File RelativePath="..\src\RunControl.f90"/>
538+
<File RelativePath="..\src\ModelFactory.f90"/>
539+
<File RelativePath="..\src\ExchangeFactory.f90"/>
534540
<File RelativePath="..\src\RunControlFactory.F90">
535541
<FileConfiguration Name="Debug|Win32">
536542
<Tool Name="VFFortranCompilerTool" Preprocess="preprocessYes"/></FileConfiguration>
@@ -540,6 +546,5 @@
540546
<Tool Name="VFFortranCompilerTool" Preprocess="preprocessYes"/></FileConfiguration>
541547
<FileConfiguration Name="Release|Win32">
542548
<Tool Name="VFFortranCompilerTool" Preprocess="preprocessYes"/></FileConfiguration></File>
543-
544549
<File RelativePath="..\src\SimulationCreate.f90"/></Filter></Files>
545550
<Globals/></VisualStudioProject>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
module VirtualPrtExchangeModule
2+
use KindModule, only: I4B
3+
use SimStagesModule
4+
use VirtualBaseModule
5+
use VirtualDataListsModule, only: virtual_exchange_list
6+
use VirtualExchangeModule
7+
implicit none
8+
private
9+
10+
public :: add_virtual_prt_exchange
11+
12+
type, public, extends(VirtualExchangeType) :: VirtualPrtExchangeType
13+
type(VirtualDbl1dType), pointer :: gwfsimvals => null()
14+
contains
15+
procedure :: create => vtx_create
16+
procedure :: destroy => vtx_destroy
17+
procedure :: prepare_stage => vtx_prepare_stage
18+
! private
19+
procedure, private :: init_virtual_data
20+
procedure, private :: allocate_data
21+
procedure, private :: deallocate_data
22+
end type VirtualPrtExchangeType
23+
24+
contains
25+
26+
!> @brief Add a virtual PRT-PRT exchange to the simulation
27+
!<
28+
subroutine add_virtual_prt_exchange(name, exchange_id, &
29+
model1_id, model2_id)
30+
character(len=*) :: name
31+
integer(I4B) :: exchange_id
32+
integer(I4B) :: model1_id
33+
integer(I4B) :: model2_id
34+
! noop
35+
end subroutine add_virtual_prt_exchange
36+
37+
!> @brief Create a virtual PRT-PRT exchange
38+
!<
39+
subroutine vtx_create(this, name, exg_id, m1_id, m2_id)
40+
class(VirtualPrtExchangeType) :: this
41+
character(len=*) :: name
42+
integer(I4B) :: exg_id
43+
integer(I4B) :: m1_id
44+
integer(I4B) :: m2_id
45+
! noop
46+
end subroutine vtx_create
47+
48+
subroutine init_virtual_data(this)
49+
class(VirtualPrtExchangeType) :: this
50+
! noop
51+
end subroutine init_virtual_data
52+
53+
subroutine vtx_prepare_stage(this, stage)
54+
class(VirtualPrtExchangeType) :: this
55+
integer(I4B) :: stage
56+
! noop
57+
end subroutine vtx_prepare_stage
58+
59+
subroutine vtx_destroy(this)
60+
class(VirtualPrtExchangeType) :: this
61+
! noop
62+
end subroutine vtx_destroy
63+
64+
subroutine allocate_data(this)
65+
class(VirtualPrtExchangeType) :: this
66+
! noop
67+
end subroutine allocate_data
68+
69+
subroutine deallocate_data(this)
70+
class(VirtualPrtExchangeType) :: this
71+
! noop
72+
end subroutine deallocate_data
73+
74+
end module VirtualPrtExchangeModule

src/Distributed/VirtualPrtModel.f90

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module VirtualPrtModelModule
2+
use KindModule, only: I4B
3+
use SimStagesModule
4+
use VirtualBaseModule
5+
use VirtualModelModule
6+
use NumericalModelModule, only: NumericalModelType
7+
implicit none
8+
private
9+
10+
public :: add_virtual_prt_model
11+
12+
type, extends(VirtualModelType) :: VirtualPrtModelType
13+
contains
14+
! public
15+
procedure :: create => vprt_create
16+
procedure :: prepare_stage => vprt_prepare_stage
17+
procedure :: destroy => vprt_destroy
18+
! private
19+
procedure, private :: init_virtual_data
20+
procedure, private :: allocate_data
21+
procedure, private :: deallocate_data
22+
end type VirtualPrtModelType
23+
24+
contains
25+
26+
subroutine add_virtual_prt_model(model_id, model_name, model)
27+
integer(I4B) :: model_id !< global model id
28+
character(len=*) :: model_name !< model name
29+
class(NumericalModelType), pointer :: model !< the actual model (can be null() when remote)
30+
! noop
31+
end subroutine add_virtual_prt_model
32+
33+
subroutine vprt_create(this, name, id, model)
34+
class(VirtualPrtModelType) :: this
35+
character(len=*) :: name
36+
integer(I4B) :: id
37+
class(NumericalModelType), pointer :: model
38+
! noop
39+
end subroutine vprt_create
40+
41+
subroutine init_virtual_data(this)
42+
class(VirtualPrtModelType) :: this
43+
! noop
44+
end subroutine init_virtual_data
45+
46+
subroutine vprt_prepare_stage(this, stage)
47+
class(VirtualPrtModelType) :: this
48+
integer(I4B) :: stage
49+
! noop
50+
end subroutine vprt_prepare_stage
51+
52+
subroutine allocate_data(this)
53+
class(VirtualPrtModelType) :: this
54+
! noop
55+
end subroutine allocate_data
56+
57+
subroutine deallocate_data(this)
58+
class(VirtualPrtModelType) :: this
59+
! noop
60+
end subroutine deallocate_data
61+
62+
subroutine vprt_destroy(this)
63+
class(VirtualPrtModelType) :: this
64+
! noop
65+
end subroutine vprt_destroy
66+
67+
end module VirtualPrtModelModule
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
module VirtualSwfExchangeModule
2+
use KindModule, only: I4B
3+
use SimStagesModule
4+
use VirtualBaseModule
5+
use VirtualDataListsModule, only: virtual_exchange_list
6+
use VirtualExchangeModule
7+
implicit none
8+
private
9+
10+
public :: add_virtual_swf_exchange
11+
12+
type, public, extends(VirtualExchangeType) :: VirtualSwfExchangeType
13+
type(VirtualDbl1dType), pointer :: gwfsimvals => null()
14+
contains
15+
procedure :: create => vtx_create
16+
procedure :: destroy => vtx_destroy
17+
procedure :: prepare_stage => vtx_prepare_stage
18+
! private
19+
procedure, private :: init_virtual_data
20+
procedure, private :: allocate_data
21+
procedure, private :: deallocate_data
22+
end type VirtualSwfExchangeType
23+
24+
contains
25+
26+
!> @brief Add a virtual SWF-SWF exchange to the simulation
27+
!<
28+
subroutine add_virtual_swf_exchange(name, exchange_id, &
29+
model1_id, model2_id)
30+
character(len=*) :: name
31+
integer(I4B) :: exchange_id
32+
integer(I4B) :: model1_id
33+
integer(I4B) :: model2_id
34+
! noop
35+
end subroutine add_virtual_swf_exchange
36+
37+
!> @brief Create a virtual SWF-SWF exchange
38+
!<
39+
subroutine vtx_create(this, name, exg_id, m1_id, m2_id)
40+
class(VirtualSwfExchangeType) :: this
41+
character(len=*) :: name
42+
integer(I4B) :: exg_id
43+
integer(I4B) :: m1_id
44+
integer(I4B) :: m2_id
45+
! noop
46+
end subroutine vtx_create
47+
48+
subroutine init_virtual_data(this)
49+
class(VirtualSwfExchangeType) :: this
50+
! noop
51+
end subroutine init_virtual_data
52+
53+
subroutine vtx_prepare_stage(this, stage)
54+
class(VirtualSwfExchangeType) :: this
55+
integer(I4B) :: stage
56+
! noop
57+
end subroutine vtx_prepare_stage
58+
59+
subroutine vtx_destroy(this)
60+
class(VirtualSwfExchangeType) :: this
61+
! noop
62+
end subroutine vtx_destroy
63+
64+
subroutine allocate_data(this)
65+
class(VirtualSwfExchangeType) :: this
66+
! noop
67+
end subroutine allocate_data
68+
69+
subroutine deallocate_data(this)
70+
class(VirtualSwfExchangeType) :: this
71+
! noop
72+
end subroutine deallocate_data
73+
74+
end module VirtualSwfExchangeModule

src/Distributed/VirtualSwfModel.f90

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module VirtualSwfModelModule
2+
use KindModule, only: I4B
3+
use SimStagesModule
4+
use VirtualBaseModule
5+
use VirtualModelModule
6+
use NumericalModelModule, only: NumericalModelType
7+
implicit none
8+
private
9+
10+
public :: add_virtual_swf_model
11+
12+
type, extends(VirtualModelType) :: VirtualSwfModelType
13+
contains
14+
! public
15+
procedure :: create => vswf_create
16+
procedure :: prepare_stage => vswf_prepare_stage
17+
procedure :: destroy => vswf_destroy
18+
! private
19+
procedure, private :: init_virtual_data
20+
procedure, private :: allocate_data
21+
procedure, private :: deallocate_data
22+
end type VirtualSwfModelType
23+
24+
contains
25+
26+
subroutine add_virtual_swf_model(model_id, model_name, model)
27+
integer(I4B) :: model_id !< global model id
28+
character(len=*) :: model_name !< model name
29+
class(NumericalModelType), pointer :: model !< the actual model (can be null() when remote)
30+
! noop
31+
end subroutine add_virtual_swf_model
32+
33+
subroutine vswf_create(this, name, id, model)
34+
class(VirtualSwfModelType) :: this
35+
character(len=*) :: name
36+
integer(I4B) :: id
37+
class(NumericalModelType), pointer :: model
38+
! noop
39+
end subroutine vswf_create
40+
41+
subroutine init_virtual_data(this)
42+
class(VirtualSwfModelType) :: this
43+
! noop
44+
end subroutine init_virtual_data
45+
46+
subroutine vswf_prepare_stage(this, stage)
47+
class(VirtualSwfModelType) :: this
48+
integer(I4B) :: stage
49+
! noop
50+
end subroutine vswf_prepare_stage
51+
52+
subroutine allocate_data(this)
53+
class(VirtualSwfModelType) :: this
54+
! noop
55+
end subroutine allocate_data
56+
57+
subroutine deallocate_data(this)
58+
class(VirtualSwfModelType) :: this
59+
! noop
60+
end subroutine deallocate_data
61+
62+
subroutine vswf_destroy(this)
63+
class(VirtualSwfModelType) :: this
64+
! noop
65+
end subroutine vswf_destroy
66+
67+
end module VirtualSwfModelModule

src/Exchange/BaseExchange.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module BaseExchangeModule
22

33
use KindModule, only: DP, I4B, LGP
4-
use ConstantsModule, only: LENEXCHANGENAME, LENMEMPATH
4+
use ConstantsModule, only: LENEXCHANGENAME, LENMEMPATH, LINELENGTH
55
use ListModule, only: ListType
66
use BaseModelModule, only: BaseModelType
77

@@ -13,6 +13,8 @@ module BaseExchangeModule
1313

1414
type, abstract :: BaseExchangeType
1515
character(len=LENEXCHANGENAME) :: name !< the name of this exchange
16+
character(len=7) :: typename !< name of the type (e.g., 'GWF-GWF')
17+
character(len=LINELENGTH), pointer :: filename => null() !< name of the input file
1618
character(len=LENMEMPATH) :: memoryPath !< the location in the memory manager where the variables are stored
1719
character(len=LENMEMPATH) :: input_mempath
1820
integer(I4B) :: id

src/Exchange/DisConnExchange.f90

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ module DisConnExchangeModule
2121
!! in the connections object: DisBaseType%con
2222
!<
2323
type, extends(NumericalExchangeType) :: DisConnExchangeType
24-
character(len=LINELENGTH), pointer :: filename => null() !< name of the input file
25-
2624
class(NumericalModelType), pointer :: model1 => null() !< model 1
2725
class(NumericalModelType), pointer :: model2 => null() !< model 2
2826
class(VirtualModelType), pointer :: v_model1 => null() !< virtual model 1
@@ -432,6 +430,7 @@ subroutine allocate_scalars(this)
432430
call mem_allocate(this%auxname_cst, LENAUXNAME, 0, &
433431
'AUXNAME_CST', this%memoryPath)
434432
!
433+
this%filename = ''
435434
this%nexg = 0
436435
this%naux = 0
437436
this%ianglex = 0
@@ -441,7 +440,6 @@ subroutine allocate_scalars(this)
441440
this%iprflow = 0
442441
this%ipakcb = 0
443442
this%inamedbound = 0
444-
!
445443
this%dev_ifmod_on = .false.
446444
!
447445
! -- Return

src/Exchange/NumericalExchange.f90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ module NumericalExchangeModule
1414
AddNumericalExchangeToList, GetNumericalExchangeFromList
1515

1616
type, extends(BaseExchangeType) :: NumericalExchangeType
17-
character(len=7) :: typename !< name of the type (e.g., 'GWF-GWF')
18-
1917
contains
2018

2119
procedure :: exg_df

src/Exchange/exg-gwegwe.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module GweGweExchangeModule
3434

3535
private
3636
public :: GweExchangeType
37-
public :: gweexchange_create
37+
public :: gwegwe_cr
3838
public :: GetGweExchangeFromList
3939
public :: CastAsGweExchange
4040

@@ -107,7 +107,7 @@ module GweGweExchangeModule
107107
!!
108108
!! Create a new GWT to GWT exchange object.
109109
!<
110-
subroutine gweexchange_create(filename, name, id, m1_id, m2_id, input_mempath)
110+
subroutine gwegwe_cr(filename, name, id, m1_id, m2_id, input_mempath)
111111
! -- modules
112112
use BaseModelModule, only: BaseModelType
113113
use ListsModule, only: baseexchangelist
@@ -189,7 +189,7 @@ subroutine gweexchange_create(filename, name, id, m1_id, m2_id, input_mempath)
189189
!
190190
! -- Return
191191
return
192-
end subroutine gweexchange_create
192+
end subroutine gwegwe_cr
193193

194194
!> @ brief Define GWE GWE exchange
195195
!!

0 commit comments

Comments
 (0)