read_output_settings_history Subroutine

subroutine read_output_settings_history(self, json)

Arguments

Type IntentOptional Attributes Name
class(type_input), intent(inout) :: self
type(json_file), intent(inout) :: json

Calls

proc~~read_output_settings_history~~CallsGraph proc~read_output_settings_history read_output_settings_history destroy destroy proc~read_output_settings_history->destroy get get proc~read_output_settings_history->get info info proc~read_output_settings_history->info print_error_message print_error_message proc~read_output_settings_history->print_error_message proc~configure_output_variables configure_output_variables proc~read_output_settings_history->proc~configure_output_variables proc~error_message error_message proc~read_output_settings_history->proc~error_message proc~join join proc~read_output_settings_history->proc~join to_string to_string proc~read_output_settings_history->to_string proc~configure_output_variables->destroy proc~configure_output_variables->proc~error_message interface~filter filter proc~configure_output_variables->interface~filter log_error log_error proc~error_message->log_error proc~filter_character_array filter_character_array interface~filter->proc~filter_character_array

Called by

proc~~read_output_settings_history~~CalledByGraph proc~read_output_settings_history read_output_settings_history proc~inout_read_output_settings inout_read_output_settings proc~inout_read_output_settings->proc~read_output_settings_history interface~inout_read_output_settings type_input%inout_read_output_settings interface~inout_read_output_settings->proc~inout_read_output_settings proc~initialize_type_input type_input%initialize_type_input proc~initialize_type_input->interface~inout_read_output_settings

Source Code

    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