112 public::
operator(+),
operator(-)
127 character(STRING):: name
128 real(DP):: start_time
130 real(DP):: elapsed_time
132 logical:: initialized = .false.
162 interface operator(+)
165 interface operator(-)
213 &
'$Id: dc_clock.F90,v 1.1 2009-03-20 09:09:53 morikawa Exp $' 223 use dc_date, only: dcdatetimecreate
225 type(
clock),
intent(out):: clk
226 character(*),
intent(in):: name
227 character(*),
parameter:: subname =
'DCClockCreate' 230 if (clk % initialized)
then 231 call messagenotify(
'W', subname,
'This argument (type CLOCK) is already initialized.')
236 clk % elapsed_time = 0.0
237 clk % start_time = - 1.0
238 clk % initialized = .true.
239 call dcdatetimecreate(clk % start_date)
251 type(
clock),
intent(inout):: clk
252 character(*),
parameter:: subname =
'DCClockClose' 255 if (clk % initialized)
then 256 clk % initialized = .false.
277 type(
clock),
intent(inout):: clk
278 logical,
intent(out),
optional:: err
279 character(STRING):: cause_c
281 character(*),
parameter:: subname =
'DCClockStart' 286 if (.not. clk % initialized)
then 287 call messagenotify(
'W', subname,
'Call Create before Start in dc_clock.')
288 call dbgmessage(
'Ignored because input argument was not initialized.')
292 call cpu_time(clk % start_time)
294 & c1=trim(clk % name), d=(/clk % start_time/) )
316 type(
clock),
intent(inout):: clk
317 logical,
intent(out),
optional:: err
318 character(STRING):: cause_c
321 character(*),
parameter:: subname =
'DCClockStop' 326 if (.not. clk % initialized)
then 327 call messagenotify(
'W', subname,
'Call Create before Stop in dc_clock.')
328 call dbgmessage(
'Ignored because input argument was not initialized.')
331 elseif (clk % start_time < 0.0_dp)
then 332 call messagenotify(
'W', subname,
'Call Start before Stop in dc_clock.')
333 call dbgmessage(
'Ignored because input argument was not started.')
336 call cpu_time(stop_time)
337 clk % elapsed_time = clk % elapsed_time + stop_time - clk % start_time
338 clk % start_time = - 1.0
339 call dbgmessage(
'name=%c, cpu_time=%r, elapsed_time=%f', &
340 & c1=trim(clk % name), r=(/stop_time/), d=(/clk % elapsed_time/))
361 type(
clock),
intent(in):: clk
362 real,
intent(out):: sec
363 logical,
intent(out),
optional:: err
364 character(STRING):: cause_c
366 character(*),
parameter:: subname =
'DCClockGetR' 371 if (.not. clk % initialized)
then 372 call messagenotify(
'W', subname,
'Call Create before Get in dc_clock.')
373 call dbgmessage(
'Ignored because input argument was not initialized.')
377 sec = clk % elapsed_time
379 & c1=trim(clk % name), r=(/sec/))
401 type(
clock),
intent(in):: clk
402 real(DP),
intent(out):: sec
403 logical,
intent(out),
optional:: err
404 character(STRING):: cause_c
406 character(*),
parameter:: subname =
'DCClockGetD' 411 if (.not. clk % initialized)
then 412 call messagenotify(
'W', subname,
'Call Create before Get in dc_clock.')
413 call dbgmessage(
'Ignored because input argument was not initialized.')
417 sec = clk % elapsed_time
419 & c1=trim(clk % name), d=(/sec/))
435 type(
clock),
intent(in):: clk
454 type(
clock),
intent(in):: clk
455 character(STRING):: result
456 character(20):: clk_name
458 clk_name = clk % name
459 if (clk % initialized)
then 485 type(
clock),
intent(in):: clk
486 integer,
intent(in),
optional:: unit
487 character(*),
intent(in),
optional:: indent
491 logical,
intent(out),
optional:: err
493 character(STRING):: cause_c
496 character(STRING):: indent_str
497 character(*),
parameter:: subname =
'DCClockPutLine' 502 if (.not. clk % initialized)
then 503 call messagenotify(
'W', subname,
'Call Create before PutLine in dc_clock.')
504 call dbgmessage(
'Ignored because input argument was not initialized.')
508 if (
present(unit))
then 515 if (
present(indent))
then 516 if (len(indent) /= 0)
then 517 indent_len = len(indent)
518 indent_str(1:indent_len) = indent
522 & indent_str(1:indent_len) // &
523 &
'#<CLOCK:: @name=%c @clocking=%y @elapsed_time=%f sec. %c @start_date=%c>', &
524 & c1=trim(clk % name), l=(/clk % start_time > 0.0_dp/), &
525 & d=(/clk % elapsed_time/), &
527 & c3=trim(
tochar(clk % start_date)))
528 call dbgmessage(
'name=%c, output to device number %d', &
529 & c1=trim(clk % name), i=(/out_unit/))
534 subroutine dcclockresult0(clks, unit, total_auto, clk_total, total_name, err)
563 type(
clock),
intent(in):: clks(:)
564 integer,
intent(in),
optional:: unit
565 logical,
intent(in),
optional:: total_auto
566 type(
clock),
intent(in),
optional:: clk_total
567 logical,
intent(out),
optional:: err
568 character(*),
intent(in),
optional:: total_name
569 integer:: out_unit, i, clks_size, ra
570 character(20):: clk_name
571 character(STRING):: cause_c
572 character(STRING):: total_name_work
573 type(
clock):: clk_auto_total
574 logical:: total_print_complete
575 real(DP):: elapsed_time_val_cor
577 character(*),
parameter:: total_time_mes =
' TOTAL TIME = ' 578 integer:: myrank_mpi, nprocs_mpi
579 character(*),
parameter:: subname =
'DCClockResult' 584 clks_size =
size(clks)
586 if (.not. clks(i) % initialized)
then 587 call messagenotify(
'W', subname,
'Call Create before Result in dc_clock.')
588 call dbgmessage(
'Ignored because input argument was not initialized.')
593 if (
present(unit))
then 598 if (
present(total_name))
then 599 total_name_work =
' (' // trim(total_name) //
')' 605 do ra = 0, nprocs_mpi - 1
607 if ( myrank_mpi < 0 )
then 609 &
' ############## CPU TIME SUMMARY%c################', &
610 & c1=trim(total_name_work) //
' ')
613 &
' ####### CPU TIME SUMMARY%c#### [rank=%06d] ####', &
614 & c1=trim(total_name_work) //
' ', &
615 & i = (/myrank_mpi/) )
618 clk_name = clks(i) % name
619 elapsed_time_val_cor = clks(i) % elapsed_time
620 if (elapsed_time_val_cor < 0.0_dp) elapsed_time_val_cor = 0.0_dp
622 &
' %c%c %c', c1=clk_name, &
626 total_print_complete = .false.
627 if (
present(clk_total))
then 628 if (clk_total % initialized)
then 630 &
' ------------------------------------------------')
631 elapsed_time_val_cor = clk_total % elapsed_time
632 if (elapsed_time_val_cor < 0.0_dp) elapsed_time_val_cor = 0.0_dp
634 &
' %c%c %c', c1=total_time_mes, &
637 total_print_complete = .true.
640 if (
present(total_auto) .and. .not. total_print_complete)
then 642 clk_auto_total = clks(1)
643 if (clks_size > 1)
then 645 clk_auto_total = clk_auto_total + clks(i)
649 &
' ------------------------------------------------')
650 elapsed_time_val_cor = clk_auto_total % elapsed_time
651 if (elapsed_time_val_cor < 0.0_dp) elapsed_time_val_cor = 0.0_dp
653 &
' %c%c %c', c1=total_time_mes, &
658 call dbgmessage(
'total results, output to device number %d', &
674 character(TOKEN):: result
675 real(DP),
intent(in):: value
677 write(
result,
"(e15.6)")
value 692 use dc_date, only: dcdifftimecreate, evalday, evalhour, evalmin,
evalsec 695 character(TOKEN):: result
696 real(DP),
intent(in):: sec
699 character(TOKEN):: unit
701 character(TOKEN):: cval
703 if (
present(diff) )
then 706 call dcdifftimecreate( diffw, sec = sec )
708 if (evalday(diffw) > 1.0_dp)
then 710 value = evalday(diffw)
711 elseif (evalhour(diffw) > 1.0_dp)
then 713 value = evalhour(diffw)
714 elseif (evalmin(diffw) > 1.0_dp)
then 716 value = evalmin(diffw)
722 result =
'(' // trim(adjustl(cval)) // trim(unit) //
')' 735 character(TOKEN):: result
736 real(DP),
intent(in):: value
737 character(TOKEN):: int_part, dem_part
740 write(int_part,
"(i20)") int(
value)
741 dem_int = nint((
value - int(
value)) * 100)
742 if (dem_int < 0) dem_int = - dem_int
743 if (dem_int == 100)
then 745 write(int_part,
"(i20)") int(
value) + 1
747 dem_part =
cprintf(
'%02d', i=(/dem_int/))
748 result = trim(adjustl(int_part)) //
'.' // trim(dem_part)
750 function dcclockadd(clk1, clk2)
result(clk_total)
760 use dc_date, only:
operator(+),
operator(<)
762 type(
clock),
intent(in):: clk1
763 type(
clock),
intent(in):: clk2
764 type(
clock):: clk_total
766 if (.not. clk1 % initialized .or. .not. clk2 % initialized)
then 767 clk_total % initialized = .false.
770 clk_total % name =
cprintf(
'%c+%c', &
771 & c1=trim(clk1 % name), c2=trim(clk2 % name))
772 clk_total % start_time = - 1.0
773 clk_total % initialized = .true.
774 clk_total % elapsed_time = 0.0
775 if (clk1 % start_date < clk2 % start_date)
then 776 clk_total % start_date = clk1 % start_date
778 clk_total % start_date = clk2 % start_date
780 clk_total % elapsed_time = &
781 & clk1 % elapsed_time + clk2 % elapsed_time
794 use dc_date, only:
operator(-),
operator(<)
796 type(
clock),
intent(in):: clk1
797 type(
clock),
intent(in):: clk2
798 type(
clock):: clk_total
800 if (.not. clk1 % initialized .or. .not. clk2 % initialized)
then 801 clk_total % initialized = .false.
804 clk_total % name =
cprintf(
'%c-%c', &
805 & c1=trim(clk1 % name), c2=trim(clk2 % name))
806 clk_total % start_time = - 1.0
807 clk_total % initialized = .true.
808 clk_total % elapsed_time = 0.0
809 if (clk1 % start_date < clk2 % start_date)
then 810 clk_total % start_date = clk1 % start_date
812 clk_total % start_date = clk2 % start_date
814 clk_total % elapsed_time = &
815 & clk1 % elapsed_time - clk2 % elapsed_time
832 type(
clock),
intent(inout):: clk
833 character(*),
intent(in):: name
834 logical,
intent(out),
optional:: err
835 character(STRING):: cause_c
837 character(*),
parameter:: subname =
'DCClockSetName' 842 if (.not. clk % initialized)
then 843 call messagenotify(
'W', subname,
'Call Create before Set_Name in dc_clock.')
844 call dbgmessage(
'Ignored because input argument was not initialized.')
849 call dbgmessage(
'set new name "%c"', c1=trim(clk % name))
892 type(
clock),
intent(in):: clk
893 real,
intent(in):: progress
894 integer,
intent(in),
optional:: unit
895 logical,
intent(out),
optional:: err
896 character(STRING):: cause_c
897 integer:: stat, out_unit
900 character(7):: prog_percent
901 character(25):: prog_bar
902 integer:: prog_bar_ptr
904 character(*),
parameter:: subname =
'DCClockPredict' 909 if (.not. clk % initialized)
then 910 call messagenotify(
'W', subname,
'Call Create before Predict in dc_clock.')
911 call dbgmessage(
'Ignored because input argument was not initialized.')
915 if (progress <= 0.0)
then 916 call messagenotify(
'W', subname,
'Specify 0.0 -- 1.0 value to "progress"')
918 elseif (progress > 1.0)
then 919 call messagenotify(
'W', subname,
'Over 1.0 value to "progress" was modified to 1.0')
922 prog_valid = progress
924 if (
present(unit))
then 929 call dcdifftimecreate( remain_diff, &
930 & sec =
real(nint(EvalSec(clk) / prog_valid * (1.0 - prog_valid)), DP) )
931 call dcdatetimecreate(cur_date)
932 comp_date = cur_date + remain_diff
934 prog_percent = adjustr(trim(
printf_g5_2(
real(prog_valid * 100,
dp))) //
'%')
936 prog_bar_ptr = int(prog_valid * 25)
937 if (prog_bar_ptr > 0) prog_bar(1:prog_bar_ptr) =
'*************************' 940 &
' ########## PREDICTION OF CALCULATION ###########')
942 &
' Start Date %c', c1=trim(
tochar(clk % start_date)))
944 &
' Current Date %c', c1=trim(
tochar(cur_date)))
946 &
' Progress %c [%c]', c1=prog_percent, c2=prog_bar)
948 &
' Remaining CPU TIME %c %c', &
952 &
' Completion Date %c', c1=trim(
tochar(comp_date)))
character(token) function printf_g5_2(value)
type(clock) function dcclockadd(clk1, clk2)
subroutine dcclockgetd(clk, sec, err)
subroutine dcclockpredict0(clk, progress, unit, err)
integer, parameter, public dc_enotinit
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
subroutine dcclockresult0(clks, unit, total_auto, clk_total, total_name, err)
subroutine dcclockcreate0(clk, name)
character(token) function fit_unit_value(sec, diff)
type(clock) function dcclocksubtract(clk1, clk2)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_noerr
real(dp) function dcclockevalsecd(clk)
subroutine dcclockgetr(clk, sec, err)
character(*), parameter version
integer, parameter, public dp
倍精度実数型変数
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 dcclocksetname0(clk, name, err)
character(string) function dcclocktochar0(clk)
integer, parameter, public stdout
標準出力の装置番号
subroutine dcclockstop0(clk, err)
subroutine dcclockputline0(clk, unit, indent, err)
character(token) function result_value_form(value)
subroutine dcclockclose0(clk)
subroutine dcclockstart0(clk, err)
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ