subroutine read_output_settings_history(self, json)
implicit none
class(type_input), intent(inout) :: self
type(json_file), intent(inout) :: json
character(:), allocatable :: key
character(:), allocatable :: key_base
logical :: found
integer(int32) :: i
character(len=64), allocatable :: tmp_variable_names(:)
character(len=64), allocatable :: active_categories(:)
key = join([history_output, file_format])
call json%get(key, self%output_settings%history_output%file_format, found)
call json%print_error_message(output_unit)
if (.not. found) then
self%output_settings%history_output%file_format = "none"
else if (.not. any(valid_history_file_formats(:) == self%output_settings%history_output%file_format)) then
call json%destroy()
call error_message(905, c_opt=key)
end if
select case (self%output_settings%history_output%file_format)
case (valid_history_file_formats(2), valid_history_file_formats(3))
key = join([history_output, observation_type])
call json%get(key, self%output_settings%history_output%observation_type, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
else if (.not. any(valid_observation_types(:) == self%output_settings%history_output%observation_type)) then
call json%destroy()
call error_message(905, c_opt=key)
end if
key = join([history_output, output_interval, unit])
call json%get(key, self%output_settings%history_output%output_interval_unit, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
else if (.not. any(valid_units(:) == self%output_settings%history_output%output_interval_unit)) then
call json%destroy()
call error_message(905, c_opt=key)
end if
key = join([history_output, output_interval, value])
call json%get(key, self%output_settings%history_output%output_interval_step, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
else if (self%output_settings%history_output%output_interval_step <= 0) then
call json%destroy()
call error_message(905, c_opt=key)
end if
key = join([history_output, variables])
call json%get(key, tmp_variable_names, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
else if (size(tmp_variable_names) == 0) then
call json%destroy()
call error_message(905, c_opt=key)
else
active_categories = pack(variable_keys, mask=[self%basic%analysis_controls%calculate_thermal, &
any(self%basic%materials(:)%is_frozen), &
self%basic%analysis_controls%calculate_hydraulic])
call configure_output_variables(self%output_settings%history_output%variable_names, & ! 更新対象のリスト
tmp_variable_names, & ! 入力された変数名リスト
active_categories, & ! 有効なカテゴリ
json, & ! エラー処理用のjsonオブジェクト
key)
end if
select case (self%output_settings%history_output%observation_type)
case (valid_observation_types(1)) ! node_ids
key = join([history_output, valid_observation_types(1)])
call json%get(key, self%output_settings%history_output%node_ids, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
else if (size(self%output_settings%history_output%node_ids) == 0) then
call json%destroy()
call error_message(905, c_opt=key)
end if
self%output_settings%history_output%num_observations = size(self%output_settings%history_output%node_ids)
case (valid_observation_types(2)) ! coordinates
key = join([history_output, valid_observation_types(2)])
call json%info(key, found=found, n_children=self%output_settings%history_output%num_observations)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
else if (self%output_settings%history_output%num_observations <= 0) then
call json%destroy()
call error_message(905, c_opt=key)
end if
if (allocated(self%output_settings%history_output%coordinates)) then
deallocate (self%output_settings%history_output%coordinates)
end if
allocate (self%output_settings%history_output%coordinates(self%output_settings%history_output%num_observations))
do i = 1, self%output_settings%history_output%num_observations
key_base = join([history_output, valid_observation_types(2)//"("//to_string(i)//")"])
key = join([key_base, "x"])
call json%get(key, self%output_settings%history_output%coordinates(i)%x, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
end if
key = join([key_base, "y"])
call json%get(key, self%output_settings%history_output%coordinates(i)%y, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
end if
key = join([key_base, "z"])
call json%get(key, self%output_settings%history_output%coordinates(i)%z, found)
call json%print_error_message(output_unit)
if (.not. found) then
call json%destroy()
call error_message(904, c_opt=key)
end if
end do
end select
end select
end subroutine read_output_settings_history