00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "collection.h"
00010 #include "reNetcdf.h"
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 int
00043 msiNcOpen (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam,
00044 ruleExecInfo_t *rei)
00045 {
00046 rsComm_t *rsComm;
00047 ncOpenInp_t ncOpenInp;
00048 int *ncid;
00049
00050 RE_TEST_MACRO (" Calling msiNcOpen")
00051
00052 if (rei == NULL || rei->rsComm == NULL) {
00053 rodsLog (LOG_ERROR,
00054 "msiNcOpen: input rei or rsComm is NULL");
00055 return (SYS_INTERNAL_NULL_INPUT_ERR);
00056 }
00057
00058 rsComm = rei->rsComm;
00059 if (inpParam1 == NULL) {
00060 rodsLog (LOG_ERROR,
00061 "msiNcOpen: input inpParam1 is NULL");
00062 return (SYS_INTERNAL_NULL_INPUT_ERR);
00063 }
00064
00065 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
00066
00067 bzero (&ncOpenInp, sizeof (ncOpenInp));
00068 rstrcpy (ncOpenInp.objPath, (char*)inpParam1->inOutStruct,
00069 MAX_NAME_LEN);
00070 } else if (strcmp (inpParam1->type, NcOpenInp_MS_T) == 0) {
00071 ncOpenInp = *((ncOpenInp_t *) inpParam1->inOutStruct);
00072 replKeyVal (&((ncOpenInp_t *) inpParam1->inOutStruct)->condInput,
00073 &ncOpenInp.condInput);
00074 } else {
00075 rodsLog (LOG_ERROR,
00076 "msiNcOpen: Unsupported input Param1 type %s",
00077 inpParam1->type);
00078 return (USER_PARAM_TYPE_ERR);
00079 }
00080 if (inpParam2 != NULL) {
00081
00082 ncOpenInp.mode = parseMspForPosInt (inpParam2);
00083 if (ncOpenInp.mode < 0) return (ncOpenInp.mode);
00084 }
00085
00086 rei->status = rsNcOpen (rsComm, &ncOpenInp, &ncid);
00087 clearKeyVal (&ncOpenInp.condInput);
00088 if (rei->status >= 0) {
00089 fillIntInMsParam (outParam, *ncid);
00090 free (ncid);
00091 } else {
00092 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00093 "msiNcOpen: rsNcOpen failed for %s, status = %d",
00094 ncOpenInp.objPath, rei->status);
00095 }
00096
00097 return (rei->status);
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 int
00131 msiNcCreate (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam,
00132 ruleExecInfo_t *rei)
00133 {
00134 rsComm_t *rsComm;
00135 ncOpenInp_t ncOpenInp;
00136 int *ncid;
00137
00138 RE_TEST_MACRO (" Calling msiNcCreate")
00139
00140 if (rei == NULL || rei->rsComm == NULL) {
00141 rodsLog (LOG_ERROR,
00142 "msiNcCreate: input rei or rsComm is NULL");
00143 return (SYS_INTERNAL_NULL_INPUT_ERR);
00144 }
00145
00146 rsComm = rei->rsComm;
00147 if (inpParam1 == NULL) {
00148 rodsLog (LOG_ERROR,
00149 "msiNcCreate: input inpParam1 is NULL");
00150 return (SYS_INTERNAL_NULL_INPUT_ERR);
00151 }
00152
00153 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
00154
00155 bzero (&ncOpenInp, sizeof (ncOpenInp));
00156 rstrcpy (ncOpenInp.objPath, (char*)inpParam1->inOutStruct,
00157 MAX_NAME_LEN);
00158 } else if (strcmp (inpParam1->type, NcOpenInp_MS_T) == 0) {
00159 ncOpenInp = *((ncOpenInp_t *) inpParam1->inOutStruct);
00160 replKeyVal (&((ncOpenInp_t *) inpParam1->inOutStruct)->condInput,
00161 &ncOpenInp.condInput);
00162 } else {
00163 rodsLog (LOG_ERROR,
00164 "msiNcOpen: Unsupported input Param1 type %s",
00165 inpParam1->type);
00166 return (USER_PARAM_TYPE_ERR);
00167 }
00168 if (inpParam2 != NULL) {
00169
00170 ncOpenInp.mode = parseMspForPosInt (inpParam2);
00171 if (ncOpenInp.mode < 0) return (ncOpenInp.mode);
00172 }
00173
00174 rei->status = rsNcCreate (rsComm, &ncOpenInp, &ncid);
00175 clearKeyVal (&ncOpenInp.condInput);
00176 if (rei->status >= 0) {
00177 fillIntInMsParam (outParam, *ncid);
00178 free (ncid);
00179 } else {
00180 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00181 "msiNcCreate: rsNcCreate failed for %s, status = %d",
00182 ncOpenInp.objPath, rei->status);
00183 }
00184
00185 return (rei->status);
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 int
00218 msiNcClose (msParam_t *inpParam1, ruleExecInfo_t *rei)
00219 {
00220 rsComm_t *rsComm;
00221 ncCloseInp_t ncCloseInp;
00222
00223 RE_TEST_MACRO (" Calling msiNcClose")
00224
00225 if (rei == NULL || rei->rsComm == NULL) {
00226 rodsLog (LOG_ERROR,
00227 "msiNcClose: input rei or rsComm is NULL");
00228 return (SYS_INTERNAL_NULL_INPUT_ERR);
00229 }
00230 rsComm = rei->rsComm;
00231 if (inpParam1 == NULL) {
00232 rodsLog (LOG_ERROR,
00233 "msiNcClose: input inpParam1 is NULL");
00234 return (SYS_INTERNAL_NULL_INPUT_ERR);
00235 }
00236
00237 if (strcmp (inpParam1->type, INT_MS_T) == 0) {
00238
00239 bzero (&ncCloseInp, sizeof (ncCloseInp));
00240 ncCloseInp.ncid = *((int*) inpParam1->inOutStruct);
00241 } else if (strcmp (inpParam1->type, NcCloseInp_MS_T) == 0) {
00242 ncCloseInp = *((ncCloseInp_t *) inpParam1->inOutStruct);
00243 replKeyVal (&((ncCloseInp_t *) inpParam1->inOutStruct)->condInput,
00244 &ncCloseInp.condInput);
00245 } else {
00246 rodsLog (LOG_ERROR,
00247 "msiNcClose: Unsupported input Param1 type %s",
00248 inpParam1->type);
00249 return (USER_PARAM_TYPE_ERR);
00250 }
00251
00252 rei->status = rsNcClose (rsComm, &ncCloseInp);
00253 clearKeyVal (&ncCloseInp.condInput);
00254 if (rei->status < 0) {
00255 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00256 "msiNcClose: rsNcClose failed for %d, status = %d",
00257 ncCloseInp.ncid, rei->status);
00258 }
00259
00260 return (rei->status);
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 int
00292 msiNcInqId (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3,
00293 msParam_t *outParam, ruleExecInfo_t *rei)
00294 {
00295 rsComm_t *rsComm;
00296 ncInqIdInp_t ncInqIdInp;
00297 int *outId;
00298
00299 RE_TEST_MACRO (" Calling msiNcInqId")
00300
00301 if (rei == NULL || rei->rsComm == NULL) {
00302 rodsLog (LOG_ERROR,
00303 "msiNcInqId: input rei or rsComm is NULL");
00304 return (SYS_INTERNAL_NULL_INPUT_ERR);
00305 }
00306 rsComm = rei->rsComm;
00307
00308 if (inpParam1 == NULL) {
00309 rodsLog (LOG_ERROR,
00310 "msiNcInqId: input inpParam1 is NULL");
00311 return (SYS_INTERNAL_NULL_INPUT_ERR);
00312 }
00313
00314
00315 rei->status = parseMspForNcInqIdInpName (inpParam1, &ncInqIdInp);
00316
00317 if (rei->status < 0) return rei->status;
00318
00319 if (inpParam2 != NULL) {
00320
00321 ncInqIdInp.paramType = parseMspForPosInt (inpParam2);
00322 if (ncInqIdInp.paramType != NC_VAR_T &&
00323 ncInqIdInp.paramType != NC_DIM_T) {
00324 rodsLog (LOG_ERROR,
00325 "msiNcInqId: Unknow paramType %d for %s ",
00326 ncInqIdInp.paramType, ncInqIdInp.name);
00327 return (NETCDF_INVALID_PARAM_TYPE);
00328 }
00329 }
00330
00331 if (inpParam3 != NULL) {
00332
00333 ncInqIdInp.ncid = parseMspForPosInt (inpParam3);
00334 }
00335
00336 rei->status = rsNcInqId (rsComm, &ncInqIdInp, &outId);
00337 clearKeyVal (&ncInqIdInp.condInput);
00338 if (rei->status >= 0) {
00339 fillIntInMsParam (outParam, *outId);
00340 free (outId);
00341 } else {
00342 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00343 "msiNcInqId: rsNcInqId failed for %s, status = %d",
00344 ncInqIdInp.name, rei->status);
00345 }
00346
00347 return (rei->status);
00348 }
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 int
00387 msiNcInqWithId (msParam_t *inpParam1, msParam_t *inpParam2,
00388 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
00389 {
00390 rsComm_t *rsComm;
00391 ncInqIdInp_t ncInqWithIdInp;
00392 ncInqWithIdOut_t *ncInqWithIdOut = NULL;
00393
00394 RE_TEST_MACRO (" Calling msiNcInqWithId")
00395
00396 if (rei == NULL || rei->rsComm == NULL) {
00397 rodsLog (LOG_ERROR,
00398 "msiNcInqWithId: input rei or rsComm is NULL");
00399 return (SYS_INTERNAL_NULL_INPUT_ERR);
00400 }
00401 rsComm = rei->rsComm;
00402
00403 if (inpParam1 == NULL) {
00404 rodsLog (LOG_ERROR,
00405 "msiNcInqWithId: input inpParam1 is NULL");
00406 return (SYS_INTERNAL_NULL_INPUT_ERR);
00407 }
00408
00409
00410 rei->status = parseMspForNcInqIdInpId (inpParam1, &ncInqWithIdInp);
00411
00412 if (rei->status < 0) return rei->status;
00413
00414 if (inpParam2 != NULL) {
00415
00416 ncInqWithIdInp.paramType = parseMspForPosInt (inpParam2);
00417 if (ncInqWithIdInp.paramType != NC_VAR_T &&
00418 ncInqWithIdInp.paramType != NC_DIM_T) {
00419 rodsLog (LOG_ERROR,
00420 "msiNcInqWithId: Unknow paramType %d for %s ",
00421 ncInqWithIdInp.paramType, ncInqWithIdInp.name);
00422 return (NETCDF_INVALID_PARAM_TYPE);
00423 }
00424 }
00425
00426 if (inpParam3 != NULL) {
00427
00428 ncInqWithIdInp.ncid = parseMspForPosInt (inpParam3);
00429 }
00430
00431 rei->status = rsNcInqWithId (rsComm, &ncInqWithIdInp, &ncInqWithIdOut);
00432 clearKeyVal (&ncInqWithIdInp.condInput);
00433 if (rei->status >= 0) {
00434 fillMsParam (outParam, NULL, NcInqWithIdOut_MS_T, ncInqWithIdOut, NULL);
00435 } else {
00436 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00437 "msiNcInqWithId: rsNcInqWithId failed for %s, status = %d",
00438 ncInqWithIdInp.name, rei->status);
00439 }
00440
00441 return (rei->status);
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 int
00475 msiNcGetVarsByType (msParam_t *dataTypeParam, msParam_t *ncidParam,
00476 msParam_t *varidParam, msParam_t *ndimParam, msParam_t *startParam,
00477 msParam_t *countParam, msParam_t *strideParam,
00478 msParam_t *outParam, ruleExecInfo_t *rei)
00479 {
00480 rsComm_t *rsComm;
00481 ncGetVarInp_t ncGetVarInp;
00482 ncGetVarOut_t *ncGetVarOut = NULL;
00483 int ndimOut;
00484
00485 RE_TEST_MACRO (" Calling msiNcGetVarsByType")
00486
00487 if (rei == NULL || rei->rsComm == NULL) {
00488 rodsLog (LOG_ERROR,
00489 "msiNcGetVarsByType: input rei or rsComm is NULL");
00490 return (SYS_INTERNAL_NULL_INPUT_ERR);
00491 }
00492 rsComm = rei->rsComm;
00493
00494 if (dataTypeParam == NULL) {
00495 rodsLog (LOG_ERROR,
00496 "msiNcGetVarsByType: input dataTypeParam is NULL");
00497 return (SYS_INTERNAL_NULL_INPUT_ERR);
00498 }
00499
00500
00501 rei->status = parseMspForNcGetVarInp (dataTypeParam, &ncGetVarInp);
00502
00503 if (rei->status < 0) return rei->status;
00504
00505 if (ncidParam != NULL) {
00506
00507 ncGetVarInp.ncid = parseMspForPosInt (ncidParam);
00508 if (ncGetVarInp.ncid < 0) return ncGetVarInp.ncid;
00509 }
00510
00511 if (varidParam != NULL) {
00512
00513 ncGetVarInp.varid = parseMspForPosInt (varidParam);
00514 if (ncGetVarInp.varid < 0) return ncGetVarInp.varid;
00515 }
00516
00517 if (ndimParam != NULL) {
00518
00519 ncGetVarInp.ndim = parseMspForPosInt (ndimParam);
00520 if (ncGetVarInp.ndim < 0) return ncGetVarInp.ndim;
00521 }
00522
00523 if (startParam != NULL) {
00524
00525 rei->status = parseStrMspForLongArray (startParam, &ndimOut,
00526 &ncGetVarInp.start);
00527 if (rei->status < 0) return rei->status;
00528 if (ndimOut != ncGetVarInp.ndim) {
00529 rei->status = NETCDF_DIM_MISMATCH_ERR;
00530 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00531 "msiNcGetVarsByType: start dim = %d, input ndim = %d",
00532 ndimOut, ncGetVarInp.ndim);
00533 return NETCDF_DIM_MISMATCH_ERR;
00534 }
00535 }
00536
00537 if (countParam != NULL) {
00538
00539 rei->status = parseStrMspForLongArray (countParam, &ndimOut,
00540 &ncGetVarInp.count);
00541 if (rei->status < 0) return rei->status;
00542 if (ndimOut != ncGetVarInp.ndim) {
00543 rei->status = NETCDF_DIM_MISMATCH_ERR;
00544 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00545 "msiNcGetVarsByType: count dim = %d, input ndim = %d",
00546 ndimOut, ncGetVarInp.ndim);
00547 return NETCDF_DIM_MISMATCH_ERR;
00548 }
00549 }
00550
00551 if (strideParam != NULL) {
00552
00553 rei->status = parseStrMspForLongArray (strideParam, &ndimOut,
00554 &ncGetVarInp.stride);
00555 if (rei->status < 0) return rei->status;
00556 if (ndimOut != ncGetVarInp.ndim) {
00557 rei->status = NETCDF_DIM_MISMATCH_ERR;
00558 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00559 "msiNcGetVarsByType: stride dim = %d, input ndim = %d",
00560 ndimOut, ncGetVarInp.ndim);
00561 return NETCDF_DIM_MISMATCH_ERR;
00562 }
00563 }
00564
00565 rei->status = rsNcGetVarsByType (rsComm, &ncGetVarInp, &ncGetVarOut);
00566 clearNcGetVarInp (&ncGetVarInp);
00567 if (rei->status >= 0) {
00568 fillMsParam (outParam, NULL, NcGetVarOut_MS_T, ncGetVarOut, NULL);
00569 } else {
00570 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00571 "msiNcGetVarsByType: rsNcGetVarsByType failed, status = %d",
00572 rei->status);
00573 }
00574
00575 return (rei->status);
00576 }
00577
00578 #ifdef LIB_CF
00579
00580
00581
00582
00583
00584 int
00585 msiNccfGetVara (msParam_t *ncidParam, msParam_t *varidParam,
00586 msParam_t *lvlIndexParam, msParam_t *timestepParam,
00587 msParam_t *latRange0Param, msParam_t *latRange1Param,
00588 msParam_t *lonRange0Param, msParam_t *lonRange1Param,
00589 msParam_t *maxOutArrayLenParam, msParam_t *outParam, ruleExecInfo_t *rei)
00590 {
00591 rsComm_t *rsComm;
00592 nccfGetVarInp_t nccfGetVarInp;
00593 nccfGetVarOut_t *nccfGetVarOut = NULL;
00594
00595 RE_TEST_MACRO (" Calling msiNccfGetVara")
00596
00597 if (rei == NULL || rei->rsComm == NULL) {
00598 rodsLog (LOG_ERROR,
00599 "msiNccfGetVara: input rei or rsComm is NULL");
00600 return (SYS_INTERNAL_NULL_INPUT_ERR);
00601 }
00602 rsComm = rei->rsComm;
00603
00604 if (ncidParam == NULL) {
00605 rodsLog (LOG_ERROR,
00606 "msiNccfGetVara: input ncidParam is NULL");
00607 return (SYS_INTERNAL_NULL_INPUT_ERR);
00608 }
00609
00610
00611 rei->status = parseMspForNccfGetVarInp (ncidParam, &nccfGetVarInp);
00612
00613 if (rei->status < 0) return rei->status;
00614
00615 if (varidParam != NULL) {
00616
00617 nccfGetVarInp.varid = parseMspForPosInt (varidParam);
00618 if (nccfGetVarInp.varid < 0) return nccfGetVarInp.varid;
00619 }
00620
00621 if (lvlIndexParam != NULL) {
00622
00623 nccfGetVarInp.lvlIndex = parseMspForPosInt (lvlIndexParam);
00624 if (nccfGetVarInp.lvlIndex < 0) return nccfGetVarInp.lvlIndex;
00625 }
00626
00627 if (timestepParam != NULL) {
00628
00629 nccfGetVarInp.timestep = parseMspForPosInt (timestepParam);
00630 if (nccfGetVarInp.timestep < 0) return nccfGetVarInp.timestep;
00631 }
00632
00633 if (latRange0Param != NULL) {
00634 rei->status = parseMspForFloat (latRange0Param,
00635 &nccfGetVarInp.latRange[0]);
00636 if (rei->status < 0) return rei->status;
00637 }
00638
00639 if (latRange1Param != NULL) {
00640 rei->status = parseMspForFloat (latRange1Param,
00641 &nccfGetVarInp.latRange[1]);
00642 if (rei->status < 0) return rei->status;
00643 }
00644
00645 if (lonRange0Param != NULL) {
00646 rei->status = parseMspForFloat (lonRange0Param,
00647 &nccfGetVarInp.lonRange[0]);
00648 if (rei->status < 0) return rei->status;
00649 }
00650
00651 if (lonRange1Param != NULL) {
00652 rei->status = parseMspForFloat (lonRange1Param,
00653 &nccfGetVarInp.lonRange[1]);
00654 if (rei->status < 0) return rei->status;
00655 }
00656
00657 if (maxOutArrayLenParam != NULL) {
00658
00659 nccfGetVarInp.maxOutArrayLen = parseMspForPosInt (maxOutArrayLenParam);
00660 if (nccfGetVarInp.maxOutArrayLen < 0)
00661 return nccfGetVarInp.maxOutArrayLen;
00662 }
00663
00664 rei->status = rsNccfGetVara (rsComm, &nccfGetVarInp, &nccfGetVarOut);
00665 clearKeyVal (&nccfGetVarInp.condInput);
00666 if (rei->status >= 0) {
00667 fillMsParam (outParam, NULL, NccfGetVarOut_MS_T, nccfGetVarOut, NULL);
00668 } else {
00669 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00670 "msiNccfGetVara: rsNccfGetVara failed, status = %d",
00671 rei->status);
00672 }
00673
00674 return (rei->status);
00675 }
00676 #endif
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705 int
00706 msiNcGetArrayLen (msParam_t *inpParam, msParam_t *outParam,
00707 ruleExecInfo_t *rei)
00708 {
00709 #if 0
00710 rodsLong_t arrayLen;
00711 #endif
00712 int arrayLen;
00713
00714 RE_TEST_MACRO (" Calling msiNcGetArrayLen")
00715
00716 if (inpParam == NULL || outParam == NULL) return USER__NULL_INPUT_ERR;
00717
00718 if (strcmp (inpParam->type, NcInqWithIdOut_MS_T) == 0) {
00719 ncInqWithIdOut_t *ncInqWithIdOut;
00720 ncInqWithIdOut = (ncInqWithIdOut_t *) inpParam->inOutStruct;
00721 arrayLen = ncInqWithIdOut->mylong;
00722 } else if (strcmp (inpParam->type, NcGetVarOut_MS_T) == 0) {
00723 ncGetVarOut_t *ncGetVarOut;
00724 ncGetVarOut = (ncGetVarOut_t *) inpParam->inOutStruct;
00725 if (ncGetVarOut == NULL || ncGetVarOut->dataArray == NULL)
00726 return USER__NULL_INPUT_ERR;
00727 arrayLen = ncGetVarOut->dataArray->len;
00728 } else if (strcmp (inpParam->type, NccfGetVarOut_MS_T) == 0) {
00729 nccfGetVarOut_t *nccfGetVarOut;
00730 nccfGetVarOut = (nccfGetVarOut_t *) inpParam->inOutStruct;
00731 if (nccfGetVarOut == NULL || nccfGetVarOut->dataArray == NULL)
00732 return USER__NULL_INPUT_ERR;
00733 arrayLen = nccfGetVarOut->dataArray->len;
00734 } else {
00735 rodsLog (LOG_ERROR,
00736 "msiNcGetArrayLen: Unsupported input Param type %s",
00737 inpParam->type);
00738 return (USER_PARAM_TYPE_ERR);
00739 }
00740 fillIntInMsParam (outParam, arrayLen);
00741 return 0;
00742 }
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771 int
00772 msiNcGetNumDim (msParam_t *inpParam, msParam_t *outParam,
00773 ruleExecInfo_t *rei)
00774 {
00775 int ndim;
00776
00777 RE_TEST_MACRO (" Calling msiNcGetNumDim")
00778
00779 if (inpParam == NULL || outParam == NULL) return USER__NULL_INPUT_ERR;
00780
00781 if (strcmp (inpParam->type, NcInqWithIdOut_MS_T) == 0) {
00782 ncInqWithIdOut_t *ncInqWithIdOut;
00783 ncInqWithIdOut = (ncInqWithIdOut_t *) inpParam->inOutStruct;
00784 ndim = ncInqWithIdOut->ndim;
00785 } else if (strcmp (inpParam->type, NcGetVarInp_MS_T) == 0) {
00786 ncGetVarInp_t *ncGetVarInp;
00787 ncGetVarInp = (ncGetVarInp_t *) inpParam->inOutStruct;
00788 ndim = ncGetVarInp->ndim;
00789 } else {
00790 rodsLog (LOG_ERROR,
00791 "msiNcGetNumDim: Unsupported input Param type %s",
00792 inpParam->type);
00793 return (USER_PARAM_TYPE_ERR);
00794 }
00795 fillIntInMsParam (outParam, ndim);
00796 return 0;
00797 }
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826 int
00827 msiNcGetDataType (msParam_t *inpParam, msParam_t *outParam,
00828 ruleExecInfo_t *rei)
00829 {
00830 int dataType;
00831
00832 RE_TEST_MACRO (" Calling msiNcGetDataType")
00833
00834 if (inpParam == NULL || outParam == NULL) return USER__NULL_INPUT_ERR;
00835
00836 if (strcmp (inpParam->type, NcInqWithIdOut_MS_T) == 0) {
00837 ncInqWithIdOut_t *ncInqWithIdOut;
00838 ncInqWithIdOut = (ncInqWithIdOut_t *) inpParam->inOutStruct;
00839 dataType = ncInqWithIdOut->dataType;
00840 } else if (strcmp (inpParam->type, NcGetVarInp_MS_T) == 0) {
00841 ncGetVarInp_t *ncGetVarInp;
00842 ncGetVarInp = (ncGetVarInp_t *) inpParam->inOutStruct;
00843 dataType = ncGetVarInp->dataType;
00844 } else if (strcmp (inpParam->type, NcGetVarOut_MS_T) == 0) {
00845 ncGetVarOut_t *ncGetVarOut;
00846 ncGetVarOut = (ncGetVarOut_t *) inpParam->inOutStruct;
00847 if (ncGetVarOut == NULL || ncGetVarOut->dataArray == NULL)
00848 return USER__NULL_INPUT_ERR;
00849 dataType = ncGetVarOut->dataArray->type;
00850 } else if (strcmp (inpParam->type, NccfGetVarOut_MS_T) == 0) {
00851 nccfGetVarOut_t *nccfGetVarOut;
00852 nccfGetVarOut = (nccfGetVarOut_t *) inpParam->inOutStruct;
00853 if (nccfGetVarOut == NULL || nccfGetVarOut->dataArray == NULL)
00854 return USER__NULL_INPUT_ERR;
00855 dataType = nccfGetVarOut->dataArray->type;
00856 } else {
00857 rodsLog (LOG_ERROR,
00858 "msiNcGetNumDim: Unsupported input Param type %s",
00859 inpParam->type);
00860 return (USER_PARAM_TYPE_ERR);
00861 }
00862 fillIntInMsParam (outParam, dataType);
00863 return 0;
00864 }
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893 int
00894 msiNcGetElementInArray (msParam_t *arrayStructParam, msParam_t *indexParam,
00895 msParam_t *outParam, ruleExecInfo_t *rei)
00896 {
00897 int myindex;
00898 void *myarray;
00899 int dataType;
00900 int arrayLen;
00901 char *charArray;
00902 int *intArray;
00903 float *floatArray;
00904 rodsLong_t *longArray;
00905 char **strArray;
00906
00907 RE_TEST_MACRO (" Calling msiNcGetElementInArray")
00908
00909 if (arrayStructParam == NULL || indexParam == NULL ||
00910 outParam == NULL) return USER__NULL_INPUT_ERR;
00911
00912 if (strcmp (arrayStructParam->type, NcInqWithIdOut_MS_T) == 0) {
00913
00914 ncInqWithIdOut_t *ncInqWithIdOut;
00915 ncInqWithIdOut = (ncInqWithIdOut_t *) arrayStructParam->inOutStruct;
00916 dataType = NC_INT;
00917 myarray = (void *) ncInqWithIdOut->intArray;
00918 arrayLen = ncInqWithIdOut->ndim;
00919 } else if (strcmp (arrayStructParam->type, NcGetVarOut_MS_T) == 0) {
00920 ncGetVarOut_t *ncGetVarOut;
00921 ncGetVarOut = (ncGetVarOut_t *) arrayStructParam->inOutStruct;
00922 if (ncGetVarOut == NULL || ncGetVarOut->dataArray == NULL)
00923 return USER__NULL_INPUT_ERR;
00924 dataType = ncGetVarOut->dataArray->type;
00925 myarray = ncGetVarOut->dataArray->buf;
00926 arrayLen = ncGetVarOut->dataArray->len;
00927 } else if (strcmp (arrayStructParam->type, NccfGetVarOut_MS_T) == 0) {
00928 nccfGetVarOut_t *nccfGetVarOut;
00929 nccfGetVarOut = (nccfGetVarOut_t *) arrayStructParam->inOutStruct;
00930 if (nccfGetVarOut == NULL || nccfGetVarOut->dataArray == NULL)
00931 return USER__NULL_INPUT_ERR;
00932 dataType = nccfGetVarOut->dataArray->type;
00933 myarray = nccfGetVarOut->dataArray->buf;
00934 arrayLen = nccfGetVarOut->dataArray->len;
00935 } else {
00936 rodsLog (LOG_ERROR,
00937 "msiNcGetNumDim: Unsupported input Param type %s",
00938 arrayStructParam->type);
00939 return (USER_PARAM_TYPE_ERR);
00940 }
00941 myindex = parseMspForPosInt (indexParam);
00942 if (myindex < 0 || myindex >= arrayLen) {
00943 rodsLog (LOG_ERROR,
00944 "msiNcGetElementInArray: input index %d out of range. arrayLen = %d",
00945 myindex, arrayLen);
00946 return (NETCDF_DIM_MISMATCH_ERR);
00947 }
00948
00949 switch (dataType) {
00950 case NC_CHAR:
00951 case NC_BYTE:
00952 case NC_UBYTE:
00953 charArray = (char *) myarray;
00954 fillCharInMsParam (outParam, charArray[myindex]);
00955 break;
00956 case NC_STRING:
00957 strArray = (char **) myarray;
00958 fillStrInMsParam (outParam, strArray[myindex]);
00959 break;
00960 case NC_INT:
00961 case NC_UINT:
00962 intArray = (int *) myarray;
00963 fillIntInMsParam (outParam, intArray[myindex]);
00964 break;
00965 case NC_FLOAT:
00966 floatArray = (float *) myarray;
00967 fillFloatInMsParam (outParam, floatArray[myindex]);
00968 break;
00969 case NC_INT64:
00970 case NC_UINT64:
00971 case NC_DOUBLE:
00972 longArray = (rodsLong_t *) myarray;
00973 fillDoubleInMsParam (outParam, longArray[myindex]);
00974 break;
00975 default:
00976 rodsLog (LOG_ERROR,
00977 "msiNcGetElementInArray: Unknow dataType %d", dataType);
00978 return (NETCDF_INVALID_DATA_TYPE);
00979 }
00980 return 0;
00981 }
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010 int
01011 msiFloatToString (msParam_t *floatParam, msParam_t *stringParam,
01012 ruleExecInfo_t *rei)
01013 {
01014 char floatStr[NAME_LEN];
01015 float *myfloat;
01016
01017 RE_TEST_MACRO (" Calling msiFloatToString")
01018
01019 if (floatParam == NULL || stringParam == NULL) return USER__NULL_INPUT_ERR;
01020
01021 if (strcmp (floatParam->type, FLOAT_MS_T) != 0) {
01022 rodsLog (LOG_ERROR,
01023 "msiFloatToString: floatParam type %s error", floatParam->type);
01024 return USER_PARAM_TYPE_ERR;
01025 }
01026 myfloat = (float *) floatParam->inOutStruct;
01027 snprintf (floatStr, NAME_LEN, "%f", *myfloat);
01028 fillStrInMsParam (stringParam, floatStr);
01029
01030 return 0;
01031 }
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060 int
01061 msiNcInq (msParam_t *ncidParam, msParam_t *outParam, ruleExecInfo_t *rei)
01062 {
01063 rsComm_t *rsComm;
01064 ncInqInp_t ncInqInp;
01065 ncInqOut_t *ncInqOut = NULL;;
01066
01067 RE_TEST_MACRO (" Calling msiNcInq")
01068
01069 if (rei == NULL || rei->rsComm == NULL) {
01070 rodsLog (LOG_ERROR,
01071 "msiNcInq: input rei or rsComm is NULL");
01072 return (SYS_INTERNAL_NULL_INPUT_ERR);
01073 }
01074 rsComm = rei->rsComm;
01075
01076 if (ncidParam == NULL) {
01077 rodsLog (LOG_ERROR,
01078 "msiNcInq: input ncidParam is NULL");
01079 return (SYS_INTERNAL_NULL_INPUT_ERR);
01080 }
01081 bzero (&ncInqInp, sizeof (ncInqInp));
01082
01083 ncInqInp.ncid = parseMspForPosInt (ncidParam);
01084
01085 rei->status = rsNcInq (rsComm, &ncInqInp, &ncInqOut);
01086
01087 clearKeyVal (&ncInqInp.condInput);
01088 if (rei->status >= 0) {
01089 fillMsParam (outParam, NULL, NcInqOut_MS_T, ncInqOut, NULL);
01090 } else {
01091 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01092 "msiNcInq: rsNcInq failed for ncid %d, status = %d",
01093 ncInqInp.ncid, rei->status);
01094 }
01095
01096 return (rei->status);
01097 }
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128 int
01129 msiNcGetNdimsInInqOut (msParam_t *ncInqOutParam, msParam_t *varNameParam,
01130 msParam_t *outParam, ruleExecInfo_t *rei)
01131 {
01132 int ndims = -1;
01133 ncInqOut_t *ncInqOut;
01134 char *name;
01135
01136 RE_TEST_MACRO (" Calling msiNcGetNdimInInqOut")
01137
01138 if (ncInqOutParam == NULL || varNameParam == NULL || outParam == NULL)
01139 return USER__NULL_INPUT_ERR;
01140
01141 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01142 rodsLog (LOG_ERROR,
01143 "msiNcGetNdimsInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01144 ncInqOutParam->type);
01145 return (USER_PARAM_TYPE_ERR);
01146 } else {
01147 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01148 }
01149 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
01150 rodsLog (LOG_ERROR,
01151 "msiNcGetNdimsInInqOut: varNameParam must be STR_MS_T. %s",
01152 varNameParam->type);
01153 return (USER_PARAM_TYPE_ERR);
01154 } else {
01155 name = (char*) varNameParam->inOutStruct;
01156 }
01157
01158 if (strcmp (name, "null") == 0) {
01159
01160 ndims = ncInqOut->ndims;
01161 } else {
01162 int i;
01163
01164 for (i = 0; i < ncInqOut->nvars; i++) {
01165 if (strcmp (ncInqOut->var[i].name, name) == 0) {
01166 ndims = ncInqOut->var[i].nvdims;
01167 break;
01168 }
01169 }
01170 if (ndims < 0) {
01171 rodsLog (LOG_ERROR,
01172 "msiNcGetNdimInInqOut: Unmatch variable name %s.", name);
01173 return NETCDF_UNMATCHED_NAME_ERR;
01174 }
01175 }
01176 fillIntInMsParam (outParam, ndims);
01177
01178 return 0;
01179 }
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210 int
01211 msiNcGetNattsInInqOut (msParam_t *ncInqOutParam, msParam_t *varNameParam,
01212 msParam_t *outParam, ruleExecInfo_t *rei)
01213 {
01214 int natts = -1;
01215 ncInqOut_t *ncInqOut;
01216 char *name;
01217
01218 RE_TEST_MACRO (" Calling msiNcGetNattsInInqOut")
01219
01220 if (ncInqOutParam == NULL || varNameParam == NULL || outParam == NULL)
01221 return USER__NULL_INPUT_ERR;
01222
01223 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01224 rodsLog (LOG_ERROR,
01225 "msiNcGetNattsInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01226 ncInqOutParam->type);
01227 return (USER_PARAM_TYPE_ERR);
01228 } else {
01229 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01230 }
01231 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
01232 rodsLog (LOG_ERROR,
01233 "msiNcGetNattsInInqOut: varNameParam must be STR_MS_T. %s",
01234 varNameParam->type);
01235 return (USER_PARAM_TYPE_ERR);
01236 } else {
01237 name = (char*) varNameParam->inOutStruct;
01238 }
01239
01240 if (strcmp (name, "null") == 0) {
01241
01242 natts = ncInqOut->ngatts;
01243 } else {
01244 int i;
01245
01246 for (i = 0; i < ncInqOut->nvars; i++) {
01247 if (strcmp (ncInqOut->var[i].name, name) == 0) {
01248 natts = ncInqOut->var[i].natts;
01249 break;
01250 }
01251 }
01252 if (natts < 0) {
01253 rodsLog (LOG_ERROR,
01254 "msiNcGetNdimInInqOut: Unmatch variable name %s.", name);
01255 return NETCDF_UNMATCHED_NAME_ERR;
01256 }
01257 }
01258 fillIntInMsParam (outParam, natts);
01259
01260 return 0;
01261 }
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291 int
01292 msiNcGetNvarsInInqOut (msParam_t *ncInqOutParam, msParam_t *outParam,
01293 ruleExecInfo_t *rei)
01294 {
01295 ncInqOut_t *ncInqOut;
01296
01297 RE_TEST_MACRO (" Calling msiNcGetNvarsInInqOut")
01298
01299 if (ncInqOutParam == NULL || outParam == NULL)
01300 return USER__NULL_INPUT_ERR;
01301
01302 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01303 rodsLog (LOG_ERROR,
01304 "msiNcGetNattsInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01305 ncInqOutParam->type);
01306 return (USER_PARAM_TYPE_ERR);
01307 } else {
01308 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01309 }
01310
01311
01312 fillIntInMsParam (outParam, ncInqOut->nvars);
01313
01314 return 0;
01315 }
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345 int
01346 msiNcGetFormatInInqOut (msParam_t *ncInqOutParam, msParam_t *outParam,
01347 ruleExecInfo_t *rei)
01348 {
01349 ncInqOut_t *ncInqOut;
01350
01351 RE_TEST_MACRO (" Calling msiNcGetFormatInInqOut")
01352
01353 if (ncInqOutParam == NULL || outParam == NULL)
01354 return USER__NULL_INPUT_ERR;
01355
01356 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01357 rodsLog (LOG_ERROR,
01358 "msiNcGetFormatInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01359 ncInqOutParam->type);
01360 return (USER_PARAM_TYPE_ERR);
01361 } else {
01362 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01363 }
01364
01365
01366 fillIntInMsParam (outParam, ncInqOut->format);
01367
01368 return 0;
01369 }
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400 int
01401 msiNcGetVarNameInInqOut (msParam_t *ncInqOutParam, msParam_t *inxParam,
01402 msParam_t *outParam, ruleExecInfo_t *rei)
01403 {
01404 ncInqOut_t *ncInqOut;
01405 int inx;
01406
01407 RE_TEST_MACRO (" Calling msiNcGetVarNameInInqOut")
01408
01409 if (ncInqOutParam == NULL || inxParam == NULL || outParam == NULL)
01410 return USER__NULL_INPUT_ERR;
01411
01412 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01413 rodsLog (LOG_ERROR,
01414 "msiNcGetVarNameInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01415 ncInqOutParam->type);
01416 return (USER_PARAM_TYPE_ERR);
01417 } else {
01418 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01419 }
01420 inx = parseMspForPosInt (inxParam);
01421 if (inx < 0 || inx >= ncInqOut->nvars) {
01422 rodsLog (LOG_ERROR,
01423 "msiNcGetVarNameInInqOut: input inx %d is out of range. nvars = %d",
01424 inx, ncInqOut->nvars);
01425 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01426 }
01427
01428
01429 fillStrInMsParam (outParam, ncInqOut->var[inx].name);
01430
01431 return 0;
01432 }
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463 int
01464 msiNcGetVarIdInInqOut (msParam_t *ncInqOutParam, msParam_t *whichVarParam,
01465 msParam_t *outParam, ruleExecInfo_t *rei)
01466 {
01467 ncInqOut_t *ncInqOut;
01468 int inx;
01469 char *varName;
01470 int id = -1;
01471
01472 RE_TEST_MACRO (" msiNcGetVarIdInInqOut msiNcGetVarNameInInqOut")
01473
01474 if (ncInqOutParam == NULL || whichVarParam == NULL || outParam == NULL)
01475 return USER__NULL_INPUT_ERR;
01476
01477 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01478 rodsLog (LOG_ERROR,
01479 "msiNcGetVarIdInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01480 ncInqOutParam->type);
01481 return (USER_PARAM_TYPE_ERR);
01482 } else {
01483 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01484 }
01485
01486 if (strcmp (whichVarParam->type, STR_MS_T) == 0) {
01487 varName = (char *)whichVarParam->inOutStruct;
01488 inx = -1;
01489 } else if (strcmp (whichVarParam->type, INT_MS_T) == 0) {
01490 inx = *((int *) whichVarParam->inOutStruct);
01491 varName = NULL;
01492 } else {
01493 rodsLog (LOG_ERROR,
01494 "msiNcGetVarIdInInqOut:whichVarParam must be INT_MS_T/STR_MS_T. %s",
01495 whichVarParam->type);
01496 return (USER_PARAM_TYPE_ERR);
01497 }
01498
01499 if (varName == NULL) {
01500 if (inx < 0 || inx >= ncInqOut->nvars) {
01501 rodsLog (LOG_ERROR,
01502 "msiNcGetVarIdInInqOut:inp inx %d out of range. nvars=%d",
01503 inx, ncInqOut->nvars);
01504 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01505 }
01506 id = ncInqOut->var[inx].id;
01507 } else {
01508
01509 int i;
01510 for (i = 0; i < ncInqOut->nvars; i++) {
01511 if (strcmp (varName, ncInqOut->var[i].name) == 0) {
01512 id = ncInqOut->var[i].id;
01513 break;
01514 }
01515 }
01516 if (id < 0) {
01517 rodsLog (LOG_ERROR,
01518 "msiNcGetVarIdInInqOut: unmatched varName %s", varName);
01519 return NETCDF_UNMATCHED_NAME_ERR;
01520 }
01521 }
01522 fillIntInMsParam (outParam, id);
01523
01524 return 0;
01525 }
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557 int
01558 msiNcGetDimNameInInqOut (msParam_t *ncInqOutParam, msParam_t *inxParam,
01559 msParam_t *varNameParam, msParam_t *outParam, ruleExecInfo_t *rei)
01560 {
01561 ncInqOut_t *ncInqOut;
01562 int inx, i;
01563 char *name = NULL;
01564
01565 RE_TEST_MACRO (" Calling msiNcGetDimNameInInqOut")
01566
01567 if (ncInqOutParam == NULL || inxParam == NULL || outParam == NULL)
01568 return USER__NULL_INPUT_ERR;
01569
01570 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01571 rodsLog (LOG_ERROR,
01572 "msiNcGetDimNameInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01573 ncInqOutParam->type);
01574 return (USER_PARAM_TYPE_ERR);
01575 } else {
01576 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01577 }
01578 inx = parseMspForPosInt (inxParam);
01579 if (inx < UNLIMITED_DIM_INX || inx >= ncInqOut->ndims) {
01580 rodsLog (LOG_ERROR,
01581 "msiNcGetDimNameInInqOut: input inx %d is out of range. ndims = %d",
01582 inx, ncInqOut->ndims);
01583 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01584 }
01585
01586 if (inx == UNLIMITED_DIM_INX) {
01587
01588 if (ncInqOut->unlimdimid < 0) return NETCDF_NO_UNLIMITED_DIM;
01589 for (i = 0; i < ncInqOut->ndims; i++) {
01590 if (ncInqOut->unlimdimid == ncInqOut->dim[i].id) {
01591 name = ncInqOut->dim[i].name;
01592 break;
01593 }
01594 }
01595 if (name == NULL) {
01596 rodsLog (LOG_ERROR,
01597 "msiNcGetDimNameInInqOut: no match for unlimdimid %d",
01598 ncInqOut->unlimdimid);
01599 return NETCDF_NO_UNLIMITED_DIM;
01600 }
01601 } else {
01602 char *varName;
01603 if (varNameParam == NULL) return USER__NULL_INPUT_ERR;
01604 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
01605 rodsLog (LOG_ERROR,
01606 "msiNcGetDimNameInInqOut: nameParam must be STR_MS_T. %s",
01607 varNameParam->type);
01608 return (USER_PARAM_TYPE_ERR);
01609 } else {
01610 varName = (char*) varNameParam->inOutStruct;
01611 }
01612 if (strcmp (varName, "null") == 0) {
01613
01614 name = ncInqOut->dim[inx].name;
01615 } else {
01616
01617 for (i = 0; i < ncInqOut->nvars; i++) {
01618 int dimId, j;
01619 if (strcmp (varName, ncInqOut->var[i].name) == 0) {
01620
01621 dimId = ncInqOut->var[i].dimId[inx];
01622
01623 for (j = 0; j < ncInqOut->ndims; j++) {
01624 if (ncInqOut->dim[j].id == dimId) {
01625 name = ncInqOut->dim[j].name;
01626 break;
01627 }
01628 }
01629 }
01630 }
01631 if (name == NULL) {
01632 rodsLog (LOG_ERROR,
01633 "msiNcGetDimNameInInqOut: unmatched varName %s and ix %d",
01634 varName, inx);
01635 return NETCDF_UNMATCHED_NAME_ERR;
01636 }
01637 }
01638 }
01639 fillStrInMsParam (outParam, name);
01640
01641 return 0;
01642 }
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673 int
01674 msiNcGetDimLenInInqOut (msParam_t *ncInqOutParam, msParam_t *inxParam,
01675 msParam_t *varNameParam, msParam_t *outParam, ruleExecInfo_t *rei)
01676 {
01677 ncInqOut_t *ncInqOut;
01678 int inx, i;
01679 int arrayLen = -1;
01680
01681 RE_TEST_MACRO (" Calling msiNcGetDimLenInInqOut")
01682
01683 if (ncInqOutParam == NULL || inxParam == NULL || outParam == NULL)
01684 return USER__NULL_INPUT_ERR;
01685
01686 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01687 rodsLog (LOG_ERROR,
01688 "msiNcGetDimLenInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01689 ncInqOutParam->type);
01690 return (USER_PARAM_TYPE_ERR);
01691 } else {
01692 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01693 }
01694 inx = parseMspForPosInt (inxParam);
01695 if (inx < UNLIMITED_DIM_INX || inx >= ncInqOut->nvars) {
01696 rodsLog (LOG_ERROR,
01697 "msiNcGetDimLenInInqOut: input inx %d is out of range. nvars = %d",
01698 inx, ncInqOut->nvars);
01699 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01700 }
01701
01702 if (inx == UNLIMITED_DIM_INX) {
01703
01704 if (ncInqOut->unlimdimid < 0) return NETCDF_NO_UNLIMITED_DIM;
01705 for (i = 0; i < ncInqOut->ndims; i++) {
01706 if (ncInqOut->unlimdimid == ncInqOut->dim[i].id) {
01707 arrayLen = ncInqOut->dim[i].arrayLen;
01708 break;
01709 }
01710 }
01711 if (arrayLen == -1) {
01712 rodsLog (LOG_ERROR,
01713 "msiNcGetDimLenInInqOut: no match for unlimdimid %d",
01714 ncInqOut->unlimdimid);
01715 return NETCDF_NO_UNLIMITED_DIM;
01716 }
01717 } else {
01718 char *varName;
01719 if (varNameParam == NULL) return USER__NULL_INPUT_ERR;
01720 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
01721 rodsLog (LOG_ERROR,
01722 "msiNcGetDimLenInInqOut: nameParam must be STR_MS_T. %s",
01723 varNameParam->type);
01724 return (USER_PARAM_TYPE_ERR);
01725 } else {
01726 varName = (char*) varNameParam->inOutStruct;
01727 }
01728 if (strcmp (varName, "null") == 0) {
01729
01730 arrayLen = ncInqOut->dim[inx].arrayLen;
01731 } else {
01732
01733 for (i = 0; i < ncInqOut->nvars; i++) {
01734 int dimId, j;
01735 if (strcmp (varName, ncInqOut->var[i].name) == 0) {
01736
01737 dimId = ncInqOut->var[i].dimId[inx];
01738
01739 for (j = 0; j < ncInqOut->ndims; j++) {
01740 if (ncInqOut->dim[j].id == dimId) {
01741 arrayLen = ncInqOut->dim[j].arrayLen;
01742 break;
01743 }
01744 }
01745 }
01746 }
01747 if (arrayLen == -1) {
01748 rodsLog (LOG_ERROR,
01749 "msiNcGetDimLenInInqOut: unmatched varName %s and ix %d",
01750 varName, inx);
01751 return NETCDF_UNMATCHED_NAME_ERR;
01752 }
01753 }
01754 }
01755 fillIntInMsParam (outParam, arrayLen);
01756
01757 return 0;
01758 }
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790 int
01791 msiNcGetAttNameInInqOut (msParam_t *ncInqOutParam, msParam_t *inxParam,
01792 msParam_t *varNameParam, msParam_t *outParam, ruleExecInfo_t *rei)
01793 {
01794 ncInqOut_t *ncInqOut;
01795 int inx, i;
01796 char *varName;
01797 char *name = NULL;
01798
01799 RE_TEST_MACRO (" Calling msiNcGetAttNameInInqOut")
01800
01801 if (ncInqOutParam == NULL || inxParam == NULL || outParam == NULL)
01802 return USER__NULL_INPUT_ERR;
01803
01804 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01805 rodsLog (LOG_ERROR,
01806 "msiNcGetAttNameInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01807 ncInqOutParam->type);
01808 return (USER_PARAM_TYPE_ERR);
01809 } else {
01810 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01811 }
01812 inx = parseMspForPosInt (inxParam);
01813
01814 if (varNameParam == NULL) return USER__NULL_INPUT_ERR;
01815
01816 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
01817 rodsLog (LOG_ERROR,
01818 "msiNcGetAttNameInInqOut: nameParam must be STR_MS_T. %s",
01819 varNameParam->type);
01820 return (USER_PARAM_TYPE_ERR);
01821 } else {
01822 varName = (char*) varNameParam->inOutStruct;
01823 }
01824
01825 if (strcmp (varName, "null") == 0) {
01826
01827 if (inx < 0 || inx >= ncInqOut->ngatts) {
01828 rodsLog (LOG_ERROR,
01829 "msiNcGetAttNameInInqOut: input inx %d out of range. ngatts = %d",
01830 inx, ncInqOut->ngatts);
01831 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01832 }
01833 name = ncInqOut->gatt[inx].name;
01834 } else {
01835
01836 for (i = 0; i < ncInqOut->nvars; i++) {
01837 if (strcmp (varName, ncInqOut->var[i].name) == 0) {
01838
01839 break;
01840 }
01841 }
01842 if (i >= ncInqOut->nvars) {
01843 rodsLog (LOG_ERROR,
01844 "msiNcGetAttNameInInqOut: unmatched varName %s", varName);
01845 return NETCDF_UNMATCHED_NAME_ERR;
01846 }
01847 if (inx < 0 || inx >= ncInqOut->var[i].natts) {
01848 rodsLog (LOG_ERROR,
01849 "msiNcGetAttNameInInqOut: input inx %d out of range. natts = %d",
01850 inx, ncInqOut->var[i].natts);
01851 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01852 }
01853 name = ncInqOut->var[i].att[inx].name;
01854 }
01855 fillStrInMsParam (outParam, name);
01856
01857 return 0;
01858 }
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890 int
01891 msiNcGetAttValStrInInqOut (msParam_t *ncInqOutParam, msParam_t *whichAttParam,
01892 msParam_t *varNameParam, msParam_t *outParam, ruleExecInfo_t *rei)
01893 {
01894 int status;
01895 ncGetVarOut_t *value = NULL;
01896 char tempStr[NAME_LEN];
01897 void *bufPtr;
01898
01899 RE_TEST_MACRO (" Calling msiNcGetAttValStrInInqOut")
01900 status = _msiNcGetAttValInInqOut (ncInqOutParam, whichAttParam,
01901 varNameParam, &value);
01902
01903 if (status < 0) return status;
01904
01905 bufPtr = value->dataArray->buf;
01906 if (value->dataArray->type == NC_CHAR && value->dataArray->len > 0) {
01907
01908 status = ncValueToStr (NC_STRING, &bufPtr, tempStr);
01909 } else {
01910 status = ncValueToStr (value->dataArray->type, &bufPtr, tempStr);
01911 }
01912 if (status < 0) return status;
01913
01914 fillStrInMsParam (outParam, tempStr);
01915
01916 return status;
01917 }
01918
01919 int
01920 _msiNcGetAttValInInqOut (msParam_t *ncInqOutParam, msParam_t *whichAttParam,
01921 msParam_t *varNameParam, ncGetVarOut_t **ncGetVarOut)
01922 {
01923 ncInqOut_t *ncInqOut;
01924 int i;
01925 int inx;
01926 char *varName, *attName;
01927 ncGetVarOut_t *value = NULL;
01928
01929 if (ncInqOutParam == NULL || whichAttParam == NULL || ncGetVarOut == NULL)
01930 return USER__NULL_INPUT_ERR;
01931
01932 *ncGetVarOut = NULL;
01933
01934 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
01935 rodsLog (LOG_ERROR,
01936 "_msiNcGetAttValInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
01937 ncInqOutParam->type);
01938 return (USER_PARAM_TYPE_ERR);
01939 } else {
01940 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
01941 }
01942
01943 if (strcmp (whichAttParam->type, STR_MS_T) == 0) {
01944 attName = (char *)whichAttParam->inOutStruct;
01945 inx = -1;
01946 } else if (strcmp (whichAttParam->type, INT_MS_T) == 0) {
01947 inx = *((int *) whichAttParam->inOutStruct);
01948 attName = NULL;
01949 } else {
01950 rodsLog (LOG_ERROR,
01951 "_msiNcGetAttValInInqOut:whichAttParam must be INT_MS_T/STR_MS_T. %s",
01952 whichAttParam->type);
01953 return (USER_PARAM_TYPE_ERR);
01954 }
01955 if (varNameParam == NULL) return USER__NULL_INPUT_ERR;
01956
01957 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
01958 rodsLog (LOG_ERROR,
01959 "_msiNcGetAttValInInqOut: varNameParam must be STR_MS_T. %s",
01960 varNameParam->type);
01961 return (USER_PARAM_TYPE_ERR);
01962 } else {
01963 varName = (char*) varNameParam->inOutStruct;
01964 }
01965
01966 if (strcmp (varName, "null") == 0) {
01967
01968 if (attName == NULL) {
01969 if (inx < 0 || inx >= ncInqOut->ngatts) {
01970 rodsLog (LOG_ERROR,
01971 "_msiNcGetAttValInInqOut:inp inx %d out of range. ngatts=%d",
01972 inx, ncInqOut->ngatts);
01973 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
01974 }
01975 value = &ncInqOut->gatt[inx].value;
01976 } else {
01977
01978 for (i = 0; i < ncInqOut->ngatts; i++) {
01979 if (strcmp (attName, ncInqOut->gatt[i].name) == 0) {
01980 value = &ncInqOut->gatt[i].value;
01981 break;
01982 }
01983 }
01984 if (value == NULL) {
01985 rodsLog (LOG_ERROR,
01986 "_msiNcGetAttValInInqOut: unmatched attName %s", attName);
01987 return NETCDF_UNMATCHED_NAME_ERR;
01988 }
01989 }
01990 } else {
01991
01992 for (i = 0; i < ncInqOut->nvars; i++) {
01993 if (strcmp (varName, ncInqOut->var[i].name) == 0) {
01994
01995 break;
01996 }
01997 }
01998 if (i >= ncInqOut->nvars) {
01999 rodsLog (LOG_ERROR,
02000 "_msiNcGetAttValInInqOut: unmatched varName %s", varName);
02001 return NETCDF_UNMATCHED_NAME_ERR;
02002 }
02003 if (attName == NULL) {
02004 if (inx < 0 || inx >= ncInqOut->var[i].natts) {
02005 rodsLog (LOG_ERROR,
02006 "_msiNcGetAttNameInInqOut:inp inx %d out of range. natts=%d",
02007 inx, ncInqOut->var[i].natts);
02008 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
02009 }
02010 value = &ncInqOut->var[i].att[inx].value;
02011 } else {
02012
02013 int j;
02014 for (j = 0; j < ncInqOut->ngatts; j++) {
02015 if (strcmp (attName, ncInqOut->var[i].att[j].name) == 0) {
02016 value = &ncInqOut->var[i].att[j].value;
02017 break;
02018 }
02019 }
02020 if (value == NULL) {
02021 rodsLog (LOG_ERROR,
02022 "_msiNcGetAttValInInqOut: unmatched attName %s", attName);
02023 return NETCDF_UNMATCHED_NAME_ERR;
02024 }
02025 }
02026 }
02027 *ncGetVarOut = value;
02028
02029 return 0;
02030 }
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061 int
02062 msiNcGetVarTypeInInqOut (msParam_t *ncInqOutParam, msParam_t *varNameParam,
02063 msParam_t *outParam, ruleExecInfo_t *rei)
02064 {
02065 ncInqOut_t *ncInqOut;
02066 int i;
02067 char *varName;
02068
02069 RE_TEST_MACRO (" Calling msiNcGetVarTypeInInqOut")
02070
02071 if (ncInqOutParam == NULL || outParam == NULL || varNameParam == NULL)
02072 return USER__NULL_INPUT_ERR;
02073
02074 if (strcmp (ncInqOutParam->type, NcInqOut_MS_T) != 0) {
02075 rodsLog (LOG_ERROR,
02076 "msiNcGetVarTypeInInqOut: ncInqOutParam must be NcInqOut_MS_T. %s",
02077 ncInqOutParam->type);
02078 return (USER_PARAM_TYPE_ERR);
02079 } else {
02080 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
02081 }
02082
02083 if (strcmp (varNameParam->type, STR_MS_T) != 0) {
02084 rodsLog (LOG_ERROR,
02085 "msiNcGetAttNameInInqOut: nameParam must be STR_MS_T. %s",
02086 varNameParam->type);
02087 return (USER_PARAM_TYPE_ERR);
02088 } else {
02089 varName = (char*) varNameParam->inOutStruct;
02090 }
02091
02092
02093 for (i = 0; i < ncInqOut->nvars; i++) {
02094 if (strcmp (varName, ncInqOut->var[i].name) == 0) {
02095
02096 break;
02097 }
02098 }
02099 if (i >= ncInqOut->nvars) {
02100 rodsLog (LOG_ERROR,
02101 "msiNcGetAttNameInInqOut: unmatched varName %s", varName);
02102 return NETCDF_UNMATCHED_NAME_ERR;
02103 }
02104 fillIntInMsParam (outParam, ncInqOut->var[i].dataType);
02105
02106 return 0;
02107 }
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137 int
02138 msiNcIntDataTypeToStr (msParam_t *dataTypeParam, msParam_t *outParam,
02139 ruleExecInfo_t *rei)
02140 {
02141 int dataType;
02142 char dataTypeStr[NAME_LEN];
02143 int status;
02144
02145 RE_TEST_MACRO (" Calling msiNcIntDataTypeToStr")
02146
02147 if (dataTypeParam == NULL || outParam == NULL) return USER__NULL_INPUT_ERR;
02148
02149 if (strcmp (dataTypeParam->type, INT_MS_T) != 0) {
02150 rodsLog (LOG_ERROR,
02151 "msiNcIntDataTypeToStr: Unsupported input dataTypeParam type %s",
02152 dataTypeParam->type);
02153 return (USER_PARAM_TYPE_ERR);
02154 }
02155
02156 dataType = *((int *) dataTypeParam->inOutStruct);
02157
02158 if ((status = getNcTypeStr (dataType, dataTypeStr)) < 0) return status;
02159
02160 fillStrInMsParam (outParam, dataTypeStr);
02161
02162 return 0;
02163 }
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194 int
02195 msiAddToNcArray (msParam_t *elementParam, msParam_t *inxParam,
02196 msParam_t *ncArrayParam, ruleExecInfo_t *rei)
02197 {
02198 ncGetVarOut_t *ncArray;
02199 int inx;
02200
02201 RE_TEST_MACRO (" Calling msiAddToNcArray")
02202
02203 if (elementParam == NULL || ncArrayParam == NULL)
02204 return USER__NULL_INPUT_ERR;
02205
02206 inx = parseMspForPosInt (inxParam);
02207 if (inx < 0 || inx >= NC_MAX_DIMS) {
02208 rodsLog (LOG_ERROR,
02209 "msiAddToNcArray: input inx %d is out of range. max = %d",
02210 inx, NC_MAX_DIMS);
02211 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
02212 }
02213
02214 if (strcmp (elementParam->type, INT_MS_T) == 0) {
02215 int *intArray;
02216
02217 if (ncArrayParam->inOutStruct == NULL) {
02218
02219 ncArray = (ncGetVarOut_t *) calloc (1, sizeof (ncGetVarOut_t));
02220 ncArray->dataArray = (dataArray_t *)
02221 calloc (1, sizeof (dataArray_t));
02222 ncArray->dataArray->type = NC_INT;
02223 rstrcpy (ncArray->dataType_PI, "intDataArray_PI", NAME_LEN);
02224 ncArray->dataArray->buf = calloc (1, sizeof (int) * NC_MAX_DIMS);
02225 fillMsParam (ncArrayParam, NULL, NcGetVarOut_MS_T, ncArray, NULL);
02226 } else {
02227 ncArray = (ncGetVarOut_t *) ncArrayParam->inOutStruct;
02228 if (strcmp (ncArray->dataType_PI, "intDataArray_PI") != 0) {
02229 rodsLog (LOG_ERROR,
02230 "msiAddToNcArray: wrong dataType_PI for INT_MS_T %s",
02231 ncArray->dataType_PI);
02232 return (USER_PARAM_TYPE_ERR);
02233 }
02234 }
02235 intArray = (int *) ncArray->dataArray->buf;
02236 intArray[inx] = *((int *) elementParam->inOutStruct);
02237 if (ncArray->dataArray->len < inx + 1)
02238 ncArray->dataArray->len = inx + 1;
02239 } else {
02240
02241 rodsLog (LOG_ERROR,
02242 "msiAddToNcArray: Unsupported input dataTypeParam type %s",
02243 elementParam->type);
02244 return (USER_PARAM_TYPE_ERR);
02245 }
02246 return 0;
02247 }
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276 int
02277 msiFreeNcStruct (msParam_t *inpParam, ruleExecInfo_t *rei)
02278 {
02279 ncGetVarOut_t *ncArray;
02280
02281 RE_TEST_MACRO (" Calling msiFreeNcStruct")
02282
02283 if (inpParam == NULL) return USER__NULL_INPUT_ERR;
02284
02285 if (strcmp (inpParam->type, NcGetVarOut_MS_T) == 0) {
02286 ncArray = (ncGetVarOut_t *) inpParam->inOutStruct;
02287 if (ncArray != NULL) {
02288 freeNcGetVarOut (&ncArray);
02289 inpParam->inOutStruct = NULL;
02290 }
02291 } else {
02292 rodsLog (LOG_ERROR,
02293 "msiFreeNcStruct: inpParam must be NcGetVarOut_MS_T. %s",
02294 inpParam->type);
02295 return (USER_PARAM_TYPE_ERR);
02296 }
02297
02298 return 0;
02299 }
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330 int
02331 msiNcInqGrps (msParam_t *ncidParam, msParam_t *outParam, ruleExecInfo_t *rei)
02332 {
02333 #ifdef NETCDF4_API
02334 rsComm_t *rsComm;
02335 ncInqGrpsInp_t ncInqGrpsInp;
02336 ncInqGrpsOut_t *ncInqGrpsOut = NULL;
02337
02338 RE_TEST_MACRO (" Calling msiNcInqGrps")
02339
02340 if (rei == NULL || rei->rsComm == NULL) {
02341 rodsLog (LOG_ERROR,
02342 "msiNcInqGrps: input rei or rsComm is NULL");
02343 return (SYS_INTERNAL_NULL_INPUT_ERR);
02344 }
02345 rsComm = rei->rsComm;
02346
02347 if (ncidParam == NULL) {
02348 rodsLog (LOG_ERROR,
02349 "msiNcInqGrps: input ncidParam is NULL");
02350 return (SYS_INTERNAL_NULL_INPUT_ERR);
02351 }
02352 bzero (&ncInqGrpsInp, sizeof (ncInqGrpsInp));
02353
02354 ncInqGrpsInp.ncid = parseMspForPosInt (ncidParam);
02355
02356 rei->status = rsNcInqGrps (rsComm, &ncInqGrpsInp, &ncInqGrpsOut);
02357
02358 clearKeyVal (&ncInqGrpsInp.condInput);
02359 if (rei->status >= 0) {
02360 fillMsParam (outParam, NULL, NcInqGrpsOut_MS_T, ncInqGrpsOut, NULL);
02361 } else {
02362 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02363 "msiNcInqGrps: rsNcInqGrps failed for ncid %d, status = %d",
02364 ncInqGrpsInp.ncid, rei->status);
02365 }
02366 #else
02367 rei->status = NETCDF_BUILD_WITH_NETCDF_API_NEEDED;
02368 #endif
02369 return (rei->status);
02370 }
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391 int
02392 msiNcOpenGroup (msParam_t *rootNcidParam, msParam_t *fullGrpNameParam,
02393 msParam_t *outParam, ruleExecInfo_t *rei)
02394 {
02395 #ifdef NETCDF4_API
02396 rsComm_t *rsComm;
02397 ncOpenInp_t ncOpenInp;
02398 int *grpNcid = NULL;
02399
02400 RE_TEST_MACRO (" Calling msiNcOpenGroup")
02401
02402 if (rei == NULL || rei->rsComm == NULL) {
02403 rodsLog (LOG_ERROR,
02404 "msiNcOpenGroup: input rei or rsComm is NULL");
02405 return (SYS_INTERNAL_NULL_INPUT_ERR);
02406 }
02407 rsComm = rei->rsComm;
02408
02409 bzero (&ncOpenInp, sizeof (ncOpenInp));
02410 if (rootNcidParam == NULL) {
02411 rodsLog (LOG_ERROR,
02412 "msiNcOpenGroup: input rootNcidParam is NULL");
02413 return (SYS_INTERNAL_NULL_INPUT_ERR);
02414 }
02415 ncOpenInp.rootNcid = parseMspForPosInt (rootNcidParam);
02416 if (strcmp (fullGrpNameParam->type, STR_MS_T) == 0) {
02417 rstrcpy (ncOpenInp.objPath, (char*)fullGrpNameParam->inOutStruct,
02418 MAX_NAME_LEN);
02419 } else {
02420 rodsLog (LOG_ERROR,
02421 "msiNcOpenGroup: Unsupported input fullGrpNameParam type %s",
02422 fullGrpNameParam->type);
02423 return (USER_PARAM_TYPE_ERR);
02424 }
02425 rei->status = rsNcOpenGroup (rsComm, &ncOpenInp, &grpNcid);
02426
02427 clearKeyVal (&ncOpenInp.condInput);
02428 if (rei->status >= 0) {
02429 fillIntInMsParam (outParam, *grpNcid);
02430 free (grpNcid);
02431 } else {
02432 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02433 "msiNcOpenGroup: rsNcOpenGroup failed for rootNcid %d, status = %d",
02434 ncOpenInp.rootNcid, rei->status);
02435 }
02436 #else
02437 rei->status = NETCDF_BUILD_WITH_NETCDF_API_NEEDED;
02438 #endif
02439 return (rei->status);
02440 }
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470 int
02471 msiNcGetNGrpsInInqOut (msParam_t *ncInqGrpsOutParam, msParam_t *outParam,
02472 ruleExecInfo_t *rei)
02473 {
02474 ncInqGrpsOut_t *ncInqGrpsOut;
02475
02476 RE_TEST_MACRO (" Calling msiNcGetNGrpsInInqOut")
02477
02478 if (ncInqGrpsOutParam == NULL || outParam == NULL)
02479 return USER__NULL_INPUT_ERR;
02480
02481 if (strcmp (ncInqGrpsOutParam->type, NcInqGrpsOut_MS_T) != 0) {
02482 rodsLog (LOG_ERROR,
02483 "msiNcGetNGrpsInInqOut: ncInqGrpsOutParam must be NcInqGrpsOut_MS_T. %s",
02484 ncInqGrpsOutParam->type);
02485 return (USER_PARAM_TYPE_ERR);
02486 } else {
02487 ncInqGrpsOut = (ncInqGrpsOut_t *) ncInqGrpsOutParam->inOutStruct;
02488 }
02489
02490
02491 fillIntInMsParam (outParam, ncInqGrpsOut->ngrps);
02492
02493 return 0;
02494 }
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525 int
02526 msiNcGetGrpInInqOut (msParam_t *ncInqGrpsOutParam,
02527 msParam_t *inxParam, msParam_t *outParam, ruleExecInfo_t *rei)
02528 {
02529 ncInqGrpsOut_t *ncInqGrpsOut;
02530 int inx;
02531
02532 RE_TEST_MACRO (" Calling msiNcGetGrpInInqOut")
02533
02534 if (ncInqGrpsOutParam == NULL || inxParam == NULL || outParam == NULL)
02535 return USER__NULL_INPUT_ERR;
02536
02537 if (strcmp (ncInqGrpsOutParam->type, NcInqGrpsOut_MS_T) != 0) {
02538 rodsLog (LOG_ERROR,
02539 "msiNcGetGrpInInqOut: ncInqGrpsOutParam must be NcInqGrpsOut_MS_T. %s",
02540 ncInqGrpsOutParam->type);
02541 return (USER_PARAM_TYPE_ERR);
02542 } else {
02543 ncInqGrpsOut = (ncInqGrpsOut_t *) ncInqGrpsOutParam->inOutStruct;
02544 }
02545 inx = parseMspForPosInt (inxParam);
02546 if (inx < 0 || inx >= ncInqGrpsOut->ngrps) {
02547 rodsLog (LOG_ERROR,
02548 "msiNcGetGrpInInqOut: input inx %d is out of range. ngrps = %d",
02549 inx, ncInqGrpsOut->ngrps);
02550 return NETCDF_VAR_COUNT_OUT_OF_RANGE;
02551 }
02552
02553
02554 fillStrInMsParam (outParam, ncInqGrpsOut->grpName[inx]);
02555
02556 return 0;
02557 }
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588 int
02589 msiNcRegGlobalAttr (msParam_t *objPathParam, msParam_t *adminParam,
02590 msParam_t *outParam, ruleExecInfo_t *rei)
02591 {
02592 rsComm_t *rsComm;
02593 ncRegGlobalAttrInp_t ncRegGlobalAttrInp;
02594
02595 RE_TEST_MACRO (" Calling msiNcRegGlobalAttr")
02596
02597 if (rei == NULL || rei->rsComm == NULL) {
02598 rodsLog (LOG_ERROR,
02599 "msiNcRegGlobalAttr: input rei or rsComm is NULL");
02600 return (SYS_INTERNAL_NULL_INPUT_ERR);
02601 }
02602
02603 rsComm = rei->rsComm;
02604 if (objPathParam == NULL) {
02605 rodsLog (LOG_ERROR,
02606 "msiNcRegGlobalAttr: input objPathParam is NULL");
02607 return (SYS_INTERNAL_NULL_INPUT_ERR);
02608 }
02609
02610 if (strcmp (objPathParam->type, STR_MS_T) == 0) {
02611
02612 bzero (&ncRegGlobalAttrInp, sizeof (ncRegGlobalAttrInp));
02613 rstrcpy (ncRegGlobalAttrInp.objPath,
02614 (char*)objPathParam->inOutStruct, MAX_NAME_LEN);
02615 } else {
02616 rodsLog (LOG_ERROR,
02617 "msiNcRegGlobalAttr: Unsupported input objPathParam type %s",
02618 objPathParam->type);
02619 return (USER_PARAM_TYPE_ERR);
02620 }
02621 if (adminParam != NULL) {
02622 int adminFlag = parseMspForPosInt (adminParam);
02623 if (adminFlag > 0) {
02624 addKeyVal (&ncRegGlobalAttrInp.condInput, IRODS_ADMIN_KW, "");
02625 }
02626 }
02627 rei->status = rsNcRegGlobalAttr (rsComm, &ncRegGlobalAttrInp);
02628 clearKeyVal (&ncRegGlobalAttrInp.condInput);
02629 fillIntInMsParam (outParam, rei->status);
02630 if (rei->status < 0) {
02631 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02632 "msiNcRegGlobalAttr: rscNcRegGlobalAttr failed for %s, status = %d",
02633 ncRegGlobalAttrInp.objPath, rei->status);
02634 }
02635
02636 return (rei->status);
02637 }
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671 int
02672 msiNcSubsetVar (msParam_t *varNameParam, msParam_t *ncidParam,
02673 msParam_t *ncInqOutParam, msParam_t *subsetStrParam,
02674 msParam_t *outParam, ruleExecInfo_t *rei)
02675 {
02676 rsComm_t *rsComm;
02677 ncVarSubset_t ncVarSubset;
02678 int ncid;
02679 ncInqOut_t *ncInqOut;
02680 char *name;
02681 char *subsetStr;
02682 ncGetVarOut_t *ncGetVarOut = NULL;
02683
02684 RE_TEST_MACRO (" Calling msiNcSubsetVar")
02685
02686 if (rei == NULL || rei->rsComm == NULL) {
02687 rodsLog (LOG_ERROR,
02688 "msiNcSubsetVar: input rei or rsComm is NULL");
02689 return (SYS_INTERNAL_NULL_INPUT_ERR);
02690 }
02691 rsComm = rei->rsComm;
02692 if (ncidParam == NULL) {
02693 rodsLog (LOG_ERROR,
02694 "msiNcSubsetVar: input ncidParam is NULL");
02695 return (SYS_INTERNAL_NULL_INPUT_ERR);
02696 } else {
02697 ncid = parseMspForPosInt (ncidParam);
02698 if (ncid < 0) return ncid;
02699 }
02700 if (ncInqOutParam == NULL) {
02701 rodsLog (LOG_ERROR,
02702 "msiNcSubsetVar: input ncInqOutParam is NULL");
02703 return (SYS_INTERNAL_NULL_INPUT_ERR);
02704 } else {
02705 ncInqOut = (ncInqOut_t *) ncInqOutParam->inOutStruct;
02706
02707 }
02708
02709 if (varNameParam == NULL) {
02710 rodsLog (LOG_ERROR,
02711 "msiNcSubsetVar: input varNameParam is NULL");
02712 return (SYS_INTERNAL_NULL_INPUT_ERR);
02713 } else {
02714 name = (char*) varNameParam->inOutStruct;
02715 }
02716 if (subsetStrParam == NULL) {
02717 rodsLog (LOG_ERROR,
02718 "msiNcSubsetVar: input subsetStrParam is NULL");
02719 return (SYS_INTERNAL_NULL_INPUT_ERR);
02720 } else {
02721 subsetStr = (char*) subsetStrParam->inOutStruct;
02722 }
02723 bzero (&ncVarSubset, sizeof (ncVarSubset));
02724 ncVarSubset.numVar = 1;
02725 rstrcpy ((char *) ncVarSubset.varName, name, LONG_NAME_LEN);
02726 rei->status = parseSubsetStr (subsetStr, &ncVarSubset);
02727 if (rei->status < 0) return rei->status;
02728 rei->status = ncSubsetVar (rsComm, ncid, ncInqOut, &ncVarSubset,
02729 &ncGetVarOut);
02730 if (rei->status >= 0) {
02731 fillMsParam (outParam, NULL, NcGetVarOut_MS_T, ncGetVarOut, NULL);
02732 } else {
02733 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02734 "msiNcSubsetVar: ncSubsetVar failed, status = %d",
02735 rei->status);
02736 }
02737
02738 return rei->status;
02739 }
02740
02741 int
02742 ncSubsetVar (rsComm_t *rsComm, int ncid, ncInqOut_t *ncInqOut,
02743 ncVarSubset_t *ncVarSubset, ncGetVarOut_t **ncGetVarOut)
02744 {
02745 int i, j, k, status;
02746 rodsLong_t start[NC_MAX_DIMS], stride[NC_MAX_DIMS], count[NC_MAX_DIMS];
02747 ncGetVarInp_t ncGetVarInp;
02748 int varInx = -1;
02749
02750 for (i = 0; i < ncInqOut->nvars; i++) {
02751 if (strcmp ((char *)ncVarSubset->varName, ncInqOut->var[i].name) == 0) {
02752 varInx = i;
02753 break;
02754 }
02755 }
02756 if (varInx < 0) {
02757 rodsLog (LOG_ERROR,
02758 "ncSubsetVar: unmatched input var name %s", ncVarSubset->varName);
02759 return NETCDF_UNMATCHED_NAME_ERR;
02760 }
02761
02762
02763 for (j = 0; j < ncInqOut->var[varInx].nvdims; j++) {
02764 int dimId = ncInqOut->var[varInx].dimId[j];
02765 int doSubset = False;
02766 if (ncVarSubset != NULL && ncVarSubset->numSubset > 0) {
02767 for (k = 0; k < ncVarSubset->numSubset; k++) {
02768 if (strcmp (ncInqOut->dim[dimId].name,
02769 ncVarSubset->ncSubset[k].subsetVarName) == 0) {
02770 doSubset = True;
02771 break;
02772 }
02773 }
02774 }
02775 if (doSubset == True) {
02776 if (ncVarSubset->ncSubset[k].start >=
02777 ncInqOut->dim[dimId].arrayLen ||
02778 ncVarSubset->ncSubset[k].end >=
02779 ncInqOut->dim[dimId].arrayLen ||
02780 ncVarSubset->ncSubset[k].start >
02781 ncVarSubset->ncSubset[k].end) {
02782 rodsLog (LOG_ERROR,
02783 "ncSubsetVar:start %d or end %d for %s outOfRange %lld",
02784 ncVarSubset->ncSubset[k].start,
02785 ncVarSubset->ncSubset[k].end,
02786 ncVarSubset->ncSubset[k].subsetVarName,
02787 ncInqOut->dim[dimId].arrayLen);
02788 return NETCDF_DIM_MISMATCH_ERR;
02789 }
02790 start[j] = ncVarSubset->ncSubset[k].start;
02791 stride[j] = ncVarSubset->ncSubset[k].stride;
02792 count[j] = ncVarSubset->ncSubset[k].end -
02793 ncVarSubset->ncSubset[k].start + 1;
02794 } else {
02795 start[j] = 0;
02796 count[j] = ncInqOut->dim[dimId].arrayLen;
02797 stride[j] = 1;
02798 }
02799 }
02800 bzero (&ncGetVarInp, sizeof (ncGetVarInp));
02801 ncGetVarInp.dataType = ncInqOut->var[varInx].dataType;
02802 ncGetVarInp.ncid = ncid;
02803 ncGetVarInp.varid = ncInqOut->var[varInx].id;
02804 ncGetVarInp.ndim = ncInqOut->var[varInx].nvdims;
02805 ncGetVarInp.start = start;
02806 ncGetVarInp.count = count;
02807 ncGetVarInp.stride = stride;
02808
02809 status = rsNcGetVarsByType (rsComm, &ncGetVarInp, ncGetVarOut);
02810
02811 if (status < 0) {
02812 rodsLogError (LOG_ERROR, status,
02813 "ncSubsetVar: rcNcGetVarsByType error for %s",
02814 ncInqOut->var[varInx].name);
02815 }
02816 return status;
02817 }
02818
02819
02820
02821
02822
02823
02824
02825
02826
02827
02828
02829
02830
02831
02832
02833
02834
02835
02836
02837
02838
02839
02840
02841
02842 int
02843 msiNcVarStat (msParam_t *ncGetVarOutParam, msParam_t *statOutStr,
02844 ruleExecInfo_t *rei)
02845 {
02846 ncGetVarOut_t *ncGetVarOut;
02847 char outStr[MAX_NAME_LEN];
02848 int i;
02849 float mymax = 0;
02850 float mymin = 0;
02851 float mytotal = 0;
02852 short *myshortArray;
02853 unsigned short *myushortArray;
02854 int *myintArray;
02855 unsigned int *myuintArray;
02856 long long *mylongArray;
02857 unsigned long long *myulongArray;
02858 float myfloat, *myfloatArray;
02859 double *mydoubleArray;
02860
02861
02862 RE_TEST_MACRO (" Calling msiNcVarStat")
02863
02864 if (rei == NULL) {
02865 rodsLog (LOG_ERROR, "msiNcVarStat: input rei is NULL");
02866 return (SYS_INTERNAL_NULL_INPUT_ERR);
02867 }
02868
02869 if (ncGetVarOutParam == NULL) {
02870 rodsLog (LOG_ERROR,
02871 "msiNcVarStat: input ncidParam is NULL");
02872 return (SYS_INTERNAL_NULL_INPUT_ERR);
02873 } else {
02874 ncGetVarOut = (ncGetVarOut_t *) ncGetVarOutParam->inOutStruct;
02875 if (ncGetVarOut == NULL || ncGetVarOut->dataArray == NULL)
02876 return USER__NULL_INPUT_ERR;
02877 }
02878
02879 if (ncGetVarOut->dataArray->type == NC_CHAR ||
02880 ncGetVarOut->dataArray->type == NC_STRING ||
02881 ncGetVarOut->dataArray->type == NC_BYTE ||
02882 ncGetVarOut->dataArray->type == NC_UBYTE) {
02883 rodsLog (LOG_ERROR,
02884 "msiNcVarStat: cannot compute max/min/ave of chr or string");
02885 return (NETCDF_INVALID_DATA_TYPE);
02886 }
02887 switch (ncGetVarOut->dataArray->type) {
02888 case NC_SHORT:
02889 myshortArray = (short *) ncGetVarOut->dataArray->buf;
02890 mymax = mymin = (float) myshortArray[0];
02891 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02892 myfloat = (float) myshortArray[i];
02893 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02894 }
02895 break;
02896 case NC_USHORT:
02897 myushortArray = (unsigned short *) ncGetVarOut->dataArray->buf;
02898 mymax = mymin = (float) myushortArray[0];
02899 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02900 myfloat = (float) myushortArray[i];
02901 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02902 }
02903 break;
02904 case NC_INT:
02905 myintArray = (int *) ncGetVarOut->dataArray->buf;
02906 mymax = mymin = (float) myintArray[0];
02907 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02908 myfloat = (float) myintArray[i];
02909 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02910 }
02911 break;
02912 case NC_UINT:
02913 myuintArray = (unsigned int *) ncGetVarOut->dataArray->buf;
02914 mymax = mymin = (float) myuintArray[0];
02915 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02916 myfloat = (float) myuintArray[i];
02917 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02918 }
02919 break;
02920 case NC_INT64:
02921 mylongArray = (long long *) ncGetVarOut->dataArray->buf;
02922 mymax = mymin = (float) mylongArray[0];
02923 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02924 myfloat = (float) mylongArray[i];
02925 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02926 }
02927 break;
02928 case NC_UINT64:
02929 myulongArray = (unsigned long long *) ncGetVarOut->dataArray->buf;
02930 mymax = mymin = (float) myulongArray[0];
02931 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02932 myfloat = (float) myulongArray[i];
02933 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02934 }
02935 break;
02936 case NC_FLOAT:
02937 myfloatArray = (float *) ncGetVarOut->dataArray->buf;
02938 mymax = mymin = myfloatArray[0];
02939 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02940 myfloat = myfloatArray[i];
02941 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02942 }
02943 break;
02944 case NC_DOUBLE:
02945 mydoubleArray = (double *) ncGetVarOut->dataArray->buf;
02946 mymax = mymin = (float) mydoubleArray[0];
02947 for (i = 0; i < ncGetVarOut->dataArray->len; i++) {
02948 myfloat = (float) mydoubleArray[i];
02949 procMaxMinAve (myfloat, &mymax, &mymin, &mytotal);
02950 }
02951 break;
02952 default:
02953 rodsLog (LOG_ERROR,
02954 "msiNcVarStat: Unknow dataType %d", ncGetVarOut->dataArray->type);
02955 return (NETCDF_INVALID_DATA_TYPE);
02956 }
02957 snprintf (outStr, MAX_NAME_LEN,
02958 " array length = %d max = %.4f min = %.4f ave = %.4f\n",
02959 ncGetVarOut->dataArray->len, mymax, mymin,
02960 mytotal / ncGetVarOut->dataArray->len);
02961 fillMsParam (statOutStr, NULL, STR_MS_T, outStr, NULL);
02962 return 0;
02963 }
02964
02965 int
02966 procMaxMinAve (float myfloat, float *mymax, float *mymin, float *mytotal)
02967 {
02968 *mytotal += myfloat;
02969 if (myfloat < *mymin) *mymin = myfloat;
02970 if (myfloat > *mymax) *mymax = myfloat;
02971 return 0;
02972 }
02973
02974 #if 0
02975 int
02976 msiPrVarInNcGetVarOut (msParam_t *ncGetVarOutParam, msParam_t *prefixParam,
02977 msParam_t *itemsPerLineParam, ruleExecInfo_t *rei)
02978 {
02979 ncGetVarOut_t *ncGetVarOut;
02980 RE_TEST_MACRO (" Calling msiPrVarInNcGetVarOut")
02981 char *prefix;
02982 int itemsPerLine;
02983 char tempStr[NAME_LEN];
02984 void *bufPtr;
02985 int outCnt = 0;
02986 int itemsInLine = 0;
02987
02988 if (rei == NULL) {
02989 rodsLog (LOG_ERROR, "msiPrVarInNcGetVarOut: input rei is NULL");
02990 return (SYS_INTERNAL_NULL_INPUT_ERR);
02991 }
02992
02993 if (ncGetVarOutParam == NULL) {
02994 rodsLog (LOG_ERROR,
02995 "msiPrVarInNcGetVarOut: input ncidParam is NULL");
02996 return (SYS_INTERNAL_NULL_INPUT_ERR);
02997 } else {
02998 ncGetVarOut = (ncGetVarOut_t *) ncGetVarOutParam->inOutStruct;
02999 if (ncGetVarOut == NULL || ncGetVarOut->dataArray == NULL)
03000 return USER__NULL_INPUT_ERR;
03001 }
03002 if (prefixParam == NULL) {
03003 rodsLog (LOG_ERROR,
03004 "msiPrVarInNcGetVarOut: input prefixParam is NULL");
03005 return (SYS_INTERNAL_NULL_INPUT_ERR);
03006 } else {
03007 prefix = (char *) prefixParam->inOutStruct;
03008 if ( prefix == NULL) return USER__NULL_INPUT_ERR;
03009 }
03010 if (itemsPerLineParam == NULL) {
03011 itemsPerLine = 1;
03012 } else {
03013 itemsPerLine = parseMspForPosInt (itemsPerLineParam);
03014 if (itemsPerLine <= 0) itemsPerLine = 1;
03015 }
03016 bufPtr = ncGetVarOut->dataArray->buf;
03017 bzero (tempStr, sizeof (tempStr));
03018 if (ncInqOut->var[varInx].dataType == NC_CHAR) {
03019 int totalLen = 0;
03020 while (totalLen < ncGetVarOut->dataArray->len) {
03021 int len;
03022 char *nextBufPtr;
03023
03024 if (outCnt == 0) _writeString ("stdout", prefix, rei);
03025 len = strlen (bufPtr);
03026 totalLen += (len + 1);
03027
03028 nextBufPtr = bufPtr + len + 1;
03029 while (isspace (*nextBufPtr) || *nextBufPtr = '\0') {
03030 bufPtr++;
03031 totalLen++;
03032 if (totalLen >= ncGetVarOut->dataArray->len) break;
03033 }
03034 if (totalLen >= ncGetVarOut->dataArray->len) {
03035
03036 printf ("%s ;\n", (char *) bufPtr);
03037 snprintf (tempStr, NAME_LEN, "%s ;\n", bufPtr);
03038 if (outCnt >= itemsPerLine - 1) {
03039
03040 snprintf (tempStr, NAME_LEN, "%s,\n", bufPtr);
03041 outCnt = 0;
03042 } else {
03043 snprintf (tempStr, NAME_LEN, "%s,", bufPtr);
03044 }
03045 _writeString ("stdout", tempStr, rei);
03046 outCnt ++;
03047 bufPtr = nextBufPtr;
03048 }
03049 } else {
03050 for (j = 0; j < ncGetVarOut->dataArray->len; j++) {
03051 ncValueToStr (ncInqOut->var[varInx].dataType, &bufPtr, tempStr);
03052 outCnt++;
03053 if (j >= ncGetVarOut->dataArray->len - 1) {
03054 strcat (tempStr, " ;\n");
03055 printf ("%s ;\n", tempStr);
03056 } else if (itemsPerLine > 0) {
03057 itemsInLine++;
03058 if (itemsInLine >= itemsPerLine) {
03059 strcat (tempStr, ",\n");
03060 itemsInLine = 0;
03061 } else {
03062 strcat (tempStr, ", ");
03063 }
03064 } else if (outCnt >= lastDimLen) {
03065
03066 strcat (tempStr, ",\n ");
03067 outCnt = 0;
03068 } else {
03069 strcat (tempStr, ", ");
03070 }
03071 }
03072 }
03073 return 0;
03074 }
03075 #endif
03076