output_system_logger.F90 Source File


This file depends on

sourcefile~~output_system_logger.f90~~EfferentGraph sourcefile~output_system_logger.f90 output_system_logger.F90 sourcefile~output_interface.f90 output_interface.F90 sourcefile~output_system_logger.f90->sourcefile~output_interface.f90 sourcefile~control.f90 control.F90 sourcefile~output_interface.f90->sourcefile~control.f90 sourcefile~core.f90 core.F90 sourcefile~output_interface.f90->sourcefile~core.f90 sourcefile~domain.f90 domain.F90 sourcefile~output_interface.f90->sourcefile~domain.f90 sourcefile~input.f90 input.F90 sourcefile~output_interface.f90->sourcefile~input.f90 sourcefile~matrix.f90 matrix.F90 sourcefile~output_interface.f90->sourcefile~matrix.f90 sourcefile~project_settings.f90 project_settings.F90 sourcefile~output_interface.f90->sourcefile~project_settings.f90 sourcefile~properties.f90 properties.F90 sourcefile~output_interface.f90->sourcefile~properties.f90 sourcefile~iteration.f90 iteration.F90 sourcefile~control.f90->sourcefile~iteration.f90 sourcefile~time.f90 time.F90 sourcefile~control.f90->sourcefile~time.f90 sourcefile~allocate.f90 allocate.F90 sourcefile~core.f90->sourcefile~allocate.f90 sourcefile~check_range.f90 check_range.F90 sourcefile~core.f90->sourcefile~check_range.f90 sourcefile~deallocate.f90 deallocate.F90 sourcefile~core.f90->sourcefile~deallocate.f90 sourcefile~error.f90 error.F90 sourcefile~core.f90->sourcefile~error.f90 sourcefile~fortran_utils.f90 fortran_utils.F90 sourcefile~core.f90->sourcefile~fortran_utils.f90 sourcefile~string_utils.f90 string_utils.F90 sourcefile~core.f90->sourcefile~string_utils.f90 sourcefile~types.f90 types.F90 sourcefile~core.f90->sourcefile~types.f90 sourcefile~unique.f90 unique.F90 sourcefile~core.f90->sourcefile~unique.f90 sourcefile~vtk.f90 vtk.F90 sourcefile~core.f90->sourcefile~vtk.f90 sourcefile~vtk_constants.f90 vtk_constants.F90 sourcefile~core.f90->sourcefile~vtk_constants.f90 sourcefile~adjacency.f90 adjacency.F90 sourcefile~domain.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90 domain_manager.F90 sourcefile~domain.f90->sourcefile~domain_manager.f90 sourcefile~element.f90 element.F90 sourcefile~domain.f90->sourcefile~element.f90 sourcefile~element_factory.f90 element_factory.F90 sourcefile~domain.f90->sourcefile~element_factory.f90 sourcefile~multicoloring.f90 multicoloring.F90 sourcefile~domain.f90->sourcefile~multicoloring.f90 sourcefile~reordering.f90 reordering.F90 sourcefile~domain.f90->sourcefile~reordering.f90 sourcefile~side.f90 side.F90 sourcefile~domain.f90->sourcefile~side.f90 sourcefile~side_factory.f90 side_factory.F90 sourcefile~domain.f90->sourcefile~side_factory.f90 sourcefile~input_interface.f90 input_interface.F90 sourcefile~input.f90->sourcefile~input_interface.f90 sourcefile~matrix_base.f90 matrix_base.F90 sourcefile~matrix.f90->sourcefile~matrix_base.f90 sourcefile~matrix_coo.f90 matrix_coo.F90 sourcefile~matrix.f90->sourcefile~matrix_coo.f90 sourcefile~matrix_crs.f90 matrix_crs.F90 sourcefile~matrix.f90->sourcefile~matrix_crs.f90 sourcefile~matrix_dense.f90 matrix_dense.F90 sourcefile~matrix.f90->sourcefile~matrix_dense.f90 sourcefile~project_settings.f90->sourcefile~core.f90 sourcefile~materials_manager.f90 materials_manager.F90 sourcefile~properties.f90->sourcefile~materials_manager.f90 sourcefile~properties_manager.f90 properties_manager.F90 sourcefile~properties.f90->sourcefile~properties_manager.f90 sourcefile~adjacency_element.f90 adjacency_element.F90 sourcefile~adjacency.f90->sourcefile~adjacency_element.f90 sourcefile~adjacency_node.f90 adjacency_node.F90 sourcefile~adjacency.f90->sourcefile~adjacency_node.f90 sourcefile~allocate.f90->sourcefile~error.f90 sourcefile~deallocate.f90->sourcefile~error.f90 sourcefile~domain_manager.f90->sourcefile~core.f90 sourcefile~domain_manager.f90->sourcefile~input.f90 sourcefile~domain_manager.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90->sourcefile~element.f90 sourcefile~domain_manager.f90->sourcefile~element_factory.f90 sourcefile~domain_manager.f90->sourcefile~multicoloring.f90 sourcefile~domain_manager.f90->sourcefile~reordering.f90 sourcefile~domain_manager.f90->sourcefile~side.f90 sourcefile~domain_manager.f90->sourcefile~side_factory.f90 sourcefile~element.f90->sourcefile~core.f90 sourcefile~element.f90->sourcefile~input.f90 sourcefile~element_factory.f90->sourcefile~core.f90 sourcefile~element_factory.f90->sourcefile~input.f90 sourcefile~element_factory.f90->sourcefile~element.f90 sourcefile~memory_stats_wrapper.f90 memory_stats_wrapper.F90 sourcefile~fortran_utils.f90->sourcefile~memory_stats_wrapper.f90 sourcefile~signal_flag_wrapper.f90 signal_flag_wrapper.F90 sourcefile~fortran_utils.f90->sourcefile~signal_flag_wrapper.f90 sourcefile~system_info_wrapper.f90 system_info_wrapper.F90 sourcefile~fortran_utils.f90->sourcefile~system_info_wrapper.f90 sourcefile~input_interface.f90->sourcefile~core.f90 sourcefile~input_interface.f90->sourcefile~project_settings.f90 sourcefile~materials_manager.f90->sourcefile~input.f90 sourcefile~calculate.f90 calculate.F90 sourcefile~materials_manager.f90->sourcefile~calculate.f90 sourcefile~matrix_base.f90->sourcefile~domain.f90 sourcefile~matrix_coo.f90->sourcefile~core.f90 sourcefile~matrix_coo.f90->sourcefile~domain.f90 sourcefile~matrix_coo.f90->sourcefile~matrix_base.f90 sourcefile~matrix_crs.f90->sourcefile~core.f90 sourcefile~matrix_crs.f90->sourcefile~domain.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_base.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_coo.f90 sourcefile~matrix_dense.f90->sourcefile~core.f90 sourcefile~matrix_dense.f90->sourcefile~domain.f90 sourcefile~matrix_dense.f90->sourcefile~matrix_base.f90 sourcefile~multicoloring.f90->sourcefile~core.f90 sourcefile~multicoloring.f90->sourcefile~adjacency_element.f90 sourcefile~properties_manager.f90->sourcefile~core.f90 sourcefile~properties_manager.f90->sourcefile~input.f90 sourcefile~properties_manager.f90->sourcefile~materials_manager.f90 sourcefile~properties_manager.f90->sourcefile~calculate.f90 sourcefile~reordering.f90->sourcefile~core.f90 sourcefile~reordering.f90->sourcefile~element.f90 sourcefile~reordering.f90->sourcefile~adjacency_node.f90 sourcefile~side.f90->sourcefile~core.f90 sourcefile~side.f90->sourcefile~input.f90 sourcefile~side_factory.f90->sourcefile~core.f90 sourcefile~side_factory.f90->sourcefile~input.f90 sourcefile~side_factory.f90->sourcefile~side.f90 sourcefile~string_utils.f90->sourcefile~allocate.f90 sourcefile~time.f90->sourcefile~core.f90 sourcefile~time.f90->sourcefile~input.f90 sourcefile~array.f90 array.F90 sourcefile~types.f90->sourcefile~array.f90 sourcefile~gauss.f90 gauss.F90 sourcefile~types.f90->sourcefile~gauss.f90 sourcefile~pointer.f90 pointer.F90 sourcefile~types.f90->sourcefile~pointer.f90 sourcefile~variable.f90 variable.F90 sourcefile~types.f90->sourcefile~variable.f90 sourcefile~vector.f90 vector.F90 sourcefile~types.f90->sourcefile~vector.f90 sourcefile~unique.f90->sourcefile~allocate.f90 sourcefile~vtk.f90->sourcefile~allocate.f90 sourcefile~vtk.f90->sourcefile~deallocate.f90 sourcefile~vtk.f90->sourcefile~unique.f90 sourcefile~vtk.f90->sourcefile~vtk_constants.f90 sourcefile~vtk.f90->sourcefile~array.f90 sourcefile~vtk_wrapper.f90 vtk_wrapper.F90 sourcefile~vtk.f90->sourcefile~vtk_wrapper.f90 sourcefile~vtu_wrapper.f90 vtu_wrapper.F90 sourcefile~vtk.f90->sourcefile~vtu_wrapper.f90 sourcefile~adjacency_element.f90->sourcefile~core.f90 sourcefile~adjacency_element.f90->sourcefile~element.f90 sourcefile~adjacency_node.f90->sourcefile~core.f90 sourcefile~array.f90->sourcefile~allocate.f90 sourcefile~array.f90->sourcefile~deallocate.f90 sourcefile~density_interface.f90 density_interface.F90 sourcefile~calculate.f90->sourcefile~density_interface.f90 sourcefile~gcc_interface.f90 gcc_interface.F90 sourcefile~calculate.f90->sourcefile~gcc_interface.f90 sourcefile~heat_capacity_interface.f90 heat_capacity_interface.F90 sourcefile~calculate.f90->sourcefile~heat_capacity_interface.f90 sourcefile~specific_heat_interface.f90 specific_heat_interface.F90 sourcefile~calculate.f90->sourcefile~specific_heat_interface.f90 sourcefile~thermal_conductivity_interface.f90 thermal_conductivity_interface.F90 sourcefile~calculate.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~c_utils.f90 c_utils.F90 sourcefile~memory_stats_wrapper.f90->sourcefile~c_utils.f90 sourcefile~signal_flag.f90 signal_flag.F90 sourcefile~signal_flag_wrapper.f90->sourcefile~signal_flag.f90 sourcefile~system_info_wrapper.f90->sourcefile~c_utils.f90 sourcefile~variable.f90->sourcefile~allocate.f90 sourcefile~c_utils.f90->sourcefile~signal_flag.f90 sourcefile~memory_stats.f90 memory_stats.F90 sourcefile~c_utils.f90->sourcefile~memory_stats.f90 sourcefile~system_info.f90 system_info.F90 sourcefile~c_utils.f90->sourcefile~system_info.f90 sourcefile~density_interface.f90->sourcefile~core.f90 sourcefile~density_interface.f90->sourcefile~input.f90 sourcefile~gcc_interface.f90->sourcefile~input.f90 sourcefile~heat_capacity_interface.f90->sourcefile~core.f90 sourcefile~heat_capacity_interface.f90->sourcefile~input_interface.f90 sourcefile~heat_capacity_interface.f90->sourcefile~density_interface.f90 sourcefile~specific_heat_interface.f90->sourcefile~core.f90 sourcefile~specific_heat_interface.f90->sourcefile~input.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~core.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~input.f90

Source Code

submodule(input_output) input_output_system_logger
    implicit none
contains
    module subroutine output_system_log(self, time, Matrix, domain)
        implicit none
        class(type_output), intent(inout) :: self
        type(type_time), intent(in) :: time
        type(Type_CRS), intent(in) :: Matrix
        type(type_domain), intent(inout) :: domain

        character(:), allocatable :: username
        character(:), allocatable :: hostname
        character(:), allocatable :: compiler
        character(:), allocatable :: compiler_version
        character(:), allocatable :: architecture
        character(:), allocatable :: os
!$      character(:), allocatable :: openmp_version
!$      integer(int32) :: max_threads
!$      integer(int32) :: num_threads
        integer(int32) :: num_unit, ios
        integer(int64) :: rss_kb
        real(real64) :: rss_mb

        integer(int32) :: i
        real(real64) :: component_total_time ! 「Total」を除いた合計時間
        real(real64) :: total_section_time ! 「Total」セクションの時間
        integer(int32), parameter :: nRepeat = 50

        character(len=32) :: fmt
        integer(int32) :: width

        ! 保険として初期化
        fmt = ''

        username = get_username()
        hostname = get_hostname()
        compiler = get_compiler_name()
        compiler_version = get_compiler_version()
        architecture = get_cpu_architecture()
        os = get_os()
!$      openmp_version = get_openmp_version()
!$      max_threads = omp_get_num_procs()
!$      num_threads = omp_get_max_threads()

        rss_mb = get_memory_usage()
        ! 幅の計算。log10(0) の回避と最小幅保証
        width = max(6, int(log10(max(1.0d0, rss_mb))) + 6)
        ! フォーマット文字列の構築
        write (fmt, '(a,i0,a)') '(a,f', width, '.4,a)'

        open (newunit=num_unit, file=self%log_file_name, status='replace', action='write', iostat=ios)
        if (ios /= 0) then
            write (*, *) "Error opening log file: ", self%log_file_name
            stop
        end if
        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a)') "FTDSS System Log" !&
        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a)') "Username           : "//trim(username) !&
        write (num_unit, '(a)') "Hostname           : "//trim(hostname) !&
        write (num_unit, '(a)') "OS                 : "//trim(os) !&
        write (num_unit, '(a)') "Architecture       : "//trim(architecture) !&
        write (num_unit, '(a)') "Compiler           : "//trim(compiler) !&
        write (num_unit, '(a)') "Compiler Version   : "//trim(compiler_version) !&
        write (num_unit, fmt)   "RSS Memory Usage   : ", rss_mb, " MB" !&
!$      write (num_unit, '(a)') "OpenMP Version     : "//trim(openmp_version) !&
!$      write (num_unit, '(a)') "OpenMP Max Threads : "//trim(to_string(max_threads)) !&
!$      write (num_unit, '(a)') "OpenMP Threads     : "//trim(to_string(num_threads)) !&
        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a)') "Time Information" !&
        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a)') trim(time%start%label)//" Time : "//time%start%date(1:4)//"-"//time%start%date(5:6)//"-"//time%start%date(7:8)//"T"//time%start%time(1:2)//":"//time%start%time(3:4)//":"//time%start%time(5:6)//trim(time%start%zone)
        write (num_unit, '(a)') trim(time%end%label)//" Time   : "//time%end%date(1:4)//"-"//time%end%date(5:6)//"-"//time%end%date(7:8)//"T"//time%end%time(1:2)//":"//time%end%time(3:4)//":"//time%end%time(5:6)//trim(time%end%zone)

        component_total_time = 0.0d0
        total_section_time = 0.0d0

        ! --- 先に合計を計算 ---
        do i = 1, size(time%sections)
            ! 'Total'セクションは別で保持し、部品の合計からは除外する
            if (trim(adjustl(time%sections(i)%label)) == "Total") then
                total_section_time = time%sections(i)%total_time
            else
                component_total_time = component_total_time + time%sections(i)%total_time
            end if
        end do

        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a)') "Performance Profiling Report"
        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a10, a15, a15)') "Section", "Time (sec)", "Percentage"
        write (num_unit, '(a)') repeat('-', nRepeat)

        ! --- 各セクションの結果を出力 ---
        do i = 1, size(time%sections)
            if (trim(adjustl(time%sections(i)%label)) == "Total") cycle

            if (component_total_time > 0.0d0) then
                write (num_unit, '(a10, f15.4, f14.4, a)') trim(time%sections(i)%label), &
                    time%sections(i)%total_time, &
                    (time%sections(i)%total_time / component_total_time) * 100.0d0, " %"
            else
                write (num_unit, '(a10, f15.4, a)') trim(time%sections(i)%label), time%sections(i)%total_time, " (N/A %)"
            end if
        end do

        write (num_unit, '(a)') repeat('-', nRepeat)

        ! 'Total'セクションが計測されていれば、それも表示
        if (total_section_time > 0.0d0) then
            write (num_unit, '(a10, f15.4, a)') "Total", total_section_time, ""
        else
            write (num_unit, '(a10, f15.4, a)') "Total", component_total_time, ""
        end if

        write (num_unit, '(a)') repeat('=', nRepeat)
        write (num_unit, '(a)') "Matrix Information"
        write (num_unit, '(a)') repeat('-', nRepeat)
        write (num_unit, '(a)') "Matrix type : CRS"
        write (num_unit, '(a,i0)') "Matrix size : ", Matrix%num_row
        write (num_unit, '(a,i0)') "Matrix nnz  : ", Matrix%nnz
        write (num_unit, '(a)') repeat('-', nRepeat)
        write (num_unit, '(a,i0)') "Coloring Count : ", Domain%Colors%num_colors
        write (num_unit, '(a)') repeat('=', nRepeat)

        close (num_unit)
    end subroutine output_system_log

end submodule input_output_system_logger