28 int32 *sdfid, *fid,
mode;
32 if ((lsdfid = SDstart(outfile,
mode)) < 0)
return FAIL;
33 if ((lfid = Hopen(outfile, DFACC_RDONLY, 0)) < 0)
return FAIL;
56 gridid = Vattach(fid, -1,
"w");
58 Vsetname(gridid, grpname);
71 int32 outergridid, innergridid;
75 groupref = VQueryref(innergridid);
76 if (groupref < 0)
return -1;
78 Vaddtagref(outergridid, DFTAG_VG, groupref);
92 int32_t
writeGeom(int32_t fid, int32_t gridid,
char *geomname, int32_t bin_meth, int32_t registration,
93 float vsize,
float hsize,
float max_north,
float max_south,
float max_west,
float max_east)
95 int32 geomid, geomref, *i32;
104 geomid = VSattach(fid, -1,
"w");
115 VSsetname(geomid, geomname);
117 result = VSsetfields(geomid,
118 "bin_meth,registration,vsize,hsize,max_north,max_south,max_west,max_east");
120 i32 = (
void *) &arrhold[0];
122 i32 = (
void *) &arrhold[4];
125 f32 = (
void *) &arrhold[8];
127 f32 = (
void *) &arrhold[12];
129 f32 = (
void *) &arrhold[16];
131 f32 = (
void *) &arrhold[20];
133 f32 = (
void *) &arrhold[24];
135 f32 = (
void *) &arrhold[28];
138 result = VSwrite(geomid, arrhold, 1, FULL_INTERLACE);
145 geomref = VSQueryref(geomid);
146 Vaddtagref(gridid, DFTAG_VH, geomref);
168 if ((vsid = VSfind(fid, geomname)) < 0)
169 pexit(
"getting geom vsid");
171 if ((geomid = VSattach(fid, vsid,
"r")) < 0)
172 pexit(
"attaching geom vsid");
187 int32 gridid, geomid;
191 geomref = VSQueryref(geomid);
192 result = Vaddtagref(gridid, DFTAG_VH, geomref);
222 int addAttr(sdsid, dataattr, datatype, dataunit)
230 if ((
result = SDsetattr(sdsid, dataattr, datatype, strlen(dataunit) + 1,
231 dataunit)) != 0)
return (-1);
246 int32_t sdsid, gridid;
251 if ((sdsref = (int32) SDidtoref(sdsid)) < 0)
return (-1);
253 Vaddtagref(gridid, DFTAG_NDG, sdsref);
270 return Vdetach(gridid);
286 if ((
result = Vend(fid)) < 0) {
287 printf(
"Vend: result: %d\n",
result);
291 if ((
result = SDend(sdfid)) < 0) {
292 printf(
"SDend: result: %d\n",
result);
296 if ((
result = Hclose(fid)) < 0) {
297 printf(
"Error on Hclose(); stack follows:\n");
299 printf(
"Stack complete\n");
348 int32_t sdfid, shape[], datatype;
355 static int32
start[3] = {0, 0, 0};
357 if ((sdsid = SDcreate(sdfid, datalabel, datatype,
rank, shape)) < 0)
401 int32_t sdsid, shape[];
405 static int32
start[2] = {0, 0};
407 printf(
"rewrtsds sdsid %d, shape[0] %d, shape[1] %d\n",
408 sdsid, shape[0], shape[1]);
411 printf(
"rewrtsds SDwritedata result: %d\n",
result);
413 result += SDendaccess(sdsid);
414 printf(
"rewrtsds SDendaccess result: %d\n",
result);
466 int32 sdfid, fid, vid, vg;
467 int32 sdsindex, sdsid;
468 int32
rank, numbertype;
470 int32 tagarray1[255], refarray1[255], nrefs1, nattrs1;
485 pwarning(
"Fatal error starting HDF file");
499 if ((vid = Vfind(fid, vgname)) <= 0)
return (
ERROR);
500 vg = Vattach(fid, vid,
"r");
501 nrefs1 = Vntagrefs(vg);
503 Vgettagrefs(vg, tagarray1, refarray1, nattrs1);
505 for (
j = 0;
j < nrefs1;
j++) {
506 if ((tagarray1[
j] == DFTAG_NDG) ||
507 (tagarray1[
j] == DFTAG_SD)) {
508 sdsindex = SDreftoindex(sdfid, refarray1[
j]);
509 sdsid = SDselect(sdfid, sdsindex);
510 SDgetinfo(sdsid, lname, &
rank, dimsizes, &numbertype, &nattrs1);
511 if (!strcmp(sdsname, lname)) {
512 if ((SDreaddata(sdsid,
start, (int32 *)
NULL, dimsizes, inData)) != 0) {
513 pwarning(
"Fatal error reading SDS data array");
522 pwarning(
"Fatal error: Case 1 SDS data array not found");
530 pwarning(
"Fatal error closing SDS: closeHDFstructs");
548 datatype, sdfid,
rank, shape,
data, gridid)
549 char *sdsname, *longname, *
units, *datafmt;
550 int32_t sdfid, datatype,
rank, shape[], gridid;
560 if ((sdsid =
wrtsds(sdfid,
rank, shape, datatype, sdsname,
data)) < 0) {
569 if ((
result =
addAttr(sdsid,
"long_name", DFNT_CHAR, longname)) != 0) {
574 if (strlen(
units) > 0)
645 float32 outfloat32[1];
653 for (
i = 0;
i < numannarr;
i++) {
657 switch (lannot[
i].
type) {
660 result = SDsetattr(dfile, outlabel, DFNT_CHAR8,
661 strlen(outchar) + 1, outchar);
665 sscanf(lannot[
i].
descr,
"%hd", &outint16[0]);
671 sscanf(lannot[
i].
descr,
"%d", &outint32[0]);
676 sscanf(lannot[
i].
descr,
"%f", &outfloat32[0]);
681 printf(
"Error in function WRTATTR, default CASE encountered\n");
686 if (
result) printf(
"Error in writing header annotations\n");