- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran 2023 standard talks about the issue with system_clock routine. The user was previously free to use integer of any kind for the actual argument for system_clock.
I have the following code.
- I use the same integer kind for system_clock actual arguments
integer ( 8 ) :: start_count
integer ( 8 ) :: rate, stop_count
program system_clock_test
implicit none
integer ( 4 ), parameter :: x = 100 , y = 100, dx = 1, dy = 1
integer ( 4 ) :: steps = 100000 , step, i, j, ip, jp, im, jm
integer ( 8 ) :: start_count
integer ( 8 ) :: rate, stop_count
real ( 8 ) :: dt = 0.01 , m = 1.0 , k = 0.5
real ( 8 ), dimension ( :, : ), allocatable :: r, c, f, cc, dc, md
allocate ( r(x,y) , c(x,y), f(x,y), cc(x,y), dc(x,y), md(x,y) )
!====
call system_clock(count=start_count , count_rate=rate)
!====
call random_number ( r )
c = 0.4 + 0.02*( 0.5 - r )
do step = 1, steps
do concurrent ( integer :: i=1:x, j=1:y )
f(i,j) = 24.0*c(i,j)*( 1.50 - c(i,j) )**2 - &
&c(i,j)**3*( 1.03 - c(i,j) )
jp = j + 1
jm = j - 1
ip = i + 1
im = i - 1
if ( im == 0 ) im = x
if ( ip == ( x + 1) ) ip = 1
if ( jm == 0 ) jm = y
if ( jp == ( y + 1) ) jp = 1
cc(i,j) = ( c(ip,j) + c(im,j) + c(i,jm) + c(i,jp) - &
4.0*c(i,j) ) /( dx*dy )
dc(i,j) = f(i,j) - k*cc(i,j)
md(i,j) = ( dc(ip,j) + dc(im,j) + dc(i,jm) &
+ dc(i,jp) - 4.0*dc(i,j) ) / ( dx*dy )
c(i,j) = c(i,j) + dt*m*md(i,j)
end do
end do
!=====
call system_clock(count=stop_count)
!=====
print*, ' system clock time : ', real(max(stop_count - start_count , 1_8 )) /real(rate),' seconds'
print*, ' kind type start_count : ', kind(start_count)
print*, ' kind type stop_count : ', kind(stop_count)
end program system_clock_test
and run with
C:\Users\owner\Desktop>ifx test.f90 /O1
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.0.0 Build 20231017
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.32.31332.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:test.exe
-subsystem:console
test.obj
C:\Users\owner\Desktop>test
system clock time : 10.40300 seconds
kind type start_count : 8
kind type stop_count : 8
- Next I change the integer kind for system_clock actual arguments
integer ( 8 ) :: start_count
integer ( 4 ) :: rate, stop_count
and run with
C:\Users\owner\Desktop>ifx test.f90 /O1
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.0.0 Build 20231017
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.32.31332.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:test.exe
-subsystem:console
test.obj
C:\Users\owner\Desktop>test
system clock time : 1.0000000E-06 seconds
kind type start_count : 8
kind type stop_count : 4
As expected, there is an error.
So my question is, should not the latest Intel compiler throw the warning or error message of using different integer kinds ? Or this warning message is expected to be in the next version ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I learned from the following post:
https://fortran-lang.discourse.group/t/fortran-2023-standard-and-system-clock/6861
that the Fortran 2023 does not allow mixed type in this function call (cite: "https://j3-fortran.org/doc/year/21/21-117r3.txt"). I also test the case with all variables in integer(4), and it works as everything in integer(8).
$ ifx -what test.f90
Intel(R) Fortran 23.0-1769.01
$ ./a.out
system clock time : 13.75390 seconds
kind type start_count : 4
kind type stop_count : 4
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I learned from the following post:
https://fortran-lang.discourse.group/t/fortran-2023-standard-and-system-clock/6861
that the Fortran 2023 does not allow mixed type in this function call (cite: "https://j3-fortran.org/doc/year/21/21-117r3.txt"). I also test the case with all variables in integer(4), and it works as everything in integer(8).
$ ifx -what test.f90
Intel(R) Fortran 23.0-1769.01
$ ./a.out
system clock time : 13.75390 seconds
kind type start_count : 4
kind type stop_count : 4
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page