OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
asap_rot_int.f
Go to the documentation of this file.
1  subroutine asap_rot_int(nstp,iyinit,idinit,tsap,asap,ngps,
2  * igyr,igday,gpsec,vecs)
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 iyinit I*4 I ASAP time tag year
14 c idinit I*4 I ASAP time tag day
15 c tsap(nstp) R*8 I ASAP time tag seconds-of-day
16 c asap(6,nstp) R*8 I ASAP orbit vectors (inertial)
17 c ngps I*4 I Number of GPS sample times
18 c igyr I*4 I GPS time tag year
19 c igday I*4 I GPS time tag year
20 c gpsec(nstp) R*8 I GPS time tag seconds-of-day
21 c vecs(6,nstp) R*8 I Interpolated ASAP vectors
22 c
23 c
24 c By: Frederick S. Patt, GSC, December 22, 1993
25 c
26 c Notes: Method uses cubic polynomial to match positions and velocities
27 c at input data points.
28 c
29 c Modification History:
30 c
31 c Corrected logic to allow for times out of ascending order
32 c
33 c Added error return code
34 c F. S. Patt, July 19, 2011
35 
36  implicit none
37 c
38  real*8 asap(6,*),tsap(*),vecs(6,*),gpsec(*)
39  real*8 a0(3),a1(3),a2(3),a3(3),vt(6,2)
40  real*8 tsap1,tsap2,t,dift,dt,x,x2,x3
41  integer*4 nstp,iyinit,idinit,ngps,igyr,igday,jd
42  integer*4 ind, i, j, i1, nr
43  data nr/2/
44 
45  ind = 1
46  tsap2 = -1.d6
47  tsap1 = 1.d6
48 
49  dift = (jd(igyr,1,igday) - jd(iyinit,1,idinit))*864.d2
50 
51 c Start main interpolation loop
52  do i=1,ngps
53  t = dift + gpsec(i)
54 
55 c Check if GPS time is outside range of current ASAP vectors
56  if ((t.gt.tsap2).or.(t.lt.tsap1)) then
57  if (t.gt.tsap(ind+1)) then
58  do while (t.gt.tsap(ind+1))
59  ind = ind + 1
60  if (ind.ge.nstp) then
61  print *, 'GPS times after available ASAP data'
62  do j=1,6
63  vecs(j,i) = 0.d0
64  end do
65  ind = 1
66  go to 990
67  end if
68  end do
69  else
70  do while (t.lt.tsap(ind))
71  ind = ind - 1
72  if (ind.lt.1) then
73  print *, 'GPS times before available ASAP data'
74  do j=1,6
75  vecs(j,i) = 0.d0
76  end do
77  ind = 1
78  go to 990
79  end if
80  end do
81  end if
82 
83 c Set up cubic interpolation
84  dt = tsap(ind+1) - tsap(ind)
85  call asap_rots(iyinit,idinit,tsap(ind),asap(1,ind),nr,vt)
86  do j=1,3
87  a0(j) = vt(j,1)
88  a1(j) = vt(j+3,1)*dt
89  a2(j) = 3.d0*vt(j,2) - 3.d0*vt(j,1)
90  * - 2.d0*vt(j+3,1)*dt - vt(j+3,2)*dt
91  a3(j) = 2.d0*vt(j,1) - 2.d0*vt(j,2)
92  * + vt(j+3,1)*dt + vt(j+3,2)*dt
93  end do
94  tsap1 = tsap(ind)
95  tsap2 = tsap(ind+1)
96  end if
97 
98 c Interpolate orbit position and velocity components to GPS time
99  x = (t - tsap1)/dt
100  x2 = x*x
101  x3 = x2*x
102  do j=1,3
103  vecs(j,i) = a0(j) + a1(j)*x + a2(j)*x2 + a3(j)*x3
104  vecs(j+3,i) = (a1(j) + 2.*a2(j)*x + 3.*a3(j)*x2)/dt
105  end do
106 
107  end do
108  return
109 
110  990 call exit(1)
111 
112  end
#define real
Definition: DbAlgOcean.cpp:26
subroutine asap_rot_int(nstp, iyinit, idinit, tsap, asap, ngps, igyr, igday, gpsec, vecs)
Definition: asap_rot_int.f:3
Definition: jd.py:1
subroutine asap_rots(iyinit, idinit, tsap, asap, nstp, vecs)
Definition: asap_rots.f:2