OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
anc_daymon.c
Go to the documentation of this file.
1 #include "l1io.h"
2 
3 int anc_daymon(char *fname, int *jday, char *monstr)
4 /*******************************************************************
5 
6  anc_daymon
7 
8  purpose: find the ancillary file start day and convert that to the month
9 
10  Returns type: int - return status: 0 is good
11 
12  Parameters: (in calling order)
13  Type Name I/O Description
14  ---- ---- --- -----------
15  char * fname I name of file to open
16  int * jday O julian start day
17  char * monstr O month the start is in
18 
19  Modification history:
20  Programmer Date Description of change
21  ---------- ---- ---------------------
22  W. Robinson 17-Jun-1997 Original development
23 
24  *******************************************************************/
25  {
26  l1info_struct hdf_info;
27  int month, day, year;
28  char *mon_list[] = {"January", "February", "March", "April", "May",
29  "June", "July", "August", "September", "October",
30  "November", "December"};
31  int32 count = 1, n_type = DFNT_INT16;
32  int16 i16;
33 
34  /*
35  * open the file and read the julian day
36  */
37  if (open_hdf(fname, &hdf_info) != 0) {
38  printf("anc_daymon: open_hdf error\n");
39  return -1;
40  }
41  if (read_g_attr(hdf_info, "Start Day", &n_type, &count, (void *) &i16) != 0) {
42  printf("anc_daymon: read_g_attr (day) error\n");
43  return -1;
44  }
45  *jday = i16;
46  if (read_g_attr(hdf_info, "Start Year", &n_type, &count, (void *) &i16) != 0) {
47  printf("anc_daymon: read_g_attr (year) error\n");
48  return -1;
49  }
50  year = i16;
51  if (*jday < 1 || *jday > 366) {
52  printf("anc_daymon: ancillary file julian day out of bounds: %d\n",
53  *jday);
54  if (*jday < 1) *jday = 1;
55  if (*jday > 366) *jday = 365;
56  }
57 
58  l1io_close(hdf_info);
59 
60  /*
61  * get the month now
62  */
63  if (day2mday(year, *jday, &month, &day) != 0) {
64  printf("anc_daymon: trouble with day2mday\n");
65  return -1;
66  }
67 
68  strcpy(monstr, mon_list[month - 1]);
69  return 0;
70 }
integer, parameter int16
Definition: cubeio.f90:3
int32 open_hdf(char *fname, l1info_struct *l1info)
Definition: open_hdf.c:5
int32_t day
int32_t jday(int16_t i, int16_t j, int16_t k)
Definition: jday.c:4
int anc_daymon(char *fname, int *jday, char *monstr)
Definition: anc_daymon.c:3
int32 read_g_attr(l1info_struct l1info, char *name, int32 *n_type, int32 *count, void *data)
Definition: read_g_attr.c:6
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT16
int day2mday(int year, int day_of_year, int *month, int *day_of_month)
Definition: day2mday.c:3
void l1io_close(l1info_struct)
Definition: l1io_close.c:4
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int count
Definition: decode_rs.h:79