355 subroutine dcclockstop0(clk, err)
364 type(
clock),
intent(inout):: clk
365 logical,
intent(out),
optional:: err
366 character(STRING):: cause_c
369 character(*),
parameter:: subname =
'DCClockStop'
374 if (.not. clk % initialized)
then
375 call messagenotify(
'W', subname,
'Call Create before Stop in dc_clock.')
376 call dbgmessage(
'Ignored because input argument was not initialized.')
379 elseif (clk % start_time < 0.0_dp)
then
380 call messagenotify(
'W', subname,
'Call Start before Stop in dc_clock.')
381 call dbgmessage(
'Ignored because input argument was not started.')
384 call cpu_time(stop_time)
386 clk % elapsed_time = clk % elapsed_time + stop_time - clk % start_time
387 clk % start_time = - 1.0
388 call dbgmessage(
'name=%c, cpu_time=%f, elapsed_time=%f', &
389 & c1=trim(clk % name), d=(/stop_time, clk % elapsed_time/))
420 subroutine dcclockgetr(clk, sec, err)
426 type(
clock),
intent(in):: clk
427 real,
intent(out):: sec
428 logical,
intent(out),
optional:: err
429 character(STRING):: cause_c
431 character(*),
parameter:: subname =
'DCClockGetR'
436 if (.not. clk % initialized)
then
437 call messagenotify(
'W', subname,
'Call Create before Get in dc_clock.')
438 call dbgmessage(
'Ignored because input argument was not initialized.')
442 sec = real(clk % elapsed_time, kind=kind(sec))
444 & c1=trim(clk % name), r=(/sec/))
608 subroutine dcclockputline0(clk, unit, indent, err)
616 type(
clock),
intent(in):: clk
617 integer,
intent(in),
optional:: unit
618 character(*),
intent(in),
optional:: indent
619 logical,
intent(out),
optional:: err
621 character(STRING):: cause_c
624 character(STRING):: indent_str
625 character(*),
parameter:: subname =
'DCClockPutLine'
630 if (.not. clk % initialized)
then
631 call messagenotify(
'W', subname,
'Call Create before PutLine in dc_clock.')
632 call dbgmessage(
'Ignored because input argument was not initialized.')
636 if (
present(unit))
then
643 if (
present(indent))
then
644 if (len(indent) /= 0)
then
645 indent_len = len(indent)
646 indent_str(1:indent_len) = indent
650 & indent_str(1:indent_len) // &
651 &
'#<CLOCK:: @name=%c @clocking=%y @elapsed_time=%f sec. %c @start_date=%c>', &
652 & c1=trim(clk % name), l=(/clk % start_time > 0.0_dp/), &
653 & d=(/clk % elapsed_time/), &
654 & c2=trim(fit_unit_value(clk % elapsed_time)), &
655 & c3=trim(
tochar(clk % start_date)))
656 call dbgmessage(
'name=%c, output to device number %d', &
657 & c1=trim(clk % name), i=(/out_unit/))
716 subroutine dcclockresult0(clks, unit, total_auto, clk_total, total_name, err)
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
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
738 character(*),
parameter:: total_time_mes =
' TOTAL TIME = '
739 logical:: initflag_mpi
741 integer:: myrank_mpi, nprocs_mpi
742 character(*),
parameter:: subname =
'DCClockResult'
747 clks_size =
size(clks)
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.')
756 if (
present(unit))
then
761 if (
present(total_name))
then
762 total_name_work =
' (' // trim(total_name) //
')'
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)
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
777 if ( myrank_mpi < 0 )
then
779 &
' ############## CPU TIME SUMMARY%c################', &
780 & c1=trim(total_name_work) //
' ')
783 &
' ####### CPU TIME SUMMARY%c#### [rank=%06d] ####', &
784 & c1=trim(total_name_work) //
' ', &
785 & i = (/myrank_mpi/) )
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)
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
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)))
800 total_print_complete = .false.
801 if (
present(clk_total))
then
802 if (clk_total % initialized)
then
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
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.
814 if (
present(total_auto) .and. .not. total_print_complete)
then
816 clk_auto_total = clks(1)
817 if (clks_size > 1)
then
819 clk_auto_total = clk_auto_total + clks(i)
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
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)))
832 call dbgmessage(
'total results, output to device number %d', &
940 function dcclockadd(clk1, clk2)
result(clk_total)
942 use dc_date,
only:
operator(+),
operator(<)
944 type(
clock),
intent(in):: clk1
945 type(
clock),
intent(in):: clk2
946 type(
clock):: clk_total
948 if (.not. clk1 % initialized .or. .not. clk2 % initialized)
then
949 clk_total % initialized = .false.
952 clk_total % name =
cprintf(
'%c+%c', &
953 & c1=trim(clk1 % name), c2=trim(clk2 % name))
954 clk_total % start_time = - 1.0
955 clk_total % initialized = .true.
956 clk_total % elapsed_time = 0.0
957 if (clk1 % start_date < clk2 % start_date)
then
958 clk_total % start_date = clk1 % start_date
960 clk_total % start_date = clk2 % start_date
962 clk_total % elapsed_time = &
963 & clk1 % elapsed_time + clk2 % elapsed_time
989 function dcclocksubtract(clk1, clk2)
result(clk_total)
991 use dc_date,
only:
operator(-),
operator(<)
993 type(
clock),
intent(in):: clk1
994 type(
clock),
intent(in):: clk2
995 type(
clock):: clk_total
997 if (.not. clk1 % initialized .or. .not. clk2 % initialized)
then
998 clk_total % initialized = .false.
1001 clk_total % name =
cprintf(
'%c-%c', &
1002 & c1=trim(clk1 % name), c2=trim(clk2 % name))
1003 clk_total % start_time = - 1.0
1004 clk_total % initialized = .true.
1005 clk_total % elapsed_time = 0.0
1006 if (clk1 % start_date < clk2 % start_date)
then
1007 clk_total % start_date = clk1 % start_date
1009 clk_total % start_date = clk2 % start_date
1011 clk_total % elapsed_time = &
1012 & clk1 % elapsed_time - clk2 % elapsed_time
1137 subroutine dcclockpredict0(clk, progress, unit, err)
1146 type(
clock),
intent(in):: clk
1147 real,
intent(in):: progress
1148 integer,
intent(in),
optional:: unit
1149 logical,
intent(out),
optional:: err
1150 character(STRING):: cause_c
1151 integer:: stat, out_unit
1154 character(7):: prog_percent
1155 character(25):: prog_bar
1156 integer:: prog_bar_ptr
1158 logical:: initflag_mpi
1159 integer:: err_mpi, myrank_mpi
1160 character(*),
parameter:: subname =
'DCClockPredict'
1165 if (.not. clk % initialized)
then
1166 call messagenotify(
'W', subname,
'Call Create before Predict in dc_clock.')
1167 call dbgmessage(
'Ignored because input argument was not initialized.')
1171 if (progress <= 0.0)
then
1172 call messagenotify(
'W', subname,
'Specify 0.0 -- 1.0 value to "progress"')
1174 elseif (progress > 1.0)
then
1175 call messagenotify(
'W', subname,
'Over 1.0 value to "progress" was modified to 1.0')
1178 prog_valid = progress
1180 if (
present(unit))
then
1185 call dcdifftimecreate( remain_diff, &
1186 & sec = real(nint(
evalsec(clk) / prog_valid * (1.0 - prog_valid)),
dp) )
1187 call dcdatetimecreate(cur_date)
1188 comp_date = cur_date + remain_diff
1190 prog_percent = adjustr(trim(printf_g5_2(real(prog_valid * 100,
dp))) //
'%')
1192 prog_bar_ptr = int(prog_valid * 25)
1193 if (prog_bar_ptr > 0) prog_bar(1:prog_bar_ptr) =
'*************************'
1194 call mpi_initialized(initflag_mpi, err_mpi)
1195 if ( initflag_mpi )
then
1196 call mpi_comm_rank(mpi_comm_world, myrank_mpi, err_mpi)
1197 if ( myrank_mpi /= 0 )
goto 999
1199 call printf(out_unit,
'')
1201 &
' ########## PREDICTION OF CALCULATION ###########')
1203 &
' Start Date %c', c1=trim(
tochar(clk % start_date)))
1205 &
' Current Date %c', c1=trim(
tochar(cur_date)))
1207 &
' Progress %c [%c]', c1=prog_percent, c2=prog_bar)
1209 &
' Remaining CPU TIME %c %c', &
1210 & c1=trim(result_value_form(
evalsec(remain_diff))), &
1211 & c2=trim(fit_unit_value(0.0_dp, remain_diff)))
1213 &
' Completion Date %c', c1=trim(
tochar(comp_date)))
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)