OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
asap_int2.f
Go to the documentation of this file.
1  subroutine asap_int2( nstp, tsap, asap, pos_erri, ngps,
2  * gpsec, vecs, pos_erro )
3 c
4 c Purpose: Rotate ASAP orbit vectors to ECEF coordinates and interplolate
5 c to GPS sample times
6 c
7 c
8 c Calling Arguments:
9 c
10 c Name Type I/O Description
11 c -------- ---- --- -----------
12 c nstp I*4 I Number of ASAP vectors
13 c tsap(nstp) R*8 I ASAP time tag seconds-of-day
14 c asap(6,nstp) R*8 I ASAP orbit vectors (inertial)
15 c pos_erri(nstp) R*8 I position error , meters
16 c ngps I*4 I Number of GPS sample times
17 c gpsec(ngps) R*8 I GPS time tag seconds-of-day
18 c vecs(6,ngps) R*8 O Interpolated ASAP vectors
19 c pos_erro(ngps) R*4 O interpolated position errors (linearly)
20 c
21 c
22 c By: Frederick S. Patt, GSC, December 22, 1993
23 c
24 c Notes: Method uses cubic polynomial to match positions and velocities
25 c at input data points.
26 c
27 c Modification History:
28 c
29 c Corrected logic to allow for times out of ascending order
30 c W. Robinson, SAIC, 19 Dec 2005 adapted for use with CZCS daily orbit data
31 c and to linearly interpolate the position error information
32 c
33  implicit none
34 c
35  real*8 asap(6,*),tsap(*),vecs(6,*),gpsec(*)
36  real*8 a0(3),a1(3),a2(3),a3(3),vt(6,2)
37  real*8 tsap1,tsap2,t,dift,dt,x,x2,x3
38  real*8 pos_erri(*)
39  real*4 pos_erro(*)
40  integer*4 nstp,iyinit,idinit,ngps,igyr,igday,jd
41  integer*4 ind, i, j, i1, nr
42  data nr/2/
43 
44  ind = 1
45  tsap2 = -1.d6
46  tsap1 = 1.d6
47 
48  dift = 0.
49 
50 c Start main interpolation loop
51  do i=1,ngps
52  t = dift + gpsec(i)
53 
54 c Check if GPS time is outside range of current ASAP vectors
55  if ((t.gt.tsap2).or.(t.lt.tsap1)) then
56  if (t.gt.tsap(ind+1)) then
57  dowhile(t.gt.tsap(ind+1))
58  ind = ind + 1
59  if (ind.ge.nstp) then
60  write(*,*) 'GPS times after available ASAP data'
61  do j=1,6
62  vecs(j,i) = 0.d0
63  end do
64  ind = 1
65  pos_erro(i) = -1
66  go to 990
67  end if
68  end do
69  else
70  dowhile(t.lt.tsap(ind))
71  ind = ind - 1
72  if (ind.lt.1) then
73  write(*,*) 'GPS times before available ASAP data'
74  do j=1,6
75  vecs(j,i) = 0.d0
76  end do
77  ind = 1
78  pos_erro(i) = -1
79  go to 990
80  end if
81  end do
82  end if
83 
84 
85 c Set up cubic interpolation
86  dt = tsap(ind+1) - tsap(ind)
87 c call asap_rots(iyinit,idinit,tsap(ind),asap(1,ind),nr,vt)
88  do j=1,6
89  vt(j,1) = asap(j,ind)
90  vt(j,2) = asap(j,ind+1)
91  end do
92  do j=1,3
93  a0(j) = vt(j,1)
94  a1(j) = vt(j+3,1)*dt
95  a2(j) = 3.d0*vt(j,2) - 3.d0*vt(j,1)
96  * - 2.d0*vt(j+3,1)*dt - vt(j+3,2)*dt
97  a3(j) = 2.d0*vt(j,1) - 2.d0*vt(j,2)
98  * + vt(j+3,1)*dt + vt(j+3,2)*dt
99  end do
100  tsap1 = tsap(ind)
101  tsap2 = tsap(ind+1)
102  end if
103 
104 c Interpolate orbit position and velocity components to GPS time
105 c also, just linearly interpolate the position error values
106  x = (t - tsap1)/dt
107  x2 = x*x
108  x3 = x2*x
109  do j=1,3
110  vecs(j,i) = a0(j) + a1(j)*x + a2(j)*x2 + a3(j)*x3
111  vecs(j+3,i) = (a1(j) + 2.*a2(j)*x + 3.*a3(j)*x2)/dt
112  end do
113 
114  pos_erro(i) = pos_erri(ind) * ( 1. - x ) + pos_erri(ind+1) * x
115 
116  990 continue
117  end do
118  return
119 
120  end
subroutine asap_int2(nstp, tsap, asap, pos_erri, ngps, gpsec, vecs, pos_erro)
Definition: asap_int2.f:3
#define real
Definition: DbAlgOcean.cpp:26