Skip to content

Commit 4bd0578

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 4bd0578

File tree

23 files changed

+238
-566
lines changed

23 files changed

+238
-566
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@
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"/>
108104
<File RelativePath="..\src\Distributed\VirtualModel.f90"/>
109105
<File RelativePath="..\src\Distributed\VirtualSolution.f90"/></Filter>
110106
<Filter Name="Idm">
@@ -536,6 +532,7 @@
536532
<File RelativePath="..\src\mf6lists.f90"/>
537533
<File RelativePath="..\src\RunControl.f90"/>
538534
<File RelativePath="..\src\ModelFactory.f90"/>
535+
<File RelativePath="..\src\ModelRegistrar.f90"/>
539536
<File RelativePath="..\src\ExchangeFactory.f90"/>
540537
<File RelativePath="..\src\RunControlFactory.F90">
541538
<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/VirtualPrtExchange.f90

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/Distributed/VirtualPrtModel.f90

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)