C+
C NAME:
C	Time2GetOrigin
C PURPOSE:
C	Retrieve current time origin and fract-day units
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	subroutine Time2GetOrigin(t3)
C OUTPUTS:
C	t3(3)		integer		current time origin
C INCLUDE:
	include		'fortime.h'
C PROCEDURE:
C	Used to save current settings for restoration by
C	Time2PutOrigin
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	integer units_in_day
	integer t3(3)

	t3(1) = TIME__ORIGIN(1)
	t3(2) = TIME__ORIGIN(2)
	t3(3) = TIME__ORIGIN(3)

	return
C+
C NAME:
C	Time2PutOrigin
C PURPOSE:
C	Restore saved time origin and fract-day units
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2PutOrigin(t3)
C OUTPUTS:
C	t3(3)		integer		current time origin
C PROCEDURE:
C	Used to restore saved settings by Time2GetOrigin
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	TIME__ORIGIN(1) = t3(1)
	TIME__ORIGIN(2) = t3(2)
	TIME__ORIGIN(3) = t3(3)

	return
C+
C NAME:
C	Time2SetOrigin2000
C PURPOSE:
C	Initialize time tracking by setting origin to 2000 Jan 1, 0 UT
C	with frac. day units in hours
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2SetOrigin2000(units_in_day)
C CALLS:
C	Time2ChangeUnits
C PROCEDURE:
C	Initializes the time origin to 2000 Jan 1, 0 UT with milliseconds to
C	keep track of the fraction of a day..
C
C	The origin and time scale is saved internally into a 3-element integer	
C	A 2-element standard time is a 2-element integer array defining the time difference
C	from the current time origin: t2=[ta,tb] corresponds to a time ta+tb/units_in_day days after
C	the time origin. Here units_in_day is defined by the value of idt, e.g. if idt=TIME__UNIT_MSEC
C	(the default) then units_in_day=86400000.
C
C	A 1-element standard time is a scalar integer: t1 corresponds to a time t1/units_in_day days
C	after the time origin.
C
C	Using 1-element times saves memory, but limits the range of possible of times to the number hours,
C	minutes, seconds, etc. that can be fitted into an integer*4.
C	Using 2-element times takes more memory but extends the range to the number of days that
C	can be fitted into an integer*4.
C
C	The time origin t0 is specified as a 2-element standard time relative to the absolute time
C	origin, e.g. to set the time origin to 2000 Jan 1.0, set t0=[0,0] (this is the default).
C	Once the time origin and the time scale have been set, all times are defined as 1- or 2-element
C	standard times relative to the time origin.
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	TIME__ORIGIN(1) = TIME__2000_DAY
	TIME__ORIGIN(2) = TIME__2000_SMALL
	TIME__ORIGIN(3) = TIME__2000_UNITS

	call Time2ChangeUnits(units_in_day)

	return
C+
C NAME:
C	Time2GetOrigin2000
C PURPOSE:
C	Get origin for 2000 Jan 1, 0 UT
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2GetOrigin2000(t3)
C PROCEDURE:
C	Initializes the time origin to 2000 Jan 1, 0 UT.
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	t3(1) = TIME__2000_DAY
	t3(2) = TIME__2000_SMALL
	t3(3) = TIME__2000_UNITS

	return
C+
C NAME:
C	Time2SetOriginJD
C PURPOSE:
C	Initialize time tracking by setting origin to Julian day zero
C	with frac. day units in hours
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2SetOriginJD(units_in_day)
C CALLS:
C	Time2ChangeUnits
C PROCEDURE:
C	Initializes the time origin to Julian day 0
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	TIME__ORIGIN(1) = TIME__JD_DAY
	TIME__ORIGIN(2) = TIME__JD_SMALL
	TIME__ORIGIN(3) = TIME__JD_UNITS

	call Time2ChangeUnits(units_in_day)

	return
C+
C NAME:
C	Time2GetOriginJD
C PURPOSE:
C	Get origin for Julian days
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2GetOriginJD(t3)
C PROCEDURE:
C	Initializes the time origin to 2000 Jan 1, 0 UT.
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	t3(1) = TIME__JD_DAY
	t3(2) = TIME__JD_SMALL
	t3(3) = TIME__JD_UNITS

	return
C+
C NAME:
C	Time2SetOriginMJD
C PURPOSE:
C	Initialize time tracking by setting origin to Modified
C	Julian day 0 with frac. day units in hours
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2SetOriginMJD(units_in_day)
C CALLS:
C	Time2ChangeUnits
C PROCEDURE:
C	Initializes the time origin to Modified Julian day 0
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	TIME__ORIGIN(1) = TIME__MJD_DAY
	TIME__ORIGIN(2) = TIME__MJD_SMALL
	TIME__ORIGIN(3) = TIME__MJD_UNITS

	call Time2ChangeUnits(units_in_day)

	return
C+
C NAME:
C	Time2GetOriginMJD
C PURPOSE:
C	Get origin for modified Julian days
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2GetOriginMJD(t3)
C PROCEDURE:
C	Initializes the time origin to 2000 Jan 1, 0 UT.
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	t3(1) = TIME__MJD_DAY
	t3(2) = TIME__MJD_SMALL
	t3(3) = TIME__MJD_UNITS

	return
C+
C NAME:
C	Time2SetOriginIn2000
C PURPOSE:
C	Initialize time tracking by setting origin and frac-day units
C	specified relative to 2000 Jan 1, 0 UT..
C CATEGORY:
C	gen/for/lib
C CALLING SEQUENCE:
	entry Time2SetOriginIn2000(t3)
C INPUTS:
C	t3(3)		integer		time origin defined relative to the
C					absolute time origin 2000, Jan 1, 0 UT.
C					t0(1): # days
C					t0(2): # units in fractional day
C					t0(3): # units in whole day
C
C					t0(3) should be set by using one of the parameters defined
C					in include file fortime.h:
C					Parameter name		Unit is:
C					TIME__HOURS_IN_DAY	hours
C					TIME__MINUTES_IN_DAY	minutes
C					TIME__SECONDS_IN_DAY	seconds		
C					TIME__DSEC_IN_DAY	decisecond (0.1 s)
C					TIME__CSEC_IN_DAY	centisecond (0.01 s)
C					TIME__MSEC_IN_DAY	millisecond (0.001 s)
C CALLS:
C	Time2Standardize
C SIDE EFFECTS:
C	Updates common block included in fortime.h
C PROCEDURE:
C	The specified t3 is added to the absolute time origin 2000 Jan 1.0 to define the new
C	origin.
C MODIFICATION HISTORY:
C	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	TIME__ORIGIN(3) = t3(3)
	call Time2Standardize(t3,TIME__ORIGIN)

	return
	end
