@@ -133,13 +133,14 @@ subroutine forcing_config_parse_field(self, field_jv_ptr, field_ptr, &
133133
134134 character (kind= CK, len= :), allocatable :: cname, fieldname, domain_str
135135 character (kind= CK, len= :), allocatable :: filename, perturbation_filename
136+ character (kind= CK, len= :), allocatable :: comment
136137 character (kind= CK, len= :), allocatable :: perturbation_type
137138 character (kind= CK, len= :), allocatable :: dimension_type
138139 character (kind= CK, len= :), allocatable :: perturbation_calendar
139140
140141 integer :: perturbation_constant_value
141142 logical :: found, domain_found
142- integer :: num_perturbations
143+ integer :: num_perturbations, num_fields
143144 integer :: i, j
144145
145146 type (json_value), pointer :: perturbation_jv_ptr
@@ -302,16 +303,22 @@ subroutine forcing_config_parse_field(self, field_jv_ptr, field_ptr, &
302303 endif
303304 endif
304305
306+ num_fields = self% core% count (perturbation_jv_ptr)
305307 call self% core% get(perturbation_jv_ptr, " calendar" , &
306308 perturbation_calendar, found)
309+ ! Calendar is optional for dimension 'constant'
307310 if (.not. found) then
308311 call assert(field_ptr% perturbations(i)% dimension_type == &
309312 FORCING_PERTURBATION_DIMENSION_CONSTANT, &
310313 " forcing_parse_field: missing calendar type" )
314+ call assert(num_fields == 4 , ' forcing_parse_field: wrong number of fields' // &
315+ ' in perturbation definition, should be 4.' )
311316 else
312317 call assert(trim (perturbation_calendar) == ' forcing' .or. &
313318 trim (perturbation_calendar) == ' experiment' , &
314319 " forcing_parse_field: invalid perturbation calendar type" )
320+ call assert(num_fields == 5 , ' forcing_parse_field: wrong number of fields' // &
321+ ' in perturbation definition, should be 5.' )
315322 if (trim (perturbation_calendar) == ' forcing' ) then
316323 field_ptr% perturbations(i)% calendar = &
317324 FORCING_PERTURBATION_CALENDAR_FORCING
@@ -321,6 +328,10 @@ subroutine forcing_config_parse_field(self, field_jv_ptr, field_ptr, &
321328 endif
322329 endif
323330
331+ call self% core% get(perturbation_jv_ptr, " comment" , &
332+ comment, found)
333+ call assert(found, ' forcing_parse_field: perturbation missing "comment" field' )
334+
324335 call field_ptr% perturbations(i)% init()
325336 if (field_ptr% separated_perturbations(i)% valid) then
326337 call field_ptr% separated_perturbations(i)% init()
0 commit comments