Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Suggested change

JohnNichols
Valued Contributor III
414 Views
 ! Getsystime.f90 file shows how to call a Windows API routine
! Since the only routine called is GetSystemTime, only include
! interface definitions from kernel32.mod instead of all modules
! included by ifwin.f90. Type definitions are defined in IFWINTY,
! which is used within KERNEL32.
PROGRAM Getsystime
USE KERNEL32
TYPE (T_SYSTEMTIME) MYTIME
CALL GetSystemTime(MYTIME)
WRITE (*,*) 'Current UTC time year :: ', Mytime.wyear, ' Month :: ', Mytime.wMonth, '  Day :: ', Mytime.wDay,' Hour :: ', Mytime.wHour, ' Minute :: ', Mytime.Wminute, ' Second :: ', Mytime.Wsecond
END PROGRAM

On page 627 of the manual you provide a nice little sample of grabbing the time, but it would be nicer if it gave you the whole date and then you can cut it down instead of having to guess what is in the structure type.  

Just a thought.  

This works. 

2 Replies
Barbara_P_Intel
Moderator
344 Views

Thanks, @JohnNichols. I submitted a feature request, DOC-10965.

I shortened that LONG line a bit. The DGR lines aren't that long, no scrollbar either.

! Getsystime.f90 file shows how to call a Windows API routine
! Since the only routine called is GetSystemTime, only include
! interface definitions from kernel32.mod instead of all modules
! included by ifwin.f90. Type definitions are defined in IFWINTY,
! which is used within KERNEL32.
PROGRAM Getsystime
USE KERNEL32
TYPE (T_SYSTEMTIME) MYTIME
CALL GetSystemTime(MYTIME)
WRITE (*,*) 'Current UTC time year :: ', Mytime.wYear, &
  ' Month :: ', Mytime.wMonth, ' Day :: ', Mytime.wDay, &
  ' Hour :: ', Mytime.wHour, ' Minute :: ', Mytime.wMinute, &
  ' Second :: ', Mytime.wSecond
END PROGRAM

 

0 Kudos
Barbara_P_Intel
Moderator
262 Views

The expanded example you submitted is published now in the Fortran Developer Guide 2023.1.

Check it out.


0 Kudos
Reply