time.f90 Source File

This File Depends On

sourcefile~~time.f90~~EfferentGraph sourcefile~time.f90 time.f90 sourcefile~kinds.f90 kinds.f90 sourcefile~kinds.f90->sourcefile~time.f90
Help

Files Dependent On This One

sourcefile~~time.f90~~AfferentGraph sourcefile~time.f90 time.f90 sourcefile~testtime.f90 testTime.f90 sourcefile~time.f90->sourcefile~testtime.f90 sourcefile~text.f90 text.f90 sourcefile~time.f90->sourcefile~text.f90 sourcefile~testiterate.f90 testIterate.f90 sourcefile~time.f90->sourcefile~testiterate.f90 sourcefile~solvers.f90 solvers.f90 sourcefile~time.f90->sourcefile~solvers.f90 sourcefile~text.f90->sourcefile~testiterate.f90 sourcefile~text.f90->sourcefile~solvers.f90 sourcefile~basicsolvers.f90 basicSolvers.f90 sourcefile~text.f90->sourcefile~basicsolvers.f90 sourcefile~testoptimize.f90 testOptimize.f90 sourcefile~text.f90->sourcefile~testoptimize.f90 sourcefile~testtext.f90 testText.f90 sourcefile~text.f90->sourcefile~testtext.f90 sourcefile~plplotlib.f90 plplotlib.f90 sourcefile~text.f90->sourcefile~plplotlib.f90 sourcefile~node.f90 node.f90 sourcefile~text.f90->sourcefile~node.f90 sourcefile~config.f90 config.f90 sourcefile~text.f90->sourcefile~config.f90 sourcefile~testsparse.f90 testSparse.f90 sourcefile~solvers.f90->sourcefile~testsparse.f90 sourcefile~basicsolvers.f90->sourcefile~testsparse.f90 sourcefile~plplotlib.f90->sourcefile~testoptimize.f90 sourcefile~plplotlib.f90->sourcefile~testsparse.f90 sourcefile~animate.f90 animate.f90 sourcefile~plplotlib.f90->sourcefile~animate.f90 sourcefile~logo.f90 logo.f90 sourcefile~plplotlib.f90->sourcefile~logo.f90 sourcefile~basic.f90 basic.f90 sourcefile~plplotlib.f90->sourcefile~basic.f90 sourcefile~testexpression.f90 testExpression.f90 sourcefile~plplotlib.f90->sourcefile~testexpression.f90 sourcefile~testspline.f90 testSpline.f90 sourcefile~plplotlib.f90->sourcefile~testspline.f90 sourcefile~examples.f90 examples.f90 sourcefile~plplotlib.f90->sourcefile~examples.f90 sourcefile~treetrigonometric.f90 treeTrigonometric.f90 sourcefile~node.f90->sourcefile~treetrigonometric.f90 sourcefile~treeexponential.f90 treeExponential.f90 sourcefile~node.f90->sourcefile~treeexponential.f90 sourcefile~treevalue.f90 treeValue.f90 sourcefile~node.f90->sourcefile~treevalue.f90 sourcefile~expression.f90 expression.f90 sourcefile~node.f90->sourcefile~expression.f90 sourcefile~treeoperator.f90 treeOperator.f90 sourcefile~node.f90->sourcefile~treeoperator.f90 sourcefile~testconfig.f90 testConfig.f90 sourcefile~config.f90->sourcefile~testconfig.f90 sourcefile~treetrigonometric.f90->sourcefile~expression.f90 sourcefile~treeexponential.f90->sourcefile~expression.f90 sourcefile~treevalue.f90->sourcefile~expression.f90 sourcefile~expression.f90->sourcefile~testexpression.f90 sourcefile~treeoperator.f90->sourcefile~expression.f90
Help

Source Code


Source Code

module time_mod
	!! Timing module
	use kinds_mod
	use iso_c_binding
	implicit none
	private
	
	public::cpuTime
	public::wallTime
	public::wait
	
contains

	function cpuTime() result(o)
		!! Return the cpu time to within an added constant (excludes sleep time)
		real(wp)::o
		
		call cpu_time(o)
	end function cpuTime

	function wallTime() result(o)
		!! Return the wall time to within an added constant (includes sleep time)
		real(wp)::o
		
		integer,parameter::ip = selected_int_kind(15)
		integer(ip)::ticks,tickRate,r
		
		call system_clock(ticks,tickRate)
		
		r = mod(ticks,tickRate)
		
		o = real(ticks/tickRate,wp)+real(r,wp)/real(tickRate,wp)
	end function wallTime

	subroutine wait(dt)
		!! Make the thread sleep
		real(wp),intent(in)::dt
			!! Time to sleep in seconds
		
		integer(c_int)::usec
		integer(c_int)::ret
		
		interface
			function doSleep(usec) result(e) bind(C,name='usleep')
				use iso_c_binding
				integer(c_int),value::usec
				integer(c_int)::e
			end function doSleep
		end interface
		
		usec = nint(dt*1.0E6)
		ret  = doSleep(usec)
	end subroutine wait

end module time_mod