netCDF 4.2.1.1
|
00001 00007 #include "ncdispatch.h" 00008 00009 00014 int 00015 NC_get_vara(int ncid, int varid, 00016 const size_t *start, const size_t *edges, 00017 void *value, nc_type memtype) 00018 { 00019 NC* ncp; 00020 int stat = NC_check_id(ncid, &ncp); 00021 if(stat != NC_NOERR) return stat; 00022 #ifdef USE_NETCDF4 00023 if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT; 00024 #endif 00025 if(edges == NULL) { 00026 size_t shape[NC_MAX_VAR_DIMS]; 00027 int ndims; 00028 stat = nc_inq_varndims(ncid, varid, &ndims); 00029 if(stat != NC_NOERR) return stat; 00030 stat = NC_getshape(ncid,varid,ndims,shape); 00031 if(stat != NC_NOERR) return stat; 00032 return ncp->dispatch->get_vara(ncid,varid,start,shape,value,memtype); 00033 } else 00034 return ncp->dispatch->get_vara(ncid,varid,start,edges,value,memtype); 00035 } 00036 00040 static int 00041 NC_get_var(int ncid, int varid, void *value, nc_type memtype) 00042 { 00043 int ndims; 00044 size_t shape[NC_MAX_VAR_DIMS]; 00045 int stat = nc_inq_varndims(ncid,varid, &ndims); 00046 if(stat) return stat; 00047 stat = NC_getshape(ncid,varid, ndims, shape); 00048 if(stat) return stat; 00049 return NC_get_vara(ncid, varid, NC_coord_zero, shape, value, memtype); 00050 } 00051 00056 int 00057 NCDEFAULT_get_vars(int ncid, int varid, const size_t * start, 00058 const size_t * edges, const ptrdiff_t * stride, 00059 void *value, nc_type memtype) 00060 { 00061 NC* ncp; 00062 int stat = NC_check_id(ncid, &ncp); 00063 00064 if(stat != NC_NOERR) return stat; 00065 return ncp->dispatch->get_varm(ncid,varid,start,edges,stride,NULL,value,memtype); 00066 } 00067 00071 static int 00072 NC_get_var1(int ncid, int varid, const size_t *coord, void* value, 00073 nc_type memtype) 00074 { 00075 return NC_get_vara(ncid, varid, coord, NC_coord_one, value, memtype); 00076 } 00077 00081 int 00082 NCDEFAULT_get_varm(int ncid, int varid, const size_t *start, 00083 const size_t *edges, const ptrdiff_t *stride, 00084 const ptrdiff_t *imapp, void *value0, nc_type memtype) 00085 { 00086 int status = NC_NOERR; 00087 nc_type vartype = NC_NAT; 00088 int varndims,maxidim; 00089 NC* ncp; 00090 size_t memtypelen; 00091 ptrdiff_t cvtmap[NC_MAX_VAR_DIMS]; 00092 char* value = (char*)value0; 00093 00094 status = NC_check_id (ncid, &ncp); 00095 if(status != NC_NOERR) return status; 00096 00097 /* 00098 if(NC_indef(ncp)) return NC_EINDEFINE; 00099 */ 00100 00101 status = nc_inq_vartype(ncid, varid, &vartype); 00102 if(status != NC_NOERR) return status; 00103 /* Check that this is an atomic type */ 00104 if(vartype >= NC_MAX_ATOMIC_TYPE) 00105 return NC_EMAPTYPE; 00106 00107 status = nc_inq_varndims(ncid, varid, &varndims); 00108 if(status != NC_NOERR) return status; 00109 00110 if(memtype == NC_NAT) { 00111 if(imapp != NULL && varndims != 0) { 00112 /* 00113 * convert map units from bytes to units of sizeof(type) 00114 */ 00115 size_t ii; 00116 const ptrdiff_t szof = (ptrdiff_t) nctypelen(vartype); 00117 for(ii = 0; ii < varndims; ii++) { 00118 if(imapp[ii] % szof != 0) { 00119 /*free(cvtmap);*/ 00120 return NC_EINVAL; 00121 } 00122 cvtmap[ii] = imapp[ii] / szof; 00123 } 00124 imapp = cvtmap; 00125 } 00126 memtype = vartype; 00127 } 00128 00129 if(memtype == NC_CHAR && vartype != NC_CHAR) 00130 return NC_ECHAR; 00131 else if(memtype != NC_CHAR && vartype == NC_CHAR) 00132 return NC_ECHAR; 00133 00134 memtypelen = nctypelen(memtype); 00135 00136 maxidim = (int) varndims - 1; 00137 00138 if (maxidim < 0) 00139 { 00140 /* 00141 * The variable is a scalar; consequently, 00142 * there s only one thing to get and only one place to put it. 00143 * (Why was I called?) 00144 */ 00145 size_t edge1[1] = {1}; 00146 return NC_get_vara(ncid, varid, start, edge1, value, memtype); 00147 } 00148 00149 /* 00150 * else 00151 * The variable is an array. 00152 */ 00153 { 00154 int idim; 00155 size_t *mystart = NULL; 00156 size_t *myedges; 00157 size_t *iocount; /* count vector */ 00158 size_t *stop; /* stop indexes */ 00159 size_t *length; /* edge lengths in bytes */ 00160 ptrdiff_t *mystride; 00161 ptrdiff_t *mymap; 00162 size_t varshape[NC_MAX_VAR_DIMS]; 00163 int isrecvar; 00164 size_t numrecs; 00165 00166 /* Compute some dimension related values */ 00167 isrecvar = NC_is_recvar(ncid,varid,&numrecs); 00168 NC_getshape(ncid,varid,varndims,varshape); 00169 00170 /* 00171 * Verify stride argument; also see if stride is all ones 00172 */ 00173 if(stride != NULL) { 00174 int stride1 = 1; 00175 for (idim = 0; idim <= maxidim; ++idim) 00176 { 00177 if (stride[idim] == 0 00178 /* cast needed for braindead systems with signed size_t */ 00179 || ((unsigned long) stride[idim] >= X_INT_MAX)) 00180 { 00181 return NC_ESTRIDE; 00182 } 00183 if(stride[idim] != 1) stride1 = 0; 00184 } 00185 /* If stride1 is true, and there is no imap 00186 then call get_vara directly. 00187 */ 00188 if(stride1 && imapp == NULL) { 00189 return NC_get_vara(ncid, varid, start, edges, value, memtype); 00190 } 00191 } 00192 00193 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */ 00194 /* Allocate space for mystart,mystride,mymap etc.all at once */ 00195 mystart = (size_t *)calloc(varndims * 7, sizeof(ptrdiff_t)); 00196 if(mystart == NULL) return NC_ENOMEM; 00197 myedges = mystart + varndims; 00198 iocount = myedges + varndims; 00199 stop = iocount + varndims; 00200 length = stop + varndims; 00201 mystride = (ptrdiff_t *)(length + varndims); 00202 mymap = mystride + varndims; 00203 00204 /* 00205 * Initialize I/O parameters. 00206 */ 00207 for (idim = maxidim; idim >= 0; --idim) 00208 { 00209 mystart[idim] = start != NULL 00210 ? start[idim] 00211 : 0; 00212 00213 if (edges != NULL && edges[idim] == 0) 00214 { 00215 status = NC_NOERR; /* read/write no data */ 00216 goto done; 00217 } 00218 00219 #ifdef COMPLEX 00220 myedges[idim] = edges != NULL 00221 ? edges[idim] 00222 : idim == 0 && isrecvar 00223 ? numrecs - mystart[idim] 00224 : varshape[idim] - mystart[idim]; 00225 #else 00226 if(edges != NULL) 00227 myedges[idim] = edges[idim]; 00228 else if (idim == 0 && isrecvar) 00229 myedges[idim] = numrecs - mystart[idim]; 00230 else 00231 myedges[idim] = varshape[idim] - mystart[idim]; 00232 #endif 00233 00234 mystride[idim] = stride != NULL 00235 ? stride[idim] 00236 : 1; 00237 00238 /* Remember: imapp is byte oriented, not index oriented */ 00239 #ifdef COMPLEX 00240 mymap[idim] = (imapp != NULL 00241 ? imapp[idim] 00242 : (idim == maxidim ? 1 00243 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1])); 00244 #else 00245 if(imapp != NULL) 00246 mymap[idim] = imapp[idim]; 00247 else if (idim == maxidim) 00248 mymap[idim] = 1; 00249 else 00250 mymap[idim] = 00251 mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1]; 00252 #endif 00253 iocount[idim] = 1; 00254 length[idim] = mymap[idim] * myedges[idim]; 00255 stop[idim] = mystart[idim] + myedges[idim] * mystride[idim]; 00256 } 00257 00258 /* 00259 * Check start, edges 00260 */ 00261 for (idim = maxidim; idim >= 0; --idim) 00262 { 00263 size_t dimlen = 00264 idim == 0 && isrecvar 00265 ? numrecs 00266 : varshape[idim]; 00267 if (mystart[idim] >= dimlen) 00268 { 00269 status = NC_EINVALCOORDS; 00270 goto done; 00271 } 00272 00273 if (mystart[idim] + myedges[idim] > dimlen) 00274 { 00275 status = NC_EEDGE; 00276 goto done; 00277 } 00278 00279 } 00280 00281 00282 /* Lower body */ 00283 /* 00284 * As an optimization, adjust I/O parameters when the fastest 00285 * dimension has unity stride both externally and internally. 00286 * In this case, the user could have called a simpler routine 00287 * (i.e. ncvar$1() 00288 */ 00289 if (mystride[maxidim] == 1 00290 && mymap[maxidim] == 1) 00291 { 00292 iocount[maxidim] = myedges[maxidim]; 00293 mystride[maxidim] = (ptrdiff_t) myedges[maxidim]; 00294 mymap[maxidim] = (ptrdiff_t) length[maxidim]; 00295 } 00296 00297 /* 00298 * Perform I/O. Exit when done. 00299 */ 00300 for (;;) 00301 { 00302 /* TODO: */ 00303 int lstatus = NC_get_vara(ncid, varid, mystart, iocount, 00304 value, memtype); 00305 if (lstatus != NC_NOERR) { 00306 if(status == NC_NOERR || lstatus != NC_ERANGE) 00307 status = lstatus; 00308 } 00309 /* 00310 * The following code permutes through the variable s 00311 * external start-index space and it s internal address 00312 * space. At the UPC, this algorithm is commonly 00313 * called "odometer code". 00314 */ 00315 idim = maxidim; 00316 carry: 00317 value += (mymap[idim] * memtypelen); 00318 mystart[idim] += mystride[idim]; 00319 if (mystart[idim] == stop[idim]) 00320 { 00321 mystart[idim] = start[idim]; 00322 value -= (length[idim] * memtypelen); 00323 if (--idim < 0) 00324 break; /* normal return */ 00325 goto carry; 00326 } 00327 } /* I/O loop */ 00328 done: 00329 free(mystart); 00330 } /* variable is array */ 00331 return status; 00332 } 00333 00337 static int 00338 NC_get_vars(int ncid, int varid, const size_t *start, 00339 const size_t *edges, const ptrdiff_t *stride, void *value, 00340 nc_type memtype) 00341 { 00342 NC* ncp; 00343 int stat = NC_check_id(ncid, &ncp); 00344 00345 if(stat != NC_NOERR) return stat; 00346 #ifdef USE_NETCDF4 00347 if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT; 00348 #endif 00349 return ncp->dispatch->get_vars(ncid,varid,start,edges,stride,value,memtype); 00350 } 00351 00356 static int 00357 NC_get_varm(int ncid, int varid, const size_t *start, 00358 const size_t *edges, const ptrdiff_t *stride, const ptrdiff_t* map, 00359 void *value, nc_type memtype) 00360 { 00361 NC* ncp; 00362 int stat = NC_check_id(ncid, &ncp); 00363 00364 if(stat != NC_NOERR) return stat; 00365 #ifdef USE_NETCDF4 00366 if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT; 00367 #endif 00368 return ncp->dispatch->get_varm(ncid,varid,start,edges,stride,map,value,memtype); 00369 } 00370 /* All these functions are part of this named group... */ 00375 00450 int 00451 nc_get_vara(int ncid, int varid, const size_t *startp, 00452 const size_t *countp, void *ip) 00453 { 00454 NC* ncp = NULL; 00455 nc_type xtype = NC_NAT; 00456 int stat = NC_check_id(ncid, &ncp); 00457 if(stat != NC_NOERR) return stat; 00458 stat = nc_inq_vartype(ncid, varid, &xtype); 00459 if(stat != NC_NOERR) return stat; 00460 return NC_get_vara(ncid, varid, startp, countp, ip, xtype); 00461 } 00462 00463 int 00464 nc_get_vara_text(int ncid, int varid, const size_t *startp, 00465 const size_t *countp, char *ip) 00466 { 00467 NC* ncp; 00468 int stat = NC_check_id(ncid, &ncp); 00469 if(stat != NC_NOERR) return stat; 00470 return NC_get_vara(ncid, varid, startp, countp, 00471 (void *)ip, NC_CHAR); 00472 } 00473 00474 int 00475 nc_get_vara_schar(int ncid, int varid, const size_t *startp, 00476 const size_t *countp, signed char *ip) 00477 { 00478 NC* ncp; 00479 int stat = NC_check_id(ncid, &ncp); 00480 if(stat != NC_NOERR) return stat; 00481 return NC_get_vara(ncid, varid, startp, countp, 00482 (void *)ip, NC_BYTE); 00483 } 00484 00485 int 00486 nc_get_vara_uchar(int ncid, int varid, const size_t *startp, 00487 const size_t *countp, unsigned char *ip) 00488 { 00489 NC* ncp; 00490 int stat = NC_check_id(ncid, &ncp); 00491 if(stat != NC_NOERR) return stat; 00492 return NC_get_vara(ncid, varid, startp, countp, 00493 (void *)ip, T_uchar); 00494 } 00495 00496 int 00497 nc_get_vara_short(int ncid, int varid, const size_t *startp, 00498 const size_t *countp, short *ip) 00499 { 00500 NC* ncp; 00501 int stat = NC_check_id(ncid, &ncp); 00502 if(stat != NC_NOERR) return stat; 00503 return NC_get_vara(ncid, varid, startp, countp, 00504 (void *)ip, NC_SHORT); 00505 } 00506 00507 int 00508 nc_get_vara_int(int ncid, int varid, 00509 const size_t *startp, const size_t *countp, int *ip) 00510 { 00511 NC* ncp; 00512 int stat = NC_check_id(ncid, &ncp); 00513 if(stat != NC_NOERR) return stat; 00514 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_INT); 00515 } 00516 00517 int 00518 nc_get_vara_long(int ncid, int varid, 00519 const size_t *startp, const size_t *countp, long *ip) 00520 { 00521 NC* ncp; 00522 int stat = NC_check_id(ncid, &ncp); 00523 if(stat != NC_NOERR) return stat; 00524 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_long); 00525 } 00526 00527 int 00528 nc_get_vara_float(int ncid, int varid, 00529 const size_t *startp, const size_t *countp, float *ip) 00530 { 00531 NC* ncp; 00532 int stat = NC_check_id(ncid, &ncp); 00533 if(stat != NC_NOERR) return stat; 00534 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_float); 00535 } 00536 00537 00538 int 00539 nc_get_vara_double(int ncid, int varid, const size_t *startp, 00540 const size_t *countp, double *ip) 00541 { 00542 NC* ncp; 00543 int stat = NC_check_id(ncid, &ncp); 00544 if(stat != NC_NOERR) return stat; 00545 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_double); 00546 } 00547 00548 int 00549 nc_get_vara_ubyte(int ncid, int varid, 00550 const size_t *startp, const size_t *countp, unsigned char *ip) 00551 { 00552 NC* ncp; 00553 int stat = NC_check_id(ncid, &ncp); 00554 if(stat != NC_NOERR) return stat; 00555 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ubyte); 00556 } 00557 00558 int 00559 nc_get_vara_ushort(int ncid, int varid, 00560 const size_t *startp, const size_t *countp, unsigned short *ip) 00561 { 00562 NC* ncp; 00563 int stat = NC_check_id(ncid, &ncp); 00564 if(stat != NC_NOERR) return stat; 00565 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ushort); 00566 } 00567 00568 int 00569 nc_get_vara_uint(int ncid, int varid, 00570 const size_t *startp, const size_t *countp, unsigned int *ip) 00571 { 00572 NC* ncp; 00573 int stat = NC_check_id(ncid, &ncp); 00574 if(stat != NC_NOERR) return stat; 00575 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_uint); 00576 } 00577 00578 int 00579 nc_get_vara_longlong(int ncid, int varid, 00580 const size_t *startp, const size_t *countp, long long *ip) 00581 { 00582 NC* ncp; 00583 int stat = NC_check_id(ncid, &ncp); 00584 if(stat != NC_NOERR) return stat; 00585 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_longlong); 00586 } 00587 00588 int 00589 nc_get_vara_ulonglong(int ncid, int varid, 00590 const size_t *startp, const size_t *countp, unsigned long long *ip) 00591 { 00592 NC* ncp; 00593 int stat = NC_check_id(ncid, &ncp); 00594 if(stat != NC_NOERR) return stat; 00595 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_UINT64); 00596 } 00597 00598 #ifdef USE_NETCDF4 00599 int 00600 nc_get_vara_string(int ncid, int varid, 00601 const size_t *startp, const size_t *countp, char* *ip) 00602 { 00603 NC* ncp; 00604 int stat = NC_check_id(ncid, &ncp); 00605 if(stat != NC_NOERR) return stat; 00606 return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_STRING); 00607 } 00608 00609 #endif /*USE_NETCDF4*/ 00610 00646 int 00647 nc_get_var1(int ncid, int varid, const size_t *indexp, void *ip) 00648 { 00649 return NC_get_var1(ncid, varid, indexp, ip, NC_NAT); 00650 } 00651 00652 int 00653 nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip) 00654 { 00655 NC* ncp; 00656 int stat = NC_check_id(ncid, &ncp); 00657 if(stat != NC_NOERR) return stat; 00658 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_CHAR); 00659 } 00660 00661 int 00662 nc_get_var1_schar(int ncid, int varid, const size_t *indexp, signed char *ip) 00663 { 00664 NC* ncp; 00665 int stat = NC_check_id(ncid, &ncp); 00666 if(stat != NC_NOERR) return stat; 00667 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_BYTE); 00668 } 00669 00670 int 00671 nc_get_var1_uchar(int ncid, int varid, const size_t *indexp, unsigned char *ip) 00672 { 00673 NC* ncp; 00674 int stat = NC_check_id(ncid, &ncp); 00675 if(stat != NC_NOERR) return stat; 00676 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE); 00677 } 00678 00679 int 00680 nc_get_var1_short(int ncid, int varid, const size_t *indexp, short *ip) 00681 { 00682 NC* ncp; 00683 int stat = NC_check_id(ncid, &ncp); 00684 if(stat != NC_NOERR) return stat; 00685 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_SHORT); 00686 } 00687 00688 int 00689 nc_get_var1_int(int ncid, int varid, const size_t *indexp, int *ip) 00690 { 00691 NC* ncp; 00692 int stat = NC_check_id(ncid, &ncp); 00693 if(stat != NC_NOERR) return stat; 00694 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT); 00695 } 00696 00697 int 00698 nc_get_var1_long(int ncid, int varid, const size_t *indexp, 00699 long *ip) 00700 { 00701 NC* ncp; 00702 int stat = NC_check_id(ncid, &ncp); 00703 if(stat != NC_NOERR) return stat; 00704 return NC_get_var1(ncid, varid, indexp, (void *)ip, longtype); 00705 } 00706 00707 int 00708 nc_get_var1_float(int ncid, int varid, const size_t *indexp, 00709 float *ip) 00710 { 00711 NC* ncp; 00712 int stat = NC_check_id(ncid, &ncp); 00713 if(stat != NC_NOERR) return stat; 00714 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_FLOAT); 00715 } 00716 00717 int 00718 nc_get_var1_double(int ncid, int varid, const size_t *indexp, 00719 double *ip) 00720 { 00721 NC* ncp; 00722 int stat = NC_check_id(ncid, &ncp); 00723 if(stat != NC_NOERR) return stat; 00724 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_DOUBLE); 00725 } 00726 00727 int 00728 nc_get_var1_ubyte(int ncid, int varid, const size_t *indexp, 00729 unsigned char *ip) 00730 { 00731 NC* ncp; 00732 int stat = NC_check_id(ncid, &ncp); 00733 if(stat != NC_NOERR) return stat; 00734 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE); 00735 } 00736 00737 int 00738 nc_get_var1_ushort(int ncid, int varid, const size_t *indexp, 00739 unsigned short *ip) 00740 { 00741 NC* ncp; 00742 int stat = NC_check_id(ncid, &ncp); 00743 if(stat != NC_NOERR) return stat; 00744 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_USHORT); 00745 } 00746 00747 int 00748 nc_get_var1_uint(int ncid, int varid, const size_t *indexp, 00749 unsigned int *ip) 00750 { 00751 NC* ncp; 00752 int stat = NC_check_id(ncid, &ncp); 00753 if(stat != NC_NOERR) return stat; 00754 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT); 00755 } 00756 00757 int 00758 nc_get_var1_longlong(int ncid, int varid, const size_t *indexp, 00759 long long *ip) 00760 { 00761 NC* ncp; 00762 int stat = NC_check_id(ncid, &ncp); 00763 if(stat != NC_NOERR) return stat; 00764 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT64); 00765 } 00766 00767 int 00768 nc_get_var1_ulonglong(int ncid, int varid, const size_t *indexp, 00769 unsigned long long *ip) 00770 { 00771 NC* ncp; 00772 int stat = NC_check_id(ncid, &ncp); 00773 if(stat != NC_NOERR) return stat; 00774 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UINT64); 00775 } 00776 00777 #ifdef USE_NETCDF4 00778 int 00779 nc_get_var1_string(int ncid, int varid, const size_t *indexp, char* *ip) 00780 { 00781 NC* ncp; 00782 int stat = NC_check_id(ncid, &ncp); 00783 if(stat != NC_NOERR) return stat; 00784 return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_STRING); 00785 } 00786 #endif /*USE_NETCDF4*/ 00787 00832 int 00833 nc_get_var(int ncid, int varid, void *ip) 00834 { 00835 return NC_get_var(ncid, varid, ip, NC_NAT); 00836 } 00837 00838 int 00839 nc_get_var_text(int ncid, int varid, char *ip) 00840 { 00841 NC *ncp; 00842 int stat = NC_check_id(ncid, &ncp); 00843 if(stat != NC_NOERR) return stat; 00844 return NC_get_var(ncid, varid, (void *)ip, NC_CHAR); 00845 } 00846 00847 int 00848 nc_get_var_schar(int ncid, int varid, signed char *ip) 00849 { 00850 NC *ncp; 00851 int stat = NC_check_id(ncid, &ncp); 00852 if(stat != NC_NOERR) return stat; 00853 return NC_get_var(ncid, varid, (void *)ip, NC_BYTE); 00854 } 00855 00856 int 00857 nc_get_var_uchar(int ncid, int varid, unsigned char *ip) 00858 { 00859 NC *ncp; 00860 int stat = NC_check_id(ncid, &ncp); 00861 if(stat != NC_NOERR) return stat; 00862 return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE); 00863 } 00864 00865 int 00866 nc_get_var_short(int ncid, int varid, short *ip) 00867 { 00868 NC* ncp; 00869 int stat = NC_check_id(ncid, &ncp); 00870 if(stat != NC_NOERR) return stat; 00871 return NC_get_var(ncid, varid, (void *)ip, NC_SHORT); 00872 } 00873 00874 int 00875 nc_get_var_int(int ncid, int varid, int *ip) 00876 { 00877 NC* ncp; 00878 int stat = NC_check_id(ncid, &ncp); 00879 if(stat != NC_NOERR) return stat; 00880 return NC_get_var(ncid,varid, (void *)ip, NC_INT); 00881 } 00882 00883 int 00884 nc_get_var_long(int ncid, int varid, long *ip) 00885 { 00886 NC* ncp; 00887 int stat = NC_check_id(ncid, &ncp); 00888 if(stat != NC_NOERR) return stat; 00889 return NC_get_var(ncid,varid, (void *)ip, longtype); 00890 } 00891 00892 int 00893 nc_get_var_float(int ncid, int varid, float *ip) 00894 { 00895 NC* ncp; 00896 int stat = NC_check_id(ncid, &ncp); 00897 if(stat != NC_NOERR) return stat; 00898 return NC_get_var(ncid,varid, (void *)ip, NC_FLOAT); 00899 } 00900 00901 int 00902 nc_get_var_double(int ncid, int varid, double *ip) 00903 { 00904 NC* ncp; 00905 int stat = NC_check_id(ncid, &ncp); 00906 if(stat != NC_NOERR) return stat; 00907 return NC_get_var(ncid,varid, (void *)ip, NC_DOUBLE); 00908 } 00909 00910 int 00911 nc_get_var_ubyte(int ncid, int varid, unsigned char *ip) 00912 { 00913 NC* ncp; 00914 int stat = NC_check_id(ncid, &ncp); 00915 if(stat != NC_NOERR) return stat; 00916 return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE); 00917 } 00918 00919 int 00920 nc_get_var_ushort(int ncid, int varid, unsigned short *ip) 00921 { 00922 NC* ncp; 00923 int stat = NC_check_id(ncid, &ncp); 00924 if(stat != NC_NOERR) return stat; 00925 return NC_get_var(ncid,varid, (void *)ip, NC_USHORT); 00926 } 00927 00928 int 00929 nc_get_var_uint(int ncid, int varid, unsigned int *ip) 00930 { 00931 NC* ncp; 00932 int stat = NC_check_id(ncid, &ncp); 00933 if(stat != NC_NOERR) return stat; 00934 return NC_get_var(ncid,varid, (void *)ip, NC_UINT); 00935 } 00936 00937 int 00938 nc_get_var_longlong(int ncid, int varid, long long *ip) 00939 { 00940 NC* ncp; 00941 int stat = NC_check_id(ncid, &ncp); 00942 if(stat != NC_NOERR) return stat; 00943 return NC_get_var(ncid,varid, (void *)ip, NC_INT64); 00944 } 00945 00946 int 00947 nc_get_var_ulonglong(int ncid, int varid, unsigned long long *ip) 00948 { 00949 NC* ncp; 00950 int stat = NC_check_id(ncid, &ncp); 00951 if(stat != NC_NOERR) return stat; 00952 return NC_get_var(ncid,varid, (void *)ip,NC_UINT64); 00953 } 00954 00955 #ifdef USE_NETCDF4 00956 int 00957 nc_get_var_string(int ncid, int varid, char* *ip) 00958 { 00959 NC* ncp; 00960 int stat = NC_check_id(ncid, &ncp); 00961 if(stat != NC_NOERR) return stat; 00962 return NC_get_var(ncid,varid, (void *)ip,NC_STRING); 00963 } 00964 #endif /*USE_NETCDF4*/ 00965 01007 int 01008 nc_get_vars (int ncid, int varid, const size_t * startp, 01009 const size_t * countp, const ptrdiff_t * stridep, 01010 void *ip) 01011 { 01012 NC* ncp; 01013 int stat = NC_NOERR; 01014 01015 if ((stat = NC_check_id(ncid, &ncp))) 01016 return stat; 01017 return ncp->dispatch->get_vars(ncid, varid, startp, countp, stridep, 01018 ip, NC_NAT); 01019 } 01020 01021 int 01022 nc_get_vars_text(int ncid, int varid, const size_t *startp, 01023 const size_t *countp, const ptrdiff_t * stridep, 01024 char *ip) 01025 { 01026 NC* ncp; 01027 int stat = NC_check_id(ncid, &ncp); 01028 if(stat != NC_NOERR) return stat; 01029 return NC_get_vars(ncid,varid,startp, countp, stridep, 01030 (void *)ip, NC_CHAR); 01031 } 01032 01033 int 01034 nc_get_vars_schar(int ncid, int varid, const size_t *startp, 01035 const size_t *countp, const ptrdiff_t * stridep, 01036 signed char *ip) 01037 { 01038 NC* ncp; 01039 int stat = NC_check_id(ncid, &ncp); 01040 if(stat != NC_NOERR) return stat; 01041 return NC_get_vars(ncid,varid,startp, countp, stridep, 01042 (void *)ip, NC_BYTE); 01043 } 01044 01045 int 01046 nc_get_vars_uchar(int ncid, int varid, const size_t *startp, 01047 const size_t *countp, const ptrdiff_t * stridep, 01048 unsigned char *ip) 01049 { 01050 NC* ncp; 01051 int stat = NC_check_id(ncid, &ncp); 01052 if(stat != NC_NOERR) return stat; 01053 return NC_get_vars(ncid,varid,startp, countp, stridep, 01054 (void *)ip, T_uchar); 01055 } 01056 01057 int 01058 nc_get_vars_short(int ncid, int varid, const size_t *startp, 01059 const size_t *countp, const ptrdiff_t *stridep, 01060 short *ip) 01061 { 01062 NC* ncp; 01063 int stat = NC_check_id(ncid, &ncp); 01064 if(stat != NC_NOERR) return stat; 01065 return NC_get_vars(ncid,varid,startp, countp, stridep, 01066 (void *)ip, NC_SHORT); 01067 } 01068 01069 int 01070 nc_get_vars_int(int ncid, int varid, const size_t *startp, 01071 const size_t *countp, const ptrdiff_t * stridep, 01072 int *ip) 01073 { 01074 NC* ncp; 01075 int stat = NC_check_id(ncid, &ncp); 01076 if(stat != NC_NOERR) return stat; 01077 return NC_get_vars(ncid,varid,startp, countp, stridep, 01078 (void *)ip, NC_INT); 01079 } 01080 01081 int 01082 nc_get_vars_long(int ncid, int varid, const size_t *startp, 01083 const size_t *countp, const ptrdiff_t * stridep, 01084 long *ip) 01085 { 01086 NC* ncp; 01087 int stat = NC_check_id(ncid, &ncp); 01088 if(stat != NC_NOERR) return stat; 01089 return NC_get_vars(ncid,varid,startp, countp, stridep, 01090 (void *)ip, T_long); 01091 } 01092 01093 int 01094 nc_get_vars_float(int ncid, int varid, const size_t *startp, 01095 const size_t *countp, const ptrdiff_t * stridep, 01096 float *ip) 01097 { 01098 NC* ncp; 01099 int stat = NC_check_id(ncid, &ncp); 01100 if(stat != NC_NOERR) return stat; 01101 return NC_get_vars(ncid,varid,startp, countp, stridep, 01102 (void *)ip, T_float); 01103 } 01104 01105 int 01106 nc_get_vars_double(int ncid, int varid, const size_t *startp, 01107 const size_t *countp, const ptrdiff_t * stridep, 01108 double *ip) 01109 { 01110 NC* ncp; 01111 int stat = NC_check_id(ncid, &ncp); 01112 if(stat != NC_NOERR) return stat; 01113 return NC_get_vars(ncid,varid,startp, countp, stridep, 01114 (void *)ip, T_double); 01115 } 01116 01117 int 01118 nc_get_vars_ubyte(int ncid, int varid, const size_t *startp, 01119 const size_t *countp, const ptrdiff_t * stridep, 01120 unsigned char *ip) 01121 { 01122 NC* ncp; 01123 int stat = NC_check_id(ncid, &ncp); 01124 if(stat != NC_NOERR) return stat; 01125 return NC_get_vars(ncid,varid, startp, countp, stridep, 01126 (void *)ip, T_ubyte); 01127 } 01128 01129 int 01130 nc_get_vars_ushort(int ncid, int varid, const size_t *startp, 01131 const size_t *countp, const ptrdiff_t * stridep, 01132 unsigned short *ip) 01133 { 01134 NC* ncp; 01135 int stat = NC_check_id(ncid, &ncp); 01136 if(stat != NC_NOERR) return stat; 01137 return NC_get_vars(ncid,varid,startp,countp, stridep, 01138 (void *)ip, T_ushort); 01139 } 01140 01141 int 01142 nc_get_vars_uint(int ncid, int varid, const size_t *startp, 01143 const size_t *countp, const ptrdiff_t * stridep, 01144 unsigned int *ip) 01145 { 01146 NC* ncp; 01147 int stat = NC_check_id(ncid, &ncp); 01148 if(stat != NC_NOERR) return stat; 01149 return NC_get_vars(ncid,varid,startp, countp, stridep, 01150 (void *)ip, T_uint); 01151 } 01152 01153 int 01154 nc_get_vars_longlong(int ncid, int varid, const size_t *startp, 01155 const size_t *countp, const ptrdiff_t * stridep, 01156 long long *ip) 01157 { 01158 NC* ncp; 01159 int stat = NC_check_id(ncid, &ncp); 01160 if(stat != NC_NOERR) return stat; 01161 return NC_get_vars(ncid, varid, startp, countp, stridep, 01162 (void *)ip, T_longlong); 01163 } 01164 01165 int 01166 nc_get_vars_ulonglong(int ncid, int varid, const size_t *startp, 01167 const size_t *countp, const ptrdiff_t * stridep, 01168 unsigned long long *ip) 01169 { 01170 NC* ncp; 01171 int stat = NC_check_id(ncid, &ncp); 01172 if(stat != NC_NOERR) return stat; 01173 return NC_get_vars(ncid, varid, startp, countp, stridep, 01174 (void *)ip, NC_UINT64); 01175 } 01176 01177 #ifdef USE_NETCDF4 01178 int 01179 nc_get_vars_string(int ncid, int varid, 01180 const size_t *startp, const size_t *countp, 01181 const ptrdiff_t * stridep, 01182 char* *ip) 01183 { 01184 NC* ncp; 01185 int stat = NC_check_id(ncid, &ncp); 01186 if(stat != NC_NOERR) return stat; 01187 return NC_get_vars(ncid, varid, startp, countp, stridep, 01188 (void *)ip, NC_STRING); 01189 } 01190 #endif /*USE_NETCDF4*/ 01191 01242 int 01243 nc_get_varm(int ncid, int varid, const size_t * startp, 01244 const size_t * countp, const ptrdiff_t * stridep, 01245 const ptrdiff_t * imapp, void *ip) 01246 { 01247 NC* ncp; 01248 int stat = NC_NOERR; 01249 01250 if ((stat = NC_check_id(ncid, &ncp))) 01251 return stat; 01252 return ncp->dispatch->get_varm(ncid, varid, startp, countp, 01253 stridep, imapp, ip, NC_NAT); 01254 } 01255 01256 int 01257 nc_get_varm_schar(int ncid, int varid, 01258 const size_t *startp, const size_t *countp, 01259 const ptrdiff_t *stridep, 01260 const ptrdiff_t *imapp, signed char *ip) 01261 { 01262 NC *ncp; 01263 int stat = NC_check_id(ncid, &ncp); 01264 if(stat != NC_NOERR) return stat; 01265 return NC_get_varm(ncid, varid, startp, countp, 01266 stridep, imapp, (void *)ip, NC_BYTE); 01267 } 01268 01269 int 01270 nc_get_varm_uchar(int ncid, int varid, 01271 const size_t *startp, const size_t *countp, 01272 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01273 unsigned char *ip) 01274 { 01275 NC *ncp; 01276 int stat = NC_check_id(ncid, &ncp); 01277 if(stat != NC_NOERR) return stat; 01278 return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_uchar); 01279 } 01280 01281 int 01282 nc_get_varm_short(int ncid, int varid, const size_t *startp, 01283 const size_t *countp, const ptrdiff_t *stridep, 01284 const ptrdiff_t *imapp, short *ip) 01285 { 01286 NC *ncp; 01287 int stat = NC_check_id(ncid, &ncp); 01288 if(stat != NC_NOERR) return stat; 01289 return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_SHORT); 01290 } 01291 01292 int 01293 nc_get_varm_int(int ncid, int varid, 01294 const size_t *startp, const size_t *countp, 01295 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01296 int *ip) 01297 { 01298 NC *ncp; 01299 int stat = NC_check_id(ncid, &ncp); 01300 if(stat != NC_NOERR) return stat; 01301 return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_INT); 01302 } 01303 01304 int 01305 nc_get_varm_long(int ncid, int varid, 01306 const size_t *startp, const size_t *countp, 01307 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01308 long *ip) 01309 { 01310 NC *ncp; 01311 int stat = NC_check_id(ncid, &ncp); 01312 if(stat != NC_NOERR) return stat; 01313 return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_long); 01314 } 01315 01316 int 01317 nc_get_varm_float(int ncid, int varid, 01318 const size_t *startp, const size_t *countp, 01319 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01320 float *ip) 01321 { 01322 NC *ncp; 01323 int stat = NC_check_id(ncid, &ncp); 01324 if(stat != NC_NOERR) return stat; 01325 return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_float); 01326 } 01327 01328 int 01329 nc_get_varm_double(int ncid, int varid, 01330 const size_t *startp, const size_t *countp, 01331 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01332 double *ip) 01333 { 01334 NC *ncp; 01335 int stat = NC_check_id(ncid, &ncp); 01336 if(stat != NC_NOERR) return stat; 01337 return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_double); 01338 } 01339 01340 int 01341 nc_get_varm_ubyte(int ncid, int varid, 01342 const size_t *startp, const size_t *countp, 01343 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01344 unsigned char *ip) 01345 { 01346 NC *ncp; 01347 int stat = NC_check_id(ncid, &ncp); 01348 if(stat != NC_NOERR) return stat; 01349 return NC_get_varm(ncid,varid,startp,countp,stridep, 01350 imapp, (void *)ip, T_ubyte); 01351 } 01352 01353 int 01354 nc_get_varm_ushort(int ncid, int varid, 01355 const size_t *startp, const size_t *countp, 01356 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01357 unsigned short *ip) 01358 { 01359 NC *ncp; 01360 int stat = NC_check_id(ncid, &ncp); 01361 if(stat != NC_NOERR) return stat; 01362 return NC_get_varm(ncid, varid, startp, countp, stridep, 01363 imapp, (void *)ip, T_ushort); 01364 } 01365 01366 int 01367 nc_get_varm_uint(int ncid, int varid, 01368 const size_t *startp, const size_t *countp, 01369 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01370 unsigned int *ip) 01371 { 01372 NC *ncp; 01373 int stat = NC_check_id(ncid, &ncp); 01374 if(stat != NC_NOERR) return stat; 01375 return NC_get_varm(ncid, varid, startp, countp, 01376 stridep, imapp, (void *)ip, T_uint); 01377 } 01378 01379 int 01380 nc_get_varm_longlong(int ncid, int varid, const size_t *startp, 01381 const size_t *countp, const ptrdiff_t *stridep, 01382 const ptrdiff_t *imapp, long long *ip) 01383 { 01384 NC *ncp; 01385 int stat = NC_check_id(ncid, &ncp); 01386 if(stat != NC_NOERR) return stat; 01387 return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, 01388 (void *)ip, T_longlong); 01389 } 01390 01391 int 01392 nc_get_varm_ulonglong(int ncid, int varid, 01393 const size_t *startp, const size_t *countp, 01394 const ptrdiff_t *stridep, const ptrdiff_t *imapp, 01395 unsigned long long *ip) 01396 { 01397 NC *ncp; 01398 int stat = NC_check_id(ncid, &ncp); 01399 if(stat != NC_NOERR) return stat; 01400 return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, 01401 (void *)ip, NC_UINT64); 01402 } 01403 01404 int 01405 nc_get_varm_text(int ncid, int varid, const size_t *startp, 01406 const size_t *countp, const ptrdiff_t *stridep, 01407 const ptrdiff_t *imapp, char *ip) 01408 { 01409 NC *ncp; 01410 int stat = NC_check_id(ncid, &ncp); 01411 if(stat != NC_NOERR) return stat; 01412 return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, 01413 (void *)ip, NC_CHAR); 01414 } 01415 01416 #ifdef USE_NETCDF4 01417 int 01418 nc_get_varm_string(int ncid, int varid, const size_t *startp, 01419 const size_t *countp, const ptrdiff_t *stridep, 01420 const ptrdiff_t *imapp, char **ip) 01421 { 01422 NC *ncp; 01423 int stat = NC_check_id(ncid, &ncp); 01424 if(stat != NC_NOERR) return stat; 01425 return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, 01426 (void *)ip, NC_STRING); 01427 } 01429 #endif /*USE_NETCDF4*/ 01430 /* End of named group... */ 01432