| 54 |
|
|
| 55 |
|
static const char ROW_DONE[] = "ROW FINISHED\n"; |
| 56 |
|
|
| 57 |
< |
// Get format identifier |
| 58 |
< |
const char * |
| 59 |
< |
formstr(int f) |
| 60 |
< |
{ |
| 61 |
< |
switch (f) { |
| 62 |
< |
case 'a': return("ascii"); |
| 63 |
< |
case 'f': return("float"); |
| 64 |
< |
case 'd': return("double"); |
| 65 |
< |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
| 66 |
< |
} |
| 67 |
< |
return("unknown"); |
| 68 |
< |
} |
| 69 |
< |
|
| 70 |
< |
// Our default data share function |
| 71 |
< |
RdataShare * |
| 72 |
< |
defDataShare(const char *name, RCOutputOp op, size_t siz) |
| 73 |
< |
{ |
| 74 |
< |
return new RdataShareMap(name, RSDOflags[op], siz); |
| 75 |
< |
} |
| 76 |
< |
|
| 77 |
< |
// Allocate rcontrib accumulator |
| 78 |
< |
RcontribMod * |
| 57 |
> |
// allocate rcontrib accumulator |
| 58 |
> |
static RcontribMod * |
| 59 |
|
NewRcMod(const char *prms, const char *binexpr, int ncbins) |
| 60 |
|
{ |
| 61 |
+ |
if (binexpr && !*binexpr) binexpr = NULL; |
| 62 |
|
if (!prms) prms = ""; |
| 63 |
|
if ((ncbins > 1) & !binexpr) { |
| 64 |
|
error(USER, "missing bin expression"); |
| 93 |
|
return mp; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
< |
// Free an RcontribMod |
| 96 |
> |
// Free an RcontribMod (public for RcontribSimulManager constructor) |
| 97 |
|
void |
| 98 |
|
FreeRcMod(void *p) |
| 99 |
|
{ |
| 103 |
|
efree(p); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
+ |
// Get format identifier |
| 107 |
+ |
const char * |
| 108 |
+ |
formstr(int f) |
| 109 |
+ |
{ |
| 110 |
+ |
switch (f) { |
| 111 |
+ |
case 'a': return("ascii"); |
| 112 |
+ |
case 'f': return("float"); |
| 113 |
+ |
case 'd': return("double"); |
| 114 |
+ |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
| 115 |
+ |
} |
| 116 |
+ |
return("unknown"); |
| 117 |
+ |
} |
| 118 |
+ |
|
| 119 |
+ |
// Standard file data share function |
| 120 |
+ |
RdataShare * |
| 121 |
+ |
fileDataShare(const char *name, RCOutputOp op, size_t siz) |
| 122 |
+ |
{ |
| 123 |
+ |
if (op == RCOrecover && access(name, R_OK|W_OK) < 0) { |
| 124 |
+ |
sprintf(errmsg, "cannot recover from '%s'", name); |
| 125 |
+ |
error(SYSTEM, errmsg); |
| 126 |
+ |
return NULL; |
| 127 |
+ |
} |
| 128 |
+ |
return new RdataShareFile(name, RSDOflags[op], siz); |
| 129 |
+ |
} |
| 130 |
+ |
|
| 131 |
+ |
// Memory-mapped data share function |
| 132 |
+ |
RdataShare * |
| 133 |
+ |
mapDataShare(const char *name, RCOutputOp op, size_t siz) |
| 134 |
+ |
{ |
| 135 |
+ |
if (op == RCOrecover && access(name, R_OK|W_OK) < 0) { |
| 136 |
+ |
sprintf(errmsg, "cannot recover from '%s'", name); |
| 137 |
+ |
error(SYSTEM, errmsg); |
| 138 |
+ |
return NULL; |
| 139 |
+ |
} |
| 140 |
+ |
return new RdataShareMap(name, RSDOflags[op], siz); |
| 141 |
+ |
} |
| 142 |
+ |
|
| 143 |
|
// Set output format ('f', 'd', or 'c') |
| 144 |
|
bool |
| 145 |
|
RcontribSimulManager::SetDataFormat(int ty) |
| 397 |
|
if (rd < 0) |
| 398 |
|
return -1; |
| 399 |
|
if (rd >= op->nRows) { |
| 400 |
< |
if (remWarnings >= 0) { |
| 400 |
> |
if (remWarnings > 0) { |
| 401 |
|
sprintf(errmsg, "recovered output '%s' is complete", |
| 402 |
|
op->GetName()); |
| 403 |
|
error(WARNING, --remWarnings ? errmsg : "etc..."); |
| 414 |
|
} |
| 415 |
|
rowsDone.NewBitMap(outList->nRows); // create row completion map |
| 416 |
|
rowsDone.ClearBits(0, rInPos, true); |
| 417 |
< |
return rInPos; |
| 417 |
> |
return nrDone = rInPos; |
| 418 |
|
} |
| 419 |
|
|
| 420 |
|
// Create header in open write-only channel |
| 534 |
|
return -1; |
| 535 |
|
} |
| 536 |
|
// check #columns |
| 537 |
< |
if (((cp = findArgs(hdr, "NCOLS=", begData)) && atoi(cp)*esiz != rowBytes) || |
| 538 |
< |
!rcp->xres | (rowBytes > esiz)) { |
| 539 |
< |
sprintf(errmsg, "expected NCOLS=%d in '%s'", |
| 522 |
< |
int(rowBytes/esiz), GetName()); |
| 537 |
> |
if ((cp = findArgs(hdr, "NCOLS=", begData)) ? (atoi(cp)*esiz != rowBytes) |
| 538 |
> |
: (!rcp->xres | (rowBytes > esiz))) { |
| 539 |
> |
sprintf(errmsg, "expected NCOLS=%d in '%s'", int(rowBytes/esiz), GetName()); |
| 540 |
|
error(USER, errmsg); |
| 541 |
|
return -1; |
| 542 |
|
} |
| 578 |
|
return false; |
| 579 |
|
|
| 580 |
|
rowsDone.ClearBits(r, rInPos-r, false); |
| 581 |
< |
rInPos = r; |
| 581 |
> |
nrDone = rInPos = r; |
| 582 |
|
return true; |
| 583 |
|
} |
| 584 |
|
|
| 737 |
|
error(WARNING, "redundant call to UpdateRowsDone()"); |
| 738 |
|
return false; |
| 739 |
|
} |
| 740 |
< |
int nDone = GetRowFinished(); |
| 741 |
< |
if (nDone <= r) |
| 740 |
> |
GetRowFinished(); |
| 741 |
> |
if (nrDone <= r) |
| 742 |
|
return true; // nothing to update, yet |
| 743 |
|
for (RcontribOutput *op = outList; op; op = op->next) |
| 744 |
< |
if (!op->SetRowsDone(nDone)) |
| 744 |
> |
if (!op->SetRowsDone(nrDone)) |
| 745 |
|
return false; |
| 746 |
|
return true; // up-to-date |
| 747 |
|
} |