https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98577

--- Comment #4 from Chinoune <mehdi.chinoune at hotmail dot com> ---
(In reply to kargl from comment #3)
> (In reply to Chinoune from comment #2)
> > program main
> >   use iso_fortran_env
> >   implicit none
> >   !
> >   integer(int32) :: count_rate_i32
> >   integer(int64) :: t1, t2, t3, t4, t5, t6
> >   real(real32) :: count_rate_r32
> >   real(real64) :: count_rate_r64
> 
> (brevity)
> 
> > $ gfortran-10 -O3 bug_gcc_98577_2.f90 -o test.x
> > $ ./test.x                                                                  
> > count_rate_r32:   568052096.                                                
> > count_rate_i32:   568763156.84800005                                        
> > count_rate_r64:  0.71658250000000001
> > 
> > Can you explain these results?!
> 
> Harald just explained it to you.
> 
> % gfcg -o z -Wall a.f90 && ./z
> integer
>   kind:     1      2           4                    8
>  count:  -127 -32767   996821773      996821773517757
>   rate:     0      0        1000           1000000000
>    max:     0      0  2147483647  9223372036854775807
> 
> real:
>   kind     4            8           10           16
>   rate: 1000.0 1000000000.0 1000000000.0 1000000000.0
> 
> 
> For integer(4) and real(4), the number of ticks per second
> is 1000, i.e., count_rate.  For integer(4) and real(4), the
> count is done in units of 1/1000, i.e., 1/count_rate.
> 
> For integer(8) (and integer(16) if support) and real(8),
> real(10), and real(16), the number of ticks per second 
> is 1000000000.  For integer(8) (and integer(16) if support),
> count is done in units of 1/1000000000, ie., 1/count_rate.
> 
> In your program when you do your scaling, it is mixing units.
> 
>    print*, "count_rate_r32:", (t2-t1)/count_rate_r32
> 
> t2-t1 is nanosecond time scale.  count_rate_r32 is millisecond time scale.
> 
>    print*, "count_rate_i32:", (t4-t3)/real(count_rate_i32,real64)
> 
> t4-t3 is nanosecond time scale.  count_rate_i32 is millisecond time scale.
> 
>    print*, "count_rate_r64:", (t6-t5)/count_rate_r64
> 
> t6-t5 is nanosecond time scale.  count_rate_r64 is nanosecond time scale.

There is no mention of your claims in the standard:

Fortran 2018:
<<
6.9.186 SYSTEM_CLOCK ([COUNT, COUNT_RATE, COUNT_MAX])
 1 Description. Query system clock.
 2 Class. Subroutine.
 3 Arguments.
  COUNT (optional) shall be an integer scalar. It is an INTENT (OUT) argument.
It is assigned a processor-dependent value based on the value of a processor
clock, or −HUGE (COUNT) if there is no clock for the invoking image. The
processor-dependent value is incremented by one for each clock count until the
value COUNT_MAX is reached and is reset to zero at the next count. It lies in
the range 0 to COUNT_MAX if there is a clock.
  COUNT_RATE (optional) shall be an integer or real scalar. It is an INTENT
(OUT) argument. It is assigned a processor-dependent approximation to the
number of processor clock counts per second, or zero if there is no clock for
the invoking image.
  COUNT_MAX (optional) shall be an integer scalar. It is an INTENT (OUT)
argument. It is assigned the maximum value that COUNT can have, or zero if
there is no clock for the invoking image.

 4 Whether an image has no clock, has a single clock of its own, or shares a
clock with another image, is processor dependent.
 5 Example. If the processor clock is a 24-hour clock that registers time at
approximately 18.20648193 ticks per second, at 11:30 A.M. the reference CALL
SYSTEM_CLOCK (COUNT = C, COUNT_RATE = R, COUNT_MAX = M) defines C =
(11×3600+30×60)×18.20648193 = 753748, R = 18.20648193, and M =
24×3600×18.20648193−1 = 1573039.
>>

Reply via email to