Due to the lapse in federal government funding, NASA is not updating this website. We sincerely regret this inconvenience.
NASA Logo
Ocean Color Science Software

ocssw V2022
earcnst.f
Go to the documentation of this file.
1  subroutine earcnst(gaclac,navqc,earrng,earth)
2 c
3 c earcnst(gaclac,navqc,earrng,earth)
4 c
5 c Purpose: check consistency of the earth sensor data for the 2 sensors
6 c
7 c Calling Arguments:
8 c
9 c Name Type I/O Description
10 c -------- ---- --- -----------
11 c gaclac I*4 I flag for GAC or LAC data. If LAC
12 c data, there is 1 TLM for 3 lines
13 c else only once every 15 lines
14 c and the lines are 14 scan lines apart
15 c navqc struct I navigation quality control info
16 c earrng I*4 I/O size 2 (low, hi) by 2 (sensor 1, 2)
17 c array of active range for
18 c the 2 sun sensors
19 c earth struct I/O earth sensor data structure
20 c
21 c By: W. Robinson, GSC, 13 Apr 93
22 c
23 c Notes:
24 c
25 c Modification History:
26 c
27 c Corrected logic of difference comparison to use absolute value.
28 c F. S. Patt, GSC, December 3, 1997.
29 c
30 c Fixed bug which caused width tolerance to be used for both angles.
31 c F. S. Patt, SAIC GSC, April 26. 1998
32 c
33 c Added a check for maximum gap between samples, since the usefulness of this
34 c check degrades with gap size.
35 c F. S. Patt, SAIC GSC, September 14, 1998.
36 c
37 c Added logic to change earrng according to first and last unflagged values.
38 c F. S. Patt, SAIC GSC, February 3, 1999.
39 
40  implicit none
41 #include "tlm_str.fin"
42 #include "navqc_s.fin"
43  type(earth_struct) :: earth(2)
44  type(navqc_struct) :: navqc
45 c
46  integer*4 gaclac, earrng(2,2)
47 c
48  real*4 toldif(2)
49 c
50  integer*4 i1, i2, j1, j2, nper, nrng, isens, maxgap
51  logical found, end, gottwo
52  real*4 tolmult, diff(2)
53  data maxgap/6/
54 
55 c
56 c
57 c set up some controls
58 c
59  nper = 1
60  tolmult = 1.
61  if( gaclac .eq. 1 ) then
62  nper = 5 ! # actual lines per tlm line
63 c tolmult = 4. ! second tolerence multiplier
64  end if
65 c
66 c loop over the 2 sensors ( if they are active)
67 c
68  do isens = 1,2
69  if( earrng(1,isens) .ne. -1 ) then
70 c
71 c check the consistency of the width and phase
72 c
73  i2 = 0 ! i1, i2 are pointers to consecutive good values
74  end = .FALSE. ! true if the last unflagged value was found
75  found = .false. ! to signal that a consistent pair was found
76  gottwo = .false.! to signal that previous pair was consistent
77  nrng = earrng(2,isens) ! only go searching flags to end
78 c of active range
79 c
80 c start out by finding the next unflagged earth angle set
81 c
82  call fndflg(earth(isens)%flag, nrng, earrng(1,isens), i1 )
83  if( i1 .le. 0 ) then
84 c
85 c no unflagged values found at all, return with error
86 c
87  write( 6, 100 ) isens
88  100 format(' EARCNST: no unflagged earth angle values found',
89  1 /,' for sensor:',i7)
90  earrng(1,isens) = -1
91  go to 980
92  end if
93 c
94 c place the next unflagged location in i2 and compare values
95 c
96  do while( .not. end )
97  call fndflg(earth(isens)%flag, nrng, (i1 + 1), i2 )
98  if( i2 .le. 0 ) then
99  end = .TRUE.
100  else
101 c
102 c do the actual consistency checks
103 c
104  diff(1) = earth(isens)%widphse(1,i2) -
105  1 earth(isens)%widphse(1,i1)
106  diff(2) = earth(isens)%widphse(2,i2) -
107  1 earth(isens)%widphse(2,i1)
108  toldif(1) = navqc%ear_del_wd* ( i2 - i1 ) *
109  1 nper * tolmult
110  toldif(2) = navqc%ear_del_ph* ( i2 - i1 ) *
111  1 nper * tolmult
112 c
113  if( ( abs(diff(1)) .gt. toldif(1) ) .or.
114  1 ( abs(diff(2)) .gt. toldif(2) ) .or.
115  2 ( (i2-i1) .gt. maxgap ) ) then
116  if ( .not. gottwo) earth(isens)%flag(i1) = 1
117  gottwo = .false.
118 c earth(isens)%flag(i2) = 1
119  else
120  if (.not.found) then
121  j1 = i1
122  found = .true.
123  end if
124  gottwo = .true.
125  j2 = i2
126  end if
127 
128 c
129 c for next pair, move second pointer to the first
130  i1 = i2
131  end if
132  end do
133 
134 c check for last point passing check
135  if ( .not. gottwo) earth(isens)%flag(i1) = 1
136 c
137 c make sure a consistent pair was found
138 c
139 
140  if( .not. found ) then
141  write( 6, 500 ) isens
142  500 format(' EARCNST: no consistent pairs of earth sensor',/,
143  1 ' width, phase were found for sensor:',i7)
144  earrng(1,isens) = -1
145  go to 980
146  else
147 
148 c check first and last unflagged values vs sunrng
149  if (j1 .gt. earrng(1,isens)) earrng(1,isens) = j1
150  if (j2 .lt. earrng(2,isens)) earrng(2,isens) = j2
151 
152  end if
153 c
154  980 continue
155  end if
156  end do
157 c
158 c and end
159 c
160  990 continue
161  return
162  end
subroutine earcnst(gaclac, navqc, earrng, earth)
Definition: earcnst.f:2
subroutine earth(pos, vel, widphse1, widphfl1, widphse2,
Definition: earth.f:2
#define real
Definition: DbAlgOcean.cpp:26
subroutine fndflg(flag, nflag, istndx, next)
Definition: fndflg.f:2
subroutine diff(x, conec, n, dconecno, dn, dconecmk, units, u, inno, i, outno, o, input, deriv)
Definition: ffnet.f:205
#define abs(a)
Definition: misc.h:90