Skip to content

Commit

Permalink
All output files are a string now + replaced error messages in Comman…
Browse files Browse the repository at this point in the history
…dLineInterface with ShowFatalError
  • Loading branch information
Monika Sharma committed Sep 25, 2014
1 parent 4f41f3d commit b01fc95
Show file tree
Hide file tree
Showing 24 changed files with 329 additions and 244 deletions.
6 changes: 4 additions & 2 deletions src/EnergyPlus/AirflowNetworkSolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// EnergyPlus Headers
#include <AirflowNetworkSolver.hh>
#include <CommandLineInterface.hh>
#include <DataAirflowNetwork.hh>
#include <DataAirLoop.hh>
#include <DataEnvironment.hh>
Expand Down Expand Up @@ -54,6 +55,7 @@ namespace AirflowNetworkSolver {
// USE STATEMENTS:

// Using/Aliasing
using namespace CommandLineInterface;
using namespace DataPrecisionGlobals;
using DataGlobals::Pi;
using DataGlobals::DegToRadians;
Expand Down Expand Up @@ -217,7 +219,7 @@ namespace AirflowNetworkSolver {
LIST = 0;
if ( LIST >= 1 ) {
Unit21 = GetNewUnitNumber();
gio::open( Unit21, "eplusADS.out" );
gio::open( Unit21, outputAdsFileName );
}

for ( n = 1; n <= NetworkNumOfNodes; ++n ) {
Expand All @@ -242,7 +244,7 @@ namespace AirflowNetworkSolver {
// Write an ouput file used for AIRNET input
if ( LIST >= 5 ) {
Unit11 = GetNewUnitNumber();
gio::open( Unit11, "eplusADS.inp" );
gio::open( Unit11, eplusADSFileName );
for ( i = 1; i <= NetworkNumOfNodes; ++i ) {
gio::write( Unit11, Format_901 ) << i << AirflowNetworkNodeData( i ).NodeTypeNum << AirflowNetworkNodeData( i ).NodeHeight << TZ( i ) << PZ( i );
}
Expand Down
168 changes: 107 additions & 61 deletions src/EnergyPlus/CommandLineInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,49 @@ namespace CommandLineInterface{
using namespace SolarShading;
using namespace ez;

std::string outputAuditFile;
std::string outputBndFile;
std::string outputDxfFile;
std::string outputEioFile;
std::string outputEndFile;
std::string outputErrFile;
std::string outputEsoFile;
std::string outputMtdFile;
std::string outputMddFile;
std::string outputMtrFile;
std::string outputRddFile;
std::string outputShdFile;
std::string outputCsvFile;
std::string outputHtmFile;
std::string outputTabFile;
std::string outputTxtFile;
std::string outputXmlFile;
std::string inputFileName;
std::string inputEnergyFile;
std::string inputWeatherFile;
std::string outputAuditFileName;
std::string outputBndFileName;
std::string outputDxfFileName;
std::string outputEioFileName;
std::string outputEndFileName;
std::string outputErrFileName;
std::string outputEsoFileName;
std::string outputMtdFileName;
std::string outputMddFileName;
std::string outputMtrFileName;
std::string outputRddFileName;
std::string outputShdFileName;
std::string outputTblCsvFileName;
std::string outputTblHtmFileName;
std::string outputTblTabFileName;
std::string outputTblTxtFileName;
std::string outputTblXmlFileName;
std::string inputIdfFileName;
std::string inputIddFileName;
std::string inputWeatherFileName;
std::string outputAdsFileName;
std::string outputDfsFileName;
std::string outputDelightFileName;
std::string outputMapTabFileName;
std::string outputMapCsvFileName;
std::string outputMapTxtFileName;
std::string outputEddFileName;
std::string outputIperrFileName;
std::string outputDbgFileName;
std::string outputSlnFileName;
std::string outputSciFileName;
std::string outputWrlFileName;
std::string outputZszCsvFileName;
std::string outputZszTabFileName;
std::string outputZszTxtFileName;
std::string outputSszCsvFileName;
std::string outputSszTabFileName;
std::string outputSszTxtFileName;
std::string outputScreenCsvFileName;
std::string EnergyPlusIniFileName;
std::string inStatFileName;
std::string TarcogIterationsFileName;
std::string eplusADSFileName;

int
ProcessArgs(int argc, const char * argv[])
Expand Down Expand Up @@ -89,12 +112,70 @@ namespace CommandLineInterface{
std::string usage;
opt.getUsage(usage);

opt.get("-i")->getString(inputIdfFileName);

opt.get("-w")->getString(inputWeatherFileName);

opt.get("-e")->getString(inputIddFileName);

std::string outputFilePrefix;

if (opt.isSet("-o")) {
outputFilePrefix = inputIdfFileName.substr(0, inputIdfFileName.size()-4) + "_" +
inputWeatherFileName.substr(0, inputWeatherFileName.size()-4) + "_";
}
else {
outputFilePrefix = "eplus";
}

outputAuditFileName = outputFilePrefix + "out.audit";
outputBndFileName = outputFilePrefix + "out.bnd";
outputDxfFileName = outputFilePrefix + "out.dxf";
outputEioFileName = outputFilePrefix + "out.eio";
outputEndFileName = outputFilePrefix + "out.end";
outputErrFileName = outputFilePrefix + "out.err";
outputEsoFileName = outputFilePrefix + "out.eso";
outputMtdFileName = outputFilePrefix + "out.mtd";
outputMddFileName = outputFilePrefix + "out.mdd";
outputMtrFileName = outputFilePrefix + "out.mtr";
outputRddFileName = outputFilePrefix + "out.rdd";
outputShdFileName = outputFilePrefix + "out.shd";
outputTblCsvFileName = outputFilePrefix + "tbl.csv";
outputTblHtmFileName = outputFilePrefix + "tbl.htm";
outputTblTabFileName = outputFilePrefix + "tbl.tab";
outputTblTxtFileName = outputFilePrefix + "tbl.txt";
outputTblXmlFileName = outputFilePrefix + "tbl.xml";
outputAdsFileName = outputFilePrefix + "ADS.out";
outputDfsFileName = outputFilePrefix + "out.dfs";
outputDelightFileName = outputFilePrefix + "out.delightdfdmp";
outputMapTabFileName = outputFilePrefix + "map.tab";
outputMapCsvFileName = outputFilePrefix + "map.csv";
outputMapTxtFileName = outputFilePrefix + "map.txt";
outputEddFileName = outputFilePrefix + "out.edd";
outputIperrFileName = outputFilePrefix + "out.iperr";
outputDbgFileName = outputFilePrefix + "out.dbg";
outputSlnFileName = outputFilePrefix + "out.sln";
outputSciFileName = outputFilePrefix + "out.sci";
outputWrlFileName = outputFilePrefix + "out.wrl";
outputZszCsvFileName = outputFilePrefix + "zsz.csv";
outputZszTabFileName = outputFilePrefix + "zsz.tab";
outputZszTxtFileName = outputFilePrefix + "zsz.txt";
outputSszCsvFileName = outputFilePrefix + "ssz.csv";
outputSszTabFileName = outputFilePrefix + "ssz.tab";
outputSszTxtFileName = outputFilePrefix + "ssz.txt";
outputScreenCsvFileName = outputFilePrefix + "screen.csv";
EnergyPlusIniFileName = "Energy+.ini";
inStatFileName = "in.stat";
TarcogIterationsFileName = "TarcogIterations.dbg";
eplusADSFileName = "eplusADS.inp";


// Handle bad options
std::vector<std::string> badOptions;

if(!opt.gotExpected(badOptions)) {
for(int i=0; i < badOptions.size(); ++i) {
DisplayString("ERROR: Unexpected number of arguments for option " + badOptions[i] + "\n");
ShowFatalError("ERROR: Unexpected number of arguments for option " + badOptions[i] + "\n");
}
DisplayString(usage);
exit(EXIT_FAILURE);
Expand All @@ -103,29 +184,29 @@ namespace CommandLineInterface{
if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0 || opt.lastArgs.size() > 0){
for(int i=1; i < opt.firstArgs.size(); ++i) {
std::string arg(opt.firstArgs[i]->c_str());
DisplayString("ERROR: Invalid option: " + arg + "\n");
ShowFatalError("ERROR: Invalid option first arg: " + arg + "\n");
}
for(int i=0; i < opt.unknownArgs.size(); ++i) {
std::string arg(opt.unknownArgs[i]->c_str());
DisplayString("ERROR: Invalid option: " + arg + "\n");
ShowFatalError("ERROR: Invalid option unknown arg: " + arg + "\n");
}
for(int i=0; i < opt.lastArgs.size(); ++i) {
std::string arg(opt.lastArgs[i]->c_str());
DisplayString("ERROR: Invalid option: " + arg + "\n");
ShowFatalError("ERROR: Invalid option last arg: " + arg + "\n");
}
DisplayString(usage);
exit(EXIT_FAILURE);
}

if(!opt.gotRequired(badOptions)) {
for(int i=0; i < badOptions.size(); ++i) {
DisplayString("ERROR: Missing required option " + badOptions[i] + "\n");
ShowFatalError("ERROR: Missing required option " + badOptions[i] + "\n");
}
DisplayString(usage);
exit(EXIT_FAILURE);
}

// Process arguments
// Process standard arguments
if (opt.isSet("-h")) {
DisplayString(usage);
exit(EXIT_SUCCESS);
Expand All @@ -136,41 +217,6 @@ namespace CommandLineInterface{
exit(EXIT_SUCCESS);
}

opt.get("-i")->getString(inputFileName);

opt.get("-w")->getString(inputWeatherFile);

opt.get("-e")->getString(inputEnergyFile);

std::string outputFilePrefix;

if (opt.isSet("-o")) {
outputFilePrefix =
inputFileName.substr(0, inputFileName.size()-4) + "_" +
inputWeatherFile.substr(0, inputWeatherFile.size()-4) + "_";
}
else {
outputFilePrefix = "eplus";
}

outputAuditFile = outputFilePrefix + "out.audit";
outputBndFile = outputFilePrefix + "out.bnd";
outputDxfFile = outputFilePrefix + "out.dxf";
outputEioFile = outputFilePrefix + "out.eio";
outputEndFile = outputFilePrefix + "out.end";
outputErrFile = outputFilePrefix + "out.err";
outputEsoFile = outputFilePrefix + "out.eso";
outputMtdFile = outputFilePrefix + "out.mtd";
outputMddFile = outputFilePrefix + "out.mdd";
outputMtrFile = outputFilePrefix + "out.mtr";
outputRddFile = outputFilePrefix + "out.rdd";
outputShdFile = outputFilePrefix + "out.shd";
outputCsvFile = outputFilePrefix + "tbl.csv";
outputHtmFile = outputFilePrefix + "tbl.htm";
outputTabFile = outputFilePrefix + "tbl.tab";
outputTxtFile = outputFilePrefix + "tbl.txt";
outputXmlFile = outputFilePrefix + "tbl.xml";

return 0;
}
} //namespace options
Expand Down
63 changes: 43 additions & 20 deletions src/EnergyPlus/CommandLineInterface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,49 @@ namespace EnergyPlus{

namespace CommandLineInterface {

extern std::string outputAuditFile;
extern std::string outputBndFile;
extern std::string outputDxfFile;
extern std::string outputEioFile;
extern std::string outputEndFile;
extern std::string outputErrFile;
extern std::string outputEsoFile;
extern std::string outputMtdFile;
extern std::string outputMddFile;
extern std::string outputMtrFile;
extern std::string outputRddFile;
extern std::string outputShdFile;
extern std::string outputCsvFile;
extern std::string outputHtmFile;
extern std::string outputTabFile;
extern std::string outputTxtFile;
extern std::string outputXmlFile;
extern std::string inputFileName;
extern std::string inputEnergyFile;
extern std::string inputWeatherFile;
extern std::string outputAuditFileName;
extern std::string outputBndFileName;
extern std::string outputDxfFileName;
extern std::string outputEioFileName;
extern std::string outputEndFileName;
extern std::string outputErrFileName;
extern std::string outputEsoFileName;
extern std::string outputMtdFileName;
extern std::string outputMddFileName;
extern std::string outputMtrFileName;
extern std::string outputRddFileName;
extern std::string outputShdFileName;
extern std::string outputTblCsvFileName;
extern std::string outputTblHtmFileName;
extern std::string outputTblTabFileName;
extern std::string outputTblTxtFileName;
extern std::string outputTblXmlFileName;
extern std::string inputIdfFileName;
extern std::string inputIddFileName;
extern std::string inputWeatherFileName;
extern std::string outputAdsFileName;
extern std::string outputDfsFileName;
extern std::string outputDelightFileName;
extern std::string outputMapTabFileName;
extern std::string outputMapCsvFileName;
extern std::string outputMapTxtFileName;
extern std::string outputEddFileName;
extern std::string outputIperrFileName;
extern std::string outputDbgFileName;
extern std::string outputSlnFileName;
extern std::string outputSciFileName;
extern std::string outputWrlFileName;
extern std::string outputZszCsvFileName;
extern std::string outputZszTabFileName;
extern std::string outputZszTxtFileName;
extern std::string outputSszCsvFileName;
extern std::string outputSszTabFileName;
extern std::string outputSszTxtFileName;
extern std::string outputScreenCsvFileName;
extern std::string EnergyPlusIniFileName;
extern std::string inStatFileName;
extern std::string TarcogIterationsFileName;
extern std::string eplusADSFileName;

// Process command line arguments
int
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/DataStringGlobals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace DataStringGlobals {
// na

// MODULE VARIABLE DECLARATIONS:
std::string ProgramPath; // Path for Program from Energy+.ini
std::string ProgramPath; // Path for Program from EnergyPlusIniFileName
std::string CurrentWorkingFolder; // Current working directory for run
std::string FullName; // Full name of file to open, including path
std::string IDDVerString; // Version information from the IDD (line 1)
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/DataStringGlobals.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace DataStringGlobals {
// na

// MODULE VARIABLE DECLARATIONS:
extern std::string ProgramPath; // Path for Program from Energy+.ini
extern std::string ProgramPath; // Path for Program from EnergyPlusIniFileName
extern std::string CurrentWorkingFolder; // Current working directory for run
extern std::string FullName; // Full name of file to open, including path
extern std::string IDDVerString; // Version information from the IDD (line 1)
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/DataSystemVariables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ namespace DataSystemVariables {
std::string::size_type pos;

if ( firstTime ) {
EchoInputFile = FindUnitNumber( outputAuditFile );
EchoInputFile = FindUnitNumber( outputAuditFileName );
get_environment_variable( cInputPath1, envinputpath1 );
if ( envinputpath1 != blank ) {
pos = index( envinputpath1, pathChar, true ); // look backwards for pathChar
Expand Down
Loading

6 comments on commit b01fc95

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (monika0603) - i386-Windows-7-VisualStudio-12: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (monika0603) - Win64-Windows-7-VisualStudio-12: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (monika0603) - x86_64-Linux-Ubuntu-14.04-gcc-4.8: Build Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (monika0603) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (monika0603) - x86_64-MacOS-10.9-clang: OK (903 of 906 tests passed)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (monika0603) - x86_64-MacOS-10.9-clang-Debug: OK (898 of 906 tests passed)

Build Badge Test Badge

Please sign in to comment.