Skip to content

Commit 0372cc2

Browse files
committed
use proc pointers, introduce ModelRegistrar module (minimizes code in to-be-templated ModelFactory module), cr -> register renaming (seems appropriate since cr routines create and then add models to global lists)
1 parent eb5f11c commit 0372cc2

File tree

20 files changed

+212
-301
lines changed

20 files changed

+212
-301
lines changed

make/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ $(OBJDIR)/VirtualPrtModel.o \
404404
$(OBJDIR)/VirtualGwtModel.o \
405405
$(OBJDIR)/VirtualGwfModel.o \
406406
$(OBJDIR)/VirtualGweModel.o \
407+
$(OBJDIR)/ModelRegistrar.o \
407408
$(OBJDIR)/VirtualGwtExchange.o \
408409
$(OBJDIR)/VirtualGwfExchange.o \
409410
$(OBJDIR)/VirtualGweExchange.o \

msvs/mf6core.vfproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@
536536
<File RelativePath="..\src\mf6lists.f90"/>
537537
<File RelativePath="..\src\RunControl.f90"/>
538538
<File RelativePath="..\src\ModelFactory.f90"/>
539+
<File RelativePath="..\src\ModelRegistrar.f90"/>
539540
<File RelativePath="..\src\ExchangeFactory.f90"/>
540541
<File RelativePath="..\src\RunControlFactory.F90">
541542
<FileConfiguration Name="Debug|Win32">

src/Distributed/VirtualGweModel.f90

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module VirtualGweModelModule
88
implicit none
99
private
1010

11-
public :: add_virtual_gwe_model
11+
public :: register_virtual_gwe
1212

1313
type, extends(VirtualModelType) :: VirtualGweModelType
1414
! CND
@@ -34,7 +34,6 @@ module VirtualGweModelModule
3434
type(VirtualIntType), pointer :: inest => null()
3535
contains
3636
! public
37-
procedure :: create => vgwe_create
3837
procedure :: prepare_stage => vgwe_prepare_stage
3938
procedure :: destroy => vgwe_destroy
4039
! private
@@ -45,37 +44,26 @@ module VirtualGweModelModule
4544

4645
contains
4746

48-
subroutine add_virtual_gwe_model(model_id, model_name, model)
47+
subroutine register_virtual_gwe(model_id, model_name, model)
4948
use VirtualDataListsModule, only: virtual_model_list
50-
integer(I4B) :: model_id !< global model id
51-
character(len=*) :: model_name !< model name
52-
class(NumericalModelType), pointer :: model !< the actual model (can be null() when remote)
49+
integer(I4B), intent(in) :: model_id !< global model id
50+
character(len=*), intent(in) :: model_name !< model name
51+
class(NumericalModelType), pointer, intent(inout) :: model !< the actual model (can be null() when remote)
5352
! local
5453
class(VirtualGweModelType), pointer :: virtual_gwe_model
5554
class(*), pointer :: obj
5655

5756
allocate (virtual_gwe_model)
58-
call virtual_gwe_model%create(model_name, model_id, model)
57+
call virtual_gwe_model%VirtualModelType%create(model_name, model_id, model)
58+
virtual_gwe_model%container_type = VDC_GWEMODEL_TYPE
59+
60+
call virtual_gwe_model%allocate_data()
61+
call virtual_gwe_model%init_virtual_data()
5962

6063
obj => virtual_gwe_model
6164
call virtual_model_list%Add(obj)
6265

63-
end subroutine add_virtual_gwe_model
64-
65-
subroutine vgwe_create(this, name, id, model)
66-
class(VirtualGweModelType) :: this
67-
character(len=*) :: name
68-
integer(I4B) :: id
69-
class(NumericalModelType), pointer :: model
70-
71-
! create base
72-
call this%VirtualModelType%create(name, id, model)
73-
this%container_type = VDC_GWEMODEL_TYPE
74-
75-
call this%allocate_data()
76-
call this%init_virtual_data()
77-
78-
end subroutine vgwe_create
66+
end subroutine register_virtual_gwe
7967

8068
subroutine init_virtual_data(this)
8169
class(VirtualGweModelType) :: this

src/Distributed/VirtualGwfModel.f90

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module VirtualGwfModelModule
88
implicit none
99
private
1010

11-
public :: add_virtual_gwf_model
11+
public :: register_virtual_gwf
1212

1313
type, public, extends(VirtualModelType) :: VirtualGwfModelType
1414
! NPF
@@ -28,7 +28,6 @@ module VirtualGwfModelModule
2828
type(VirtualDbl1dType), pointer :: buy_dense => null()
2929
contains
3030
! public
31-
procedure :: create => vgwf_create
3231
procedure :: destroy => vgwf_destroy
3332
procedure :: prepare_stage => vgwf_prepare_stage
3433
! private
@@ -39,39 +38,28 @@ module VirtualGwfModelModule
3938

4039
contains
4140

42-
!> @brief Add virtual GWF model
41+
!> @brief Create and register a virtual GWF model
4342
!<
44-
subroutine add_virtual_gwf_model(model_id, model_name, model)
43+
subroutine register_virtual_gwf(model_id, model_name, model)
4544
use VirtualDataListsModule, only: virtual_model_list
46-
integer(I4B) :: model_id !< global model id
47-
character(len=*) :: model_name !< model name
48-
class(NumericalModelType), pointer :: model !< the actual model (can be null() when remote)
45+
integer(I4B), intent(in) :: model_id !< global model id
46+
character(len=*), intent(in) :: model_name !< model name
47+
class(NumericalModelType), pointer, intent(inout) :: model !< the actual model (can be null() when remote)
4948
! local
5049
class(VirtualGwfModelType), pointer :: virtual_gwf_model
5150
class(*), pointer :: obj
5251

5352
allocate (virtual_gwf_model)
54-
call virtual_gwf_model%create(model_name, model_id, model)
53+
call virtual_gwf_model%VirtualModelType%create(model_name, model_id, model)
54+
virtual_gwf_model%container_type = VDC_GWFMODEL_TYPE
55+
56+
call virtual_gwf_model%allocate_data()
57+
call virtual_gwf_model%init_virtual_data()
5558

5659
obj => virtual_gwf_model
5760
call virtual_model_list%Add(obj)
5861

59-
end subroutine add_virtual_gwf_model
60-
61-
subroutine vgwf_create(this, name, id, model)
62-
class(VirtualGwfModelType) :: this
63-
character(len=*) :: name
64-
integer(I4B) :: id
65-
class(NumericalModelType), pointer :: model
66-
67-
! create base
68-
call this%VirtualModelType%create(name, id, model)
69-
this%container_type = VDC_GWFMODEL_TYPE
70-
71-
call this%allocate_data()
72-
call this%init_virtual_data()
73-
74-
end subroutine vgwf_create
62+
end subroutine register_virtual_gwf
7563

7664
subroutine init_virtual_data(this)
7765
class(VirtualGwfModelType) :: this

src/Distributed/VirtualGwtModel.f90

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module VirtualGwtModelModule
88
implicit none
99
private
1010

11-
public :: add_virtual_gwt_model
11+
public :: register_virtual_gwt
1212

1313
type, extends(VirtualModelType) :: VirtualGwtModelType
1414
! DSP
@@ -32,7 +32,6 @@ module VirtualGwtModelModule
3232
type(VirtualIntType), pointer :: inmst => null()
3333
contains
3434
! public
35-
procedure :: create => vgwt_create
3635
procedure :: prepare_stage => vgwt_prepare_stage
3736
procedure :: destroy => vgwt_destroy
3837
! private
@@ -43,37 +42,26 @@ module VirtualGwtModelModule
4342

4443
contains
4544

46-
subroutine add_virtual_gwt_model(model_id, model_name, model)
45+
subroutine register_virtual_gwt(model_id, model_name, model)
4746
use VirtualDataListsModule, only: virtual_model_list
48-
integer(I4B) :: model_id !< global model id
49-
character(len=*) :: model_name !< model name
50-
class(NumericalModelType), pointer :: model !< the actual model (can be null() when remote)
47+
integer(I4B), intent(in) :: model_id !< global model id
48+
character(len=*), intent(in) :: model_name !< model name
49+
class(NumericalModelType), pointer, intent(inout) :: model !< the actual model (can be null() when remote)
5150
! local
5251
class(VirtualGwtModelType), pointer :: virtual_gwt_model
5352
class(*), pointer :: obj
5453

5554
allocate (virtual_gwt_model)
56-
call virtual_gwt_model%create(model_name, model_id, model)
55+
call virtual_gwt_model%VirtualModelType%create(model_name, model_id, model)
56+
virtual_gwt_model%container_type = VDC_GWTMODEL_TYPE
57+
58+
call virtual_gwt_model%allocate_data()
59+
call virtual_gwt_model%init_virtual_data()
5760

5861
obj => virtual_gwt_model
5962
call virtual_model_list%Add(obj)
6063

61-
end subroutine add_virtual_gwt_model
62-
63-
subroutine vgwt_create(this, name, id, model)
64-
class(VirtualGwtModelType) :: this
65-
character(len=*) :: name
66-
integer(I4B) :: id
67-
class(NumericalModelType), pointer :: model
68-
69-
! create base
70-
call this%VirtualModelType%create(name, id, model)
71-
this%container_type = VDC_GWTMODEL_TYPE
72-
73-
call this%allocate_data()
74-
call this%init_virtual_data()
75-
76-
end subroutine vgwt_create
64+
end subroutine register_virtual_gwt
7765

7866
subroutine init_virtual_data(this)
7967
class(VirtualGwtModelType) :: this

src/Distributed/VirtualPrtModel.f90

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ module VirtualPrtModelModule
77
implicit none
88
private
99

10-
public :: add_virtual_prt_model
10+
public :: register_virtual_prt
1111

1212
type, extends(VirtualModelType) :: VirtualPrtModelType
1313
contains
1414
! public
15-
procedure :: create => vprt_create
1615
procedure :: prepare_stage => vprt_prepare_stage
1716
procedure :: destroy => vprt_destroy
1817
! private
@@ -23,20 +22,12 @@ module VirtualPrtModelModule
2322

2423
contains
2524

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)
25+
subroutine register_virtual_prt(model_id, model_name, model)
26+
integer(I4B), intent(in) :: model_id !< global model id
27+
character(len=*), intent(in) :: model_name !< model name
28+
class(NumericalModelType), pointer, intent(inout) :: model !< the actual model (can be null() when remote)
3029
! 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
30+
end subroutine register_virtual_prt
4031

4132
subroutine init_virtual_data(this)
4233
class(VirtualPrtModelType) :: this

src/Distributed/VirtualSwfModel.f90

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ module VirtualSwfModelModule
77
implicit none
88
private
99

10-
public :: add_virtual_swf_model
10+
public :: register_virtual_swf
1111

1212
type, extends(VirtualModelType) :: VirtualSwfModelType
1313
contains
1414
! public
15-
procedure :: create => vswf_create
1615
procedure :: prepare_stage => vswf_prepare_stage
1716
procedure :: destroy => vswf_destroy
1817
! private
@@ -23,20 +22,12 @@ module VirtualSwfModelModule
2322

2423
contains
2524

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)
25+
subroutine register_virtual_swf(model_id, model_name, model)
26+
integer(I4B), intent(in) :: model_id !< global model id
27+
character(len=*), intent(in) :: model_name !< model name
28+
class(NumericalModelType), pointer, intent(inout) :: model !< the actual model (can be null() when remote)
3029
! 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
30+
end subroutine register_virtual_swf
4031

4132
subroutine init_virtual_data(this)
4233
class(VirtualSwfModelType) :: this

src/Model/Connection/GweInterfaceModel.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module GweInterfaceModelModule
4949
contains
5050

5151
!> @brief Create the interface model, analogously to what
52-
!< happens in gwe_cr
52+
!< happens in register_gwe
5353
subroutine gweifmod_cr(this, name, iout, gridConn)
5454
! -- modules
5555
use GweInputDataModule, only: gweshared_dat_cr

src/Model/Connection/GwfInterfaceModel.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module GwfInterfaceModelModule
4242
contains
4343

4444
!> @brief set up the interface model, analogously to what
45-
!< happens in gwf_cr
45+
!< happens in register_gwf
4646
subroutine gwfifm_cr(this, name, iout, gridConn)
4747
class(GwfInterfaceModelType) :: this !< the GWF interface model
4848
character(len=*), intent(in) :: name !< the interface model's name

src/Model/Connection/GwtInterfaceModel.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module GwtInterfaceModelModule
4545
contains
4646

4747
!> @brief Create the interface model, analogously to what
48-
!< happens in gwt_cr
48+
!< happens in register_gwt
4949
subroutine gwtifmod_cr(this, name, iout, gridConn)
5050
! -- dummy
5151
class(GwtInterfaceModelType) :: this !< the GWT interface model

src/Model/GroundWaterEnergy/gwe.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module GweModule
1919
implicit none
2020

2121
private
22-
public :: gwe_cr
22+
public :: register_gwe
2323
public :: GweModelType
2424
public :: CastAsGweModel
2525

@@ -92,7 +92,7 @@ module GweModule
9292

9393
!> @brief Create a new groundwater energy transport model object
9494
!<
95-
subroutine gwe_cr(filename, id, modelname)
95+
subroutine register_gwe(id, modelname, filename)
9696
! -- modules
9797
use ListsModule, only: basemodellist
9898
use BaseModelModule, only: AddBaseModelToList
@@ -103,9 +103,9 @@ subroutine gwe_cr(filename, id, modelname)
103103
use BudgetModule, only: budget_cr
104104
use GweInputDataModule, only: gweshared_dat_cr
105105
! -- dummy
106-
character(len=*), intent(in) :: filename !< input file
107106
integer(I4B), intent(in) :: id !< consecutive model number listed in mfsim.nam
108107
character(len=*), intent(in) :: modelname !< name of the model
108+
character(len=*), intent(in) :: filename !< input file
109109
! -- local
110110
integer(I4B) :: indis
111111
type(GweModelType), pointer :: this
@@ -137,7 +137,7 @@ subroutine gwe_cr(filename, id, modelname)
137137
!
138138
! -- Return
139139
return
140-
end subroutine gwe_cr
140+
end subroutine register_gwe
141141

142142
!> @brief Define packages of the GWE model
143143
!!

src/Model/GroundWaterFlow/gwf-mvr.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
! water, but this value decreases as the mover object consumes water from
4242
! it.
4343
!
44-
! 2. In gwf_cr create the mover package by calling the CR subroutine:
44+
! 2. In register_gwf create the mover package by calling the CR subroutine:
4545
!
4646
! call mvr_cr(this%mvr, this%name, this%inmvr, this%iout)
4747
!

0 commit comments

Comments
 (0)