/* Copyright 1984-2002 The MathWorks, Inc. */ /* * hdfsw.c --- support file for HDF.MEX * * This module supports the HDF-EOS SW interface. The only public * function is hdfSW(), which is called by mexFunction(). * hdfSW looks at the second input argument to determine which * private function should get control. * */ /* $Revision: 1.1.6.1 $ $Date: 2003/12/13 03:02:21 $ */ static char rcsid[] = "$Id: hdfsw.c,v 1.1.6.1 2003/12/13 03:02:21 batserve Exp $"; #include #include /* Main HDF library header file */ #include "hdf.h" /* MATLAB API header file */ #include "mex.h" /* HDFMEX utility functions */ #include "hdfutils.h" /* Multifile scientific dataset interface header file */ #include "mfhdf.h" /* HDF-EOS header file */ #include "HdfEosDef.h" #define BUFLEN 128 /* * CreateDoubleMxArrayFromINT32Array * * Purpose: Allocates an mxArray of class double and copies * into it the values from the given int32 array * * Inputs: array - the int32 array * ndims - number of dimensions in the array * dims - size along each dimension * * Outputs: none * * Returns: out - the MATLAB array */ static mxArray *CreateDoubleMxArrayFromINT32Array(int32 *array, int ndims, int *dims) { int i; mxArray *out; double *pr; int length; out = mxCreateNumericArray(ndims, dims, mxDOUBLE_CLASS, mxREAL); pr = mxGetPr(out); length = mxGetNumberOfElements(out); for (i=0; i ((dims[i] - start[i]) / stride[i])) mexErrMsgTxt("The EDGE vector specified a larger data dimension than exists in file."); } } /* Allocate the buffer */ bufsize = 1; for (i=0; i 1) { if (status != FAIL) { plhs[1] = mxCreateString(dimname); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { if (status != FAIL) { dimsdims[0] = 1; dimsdims[1] = ndims; /* dimsdims contains dimensions of ** the output dimensions array. */ plhs[2] = CreateDoubleMxArrayFromINT32Array(dims, 2, dimsdims); } else { plhs[2] = EMPTY; } } /* Clean up */ if (dimname != NULL) { mxFree(dimname); } } /* * hdfSWinqmaps * * Purpose: Gateway to the HDF-EOS Library function SWinqmaps * Retrieve information about all of the (non-indexed) * geolocation relations defined in a swath. * * MATLAB usage: * [nmaps, dimmap, offset, increment] = ... * hdf('SW', 'inqmaps', swathid); * * Inputs: swathid - Swath identifier * * Outputs: nmaps - number of geolocation entries found * dimmap - dimension mapping list * offset - array containing the offset of each * geolocation relation * increment - array containing the increment of each * geolocation relation * * Returns: none */ static void hdfSWinqmaps(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 nmaps; char *dimmap = NULL; int32 *offset = NULL; int32 *increment = NULL; int32 strbufsz; intn status; int dims[2] = {0, 1}; /* Argument checking */ haNarginChk(3, 3, nrhs); haNargoutChk(4, 4, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); status = (swathid < 0) ? FAIL : SUCCEED; /* Find out how much space we need to allocate. */ if (status != FAIL) { nmaps = SWnentries(swathid, HDFE_NENTMAP, &strbufsz); status = (nmaps < 0) ? FAIL : SUCCEED; } /* Allocate space and call HDF-EOS function. */ dimmap = mxCalloc(strbufsz+1, sizeof(char)); offset = mxCalloc(nmaps, sizeof(int32)); increment = mxCalloc(nmaps, sizeof(int32)); nmaps = SWinqmaps(swathid, dimmap, offset, increment); status = (nmaps < 0) ? FAIL : SUCCEED; plhs[0] = haCreateDoubleScalar((double) nmaps); if (nlhs > 1) { plhs[1] = (status == FAIL) ? EMPTY : mxCreateString(dimmap); } if (nlhs > 2) { if (status != FAIL) { dims[0] = nmaps; /* dims contains dimensions of the output ** arrays (offset & increment) */ plhs[2] = CreateDoubleMxArrayFromINT32Array(offset, 2, dims); } else { plhs[2] = EMPTY; } } if (nlhs > 3) { plhs[3] = (status == FAIL) ? EMPTY : CreateDoubleMxArrayFromINT32Array(increment, 2, dims); } /* Clean up */ if (dimmap != NULL) { mxFree(dimmap); } if (offset != NULL) { mxFree(offset); } if (increment != NULL) { mxFree(increment); } } /* * hdfSWinqidxmaps * * Purpose: Gateway to the HDF-EOS Library function SWinqidxmaps * Retrieve information about all of the indexed * geolocation/data mappings defined in a swath. * * MATLAB usage: * [nidxmaps, idxmap, idxsizes] = ... * hdf('SW', 'inqidxmaps', swathid); * * Inputs: swathid - Swath identifier * * Outputs: nidxmaps - number of indexed mapping relations found * idxmap - indexed dimension mapping list * idxsizes - array conaining the sizes of the corresponding * index arrays * * Returns: none */ static void hdfSWinqidxmaps(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 nidxmaps; char *idxmap = NULL; int32 *idxsizes = NULL; int32 strbufsz; int dims[2] = {0, 1}; intn status; /* Argument checking */ haNarginChk(3, 3, nrhs); haNargoutChk(0, 3, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); status = (swathid < 0) ? FAIL : SUCCEED; /* How much space do we need to allocate? */ if (status != FAIL) { nidxmaps = SWnentries(swathid, HDFE_NENTIMAP, &strbufsz); status = (nidxmaps < 0) ? FAIL : SUCCEED; } /* Allocate space and call HDF-EOS function. */ if (status != FAIL) { idxsizes = mxCalloc(nidxmaps, sizeof(int32)); idxmap = mxCalloc(strbufsz+1, sizeof(char)); nidxmaps = SWinqidxmaps(swathid, idxmap, idxsizes); status = (nidxmaps < 0) ? FAIL : SUCCEED; } if (status != FAIL) { plhs[0] = haCreateDoubleScalar((double) nidxmaps); } else { plhs[0] = haCreateDoubleScalar((double) FAIL); } if (nlhs > 1) { plhs[1] = (status == FAIL) ? EMPTY : mxCreateString(idxmap); } if (nlhs > 2) { if (status != FAIL) { dims[0] = nidxmaps; /* dims contains dimensions of ** the output idxsizes array. */ plhs[2] = CreateDoubleMxArrayFromINT32Array(idxsizes, 2, dims); } else { plhs[2] = EMPTY; } } /* Clean up */ if (idxmap != NULL) { mxFree(idxmap); } if (idxsizes != NULL) { mxFree(idxsizes); } } /* * hdfSWinqgeofields * * Purpose: Gateway to the HDF-EOS Library function SWinqgeofields * Retrieve information about all of the geolocation * fields defined in a swath. * * MATLAB usage: * [nfields, fieldlist, rank, numbertype] = ... * hdf('SW', 'inqgeofields', swathid); * * Inputs: swathid - Swath identifier * * Outputs: nfields - number of geolocation fields found * fieldlist - listing of geolocation fields * rank - array conaining rank of each geolocation field * numbertype - cell-array conaining numbertype of each field * * Returns: none */ static void hdfSWinqgeofields(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 nfields; char *fieldlist = NULL; int32 *rank = NULL; int32 *numbertype = NULL; int32 strbufsz; intn status; int dims[2] = {0, 1}; /* Argument checking */ haNarginChk(3, 3, nrhs); haNargoutChk(4, 4, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); status = (swathid < 0) ? FAIL : SUCCEED; /* How much space do we need to allocate? */ if (status != FAIL) { nfields = SWnentries(swathid, HDFE_NENTGFLD, &strbufsz); status = (nfields < 0) ? FAIL : SUCCEED; } /* Allocate space and call the HDF-EOS library function. */ if (status != FAIL) { fieldlist = mxCalloc(strbufsz + 1, sizeof(char)); rank = mxCalloc(nfields, sizeof(int32)); numbertype = mxCalloc(nfields, sizeof(int32)); nfields = SWinqgeofields(swathid, fieldlist, rank, numbertype); status = (nfields < 0) ? FAIL : SUCCEED; } if (status != FAIL) { plhs[0] = haCreateDoubleScalar((double) nfields); } else { plhs[0] = haCreateDoubleScalar((double) FAIL); } if (nlhs > 1) { if (status != FAIL) { plhs[1] = mxCreateString(fieldlist); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { if (status != FAIL) { dims[0] = nfields; /* dims contains dimensions of ** the output idxsizes array. */ plhs[2] = CreateDoubleMxArrayFromINT32Array(rank, 2, dims); } else { plhs[2] = EMPTY; } } if (nlhs > 3) { if (status != FAIL) { plhs[3] = haGenerateNumberTypeArray(nfields, numbertype); } else { plhs[3] = EMPTY; } } /* Clean up */ if (fieldlist != NULL) { mxFree(fieldlist); } if (rank != NULL) { mxFree(rank); } if (numbertype != NULL) { mxFree(numbertype); } } /* * hdfSWinqdatafields * * Purpose: Gateway to the HDF-EOS Library function SWinqdatafields * Retrieve information about all of the data * fields defined in a swath. * * MATLAB usage: * [nfields, fieldlist, rank, numbertype] = ... * hdf('SW', 'inqdatafields', swathid); * * Inputs: swathid - Swath identifier * * Outputs: nfields - number of data fields found * fieldlist - listing of data fields * rank - array conaining rank of each data field * numbertype - array conaining numbertype of each data field * * Returns: none */ static void hdfSWinqdatafields(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 nfields; char *fieldlist = NULL; int32 *rank = NULL; int32 *numbertype = NULL; int32 strbufsz; intn status; int dims[2] = {0, 1}; /* Argument checking */ haNarginChk(3, 3, nrhs); haNargoutChk(0, 4, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); status = (swathid == FAIL) ? FAIL : SUCCEED; /* How much space do we need to allocate? */ if (status != FAIL) { nfields = SWnentries(swathid, HDFE_NENTDFLD, &strbufsz); status = (nfields < 0) ? FAIL : SUCCEED; } /* Allocate space and call library function */ if (status != FAIL) { fieldlist = mxCalloc(strbufsz + 1, sizeof(char)); rank = mxCalloc(nfields, sizeof(int32)); numbertype = mxCalloc(nfields, sizeof(int32)); nfields = SWinqdatafields(swathid, fieldlist, rank, numbertype); status = (nfields < 0) ? FAIL : SUCCEED; } if (status != FAIL) { plhs[0] = haCreateDoubleScalar((double) nfields); } else { plhs[0] = haCreateDoubleScalar((double) FAIL); } if (nlhs > 1) { if (status != FAIL) { plhs[1] = mxCreateString(fieldlist); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { if (status != FAIL) { dims[0] = nfields; /* dims contains dimensions of the output ** idxsizes array. */ plhs[2] = CreateDoubleMxArrayFromINT32Array(rank, 2, dims); } else { plhs[2] = EMPTY; } } if (nlhs > 3) { if (status != FAIL) { plhs[3] = haGenerateNumberTypeArray(nfields, numbertype); } else { plhs[3] = EMPTY; } } /* Clean up */ if (fieldlist != NULL) { mxFree(fieldlist); } if (rank != NULL) { mxFree(rank); } if (numbertype != NULL) { mxFree(numbertype); } } /* * hdfSWnentries * * Purpose: Gateway to the HDF-EOS Library function SWnentries * Returns number of entries for a specified entity * * MATLAB usage: * [nmaps,strbufsize] = hdf('SW', 'nentries', swathid, entrycode); * * Inputs: swathid - Swath identifier * entrycode - Entry code * * Outputs: nmaps - number of entries * * Returns: none */ static void hdfSWnentries(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 nmaps; int32 entrycode; int32 strbufsize; /* Argument checking */ haNarginChk(4, 4, nrhs); haNargoutChk(0, 2, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); entrycode = GetEntryCode(prhs[3]); /* Call HDF-EOS library function, and output result */ nmaps = SWnentries(swathid, entrycode, &strbufsize); plhs[0] = haCreateDoubleScalar((double) nmaps); if (nlhs > 1) { if (nmaps == FAIL) { plhs[1] = EMPTY; } else { plhs[1] = haCreateDoubleScalar((double) strbufsize); } } } /* * hdfSWdiminfo * * Purpose: Gateway to the HDF-EOS Library function SWdiminfo * Retrieve size of specified dimension * * MATLAB usage: * dimsize = hdf('SW', 'diminfo', swathid, dimname); * * Inputs: swathid - Swath identifier * dimname - dimension name * * Outputs: dimsize - size of dimension * * Retuns: none */ static void hdfSWdiminfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 dimsize; char *dimname; /* Argument checking */ haNarginChk(4, 4, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); dimname = haGetString(prhs[3], "Dimension name"); /* Call HDF-EOS library function, and output result */ dimsize = SWdiminfo(swathid, dimname); plhs[0] = haCreateDoubleScalar((double) dimsize); /* Clean up */ mxFree(dimname); } /* * hdfSWmapinfo * * Purpose: Gateway to the HDF-EOS Library function SWmapinfo * Retrieve offset and increment of specific monotonic * geolocation mapping. * * MATLAB usage: * [offset, increment, status] = ... * hdf('SW', 'mapinfo', swathid, geodim, datadim); * * Inputs: swathid - Swath identifier * geodim - Geolocation dimension name * datadim - Data dimension name * * Outputs: offset - mapping offset * increment - mapping increment * status - 0 if succeeded, -1 if failed. * * Retuns: none */ static void hdfSWmapinfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *geodim; char *datadim; int32 offset; int32 increment; int32 status; /* Argument checking */ haNarginChk(5, 5, nrhs); haNargoutChk(0, 3, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); geodim = haGetString(prhs[3], "Geolocation dimension name"); datadim = haGetString(prhs[4], "Data dimension name"); /* Call HDF-EOS library function, and output result */ status = SWmapinfo(swathid, geodim, datadim, &offset, &increment); plhs[0] = haCreateDoubleScalar((double) offset); if (nlhs > 1) { plhs[1] = haCreateDoubleScalar((double) increment); } if (nlhs > 2) { plhs[2] = haCreateDoubleScalar((double) status); } /* Clean up */ mxFree(geodim); mxFree(datadim); } /* * hdfSWidxmapinfo * * Purpose: Gateway to the HDF-EOS Library function SWidxmapinfo * Retrieve indexed array of specified geolocation mapping. * * MATLAB usage: * [idxsize, index] = ... * hdf('SW', 'idxmapinfo', swathid, geodim, datadim); * * Inputs: swathid - Swath identifier * geodim - Geolocation dimension name * datadim - Data dimension name * * Outputs: idxsize - size of indexed array * index - mapping offset * * Retuns: none */ static void hdfSWidxmapinfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *geodim = NULL; char *datadim = NULL; int32 idxsize; int32 dimsize; int32 *index = NULL; int dims[2] = {0,1}; int32 mapsize = 32000; intn status; /* Argument checking */ haNarginChk(5, 5, nrhs); haNargoutChk(0, 2, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); geodim = haGetString(prhs[3], "Geolocation dimension name"); datadim = haGetString(prhs[4], "Data dimension name"); /* How big is the dimension? */ dimsize = SWdiminfo(swathid, datadim); status = (dimsize < 0) ? FAIL : SUCCEED; /* Allocate space and get result. */ if (status != FAIL) { index = mxCalloc( mapsize , sizeof(int32)); idxsize = SWidxmapinfo(swathid, geodim, datadim, index); status = (idxsize < 0) ? FAIL : SUCCEED; } if (status != FAIL) { plhs[0] = haCreateDoubleScalar((double) idxsize); } else { plhs[0] = haCreateDoubleScalar((double) FAIL); } if (nlhs > 1) { if (status != FAIL) { dims[0] = idxsize; plhs[1] = CreateDoubleMxArrayFromINT32Array(index, 2, dims); } else { plhs[1] = EMPTY; } } /* Clean up */ if (geodim != NULL) { mxFree(geodim); } if (datadim != NULL) { mxFree(datadim); } if (index != NULL) { mxFree(index); } } /* * hdfSWfieldinfo * * Purpose: Gateway to the HDF-EOS Library function SWfieldinfo * Returns information about a specified geolocation * or data field within a swath. * * MATLAB usage: * [rank, dims, numbertype, dimlist, status] = ... * hdf('SW', 'fieldinfo', swathid, fieldname); * * Inputs: swathid - Swath identifier * fieldname - field name * * Outputs: rank - rank of field * dims - array containing the dimension sizes * of the field. * numbertype - number type of field * dimlist - list of dimensions in a field * status - returns 0 if succeed, and -1 if fail * * Retuns: none */ static void hdfSWfieldinfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *fieldname = NULL; int32 rank; int32 dims[MAX_VAR_DIMS]; int32 numbertype; char *dimlist = NULL; int dimsdims[2] = {0, 0}; intn status; int32 strbufsz; int32 ndims; /* Argument checking */ haNarginChk(4, 4, nrhs); haNargoutChk(0, 5, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); fieldname = haGetString(prhs[3], "Field name"); /* Call HDF-EOS library function, and output result */ ndims = SWnentries(swathid, HDFE_NENTDIM, &strbufsz); status = (ndims < 0) ? FAIL : SUCCEED; if (status != FAIL) { dimlist = mxCalloc(strbufsz+1, sizeof(char)); status = SWfieldinfo(swathid, fieldname, &rank, dims, &numbertype, dimlist); } if (status != FAIL) { plhs[0] = haCreateDoubleScalar((double) rank); } else { plhs[0] = EMPTY; } if (nlhs > 1) { if (status != FAIL) { dimsdims[0] = 1; dimsdims[1] = rank; plhs[1] = CreateDoubleMxArrayFromINT32Array(dims, 2, dimsdims); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { if (status != FAIL) { plhs[2] = mxCreateString(haGetNumberTypeString(numbertype)); } else { plhs[2] = EMPTY; } } if (nlhs > 3) { if (status != FAIL) { plhs[3] = mxCreateString(dimlist); } else { plhs[3] = EMPTY; } } if (nlhs > 4) { plhs[4] = haCreateDoubleScalar(status); } /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } if (dimlist != NULL) { mxFree(dimlist); } } /* * hdfSWdefboxregion * * Purpose: Gateway to the HDF-EOS Library function SWdefboxregion * Defines a longitude-latitude box region for a swath * * MATLAB usage: * regionid = hdf('SW', 'defboxregion', swathid, ... * cornerlon, cornerlat, mode); * * Inputs: swathid - Swath identifier * cornerlon - Longitude in decimal degrees of box corners * cornerlat - Latitude in decimal degrees of box corners * mode - Cross track inclusion mode * * Outputs: regionid - Swath region ID * * Retuns: none */ static void hdfSWdefboxregion(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 regionid; double cornerlon[2]; double cornerlat[2]; int32 mode; double *pd; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); if (mxGetNumberOfElements(prhs[3]) != 2 || mxGetNumberOfElements(prhs[4]) != 2) { mexErrMsgTxt("cornerlat and cornerlon must be 2 element vectors."); } if (!mxIsDouble(prhs[3]) || !mxIsDouble(prhs[4])) { mexErrMsgTxt("cornerlat and cornerlon must be of class double."); } pd = mxGetData(prhs[3]); cornerlon[0] = pd[0]; cornerlon[1] = pd[1]; pd = mxGetData(prhs[4]); cornerlat[0] = pd[0]; cornerlat[1] = pd[1]; mode = GetCrossTrackInclusionMode(prhs[5]); /* Call HDF-EOS library function, and output result */ regionid = SWdefboxregion(swathid, cornerlon, cornerlat, mode); plhs[0] = haCreateDoubleScalar((double) regionid); } /* * hdfSWregionindex * * Purpose: Gateway to the HDF-EOS Library function SWregionindex * Defines a longitude-latitude box region for a swath * * MATLAB usage: * [regionid, geodim, idxrange] = hdf('SW', 'regionindex', swathid, ... * cornerlon, cornerlat, mode); * * Inputs: swathid - Swath identifier * cornerlon - Longitude in decimal degrees of box corners * cornerlat - Latitude in decimal degrees of box corners * mode - Cross track inclusion mode * * Outputs: regionid - Swath region ID geodim - Geolocation track dimension name idxrange - range of the dimension * * Returns: none */ static void hdfSWregionindex(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 regionid; double cornerlon[2]; double cornerlat[2]; int32 mode; double *pd; char *geodim; int32 idxrange[2]; int32 ndims; int32 strbufsz; int dimsdims[2] = {1,2}; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 3, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); if (mxGetNumberOfElements(prhs[3]) != 2 || mxGetNumberOfElements(prhs[4]) != 2) { mexErrMsgTxt("cornerlat and cornerlon must be 2 element vectors."); } if (!mxIsDouble(prhs[3]) || !mxIsDouble(prhs[4])) { mexErrMsgTxt("cornerlat and cornerlon must be of class double."); } pd = mxGetData(prhs[3]); cornerlon[0] = pd[0]; cornerlon[1] = pd[1]; pd = mxGetData(prhs[4]); cornerlat[0] = pd[0]; cornerlat[1] = pd[1]; mode = GetCrossTrackInclusionMode(prhs[5]); /* Get size of geodim */ ndims = SWnentries(swathid, HDFE_NENTDIM, &strbufsz); geodim = mxMalloc(strbufsz*sizeof(char)); /* Call HDF-EOS library function, and output result */ regionid = SWregionindex(swathid, cornerlon, cornerlat, mode, geodim, idxrange); plhs[0] = haCreateDoubleScalar((double) regionid); plhs[1] = mxCreateString(geodim); plhs[2] = CreateDoubleMxArrayFromINT32Array(idxrange, 2, dimsdims); if(geodim != NULL) { mxFree(geodim); } } /* * hdfSWupdateidxmap * * Purpose: Gateway to the HDF-EOS Library function SWupdateidxmap * Retrieves indexed array of specified geolocation mapping * for a specified region. * * MATLAB usage: [indexout, indices, idxsz] = ... * hdf('SW','updateidxmap',swathid, regionid,indexin); * * Inputs: swathid - Swath identifier * regionid - Region identifier * indexin - Array containing indices of the data dimension * to which each geolocation element corresponds * * Outputs: indexout - Array containing indices of the data dimension * to which each geolocation corresponds in the * subsetted region. * indices - Array containing indices for start and stop of region * idxsz - Size of updated indexed aray, -1 if failed * * Returns: none */ static void hdfSWupdateidxmap(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 regionid; int32 *indexout; int32 *indexin; int32 indices[2]; int32 idxsz; double *indexin_ptr; int dimsdims[2]; int i, count; /* Argument checking */ haNarginChk(5,5,nrhs); haNargoutChk(0,3,nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); regionid = (int32) haGetNonNegativeDoubleScalar(prhs[3], "Region identifier"); if(mxGetClassID(prhs[4]) != mxDOUBLE_CLASS) { mexErrMsgTxt("OFFSET values must be double precision."); } count = mxGetNumberOfElements(prhs[4]); indexin = mxMalloc(count*sizeof(int32)); indexin_ptr = mxGetPr(prhs[4]); for(i=0;i 1) { if (status != FAIL) { plhs[1] = haCreateDoubleScalar((double) rank); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { if (status != FAIL) { dimsdims[0] = 1; dimsdims[1] = rank; plhs[2] = CreateDoubleMxArrayFromINT32Array(dims, 2, dimsdims); } else { plhs[2] = EMPTY; } } if (nlhs > 3) { if (status != FAIL) { plhs[3] = haCreateDoubleScalar((double) size); } else { plhs[3] = EMPTY; } } if (nlhs > 4) { plhs[4] = haCreateDoubleScalar((double) status); } /* Clean up */ mxFree(fieldname); } /* * hdfSWextractregion * * Purpose: Gateway to the HDF-EOS Library function SWextractregion * Extracts (Reads) from subsetted region. * * MATLAB usage: * [buffer, status] = hdf('SW', 'extractregion', swathid, ... * regionid, fieldname, external_mode); * * Inputs: swathid - Swath identifier * regionid - Region identifier * fieldname - field to subset * external_mode - external geoloaction mode * * Outputs: buffer - data buffer * status - 0 if succeed, -1 if fail * * Retuns: none */ static void hdfSWextractregion(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 regionid; char *fieldname; int32 external_mode; VOIDP buffer = NULL; intn status; int32 ntype; int32 rank; int32 dims[MAX_VAR_DIMS]; int32 size; int matlabdims[MAX_VAR_DIMS]; int i; bool ok2free = true; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 2, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); regionid = (int32) haGetNonNegativeDoubleScalar(prhs[3], "Region identifier"); fieldname = haGetString(prhs[4], "Field name"); external_mode = GetExternalMode(prhs[5]); /* Get the number type */ status = SWregioninfo(swathid, regionid, fieldname, &ntype, &rank, dims, &size); if (status != FAIL) { int count = 1; /* flip the size vector */ if (rank==0) { matlabdims[0] = 1; matlabdims[1] = 1; rank = 2; } else if (rank == 1) { matlabdims[0] = dims[0]; matlabdims[1] = 1; rank = 2; count = dims[0]; } else { for (i =0; i 1) { if (status != FAIL) { plhs[1] = haCreateDoubleScalar((double) rank); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { if (status != FAIL) { dimsdims[0] = rank; plhs[2] = CreateDoubleMxArrayFromINT32Array(dims, 2, dimsdims); } else { plhs[2] = EMPTY; } } if (nlhs > 3) { if (status != FAIL) { plhs[3] = haCreateDoubleScalar((double) size); } else { plhs[3] = EMPTY; } } if (nlhs > 4) { plhs[4] = haCreateDoubleScalar((double) status); } /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } } /* * hdfSWextractperiod * * Purpose: Gateway to the HDF-EOS Library function SWextractperiod * Extracts (Reads) from subsetted time period. * * MATLAB usage: * [buffer, status] = hdf('SW', 'extractperiod', swathid, ... * periodid, fieldname, external_mode); * * Inputs: swathid - Swath identifier * periodid - Period identifier * fieldname - field to subset * external_mode - external geoloaction mode * * Outputs: buffer - data buffer * status - 0 if succeed, -1 if fail * * Retuns: none */ static void hdfSWextractperiod(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 periodid; char *fieldname; int32 external_mode; VOIDP buffer = NULL; intn status; int32 ntype; int32 rank; int32 dims[MAX_VAR_DIMS]; int32 size; int matlabdims[MAX_VAR_DIMS]; int i; bool ok2free = true; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 2, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); periodid = (int32) haGetNonNegativeDoubleScalar(prhs[3], "Period identifier"); fieldname = haGetString(prhs[4], "Field name"); external_mode = GetExternalMode(prhs[5]); /* Get the number type */ status = SWperiodinfo(swathid, periodid, fieldname, &ntype, &rank, dims, &size); if (status != FAIL) { int count = 1; /* flip the size vector */ if (rank==0) { matlabdims[0] = 1; matlabdims[1] = 1; rank = 2; } else if (rank == 1) { matlabdims[0] = dims[0]; matlabdims[1] = 1; rank = 2; count = dims[0]; } else { for (i =0; i 1) { if (status != FAIL) { plhs[1] = mxCreateString(attrlist); } else { plhs[1] = EMPTY; } } /* Clean up */ if (attrlist != NULL) { mxFree(attrlist); } } /* * hdfSWattrinfo * * Purpose: Gateway to the HDF-EOS Library function SWattrinfo * Returns information about a swath attribute. * * MATLAB usage: * [numbertype, count, status] = ... * hdf('SW', 'attrinfo', swathid, attrname); * * Inputs: swathid - Swath identifier * attrname - attribute name * * Outputs: numbertype - number type of attribute * count - number of total bytes in attribute * status - returns 0 if succeed, and -1 if fail * * Retuns: none */ static void hdfSWattrinfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *attrname = NULL; int32 numbertype; int32 count; int32 status; /* Argument checking */ haNarginChk(4, 4, nrhs); haNargoutChk(0, 3, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); attrname = haGetString(prhs[3], "Attribute name"); /* Call HDF-EOS library function, and output result */ status = SWattrinfo(swathid, attrname, &numbertype, &count); if (status != FAIL) { plhs[0] = mxCreateString(haGetNumberTypeString(numbertype)); } else { plhs[0] = EMPTY; } if (nlhs > 1) { if (status != FAIL) { plhs[1] = haCreateDoubleScalar((double) count); } else { plhs[1] = EMPTY; } } if (nlhs > 2) { plhs[2] = haCreateDoubleScalar(status); } /* Clean up */ if (attrname != NULL) { mxFree(attrname); } } /* * hdfSWcompinfo * * Purpose: Gateway to the HDF-EOS Library function SWcompinfo * Retreives compression information about a field * * MATLAB usage: * [compcode, compparm, status] = ... * hdf('SW', 'compinfo', swathid, fieldname); * * Inputs: swathid - Swath identifier * fieldname - field name * * Outputs: compcode - HDF compression code * compparm - compression parameters * status - returns 0 if succeed, and -1 if fail * * Retuns: none */ static void hdfSWcompinfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *fieldname = NULL; int32 compcode; intn compparm[NUM_EOS_COMP_PARMS]; double *real_ptr; intn status; int i; /* Argument checking */ haNarginChk(4, 4, nrhs); haNargoutChk(0, 3, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); fieldname = haGetString(prhs[3], "Field name"); /* Initialize parameter vector to zeros, because HDF-EOS library */ /* may not fill it. */ for (i = 0; i < NUM_EOS_COMP_PARMS; i++) { compparm[i] = 0; } /* Call HDF-EOS library function. */ status = SWcompinfo(swathid, fieldname, &compcode, compparm); if (status != FAIL) { plhs[0] = GetCompressionStringFromCode(compcode); } else { plhs[0] = EMPTY; } if (nlhs > 1) { if (status != FAIL) { plhs[1] = mxCreateDoubleMatrix(1, NUM_EOS_COMP_PARMS, mxREAL); real_ptr = mxGetPr(plhs[1]); for (i = 0; i < NUM_EOS_COMP_PARMS; i++) { real_ptr[i] = (double) compparm[i]; } } else { plhs[1] = EMPTY; } } if (nlhs > 2) { plhs[2] = haCreateDoubleScalar(status); } /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } } /* * hdfSWinqswath * * Purpose: Gateway to the HDF-EOS Library function SWinqswath * Retreives compression information about a field * * MATLAB usage: * [nswath, swathlist] = hdf('SW', 'inqswath', filename); * * Inputs: filename - HDF file name * * Outputs: nswath - Number of swaths found * swathlist - listing of swaths in file * * Retuns: none */ static void hdfSWinqswath(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { char *filename = NULL; int32 nswath; char *swathlist = NULL; int32 strbufsize; intn status; /* Argument checking */ haNarginChk(3, 3, nrhs); haNargoutChk(0, 2, nlhs); /* Get data from MATLAB arrays */ filename = haGetString(prhs[2], "Filename"); /* How much space do we need to allocate? */ nswath = SWinqswath(filename, NULL, &strbufsize); status = (nswath < 0) ? FAIL : SUCCEED; /* Allocate space and get the swathlist */ if (status != FAIL) { swathlist = mxCalloc(strbufsize+1, sizeof(char)); nswath = SWinqswath(filename, swathlist, &strbufsize); } plhs[0] = haCreateDoubleScalar((double) nswath); if (nlhs > 1) { if (status != FAIL) { plhs[1] = mxCreateString(swathlist); } else { plhs[1] = EMPTY; } } /* Clean up */ if (filename != NULL) { mxFree(filename); } if (swathlist != NULL) { mxFree(swathlist); } } /* hdfSWgeomapinfo * * Purpose: Gateway to the HDF-EOS Library function SWgeomapinfo * Retrieves type of dimension mapping for a dimension * * MATLAB usage: * regmap = hdf('SW','geomapinfo',swathid, geodim) * * Inputs: swathid - Swath identifier * geodim - Dimension name * * Outputs: none * * Returns: regmap - An integer * -1 Failed * 0 not mapped * 1 regular mapping * 2 indexed mapping * 3 regular and indexed mapping * */ static void hdfSWgeomapinfo(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *geodim; intn regmap; char dimmap[8]; haNarginChk(4,4,nrhs); haNargoutChk(0,1,nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); geodim = haGetString(prhs[3],"Dimension name"); /* Call HDF-EOS library function and output result */ regmap = SWgeomapinfo(swathid,geodim); plhs[0] = haCreateDoubleScalar((double)regmap); /* Clean up */ if(geodim != NULL) { mxFree(geodim); } } /* * hdfSWdefcomp * * Purpose: Gateway to the HDF-EOS Library function SWdefcomp * Sets the field compression for all subsequent field definitions. * * MATLAB usage: * status = hdf('SW', 'defcomp', swathid, compcode, compparm) * * Inputs: swathid - Swath identifier * compcode - HDF Compression code * compparm - Compression parameters (if applicable) * * Outputs: status - 0 if succeeded, -1 if failed. * * Returns: none */ static void hdfSWdefcomp(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 compcode; intn compparm[NUM_EOS_COMP_PARMS]; intn status; /* Argument checking */ haNarginChk(5, 5, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); compcode = haGetEOSCompressionCode(prhs[3]); haGetEOSCompressionParameters(prhs[4], compparm); /* Call HDF-EOS library function, and output result */ status = SWdefcomp(swathid, compcode, compparm); plhs[0] = haCreateDoubleScalar((double) status); } /* * hdfSWwritegeometa * * Purpose: Gateway to the HDF-EOS Library function SWwritegeometa * Writes field metadata for an existing swath geolocation field * * MATLAB usage: * status = hd('SW', 'writegeometa', swathid, fieldname, ... * dimlist, numbertype) * * Inputs: swathid - Swath identifier * fieldname - Name of field * dimlist - list of geolocation dimensions defining the field * numbertype - The numbertype of the data stored in the field * * Outputs: status - 0 if succeeded, -1 if failed. * * Returns: none */ static void hdfSWwritegeometa(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *fieldname = NULL; char *dimlist = NULL; int32 numbertype; intn status; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); fieldname = haGetString(prhs[3], "Field name"); dimlist = haGetString(prhs[4], "Dimension list"); numbertype = haGetDataType(prhs[5]); /* Call HDF-EOS library function, and output result */ status = SWwritegeometa(swathid, fieldname, dimlist, numbertype); plhs[0] = haCreateDoubleScalar((double) status); /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } if (dimlist != NULL) { mxFree(dimlist); } } /* * hdfSWwritedatameta * * Purpose: Gateway to the HDF-EOS Library function SWwritedatameta * Writes field metadata for an existing swath data field * * MATLAB usage: * status = hd('SW', 'writedatameta', swathid, fieldname, ... * dimlist, numbertype) * * Inputs: swathid - Swath identifier * fieldname - Name of field * dimlist - list of geolocation dimensions defining the field * numbertype - The numbertype of the data stored in the field * * Outputs: status - 0 if succeeded, -1 if failed. * * Returns: none */ static void hdfSWwritedatameta(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *fieldname = NULL; char *dimlist = NULL; int32 numbertype; intn status; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); fieldname = haGetString(prhs[3], "Field name"); dimlist = haGetString(prhs[4], "Dimension list"); numbertype = haGetDataType(prhs[5]); /* Call HDF-EOS library function, and output result */ status = SWwritedatameta(swathid, fieldname, dimlist, numbertype); plhs[0] = haCreateDoubleScalar((double) status); /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } if (dimlist != NULL) { mxFree(dimlist); } } /* * hdfSWsetfillvalue * * Purpose: Gateway to the HDF-EOS Library function SWsetfillvalue * Sets fill value for the specified field. * * MATLAB usage: * status = hd('SW', 'setfillvalue', swathid, fieldname, fillvalue) * * Inputs: swathid - Swath identifier * fieldname - field name * fillvalue - fill value to use * * Outputs: status - 0 if succeeded, -1 if failed. * * Returns: none */ static void hdfSWsetfillvalue(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *fieldname = NULL; void *fillvalue = NULL; intn status; int32 rank; int32 dims[MAX_VAR_DIMS]; int32 numbertype; bool free_fillvalue = false; /* Argument checking */ haNarginChk(5, 5, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); fieldname = haGetString(prhs[3], "Field name"); /* Call fieldinfo to get the data type of the field */ status = SWfieldinfo(swathid, fieldname, &rank, dims, &numbertype, NULL); if (status != FAIL) { if (haGetClassIDFromDataType(numbertype) != mxGetClassID(prhs[4])) { mexErrMsgTxt("The data type of the fill value must match the " "data type of the field."); } if (mxGetClassID(prhs[4]) == mxCHAR_CLASS) { fillvalue = haMakeHDFDataBufferFromCharArray(prhs[4], numbertype); free_fillvalue = true; } else { fillvalue = mxGetData(prhs[4]); } } /* Call HDF-EOS library function, and output result */ if (status != FAIL) { status = SWsetfillvalue(swathid, fieldname, fillvalue); } plhs[0] = haCreateDoubleScalar((double) status); /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } if (free_fillvalue) { mxFree(fillvalue); } } /* * hdfSWgetfillvalue * * Purpose: Gateway to the HDF-EOS Library function SWgetfillvalue * Gets fill value for the specified field. * * MATLAB usage: * [fillvalue, status] = hdf('SW', 'getfillvalue', swathid, ... * fieldname) * * Inputs: swathid - Swath identifier * fieldname - field name * * Outputs: fillvalue - fill value * status - 0 if succeeded, -1 if failed. * * Returns: none */ static void hdfSWgetfillvalue(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; char *fieldname = NULL; VOIDP fillvalue = NULL; intn status; int32 numbertype; int32 rank; int32 dims[MAX_VAR_DIMS]; int matlab_dims[MAX_VAR_DIMS]; bool ok2free = true; /* Argument checking */ haNarginChk(4, 4, nrhs); haNargoutChk(0, 2, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); fieldname = haGetString(prhs[3], "Field name"); /* Get number type for the field */ status = SWfieldinfo(swathid, fieldname, &rank, dims, &numbertype, NULL); /* Allocate space for fillvalue and get it */ if (status != FAIL) { fillvalue = haMakeHDFDataBuffer(1, numbertype); status = SWgetfillvalue(swathid, fieldname, fillvalue); } matlab_dims[0] = 1; matlab_dims[1] = 1; if (status == 0) { plhs[0] = haMakeArrayFromHDFDataBuffer(2, matlab_dims, numbertype, fillvalue, &ok2free); } else { plhs[0] = EMPTY; } if (nlhs > 1) { plhs[1] = haCreateDoubleScalar((double) status); } /* Clean up */ if (fieldname != NULL) { mxFree(fieldname); } if (ok2free && fillvalue!=NULL) { mxFree(fillvalue); } } /* * hdfSWdefvrtregion * * Purpose: Gateway to the HDF-EOS Library function SWdefvrtregion * Subsets on a monotonic field or contiguous elements of * a dimension. * * MATLAB usage: * regionid2 = hdf('SW', 'defvrtregion', swathid, ... * regionid, vertobj, range); * * Inputs: swathid - Swath identifier * regionid - Region (or period) ID from previous subset call * (may be -1 for "stand-alone" * vertobj - Dimension or field to subset by * range - minimum and maximum range for subset * * Outputs: regionid2 - Swath region ID * * Retuns: none */ static void hdfSWdefvrtregion(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 swathid; int32 regionid; char *vertobj = NULL; char *regidmacro = NULL; double *range = NULL; int32 regionid2; /* Argument checking */ haNarginChk(6, 6, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ swathid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Swath identifier"); if (mxIsChar(prhs[3])) { regidmacro = haGetString(prhs[3], "Region Identifier macro"); if (!haStrcmpi(regidmacro, "HDFE_NOPREVSUB") || !haStrcmpi(regidmacro, "NOPREVSUB")) { regionid = HDFE_NOPREVSUB; } else { mexErrMsgTxt("REGIONID must be a valid region identifier or 'noprevsub'"); } mxFree(regidmacro); } else { regionid = (int32) haGetNonNegativeDoubleScalar(prhs[3], "Region identifier"); } vertobj = haGetString(prhs[4], "VertObj"); if (!mxIsDouble(prhs[5]) || (mxGetNumberOfElements(prhs[5]) != 2)) { mexErrMsgTxt("range must be a double array of length 2."); } range = mxGetPr(prhs[5]); /* Call HDF-EOS library function, and output result */ regionid2 = SWdefvrtregion(swathid, regionid, vertobj, range); plhs[0] = haCreateDoubleScalar((double) regionid2); /* Clean up */ if (vertobj != NULL) { mxFree(vertobj); } } /* * hdfSWdupregion * * Purpose: Gateway to the HDF-EOS Library function SWdupregion * Duplicates a region. * * MATLAB usage: * regionid2 = hdf('SW', 'dupregion', regionid); * * Inputs: regionid - Region (or period) ID from previous subset call * * Outputs: regionid2 - Swath region ID * * Retuns: none */ static void hdfSWdupregion(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int32 regionid; int32 regionid2; /* Argument checking */ haNarginChk(3, 3, nrhs); haNargoutChk(0, 1, nlhs); /* Get data from MATLAB arrays */ regionid = (int32) haGetNonNegativeDoubleScalar(prhs[2], "Region identifier"); /* Call HDF-EOS library function, and output result */ regionid2 = SWdupregion(regionid); plhs[0] = haCreateDoubleScalar((double) regionid2); } /* * hdfSW * * Purpose: Function switchyard for the HDF-EOS SW part of the HDF gateway. * * Inputs: nlhs --- number of left-side arguments * plhs --- left-side arguments * nrhs --- number of right-side arguments * prhs --- right-side arguments * functionStr --- string specifying which SW function to call * Outputs: none * Return: none */ void hdfSW(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], char *functionStr) { typedef void (MATLAB_FCN)(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]); struct { char *name; MATLAB_FCN *func; } SWFcns[] = { {"open", hdfSWopen}, {"create", hdfSWcreate}, {"attach", hdfSWattach}, {"detach", hdfSWdetach}, {"close", hdfSWclose}, {"defdim", hdfSWdefdim}, {"defdimmap", hdfSWdefdimmap}, {"defidxmap", hdfSWdefidxmap}, {"defgeofield", hdfSWdefgeofield}, {"defdatafield", hdfSWdefdatafield}, {"writefield", hdfSWwritefield}, {"readfield", hdfSWreadfield}, {"writeattr", hdfSWwriteattr}, {"readattr", hdfSWreadattr}, {"inqdims", hdfSWinqdims}, {"inqmaps", hdfSWinqmaps}, {"inqidxmaps", hdfSWinqidxmaps}, {"inqgeofields", hdfSWinqgeofields}, {"inqdatafields", hdfSWinqdatafields}, {"nentries", hdfSWnentries}, {"diminfo", hdfSWdiminfo}, {"mapinfo", hdfSWmapinfo}, {"idxmapinfo", hdfSWidxmapinfo}, {"fieldinfo", hdfSWfieldinfo}, {"defboxregion", hdfSWdefboxregion}, {"regioninfo", hdfSWregioninfo}, {"extractregion", hdfSWextractregion}, {"deftimeperiod", hdfSWdeftimeperiod}, {"periodinfo", hdfSWperiodinfo}, {"extractperiod", hdfSWextractperiod}, {"inqattrs", hdfSWinqattrs}, {"attrinfo", hdfSWattrinfo}, {"compinfo", hdfSWcompinfo}, {"inqswath", hdfSWinqswath}, {"defcomp", hdfSWdefcomp}, {"writegeometa", hdfSWwritegeometa}, {"writedatameta", hdfSWwritedatameta}, {"setfillvalue", hdfSWsetfillvalue}, {"getfillvalue", hdfSWgetfillvalue}, {"defvrtregion", hdfSWdefvrtregion}, {"dupregion", hdfSWdupregion}, {"geomapinfo", hdfSWgeomapinfo}, {"updateidxmap", hdfSWupdateidxmap}, }; int NumberOfFunctions = sizeof(SWFcns) / sizeof(*SWFcns); int i; bool found = false; for (i=0; i