Skip to content

Commit

Permalink
Fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Belén Torrente committed Sep 11, 2024
1 parent f62c100 commit c39fe0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@ const char *CDPPSolarTerminator::className = "CDPPSolarTerminator";

const char *CDPPSolarTerminator::getId() { return "solarterminator"; }

#define SIZE 255
void CDPPSolarTerminator::print_trace() {
void *buffer[SIZE];
char cmd[256];
int nptrs;

nptrs = backtrace(buffer, SIZE);
backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO); // prints out raw stack trace

for (int j = 0; j < nptrs; j++) {
sprintf(cmd, "addr2line -e myprogram -f -C -i %p", buffer[j]); // replace 'myprogram' with your binary name
system(cmd);
}

return;
}

int CDPPSolarTerminator::isApplicable(CServerConfig::XMLE_DataPostProc *proc, CDataSource *dataSource, int mode) {
if (proc->attr.algorithm.equals("solarterminator")) {
if (dataSource->getNumDataObjects() < 1 && mode == CDATAPOSTPROCESSOR_RUNBEFOREREADING) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class CDPPSolarTerminator : public CDPPInterface {
private:
DEF_ERRORFUNCTION();
void print_trace();

public:
virtual const char *getId();
Expand Down
58 changes: 13 additions & 45 deletions adagucserverEC/CRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,53 +1825,29 @@ int CRequest::process_all_layers() {
if (dataSources[j]->dLayerType == CConfigReaderLayerTypeLiveUpdate) {
// This layer has no dimensions, but we need to add one timestep with data in order to make the next code work.
layerTypeLiveUpdateConfigureDimensionsInDataSource(dataSources[j]);
// Basic case of liveupdate layer
if (dataSources[j]->cfgLayer->DataPostProc.empty()) {
// // Add step to empty file
dataSources[j]->addStep("", NULL);
dataSources[j]->getCDFDims()->addDimension("none", "0", 0);
} else {
if (dataSources[j]->cfgLayer->Dimension.size() != 0) {
// Case of liveupdate layers with data post processors (such as solar terminator)
// Currently one (dummy) file is required
std::vector<std::string> fileList;
if (!dataSources[j]->cfgLayer->FilePath.empty()) {
try {
if (setDimValuesForDataSource(dataSources[j], srvParam) != 0) {
CDBError("Error in setDimValuesForDataSource: Unable to find data for layer %s", dataSources[j]->layerName.c_str());
return 1;
}

} catch (ServiceExceptionCode e) {
CDBError("Invalid dimensions values: No data available for layer %s", dataSources[j]->layerName.c_str());
setExceptionType(e);
fileList = CDBFileScanner::searchFileNames(dataSources[j]->cfgLayer->FilePath[0]->value.c_str(), dataSources[j]->cfgLayer->FilePath[0]->attr.filter, NULL);
} catch (int e) {
CDBError("Could not find any filename");
return 1;
}

} else {
CDBDebug("Layer has no dims");
// This layer has no dimensions, but we need to add one timestep with data in order to make the next code work.
std::vector<std::string> fileList;
if (dataSources[j]->cfgLayer->FilePath.empty()) {
dataSources[j]->addStep("", NULL);
dataSources[j]->getCDFDims()->addDimension("none", "0", 0);
CDBDebug("Path empty");
} else {

try {
fileList = CDBFileScanner::searchFileNames(dataSources[j]->cfgLayer->FilePath[0]->value.c_str(), dataSources[j]->cfgLayer->FilePath[0]->attr.filter, NULL);
} catch (int e) {
CDBError("Could not find any filename");
return 1;
}

if (fileList.size() == 0) {
CDBError("fileList.size()==0");
return 1;
}
dataSources[j]->addStep(fileList[0].c_str(), NULL);
if (fileList.size() == 0) {
CDBError("fileList.size()==0");
return 1;
}
dataSources[j]->addStep(fileList[0].c_str(), NULL);
}

// dataSources[j]->addStep("", NULL);

// dataSources[j]->getCDFDims()->addDimension("none", "0", 0);
// layerTypeLiveUpdateConfigureDimensionsInDataSource(dataSources[j]);
}
}
}
Expand Down Expand Up @@ -2366,22 +2342,14 @@ int CRequest::process_all_layers() {
image.printImagePng8(true);
} else {
// General case: Liveupdate with some data postprocessors
// CDrawImage image;
// CDataReader reader;
// Covers case of Solar Terminator
CImageDataWriter imageDataWriter;
// bool imageDataWriterIsInitialized = false;
status = imageDataWriter.init(srvParam, dataSources[j], dataSources[j]->getNumTimeSteps());
CDBDebug("Init imageDataWriter status %d", status);
// if (status != 0) throw(__LINE__);
// imageDataWriterIsInitialized = true;
// // When we have multiple timesteps, we will create an animation.
CDBDebug("Num timesteps was %d", dataSources[j]->getNumTimeSteps());
if (dataSources[j]->getNumTimeSteps() > 1) CDBDebug("Status from create animation was %d", imageDataWriter.createAnimation());
status = imageDataWriter.addData(dataSources);
CDBDebug("Adding data status was %d", status);
// // Note: add legend etc
// status = imageDataWriter.end();
// CDBDebug("Ending imagedatawriter status was %d", status);
status = imageDataWriter.end();
}
CDBDebug("Ending image data writing with status %d", status);
Expand Down
4 changes: 0 additions & 4 deletions adagucserverEC/LayerTypeLiveUpdate/LayerTypeLiveUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ int layerTypeLiveUpdateConfigureDimensionsInDataSource(CDataSource *dataSource)
dataSource->requiredDims.push_back(requiredDim);
}

// // Add step to empty file
// dataSource->addStep("", NULL);
// dataSource->getCDFDims()->addDimension("none", "0", 0);

return 0;
}

Expand Down

0 comments on commit c39fe0b

Please sign in to comment.