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

call to system - CPU time

ndsr
Beginner
1,267 Views
HI,
I would like to know the CPU time and I should call it in my script
specify the call to the system subroutine to learn CPU time
SUBROUTINE TIMEL(TRES)
************************************************************
* Returns CPU time. *
************************************************************
REAL*8 TRES,TRES0
INTRINSIC SYSTEM_CLOCK
C EXTERNAL CPSEC
SAVE IF,TRES0,IRES0
DATA IF/0/
* THIS IS THE <> CALL TO LEARN CPU TIME
C TRES=MCLOCK()/100.d0
C RETURN
* THIS IS THE <> CALL TO LEARN CPU TIME
C CALL DCLOCK@(TRES)
C IF(IF.EQ.0)TRES0=TRES
C IF=1
C TRES=TRES-TRES0
C RETURN
* THIS IS INTRINSIC PROCEDURE IN FORTRAN<90>
C IF(IF.EQ.0)CALL SYSTEM_CLOCK(IRES0,IRESR,IRESM)
C IF=1
C CALL SYSTEM_CLOCK(IRES,IRESR,IRESM)
C TRES=DBLE(IRES-IRES0)/DBLE(IRESR)
* THIS IS THE MICROSOFT FORTRAN POWER STATION CALL
C IF(IF.EQ.0)TRES0=CPSEC()
C TRES=CPSEC()
C TRES=TRES-TRES0
C IF=1
TRES=0.D0
END
this is the script and where should I specify the call
Pl advice me
0 Kudos
1 Solution
mecej4
Honored Contributor III
1,267 Views
[bash]      SUBROUTINE TIMEL(TRES)
************************************************************
* Returns CPU time.  Fortran 9X version                          *
************************************************************
      REAL*8 TRES,TRES0
      SAVE IF,TRES0,IRES0
      DATA IF/0/
* THIS IS INTRINSIC PROCEDURE IN FORTRAN<90>
     IF(IF.EQ.0)CALL SYSTEM_CLOCK(IRES0,IRESR,IRESM)
     IF=1
     CALL SYSTEM_CLOCK(IRES,IRESR,IRESM)
     TRES=DBLE(IRES-IRES0)/DBLE(IRESR)
      END
[/bash]

View solution in original post

0 Kudos
10 Replies
rreis
New Contributor I
1,267 Views
The piece of program already tells you how to do it, after each * line there is the code for doing what you want, you just have to uncomment it (remove the initial "C" of each line).

In what architecture will you running this program?
0 Kudos
ndsr
Beginner
1,267 Views
Dear Reis,
I would like to run this on a 32 bit architecture and my processor speed is 2.93 Ghz. So how should I specify
0 Kudos
TimP
Honored Contributor III
1,267 Views
You might take into account that system_clock() works much better with 64-bit integers. One more reason for explicit declarations.
0 Kudos
ndsr
Beginner
1,267 Views
HOw can I able to specify 64 bit when my system architecture is 32-bit
0 Kudos
TimP
Honored Contributor III
1,267 Views
You choose the 35 year old non-standard way of specifying 64-bit real, if you choose to be further non-standard you can so the same with integer (integer*8), or you can adopt the way which came in together with system_clock:
integer(selected_int_kind(12)) :: ires0,iresr,iresm,ires
0 Kudos
Steven_L_Intel1
Employee
1,267 Views
Intel Fortran for IA-32 supports 64-bit integers.
0 Kudos
ndsr
Beginner
1,267 Views
Thank you TIM

but can you put that in the code which I've geiven so that would give me clearly
0 Kudos
mecej4
Honored Contributor III
1,268 Views
[bash]      SUBROUTINE TIMEL(TRES)
************************************************************
* Returns CPU time.  Fortran 9X version                          *
************************************************************
      REAL*8 TRES,TRES0
      SAVE IF,TRES0,IRES0
      DATA IF/0/
* THIS IS INTRINSIC PROCEDURE IN FORTRAN<90>
     IF(IF.EQ.0)CALL SYSTEM_CLOCK(IRES0,IRESR,IRESM)
     IF=1
     CALL SYSTEM_CLOCK(IRES,IRESR,IRESM)
     TRES=DBLE(IRES-IRES0)/DBLE(IRESR)
      END
[/bash]
0 Kudos
Steven_L_Intel1
Employee
1,267 Views
Please note that SYSTEM_CLOCK returns "wall clock" elapsed time, not CPU time. The CPU_TIME intrinsic returns that.
0 Kudos
ndsr
Beginner
1,267 Views
It has been so long and after my PC crashed out. I reinstated my PC and Now I exactly got what I can do I'll keep posted on the improvement
0 Kudos
Reply