7 static l3_org_str l3_org;
9 void ck_v_l3(int32 file_id, fmt_str *fmt)
31 int32
nbins, tot_vgroup;
32 int32 num_vgroups, dummy_i32, *ref_array,
i, iret, ifound;
37 nbins = fmt->dim_id[ fmt->vg_nbin_indx ].dim_size;
46 printf(
"\n\nChecking the 'Level-3 Binned Data' Vgroup...\n\n");
54 if ((num_vgroups = Vlone(file_id, &dummy_i32, 0)) == -1) {
55 printf(
"********************Program problem:\n");
56 printf(
"Vgroup check: The Vlone #1 failed\n");
60 printf(
"the # of 'lone' Vgroups is %d\n", num_vgroups);
64 ref_array = (int32 *) malloc(num_vgroups *
sizeof ( int32));
65 if ((num_vgroups = Vlone(file_id, ref_array, num_vgroups)) == -1) {
66 printf(
"********************Program problem:\n");
67 printf(
"Vgroup check: The Vlone #2 failed\n");
75 tot_vgroup = fmt->n_vgroup + 3;
76 for (
i = 0;
i < num_vgroups;
i++) {
78 fmt->vg_info)) == 0) {
83 printf(
"**** the Vgroup: 'Level-3 Binned Data' was not found\n");
92 int32
group_fnd(int32 file_id, int32 vgroup_ref, int32
nbins, int32 n_vgroup,
93 vg_info_str *vd_check)
121 int32 v_id, n_vgroup_entries;
122 int32 vd_id,
i, n_vd_fields, vdata_size, interlace;
123 int32 n_rec,
j, vd_typ, vd_ref;
125 char vgroup_class[VGNAMELENMAX], vgroup_name[VGNAMELENMAX];
126 char vd_name[VSNAMELENMAX], vd_class[VSNAMELENMAX];
127 char field_list[500];
132 begin = (int32 *) malloc(l3_org.numrows * sizeof (int32));
133 extent = (int32 *) malloc(l3_org.numrows * sizeof (int32));
137 if ((v_id = Vattach(file_id, vgroup_ref,
"r")) == -1) {
138 printf(
"******************** Probable Program Error\n");
139 printf(
"Problem on attaching to group with ref # %d\n", vgroup_ref);
146 if (Vinquire(v_id, &n_vgroup_entries, vgroup_name) == -1) {
147 printf(
"******************** Probable Program Error\n");
148 printf(
"Vinquire failed on group ref # %d\n",
155 printf(
"The group name being checked is:\n'%s'\n", vgroup_name);
156 if (strcmp(vgroup_name,
"Level-3 Binned Data") != 0) {
163 Vgetclass(v_id, vgroup_class);
165 printf(
"For target Vgroup of '%s'\n# entries = %d and class = '%s'\n",
166 vgroup_name, n_vgroup_entries, vgroup_class);
168 if (n_vgroup_entries != n_vgroup) {
169 printf(
"**** Error, # entries (%d) is not = %d\n", n_vgroup_entries,
173 if (strcmp(vgroup_class,
"PlanetaryGrid") != 0) {
174 printf(
"**** Error, Vgroup class ('%s') is incorrect\n", vgroup_class);
180 printf(
"\n\nChecking Vdatas inside the Vgroup\n\n");
182 for (
i = 0;
i < n_vgroup_entries;
i++) {
186 if ((vd_ref = VSfind(file_id, vd_check[
i].
name)) < 0) {
187 printf(
"**** Unable to locate Vdata with name '%s'\n",
194 if ((vd_id = VSattach(file_id, vd_ref,
"r")) == -1) {
196 "*************** Program Error: Unable to attach to Vdata name: '%s'\n",
198 printf(
" and vd_ref # %d\n", vd_ref);
204 VSgetclass(vd_id, vd_class);
206 printf(
"Vdata: '%s' has class '%s'\n", vd_check[
i].
name, vd_class);
207 if (strcmp(vd_class, vd_check[
i].
class) != 0) {
208 printf(
"****for Vdata: '%s', mismatch in the class\n",
210 printf(
"expected class: '%s'\n", vd_check[
i].
class);
211 printf(
"read class: '%s'\n", vd_class);
217 if (VSinquire(vd_id, &n_rec, &interlace, field_list,
218 &vdata_size, vd_name) == -1) {
220 "******************* Program Error, VSinquire failed\n");
224 printf(
"Vdata: '%s' has #records = %d, field list:\n'%s'\n",
225 vd_check[
i].
name, n_rec, field_list);
226 if (strcmp(field_list, vd_check[
i].field_list) != 0) {
227 printf(
"****for Vdata: '%s', mismatch in the field list\n",
229 printf(
"expected list: '%s'\n", vd_check[
i].field_list);
230 printf(
"read list: '%s'\n", field_list);
233 if (vd_check[
i].nrec == -1) {
240 printf(
"****for Vdata: '%s', # records < # bins\n",
242 printf(
"expected: %d, read: %d\n",
nbins, n_rec);
246 if (n_rec != vd_check[
i].nrec) {
247 printf(
"****for Vdata: '%s', mismatch in the # records\n",
249 printf(
"expected: %d, read: %d\n",
250 vd_check[
i].nrec, n_rec);
258 if ((n_vd_fields = VSgetfields(vd_id, field_list)) == -1) {
259 printf(
"*************** Program error, VSgetfields failed.\n");
263 printf(
"Vdata: '%s', has %d fields\n",
264 vd_check[
i].
name, n_vd_fields);
265 if (n_vd_fields != vd_check[
i].n_fields) {
266 printf(
"****for Vdata: '%s', mismatch in the # fields\n",
268 printf(
"expected: %d, read: %d\n", vd_check[
i].n_fields,
272 for (
j = 0;
j < n_vd_fields;
j++) {
273 vd_typ = VFfieldtype(vd_id,
j);
275 printf(
"Vdata: '%s', field # %d has num type %d\n",
276 vd_check[
i].
name,
j, vd_typ);
280 if ((
j != 5) && (
i != 2) &&
281 (vd_typ != vd_check[
i].num_typs[
j])) {
283 "****for Vdata: '%s', field # %d has incorrect number type\n",
285 printf(
"expected: %d, read: %d\n",
286 vd_check[
i].num_typs[
j], vd_typ);
365 struct sea_grid_str {
382 if (VSsetfields(vd_id,
383 "registration,straddle,bins,radius,max_north,max_south,seam_lon"
386 "*************** Program Error: For Vdata: 'SEAGrid',\n"
387 "Cannot do VSsetfields\n");
392 if (VSseek(vd_id, 0) == -1) {
394 "*************** Program Error: For Vdata: 'SEAGrid',\n"
395 "Cannot do VSseek\n");
399 if ((n_vd_rec = VSread(vd_id, (sea_grid.buf + 4), 1, 0)) != 1) {
401 "**** For Vdata: 'SEAGrid', data read failed to read the 1 record \n"
402 " with return: %d\n", n_vd_rec);
406 printf(
"For Vdata 'SEAGrid', registration = %d\n",
407 sea_grid.str.registration);
408 if (sea_grid.str.registration != 5) {
409 printf(
"**** For Vdata 'SEAGrid', mismatch in registration\n");
410 printf(
" expected: 5, read: %d\n", sea_grid.str.registration);
414 printf(
"For Vdata 'SEAGrid', straddle = %d\n",
415 sea_grid.str.straddle);
416 if (sea_grid.str.straddle != 0) {
417 printf(
"**** For Vdata 'SEAGrid', mismatch in straddle\n");
418 printf(
" expected: 0, read: %d\n", sea_grid.str.straddle);
422 printf(
"For Vdata 'SEAGrid', bins = %d\n",
427 if (sea_grid.str.bins != l3_org.bins_eq) {
428 printf(
"**** For Vdata 'SEAGrid', mismatch in bins\n");
429 printf(
" expected: %d, read: %d\n", l3_org.bins_eq,
434 printf(
"For Vdata 'SEAGrid', radius = %f\n",
435 sea_grid.str.radius);
436 if (sea_grid.str.radius != 6378.137) {
437 printf(
"**** For Vdata 'SEAGrid', mismatch in radius\n");
438 printf(
" expected: 6378.137, read: %f\n", sea_grid.str.radius);
442 printf(
"For Vdata 'SEAGrid', max_north = %f\n",
443 sea_grid.str.max_north);
444 if (sea_grid.str.max_north != 90.0) {
445 printf(
"**** For Vdata 'SEAGrid', mismatch in max_north/n");
446 printf(
" expected: 90.0, read: %f\n", sea_grid.str.max_north);
450 printf(
"For Vdata 'SEAGrid', max_south = %f\n",
451 sea_grid.str.max_south);
452 if (sea_grid.str.max_south != -90.0) {
453 printf(
"**** For Vdata 'SEAGrid', mismatch in max_south/n");
454 printf(
" expected: -90.0, read: %f\n", sea_grid.str.max_south);
458 printf(
"For Vdata 'SEAGrid', seam_lon = %f\n",
459 sea_grid.str.seam_lon);
460 if (sea_grid.str.seam_lon != -180.0) {
461 printf(
"**** For Vdata 'SEAGrid', mismatch in seam_lon/n");
462 printf(
" expected: -180.0, read: %f\n", sea_grid.str.seam_lon);
496 float64 *ft64buf, vsz;
501 int32buf = (int32 *) malloc(l3_org.numrows * sizeof (int32));
502 ft64buf = (float64 *) malloc(l3_org.numrows * sizeof (float64));
510 (
unsigned char *) &int32buf[0]))) >= 0) {
512 printf(
"For Vdata 'BinIndex', checking row_num \n");
513 for (
i = 0;
i < l3_org.numrows;
i++)
514 if (int32buf[
i] !=
i) {
515 printf(
"***** For Vdata 'BinIndex', mismatch in row_num\n");
516 printf(
" expected: %d, read: %d\n",
i, int32buf[
i]);
525 (
unsigned char *) ft64buf))) >= 0) {
527 printf(
"For Vdata 'BinIndex', checking vsize \n");
528 for (
i = 0;
i < l3_org.numrows;
i++)
529 if (ft64buf[
i] != vsz) {
530 printf(
"***** For Vdata 'BinIndex', mismatch in vsize\n");
531 printf(
" expected: %15.10f, read: %15.10f\n", vsz, ft64buf[
i]);
540 (
unsigned char *) ft64buf))) >= 0) {
542 printf(
"For Vdata 'BinIndex', checking hsize \n");
543 for (row = 0; row < l3_org.numrows; row++) {
544 if ((
fabs(ft64buf[row] - l3_org.hsize[row])) > 1.0 / 1000.0) {
545 printf(
"***** For Vdata 'BinIndex', mismatch in hsize\n");
546 printf(
" expected: %10.8g, read: %10.8g\n", l3_org.hsize[row],
548 printf(
" for index %d\n", row);
557 if ((
status = (
rdvdata(vd_id,
"start_num", 0, l3_org.numrows,
558 (
unsigned char *) int32buf))) >= 0) {
560 printf(
"For Vdata 'BinIndex', checking start_num \n");
561 for (
i = 0;
i < l3_org.numrows;
i++) {
562 if (int32buf[
i] != l3_org.start_bin[
i]) {
563 printf(
"***** For Vdata 'BinIndex', mismatch in start_num\n");
564 printf(
" expected: %d, read: %d\n", l3_org.start_bin[
i + 1],
575 (
unsigned char *) int32buf))) >= 0) {
577 printf(
"For Vdata 'BinIndex', checking max \n");
578 for (
i = 0;
i < l3_org.numrows;
i++) {
579 if (int32buf[
i] != l3_org.max_bin[
i]) {
580 printf(
"***** For Vdata 'BinIndex', mismatch in max\n");
581 printf(
" expected: %d, read: %d\n", l3_org.max_bin[
i],
591 rdvdata(vd_id,
"begin", 0, l3_org.numrows, (
unsigned char *) begin);
596 rdvdata(vd_id,
"extent", 0, l3_org.numrows, (
unsigned char *)
extent);
628 int32
i, binno[512], row = 0, rowcount = 0;
629 int32 *loc_extent, *loc_begin, nrec;
630 int32
start, nelts, rec, recsleft, lastbin;
631 static int32 prev_bin = 0;
636 loc_extent = (int32 *) calloc(l3_org.numrows, sizeof ( int32));
637 loc_begin = (int32 *) calloc(l3_org.numrows, sizeof ( int32));
639 lastbin = l3_org.start_bin[0] + l3_org.max_bin[0] - 1;
650 printf(
"\n nbins = %d",
nbins);
651 for (rec = 0; rec <
nbins; rec += 512) {
652 if ((recsleft =
nbins - rec) < 512)
653 nelts = nrec = recsleft;
656 (
unsigned char *) binno)) >= 0) {
660 if (prev_bin >= binno[0]) {
661 printf(
"****For Vdata 'BinList', discrepancy in bin numbers\n");
662 printf(
" expected bin# greater than %d, but read: %d\n",
669 for (
i = 0;
i < nrec;
i++) {
670 if (
i < nrec - 1 && binno[
i] > binno[
i + 1]) {
671 printf(
"***For Vdata 'BinList', discrepancy in bin numbers");
672 printf(
" expected bin# greater than %d, but read: %d\n",
676 if (binno[
i] > lastbin) {
677 loc_extent[row] = rowcount;
678 while (binno[
i] > lastbin) {
680 lastbin = l3_org.start_bin[row] + l3_org.max_bin[row] - 1;
683 loc_begin[row] = binno[
i];
689 prev_bin = binno[nrec - 1];
694 loc_extent[row] = rowcount;
697 printf(
"\nFor Vdata 'BinIndex', checking begin ");
698 printf(
"\nFor Vdata 'BinIndex', checking extent \n");
700 for (
i = 0;
i < l3_org.numrows;
i++) {
705 if (loc_begin[
i] != begin[
i]) {
706 printf(
"***** For Vdata 'BinIndex', mismatch in 'begin'\n");
707 printf(
" expected: %d for row %d, read: %d\n",
708 loc_begin[
i],
i, begin[
i]);
712 printf(
"***** For Vdata 'BinIndex', mismatch in 'extent'\n");
713 printf(
" expected: %d for row %d, read: %d\n",
754 p_data = (float32 *) malloc(2 *
nbins *
sizeof ( float32));
759 if (VSsetfields(vd_id, field_list) == -1) {
761 "*************** Program Error: For Vdata: '%s',\nCannot do VSsetfields\n",
766 if (VSseek(vd_id, 0) == -1) {
768 "*************** Program Error: For Vdata: '%s',\nCannot do VSseek\n",
771 if ((n_vd_rec = VSread(vd_id, (uint8 *) p_data,
nbins, FULL_INTERLACE))
774 "**** For Vdata: '%s', data read failed to read the %d record \n"
775 " with return: %d\n",
name,
nbins, n_vd_rec);
787 sum += *(p_data + 2 *
i);
788 sum_sq += *(p_data + 2 *
i + 1);
791 sum_sq = sum_sq /
nbins;
794 printf(
"For Vdata: '%s', mean of sum: %f, sum_sq: %f\n",