Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions heclib/heclib_c/src/Internal/ztsIrregStoreBlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,61 +296,6 @@ int ztsIrregStoreBlock(long long *ifltab, zStructTimeSeries *tss, const char *pa

long long *info;

zStructRecordBasics* rb = zstructRecordBasicsNew(pathname);
status = zgetRecordBasics(ifltab, rb);

int recordType = rb->recordType;
zstructFree(rb);
if (status == STATUS_RECORD_FOUND && recordType == DATA_TYPE_ITD
&& dataType == DATA_TYPE_ITS
&& tss->floatValues
&& tss->doubleValues == NULL) {
// Support writing floats into a double record (calling ztsStore recursively)

zStructTimeSeries* tsClone = zstructTsClone(tss, pathname);

free(tsClone->floatValues);
tsClone->floatValues = NULL;
tsClone->doubleValues = calloc(numberToStore, sizeof(double));
int memoryError = 0;
if (tsClone->doubleValues) {
tsClone->allocated[zSTRUCT_TS_doubleValues] = 1;
tsClone->dataType = DATA_TYPE_ITD;
convertDataArray((void*)valuesToStore, (void*)tsClone->doubleValues, numberToStore, 1, 2);
tsClone->numberValues = numberToStore;
free(tsClone->times);
tsClone->times = calloc(numberToStore, sizeof(int));

if (tsClone->times) {
for (size_t i = 0; i < numberToStore; i++)
{
if (blockSize == 5) {
tsClone->times[i] = timesToStore[i] + julianStartBlockDate * 1440;
}
else {
tsClone->times[i] = (julianStartBlockDate * (86400 / tsClone->timeGranularitySeconds)) + (timesToStore[i] / tsClone->timeGranularitySeconds);
}
}
status = ztsStore(ifltab, tsClone, storageFlag);
}
else {
memoryError = 1;
status = STATUS_NOT_OKAY;
}
zstructFree(tsClone);
}
else {
memoryError = 1;
status = STATUS_NOT_OKAY;
}
if (memoryError) {
if (zmessageLevel(ifltab, MESS_METHOD_TS_WRITE_ID, MESS_LEVEL_INTERNAL_DIAG_1)) {
zmessageDebug(ifltab, DSS_FUNCTION_ztsIrregStoreBlock_ID, "Memory Error storing ", pathname);
}
}
return status;
}


if (zmessageLevel(ifltab, MESS_METHOD_TS_WRITE_ID, MESS_LEVEL_USER_DIAG)) {
zmessageDebug(ifltab, DSS_FUNCTION_ztsIrregStoreBlock_ID, "Enter, Pathname: ", pathname);
Expand Down
2 changes: 1 addition & 1 deletion heclib/heclib_c/src/Internal/ztsRegStoreBlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ int ztsRegStoreBlock(long long *ifltab, zStructTimeSeries *tss, const char *path

internalHeader[INT_HEAD_valueSize] = 2;
internalHeader[INT_HEAD_valueElementSize] = 2;
// Support writing floats into a double record (calling ztsStore recursively)
// Support writing floats into a double record
double* dblValues = (double*)calloc(numberToStore, sizeof(double));
if (!dblValues) {
if (zmessageLevel(ifltab, MESS_METHOD_TS_WRITE_ID, MESS_LEVEL_INTERNAL_DIAG_1)) {
Expand Down
69 changes: 55 additions & 14 deletions heclib/heclib_c/src/Internal/ztsStoreIrreg7.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,61 @@ int ztsStoreIrreg7(long long *ifltab, zStructTimeSeries *tss, int storageFlag)
kpos = currentPosition * tss->inoteElementSize;
npos = tss->cnotesLengthTotal - lengthCNotesRemaining;

status = ztsIrregStoreBlock(ifltab, tss, path,
buffer, bufferControl,
numberToStore, itimes,
&values[ipos], valueSize, valueElementSize,
&tss->quality[jpos], tss->qualityElementSize,
&tss->inotes[kpos], tss->inoteElementSize,
&tss->cnotes[npos], lengthCNotesRemaining, &lengthCNotesRemaining,
profileDepths, profileDepthsSize, profileDepthsNumber,
internalHeader,
tss->userHeader, tss->userHeaderNumber,
julianBlockDate, julianNextBlockDate, blockSize,
boolFromStartOfBlock, boolToEndOfBlock,
storageFlag, boolReadBlock, dataType);

zStructRecordBasics* rb = zstructRecordBasicsNew(path);
status = zgetRecordBasics(ifltab, rb);
int recordType = rb->recordType;
zstructFree(rb);

if (status == STATUS_RECORD_FOUND && recordType == DATA_TYPE_ITD
&& dataType == DATA_TYPE_ITS
&& tss->floatValues
&& tss->doubleValues == NULL) {
// Support writing floats into a double record
double* dblValues = (double*)calloc(numberToStore, sizeof(double));
if (!dblValues) {
if (zmessageLevel(ifltab, MESS_METHOD_TS_WRITE_ID, MESS_LEVEL_INTERNAL_DIAG_1)) {
zmessageDebug(ifltab, DSS_FUNCTION_ztsRegStoreBlock_ID, "Memory Error storing ", path);
}
}
int oldINT_HEAD_valueSize = internalHeader[INT_HEAD_valueSize];
int oldINT_HEAD_valueElementSize = internalHeader[INT_HEAD_valueElementSize];

internalHeader[INT_HEAD_valueSize] = 2;
internalHeader[INT_HEAD_valueElementSize] = 2;

convertDataArray((void*)&values[ipos], (void*)dblValues, numberToStore, 1, 2);
status = ztsIrregStoreBlock(ifltab, tss, path,
buffer, bufferControl,
numberToStore, itimes,
(int*)dblValues, 2, 2,
&tss->quality[jpos], tss->qualityElementSize,
&tss->inotes[kpos], tss->inoteElementSize,
&tss->cnotes[npos], lengthCNotesRemaining, &lengthCNotesRemaining,
profileDepths, profileDepthsSize, profileDepthsNumber,
internalHeader,
tss->userHeader, tss->userHeaderNumber,
julianBlockDate, julianNextBlockDate, blockSize,
boolFromStartOfBlock, boolToEndOfBlock,
storageFlag, boolReadBlock, DATA_TYPE_ITD);
free(dblValues);
internalHeader[INT_HEAD_valueSize] = oldINT_HEAD_valueSize;
internalHeader[INT_HEAD_valueElementSize] = oldINT_HEAD_valueElementSize;
}
else {
status = ztsIrregStoreBlock(ifltab, tss, path,
buffer, bufferControl,
numberToStore, itimes,
&values[ipos], valueSize, valueElementSize,
&tss->quality[jpos], tss->qualityElementSize,
&tss->inotes[kpos], tss->inoteElementSize,
&tss->cnotes[npos], lengthCNotesRemaining, &lengthCNotesRemaining,
profileDepths, profileDepthsSize, profileDepthsNumber,
internalHeader,
tss->userHeader, tss->userHeaderNumber,
julianBlockDate, julianNextBlockDate, blockSize,
boolFromStartOfBlock, boolToEndOfBlock,
storageFlag, boolReadBlock, dataType);
}
if (itimes) {
free(itimes);
itimes = 0;
Expand Down
2 changes: 1 addition & 1 deletion heclib/heclib_c/src/headers/hecdssInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define DSS_VERSION "7-IV"


#define DSS_VERSION_DATE "29 July 2025"
#define DSS_VERSION_DATE "30 July 2025"

const char *ztypeName(int recordType, int boolAbbreviation);
void zreada(long long *ifltab, const char *path, int *npath,
Expand Down
38 changes: 30 additions & 8 deletions test/Dss-C/TestDssC.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
int runTheTests();
int renameTest();
int test_mixed_record_types();
int test_data_shift_during_save();
int test_data_shift_during_save(int regular);


int skip_dss6(void){
Expand Down Expand Up @@ -210,7 +210,11 @@ int runTheTests() {
int status;


status = test_data_shift_during_save();
status = test_data_shift_during_save(0);
if (status != STATUS_OKAY)
return status;

status = test_data_shift_during_save(1);
if (status != STATUS_OKAY)
return status;

Expand Down Expand Up @@ -2019,23 +2023,41 @@ double* make_doubles_with_dates(int size) {
return a;
}

zStructTimeSeries* create_test_data_mark_twain(const char* pathname) {
zStructTimeSeries* create_test_data_mark_twain(const char* pathname, int regular) {

const char* type = "INST-VAL";
const char* units = "ft";
const char* startDate = "22Jun2025";
const char* startTime = "2400";
int size = 735;
double* doubleValues = make_doubles_with_dates(size);
zStructTimeSeries* tss = zstructTsNewRegDoubles(pathname, doubleValues,size,startDate,startTime,units,type);
zStructTimeSeries* tss;
if (regular) {
tss = zstructTsNewRegDoubles(pathname, doubleValues, size, startDate, startTime, units, type);
}
else
{
int* times = (int*)malloc(size * sizeof(int));
int julian = dateToJulian(startDate);
for (size_t i = 0; i < size; i++)
{
times[i] = i * 60 + julian;
}
tss = zstructTsNewIrregDoubles(pathname, doubleValues, size, times, 60, startDate, units, type);
tss->allocated[zSTRUCT_TS_times] = 1;
}
return tss;

}

int test_data_shift_during_save(int regular) {

int test_data_shift_during_save() {

const char* pathname = "/Salt/Mark Twain Lake/Elev//1Hour/Comp/";
zStructTimeSeries* markTwain = create_test_data_mark_twain(pathname);
const char* regularPathname = "/Salt/Mark Twain Lake/Elev//1Hour/Comp/";
const char* irregularPathname = "/Salt/Mark Twain Lake/Elev//IR-Month/Comp/";

const char* pathname = regular ? regularPathname : irregularPathname;

zStructTimeSeries* markTwain = create_test_data_mark_twain(pathname, regular);

long long ifltab[250];
const char* dssFilename = "working_mark_twain.dss";
Expand Down