OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l0cnst_read_modis.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <PGS_TD.h>
5 
6 #define buffsize_mb 0.5
7 #define primary_hdr_size 6
8 
9 int main(int argc, char *argv[]) {
10  int tptr;
11 
12  //static int pkt_len_off = 4;
13  //static int time_cnt = 8;
14  //static int day_pkt_size = 642;
15  //static int night_pkt_size = 276;
16  static unsigned char start_time_tag[8];
17  static unsigned char stop_time_tag[8];
18 
19  double taitime_start;
20  double taitime_stop;
21 
22  unsigned char inbuf[384];
23  FILE *stream;
24 
25  printf("read_constructor_file: Version as of 06/18/04\n\n");
26 
27  stream = fopen(argv[1], "r");
28  if (stream == NULL) {
29  printf("%s not found.\n", argv[1]);
30  exit(-1);
31  }
32  fseek(stream, (long) 0, SEEK_SET);
33 
34 
35  fread(inbuf, sizeof (char), 384, stream);
36 
37  tptr = 64 + 16 * inbuf[51];
38  memcpy(start_time_tag, &inbuf[tptr], 8);
39  memcpy(stop_time_tag, &inbuf[tptr + 8], 8);
40 
41  fclose(stream);
42 
43  PGS_TD_EOSAMtoTAI(start_time_tag, &taitime_start);
44  PGS_TD_EOSAMtoTAI(stop_time_tag, &taitime_stop);
45  printf("starttimeTAI=%f\n", taitime_start);
46  printf("stoptimeTAI =%f\n", taitime_stop);
47 
48  PGS_TD_TAItoUTC(taitime_start, (char*) inbuf);
49  printf("starttime=%s\n", inbuf);
50  PGS_TD_TAItoUTC(taitime_stop, (char*) inbuf);
51  printf("stoptime =%s\n", inbuf);
52 
53  printf("granule length =%f\n", (taitime_stop - taitime_start) / 60.0);
54 
55 
56  return 0;
57 }
#define NULL
Definition: decode_rs.h:63
int main(int argc, char *argv[])