@@ -35,7 +35,9 @@ module forcing_config_mod
35
35
procedure , pass(self), public :: init = > forcing_config_init
36
36
procedure , pass(self), public :: deinit = > forcing_config_deinit
37
37
procedure , pass(self), public :: parse = > forcing_config_parse
38
- procedure , pass(self), private :: parse_field = > forcing_config_parse_field
38
+ procedure , pass(self), private :: parse_input = > forcing_config_parse_input
39
+ procedure , pass(self), private :: parse_permutations = > &
40
+ forcing_config_parse_permutations
39
41
endtype forcing_config
40
42
41
43
contains
@@ -71,11 +73,11 @@ subroutine forcing_config_init(self, config, loggerin, num_fields)
71
73
end subroutine forcing_config_init
72
74
73
75
74
- ! > Parse forcing file into a dictionary.
75
- subroutine forcing_config_parse (self , fields , start_date , &
76
+ ! > Parse forcing file
77
+ subroutine forcing_config_parse (self , forcing_fields , start_date , &
76
78
num_land_fields , min_dt , calendar )
77
79
class(forcing_config), intent (inout ) :: self
78
- type (forcing_field), dimension (:), intent (inout ) :: fields
80
+ type (forcing_field), dimension (:), intent (inout ) :: forcing_fields
79
81
type (datetime), intent (in ) :: start_date
80
82
integer , intent (out ) :: min_dt, num_land_fields
81
83
character (len= 9 ), intent (out ) :: calendar
@@ -88,8 +90,8 @@ subroutine forcing_config_parse(self, fields, start_date, &
88
90
type (json_value), pointer :: root, inputs
89
91
logical :: found, is_land_field
90
92
91
- call assert(size (fields ) == self% num_inputs, &
92
- " Insufficient number of fields allocated." )
93
+ call assert(size (forcing_fields ) == self% num_inputs, &
94
+ " Insufficient number of forcing_fields allocated." )
93
95
94
96
call self% json% get(root)
95
97
call self% core% get_child(root, " inputs" , inputs, found)
@@ -104,7 +106,7 @@ subroutine forcing_config_parse(self, fields, start_date, &
104
106
do i= 1 , self% num_inputs
105
107
call self% core% get_child(inputs, i, input_jv_ptr, found)
106
108
call assert(found, " No inputs found in forcing config." )
107
- call self% parse_input(input_jv_ptr, fields (i), start_date, &
109
+ call self% parse_input(input_jv_ptr, forcing_fields (i), start_date, &
108
110
product_name, dt, calendar_str, is_land_field)
109
111
if (dt < min_dt) then
110
112
min_dt = dt
@@ -122,7 +124,7 @@ subroutine forcing_config_parse(self, fields, start_date, &
122
124
123
125
end subroutine forcing_config_parse
124
126
125
-
127
+ ! > Parse a single forcing input. This corresponds to a single coupling field.
126
128
subroutine forcing_config_parse_input (self , input_jv_ptr , field_ptr , &
127
129
start_date , product_name , dt , forcing_calendar , &
128
130
is_land_field )
@@ -136,34 +138,20 @@ subroutine forcing_config_parse_input(self, input_jv_ptr, field_ptr, &
136
138
character (len= 9 ), intent (out ) :: forcing_calendar
137
139
logical , intent (out ) :: is_land_field
138
140
139
- character (kind= CK, len= :), allocatable :: cname, fieldname, domain_str
140
- character (kind= CK, len= :), allocatable :: filename, perturbation_filename
141
- character (kind= CK, len= :), allocatable :: comment
142
- character (kind= CK, len= :), allocatable :: perturbation_type
143
- character (kind= CK, len= :), allocatable :: dimension_type
144
- character (kind= CK, len= :), allocatable :: perturbation_calendar
145
-
141
+ character (kind= CK, len= :), allocatable :: cname, realm_str
142
+ character (kind= CK, len= :), allocatable :: filename, fieldname
146
143
character (len= 256 ), dimension (:), allocatable :: fieldname_list, filename_list
147
-
148
- integer :: num_fieldnames, num_filenames
149
- integer :: perturbation_constant_value
150
- logical :: found, domain_found
151
- integer :: num_perturbations, num_fields
144
+ integer :: num_input_fields
145
+ logical :: found
152
146
integer :: i, j
153
147
154
- type (json_value), pointer :: input_field_jv_list,
155
- type (json_value), pointer :: fieldname_jv_list, filename_jv_list
156
- type (json_value), pointer :: fieldname_jv_ptr, filename_jv_ptr
157
- type (json_value), pointer :: perturbation_jv_ptr
158
- type (json_value), pointer :: dimension_jv_ptr, value_jv_ptr
159
- type (json_value), pointer :: perturbation_list, dimension_list
160
- type (json_value), pointer :: value_list
148
+ type (json_value), pointer :: input_field_jv_list, input_field_jv_ptr
161
149
162
150
call self% core% get(input_jv_ptr, " coupling_field_name" , cname, found)
163
151
call assert(found, " Entry 'coupling_field_name' not found in forcing config." )
164
152
165
- call self% core% get(input_jv_ptr, " realm" , realm_str, realm_found )
166
- if (realm_found ) then
153
+ call self% core% get(input_jv_ptr, " realm" , realm_str, found )
154
+ if (found ) then
167
155
call assert(realm_str == " land" .or. realm_str == " atmosphere" , &
168
156
" forcing_parse_field: invalid domain value." )
169
157
else
@@ -176,6 +164,7 @@ subroutine forcing_config_parse_input(self, input_jv_ptr, field_ptr, &
176
164
endif
177
165
178
166
! Each coupling field can have multiple input fields associated with it.
167
+ ! The YATM code can combine these as it sees fit.
179
168
call self% core% get_child(input_jv_ptr, " input_fields" , &
180
169
input_field_jv_list, found)
181
170
num_input_fields = self% core% count (input_field_jv_list)
@@ -185,26 +174,44 @@ subroutine forcing_config_parse_input(self, input_jv_ptr, field_ptr, &
185
174
186
175
call self% core% get(input_field_jv_ptr, " filename" , filename, found)
187
176
call assert(found, " Expected to find filename entry." )
188
- filedame_list (i) = trim (filename)
177
+ filename_list (i) = trim (filename)
189
178
190
179
call self% core% get(input_field_jv_ptr, " fieldname" , fieldname, found)
191
180
call assert(found, " Expected to find fieldname entry." )
192
181
fieldname_list(i) = trim (fieldname)
193
182
194
- self % parse_permutations()
195
-
183
+ ! Each input field can have a number of permutations.
184
+ call self % parse_permutations(input_field_jv_ptr, field_ptr, fieldname)
196
185
enddo
197
186
198
187
call field_ptr% init(fieldname_list, filename_list, cname, realm_str, start_date, &
199
188
product_name, self% logger, dt, forcing_calendar)
200
189
190
+ end subroutine forcing_config_parse_input
201
191
202
192
203
- end subroutine forcing_config_parse_field
193
+ subroutine forcing_config_parse_permutations ( self , field_jv_ptr , field_ptr , fieldname )
204
194
195
+ class(forcing_config), intent (inout ) :: self
196
+ type (json_value), pointer :: field_jv_ptr
197
+ type (forcing_field) :: field_ptr
198
+ character (len=* ) :: fieldname
199
+
200
+ integer :: perturbation_constant_value
201
+ logical :: found
202
+ integer :: num_perturbations, num_fields
203
+ integer :: i, j
205
204
206
- subroutine forcing_config_parse_permutations (self )
205
+ type (json_value), pointer :: perturbation_jv_ptr
206
+ type (json_value), pointer :: dimension_jv_ptr, value_jv_ptr
207
+ type (json_value), pointer :: perturbation_list, dimension_list
208
+ type (json_value), pointer :: value_list
207
209
210
+ character (kind= CK, len= :), allocatable :: filename, perturbation_filename
211
+ character (kind= CK, len= :), allocatable :: comment
212
+ character (kind= CK, len= :), allocatable :: perturbation_type
213
+ character (kind= CK, len= :), allocatable :: dimension_type
214
+ character (kind= CK, len= :), allocatable :: perturbation_calendar
208
215
209
216
call self% core% get_child(field_jv_ptr, " perturbations" , perturbation_list, found)
210
217
if (.not. found) then
@@ -371,8 +378,7 @@ subroutine forcing_config_parse_permutations(self)
371
378
endif
372
379
enddo
373
380
374
-
375
- end subroutine forcing_config_parse_permutations (self)
381
+ end subroutine forcing_config_parse_permutations
376
382
377
383
378
384
subroutine forcing_config_deinit (self )
0 commit comments