132 if ((attr_buf = (
char *) calloc(
LG_ATTRSZ + 1,
sizeof (
char))) ==
NULL) {
133 printf(
"%s -Error: Cannot allocate memory for attribute buffer\n",
149 meta_l3b->
orbit = -1;
161 strcpy(attr_name,
"product_name");
163 strcpy(attr_name,
"Product Name");
167 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
168 printf(
" size is greater than it is defined in meta_l3b ");
169 printf(
"\nstructure. Attr size read = %d\n",
count);
170 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
187 strcpy(attr_name,
"title");
189 strcpy(attr_name,
"Title");
193 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
194 printf(
" size is greater than it is defined in meta_l3b ");
195 printf(
"\nstructure. Attr size read = %d\n",
count);
196 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
201 if ((
rdattr(sdfid, attr_name, (VOIDP *) meta_l3b->
title)) < 0)
213 strcpy(attr_name,
"instrument");
215 strcpy(attr_name,
"Sensor Name");
219 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
220 printf(
" size is greater than it is defined in meta_l3b ");
221 printf(
"\nstructure. Attr size read = %d\n",
count);
222 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
246 strcpy(attr_name,
"units");
248 strcpy(attr_name,
"Units");
252 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
253 printf(
" size is greater than it is defined in meta_l3b ");
254 printf(
"\nstructure. Attr size read = %d\n",
count);
255 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
260 if ((
rdattr(sdfid, attr_name, (VOIDP *) meta_l3b->
units)) < 0)
272 strcpy(attr_name,
"platform");
275 strcpy(attr_name,
"Mission");
279 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
280 printf(
" size is greater than it is defined in meta_l3b ");
281 printf(
"\nstructure. Attr size read = %d\n",
count);
282 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
290 if ((
rdattr(sdfid, attr_name, (VOIDP *) meta_l3b->
mission)) < 0)
303 strcpy(attr_name,
"temporal_range");
305 strcpy(attr_name,
"Product Type");
309 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
310 printf(
" size is greater than it is defined in meta_l3b ");
311 printf(
"\nstructure. Attr size read = %d\n",
count);
312 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
329 strcpy(attr_name,
"processing_version");
333 strcpy(attr_name,
"Processing Version");
337 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
338 printf(
" size is greater than it is defined in meta_l3b ");
339 printf(
"\nstructure. Attr size read = %d\n",
count);
340 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
361 strcpy(attr_name,
"date_created");
363 strcpy(attr_name,
"Processing Time");
367 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
368 printf(
" size is greater than it is defined in meta_l3b ");
369 printf(
"\nstructure. Attr size read = %d\n",
count);
370 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
375 if ((
rdattr(sdfid, attr_name, (VOIDP *) meta_l3b->
ptime)) < 0)
387 strcpy(attr_name,
"history");
389 strcpy(attr_name,
"Processing Control");
393 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
394 printf(
" size is greater than it is defined in meta_l3b ");
395 printf(
"\nstructure. Attr size read = %d\n",
count);
396 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
409 strcpy(attr_name,
"L2 Flag Names");
412 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
413 printf(
" size is greater than it is defined in meta_l3b ");
414 printf(
"\nstructure. Attr size read = %d\n",
count);
415 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
433 strcpy(attr_name,
"time_coverage_start");
435 strcpy(attr_name,
"Start Time");
439 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
440 printf(
" size is greater than it is defined in meta_l3b structure.");
443 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
445 if (strstr(attr_buf,
"T") !=
NULL) {
459 strcpy(attr_name,
"time_coverage_end");
461 strcpy(attr_name,
"End Time");
465 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
466 printf(
" size is greater than it is defined in meta_l3b structure.");
469 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
471 if (strstr(attr_buf,
"T") !=
NULL) {
479 if ((
rdattr(sdfid,
"Start Orbit", (VOIDP *) & meta_l3b->
start_orb)) < 0)
480 if ((
rdattr(sdfid,
"start_orbit_number", (VOIDP *) & meta_l3b->
start_orb))
485 if ((
rdattr(sdfid,
"End Orbit", (VOIDP *) & meta_l3b->
end_orb)) < 0)
486 if ((
rdattr(sdfid,
"end_orbit_number", (VOIDP *) & meta_l3b->
end_orb))
497 strcpy(attr_name,
"geospatial_lat_units");
499 strcpy(attr_name,
"Latitude Units");
503 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
504 printf(
" size is greater than it is defined in meta_l3b ");
505 printf(
"\nstructure. Attr size read = %d\n",
count);
506 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
523 strcpy(attr_name,
"geospatial_lon_units");
525 strcpy(attr_name,
"Longitude Units");
529 printf(
"\n****read_attrs: Attribute '%s'", attr_name);
530 printf(
" size is greater than it is defined in meta_l3b ");
531 printf(
"\nstructure. Attr size read = %d\n",
count);
532 if ((
rdattr(sdfid, attr_name, (VOIDP *) attr_buf)) < 0)
544 if ((
rdattr(sdfid,
"Data Bins", (VOIDP *) &tmpInt)) < 0)
545 if ((
rdattr(sdfid,
"data_bins", (VOIDP *) &tmpInt)) < 0)
552 if ((
rdattr(sdfid,
"percent_data_bins",
559 printf(
"\n****read_attrs: Attribute '%s'",
"Software Name");
560 printf(
" size is greater than it is defined in meta_l3b ");
561 printf(
"\nstructure. Attr size read = %d\n",
count);
562 if ((
rdattr(sdfid,
"Software Name", (VOIDP *) attr_buf)) < 0)
577 printf(
"\n****read_attrs: Attribute '%s'",
"Software Version");
578 printf(
" size is greater than it is defined in meta_l3b ");
579 printf(
"\nstructure. Attr size read = %d\n",
count);
580 if ((
rdattr(sdfid,
"Software Version", (VOIDP *) attr_buf)) < 0)
585 if ((
rdattr(sdfid,
"Software Version", (VOIDP *) meta_l3b->
soft_ver))
595 printf(
"\n****read_attrs: Attribute '%s'",
"Input Files");
596 printf(
" size is greater than it is defined in meta_l3b ");
597 printf(
"\nstructure. Attr size read = %d\n",
count);
598 if ((
rdattr(sdfid,
"Input Files", (VOIDP *) attr_buf)) < 0)
603 if ((
rdattr(sdfid,
"Input Files", (VOIDP *) meta_l3b->
infiles)) < 0)
612 printf(
"\n****read_attrs: Attribute '%s'",
"Input Parameters");
613 printf(
" size is greater than it is defined in meta_l3b ");
614 printf(
"\nstructure. Attr size read = %d\n",
count);
615 if ((
rdattr(sdfid,
"Input Parameters", (VOIDP *) attr_buf)) < 0)
620 if ((
rdattr(sdfid,
"Input Parameters",
628 if ((
getattrsz(sdfid,
"Northernmost Latitude", &nt, &
count) == 0)) {
629 if ((
rdattr(sdfid,
"Northernmost Latitude", (VOIDP *) & meta_l3b->
north)) < 0)
633 if ((
getattrsz(sdfid,
"Southernmost Latitude", &nt, &
count) == 0)) {
634 if ((
rdattr(sdfid,
"Southernmost Latitude", (VOIDP *) & meta_l3b->
south)) < 0)
638 if ((
getattrsz(sdfid,
"Easternmost Longitude", &nt, &
count) == 0)) {
639 if ((
rdattr(sdfid,
"Easternmost Longitude", (VOIDP *) & meta_l3b->
east)) < 0)
643 if ((
getattrsz(sdfid,
"Westernmost Longitude", &nt, &
count) == 0)) {
644 if ((
rdattr(sdfid,
"Westernmost Longitude", (VOIDP *) & meta_l3b->
west)) < 0)
650 if ((
rdattr(sdfid,
"Bin Resolution",
651 (VOIDP *) attr_buf)) < 0)
659 printf(
"\n****read_attrs: Attribute '%s'",
"Binning Scheme");
660 printf(
" size is greater than it is defined in meta_l3b ");
661 printf(
"\nstructure. Attr size read = %d\n",
count);
662 if ((
rdattr(sdfid,
"Binning Scheme", (VOIDP *) attr_buf)) < 0)
667 if ((
rdattr(sdfid,
"Binning Scheme",
703 int32_t
rdattr(int32_t sdfid,
char *attr_name,
void *buf) {
708 attrnum = SDfindattr(sdfid, attr_name);
709 if ((SDreadattr(sdfid, attrnum, buf)) < 0)
712 status = nc_get_att(-sdfid, NC_GLOBAL, attr_name, buf);
754 attrnum = SDfindattr(
id, attr_name);
755 if ((SDattrinfo(
id, attrnum,
name, nt,
count)) < 0)
759 status = nc_inq_attlen(-
id, NC_GLOBAL, attr_name, &cnt);
772 hid_t atype = H5Tcopy(H5T_C_S1);
774 if ((attr_buf = (
char *) calloc(MAX_ORDER + 1,
sizeof (
char))) ==
NULL) {
775 printf(
"%s -Error: Cannot allocate memory for attribute buffer\n",
792 meta_l3b->
orbit = -1;
798 attr = H5Aopen_name(grp0,
"Product Name");
803 attr = H5Aopen_name(grp0,
"Title");
805 H5Aread(attr, atype, &meta_l3b->
title);
808 attr = H5Aopen_name(grp0,
"Sensor");
813 attr = H5Aopen_name(grp0,
"Sensor Characteristics");
825 attr = H5Aopen_name(grp0,
"Mission");
827 attr = H5Aopen_name(grp0,
"mission");
829 H5Aread(attr, atype, &meta_l3b->
mission);
832 attr = H5Aopen_name(grp0,
"Mission Characteristics");
839 attr = H5Aopen_name(grp0,
"Processing Version");
841 H5Aread(attr, atype, &meta_l3b->
pversion);
844 attr = H5Aopen_name(grp0,
"Software Name");
846 H5Aread(attr, atype, &meta_l3b->
soft_name);
849 attr = H5Aopen_name(grp0,
"Software ID");
851 H5Aread(attr, atype, &meta_l3b->
soft_ver);
854 attr = H5Aopen_name(grp0,
"Processing Time");
856 H5Aread(attr, atype, &meta_l3b->
ptime);
859 attr = H5Aopen_name(grp0,
"Processing Control");
861 H5Aread(attr, atype, &meta_l3b->
proc_con);
864 attr = H5Aopen_name(grp0,
"L2 Flag Names");
869 attr = H5Aopen_name(grp0,
"Start Orbit");
870 H5Aread(attr, H5T_STD_U32LE, &meta_l3b->
start_orb);
873 attr = H5Aopen_name(grp0,
"End Orbit");
874 H5Aread(attr, H5T_STD_U32LE, &meta_l3b->
end_orb);
877 attr = H5Aopen_name(grp0,
"Start Time");
879 H5Aread(attr, atype, attr_buf);
883 attr = H5Aopen_name(grp0,
"End Time");
885 H5Aread(attr, atype, attr_buf);
889 attr = H5Aopen_name(grp0,
"Latitude Units");
891 H5Aread(attr, atype, &meta_l3b->
lat_units);
894 attr = H5Aopen_name(grp0,
"Longitude Units");
896 H5Aread(attr, atype, &meta_l3b->
lon_units);
899 attr = H5Aopen_name(grp0,
"Data Bins");
901 H5Aread(attr, H5T_STD_U32LE, &tmpInt);
905 attr = H5Aopen_name(grp0,
"Percent Data Bins");
906 H5Aread(attr, H5T_NATIVE_FLOAT, &meta_l3b->
pct_databins);
909 attr = H5Aopen_name(grp0,
"Northernmost Latitude");
910 H5Aread(attr, H5T_NATIVE_FLOAT, &meta_l3b->
north);
913 attr = H5Aopen_name(grp0,
"Southernmost Latitude");
914 H5Aread(attr, H5T_NATIVE_FLOAT, &meta_l3b->
south);
917 attr = H5Aopen_name(grp0,
"Easternmost Longitude");
918 H5Aread(attr, H5T_NATIVE_FLOAT, &meta_l3b->
east);
921 attr = H5Aopen_name(grp0,
"Westernmost Longitude");
922 H5Aread(attr, H5T_NATIVE_FLOAT, &meta_l3b->
west);
935 if ((attr_buf = (
char *) calloc(MAX_ORDER + 1,
sizeof (
char))) ==
NULL) {
936 printf(
"%s -Error: Cannot allocate memory for attribute buffer\n",
949 meta_l3b->
orbit = -1;
952 nc_get_att(ncid, NC_GLOBAL,
"product_name", &meta_l3b->
product_name);
953 nc_get_att(ncid, NC_GLOBAL,
"title", &meta_l3b->
title);
954 nc_get_att(ncid, NC_GLOBAL,
"instrument", &meta_l3b->
sensor);
955 nc_get_att(ncid, NC_GLOBAL,
"platform", &meta_l3b->
mission);
964 nc_get_att(ncid, NC_GLOBAL,
"units", &meta_l3b->
units);
965 nc_get_att(ncid, NC_GLOBAL,
"temporal_range", &meta_l3b->
prod_type);
966 nc_get_att(ncid, NC_GLOBAL,
"processing_version", &meta_l3b->
pversion);
967 nc_get_att(ncid, NC_GLOBAL,
"date_created", &meta_l3b->
ptime);
968 nc_get_att(ncid, NC_GLOBAL,
"history", &meta_l3b->
proc_con);
969 nc_get_att(ncid, NC_GLOBAL,
"time_coverage_start", attr_buf);
971 nc_get_att(ncid, NC_GLOBAL,
"time_coverage_end", attr_buf);
974 nc_get_att(ncid, NC_GLOBAL,
"start_orbit_number", &meta_l3b->
start_orb);
975 nc_get_att(ncid, NC_GLOBAL,
"end_orbit_number", &meta_l3b->
end_orb);
977 nc_get_att(ncid, NC_GLOBAL,
"northernmost_latitude", &meta_l3b->
north);
978 nc_get_att(ncid, NC_GLOBAL,
"southernmost_latitude", &meta_l3b->
south);
979 nc_get_att(ncid, NC_GLOBAL,
"easternmost_longitude", &meta_l3b->
east);
980 nc_get_att(ncid, NC_GLOBAL,
"westernmost_longitude", &meta_l3b->
west);
981 nc_get_att_long(ncid, NC_GLOBAL,
"data_bins", (
long*)&meta_l3b->
data_bins);
982 nc_get_att(ncid, NC_GLOBAL,
"percent_data_bins", &meta_l3b->
pct_databins);
983 nc_get_att(ncid, NC_GLOBAL,
"binning_scheme", &meta_l3b->
binning_scheme);
986 nc_inq_atttype(ncid, NC_GLOBAL,
"geospatial_lon_resolution", &attType);
987 if(attType==NC_DOUBLE) {
989 nc_get_att(ncid, NC_GLOBAL,
"geospatial_lon_resolution", &
val);
992 nc_get_att(ncid, NC_GLOBAL,
"geospatial_lon_resolution", attr_buf);
996 nc_get_att(ncid, NC_GLOBAL,
"geospatial_lat_units", &meta_l3b->
lat_units);
997 nc_get_att(ncid, NC_GLOBAL,
"geospatial_lon_units", &meta_l3b->
lon_units);
999 nc_get_att(ncid, NC_GLOBAL,
"identifier_product_doi", &meta_l3b->
doi);
1000 nc_get_att(ncid, NC_GLOBAL,
"keywords", &meta_l3b->
keywords);
1003 nc_inq_grp_ncid(ncid,
"processing_control", &grp_id);
1004 nc_get_att(grp_id, NC_GLOBAL,
"software_name", &meta_l3b->
soft_name);
1005 nc_get_att(grp_id, NC_GLOBAL,
"software_version", &meta_l3b->
soft_ver);
1006 nc_get_att(grp_id, NC_GLOBAL,
"source", &meta_l3b->
infiles);
1007 nc_get_att(grp_id, NC_GLOBAL,
"l2_flag_names", meta_l3b->
flag_names);
1015 i = nc_inq_grp_ncid(grp_id,
"input_parameters", &grp_id2);
1016 nc_inq_natts(grp_id2, &numParams);
1017 for (
i = 0;
i < numParams;
i++) {
1018 nc_inq_attname(grp_id2, NC_GLOBAL,
i, attName);
1019 nc_get_att(grp_id2, NC_GLOBAL, attName, attr_buf);