gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dc_clock::dcclockresult Interface Reference

Public Member Functions

subroutine dcclockresult0 (clks, unit, total_auto, clk_total, total_name, err)

Detailed Description

Definition at line 152 of file dc_clock.f90.

Member Function/Subroutine Documentation

◆ dcclockresult0()

subroutine dc_clock::dcclockresult::dcclockresult0 ( type(clock), dimension(:), intent(in) clks,
integer, intent(in), optional unit,
logical, intent(in), optional total_auto,
type(clock), intent(in), optional clk_total,
character(*), intent(in), optional total_name,
logical, intent(out), optional err )

Display CPU time summary

Displays the total CPU time summary. Pass an array of CLOCK variables to clks. This is intended to be called at the end of the program. Specify the output unit number in unit. If unit is not given, output goes to standard output.

If total_auto is .true., the sum of all clks is automatically displayed. If clk_total is given, it takes precedence.

If clk_total is given, this CLOCK variable is displayed as the total.

If total_name is given, this string is output at the beginning of the summary.

If any clk in clks has not been initialized by DCClockCreate, an error is raised. If err is provided, .true. is returned in err and the program continues.

Parameters
[in]clksArray of CLOCK type variables
[in]unitOutput unit number (optional). Default: standard output.
[in]total_autoIf .true., automatically display sum of all clks (optional)
[in]clk_totalCLOCK variable to display as total (optional)
[in]total_nameString to output at the beginning of summary (optional)
[out]errError flag (optional). .true. if error occurred.

Definition at line 716 of file dc_clock.f90.

717 use dc_types, only: stdout, string, dp
718 use dc_message, only: messagenotify
719 use dc_string, only: printf, tochar, cprintf
720 use dc_date, only: evalsec
722 implicit none
723 type(CLOCK), intent(in):: clks(:)
724 integer, intent(in), optional:: unit
725 logical, intent(in), optional:: total_auto
726 type(CLOCK), intent(in), optional:: clk_total
727 logical, intent(out), optional:: err
728 character(*), intent(in), optional:: total_name
729 integer:: out_unit, i, clks_size, ra
730 character(20):: clk_name
731 integer:: name_len
732 character(STRING):: cause_c
733 character(STRING):: total_name_work
734 type(CLOCK):: clk_auto_total
735 logical:: total_print_complete
736 real(DP):: elapsed_time_val_cor
737 integer:: stat
738 character(*), parameter:: total_time_mes = ' TOTAL TIME = '
739 logical:: initflag_mpi
740 integer:: err_mpi
741 integer:: myrank_mpi, nprocs_mpi
742 character(*), parameter:: subname = 'DCClockResult'
743 continue
744 call beginsub(subname)
745 stat = dc_noerr
746 cause_c = 'CLOCK'
747 clks_size = size(clks)
748 do i = 1, clks_size
749 if (.not. clks(i) % initialized) then
750 call messagenotify('W', subname, 'Call Create before Result in dc_clock.')
751 call dbgmessage('Ignored because input argument was not initialized.')
752 stat = dc_enotinit
753 goto 999
754 end if
755 end do
756 if (present(unit)) then
757 out_unit = unit
758 else
759 out_unit = stdout
760 end if
761 if (present(total_name)) then
762 total_name_work = ' (' // trim(total_name) // ')'
763 else
764 total_name_work = ''
765 end if
766 myrank_mpi = -1
767 nprocs_mpi = 1
768 call mpi_initialized(initflag_mpi, err_mpi)
769 if ( initflag_mpi ) then
770 call mpi_comm_rank(mpi_comm_world, myrank_mpi, err_mpi)
771 call mpi_comm_size(mpi_comm_world, nprocs_mpi, err_mpi)
772 end if
773 do ra = 0, nprocs_mpi - 1
774 if ( initflag_mpi ) call mpi_barrier(mpi_comm_world, err_mpi)
775 if ( myrank_mpi > -1 .and. ra /= myrank_mpi ) cycle
776 call printf(out_unit, '')
777 if ( myrank_mpi < 0 ) then
778 call printf(out_unit, &
779 & ' ############## CPU TIME SUMMARY%c################', &
780 & c1=trim(total_name_work) // ' ')
781 else
782 call printf(out_unit, &
783 & ' ####### CPU TIME SUMMARY%c#### [rank=%06d] ####', &
784 & c1=trim(total_name_work) // ' ', &
785 & i = (/myrank_mpi/) )
786 end if
787 do i = 1, clks_size
788 clk_name = ''
789 name_len = min(len(clk_name), len_trim(clks(i) % name))
790 if (name_len > 0) then
791 clk_name(1:name_len) = clks(i) % name(1:name_len)
792 end if
793 elapsed_time_val_cor = clks(i) % elapsed_time
794 if (elapsed_time_val_cor < 0.0_dp) elapsed_time_val_cor = 0.0_dp
795 call printf(out_unit, &
796 & ' %c%c %c', c1=clk_name, &
797 & c2=trim(result_value_form(elapsed_time_val_cor)), &
798 & c3=trim(fit_unit_value(clks(i) % elapsed_time)))
799 end do
800 total_print_complete = .false.
801 if (present(clk_total)) then
802 if (clk_total % initialized) then
803 call printf(out_unit, &
804 & ' ------------------------------------------------')
805 elapsed_time_val_cor = clk_total % elapsed_time
806 if (elapsed_time_val_cor < 0.0_dp) elapsed_time_val_cor = 0.0_dp
807 call printf(out_unit, &
808 & ' %c%c %c', c1=total_time_mes, &
809 & c2=trim(result_value_form(elapsed_time_val_cor)), &
810 & c3=trim(fit_unit_value(clk_total % elapsed_time)))
811 total_print_complete = .true.
812 end if
813 end if
814 if (present(total_auto) .and. .not. total_print_complete) then
815 if (total_auto) then
816 clk_auto_total = clks(1)
817 if (clks_size > 1) then
818 do i = 2, clks_size
819 clk_auto_total = clk_auto_total + clks(i)
820 end do
821 end if
822 call printf(out_unit, &
823 & ' ------------------------------------------------')
824 elapsed_time_val_cor = clk_auto_total % elapsed_time
825 if (elapsed_time_val_cor < 0.0_dp) elapsed_time_val_cor = 0.0_dp
826 call printf(out_unit, &
827 & ' %c%c %c', c1=total_time_mes, &
828 & c2=trim(result_value_form(elapsed_time_val_cor)), &
829 & c3=trim(fit_unit_value(clk_auto_total % elapsed_time)))
830 end if
831 end if
832 call dbgmessage('total results, output to device number %d', &
833 & i=(/out_unit/))
834 end do
835999 continue
836 call storeerror(stat, subname, err, cause_c)
837 call endsub(subname)
Date and time manipulation module.
Definition dc_date.f90:57
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_enotinit
-400 or less: DC utilities errors
Definition dc_error.f90:534
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
Message output module.
Handling character types.
Definition dc_string.f90:83
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public stdout
Unit number for Standard OUTPUT
Definition dc_types.f90:117
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_error::dc_enotinit, dc_error::dc_noerr, dc_types::dp, dc_trace::endsub(), dc_types::stdout, dc_error::storeerror(), dc_types::string, and dc_types::token.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: