update new files
[unres.git] / source / maxlik / src_MD_T_maxlik-NEWCORR-PMF / 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       include 'DIMENSIONS'
23       include 'DIMENSIONS.ZSCOPT'
24       integer nf,nfold
25       save nfold
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 c      write (iout,*) "NF",nf," NFOLD",nfold," LLOCAL",llocal
34       if (llocal) then
35         stopx=.false.
36         return
37       endif
38       cutoffeval=.false.
39       if (nf.eq.1) nfold=1
40       if (ovrtim()) then
41 C Finish if time is up.
42          stopx = .true.
43          WhatsUp=1
44 c         write (iout,*) "In STOPX (OVRTIM): TRUE"
45       else if (cutoffviol) then
46         stopx = .true.
47         WhatsUp=2
48 c        write (iout,*) "In STOPX (CUTOFFVIOL): TRUE"
49       else 
50 c        write (iout,*) "In STOPX: FALSE"
51 c        write (iout,*) "NF=",nf," NFOLD=",NFOLD," NDELTA=",ndelta
52         stopx=.false.
53         if (nf-nfold.ge.ndelta) then
54           nfold=nf
55           cutoffeval=.true.
56         endif
57 c        write (iout,*) "CUFOFFEVAL",cutoffeval
58       endif
59       return
60       end
61 C--------------------------------------------------------------------------
62       logical function ovrtim() 
63       implicit none
64       include 'COMMON.TIME1'
65       real*8 tcpu,curtim
66       curtim= tcpu()
67 c      print *,'curtim=',curtim,' timlim=',timlim
68 C  curtim is the current time in seconds.
69 c      ovrtim=(curtim .ge. timlim - safety )
70 c ovrtim does not work sometimes and crashes the program !  CHUUUJ !
71 c setting always to false
72       ovrtim=.false.
73       return                                               
74       end
75 **************************************************************************      
76       double precision function tcpu()
77       implicit none
78       include 'COMMON.TIME1'
79 #ifdef ES9000 
80 ****************************
81 C Next definition for EAGLE (ibm-es9000)
82       real*8 micseconds
83       integer rcode
84       tcpu=cputime(micseconds,rcode)
85       tcpu=(micseconds/1.0E6) - stime
86 ****************************
87 #endif
88 #ifdef SUN
89 ****************************
90 C Next definitions for sun
91       REAL*8  ECPU,ETIME,ETCPU
92       dimension tarray(2)
93       tcpu=etime(tarray)
94       tcpu=tarray(1)
95 ****************************
96 #endif
97 #ifdef KSR
98 ****************************
99 C Next definitions for ksr
100 C this function uses the ksr timer ALL_SECONDS from the PMON library to
101 C return the elapsed time in seconds
102       tcpu= all_seconds() - stime
103 ****************************
104 #endif
105 #ifdef SGI
106 ****************************
107 C Next definitions for sgi
108       real timar(2), etime, seconds
109       seconds = etime(timar)
110 Cd    print *,'seconds=',seconds,' stime=',stime
111 C      usrsec = timar(1)
112 C      syssec = timar(2)
113       tcpu=seconds - stime
114 ****************************
115 #endif
116
117 #ifdef LINUX
118 ****************************
119 C Next definitions for sgi
120       real timar(2), etime, seconds
121       seconds = etime(timar)
122 Cd    print *,'seconds=',seconds,' stime=',stime
123 C      usrsec = timar(1)
124 C      syssec = timar(2)
125       tcpu=seconds - stime
126 ****************************
127 #endif
128
129
130 #ifdef CRAY
131 ****************************
132 C Next definitions for Cray
133 C     call date(curdat)
134 C     curdat=curdat(1:9)
135 C     call clock(curtim)
136 C     curtim=curtim(1:8)
137       cpusec = second()
138       tcpu=cpusec - stime
139 ****************************
140 #endif
141 #ifdef AIX
142 ****************************
143 C Next definitions for RS6000
144        integer*4 i1,mclock
145        i1 = mclock()
146        tcpu = (i1+0.0D0)/100.0D0
147 #endif
148 #ifdef WIN
149 ****************************
150 c next definitions for windows NT Digital fortran
151        real time_real
152        call cpu_time(time_real)
153        tcpu = time_real
154 #endif
155
156       return     
157       end  
158 C---------------------------------------------------------------------------
159       subroutine dajczas(rntime,hrtime,mintime,sectime)
160       include 'DIMENSIONS.ZSCOPT'
161       include 'COMMON.IOUNITS'
162       real*8 rntime,hrtime,mintime,sectime 
163       hrtime=rntime/3600.0D0 
164       hrtime=aint(hrtime)
165       mintime=aint((rntime-3600.0D0*hrtime)/60.0D0)
166       sectime=aint((rntime-3600.0D0*hrtime-60.0D0*mintime)+0.5D0)
167       if (sectime.eq.60.0D0) then
168         sectime=0.0D0
169         mintime=mintime+1.0D0
170       endif
171       ihr=hrtime
172       imn=mintime
173       isc=sectime
174       write (iout,328) ihr,imn,isc
175   328 FORMAT(//'***** Computation time: ',I4  ,' hours ',I2  ,
176      1         ' minutes ', I2  ,' seconds *****')       
177       return
178       end