@@ -86,37 +86,57 @@ module tuvx_core
86
86
end type core_t
87
87
88
88
interface core_t
89
- module procedure constructor
89
+ module procedure constructor_file_path, constructor_config
90
90
end interface core_t
91
91
92
92
contains
93
93
94
94
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
95
95
96
- function constructor ( config , grids , profiles , radiators ) result( new_core )
97
- ! Constructor of TUV-x core objects
96
+ function constructor_file_path ( config_file_path , grids , profiles , &
97
+ radiators ) result( new_core )
98
+ ! Constructor of TUV-x core objects from a configuration file
99
+
100
+ use musica_string, only : string_t
101
+
102
+ type (string_t), intent (in ) :: config_file_path ! Path to TUV-x configuration file
103
+ class(grid_warehouse_t), optional , intent (in ) :: grids ! Set of grids to include in the configuration
104
+ class(profile_warehouse_t), optional , intent (in ) :: profiles ! Set of profiles to include in the configuration
105
+ class(radiator_warehouse_t), optional , intent (in ) :: radiators ! Set of radiators to include in the configuration
106
+ class(core_t), pointer :: new_core
107
+
108
+ type (config_t) :: config
109
+
110
+ call config% from_file( config_file_path% to_char() )
111
+ new_core = > constructor_config( config, grids, profiles, radiators )
112
+
113
+ end function constructor_file_path
114
+
115
+ ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
116
+
117
+ function constructor_config ( config , grids , profiles , radiators ) &
118
+ result( new_core )
119
+ ! Constructor of TUV-x core objects from a configuration object
98
120
99
121
use musica_assert, only : assert_msg
100
122
use musica_string, only : string_t
101
123
use tuvx_diagnostic_util, only : diagout
102
124
use tuvx_profile, only : profile_t
103
125
use tuvx_radiator_warehouse, only : radiator_warehouse_t
104
126
105
- type (string_t ), intent (in ) :: config ! Full TUV-x configuration data
106
- class(grid_warehouse_t), optional , intent (in ) :: grids ! Set of grids to include in the configuration
107
- class(profile_warehouse_t), optional , intent (in ) :: profiles ! Set of profiles to include in the configuration
108
- class(radiator_warehouse_t), optional , intent (in ) :: radiators ! Set of radiators to include in the configuration
109
- class(core_t), pointer :: new_core
127
+ type (config_t ), intent (inout ) :: config ! Full TUV-x configuration data
128
+ class(grid_warehouse_t), optional , intent (in ) :: grids ! Set of grids to include in the configuration
129
+ class(profile_warehouse_t), optional , intent (in ) :: profiles ! Set of profiles to include in the configuration
130
+ class(radiator_warehouse_t), optional , intent (in ) :: radiators ! Set of radiators to include in the configuration
131
+ class(core_t), pointer :: new_core
110
132
111
133
! Local variables
112
134
character (len=* ), parameter :: Iam = ' Photolysis core constructor: '
113
135
logical :: found
114
- type (config_t) :: core_config, child_config
136
+ type (config_t) :: child_config
115
137
class(profile_t), pointer :: aprofile
116
138
type (string_t) :: required_keys(4 ), optional_keys(3 )
117
139
118
- call core_config% from_file( config% to_char() )
119
-
120
140
! Check json configuration file for basic structure, integrity
121
141
required_keys(1 ) = " radiative transfer"
122
142
required_keys(2 ) = " grids"
@@ -126,22 +146,22 @@ function constructor( config, grids, profiles, radiators ) result( new_core )
126
146
optional_keys(2 ) = " dose rates"
127
147
optional_keys(3 ) = " enable diagnostics"
128
148
call assert_msg( 255400232 , &
129
- core_config % validate( required_keys, optional_keys ), &
149
+ config % validate( required_keys, optional_keys ), &
130
150
" Bad configuration data format for tuv-x core." )
131
151
132
152
! Instantiate photolysis core
133
153
allocate ( new_core )
134
154
135
- call core_config % get( ' enable diagnostics' , new_core% enable_diagnostics_, &
155
+ call config % get( ' enable diagnostics' , new_core% enable_diagnostics_, &
136
156
Iam, default= .false. )
137
157
138
158
! Instantiate and initialize grid warehouse
139
- call core_config % get( " grids" , child_config, Iam )
159
+ call config % get( " grids" , child_config, Iam )
140
160
new_core% grid_warehouse_ = > grid_warehouse_t( child_config )
141
161
if ( present ( grids ) ) call new_core% grid_warehouse_% add( grids )
142
162
143
163
! Instantiate and initialize profile warehouse
144
- call core_config % get( " profiles" , child_config, Iam )
164
+ call config % get( " profiles" , child_config, Iam )
145
165
new_core% profile_warehouse_ = > &
146
166
profile_warehouse_t( child_config, new_core% grid_warehouse_ )
147
167
if ( present ( profiles ) ) call new_core% profile_warehouse_% add( profiles )
@@ -166,16 +186,15 @@ function constructor( config, grids, profiles, radiators ) result( new_core )
166
186
end if
167
187
168
188
! Set up radiative transfer calculator
169
- call core_config % get( " radiative transfer" , child_config, Iam )
189
+ call config % get( " radiative transfer" , child_config, Iam )
170
190
new_core% radiative_transfer_ = > &
171
191
radiative_transfer_t( child_config, &
172
192
new_core% grid_warehouse_, &
173
193
new_core% profile_warehouse_, &
174
194
radiators )
175
195
176
196
! photolysis rate constants
177
- call core_config% get( " photolysis" , child_config, Iam, &
178
- found = found )
197
+ call config% get( " photolysis" , child_config, Iam, found = found )
179
198
if ( found ) then
180
199
new_core% photolysis_rates_ = > &
181
200
photolysis_rates_t( child_config, &
@@ -187,7 +206,7 @@ function constructor( config, grids, profiles, radiators ) result( new_core )
187
206
end if
188
207
189
208
! dose rates
190
- call core_config % get( " dose rates" , child_config, Iam, found = found )
209
+ call config % get( " dose rates" , child_config, Iam, found = found )
191
210
if ( found ) then
192
211
new_core% dose_rates_ = > &
193
212
dose_rates_t( child_config, new_core% grid_warehouse_, &
@@ -199,13 +218,13 @@ function constructor( config, grids, profiles, radiators ) result( new_core )
199
218
spherical_geometry_t( new_core% grid_warehouse_ )
200
219
201
220
! instantiate and initialize lyman alpha, srb type
202
- call core_config % get( " O2 absorption" , child_config, Iam )
221
+ call config % get( " O2 absorption" , child_config, Iam )
203
222
new_core% la_sr_bands_ = > la_sr_bands_t( child_config, &
204
223
new_core% grid_warehouse_, &
205
224
new_core% profile_warehouse_ )
206
225
207
226
208
- end function constructor
227
+ end function constructor_config
209
228
210
229
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
211
230
0 commit comments