OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
b128_wd_bit.c
Go to the documentation of this file.
1 #include <math.h>
2 
3 int b128_wd_bit(float lat_off, float lon_off, int *box_wd, int *box_bit)
4 /*******************************************************************
5 
6  b128_box_num
7 
8  purpose: for the 128 / degree land mask file, find the
9  index of the degree box from the lat, lon
10 
11  Returns type: int - nothing now, later, maybe an error condition
12 
13  Parameters: (in calling order)
14  Type Name I/O Description
15  ---- ---- --- -----------
16  float lat_off I all positive latitude
17  generated in call to
18  b128_box_num
19  float lon_off I all positive longitude
20  as above
21  int * box_wd O word # in array of
22  128 sq box to find
23  desired mask value
24  int * box_bit O bit # in word of
25  desired mask value
26 
27  Modification history:
28  Programmer Date Description of change
29  ---------- ---- ---------------------
30  W. Robinson 8-Oct-1997 Original development
31 
32  *******************************************************************/ {
33  int lat_sub, lon_sub;
34  int lon_wd;
35  double dumb;
36 
37  /*
38  * find distance in to the bit from edge of 128 by 128 array
39  */
40  lat_sub = (int) (modf(lat_off, &dumb) * 128);
41  if (lat_off == 180.) lat_sub = 127;
42 
43  lon_sub = (int) (modf(lon_off, &dumb) * 128);
44  if (lon_off == 360.) lon_sub = 127;
45  /*
46  * get the word in longitude direction and bit and then get linear word
47  */
48  lon_wd = lon_sub / 16;
49  *box_bit = lon_sub - lon_wd * 16;
50  *box_wd = lon_wd + lat_sub * 8;
51 
52  return 0;
53 }
int b128_wd_bit(float lat_off, float lon_off, int *box_wd, int *box_bit)
Definition: b128_wd_bit.c:3