OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
suncnst.f
Go to the documentation of this file.
1  subroutine suncnst(gaclac,navqc,sunrng,sun)
2 c
3 c suncnst(gaclac,navqc,sunrng,sun)
4 c
5 c Purpose: check consistency of the sun sensor data for the 3 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 5 lines
14 c and the lines are 4scan lines apart
15 c navqc struct I navigation quality control info
16 c sunrng I*4 I/O size 2 by 3 array of active range for
17 c the 3 sun sensors
18 c sun struct I/O sun sensor data structure
19 c
20 c By: W. Robinson, GSC, 1 Apr 93
21 c
22 c Notes:
23 c
24 c Modification History:
25 c
26 c Corrected logic of difference comparison to use absolute value.
27 c F. S. Patt, GSC, December 3, 1997.
28 c
29 c Modified tolerance multiplier for GAC data.
30 c F. S. Patt, SAIC GSC, June 25, 1998.
31 c
32 c Added logic to change sunrng according to first and last unflagged values.
33 c F. S. Patt, SAIC GSC, August 14, 1998.
34 c
35 c Added a check for maximum gap between samples, since the usefulness of this
36 c check degrades with gap size.
37 c F. S. Patt, SAIC GSC, August 25, 1998.
38 
39 
40  implicit none
41 #include "tlm_str.fin"
42 #include "navqc_s.fin"
43  type(sun_struct) :: sun(3)
44  type(navqc_struct) :: navqc
45 c
46  integer*4 gaclac, sunrng(2,3)
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 3 sensors ( if they are active)
67 c
68  do isens = 1,3
69  if( sunrng(1,isens) .ne. -1 ) then
70 c
71 c check the consistency of angles
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 = sunrng(2,isens) ! only go searching flags to end
78 c of active range
79 c
80 c start out by finding the next unflagged sun angle set
81 c
82  call fndflg(sun(isens)%flag, nrng, sunrng(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(' SUNCNST: no unflagged sun angle values found',
89  1 /,' for sensor:',i7)
90  sunrng(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(sun(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) = sun(isens)%ang(1,i2) - sun(isens)%ang(1,i1)
105  diff(2) = sun(isens)%ang(2,i2) - sun(isens)%ang(2,i1)
106  toldif(1) = navqc%sun_del_1 * ( i2 - i1 ) *
107  1 nper * tolmult
108  toldif(2) = navqc%sun_del_2 * ( i2 - i1 ) *
109  1 nper * tolmult
110 c
111  if( ( abs(diff(1)) .gt. toldif(1) ) .or.
112  1 ( abs(diff(2)) .gt. toldif(2) ) .or.
113  2 ( (i2-i1) .gt. maxgap ) ) then
114  if ( .not. gottwo) sun(isens)%flag(i1) = 1
115  gottwo = .false.
116 c sun(isens)%flag(i2) = 1
117  else
118  if (.not.found) then
119  j1 = i1
120  found = .true.
121  end if
122  gottwo = .true.
123  j2 = i2
124  end if
125 c
126 c for next pair, move secind pointer to the first
127  i1 = i2
128  end if
129  end do
130 c
131 c make sure a consistent pair was found
132 c
133  if( .not. found ) then
134  write( 6, 500 ) isens
135  500 format(' SUNCNST: no consistent pairs of sun sensor',/,
136  1 ' angles were found for sensor:',i7)
137  sunrng(1,isens) = -1
138  go to 980
139  else
140 
141 c check first and last unflagged values vs sunrng
142  if (j1 .gt. sunrng(1,isens)) sunrng(1,isens) = j1
143  if (j2 .lt. sunrng(2,isens)) sunrng(2,isens) = j2
144  end if
145 c
146  980 continue
147  end if
148  end do
149 c
150 c and end
151 c
152  990 continue
153  return
154  end
#define real
Definition: DbAlgOcean.cpp:26
subroutine fndflg(flag, nflag, istndx, next)
Definition: fndflg.f:2
subroutine suncnst(gaclac, navqc, sunrng, sun)
Definition: suncnst.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