!
!   TITLE:  tstop.mac (MANAGEMENT)
!
!
!
!       Display time duration in H:M:S format instead of just decimal
!       minutes.
!
!
! This macro is used to measure the time duration it takes ANSYS to do
! a block of commands.
!
! The tstart/tstop pair of macro commands work just like a stopwatch.
! At the start of a block of code call "tstart" and then at the end call
! "tstop".  The elapsed time since tstart was called is then displayed.
!
! The output gives the actual time the CPU spent on running ANSYS code and
! the elapsed wall clock time.
!
!
! tstop
!

*get,prkey_,active,0,prkey
/nopr

parres,change,tstart,out

*get,_stop_w,active,0,time,wall
*get,_stop_c,active,0,time,cpu

hr_w_=_stop_w-_start_w
hr_c_=(_stop_c-_start_c)/3600

*if,hr_w_,gt,24,then

da_w_=hr_w_/24-mod(hr_w_/24,1)
da_c_=hr_c_/24-mod(hr_c_/24,1)

hr_w_=hr_w_-da_w_*24
hr_c_=hr_c_-da_c_*24

min_w_=mod(hr_w_,60)
min_c_=mod(hr_c_,60)

hr_w_=hr_w_-mod(hr_w_,1)
hr_c_=hr_c_-mod(hr_c_,1)

*msg,ui,da_w_,hr_w_,min_w_,da_c_,hr_c_,min_c_
Wall Clock Duration: %I days, %I hours, %I minutes %/ &
CPU  Clock Duration: %I days, %I hours, %I minutes

*else

min_w_=60*mod(hr_w_,1)
min_c_=60*mod(hr_c_,1)

hr_w_=hr_w_-mod(hr_w_,1)
hr_c_=hr_c_-mod(hr_c_,1)

sec_w_=60*mod(min_w_,1)
sec_c_=60*mod(min_c_,1)

min_w_=min_w_-mod(min_w_,1)
min_c_=min_c_-mod(min_c_,1)

msec_w_=1000*mod(1e-6+sec_w_,1)
msec_c_=1000*mod(1e-6+sec_c_,1)

sec_w_=sec_w_-mod(sec_w_,1)
sec_c_=sec_c_-mod(sec_c_,1)

*msg,ui,hr_w_,min_w_,sec_w_,hr_c_,min_c_,sec_c_
Wall Clock Duration: %I hr, %I min, %I sec %/ &
CPU Clock Duration: %I hr, %I min, %I sec

! Milisecond version
!*msg,ui,hr_w_,min_w_,sec_w_,msec_w_,hr_c_,min_c_,sec_c_,msec_c_
!Wall Clock Duration: %I hr, %I min, %I sec, %I msec %/ &
!CPU Clock Duration: %I hr, %I min, %I sec, %I msec

*endif

*set,_stop_w
*set,_stop_c
*set,da_w_
*set,da_c_
*set,hr_w_
*set,hr_c_
*set,min_w_
*set,min_c_
*set,sec_w_
*set,sec_c_
*set,msec_w_
*set,msec_c_

*if,prkey_,eq,1,then
    /go
*endif