added source code
[unres.git] / source / wham / src / timing.F
1 C $Date: 1994/10/05 16:41:52 $
2 C $Revision: 2.2 $
3 C
4 C
5 C
6       subroutine set_timers
7 c
8       implicit none
9       double precision tcpu
10       include 'COMMON.TIME1'
11 C Diminish the assigned time limit a little so that there is some time to
12 C end a batch job
13 c     timlim=batime-150.0
14 C Calculate the initial time, if it is not zero (e.g. for the SUN).
15       stime=tcpu()
16 cd    print *,' in SET_TIMERS stime=',stime
17       return 
18       end
19 C------------------------------------------------------------------------------
20       logical function stopx(nf)
21 C This function returns .true. in case of time up on the master node.
22       implicit none
23       include 'DIMENSIONS'
24       include 'DIMENSIONS.ZSCOPT'
25       integer nf
26       logical ovrtim
27 #ifdef MPI
28       include 'mpif.h'
29       include 'COMMON.MPI'
30 #endif
31       include 'COMMON.IOUNITS'
32       include 'COMMON.TIME1'
33       if (ovrtim()) then
34 C Finish if time is up.
35          stopx = .true.
36          WhatsUp=1
37       else if (cutoffviol) then
38         stopx = .true.
39         WhatsUp=2
40       else
41         stopx=.false.
42       endif
43       return
44       end
45 C--------------------------------------------------------------------------
46       logical function ovrtim() 
47       implicit none
48       include 'COMMON.TIME1'
49       real*8 tcpu,curtim
50       curtim= tcpu()
51 c      print *,'curtim=',curtim,' timlim=',timlim
52 C  curtim is the current time in seconds.
53 c      ovrtim=(curtim .ge. timlim - safety )
54 c ovrtim does not work sometimes and crashes the program !  CHUUUJ !
55 c setting always to false
56       ovrtim=.false.
57       return                                               
58       end
59 **************************************************************************      
60       double precision function tcpu()
61       implicit none
62       include 'COMMON.TIME1'
63 #ifdef ES9000 
64 ****************************
65 C Next definition for EAGLE (ibm-es9000)
66       real*8 micseconds
67       integer rcode
68       tcpu=cputime(micseconds,rcode)
69       tcpu=(micseconds/1.0E6) - stime
70 ****************************
71 #endif
72 #ifdef SUN
73 ****************************
74 C Next definitions for sun
75       REAL*8  ECPU,ETIME,ETCPU
76       dimension tarray(2)
77       tcpu=etime(tarray)
78       tcpu=tarray(1)
79 ****************************
80 #endif
81 #ifdef KSR
82 ****************************
83 C Next definitions for ksr
84 C this function uses the ksr timer ALL_SECONDS from the PMON library to
85 C return the elapsed time in seconds
86       tcpu= all_seconds() - stime
87 ****************************
88 #endif
89 #ifdef SGI
90 ****************************
91 C Next definitions for sgi
92       real timar(2), etime, seconds
93       seconds = etime(timar)
94 Cd    print *,'seconds=',seconds,' stime=',stime
95 C      usrsec = timar(1)
96 C      syssec = timar(2)
97       tcpu=seconds - stime
98 ****************************
99 #endif
100
101 #ifdef LINUX
102 ****************************
103 C Next definitions for sgi
104       real timar(2), etime, seconds
105       seconds = etime(timar)
106 Cd    print *,'seconds=',seconds,' stime=',stime
107 C      usrsec = timar(1)
108 C      syssec = timar(2)
109       tcpu=seconds - stime
110 ****************************
111 #endif
112
113
114 #ifdef CRAY
115 ****************************
116 C Next definitions for Cray
117 C     call date(curdat)
118 C     curdat=curdat(1:9)
119 C     call clock(curtim)
120 C     curtim=curtim(1:8)
121       cpusec = second()
122       tcpu=cpusec - stime
123 ****************************
124 #endif
125 #ifdef AIX
126 ****************************
127 C Next definitions for RS6000
128        integer*4 i1,mclock
129        i1 = mclock()
130        tcpu = (i1+0.0D0)/100.0D0
131 #endif
132 #ifdef WIN
133 ****************************
134 c next definitions for windows NT Digital fortran
135        real time_real
136        call cpu_time(time_real)
137        tcpu = time_real
138 #endif
139
140       return     
141       end  
142 C---------------------------------------------------------------------------
143       subroutine dajczas(rntime,hrtime,mintime,sectime)
144       implicit none
145       include 'COMMON.IOUNITS'
146       integer ihr,imn,isc
147       real*8 rntime,hrtime,mintime,sectime 
148       hrtime=rntime/3600.0D0 
149       hrtime=aint(hrtime)
150       mintime=aint((rntime-3600.0D0*hrtime)/60.0D0)
151       sectime=aint((rntime-3600.0D0*hrtime-60.0D0*mintime)+0.5D0)
152       if (sectime.eq.60.0D0) then
153         sectime=0.0D0
154         mintime=mintime+1.0D0
155       endif
156       ihr=hrtime
157       imn=mintime
158       isc=sectime
159       write (iout,328) ihr,imn,isc
160   328 FORMAT(//'***** Computation time: ',I4  ,' hours ',I2  ,
161      1         ' minutes ', I2  ,' seconds *****')       
162       return
163       end