Viewing contents of file '../idllib/uit/pro/comp_nite.pro'
PRO comp_nite, times, start_time, stop_time, time_res
;+
; NAME:
; COMP_NITE
; PURPOSE:
; To determine the sunset and sunrise times for a shuttle in orbit
; during a given range of time.
; CALLING SEQUENCE:
; comp_nite, times, start_time, stop_time [, time_res]
; INPUTS:
; start_time - The start of the time range, in hours MET.
; stop_time - The end of the time range, in hours MET.
; time_res - The time resolution (the max. error in the reported
; times), in hours. Defaults to 15 sec. (note: going
; much finer will result in arithmetic errors).
; OUTPUTS:
; times - An array of structures containing sunrise and sunset
; times, in hours MET. The structure declaration is:
; {TIME_STRCT, rise_time:0.0d, set_time:0.0d}
; COMMON BLOCKS:
; mission_comm - Contains a structure which, in turn, contains the
; orbit parameters.
; RESTRICTIONS:
; The SETORB procedure must be called before using this procedure.
; PROCEDURE:
; CALL_EXTERNAL is used to call the "compnite" C function. This
; function steps through the time range, in time_res increments,
; looking for changes between day and night. These times are
; recorded in the output arrays.
; MODIFICATION HISTORY:
; Written by Michael R. Greason, Hughes STX, 20 November 1992.
;-
; Check arguments.
;
np = n_params(0)
IF (np LT 3) THEN message, 'Syntax: comp_nite, times, ' + $
'start_time, stop_time, time_res'
IF (np LT 4) THEN time_res = 15.d / 3600.d
;
; Define common blocks.
;
COMMON mission_comm, mission_inf
;
; Create the output arrays with 2000 elements each.
;
st = dblarr(2000)
rt = st
;
; Perform the CALL_EXTERNAL.
;
IF (!version.os EQ 'sunos') THEN BEGIN
libfile = getenv('IDL_HOME') + '/extern/look/look.so'
ENDIF ELSE BEGIN
libfile = 'cprog'
ENDELSE
n = call_external(libfile, 'compnite', mission_inf, st, rt, $
double(start_time), double(stop_time), double(time_res), $
VALUE=[0B,0B,0B,0B,0B])
;
; Get rid of the excess array elements. If no
; elements were filled, return [-1.]'s as the first
; (and only) element in each time in the output array.
;
IF (n GT 0) THEN BEGIN
times = replicate({TIME_STRCT, rise_time:0.d, set_time:0.d}, n)
n = n - 1
times.set_time = st(0:n)
times.rise_time = rt(0:n)
ENDIF ELSE BEGIN
times = {TIME_STRCT, rise_time:-1.d, set_time:-1.d}
ENDELSE
st = 0 ; House-cleaning.
rt = 0
;
RETURN
END