From e92386621f8116acdacac8aeb25ebb8f51b458f3 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Thu, 11 Sep 2014 16:45:25 -0600 Subject: [PATCH 01/71] Version 0 for command line interface, Sep 11, 2014 --- src/EnergyPlus/InputProcessor.cc | 57 +- src/EnergyPlus/InputProcessor.hh | 12 +- src/EnergyPlus/OutputReportTabular.cc | 12 +- src/EnergyPlus/OutputReportTabular.hh | 9 +- src/EnergyPlus/SimulationManager.cc | 18 +- src/EnergyPlus/SimulationManager.hh | 5 +- src/EnergyPlus/ThermalComfort.cc | 15 +- src/EnergyPlus/UtilityRoutines.cc | 9 +- src/EnergyPlus/WeatherManager.cc | 11 +- src/EnergyPlus/ezOptionParser.hpp | 2171 +++++++++++++++++++++++++ src/EnergyPlus/main.cc | 303 +++- src/EnergyPlus/main.hh | 1 + 12 files changed, 2546 insertions(+), 77 deletions(-) create mode 100755 src/EnergyPlus/ezOptionParser.hpp diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 9b4a3f5a5ce..e31134a70bd 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -14,6 +14,9 @@ #include #include +//Standard C++ library +#include + namespace EnergyPlus { namespace InputProcessor { @@ -45,6 +48,7 @@ namespace InputProcessor { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing + using namespace DataPrecisionGlobals; using namespace DataStringGlobals; using DataGlobals::MaxNameLength; @@ -59,7 +63,8 @@ namespace InputProcessor { using DataSystemVariables::SortedIDD; using DataSystemVariables::iASCII_CR; using DataSystemVariables::iUnicode_end; - + + // Use statements for access to subroutines in other modules // Data @@ -85,6 +90,8 @@ namespace InputProcessor { Real64 const DefAutoCalculateValue( AutoCalculate ); static gio::Fmt const fmtLD( "*" ); static gio::Fmt const fmtA( "(A)" ); + std::string inputFileName; + std::string inputEnergyFile; // DERIVED TYPE DEFINITIONS @@ -163,6 +170,19 @@ namespace InputProcessor { FArray1D< LineDefinition > IDFRecords; // All the objects read from the IDF FArray1D< SecretObjects > RepObjects; // Secret Objects that could replace old ones + std::string assign(std::string& _FileName){ + std::cout<<"====================================================================== \n"; + std::cout<<"== Module 'Input Processor'::Name of the input file = "<<_FileName<> InputLine; endcol = len( InputLine ); if ( endcol > 0 ) { if ( int( InputLine[ endcol - 1 ] ) == iUnicode_end ) { - ShowSevereError( "ProcessInput: \"Energy+.idd\" appears to be a Unicode or binary file." ); + ShowSevereError( "ProcessInput: " + inputEnergyFile + " appears to be a Unicode or binary file." ); ShowContinueError( "...This file cannot be read by this program. Please save as PC or Unix file and try again" ); ShowFatalError( "Program terminates due to previous condition." ); } @@ -280,7 +300,7 @@ namespace InputProcessor { NumLines = 0; DoingInputProcessing = true; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary (Energy+.idd) File -- Start"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputEnergyFile+") File -- Start"; DisplayString( "Processing Data Dictionary" ); ProcessingIDD = true; @@ -310,7 +330,7 @@ namespace InputProcessor { } ProcessingIDD = false; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary (Energy+.idd) File -- Complete"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputEnergyFile+") File -- Complete"; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Alpha Args=" << MaxAlphaArgsFound; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Numeric Args=" << MaxNumericArgsFound; @@ -320,25 +340,25 @@ namespace InputProcessor { gio::write( EchoInputFile, fmtLD ) << " Total Number of Numeric Fields=" << NumNumericArgsFound; gio::write( EchoInputFile, fmtLD ) << " Total Number of Fields=" << NumAlphaArgsFound + NumNumericArgsFound; - gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (in.idf) -- Start"; + gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (inputFileName) -- Start"; - { IOFlags flags; gio::inquire( "in.idf", flags ); FileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - DisplayString( "Missing " + CurrentWorkingFolder + "in.idf" ); - ShowFatalError( "ProcessInput: in.idf missing. Program terminates." ); + DisplayString( "Missing " + CurrentWorkingFolder + inputFileName ); + ShowFatalError( "ProcessInput: " + inputFileName + " missing. Program terminates." ); } IDFFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( IDFFile, "in.idf", flags ); read_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( IDFFile, inputFileName, flags ); read_stat = flags.ios(); } if ( read_stat != 0 ) { - DisplayString( "Could not open (read) in.idf." ); + DisplayString( "Could not open (read)" + inputFileName ); ShowFatalError( "ProcessInput: Could not open file \"in.idf\" for input (read)." ); } gio::read( IDFFile, fmtA ) >> InputLine; endcol = len( InputLine ); if ( endcol > 0 ) { if ( int( InputLine[ endcol - 1 ] ) == iUnicode_end ) { - ShowSevereError( "ProcessInput: \"in.idf\" appears to be a Unicode or binary file." ); + ShowSevereError( "ProcessInput: " + inputFileName +" appears to be a Unicode or binary file." ); ShowContinueError( "...This file cannot be read by this program. Please save as PC or Unix file and try again" ); ShowFatalError( "Program terminates due to previous condition." ); } @@ -6153,7 +6173,7 @@ namespace InputProcessor { // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. @@ -6177,3 +6197,4 @@ namespace InputProcessor { } // InputProcessor } // EnergyPlus + diff --git a/src/EnergyPlus/InputProcessor.hh b/src/EnergyPlus/InputProcessor.hh index 858183c1902..fa87882eb93 100644 --- a/src/EnergyPlus/InputProcessor.hh +++ b/src/EnergyPlus/InputProcessor.hh @@ -89,7 +89,9 @@ namespace InputProcessor { extern std::string CurrentFieldName; // Current Field Name (IDD) extern FArray1D_string ObsoleteObjectsRepNames; // Array of Replacement names for Obsolete objects extern std::string ReplacementName; - + extern std::string inputFileName; + extern std::string inputEnergyFile; + //Logical Variables for Module extern bool OverallErrorFlag; // If errors found during parse of IDF, will fatal at end extern bool EchoInputLine; // Usually True, if the IDD is backspaced, then is set to false, then back to true @@ -407,9 +409,11 @@ namespace InputProcessor { extern LineDefinition LineItem; // Description of current record extern FArray1D< LineDefinition > IDFRecords; // All the objects read from the IDF extern FArray1D< SecretObjects > RepObjects; // Secret Objects that could replace old ones - + // Functions - + std::string assign(std::string& _FileName); + std::string assignEFile(std::string& _EFileName); + void ProcessInput(); @@ -867,7 +871,7 @@ namespace InputProcessor { // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index b4ca6d906ba..fc663f71c86 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -406,7 +406,13 @@ namespace OutputReportTabular { static gio::Fmt const fmtA( "(A)" ); // Functions - + std::string outputFile; + std::string assignOFile(std::string& _OFileName){ + std::cout<<"== Module 'Output report tabular'::Name of the output file = "<<_OFileName< UnitConv; // Functions - + void UpdateTabularReports( int const IndexTypeKey ); // What kind of data to update (Zone, HVAC) @@ -736,6 +740,7 @@ namespace OutputReportTabular { //====================================================================================================================== //====================================================================================================================== + void GetInputTabularMonthly(); @@ -1063,7 +1068,7 @@ namespace OutputReportTabular { // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 3011e78e12a..4262bdbc81d 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -149,6 +149,14 @@ namespace SimulationManager { // MODULE SUBROUTINES: // Functions + std::string inputWeatherFile; + + std::string assignWFile(std::string& _WFileName){ + std::cout<<"====================================================================== \n"; + std::cout<<"== Module 'Manage Simulation'::Name of the weather file = "<<_WFileName< #include #include +#include #include namespace EnergyPlus { @@ -2467,7 +2468,7 @@ namespace ThermalComfort { if ( initiate && weathersimulation ) { { IOFlags flags; gio::inquire( "in.stat", flags ); statFileExists = flags.exists(); } - { IOFlags flags; gio::inquire( "in.epw", flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( statFileExists ) { statFile = GetNewUnitNumber(); @@ -2492,9 +2493,9 @@ namespace ThermalComfort { useStatData = true; } else if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, "in.epw", flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, SimulationManager::inputWeatherFile, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file \"in.epw\" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " +SimulationManager::inputWeatherFile+ " for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } @@ -2718,13 +2719,13 @@ namespace ThermalComfort { } if ( initiate && weathersimulation ) { - { IOFlags flags; gio::inquire( "in.epw", flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, "in.epw", flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, SimulationManager::inputWeatherFile, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file \"in.epw\" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+SimulationManager::inputWeatherFile+" for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } @@ -2928,7 +2929,7 @@ namespace ThermalComfort { // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 80d45d785fb..0578cb2993c 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -27,6 +27,7 @@ #include #include #include +#include //Added to pass inputEnergyFile (MS) #include #include #include @@ -166,12 +167,12 @@ AbortEnergyPlus( strip( NumSevereDuringSizing ); if ( NoIDD ) { - DisplayString( "No EnergyPlus Data Dictionary (Energy+.idd) was found. It is possible " ); + DisplayString( "No EnergyPlus Data Dictionary (" +InputProcessor::inputEnergyFile+") was found. It is possible " ); DisplayString( "you \"double-clicked\"EnergyPlus.exe rather than using one of the methods" ); DisplayString( "to run Energyplus as found in the GettingStarted document in the" ); DisplayString( "documentation folder. Using EP-Launch may be best -- " ); DisplayString( "it provides extra help for new users." ); - ShowMessage( "No EnergyPlus Data Dictionary (Energy+.idd) was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); + ShowMessage( "No EnergyPlus Data Dictionary (" +InputProcessor::inputEnergyFile+") was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); ShowMessage( "rather than using one of the methods to run Energyplus as found in the GettingStarted document" ); ShowMessage( "in the documentation folder. Using EP-Launch may be best -- it provides extra help for new users." ); { IOFlags flags; flags.ADVANCE( "NO" ); gio::write( OutFmt, flags ); } @@ -829,7 +830,7 @@ ShowFatalError( ShowErrorMessage( " ** Fatal ** " + ErrorMessage, OutUnit1, OutUnit2 ); DisplayString( "**FATAL:" + ErrorMessage ); if ( has( ErrorMessage, "in.idf missing" ) ) NoIdf = true; - if ( has( ErrorMessage, "Energy+.idd missing" ) ) NoIDD = true; + if ( has( ErrorMessage, InputProcessor::inputEnergyFile +" missing" ) ) NoIDD = true; ShowErrorMessage( " ...Summary of Errors that led to program termination:", OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Reference severe error count=" + RoundSigDigits( TotalSevereErrors ), OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Last severe error=" + LastSevereError, OutUnit1, OutUnit2 ); @@ -1785,7 +1786,7 @@ ShowRecurringErrors() } // NOTICE -// Copyright © 1996-2014 The Board of Trustees of the University of Illinois +// Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. // Portions of the EnergyPlus software package have been developed and copyrighted diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 1e444a4a45d..613283b54d3 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -4389,7 +4390,7 @@ Label903: ; // FLOW: - { IOFlags flags; gio::inquire( "in.epw", flags ); WeatherFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); WeatherFileExists = flags.exists(); } if ( WeatherFileExists ) { OpenEPlusWeatherFile( ErrorsFound, true ); @@ -4442,11 +4443,11 @@ Label903: ; bool EPWOpen; int unitnumber; - { IOFlags flags; gio::inquire( "in.epw", flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); WeatherFileUnitNumber = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, "in.epw", flags ); if ( flags.err() ) goto Label9999; } + { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, SimulationManager::inputWeatherFile, flags ); if ( flags.err() ) goto Label9999; } if ( ProcessHeader ) { // Read in Header Information @@ -4530,7 +4531,7 @@ Label9999: ; // Make sure it's open - { IOFlags flags; gio::inquire( "in.epw", flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); } @@ -9466,7 +9467,7 @@ Label9998: ; // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/ezOptionParser.hpp b/src/EnergyPlus/ezOptionParser.hpp new file mode 100755 index 00000000000..2593fdefc4c --- /dev/null +++ b/src/EnergyPlus/ezOptionParser.hpp @@ -0,0 +1,2171 @@ +/* +This file is part of ezOptionParser. See MIT-LICENSE. + +Copyright (C) 2011,2012,2014 Remik Ziemlinski + +CHANGELOG + +v0.0.0 20110505 rsz Created. +v0.1.0 20111006 rsz Added validator. +v0.1.1 20111012 rsz Fixed validation of ulonglong. +v0.1.2 20111126 rsz Allow flag names start with alphanumeric (previously, flag had to start with alpha). +v0.1.3 20120108 rsz Created work-around for unique id generation with IDGenerator that avoids retarded c++ translation unit linker errors with single-header static variables. Forced inline on all methods to please retard compiler and avoid multiple def errors. +v0.1.4 20120629 Enforced MIT license on all files. +v0.2.0 20121120 Added parseIndex to OptionGroup. +v0.2.1 20130506 Allow disabling doublespace of OPTIONS usage descriptions. +v0.2.2 20140504 Jose Santiago added compiler warning fixes. + Bruce Shankle added a crash fix in description printing. +*/ +#ifndef EZ_OPTION_PARSER_H +#define EZ_OPTION_PARSER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ez { +#define DEBUGLINE() printf("%s:%d\n", __FILE__, __LINE__); + +/* ################################################################### */ +template +static T fromString(const std::string* s) { + std::istringstream stream (s->c_str()); + T t; + stream >> t; + return t; +}; +template +static T fromString(const char* s) { + std::istringstream stream (s); + T t; + stream >> t; + return t; +}; +/* ################################################################### */ +static inline bool isdigit(const std::string & s, int i=0) { + int n = s.length(); + for(; i < n; ++i) + switch(s[i]) { + case '0': case '1': case '2': + case '3': case '4': case '5': + case '6': case '7': case '8': case '9': break; + default: return false; + } + + return true; +}; +/* ################################################################### */ +static bool isdigit(const std::string * s, int i=0) { + int n = s->length(); + for(; i < n; ++i) + switch(s->at(i)) { + case '0': case '1': case '2': + case '3': case '4': case '5': + case '6': case '7': case '8': case '9': break; + default: return false; + } + + return true; +}; +/* ################################################################### */ +/* +Compare strings for opts, so short opt flags come before long format flags. +For example, -d < --dimension < --dmn, and also lower come before upper. The default STL std::string compare doesn't do that. +*/ +static bool CmpOptStringPtr(std::string * s1, std::string * s2) { + int c1,c2; + const char *s=s1->c_str(); + for(c1=0; c1 < (long int)s1->size(); ++c1) + if (isalnum(s[c1])) // locale sensitive. + break; + + s=s2->c_str(); + for(c2=0; c2 < (long int)s2->size(); ++c2) + if (isalnum(s[c2])) + break; + + // Test which has more symbols before its name. + if (c1 > c2) + return false; + else if (c1 < c2) + return true; + + // Both have same number of symbols, so compare first letter. + char char1 = s1->at(c1); + char char2 = s2->at(c2); + char lo1 = tolower(char1); + char lo2 = tolower(char2); + + if (lo1 != lo2) + return lo1 < lo2; + + // Their case doesn't match, so find which is lower. + char up1 = isupper(char1); + char up2 = isupper(char2); + + if (up1 && !up2) + return false; + else if (!up1 && up2) + return true; + + return (s1->compare(*s2)<0); +}; +/* ################################################################### */ +/* +Makes a vector of strings from one string, +splitting at (and excluding) delimiter "token". +*/ +static void SplitDelim( const std::string& s, const char token, std::vector * result) { + std::string::const_iterator i = s.begin(); + std::string::const_iterator j = s.begin(); + const std::string::const_iterator e = s.end(); + + while(i!=e) { + while(i!=e && *i++!=token); + std::string *newstr = new std::string(j, i); + if (newstr->at(newstr->size()-1) == token) newstr->erase(newstr->size()-1); + result->push_back(newstr); + j = i; + } +}; +/* ################################################################### */ +// Variant that uses deep copies and references instead of pointers (less efficient). +static void SplitDelim( const std::string& s, const char token, std::vector & result) { + std::string::const_iterator i = s.begin(); + std::string::const_iterator j = s.begin(); + const std::string::const_iterator e = s.end(); + + while(i!=e) { + while(i!=e && *i++!=token); + std::string newstr(j, i); + if (newstr.at(newstr.size()-1) == token) newstr.erase(newstr.size()-1); + result.push_back(newstr); + j = i; + } +}; +/* ################################################################### */ +// Variant that uses list instead of vector for efficient insertion, etc. +static void SplitDelim( const std::string& s, const char token, std::list & result) { + std::string::const_iterator i = s.begin(); + std::string::const_iterator j = s.begin(); + const std::string::const_iterator e = s.end(); + + while(i!=e) { + while(i!=e && *i++!=token); + std::string *newstr = new std::string(j, i); + if (newstr->at(newstr->size()-1) == token) newstr->erase(newstr->size()-1); + result.push_back(newstr); + j = i; + } +}; +/* ################################################################### */ +static void ToU1(std::string ** strings, unsigned char * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (unsigned char)atoi(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void ToS1(std::string ** strings, char * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (char)atoi(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void ToU2(std::string ** strings, unsigned short * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (unsigned short)atoi(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void ToS2(std::string ** strings, short * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (short)atoi(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void ToS4(std::string ** strings, int * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = atoi(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void ToU4(std::string ** strings, unsigned int * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (unsigned int)strtoul(strings[i]->c_str(), NULL, 0); + } +}; +/* ################################################################### */ +static void ToS8(std::string ** strings, long long * out, int n) { + for(int i=0; i < n; ++i) { + std::stringstream ss(strings[i]->c_str()); + ss >> out[i]; + } +}; +/* ################################################################### */ +static void ToU8(std::string ** strings, unsigned long long * out, int n) { + for(int i=0; i < n; ++i) { + std::stringstream ss(strings[i]->c_str()); + ss >> out[i]; + } +}; +/* ################################################################### */ +static void ToF(std::string ** strings, float * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (float)atof(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void ToD(std::string ** strings, double * out, int n) { + for(int i=0; i < n; ++i) { + out[i] = (double)atof(strings[i]->c_str()); + } +}; +/* ################################################################### */ +static void StringsToInts(std::vector & strings, std::vector & out) { + for(int i=0; i < (long int)strings.size(); ++i) { + out.push_back(atoi(strings[i].c_str())); + } +}; +/* ################################################################### */ +static void StringsToInts(std::vector * strings, std::vector * out) { + for(int i=0; i < (long int)strings->size(); ++i) { + out->push_back(atoi(strings->at(i)->c_str())); + } +}; +/* ################################################################### */ +static void StringsToLongs(std::vector & strings, std::vector & out) { + for(int i=0; i < (long int)strings.size(); ++i) { + out.push_back(atol(strings[i].c_str())); + } +}; +/* ################################################################### */ +static void StringsToLongs(std::vector * strings, std::vector * out) { + for(int i=0; i < (long int)strings->size(); ++i) { + out->push_back(atol(strings->at(i)->c_str())); + } +}; +/* ################################################################### */ +static void StringsToULongs(std::vector & strings, std::vector & out) { + for(int i=0; i < (long int)strings.size(); ++i) { + out.push_back(strtoul(strings[i].c_str(),0,0)); + } +}; +/* ################################################################### */ +static void StringsToULongs(std::vector * strings, std::vector * out) { + for(int i=0; i < (long int)strings->size(); ++i) { + out->push_back(strtoul(strings->at(i)->c_str(),0,0)); + } +}; +/* ################################################################### */ +static void StringsToFloats(std::vector & strings, std::vector & out) { + for(int i=0; i < (long int)strings.size(); ++i) { + out.push_back(atof(strings[i].c_str())); + } +}; +/* ################################################################### */ +static void StringsToFloats(std::vector * strings, std::vector * out) { + for(int i=0; i < (long int)strings->size(); ++i) { + out->push_back(atof(strings->at(i)->c_str())); + } +}; +/* ################################################################### */ +static void StringsToDoubles(std::vector & strings, std::vector & out) { + for(int i=0; i < (long int)strings.size(); ++i) { + out.push_back(atof(strings[i].c_str())); + } +}; +/* ################################################################### */ +static void StringsToDoubles(std::vector * strings, std::vector * out) { + for(int i=0; i < (long int)strings->size(); ++i) { + out->push_back(atof(strings->at(i)->c_str())); + } +}; +/* ################################################################### */ +static void StringsToStrings(std::vector * strings, std::vector * out) { + for(int i=0; i < (long int)strings->size(); ++i) { + out->push_back( *strings->at(i) ); + } +}; +/* ################################################################### */ +static void ToLowerASCII(std::string & s) { + int n = s.size(); + int i=0; + char c; + for(; i < n; ++i) { + c = s[i]; + if(c<='Z' && c>='A') + s[i] = c+32; + } +} +/* ################################################################### */ +static char** CommandLineToArgvA(char* CmdLine, int* _argc) { + char** argv; + char* _argv; + unsigned long len; + unsigned long argc; + char a; + unsigned long i, j; + + bool in_QM; + bool in_TEXT; + bool in_SPACE; + + len = strlen(CmdLine); + i = ((len+2)/2)*sizeof(void*) + sizeof(void*); + + argv = (char**)malloc(i + (len+2)*sizeof(char)); + + _argv = (char*)(((unsigned char*)argv)+i); + + argc = 0; + argv[argc] = _argv; + in_QM = false; + in_TEXT = false; + in_SPACE = true; + i = 0; + j = 0; + + while( (a = CmdLine[i]) ) { + if(in_QM) { + if( (a == '\"') || + (a == '\'')) // rsz. Added single quote. + { + in_QM = false; + } else { + _argv[j] = a; + j++; + } + } else { + switch(a) { + case '\"': + case '\'': // rsz. Added single quote. + in_QM = true; + in_TEXT = true; + if(in_SPACE) { + argv[argc] = _argv+j; + argc++; + } + in_SPACE = false; + break; + case ' ': + case '\t': + case '\n': + case '\r': + if(in_TEXT) { + _argv[j] = '\0'; + j++; + } + in_TEXT = false; + in_SPACE = true; + break; + default: + in_TEXT = true; + if(in_SPACE) { + argv[argc] = _argv+j; + argc++; + } + _argv[j] = a; + j++; + in_SPACE = false; + break; + } + } + i++; + } + _argv[j] = '\0'; + argv[argc] = NULL; + + (*_argc) = argc; + return argv; +}; +/* ################################################################### */ +// Create unique ids with static and still allow single header that avoids multiple definitions linker error. +class ezOptionParserIDGenerator { +public: + static ezOptionParserIDGenerator& instance () { static ezOptionParserIDGenerator Generator; return Generator; } + short next () { return ++_id; } +private: + ezOptionParserIDGenerator() : _id(-1) {} + short _id; +}; +/* ################################################################### */ +/* Validate a value by checking: +- if as string, see if converted value is within datatype's limits, +- and see if falls within a desired range, +- or see if within set of given list of values. + +If comparing with a range, the values list must contain one or two values. One value is required when comparing with <, <=, >, >=. Use two values when requiring a test such as list[0] */ + GE, /* value >= list[0] */ + GTLT, /* list[0] < value < list[1] */ + GELT, /* list[0] <= value < list[1] */ + GELE, /* list[0] <= value <= list[1] */ + GTLE, /* list[0] < value <= list[1] */ + IN /* if value is in list */ + }; + + enum TYPE { NOTYPE=0, S1, U1, S2, U2, S4, U4, S8, U8, F, D, T }; + enum TYPE2 { NOTYPE2=0, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, TEXT }; + + union { + unsigned char *u1; + char *s1; + unsigned short *u2; + short *s2; + unsigned int *u4; + int *s4; + unsigned long long *u8; + long long *s8; + float *f; + double *d; + std::string** t; + }; + + char op; + bool quiet; + short id; + char type; + int size; + bool insensitive; +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::~ezOptionValidator() { + reset(); +}; +/* ------------------------------------------------------------------- */ +void ezOptionValidator::reset() { + #define CLEAR(TYPE,P) case TYPE: if (P) delete [] P; P = 0; break; + switch(type) { + CLEAR(S1,s1); + CLEAR(U1,u1); + CLEAR(S2,s2); + CLEAR(U2,u2); + CLEAR(S4,s4); + CLEAR(U4,u4); + CLEAR(S8,s8); + CLEAR(U8,u8); + CLEAR(F,f); + CLEAR(D,d); + case T: + for(int i=0; i < size; ++i) + delete t[i]; + + delete [] t; + t = 0; + break; + default: break; + } + + size = 0; + op = NOOP; + type = NOTYPE; +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type) : s1(0), op(0), quiet(0), type(_type), size(0), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const char* list, int _size) : s1(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + s1 = new char[size]; + memcpy(s1, list, size); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned char* list, int _size) : u1(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + u1 = new unsigned char[size]; + memcpy(u1, list, size); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const short* list, int _size) : s2(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + s2 = new short[size]; + memcpy(s2, list, size*sizeof(short)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned short* list, int _size) : u2(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + u2 = new unsigned short[size]; + memcpy(u2, list, size*sizeof(unsigned short)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const int* list, int _size) : s4(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + s4 = new int[size]; + memcpy(s4, list, size*sizeof(int)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned int* list, int _size) : u4(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + u4 = new unsigned int[size]; + memcpy(u4, list, size*sizeof(unsigned int)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const long long* list, int _size) : s8(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + s8 = new long long[size]; + memcpy(s8, list, size*sizeof(long long)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned long long* list, int _size) : u8(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + u8 = new unsigned long long[size]; + memcpy(u8, list, size*sizeof(unsigned long long)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const float* list, int _size) : f(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + f = new float[size]; + memcpy(f, list, size*sizeof(float)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const double* list, int _size) : d(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { + id = ezOptionParserIDGenerator::instance().next(); + d = new double[size]; + memcpy(d, list, size*sizeof(double)); +}; +/* ------------------------------------------------------------------- */ +ezOptionValidator::ezOptionValidator(char _type, char _op, const char** list, int _size, bool _insensitive) : t(0), op(_op), quiet(0), type(_type), size(_size), insensitive(_insensitive) { + id = ezOptionParserIDGenerator::instance().next(); + t = new std::string*[size]; + int i=0; + + for(; i < size; ++i) { + t[i] = new std::string(list[i]); + } +}; +/* ------------------------------------------------------------------- */ +/* Less efficient but convenient ctor that parses strings to setup validator. +_type: s1, u1, s2, u2, ..., f, d, t +_op: lt, gt, ..., in +_list: comma-delimited string +*/ +ezOptionValidator::ezOptionValidator(const char* _type, const char* _op, const char* _list, bool _insensitive) : t(0), quiet(0), type(0), size(0), insensitive(_insensitive) { + id = ezOptionParserIDGenerator::instance().next(); + + switch(_type[0]) { + case 'u': + switch(_type[1]) { + case '1': type = U1; break; + case '2': type = U2; break; + case '4': type = U4; break; + case '8': type = U8; break; + default: break; + } + break; + case 's': + switch(_type[1]) { + case '1': type = S1; + break; + case '2': type = S2; break; + case '4': type = S4; break; + case '8': type = S8; break; + default: break; + } + break; + case 'f': type = F; break; + case 'd': type = D; break; + case 't': type = T; break; + default: + if (!quiet) + std::cerr << "ERROR: Unknown validator datatype \"" << _type << "\".\n"; + break; + } + + int nop = 0; + if (_op != 0) + nop = strlen(_op); + + switch(nop) { + case 0: op = NOOP; break; + case 2: + switch(_op[0]) { + case 'g': + switch(_op[1]) { + case 'e': op = GE; break; + default: op = GT; break; + } + break; + case 'i': op = IN; + break; + default: + switch(_op[1]) { + case 'e': op = LE; break; + default: op = LT; break; + } + break; + } + break; + case 4: + switch(_op[1]) { + case 'e': + switch(_op[3]) { + case 'e': op = GELE; break; + default: op = GELT; break; + } + break; + default: + switch(_op[3]) { + case 'e': op = GTLE; break; + default: op = GTLT; break; + } + break; + } + break; + default: + if (!quiet) + std::cerr << "ERROR: Unknown validator operation \"" << _op << "\".\n"; + break; + } + + if (_list == 0) return; + // Create list of strings and then cast to native datatypes. + std::string unsplit(_list); + std::list split; + std::list::iterator it; + SplitDelim(unsplit, ',', split); + size = split.size(); + std::string **strings = new std::string*[size]; + + int i = 0; + for(it = split.begin(); it != split.end(); ++it) + strings[i++] = *it; + + if (insensitive) + for(i=0; i < size; ++i) + ToLowerASCII(*strings[i]); + + #define FreeStrings() { \ + for(i=0; i < size; ++i)\ + delete strings[i];\ + delete [] strings;\ + } + + #define ToArray(T,P,Y) case T: P = new Y[size]; To##T(strings, P, size); FreeStrings(); break; + switch(type) { + ToArray(S1,s1,char); + ToArray(U1,u1,unsigned char); + ToArray(S2,s2,short); + ToArray(U2,u2,unsigned short); + ToArray(S4,s4,int); + ToArray(U4,u4,unsigned int); + ToArray(S8,s8,long long); + ToArray(U8,u8,unsigned long long); + ToArray(F,f,float); + ToArray(D,d,double); + case T: t = strings; break; /* Don't erase strings array. */ + default: break; + } +}; +/* ------------------------------------------------------------------- */ +void ezOptionValidator::print() { + printf("id=%d, op=%d, type=%d, size=%d, insensitive=%d\n", id, op, type, size, insensitive); +}; +/* ------------------------------------------------------------------- */ +bool ezOptionValidator::isValid(const std::string * valueAsString) { + if (valueAsString == 0) return false; + +#define CHECKRANGE(E,T) {\ + std::stringstream ss(valueAsString->c_str()); \ + long long E##value; \ + ss >> E##value; \ + long long E##min = static_cast(std::numeric_limits::min()); \ + if (E##value < E##min) { \ + if (!quiet) \ + std::cerr << "ERROR: Invalid value " << E##value << " is less than datatype min " << E##min << ".\n"; \ + return false; \ + } \ + \ + long long E##max = static_cast(std::numeric_limits::max()); \ + if (E##value > E##max) { \ + if (!quiet) \ + std::cerr << "ERROR: Invalid value " << E##value << " is greater than datatype max " << E##max << ".\n"; \ + return false; \ + } \ +} + // Check if within datatype limits. + if (type != T) { + switch(type) { + case S1: CHECKRANGE(S1,char); break; + case U1: CHECKRANGE(U1,unsigned char); break; + case S2: CHECKRANGE(S2,short); break; + case U2: CHECKRANGE(U2,unsigned short); break; + case S4: CHECKRANGE(S4,int); break; + case U4: CHECKRANGE(U4,unsigned int); break; + case S8: { + if ( (valueAsString->at(0) == '-') && + isdigit(valueAsString,1) && + (valueAsString->size() > 19) && + (valueAsString->compare(1, 19, "9223372036854775808") > 0) ) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << *valueAsString << " is less than datatype min -9223372036854775808.\n"; + return false; + } + + if (isdigit(valueAsString) && + (valueAsString->size() > 18) && + valueAsString->compare("9223372036854775807") > 0) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << *valueAsString << " is greater than datatype max 9223372036854775807.\n"; + return false; + } + } break; + case U8: { + if (valueAsString->compare("0") < 0) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << *valueAsString << " is less than datatype min 0.\n"; + return false; + } + + if (isdigit(valueAsString) && + (valueAsString->size() > 19) && + valueAsString->compare("18446744073709551615") > 0) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << *valueAsString << " is greater than datatype max 18446744073709551615.\n"; + return false; + } + } break; + case F: { + double dmax = static_cast(std::numeric_limits::max()); + double dvalue = atof(valueAsString->c_str()); + double dmin = -dmax; + if (dvalue < dmin) { + if (!quiet) { + fprintf(stderr, "ERROR: Invalid value %g is less than datatype min %g.\n", dvalue, dmin); + } + return false; + } + + if (dvalue > dmax) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << dvalue << " is greater than datatype max " << dmax << ".\n"; + return false; + } + } break; + case D: { + long double ldmax = static_cast(std::numeric_limits::max()); + std::stringstream ss(valueAsString->c_str()); + long double ldvalue; + ss >> ldvalue; + long double ldmin = -ldmax; + + if (ldvalue < ldmin) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << ldvalue << " is less than datatype min " << ldmin << ".\n"; + return false; + } + + if (ldvalue > ldmax) { + if (!quiet) + std::cerr << "ERROR: Invalid value " << ldvalue << " is greater than datatype max " << ldmax << ".\n"; + return false; + } + } break; + case NOTYPE: default: break; + } + } else { + if (op == IN) { + int i=0; + if (insensitive) { + std::string valueAsStringLower(*valueAsString); + ToLowerASCII(valueAsStringLower); + for(; i < size; ++i) { + if (valueAsStringLower.compare(t[i]->c_str()) == 0) + return true; + } + } else { + for(; i < size; ++i) { + if (valueAsString->compare(t[i]->c_str()) == 0) + return true; + } + } + return false; + } + } + + // Only check datatype limits, and return; + if (op == NOOP) return true; + +#define VALIDATE(T, U, LIST) { \ + /* Value string converted to true native type. */ \ + std::stringstream ss(valueAsString->c_str());\ + U v;\ + ss >> v;\ + /* Check if within list. */ \ + if (op == IN) { \ + T * last = LIST + size;\ + return (last != std::find(LIST, last, v)); \ + } \ + \ + /* Check if within user's custom range. */ \ + T v0, v1; \ + if (size > 0) { \ + v0 = LIST[0]; \ + } \ + \ + if (size > 1) { \ + v1 = LIST[1]; \ + } \ + \ + switch (op) {\ + case LT:\ + if (size > 0) {\ + return v < v0;\ + } else {\ + std::cerr << "ERROR: No value given to validate if " << v << " < X.\n";\ + return false;\ + }\ + break;\ + case LE:\ + if (size > 0) {\ + return v <= v0;\ + } else {\ + std::cerr << "ERROR: No value given to validate if " << v << " <= X.\n";\ + return false;\ + }\ + break;\ + case GT:\ + if (size > 0) {\ + return v > v0;\ + } else {\ + std::cerr << "ERROR: No value given to validate if " << v << " > X.\n";\ + return false;\ + }\ + break;\ + case GE:\ + if (size > 0) {\ + return v >= v0;\ + } else {\ + std::cerr << "ERROR: No value given to validate if " << v << " >= X.\n";\ + return false;\ + }\ + break;\ + case GTLT:\ + if (size > 1) {\ + return (v0 < v) && (v < v1);\ + } else {\ + std::cerr << "ERROR: Missing values to validate if X1 < " << v << " < X2.\n";\ + return false;\ + }\ + break;\ + case GELT:\ + if (size > 1) {\ + return (v0 <= v) && (v < v1);\ + } else {\ + std::cerr << "ERROR: Missing values to validate if X1 <= " << v << " < X2.\n";\ + return false;\ + }\ + break;\ + case GELE:\ + if (size > 1) {\ + return (v0 <= v) && (v <= v1);\ + } else {\ + std::cerr << "ERROR: Missing values to validate if X1 <= " << v << " <= X2.\n";\ + return false;\ + }\ + break;\ + case GTLE:\ + if (size > 1) {\ + return (v0 < v) && (v <= v1);\ + } else {\ + std::cerr << "ERROR: Missing values to validate if X1 < " << v << " <= X2.\n";\ + return false;\ + }\ + break;\ + case NOOP: case IN: default: break;\ + } \ + } + + switch(type) { + case U1: VALIDATE(unsigned char, int, u1); break; + case S1: VALIDATE(char, int, s1); break; + case U2: VALIDATE(unsigned short, int, u2); break; + case S2: VALIDATE(short, int, s2); break; + case U4: VALIDATE(unsigned int, unsigned int, u4); break; + case S4: VALIDATE(int, int, s4); break; + case U8: VALIDATE(unsigned long long, unsigned long long, u8); break; + case S8: VALIDATE(long long, long long, s8); break; + case F: VALIDATE(float, float, f); break; + case D: VALIDATE(double, double, d); break; + default: break; + } + + return true; +}; +/* ################################################################### */ +class OptionGroup { +public: + OptionGroup() : delim(0), expectArgs(0), isRequired(false), isSet(false) { } + + ~OptionGroup() { + int i; + for(i=0; i < (long int)flags.size(); ++i) + delete flags[i]; + + flags.clear(); + parseIndex.clear(); + clearArgs(); + }; + + inline void clearArgs(); + inline void getInt(int&); + inline void getLong(long&); + inline void getLongLong(long long&); + inline void getULong(unsigned long&); + inline void getULongLong(unsigned long long&); + inline void getFloat(float&); + inline void getDouble(double&); + inline void getString(std::string&); + inline void getInts(std::vector&); + inline void getLongs(std::vector&); + inline void getULongs(std::vector&); + inline void getFloats(std::vector&); + inline void getDoubles(std::vector&); + inline void getStrings(std::vector&); + inline void getMultiInts(std::vector< std::vector >&); + inline void getMultiLongs(std::vector< std::vector >&); + inline void getMultiULongs(std::vector< std::vector >&); + inline void getMultiFloats(std::vector< std::vector >&); + inline void getMultiDoubles(std::vector< std::vector >&); + inline void getMultiStrings(std::vector< std::vector >&); + + // defaults value regardless of being set by user. + std::string defaults; + // If expects arguments, this will delimit arg list. + char delim; + // If not 0, then number of delimited args. -1 for arbitrary number. + int expectArgs; + // Descriptive help message shown in usage instructions for option. + std::string help; + // 0 or 1. + bool isRequired; + // A list of flags that denote this option, i.e. -d, --dimension. + std::vector< std::string* > flags; + // If was set (or found). + bool isSet; + // Lists of arguments, per flag instance, after splitting by delimiter. + std::vector< std::vector< std::string* > * > args; + // Index where each group was parsed from input stream to track order. + std::vector parseIndex; +}; +/* ################################################################### */ +void OptionGroup::clearArgs() { + int i,j; + for(i=0; i < (long int)args.size(); ++i) { + for(j=0; j < (long int)args[i]->size(); ++j) + delete args[i]->at(j); + + delete args[i]; + } + + args.clear(); + isSet = false; +}; +/* ################################################################### */ +void OptionGroup::getInt(int & out) { + if (!isSet) { + if (defaults.empty()) + out = 0; + else + out = atoi(defaults.c_str()); + } else { + if (args.empty() || args[0]->empty()) + out = 0; + else { + out = atoi(args[0]->at(0)->c_str()); + } + } +}; +/* ################################################################### */ +void OptionGroup::getLong(long & out) { + if (!isSet) { + if (defaults.empty()) + out = 0; + else + out = atoi(defaults.c_str()); + } else { + if (args.empty() || args[0]->empty()) + out = 0; + else { + out = atol(args[0]->at(0)->c_str()); + } + } +}; +/* ################################################################### */ +void OptionGroup::getLongLong(long long & out) { + if (!isSet) { + if (defaults.empty()) + out = 0; + else { + std::stringstream ss(defaults.c_str()); + ss >> out; + } + } else { + if (args.empty() || args[0]->empty()) + out = 0; + else { + std::stringstream ss(args[0]->at(0)->c_str()); + ss >> out; + } + } +}; +/* ################################################################### */ +void OptionGroup::getULong(unsigned long & out) { + if (!isSet) { + if (defaults.empty()) + out = 0; + else + out = atoi(defaults.c_str()); + } else { + if (args.empty() || args[0]->empty()) + out = 0; + else { + out = strtoul(args[0]->at(0)->c_str(),0,0); + } + } +}; +/* ################################################################### */ +void OptionGroup::getULongLong(unsigned long long & out) { + if (!isSet) { + if (defaults.empty()) + out = 0; + else { + std::stringstream ss(defaults.c_str()); + ss >> out; + } + } else { + if (args.empty() || args[0]->empty()) + out = 0; + else { + std::stringstream ss(args[0]->at(0)->c_str()); + ss >> out; + } + } +}; +/* ################################################################### */ +void OptionGroup::getFloat(float & out) { + if (!isSet) { + if (defaults.empty()) + out = 0.0; + else + out = (float)atof(defaults.c_str()); + } else { + if (args.empty() || args[0]->empty()) + out = 0.0; + else { + out = (float)atof(args[0]->at(0)->c_str()); + } + } +}; +/* ################################################################### */ +void OptionGroup::getDouble(double & out) { + if (!isSet) { + if (defaults.empty()) + out = 0.0; + else + out = atof(defaults.c_str()); + } else { + if (args.empty() || args[0]->empty()) + out = 0.0; + else { + out = atof(args[0]->at(0)->c_str()); + } + } +}; +/* ################################################################### */ +void OptionGroup::getString(std::string & out) { + if (!isSet) { + out = defaults; + } else { + if (args.empty() || args[0]->empty()) + out = ""; + else { + out = *args[0]->at(0); + } + } +}; +/* ################################################################### */ +void OptionGroup::getInts(std::vector & out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + StringsToInts(strings, out); + } + } else { + if (!(args.empty() || args[0]->empty())) + StringsToInts(args[0], &out); + } +}; +/* ################################################################### */ +void OptionGroup::getLongs(std::vector & out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + StringsToLongs(strings, out); + } + } else { + if (!(args.empty() || args[0]->empty())) + StringsToLongs(args[0], &out); + } +}; +/* ################################################################### */ +void OptionGroup::getULongs(std::vector & out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + StringsToULongs(strings, out); + } + } else { + if (!(args.empty() || args[0]->empty())) + StringsToULongs(args[0], &out); + } +}; +/* ################################################################### */ +void OptionGroup::getFloats(std::vector & out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + StringsToFloats(strings, out); + } + } else { + if (!(args.empty() || args[0]->empty())) + StringsToFloats(args[0], &out); + } +}; +/* ################################################################### */ +void OptionGroup::getDoubles(std::vector & out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + StringsToDoubles(strings, out); + } + } else { + if (!(args.empty() || args[0]->empty())) + StringsToDoubles(args[0], &out); + } +}; +/* ################################################################### */ +void OptionGroup::getStrings(std::vector& out) { + if (!isSet) { + if (!defaults.empty()) { + SplitDelim(defaults, delim, out); + } + } else { + if (!(args.empty() || args[0]->empty())) + StringsToStrings(args[0], &out); + } +}; +/* ################################################################### */ +void OptionGroup::getMultiInts(std::vector< std::vector >& out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + if (out.size() < 1) out.resize(1); + StringsToInts(strings, out[0]); + } + } else { + if (!args.empty()) { + int n = args.size(); + if ((long int)out.size() < n) out.resize(n); + for(int i=0; i < n; ++i) { + StringsToInts(args[i], &out[i]); + } + } + } +}; +/* ################################################################### */ +void OptionGroup::getMultiLongs(std::vector< std::vector >& out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + if (out.size() < 1) out.resize(1); + StringsToLongs(strings, out[0]); + } + } else { + if (!args.empty()) { + int n = args.size(); + if ((long int)out.size() < n) out.resize(n); + for(int i=0; i < n; ++i) { + StringsToLongs(args[i], &out[i]); + } + } + } +}; +/* ################################################################### */ +void OptionGroup::getMultiULongs(std::vector< std::vector >& out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + if (out.size() < 1) out.resize(1); + StringsToULongs(strings, out[0]); + } + } else { + if (!args.empty()) { + int n = args.size(); + if ((long int)out.size() < n) out.resize(n); + for(int i=0; i < n; ++i) { + StringsToULongs(args[i], &out[i]); + } + } + } +}; +/* ################################################################### */ +void OptionGroup::getMultiFloats(std::vector< std::vector >& out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + if (out.size() < 1) out.resize(1); + StringsToFloats(strings, out[0]); + } + } else { + if (!args.empty()) { + int n = args.size(); + if ((long int)out.size() < n) out.resize(n); + for(int i=0; i < n; ++i) { + StringsToFloats(args[i], &out[i]); + } + } + } +}; +/* ################################################################### */ +void OptionGroup::getMultiDoubles(std::vector< std::vector >& out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + if (out.size() < 1) out.resize(1); + StringsToDoubles(strings, out[0]); + } + } else { + if (!args.empty()) { + int n = args.size(); + if ((long int)out.size() < n) out.resize(n); + for(int i=0; i < n; ++i) { + StringsToDoubles(args[i], &out[i]); + } + } + } +}; +/* ################################################################### */ +void OptionGroup::getMultiStrings(std::vector< std::vector >& out) { + if (!isSet) { + if (!defaults.empty()) { + std::vector< std::string > strings; + SplitDelim(defaults, delim, strings); + if (out.size() < 1) out.resize(1); + out[0] = strings; + } + } else { + if (!args.empty()) { + int n = args.size(); + if ((long int)out.size() < n) out.resize(n); + + for(int i=0; i < n; ++i) { + for(int j=0; j < (long int)args[i]->size(); ++j) + out[i].push_back( *args[i]->at(j) ); + } + } + } +}; +/* ################################################################### */ +typedef std::map< int, ezOptionValidator* > ValidatorMap; + +class ezOptionParser { +public: + // How to layout usage descriptions with the option flags. + enum Layout { ALIGN, INTERLEAVE, STAGGER }; + + inline ~ezOptionParser(); + + inline void add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, ezOptionValidator* validator=0); + inline void add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, ezOptionValidator* validator=0); + inline void add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, const char * flag3, ezOptionValidator* validator=0); + inline void add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, const char * flag3, const char * flag4, ezOptionValidator* validator=0); + inline bool exportFile(const char * filename, bool all=false); + inline OptionGroup * get(const char * name); + inline void getUsage(std::string & usage, int width=80, Layout layout=ALIGN); + inline void getVersion(std::string & version, int width=80, Layout layout=ALIGN); + inline void getUsageDescriptions(std::string & usage, int width=80, Layout layout=STAGGER); + inline bool gotExpected(std::vector & badOptions); + inline bool gotRequired(std::vector & badOptions); + inline bool gotValid(std::vector & badOptions, std::vector & badArgs); + inline bool importFile(const char * filename, char comment='#'); + inline int isSet(const char * name); + inline int isSet(std::string & name); + inline void parse(int argc, const char * argv[]); + inline void prettyPrint(std::string & out); + inline void reset(); + inline void resetArgs(); + + // Insert extra empty line betwee each option's usage description. + char doublespace; + // General description in human language on what the user's tool does. + // It's the first section to get printed in the full usage message. + std::string overview; + std::string overview1; + std::string overview2; + // A synopsis of command and options usage to show expected order of input arguments. + // It's the second section to get printed in the full usage message. + std::string syntax; + // Example (third) section in usage message. + std::string example; + // Final section printed in usage message. For contact, copyrights, version info. + std::string footer; + // Map from an option to an Id of its parent group. + std::map< std::string, int > optionGroupIds; + // Unordered collection of the option groups. + std::vector< OptionGroup* > groups; + // Store unexpected args in input. + std::vector< std::string* > unknownArgs; + // List of args that occur left-most before first option flag. + std::vector< std::string* > firstArgs; + // List of args that occur after last right-most option flag and its args. + std::vector< std::string* > lastArgs; + // List of validators. + ValidatorMap validators; + // Maps group id to a validator index into vector of validators. Validator index is -1 if there is no validator for group. + std::map< int, int > groupValidators; +}; +/* ################################################################### */ +ezOptionParser::~ezOptionParser() { + reset(); +} +/* ################################################################### */ +void ezOptionParser::reset() { + this->doublespace = 1; + + int i; + for(i=0; i < (long int)groups.size(); ++i) + delete groups[i]; + groups.clear(); + + for(i=0; i < (long int)unknownArgs.size(); ++i) + delete unknownArgs[i]; + unknownArgs.clear(); + + for(i=0; i < (long int)firstArgs.size(); ++i) + delete firstArgs[i]; + firstArgs.clear(); + + for(i=0; i < (long int)lastArgs.size(); ++i) + delete lastArgs[i]; + lastArgs.clear(); + + ValidatorMap::iterator it; + for(it = validators.begin(); it != validators.end(); ++it) + delete it->second; + + validators.clear(); + optionGroupIds.clear(); + groupValidators.clear(); +}; +/* ################################################################### */ +void ezOptionParser::resetArgs() { + int i; + for(i=0; i < (long int)groups.size(); ++i) + groups[i]->clearArgs(); + + for(i=0; i < (long int)unknownArgs.size(); ++i) + delete unknownArgs[i]; + unknownArgs.clear(); + + for(i=0; i < (long int)firstArgs.size(); ++i) + delete firstArgs[i]; + firstArgs.clear(); + + for(i=0; i < (long int)lastArgs.size(); ++i) + delete lastArgs[i]; + lastArgs.clear(); +}; +/* ################################################################### */ +void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, ezOptionValidator* validator) { + int id = this->groups.size(); + OptionGroup * g = new OptionGroup; + g->defaults = defaults; + g->isRequired = required; + g->expectArgs = expectArgs; + g->delim = delim; + g->isSet = 0; + g->help = help; + std::string *f1 = new std::string(flag1); + g->flags.push_back( f1 ); + this->optionGroupIds[flag1] = id; + this->groups.push_back(g); + + if (validator) { + int vid = validator->id; + validators[vid] = validator; + groupValidators[id] = vid; + } else { + groupValidators[id] = -1; + } +}; +/* ################################################################### */ +void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, ezOptionValidator* validator) { + int id = this->groups.size(); + OptionGroup * g = new OptionGroup; + g->defaults = defaults; + g->isRequired = required; + g->expectArgs = expectArgs; + g->delim = delim; + g->isSet = 0; + g->help = help; + std::string *f1 = new std::string(flag1); + g->flags.push_back( f1 ); + std::string *f2 = new std::string(flag2); + g->flags.push_back( f2 ); + this->optionGroupIds[flag1] = id; + this->optionGroupIds[flag2] = id; + + this->groups.push_back(g); + + if (validator) { + int vid = validator->id; + validators[vid] = validator; + groupValidators[id] = vid; + } else { + groupValidators[id] = -1; + } +}; +/* ################################################################### */ +void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, const char * flag3, ezOptionValidator* validator) { + int id = this->groups.size(); + OptionGroup * g = new OptionGroup; + g->defaults = defaults; + g->isRequired = required; + g->expectArgs = expectArgs; + g->delim = delim; + g->isSet = 0; + g->help = help; + std::string *f1 = new std::string(flag1); + g->flags.push_back( f1 ); + std::string *f2 = new std::string(flag2); + g->flags.push_back( f2 ); + std::string *f3 = new std::string(flag3); + g->flags.push_back( f3 ); + this->optionGroupIds[flag1] = id; + this->optionGroupIds[flag2] = id; + this->optionGroupIds[flag3] = id; + + this->groups.push_back(g); + + if (validator) { + int vid = validator->id; + validators[vid] = validator; + groupValidators[id] = vid; + } else { + groupValidators[id] = -1; + } +}; +/* ################################################################### */ +void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, const char * flag3, const char * flag4, ezOptionValidator* validator) { + int id = this->groups.size(); + OptionGroup * g = new OptionGroup; + g->defaults = defaults; + g->isRequired = required; + g->expectArgs = expectArgs; + g->delim = delim; + g->isSet = 0; + g->help = help; + std::string *f1 = new std::string(flag1); + g->flags.push_back( f1 ); + std::string *f2 = new std::string(flag2); + g->flags.push_back( f2 ); + std::string *f3 = new std::string(flag3); + g->flags.push_back( f3 ); + std::string *f4 = new std::string(flag4); + g->flags.push_back( f4 ); + this->optionGroupIds[flag1] = id; + this->optionGroupIds[flag2] = id; + this->optionGroupIds[flag3] = id; + this->optionGroupIds[flag4] = id; + + this->groups.push_back(g); + + if (validator) { + int vid = validator->id; + validators[vid] = validator; + groupValidators[id] = vid; + } else { + groupValidators[id] = -1; + } +}; +/* ################################################################### */ +bool ezOptionParser::exportFile(const char * filename, bool all) { + int i; + std::string out; + bool quote; + + // Export the first args, except the program name, so start from 1. + for(i=1; i < (long int)firstArgs.size(); ++i) { + quote = ((firstArgs[i]->find_first_of(" \t") != std::string::npos) && (firstArgs[i]->find_first_of("\'\"") == std::string::npos)); + + if (quote) + out.append("\""); + + out.append(*firstArgs[i]); + if (quote) + out.append("\""); + + out.append(" "); + } + + if (firstArgs.size() > 1) + out.append("\n"); + + std::vector stringPtrs(groups.size()); + int m; + int n = groups.size(); + for(i=0; i < n; ++i) { + stringPtrs[i] = groups[i]->flags[0]; + } + + OptionGroup *g; + // Sort first flag of each group with other groups. + std::sort(stringPtrs.begin(), stringPtrs.end(), CmpOptStringPtr); + for(i=0; i < n; ++i) { + g = get(stringPtrs[i]->c_str()); + if (g->isSet || all) { + if (!g->isSet || g->args.empty()) { + if (!g->defaults.empty()) { + out.append(*stringPtrs[i]); + out.append(" "); + quote = ((g->defaults.find_first_of(" \t") != std::string::npos) && (g->defaults.find_first_of("\'\"") == std::string::npos)); + if (quote) + out.append("\""); + + out.append(g->defaults); + if (quote) + out.append("\""); + + out.append("\n"); + } + } else { + int n = g->args.size(); + for(int j=0; j < n; ++j) { + out.append(*stringPtrs[i]); + out.append(" "); + m = g->args[j]->size(); + + for(int k=0; k < m; ++k) { + quote = ( (*g->args[j]->at(k)).find_first_of(" \t") != std::string::npos ); + if (quote) + out.append("\""); + + out.append(*g->args[j]->at(k)); + if (quote) + out.append("\""); + + if ((g->delim) && ((k+1) != m)) + out.append(1,g->delim); + } + out.append("\n"); + } + } + } + } + + // Export the last args. + for(i=0; i < (long int)lastArgs.size(); ++i) { + quote = ( lastArgs[i]->find_first_of(" \t") != std::string::npos ); + if (quote) + out.append("\""); + + out.append(*lastArgs[i]); + if (quote) + out.append("\""); + + out.append(" "); + } + + std::ofstream file(filename); + if (!file.is_open()) + return false; + + file << out; + file.close(); + + return true; +}; +/* ################################################################### */ +// Does not overwrite current options. +// Returns true if file was read successfully. +// So if this is used before parsing CLI, then option values will reflect +// this file, but if used after parsing CLI, then values will contain +// both CLI values and file's values. +// +// Comment lines are allowed if prefixed with #. +// Strings should be quoted as usual. +bool ezOptionParser::importFile(const char * filename, char comment) { + std::ifstream file (filename, std::ios::in | std::ios::ate); + if (!file.is_open()) + return false; + + // Read entire file contents. + std::ifstream::pos_type size = file.tellg(); + char * memblock = new char[(int)size+1]; // Add one for end of string. + file.seekg (0, std::ios::beg); + file.read (memblock, size); + memblock[size] = '\0'; + file.close(); + + // Find comment lines. + std::list lines; + std::string memblockstring(memblock); + delete[] memblock; + SplitDelim(memblockstring, '\n', lines); + int i,j,n; + std::list::iterator iter; + std::vector sq, dq; // Single and double quote indices. + std::vector::iterator lo; // For searching quote indices. + size_t pos; + const char *str; + std::string *line; + // Find all single and double quotes to correctly handle comment tokens. + for(iter=lines.begin(); iter != lines.end(); ++iter) { + line = *iter; + str = line->c_str(); + n = line->size(); + sq.clear(); + dq.clear(); + if (n) { + // If first char is comment, then erase line and continue. + pos = line->find_first_not_of(" \t\r"); + if ((pos==std::string::npos) || (line->at(pos)==comment)) { + line->erase(); + continue; + } else { + // Erase whitespace prefix. + line->erase(0,pos); + n = line->size(); + } + + if (line->at(0)=='"') + dq.push_back(0); + + if (line->at(0)=='\'') + sq.push_back(0); + } else { // Empty line. + continue; + } + + for(i=1; i < n; ++i) { + if ( (str[i]=='"') && (str[i-1]!='\\') ) + dq.push_back(i); + else if ( (str[i]=='\'') && (str[i-1]!='\\') ) + sq.push_back(i); + } + // Scan for comments, and when found, check bounds of quotes. + // Start with second char because already checked first char. + for(i=1; i < n; ++i) { + if ( (line->at(i)==comment) && (line->at(i-1)!='\\') ) { + // If within open/close quote pair, then not real comment. + if (sq.size()) { + lo = std::lower_bound(sq.begin(), sq.end(), i); + // All start of strings will be even indices, closing quotes is odd indices. + j = (int)(lo-sq.begin()); + if ( (j % 2) == 0) { // Even implies comment char not in quote pair. + // Erase from comment char to end of line. + line->erase(i); + break; + } + } else if (dq.size()) { + // Repeat tests for double quotes. + lo = std::lower_bound(dq.begin(), dq.end(), i); + j = (int)(lo-dq.begin()); + if ( (j % 2) == 0) { + line->erase(i); + break; + } + } else { + // Not in quotes. + line->erase(i); + break; + } + } + } + } + + std::string cmd; + // Convert list to string without newlines to simulate commandline. + for(iter=lines.begin(); iter != lines.end(); ++iter) { + if (! (*iter)->empty()) { + cmd.append(**iter); + cmd.append(" "); + } + } + + // Now parse as if from command line. + int argc=0; + char** argv = CommandLineToArgvA((char*)cmd.c_str(), &argc); + + // Parse. + parse(argc, (const char**)argv); + if (argv) free(argv); + for(iter=lines.begin(); iter != lines.end(); ++iter) + delete *iter; + + return true; +}; +/* ################################################################### */ +int ezOptionParser::isSet(const char * name) { + std::string sname(name); + + if (this->optionGroupIds.count(sname)) { + return this->groups[this->optionGroupIds[sname]]->isSet; + } + + return 0; +}; +/* ################################################################### */ +int ezOptionParser::isSet(std::string & name) { + if (this->optionGroupIds.count(name)) { + return this->groups[this->optionGroupIds[name]]->isSet; + } + + return 0; +}; +/* ################################################################### */ +OptionGroup * ezOptionParser::get(const char * name) { + if (optionGroupIds.count(name)) { + return groups[optionGroupIds[name]]; + } + + return 0; +}; +/* ################################################################### */ +void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { + + usage.append(overview); + usage.append(overview1); + usage.append(overview2); + usage.append("\n\n"); + usage.append("USAGE: "); + usage.append(syntax); + usage.append("\n\nOPTIONS:\n\n"); + getUsageDescriptions(usage, width, layout); + + if (!example.empty()) { + usage.append("EXAMPLES:\n\n"); + usage.append(example); + } + + if (!footer.empty()) { + usage.append(footer); + } +}; +/* ################################################################### */ +void ezOptionParser::getVersion(std::string & version, int width, Layout layout) { + + version.append(overview); + version.append(overview1); + version.append(overview2); + version.append("\n\n"); +}; +/* ################################################################### */ +// Creates 2 column formatted help descriptions for each option flag. +void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout layout) { + // Sort each flag list amongst each group. + int i; + // Store index of flag groups before sort for easy lookup later. + std::map stringPtrToIndexMap; + std::vector stringPtrs(groups.size()); + + for(i=0; i < (long int)groups.size(); ++i) { + std::sort(groups[i]->flags.begin(), groups[i]->flags.end(), CmpOptStringPtr); + stringPtrToIndexMap[groups[i]->flags[0]] = i; + stringPtrs[i] = groups[i]->flags[0]; + } + + size_t j, k; + std::string opts; + std::vector sortedOpts; + // Sort first flag of each group with other groups. + std::sort(stringPtrs.begin(), stringPtrs.end(), CmpOptStringPtr); + for(i=0; i < (long int)groups.size(); ++i) { + //printf("DEBUG:%d: %d %d %s\n", __LINE__, i, stringPtrToIndexMap[stringPtrs[i]], stringPtrs[i]->c_str()); + k = stringPtrToIndexMap[stringPtrs[i]]; + opts.clear(); + for(j=0; j < groups[k]->flags.size()-1; ++j) { + opts.append(*groups[k]->flags[j]); + opts.append(", "); + + if ((long int)opts.size() > width) + opts.append("\n"); + } + // The last flag. No need to append comma anymore. + opts.append( *groups[k]->flags[j] ); + + if (groups[k]->expectArgs) { + opts.append(" ARG"); + + if (groups[k]->delim) { + opts.append("1["); + opts.append(1, groups[k]->delim); + opts.append("ARGn]"); + } + } + + sortedOpts.push_back(opts); + } + + // Each option group will use this to build multiline help description. + std::list desc; + // Number of whitespaces from start of line to description (interleave layout) or + // gap between flag names and description (align, stagger layouts). + int gutter = 3; + + // Find longest opt flag string to set column start for help usage descriptions. + int maxlen=0; + if (layout == ALIGN) { + for(i=0; i < (long int)groups.size(); ++i) { + if (maxlen < (long int)sortedOpts[i].size()) + maxlen = sortedOpts[i].size(); + } + } + + // The amount of space remaining on a line for help text after flags. + int helpwidth; + std::list::iterator cIter, insertionIter; + size_t pos; + for(i=0; i < (long int)groups.size(); ++i) { + k = stringPtrToIndexMap[stringPtrs[i]]; + + if (layout == STAGGER) + maxlen = sortedOpts[i].size(); + + int pad = gutter + maxlen; + helpwidth = width - pad; + + // All the following split-fu could be optimized by just using substring (offset, length) tuples, but just to get it done, we'll do some not-too expensive string copying. + SplitDelim(groups[k]->help, '\n', desc); + // Split lines longer than allowable help width. + for(insertionIter=desc.begin(), cIter=insertionIter++; + cIter != desc.end(); + cIter=insertionIter++) { + if ((long int)((*cIter)->size()) > helpwidth) { + // Get pointer to next string to insert new strings before it. + std::string *rem = *cIter; + // Remove this line and add back in pieces. + desc.erase(cIter); + // Loop until remaining string is short enough. + while ((long int)rem->size() > helpwidth) { + // Find whitespace to split before helpwidth. + if (rem->at(helpwidth) == ' ') { + // If word ends exactly at helpwidth, then split after it. + pos = helpwidth; + } else { + // Otherwise, split occurs midword, so find whitespace before this word. + pos = rem->rfind(" ", helpwidth); + } + // Insert split string. + desc.insert(insertionIter, new std::string(*rem, 0, pos)); + // Now skip any whitespace to start new line. + pos = rem->find_first_not_of(' ', pos); + rem->erase(0, pos); + } + + if (rem->size()) + desc.insert(insertionIter, rem); + else + delete rem; + } + } + + usage.append(sortedOpts[i]); + if (layout != INTERLEAVE) + // Add whitespace between option names and description. + usage.append(pad - sortedOpts[i].size(), ' '); + else { + usage.append("\n"); + usage.append(gutter, ' '); + } + + if (desc.size() > 0) { // Crash fix by Bruce Shankle. + // First line already padded above (before calling SplitDelim) after option flag names. + cIter = desc.begin(); + usage.append(**cIter); + usage.append("\n"); + // Now inject the pad for each line. + for(++cIter; cIter != desc.end(); ++cIter) { + usage.append(pad, ' '); + usage.append(**cIter); + usage.append("\n"); + } + + if (this->doublespace) usage.append("\n"); + + for(cIter=desc.begin(); cIter != desc.end(); ++cIter) + delete *cIter; + + desc.clear(); + } + + } +}; +/* ################################################################### */ +bool ezOptionParser::gotExpected(std::vector & badOptions) { + int i,j; + + for(i=0; i < (long int)groups.size(); ++i) { + OptionGroup *g = groups[i]; + // If was set, ensure number of args is correct. + if (g->isSet) { + if ((g->expectArgs != 0) && g->args.empty()) { + badOptions.push_back(*g->flags[0]); + continue; + } + + for(j=0; j < (long int)g->args.size(); ++j) { + if ((g->expectArgs != -1) && (g->expectArgs != (long int)g->args[j]->size())) + badOptions.push_back(*g->flags[0]); + } + } + } + + return badOptions.empty(); +}; +/* ################################################################### */ +bool ezOptionParser::gotRequired(std::vector & badOptions) { + int i; + + for(i=0; i < (long int)groups.size(); ++i) { + OptionGroup *g = groups[i]; + // Simple case when required but user never set it. + if (g->isRequired && (!g->isSet)) { + badOptions.push_back(*g->flags[0]); + continue; + } + } + + return badOptions.empty(); +}; +/* ################################################################### */ +bool ezOptionParser::gotValid(std::vector & badOptions, std::vector & badArgs) { + int groupid, validatorid; + std::map< int, int >::iterator it; + + for(it = groupValidators.begin(); it != groupValidators.end(); ++it) { + groupid = it->first; + validatorid = it->second; + if (validatorid < 0) continue; + + OptionGroup *g = groups[groupid]; + ezOptionValidator *v = validators[validatorid]; + bool nextgroup = false; + + for (int i = 0; i < (long int)g->args.size(); ++i) { + if (nextgroup) break; + std::vector< std::string* > * args = g->args[i]; + for (int j = 0; j < (long int)args->size(); ++j) { + if (!v->isValid(args->at(j))) { + badOptions.push_back(*g->flags[0]); + badArgs.push_back(*args->at(j)); + nextgroup = true; + break; + } + } + } + } + + return badOptions.empty(); +}; +/* ################################################################### */ +void ezOptionParser::parse(int argc, const char * argv[]) { + if (argc < 1) return; + + /* + std::map::iterator it; + for ( it=optionGroupIds.begin() ; it != optionGroupIds.end(); it++ ) + std::cout << (*it).first << " => " << (*it).second << std::endl; + */ + + int i, k, firstOptIndex=0, lastOptIndex=0; + std::string s; + OptionGroup *g; + + for(i=0; i < argc; ++i) { + s = argv[i]; + + if (optionGroupIds.count(s)) + break; + } + + firstOptIndex = i; + + if (firstOptIndex == argc) { + // No flags encountered, so set last args. + this->firstArgs.push_back(new std::string(argv[0])); + + for(k=1; k < argc; ++k) + this->lastArgs.push_back(new std::string(argv[k])); + + return; + } + + // Store initial args before opts appear. + for(k=0; k < i; ++k) { + this->firstArgs.push_back(new std::string(argv[k])); + } + + for(; i < argc; ++i) { + s = argv[i]; + + if (optionGroupIds.count(s)) { + k = optionGroupIds[s]; + g = groups[k]; + g->isSet = 1; + g->parseIndex.push_back(i); + + if (g->expectArgs) { + // Read ahead to get args. + ++i; + if (i >= argc) return; + g->args.push_back(new std::vector); + SplitDelim(argv[i], g->delim, g->args.back()); + } + lastOptIndex = i; + } + } + + // Scan for unknown opts/arguments. + for(i=firstOptIndex; i <= lastOptIndex; ++i) { + s = argv[i]; + + if (optionGroupIds.count(s)) { + k = optionGroupIds[s]; + g = groups[k]; + if (g->expectArgs) { + // Read ahead for args and skip them. + ++i; + } + } else { + unknownArgs.push_back(new std::string(argv[i])); + } + } + + if ( lastOptIndex >= (argc-1) ) return; + + // Store final args without flags. + for(k=lastOptIndex + 1; k < argc; ++k) { + this->lastArgs.push_back(new std::string(argv[k])); + } +}; +/* ################################################################### */ +void ezOptionParser::prettyPrint(std::string & out) { + char tmp[256]; + int i,j,k; + + out += "First Args:\n"; + for(i=0; i < (long int)firstArgs.size(); ++i) { + sprintf(tmp, "%d: %s\n", i+1, firstArgs[i]->c_str()); + out += tmp; + } + + // Sort the option flag names. + int n = groups.size(); + std::vector stringPtrs(n); + for(i=0; i < n; ++i) { + stringPtrs[i] = groups[i]->flags[0]; + } + + // Sort first flag of each group with other groups. + std::sort(stringPtrs.begin(), stringPtrs.end(), CmpOptStringPtr); + + out += "\nOptions:\n"; + OptionGroup *g; + for(i=0; i < n; ++i) { + g = get(stringPtrs[i]->c_str()); + out += "\n"; + // The flag names: + for(j=0; j < (long int)g->flags.size()-1; ++j) { + sprintf(tmp, "%s, ", g->flags[j]->c_str()); + out += tmp; + } + sprintf(tmp, "%s:\n", g->flags.back()->c_str()); + out += tmp; + + if (g->isSet) { + if (g->expectArgs) { + if (g->args.empty()) { + sprintf(tmp, "%s (default)\n", g->defaults.c_str()); + out += tmp; + } else { + for(k=0; k < (long int)g->args.size(); ++k) { + for(j=0; j < (long int)g->args[k]->size()-1; ++j) { + sprintf(tmp, "%s%c", g->args[k]->at(j)->c_str(), g->delim); + out += tmp; + } + sprintf(tmp, "%s\n", g->args[k]->back()->c_str()); + out += tmp; + } + } + } else { // Set but no args expected. + sprintf(tmp, "Set\n"); + out += tmp; + } + } else { + sprintf(tmp, "Not set\n"); + out += tmp; + } + } + + out += "\nLast Args:\n"; + for(i=0; i < (long int)lastArgs.size(); ++i) { + sprintf(tmp, "%d: %s\n", i+1, lastArgs[i]->c_str()); + out += tmp; + } + + out += "\nUnknown Args:\n"; + for(i=0; i < (long int)unknownArgs.size(); ++i) { + sprintf(tmp, "%d: %s\n", i+1, unknownArgs[i]->c_str()); + out += tmp; + } +}; +} +/* ################################################################### */ +#endif /* EZ_OPTION_PARSER_H */ diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 3ffa0473117..045f5c9f6f3 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -24,18 +24,32 @@ #include #include #include +#include #include #include #include #include +#include // Added by Monika Sharma for CLI +#include "ezOptionParser.hpp" // Added by Monika Sharma for CLI +//#include + +using namespace ez; +using namespace std; +//using namespace vif; + +void Usage(ezOptionParser& opt) { + string usage; + opt.getUsage(usage); + cout << usage; +}; + int -main() +main(int argc, const char * argv[]) { // Using/Aliasing using namespace EnergyPlus; - - // NOTICE + // NOTICE // Copyright © 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the // University of California through Ernest Orlando Lawrence Berkeley National Laboratory. All rights @@ -209,9 +223,217 @@ main() using namespace InputProcessor; using namespace OutputProcessor; using namespace SimulationManager; + using namespace OutputReportTabular; using ScheduleManager::ReportOrphanSchedules; using FluidProperties::ReportOrphanFluids; using Psychrometrics::ShowPsychrometricSummary; + + ///////// Added for CLI ///////////////////////////// + ezOptionParser opt; + + opt.overview = "\n*******************************************\nCopyright (C) 2012-2014 Big Ladder Software\nWeb: www.bigladdersoftware.com\n"; + opt.overview1 = VerString; + opt.overview2 = "\n*******************************************\n"; + opt.syntax = "./EnergyPlus -df InputFile.idf -i Energy+.idd -w WeatherFile.epw -o OutFile.csv"; + + opt.add( + "", // Default. + 0, // Required? + 1, // Number of args expected. + 0, // Delimiter if expecting multiple args. + "Usage information displayed on top", // Help description. + "-h", // Flag token. + "-help", // Flag token. + "--help", // Flag token. + "--usage" // Flag token. + ); + + opt.add( + "", + 0, + 1, + 0, + "Options to get version control", + "-v", + "--v", + "-version", + "--version" + ); + + opt.add( + "in.idf", + 0, + 1, + 0, + "Input file to process", + "-df", + "--df" + //"--in", + //"--input" + ); + + opt.add( + "in.epw", + 0, + 1, + 0, + "Input weather file to process", + "-w", + "-wea", + "--w", + "--wea" + ); + + opt.add( + "Energy+.idd", + 0, + 1, + 0, + "Input energy file to process", + "-i", + "-in", + "--i", + "--in" + ); + + opt.add( + "eplustbl.csv", + 0, + 1, + 0, + "Output file", + "-o", + "-out", + "--o", + "--out" + ); + + + opt.parse(argc, argv); + if(argv[1]==0) cout<<"No arguments provided"< badOptions; + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) + cerr << "ERROR: Got unexpected number of arguments for option " << badOptions[i] << ".\n\n"; + + opt.getUsage(usage); + cout << usage; + return 1; + } + +/* if(!opt.gotRequired(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) + std::cerr << "ERROR: Missing required option " << badOptions[i] << ".\n\n"; + // Usage(opt); + opt.getUsage(usage); + return 1; + } + + std::vector badArgs; + if(!opt.gotValid(badOptions, badArgs)) { + for(int i=0; i < badOptions.size(); ++i) + std::cerr << "ERROR: Got invalid argument \"" << badArgs[i] << "\" for option " << badOptions[i] << ".\n\n"; + + //Usage(opt); + return 1; + } + + if (opt.lastArgs.size() < 2) { + cout << "Zeroth argument = " << argv[0] << '\t'<< argv[1] << '\t'<< argv[2] << endl; + cerr << "\n\n-------------------------------------------\n"; + cerr << "** EnergyPlus in default configuration **\n"; + cerr << "-------------------------------------------\n"; + Usage(opt); + } + */ // gotRequired, gotValid and lastArgs.size() options aren't working at the moment. + + Usage(opt); //Ugly at the moment + + int status = 0; + std::istream* instream; + std::string input_filename; + std::string input_weatherFile; + std::string input_energyFile; + std::string output_File; + std::ifstream input; + std::ifstream input1; + std::ifstream input2; + + if (opt.isSet("-df")) { + opt.get("-df")->getString(input_filename); + input.open( input_filename.c_str() ); + instream = &input; + std::cout << "\n\n====================================================================== \n"; + std::cout << "-- Input file request by the user = " << input_filename << std::endl; + if (!input) { + status = -1; + std::cerr << "\n -X- Error opening input file = " << input_filename << " -X- \n"; + std::cerr << " -X- Exiting -X- \n" ; + return -1; + } + } + + if (opt.isSet("-w")) { + opt.get("-w")->getString(input_weatherFile); + input1.open( input_weatherFile.c_str() ); + instream = &input1; + std::cout << "====================================================================== \n"; + std::cout << "-- Weather file requested by the user = " << input_weatherFile << std::endl; + if (!input1) { + status = -1; + std::cerr << "\n -X- Error opening weather file = " << input_weatherFile << " -X- \n"; + std::cerr << " -X- Exiting -X- \n"; + return -1; + } + } + + if (opt.isSet("-i")) { + opt.get("-i")->getString(input_energyFile); + input2.open( input_energyFile.c_str() ); + instream = &input2; + std::cout << "====================================================================== \n"; + std::cout << "-- Energy file requested by the user = " << input_energyFile << std::endl; + std::cout << "====================================================================== "; + if (!input2) { + status = -1; + std::cerr << "\n -X- Error opening energy file = " << input_energyFile << " -X- \n"; + std::cerr << " -X- Exiting -X- \n"; + return -1; + } + } + + if (opt.isSet("-o")) { + opt.get("-o")->getString(output_File); + std::ofstream output; + output.open( output_File.c_str() ); + std::cout << "====================================================================== \n"; + std::cout << "-- Output to be stored in file = " << output_File << std::endl; + std::cout << "====================================================================== "; + if (!output) { + status = -1; + std::cerr << "\n -X- Error opening output file = " << output_File << " -X- \n"; + std::cerr << " -X- Exiting -X- \n"; + return -1; + } + } + + ///////////////////////////////////////////////////// // Enable floating point exceptions #ifndef NDEBUG @@ -225,7 +447,7 @@ main() // Note: General Parameters for the entire EnergyPlus program are contained // in "DataGlobals.f90" gio::Fmt const EPlusiniFormat( "(/,'[',A,']',/,'dir=',A)" ); - std::string const BlankString; + string const BlankString; // INTERFACE BLOCK SPECIFICATIONS // na @@ -236,8 +458,8 @@ main() // PROGRAM LOCAL VARIABLE DECLARATIONS: int LFN; // Unit Number for reads bool EPlusINI; - std::string::size_type TempIndx; - static std::string cEnvValue; + string::size_type TempIndx; + static string cEnvValue; int iostatus; bool FileExists; @@ -344,7 +566,7 @@ main() { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } // Relying on compiler to supply full path name here TempIndx = index( CurrentWorkingFolder, pathChar, true ); - if ( TempIndx == std::string::npos ) { + if ( TempIndx == string::npos ) { CurrentWorkingFolder = ""; } else { CurrentWorkingFolder.erase( TempIndx + 1 ); @@ -364,7 +586,7 @@ main() // Relying on compiler to supply full path name here { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } TempIndx = index( CurrentWorkingFolder, pathChar, true ); - if ( TempIndx == std::string::npos ) { + if ( TempIndx == string::npos ) { CurrentWorkingFolder = ""; } else { CurrentWorkingFolder.erase( TempIndx + 1 ); @@ -374,9 +596,9 @@ main() } TestAllPaths = true; - DisplayString( "EnergyPlus Starting" ); - DisplayString( VerString ); - + DisplayString( "\n" ); + DisplayString( "\n" ); + OutputFileDebug = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, "eplusout.dbg", flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { @@ -386,6 +608,26 @@ main() //Call ProcessInput to produce the IDF file which is read by all of the // Get input routines in the rest of the simulation + if(input_filename.empty()) + input_filename = "in.idf"; + + inputFileName = assign(input_filename); + + if(input_weatherFile.empty()) + input_weatherFile = "in.epw"; + + inputWeatherFile = assignWFile(input_weatherFile); + + if(input_energyFile.empty()) + input_energyFile = "Energy+.idd"; + + inputEnergyFile = assignEFile(input_energyFile); + + if(output_File.empty()) + output_File = "eplustbl.csv"; + + outputFile = assignOFile(output_File); + ProcessInput(); ManageSimulation(); @@ -401,10 +643,12 @@ main() ReportOrphanSchedules(); EndEnergyPlus(); + + return 0; } void -CreateCurrentDateTimeString( std::string & CurrentDateTimeString ) +CreateCurrentDateTimeString( string & CurrentDateTimeString ) { // SUBROUTINE INFORMATION: @@ -448,7 +692,7 @@ CreateCurrentDateTimeString( std::string & CurrentDateTimeString ) //value(6) Minutes (0-59) //value(7) Seconds (0-59) //value(8) Milliseconds (0-999) - std::string datestring; // supposedly returns blank when no date available. + string datestring; // supposedly returns blank when no date available. date_and_time_string( datestring, _, _, value ); if ( ! datestring.empty() ) { @@ -462,9 +706,9 @@ CreateCurrentDateTimeString( std::string & CurrentDateTimeString ) void ReadINIFile( int const UnitNumber, // Unit number of the opened INI file - std::string const & Heading, // Heading for the parameters ('[heading]') - std::string const & KindofParameter, // Kind of parameter to be found (String) - std::string & DataOut // Output from the retrieval + string const & Heading, // Heading for the parameters ('[heading]') + string const & KindofParameter, // Kind of parameter to be found (String) + string & DataOut // Output from the retrieval ) { @@ -502,15 +746,15 @@ ReadINIFile( // na // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static std::string LINE; - static std::string LINEOut; - std::string Param; - std::string::size_type ILB; - std::string::size_type IRB; - std::string::size_type IEQ; - std::string::size_type IPAR; - std::string::size_type IPOS; - std::string::size_type ILEN; + static string LINE; + static string LINEOut; + string Param; + string::size_type ILB; + string::size_type IRB; + string::size_type IEQ; + string::size_type IPAR; + string::size_type IPOS; + string::size_type ILEN; int ReadStat; bool EndofFile; bool Found; @@ -548,7 +792,7 @@ ReadINIFile( // See if [ and ] are on line ILB = index( LINEOut, '[' ); IRB = index( LINEOut, ']' ); - if ( ILB == std::string::npos && IRB == std::string::npos ) continue; + if ( ILB == string::npos && IRB == string::npos ) continue; if ( ! has( LINEOut, '[' + Heading + ']' ) ) continue; // Must be really correct heading line // Heading line found, now looking for Kind @@ -567,14 +811,14 @@ ReadINIFile( ILB = index( LINEOut, '[' ); IRB = index( LINEOut, ']' ); - NewHeading = ( ILB != std::string::npos && IRB != std::string::npos ); + NewHeading = ( ILB != string::npos && IRB != string::npos ); // Should be a parameter line // KindofParameter = string IEQ = index( LINEOut, '=' ); IPAR = index( LINEOut, Param ); - if ( IEQ == std::string::npos ) continue; - if ( IPAR == std::string::npos ) continue; + if ( IEQ == string::npos ) continue; + if ( IPAR == string::npos ) continue; if ( IPAR != 0 ) continue; if ( ! has( LINEOut, Param + '=' ) ) continue; // needs to be param= @@ -604,5 +848,6 @@ ReadINIFile( } } + } diff --git a/src/EnergyPlus/main.hh b/src/EnergyPlus/main.hh index 49c180de3c7..d3e620cb497 100644 --- a/src/EnergyPlus/main.hh +++ b/src/EnergyPlus/main.hh @@ -1,6 +1,7 @@ #ifndef main_hh_INCLUDED #define main_hh_INCLUDED +using namespace std; // C++ Headers #include From 52b38b61d213bb5156ac16a1bb205c79e81e8869 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 12 Sep 2014 12:06:11 -0600 Subject: [PATCH 02/71] Move ezOptionParser to third_party directory. Update to latest version. --- src/EnergyPlus/main.cc | 17 ++++++++--------- third_party/CLI/MIT-LICENSE | 7 +++++++ .../CLI}/ezOptionParser.hpp | 13 ------------- 3 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 third_party/CLI/MIT-LICENSE rename {src/EnergyPlus => third_party/CLI}/ezOptionParser.hpp (99%) mode change 100755 => 100644 diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 045f5c9f6f3..447f7751c2b 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -12,6 +12,10 @@ #include #include +// CLI Headers +#include <../../CLI/ezOptionParser.hpp> // Added by Monika Sharma for CLI +#include // Added by Monika Sharma for CLI + // EnergyPlus Headers #include #include @@ -29,9 +33,6 @@ #include #include #include -#include // Added by Monika Sharma for CLI -#include "ezOptionParser.hpp" // Added by Monika Sharma for CLI -//#include using namespace ez; using namespace std; @@ -232,8 +233,8 @@ main(int argc, const char * argv[]) ezOptionParser opt; opt.overview = "\n*******************************************\nCopyright (C) 2012-2014 Big Ladder Software\nWeb: www.bigladdersoftware.com\n"; - opt.overview1 = VerString; - opt.overview2 = "\n*******************************************\n"; + opt.overview += VerString; + opt.overview += "\n*******************************************\n"; opt.syntax = "./EnergyPlus -df InputFile.idf -i Energy+.idd -w WeatherFile.epw -o OutFile.csv"; opt.add( @@ -313,7 +314,6 @@ main(int argc, const char * argv[]) if(argv[1]==0) cout<<"No arguments provided"< & badOptions); inline bool gotRequired(std::vector & badOptions); @@ -1346,8 +1345,6 @@ class ezOptionParser { // General description in human language on what the user's tool does. // It's the first section to get printed in the full usage message. std::string overview; - std::string overview1; - std::string overview2; // A synopsis of command and options usage to show expected order of input arguments. // It's the second section to get printed in the full usage message. std::string syntax; @@ -1781,8 +1778,6 @@ OptionGroup * ezOptionParser::get(const char * name) { void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { usage.append(overview); - usage.append(overview1); - usage.append(overview2); usage.append("\n\n"); usage.append("USAGE: "); usage.append(syntax); @@ -1799,14 +1794,6 @@ void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { } }; /* ################################################################### */ -void ezOptionParser::getVersion(std::string & version, int width, Layout layout) { - - version.append(overview); - version.append(overview1); - version.append(overview2); - version.append("\n\n"); -}; -/* ################################################################### */ // Creates 2 column formatted help descriptions for each option flag. void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout layout) { // Sort each flag list amongst each group. From ef1b419bf70e22ad22c3da85807fea332cde84ad Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 12 Sep 2014 13:23:01 -0600 Subject: [PATCH 03/71] Add third_party/CLI to include directories. --- CMakeLists.txt | 1 + src/EnergyPlus/main.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e384b8a3f9..4c96bc86070 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ include(cmake/CompilerFlags.cmake) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/third_party/gtest/include/ SYSTEM ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/third_party/ObjexxFCL/src/ ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/third_party/SQLite/ SYSTEM ) +INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/third_party/CLI/ ) ADD_SUBDIRECTORY(third_party/SQLite) ADD_SUBDIRECTORY(third_party/ObjexxFCL) diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 447f7751c2b..06eebdad8b8 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -13,7 +13,7 @@ #include // CLI Headers -#include <../../CLI/ezOptionParser.hpp> // Added by Monika Sharma for CLI +#include // Added by Monika Sharma for CLI #include // Added by Monika Sharma for CLI // EnergyPlus Headers @@ -232,7 +232,9 @@ main(int argc, const char * argv[]) ///////// Added for CLI ///////////////////////////// ezOptionParser opt; - opt.overview = "\n*******************************************\nCopyright (C) 2012-2014 Big Ladder Software\nWeb: www.bigladdersoftware.com\n"; + opt.overview = "*******************************************\n"; + opt.overview += "Copyright (C) 1996-2014 \n"; // Add owners of copyright? + opt.overview += "Web: www.energyplus.gov\n"; opt.overview += VerString; opt.overview += "\n*******************************************\n"; opt.syntax = "./EnergyPlus -df InputFile.idf -i Energy+.idd -w WeatherFile.epw -o OutFile.csv"; @@ -311,7 +313,7 @@ main(int argc, const char * argv[]) opt.parse(argc, argv); - if(argv[1]==0) cout<<"No arguments provided"< Date: Tue, 16 Sep 2014 15:16:48 -0600 Subject: [PATCH 04/71] Separate file for parsing command line arguments --- src/EnergyPlus/CommandLineInterface.cc | 221 +++++++++++++++++++++ src/EnergyPlus/CommandLineInterface.hh | 15 ++ src/EnergyPlus/main.cc | 257 ++----------------------- 3 files changed, 250 insertions(+), 243 deletions(-) create mode 100644 src/EnergyPlus/CommandLineInterface.cc create mode 100644 src/EnergyPlus/CommandLineInterface.hh diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc new file mode 100644 index 00000000000..e8d9e4179cc --- /dev/null +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -0,0 +1,221 @@ + +// CLI Headers +#include +#include + +// Project headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace ez; + +namespace EnergyPlus{ + +namespace options{ + +using namespace DataStringGlobals; +using namespace InputProcessor; +using namespace SimulationManager; +using namespace OutputReportTabular; + + +void Usage(ezOptionParser& opt) { + std::string usage; + opt.getUsage(usage); + DisplayString(usage); +}; + +int +ProcessArgs(int argc, const char * argv[]) +{ + ezOptionParser opt; + + opt.overview = "*******************************************\n"; + opt.overview += "Copyright (C) 1996-2014 \n"; // Add owners of copyright? + opt.overview += "Web: www.energyplus.gov\n"; + opt.overview += VerString; + opt.overview += "\n*******************************************\n"; + opt.syntax = "./EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -o OutFile.csv"; + + opt.add( + "", // Default. + 0, // Required? + 1, // Number of args expected. + 0, // Delimiter if expecting multiple args. + "Usage information displayed on top", // Help description. + "-h", // Flag token. + "--help" // Flag token. + ); + + opt.add( + "", + 0, + 1, + 0, + "Options to get version control", + "-v", + "--version" + ); + + opt.add( + "in.idf", + 0, + 1, + 0, + "Input file to process", + "-i", + "--input" + ); + + opt.add( + "in.epw", + 0, + 1, + 0, + "Input weather file to process", + "-w", + "--weather" + ); + + opt.add( + "Energy+.idd", + 0, + 1, + 0, + "Input energy file to process", + "-e", + "--energy" + ); + + opt.add( + "eplustbl.csv", + 0, + 1, + 0, + "Output file", + "-o", + "--output" + ); + + + opt.parse(argc, argv); + + std::string usage; + + if (opt.isSet("-h")) { + opt.getUsage(usage); + DisplayString(usage); + return 1; + } + + if (opt.isSet("-v")) { + DisplayString(VerString); + return 1; + } + + std::vector badOptions; + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) + DisplayString("ERROR: Got unexpected number of arguments for option " + badOptions[i] + ".\n\n"); + + opt.getUsage(usage); + DisplayString(usage); + return 1; + } + + Usage(opt); //Ugly at the moment + + std::istream* instream; + std::string input_filename; + std::string input_weatherFile; + std::string input_energyFile; + std::string output_File; + std::ifstream input; + std::ifstream input1; + std::ifstream input2; + + + if (opt.isSet("-i")) { + opt.get("-i")->getString(input_filename); + input.open( input_filename.c_str() ); + instream = &input; + DisplayString("\n\n====================================================================== \n"); + DisplayString("-- Input file request by the user = " + input_filename); + if (!input) { + DisplayString("\n -X- Error opening input file = " + input_filename + " -X- \n"); + DisplayString(" -X- Exiting -X- \n") ; + return -1; + } + } + + if (opt.isSet("-w")) { + opt.get("-w")->getString(input_weatherFile); + input1.open( input_weatherFile.c_str() ); + instream = &input1; + DisplayString("====================================================================== \n"); + DisplayString("-- Weather file requested by the user = " + input_weatherFile + "\n"); + if (!input1) { + DisplayString("\n -X- Error opening weather file = " + input_weatherFile + " -X- \n"); + DisplayString(" -X- Exiting -X- \n"); + return -1; + } + } + + if (opt.isSet("-e")) { + opt.get("-e")->getString(input_energyFile); + input2.open( input_energyFile.c_str() ); + instream = &input2; + DisplayString("====================================================================== \n"); + DisplayString("-- Energy file requested by the user = " + input_energyFile + "\n"); + DisplayString("====================================================================== "); + if (!input2) { + DisplayString("\n -X- Error opening energy file = " + input_energyFile + " -X- \n"); + DisplayString(" -X- Exiting -X- \n"); + return -1; + } + } + + if (opt.isSet("-o")) { + opt.get("-o")->getString(output_File); + std::ofstream output; + output.open( output_File.c_str() ); + DisplayString("====================================================================== \n"); + DisplayString("-- Output to be stored in file = " + output_File + "\n"); + DisplayString("====================================================================== "); + if (!output) { + DisplayString("\n -X- Error opening output file = " + output_File + " -X- \n"); + DisplayString(" -X- Exiting -X- \n"); + return -1; + } + } + + if(input_filename.empty()) + input_filename = "in.idf"; + + inputFileName = assign(input_filename); + + if(input_weatherFile.empty()) + input_weatherFile = "in.epw"; + + inputWeatherFile = assignWFile(input_weatherFile); + + if(input_energyFile.empty()) + input_energyFile = "Energy+.idd"; + + inputEnergyFile = assignEFile(input_energyFile); + + if(output_File.empty()) + output_File = "eplustbl.csv"; + + outputFile = assignOFile(output_File); + return 0; + ///////////////////////////////////////////////////// +} +} //namespace options +} //EnergyPlus namespace diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh new file mode 100644 index 00000000000..156ae52263c --- /dev/null +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -0,0 +1,15 @@ +#ifndef CommandLineInterface_hh_INCLUDED +#define CommandLineInterface_hh_INCLUDED + +#include +namespace EnergyPlus{ + +namespace options { + + + // Process command line arguments + int + ProcessArgs( int argc, const char * argv[] ); + } +} +#endif diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 06eebdad8b8..53de4eb6af1 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -12,12 +12,9 @@ #include #include -// CLI Headers -#include // Added by Monika Sharma for CLI -#include // Added by Monika Sharma for CLI - // EnergyPlus Headers #include +#include #include #include #include @@ -32,17 +29,7 @@ #include #include #include -#include - -using namespace ez; -using namespace std; -//using namespace vif; - -void Usage(ezOptionParser& opt) { - string usage; - opt.getUsage(usage); - cout << usage; -}; +//#include int @@ -52,7 +39,7 @@ main(int argc, const char * argv[]) using namespace EnergyPlus; // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the // University of California through Ernest Orlando Lawrence Berkeley National Laboratory. All rights // reserved. @@ -127,11 +114,11 @@ main(int argc, const char * argv[]) // (Conjunction Of Multizone Infiltration Specialists) developed by a multinational, multi-institutional // effort under the auspices of the International Energy Agency's Buildings and Community Systems Agreement // working group focusing on multizone air flow modeling (Annex 23) and now administered by the Swiss Federal - // Laboratories for Materials Testing and Research (EMPA), Division 175, Überlandstrasse 129, CH-8600 Dübendorf, + // Laboratories for Materials Testing and Research (EMPA), Division 175, �berlandstrasse 129, CH-8600 D�bendorf, // Switzerland. // The EnergyPlus v1.2 model for displacement ventilation and cross-ventilation was developed - // by Guilherme Carrilho da Graça and Paul Linden of the Department of Mechanical and Aerospace + // by Guilherme Carrilho da Gra�a and Paul Linden of the Department of Mechanical and Aerospace // Engineering, University of California, San Diego. // The EnergyPlus models for UFAD served zones were developed by Anna Liu and Paul Linden at the Department @@ -228,213 +215,15 @@ main(int argc, const char * argv[]) using ScheduleManager::ReportOrphanSchedules; using FluidProperties::ReportOrphanFluids; using Psychrometrics::ShowPsychrometricSummary; - - ///////// Added for CLI ///////////////////////////// - ezOptionParser opt; - - opt.overview = "*******************************************\n"; - opt.overview += "Copyright (C) 1996-2014 \n"; // Add owners of copyright? - opt.overview += "Web: www.energyplus.gov\n"; - opt.overview += VerString; - opt.overview += "\n*******************************************\n"; - opt.syntax = "./EnergyPlus -df InputFile.idf -i Energy+.idd -w WeatherFile.epw -o OutFile.csv"; - - opt.add( - "", // Default. - 0, // Required? - 1, // Number of args expected. - 0, // Delimiter if expecting multiple args. - "Usage information displayed on top", // Help description. - "-h", // Flag token. - "-help", // Flag token. - "--help", // Flag token. - "--usage" // Flag token. - ); - - opt.add( - "", - 0, - 1, - 0, - "Options to get version control", - "-v", - "--v", - "-version", - "--version" - ); - - opt.add( - "in.idf", - 0, - 1, - 0, - "Input file to process", - "-df", - "--df" - //"--in", - //"--input" - ); - - opt.add( - "in.epw", - 0, - 1, - 0, - "Input weather file to process", - "-w", - "-wea", - "--w", - "--wea" - ); - - opt.add( - "Energy+.idd", - 0, - 1, - 0, - "Input energy file to process", - "-i", - "-in", - "--i", - "--in" - ); - - opt.add( - "eplustbl.csv", - 0, - 1, - 0, - "Output file", - "-o", - "-out", - "--o", - "--out" - ); - + // CLI module + using namespace options; - opt.parse(argc, argv); - //if(argv[1]==0) cout<<"No arguments provided"< badOptions; - if(!opt.gotExpected(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) - cerr << "ERROR: Got unexpected number of arguments for option " << badOptions[i] << ".\n\n"; - - opt.getUsage(usage); - cout << usage; - return -1; - } - -/* if(!opt.gotRequired(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) - std::cerr << "ERROR: Missing required option " << badOptions[i] << ".\n\n"; - // Usage(opt); - opt.getUsage(usage); - return 1; - } - - std::vector badArgs; - if(!opt.gotValid(badOptions, badArgs)) { - for(int i=0; i < badOptions.size(); ++i) - std::cerr << "ERROR: Got invalid argument \"" << badArgs[i] << "\" for option " << badOptions[i] << ".\n\n"; - - //Usage(opt); - return 1; - } - - if (opt.lastArgs.size() < 2) { - cout << "Zeroth argument = " << argv[0] << '\t'<< argv[1] << '\t'<< argv[2] << endl; - cerr << "\n\n-------------------------------------------\n"; - cerr << "** EnergyPlus in default configuration **\n"; - cerr << "-------------------------------------------\n"; - Usage(opt); - } - */ // gotRequired, gotValid and lastArgs.size() options aren't working at the moment. - - Usage(opt); //Ugly at the moment - int status = 0; - std::istream* instream; - std::string input_filename; - std::string input_weatherFile; - std::string input_energyFile; - std::string output_File; - std::ifstream input; - std::ifstream input1; - std::ifstream input2; - - if (opt.isSet("-df")) { - opt.get("-df")->getString(input_filename); - input.open( input_filename.c_str() ); - instream = &input; - std::cout << "\n\n====================================================================== \n"; - std::cout << "-- Input file request by the user = " << input_filename << std::endl; - if (!input) { - status = -1; - std::cerr << "\n -X- Error opening input file = " << input_filename << " -X- \n"; - std::cerr << " -X- Exiting -X- \n" ; - return -1; - } - } - - if (opt.isSet("-w")) { - opt.get("-w")->getString(input_weatherFile); - input1.open( input_weatherFile.c_str() ); - instream = &input1; - std::cout << "====================================================================== \n"; - std::cout << "-- Weather file requested by the user = " << input_weatherFile << std::endl; - if (!input1) { - status = -1; - std::cerr << "\n -X- Error opening weather file = " << input_weatherFile << " -X- \n"; - std::cerr << " -X- Exiting -X- \n"; - return -1; - } - } - - if (opt.isSet("-i")) { - opt.get("-i")->getString(input_energyFile); - input2.open( input_energyFile.c_str() ); - instream = &input2; - std::cout << "====================================================================== \n"; - std::cout << "-- Energy file requested by the user = " << input_energyFile << std::endl; - std::cout << "====================================================================== "; - if (!input2) { - status = -1; - std::cerr << "\n -X- Error opening energy file = " << input_energyFile << " -X- \n"; - std::cerr << " -X- Exiting -X- \n"; - return -1; - } - } - - if (opt.isSet("-o")) { - opt.get("-o")->getString(output_File); - std::ofstream output; - output.open( output_File.c_str() ); - std::cout << "====================================================================== \n"; - std::cout << "-- Output to be stored in file = " << output_File << std::endl; - std::cout << "====================================================================== "; - if (!output) { - status = -1; - std::cerr << "\n -X- Error opening output file = " << output_File << " -X- \n"; - std::cerr << " -X- Exiting -X- \n"; - return -1; - } - } - - ///////////////////////////////////////////////////// + status = ProcessArgs(argc, argv); + if(status == 1 || status == -1) + return 0; + //ProcessArgs(argc, argv); + // Enable floating point exceptions #ifndef NDEBUG @@ -587,7 +376,7 @@ main(int argc, const char * argv[]) // Relying on compiler to supply full path name here { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } TempIndx = index( CurrentWorkingFolder, pathChar, true ); - if ( TempIndx == string::npos ) { + if ( TempIndx == std::string::npos ) { CurrentWorkingFolder = ""; } else { CurrentWorkingFolder.erase( TempIndx + 1 ); @@ -609,25 +398,7 @@ main(int argc, const char * argv[]) //Call ProcessInput to produce the IDF file which is read by all of the // Get input routines in the rest of the simulation - if(input_filename.empty()) - input_filename = "in.idf"; - - inputFileName = assign(input_filename); - - if(input_weatherFile.empty()) - input_weatherFile = "in.epw"; - - inputWeatherFile = assignWFile(input_weatherFile); - - if(input_energyFile.empty()) - input_energyFile = "Energy+.idd"; - - inputEnergyFile = assignEFile(input_energyFile); - - if(output_File.empty()) - output_File = "eplustbl.csv"; - - outputFile = assignOFile(output_File); + ProcessInput(); From 9793b69f6acc40f0acd90771c3839035556582dc Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Wed, 17 Sep 2014 09:32:20 -0600 Subject: [PATCH 05/71] added new files to cmake --- src/EnergyPlus/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 8900c83d77d..93abebe7397 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -37,6 +37,8 @@ SET( SRC ChillerIndirectAbsorption.hh ChillerReformulatedEIR.cc ChillerReformulatedEIR.hh + CommandLineInterface.cc + CommandLineInterface.hh CondenserLoopTowers.cc CondenserLoopTowers.hh ConductionTransferFunctionCalc.cc From 6ca48c6b2dbb7d560f3c0c435804b8e8362671cc Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 17 Sep 2014 09:58:54 -0600 Subject: [PATCH 06/71] Clean up main.cc. --- src/EnergyPlus/main.cc | 66 ++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 53de4eb6af1..61d4e59eb7e 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -25,11 +25,10 @@ #include #include #include -#include #include #include #include -//#include +#include int @@ -37,9 +36,10 @@ main(int argc, const char * argv[]) { // Using/Aliasing using namespace EnergyPlus; - // NOTICE - // Copyright � 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the + // NOTICE + + // Copyright © 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the // University of California through Ernest Orlando Lawrence Berkeley National Laboratory. All rights // reserved. @@ -114,11 +114,11 @@ main(int argc, const char * argv[]) // (Conjunction Of Multizone Infiltration Specialists) developed by a multinational, multi-institutional // effort under the auspices of the International Energy Agency's Buildings and Community Systems Agreement // working group focusing on multizone air flow modeling (Annex 23) and now administered by the Swiss Federal - // Laboratories for Materials Testing and Research (EMPA), Division 175, �berlandstrasse 129, CH-8600 D�bendorf, + // Laboratories for Materials Testing and Research (EMPA), Division 175, Überlandstrasse 129, CH-8600 Dübendorf, // Switzerland. // The EnergyPlus v1.2 model for displacement ventilation and cross-ventilation was developed - // by Guilherme Carrilho da Gra�a and Paul Linden of the Department of Mechanical and Aerospace + // by Guilherme Carrilho da Graça and Paul Linden of the Department of Mechanical and Aerospace // Engineering, University of California, San Diego. // The EnergyPlus models for UFAD served zones were developed by Anna Liu and Paul Linden at the Department @@ -211,7 +211,6 @@ main(int argc, const char * argv[]) using namespace InputProcessor; using namespace OutputProcessor; using namespace SimulationManager; - using namespace OutputReportTabular; using ScheduleManager::ReportOrphanSchedules; using FluidProperties::ReportOrphanFluids; using Psychrometrics::ShowPsychrometricSummary; @@ -237,7 +236,7 @@ main(int argc, const char * argv[]) // Note: General Parameters for the entire EnergyPlus program are contained // in "DataGlobals.f90" gio::Fmt const EPlusiniFormat( "(/,'[',A,']',/,'dir=',A)" ); - string const BlankString; + std::string const BlankString; // INTERFACE BLOCK SPECIFICATIONS // na @@ -248,8 +247,8 @@ main(int argc, const char * argv[]) // PROGRAM LOCAL VARIABLE DECLARATIONS: int LFN; // Unit Number for reads bool EPlusINI; - string::size_type TempIndx; - static string cEnvValue; + std::string::size_type TempIndx; + static std::string cEnvValue; int iostatus; bool FileExists; @@ -356,7 +355,7 @@ main(int argc, const char * argv[]) { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } // Relying on compiler to supply full path name here TempIndx = index( CurrentWorkingFolder, pathChar, true ); - if ( TempIndx == string::npos ) { + if ( TempIndx == std::string::npos ) { CurrentWorkingFolder = ""; } else { CurrentWorkingFolder.erase( TempIndx + 1 ); @@ -386,9 +385,9 @@ main(int argc, const char * argv[]) } TestAllPaths = true; - DisplayString( "\n" ); - DisplayString( "\n" ); - + DisplayString( "EnergyPlus Starting" ); + DisplayString( VerString ); + OutputFileDebug = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, "eplusout.dbg", flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { @@ -398,8 +397,6 @@ main(int argc, const char * argv[]) //Call ProcessInput to produce the IDF file which is read by all of the // Get input routines in the rest of the simulation - - ProcessInput(); ManageSimulation(); @@ -420,7 +417,7 @@ main(int argc, const char * argv[]) } void -CreateCurrentDateTimeString( string & CurrentDateTimeString ) +CreateCurrentDateTimeString( std::string & CurrentDateTimeString ) { // SUBROUTINE INFORMATION: @@ -464,7 +461,7 @@ CreateCurrentDateTimeString( string & CurrentDateTimeString ) //value(6) Minutes (0-59) //value(7) Seconds (0-59) //value(8) Milliseconds (0-999) - string datestring; // supposedly returns blank when no date available. + std::string datestring; // supposedly returns blank when no date available. date_and_time_string( datestring, _, _, value ); if ( ! datestring.empty() ) { @@ -478,9 +475,9 @@ CreateCurrentDateTimeString( string & CurrentDateTimeString ) void ReadINIFile( int const UnitNumber, // Unit number of the opened INI file - string const & Heading, // Heading for the parameters ('[heading]') - string const & KindofParameter, // Kind of parameter to be found (String) - string & DataOut // Output from the retrieval + std::string const & Heading, // Heading for the parameters ('[heading]') + std::string const & KindofParameter, // Kind of parameter to be found (String) + std::string & DataOut // Output from the retrieval ) { @@ -518,15 +515,15 @@ ReadINIFile( // na // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static string LINE; - static string LINEOut; - string Param; - string::size_type ILB; - string::size_type IRB; - string::size_type IEQ; - string::size_type IPAR; - string::size_type IPOS; - string::size_type ILEN; + static std::string LINE; + static std::string LINEOut; + std::string Param; + std::string::size_type ILB; + std::string::size_type IRB; + std::string::size_type IEQ; + std::string::size_type IPAR; + std::string::size_type IPOS; + std::string::size_type ILEN; int ReadStat; bool EndofFile; bool Found; @@ -564,7 +561,7 @@ ReadINIFile( // See if [ and ] are on line ILB = index( LINEOut, '[' ); IRB = index( LINEOut, ']' ); - if ( ILB == string::npos && IRB == string::npos ) continue; + if ( ILB == std::string::npos && IRB == std::string::npos ) continue; if ( ! has( LINEOut, '[' + Heading + ']' ) ) continue; // Must be really correct heading line // Heading line found, now looking for Kind @@ -583,14 +580,14 @@ ReadINIFile( ILB = index( LINEOut, '[' ); IRB = index( LINEOut, ']' ); - NewHeading = ( ILB != string::npos && IRB != string::npos ); + NewHeading = ( ILB != std::string::npos && IRB != std::string::npos ); // Should be a parameter line // KindofParameter = string IEQ = index( LINEOut, '=' ); IPAR = index( LINEOut, Param ); - if ( IEQ == string::npos ) continue; - if ( IPAR == string::npos ) continue; + if ( IEQ == std::string::npos ) continue; + if ( IPAR == std::string::npos ) continue; if ( IPAR != 0 ) continue; if ( ! has( LINEOut, Param + '=' ) ) continue; // needs to be param= @@ -620,6 +617,5 @@ ReadINIFile( } } - } From e6aee6bfafd485118b3ac33debbc73bf9d5006c1 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 19 Sep 2014 10:13:44 -0600 Subject: [PATCH 07/71] 17 output files will be named according to input+weather file names --- src/EnergyPlus/CommandLineInterface.cc | 269 ++++++++++++++++--------- src/EnergyPlus/CommandLineInterface.hh | 18 +- src/EnergyPlus/DataSystemVariables.cc | 4 +- src/EnergyPlus/DataTimings.cc | 4 +- src/EnergyPlus/InputProcessor.cc | 26 ++- src/EnergyPlus/InputProcessor.hh | 1 + src/EnergyPlus/OutputProcessor.cc | 65 ++++-- src/EnergyPlus/OutputProcessor.hh | 4 + src/EnergyPlus/OutputReportTabular.cc | 45 ++++- src/EnergyPlus/OutputReportTabular.hh | 4 + src/EnergyPlus/OutputReports.cc | 21 +- src/EnergyPlus/OutputReports.hh | 2 + src/EnergyPlus/Psychrometrics.cc | 4 +- src/EnergyPlus/ScheduleManager.cc | 4 +- src/EnergyPlus/SimulationManager.cc | 51 +++-- src/EnergyPlus/SimulationManager.hh | 4 + src/EnergyPlus/SolarShading.cc | 8 + src/EnergyPlus/SolarShading.hh | 1 + src/EnergyPlus/UtilityRoutines.cc | 28 ++- src/EnergyPlus/UtilityRoutines.hh | 3 + src/EnergyPlus/main.cc | 8 +- third_party/CLI/ezOptionParser.hpp | 2 +- 22 files changed, 407 insertions(+), 169 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index e8d9e4179cc..f9b287f892f 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -11,19 +11,39 @@ #include #include #include +#include #include +#include #include using namespace ez; namespace EnergyPlus{ -namespace options{ +namespace CommandLineInterface{ using namespace DataStringGlobals; using namespace InputProcessor; using namespace SimulationManager; using namespace OutputReportTabular; - +using namespace OutputProcessor; +using namespace SolarShading; + +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 outputHtmFile; +std::string outputTabFile; +std::string outputTxtFile; +std::string outputXmlFile; void Usage(ezOptionParser& opt) { std::string usage; @@ -34,6 +54,16 @@ void Usage(ezOptionParser& opt) { int ProcessArgs(int argc, const char * argv[]) { + std::istream* instream; + std::string input_filename; + std::string input_weatherFile; + std::string input_energyFile; + + std::ifstream input; + std::ifstream input1; + std::ifstream input2; + + ezOptionParser opt; opt.overview = "*******************************************\n"; @@ -43,70 +73,20 @@ ProcessArgs(int argc, const char * argv[]) opt.overview += "\n*******************************************\n"; opt.syntax = "./EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -o OutFile.csv"; - opt.add( - "", // Default. - 0, // Required? - 1, // Number of args expected. - 0, // Delimiter if expecting multiple args. - "Usage information displayed on top", // Help description. - "-h", // Flag token. - "--help" // Flag token. - ); - - opt.add( - "", - 0, - 1, - 0, - "Options to get version control", - "-v", - "--version" - ); - - opt.add( - "in.idf", - 0, - 1, - 0, - "Input file to process", - "-i", - "--input" - ); - - opt.add( - "in.epw", - 0, - 1, - 0, - "Input weather file to process", - "-w", - "--weather" - ); - - opt.add( - "Energy+.idd", - 0, - 1, - 0, - "Input energy file to process", - "-e", - "--energy" - ); - - opt.add( - "eplustbl.csv", - 0, - 1, - 0, - "Output file", - "-o", - "--output" - ); + opt.add("", 0, 1, 0, "Usage information displayed on top", "-h", "--help"); + opt.add("", 0, 1, 0, "Options to get version control", "-v", "--version"); - opt.parse(argc, argv); + opt.add("in.idf", 0, 1, 0, "Input file to process", "-i", "--input"); + + opt.add("in.epw", 0, 1, 0, "Input weather file to process", "-w", "--weather"); + + opt.add("Energy+.idd", 0, 1, 0, "Input energy file to process", "-e", "--energy"); + + opt.add("eplustbl.csv", 0, 0, 0, "Output file", "-o", "--output"); std::string usage; + opt.parse(argc, argv); if (opt.isSet("-h")) { opt.getUsage(usage); @@ -119,26 +99,27 @@ ProcessArgs(int argc, const char * argv[]) return 1; } - std::vector badOptions; - if(!opt.gotExpected(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) - DisplayString("ERROR: Got unexpected number of arguments for option " + badOptions[i] + ".\n\n"); - - opt.getUsage(usage); - DisplayString(usage); - return 1; - } - Usage(opt); //Ugly at the moment - std::istream* instream; - std::string input_filename; - std::string input_weatherFile; - std::string input_energyFile; - std::string output_File; - std::ifstream input; - std::ifstream input1; - std::ifstream input2; + std::vector badOptions; + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) + DisplayString("ERROR: Got unexpected number of arguments for option " + badOptions[i] + ".\n\n"); + DisplayString("Usage information displayed above. \n"); + return 1; + } + + if(!opt.isSet("-h") && !opt.isSet("-v") && !opt.isSet("-i") && !opt.isSet("-o") && !opt.isSet("-w") && !opt.isSet("-e")){ + std::cout<<"Invalid option used. Exiting...\n"; + return 1; + } + + if(!opt.gotRequired(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) + std::cerr << "ERROR: Missing required option " << badOptions[i] << ".\n\n"; + Usage(opt); + return 1; + } if (opt.isSet("-i")) { @@ -181,20 +162,6 @@ ProcessArgs(int argc, const char * argv[]) } } - if (opt.isSet("-o")) { - opt.get("-o")->getString(output_File); - std::ofstream output; - output.open( output_File.c_str() ); - DisplayString("====================================================================== \n"); - DisplayString("-- Output to be stored in file = " + output_File + "\n"); - DisplayString("====================================================================== "); - if (!output) { - DisplayString("\n -X- Error opening output file = " + output_File + " -X- \n"); - DisplayString(" -X- Exiting -X- \n"); - return -1; - } - } - if(input_filename.empty()) input_filename = "in.idf"; @@ -210,10 +177,122 @@ ProcessArgs(int argc, const char * argv[]) inputEnergyFile = assignEFile(input_energyFile); + std::string output_File = input_filename+"_"+input_weatherFile+".csv"; + std::string output_AuditFile = input_filename+"_"+input_weatherFile+".audit"; + std::string output_BndFile = input_filename+"_"+input_weatherFile+".bnd"; + std::string output_DxfFile = input_filename+"_"+input_weatherFile+".dxf"; + std::string output_EioFile = input_filename+"_"+input_weatherFile+".eio"; + std::string output_EndFile = input_filename+"_"+input_weatherFile+".end"; + std::string output_ErrFile = input_filename+"_"+input_weatherFile+".err"; + std::string output_EsoFile = input_filename+"_"+input_weatherFile+".eso"; + std::string output_MtdFile = input_filename+"_"+input_weatherFile+".mtd"; + std::string output_MddFile = input_filename+"_"+input_weatherFile+".mdd"; + std::string output_MtrFile = input_filename+"_"+input_weatherFile+".mtr"; + std::string output_RddFile = input_filename+"_"+input_weatherFile+".rdd"; + std::string output_ShdFile = input_filename+"_"+input_weatherFile+".shd"; + std::string output_HtmFile = input_filename+"_"+input_weatherFile+".htm"; + std::string output_TabFile = input_filename+"_"+input_weatherFile+".tab"; + std::string output_TxtFile = input_filename+"_"+input_weatherFile+".txt"; + std::string output_XmlFile = input_filename+"_"+input_weatherFile+".xml"; + + if (opt.isSet("-o")) { + std::ofstream output; + output.open( output_File.c_str() ); + DisplayString("====================================================================== \n"); + DisplayString("-- Output to be stored in file = " + output_File + "\n"); + DisplayString("====================================================================== "); + if (!output) { + DisplayString("\n -X- Error opening output file = " + output_File + " -X- \n"); + DisplayString(" -X- Exiting -X- \n"); + return -1; + } + } + if(output_File.empty()) - output_File = "eplustbl.csv"; + output_File = "eplustbl.csv"; outputFile = assignOFile(output_File); + + if(output_AuditFile.empty()) + output_AuditFile = "eplusout.audit"; + + outputAuditFile = assignAuditFile(output_AuditFile); + + if(output_BndFile.empty()) + output_BndFile = "eplusout.bnd"; + + outputBndFile = assignBndFile(output_BndFile); + + if(output_DxfFile.empty()) + output_DxfFile = "eplusout.dxf"; + + outputDxfFile = assignDxfFile(output_DxfFile); + + if(output_EioFile.empty()) + output_EioFile = "eplusout.eio"; + + outputEioFile = assignEioFile(output_EioFile); + + if(output_EndFile.empty()) + output_EndFile = "eplusout.end"; + + outputEndFile = assignEndFile(output_EndFile); + + if(output_ErrFile.empty()) + output_ErrFile = "eplusout.err"; + + outputErrFile = assignErrFile(output_ErrFile); + + if(output_EsoFile.empty()) + output_EsoFile = "eplusout.eso"; + + outputEsoFile = assignEsoFile(output_EsoFile); + + if(output_MtdFile.empty()) + output_MtdFile = "eplusout.mtd"; + + outputMtdFile = assignMtdFile(output_MtdFile); + + if(output_MddFile.empty()) + output_MddFile = "eplusout.mdd"; + + outputMddFile = assignMddFile(output_MddFile); + + if(output_MtrFile.empty()) + output_MtrFile = "eplusout.mtr"; + + outputMtrFile = assignMtrFile(output_MtrFile); + + if(output_RddFile.empty()) + output_RddFile = "eplusout.rdd"; + + outputRddFile = assignRddFile(output_RddFile); + + if(output_ShdFile.empty()) + output_ShdFile = "eplusout.shd"; + + outputShdFile = assignShdFile(output_ShdFile); + + if(output_HtmFile.empty()) + output_HtmFile = "eplustbl.htm"; + + outputHtmFile = assignHtmFile(output_HtmFile); + + if(output_TabFile.empty()) + output_TabFile = "eplustbl.tab"; + + outputTabFile = assignTabFile(output_TabFile); + + if(output_TxtFile.empty()) + output_TxtFile = "eplustbl.txt"; + + outputTxtFile = assignTxtFile(output_TxtFile); + + if(output_XmlFile.empty()) + output_XmlFile = "eplustbl.xml"; + + outputXmlFile = assignXmlFile(output_XmlFile); + return 0; ///////////////////////////////////////////////////// } diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 156ae52263c..e55e69bfba3 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -4,8 +4,24 @@ #include namespace EnergyPlus{ -namespace options { +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 outputHtmFile; + extern std::string outputTabFile; + extern std::string outputTxtFile; + extern std::string outputXmlFile; // Process command line arguments int diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index d3735c004fc..d09ddb280a1 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -4,6 +4,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -33,6 +34,7 @@ namespace DataSystemVariables { // na // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataStringGlobals::pathChar; using DataStringGlobals::altpathChar; @@ -185,7 +187,7 @@ namespace DataSystemVariables { std::string::size_type pos; if ( firstTime ) { - EchoInputFile = FindUnitNumber( "eplusout.audit" ); + EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); get_environment_variable( cInputPath1, envinputpath1 ); if ( envinputpath1 != blank ) { pos = index( envinputpath1, pathChar, true ); // look backwards for pathChar diff --git a/src/EnergyPlus/DataTimings.cc b/src/EnergyPlus/DataTimings.cc index 11e9c5a12ce..abdcf1d752e 100644 --- a/src/EnergyPlus/DataTimings.cc +++ b/src/EnergyPlus/DataTimings.cc @@ -4,6 +4,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -40,6 +41,7 @@ namespace DataTimings { // Using/Aliasing using namespace DataPrecisionGlobals; + using namespace CommandLineInterface; using DataSystemVariables::tabchar; using DataSystemVariables::DeveloperFlag; @@ -321,7 +323,7 @@ namespace DataTimings { return; #endif #ifdef EP_Timings - EchoInputFile = FindUnitNumber( "eplusout.audit" ); + EchoInputFile = FindUnitNumber( outputAuditFile ); gio::write( EchoInputFile, fmtA ) << "Timing Element" + tabchar + "# calls" + tabchar + "Time {s}" + tabchar + "Time {s} (per call)"; for ( loop = 1; loop <= NumTimingElements; ++loop ) { diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index e31134a70bd..bfe15e02f7e 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -4,6 +4,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -49,6 +50,7 @@ namespace InputProcessor { // Use statements for data only modules // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataStringGlobals; using DataGlobals::MaxNameLength; @@ -171,17 +173,23 @@ namespace InputProcessor { FArray1D< SecretObjects > RepObjects; // Secret Objects that could replace old ones std::string assign(std::string& _FileName){ - std::cout<<"====================================================================== \n"; - std::cout<<"== Module 'Input Processor'::Name of the input file = "<<_FileName< // EnergyPlus Headers +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +56,7 @@ namespace OutputProcessor { // na // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataGlobals::MaxNameLength; using DataGlobals::OutputFileMeters; @@ -240,7 +243,25 @@ namespace OutputProcessor { // UpdateDataandReport // UpdateMeterReporting - // Functions + // Function + + std::string assignMtdFile(std::string& _MtdFileName){ + DisplayString("== Module 'Output Processor'::Name of the output (mtd) file = " +_MtdFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _MtdFileName; + } + + std::string assignMddFile(std::string& _MddFileName){ + DisplayString("== Module 'Output Processor'::Name of the output (mdd) file = " +_MddFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _MddFileName; + } + + std::string assignRddFile(std::string& _RddFileName){ + DisplayString("== Module 'Output Processor'::Name of the output (rdd) file = " +_RddFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _RddFileName; + } void InitializeOutput() @@ -1579,9 +1600,9 @@ namespace OutputProcessor { int write_stat; OutputFileMeterDetails = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMeterDetails, "eplusout.mtd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMeterDetails, outputMtdFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "InitializeMeters: Could not open file \"eplusout.mtd\" for output (write)." ); + ShowFatalError( "InitializeMeters: Could not open file "+outputMtdFile+" for output (write)." ); } } @@ -6692,7 +6713,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptTS ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both " + outputEsoFile + " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptTS ) { @@ -6705,7 +6726,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccTS ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptAccTS ) { @@ -6720,7 +6741,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptHR ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFile + " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptHR ) { @@ -6734,7 +6755,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccHR ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFile + " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptAccHR ) { @@ -6750,7 +6771,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptDY ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Daily), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Daily), " "already on \"Output:Meter\". Will report to both " +outputEsoFile+ " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptDY ) { @@ -6764,7 +6785,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccDY ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptAccDY ) { @@ -6780,7 +6801,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptMN ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptMN ) { @@ -6794,7 +6815,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccMN ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptAccMN ) { @@ -6810,7 +6831,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptSM ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+" and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptSM ) { @@ -6824,7 +6845,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccSM ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both eplusout.eso and eplusout.mtr." ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+" and " +outputMtrFile ); } } if ( ! EnergyMeters( WhichMeter ).RptAccSM ) { @@ -8257,31 +8278,31 @@ ProduceRDDMDD() if ( ProduceReportVDD == ReportVDD_Yes ) { OutputFileRVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, "eplusout.rdd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, outputRddFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"eplusout.rdd\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputRddFile+" for output (write)." ); } gio::write( OutputFileRVDD, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileRVDD, fmtA ) << "Var Type (reported time step),Var Report Type,Variable Name [Units]"; OutputFileMVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, "eplusout.mdd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, outputMddFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"eplusout.mdd\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputMddFile+" for output (write)." ); } gio::write( OutputFileMVDD, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileMVDD, fmtA ) << "Var Type (reported time step),Var Report Type,Variable Name [Units]"; } else if ( ProduceReportVDD == ReportVDD_IDF ) { OutputFileRVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, "eplusout.rdd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, outputRddFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"eplusout.rdd\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputRddFile+" for output (write)." ); } gio::write( OutputFileRVDD, fmtA ) << "! Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileRVDD, fmtA ) << "! Output:Variable Objects (applicable to this run)"; OutputFileMVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, "eplusout.mdd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, outputMddFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"eplusout.mdd\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputMddFile+" for output (write)." ); } gio::write( OutputFileMVDD, fmtA ) << "! Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileMVDD, fmtA ) << "! Output:Meter Objects (applicable to this run)"; @@ -8479,7 +8500,7 @@ AddToOutputVariableList( } // NOTICE -// Copyright © 1996-2014 The Board of Trustees of the University of Illinois +// Copyright � 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. // Portions of the EnergyPlus software package have been developed and copyrighted diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index 98abe4518fe..860e1ff6091 100644 --- a/src/EnergyPlus/OutputProcessor.hh +++ b/src/EnergyPlus/OutputProcessor.hh @@ -138,6 +138,10 @@ namespace OutputProcessor { extern int MaxNumSubcategories; + std::string assignMtdFile(std::string& _MtdFileName); + std::string assignMddFile(std::string& _MddFileName); + std::string assignRddFile(std::string& _RddFileName); + // All routines should be listed here whether private or not //PUBLIC ReallocateTVar //PUBLIC SetReportNow diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index fc663f71c86..0da7a6dc2aa 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -14,6 +14,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -86,6 +87,7 @@ namespace OutputReportTabular { // |--> MonthlyTable --> MonthlyColumns // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace InputProcessor; using DataGlobals::BigNumber; @@ -413,6 +415,30 @@ namespace OutputReportTabular { return _OFileName; } + std::string assignHtmFile(std::string& _HtmFileName){ + DisplayString("== Module 'Output Report Tabular'::Name of the output (htm) file = " +_HtmFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _HtmFileName; + } + + std::string assignTabFile(std::string& _TabFileName){ + DisplayString("== Module 'Output Report Tabular'::Name of the output (tab) file = " +_TabFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _TabFileName; + } + + std::string assignTxtFile(std::string& _TxtFileName){ + DisplayString("== Module 'Output Report Tabular'::Name of the output (txt) file = " +_TxtFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _TxtFileName; + } + + std::string assignXmlFile(std::string& _XmlFileName){ + DisplayString("== Module 'Output Report Tabular'::Name of the output (xml) file = " +_XmlFileName+ "\n"); + DisplayString("====================================================================== \n\n"); + return _XmlFileName; + } + void UpdateTabularReports( int const IndexTypeKey ) // What kind of data to update (Zone, HVAC) { @@ -3131,9 +3157,9 @@ namespace OutputReportTabular { gio::write( curFH, fmtA ) << ""; } else if ( TableStyle( iStyle ) == tableStyleTab ) { DisplayString( "Writing tabular output file results using tab format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, "eplustbl.tab", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputTabFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"eplustbl.tab\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTabFile+" for output (write)." ); } gio::write( curFH, fmtA ) << "Program Version" + curDel + VerString; gio::write( curFH, fmtA ) << "Tabular Output Report in Format: " + curDel + "Tab"; @@ -3147,9 +3173,9 @@ namespace OutputReportTabular { gio::write( curFH, fmtA ) << ""; } else if ( TableStyle( iStyle ) == tableStyleHTML ) { DisplayString( "Writing tabular output file results using HTML format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, "eplustbl.htm", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputHtmFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"eplustbl.htm\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputHtmFile+" for output (write)." ); } gio::write( curFH, fmtA ) << ""; gio::write( curFH, fmtA ) << ""; @@ -3178,9 +3204,9 @@ namespace OutputReportTabular { gio::write( curFH, TimeStampFmt2 ) << " " << td( 5 ) << ":" << td( 6 ) << ":" << td( 7 ) << "

"; } else if ( TableStyle( iStyle ) == tableStyleXML ) { DisplayString( "Writing tabular output file results using XML format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, "eplustbl.xml", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputXmlFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"eplustbl.xml\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputXmlFile+" for output (write)." ); } gio::write( curFH, fmtA ) << ""; gio::write( curFH, fmtA ) << ""; @@ -3199,9 +3225,9 @@ namespace OutputReportTabular { gio::write( curFH ); } else { DisplayString( "Writing tabular output file results using text format." ); - { IOFlags flags; flags.ACTION( "write" ); gio::open( curFH, "eplustbl.txt", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( curFH, outputTxtFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"eplustbl.txt\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTxtFile+" for output (write)." ); } gio::write( curFH, fmtA ) << "Program Version: " + VerString; gio::write( curFH, fmtA ) << "Tabular Output Report in Format: " + curDel + "Fixed"; @@ -4809,6 +4835,7 @@ namespace OutputReportTabular { // report is added it can be added to the list here. // Locals + int EchoInputFile; // found unit number for 'eplusout.audit' FillWeatherPredefinedEntries(); @@ -4831,7 +4858,7 @@ namespace OutputReportTabular { WriteTimeBinTables(); } } - EchoInputFile = FindUnitNumber( "eplusout.audit" ); + EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); gio::write( EchoInputFile, fmtLD ) << "MonthlyInputCount=" << MonthlyInputCount; gio::write( EchoInputFile, fmtLD ) << "sizeMonthlyInput=" << sizeMonthlyInput; gio::write( EchoInputFile, fmtLD ) << "MonthlyFieldSetInputCount=" << MonthlyFieldSetInputCount; diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index 788673281fb..4139d973907 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -22,6 +22,10 @@ namespace OutputReportTabular { extern std::string outputFile; std::string assignOFile(std::string& _OFileName); + std::string assignHtmFile(std::string& _HtmFileName); + std::string assignTabFile(std::string& _TabFileName); + std::string assignTxtFile(std::string& _TxtFileName); + std::string assignXmlFile(std::string& _XmlFileName); // Using/Aliasing diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index eaf4d324fe0..ee292db3800 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -9,12 +9,14 @@ #include // EnergyPlus Headers +#include #include #include #include #include #include #include +#include #include #include #include @@ -25,8 +27,15 @@ namespace EnergyPlus { +using namespace CommandLineInterface; static gio::Fmt const fmtLD( "*" ); +std::string assignDxfFile(std::string& _DxfFileName){ + DisplayString("== Module 'Output Reports'::Name of the output (dxf) file = " + _DxfFileName + "\n"); + DisplayString("====================================================================== \n\n"); + return _DxfFileName; + } + void ReportSurfaces() { @@ -420,9 +429,9 @@ DXFOut( } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.dxf", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOut: Could not open file \"eplusout.dxf\" for output (write)." ); + ShowFatalError( "DXFOut: Could not open file "+outputDxfFile+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -913,9 +922,9 @@ DXFOutLines( std::string const & ColorScheme ) } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.dxf", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOutLines: Could not open file \"eplusout.dxf\" for output (write)." ); + ShowFatalError( "DXFOutLines: Could not open file "+outputDxfFile+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -1340,9 +1349,9 @@ DXFOutWireFrame( std::string const & ColorScheme ) } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.dxf", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOutWireFrame: Could not open file \"eplusout.dxf\" for output (write)." ); + ShowFatalError( "DXFOutWireFrame: Could not open file "+outputDxfFile+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section diff --git a/src/EnergyPlus/OutputReports.hh b/src/EnergyPlus/OutputReports.hh index 3aedd06b25a..23260c02612 100644 --- a/src/EnergyPlus/OutputReports.hh +++ b/src/EnergyPlus/OutputReports.hh @@ -9,6 +9,8 @@ namespace EnergyPlus { +std::string assignDxfFile(std::string& _DxfFileName); + void ReportSurfaces(); diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index a5a32b1eaf1..57dc0803960 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -9,6 +9,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -50,6 +51,7 @@ namespace Psychrometrics { // more research on hfg calc // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; #ifdef EP_psych_errors using namespace DataGlobals; @@ -220,7 +222,7 @@ namespace Psychrometrics { Real64 AverageIterations; std::string istring; - EchoInputFile = FindUnitNumber( "eplusout.audit" ); + EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); if ( EchoInputFile == 0 ) return; if ( any_gt( NumTimesCalled, 0 ) ) { gio::write( EchoInputFile, fmtA ) << "RoutineName,#times Called,Avg Iterations"; diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 3a6dc18ecf1..7d540cc6c81 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -5,6 +5,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -46,6 +47,7 @@ namespace ScheduleManager { // OTHER NOTES: // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataGlobals::HourOfDay; using DataGlobals::OutputFileInits; @@ -472,7 +474,7 @@ namespace ScheduleManager { Schedule( 0 ).ScheduleTypePtr = 0; Schedule( 0 ).WeekSchedulePointer = 0; - UnitNumber = FindUnitNumber( "eplusout.audit" ); + UnitNumber = FindUnitNumber( CommandLineInterface::outputAuditFile ); gio::write( UnitNumber, fmtLD ) << " Processing Schedule Input -- Start"; //!! Get Schedule Types diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 4262bdbc81d..ec1781063c0 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -11,6 +11,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -119,6 +120,8 @@ namespace SimulationManager { // and internal Evolutionary Engineering documentation. // Using/Aliasing + + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataSizing; @@ -152,12 +155,36 @@ namespace SimulationManager { std::string inputWeatherFile; std::string assignWFile(std::string& _WFileName){ - std::cout<<"====================================================================== \n"; - std::cout<<"== Module 'Manage Simulation'::Name of the weather file = "<<_WFileName< YTEMP1; // Temporary 'Y' values for HC vertices of the overlap extern int maxNumberOfFigures; + std::string assignShdFile(std::string& _ShdFileName); // SUBROUTINE SPECIFICATIONS FOR MODULE SolarShading // Types diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 0578cb2993c..1d63905f4c2 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,20 @@ namespace EnergyPlus { +// Functions + std::string assignEndFile(std::string& _EndFileName){ + DisplayString("== Module 'Utility Routines'::Name of the output (end) file = " + _EndFileName + "\n"); + DisplayString("====================================================================== \n\n"); + return _EndFileName; + } + + std::string assignErrFile(std::string& _ErrFileName){ + DisplayString("== Module 'Utility Routines'::Name of the output (err) file = " + _ErrFileName + "\n"); + DisplayString("====================================================================== \n\n"); + return _ErrFileName; + } + + void AbortEnergyPlus( bool const NoIdf, // Set to true when "noidf" was found @@ -64,6 +79,7 @@ AbortEnergyPlus( // na // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataSystemVariables; using namespace DataTimings; @@ -212,9 +228,9 @@ AbortEnergyPlus( ShowMessage( "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, "eplusout.end", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, CommandLineInterface::outputEndFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "AbortEnergyPlus: Could not open file \"eplusout.end\" for output (write)." ); + DisplayString( "AbortEnergyPlus: Could not open file "+ CommandLineInterface::outputEndFile +" for output (write)." ); } gio::write( tempfl, fmtLD ) << "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; @@ -444,9 +460,9 @@ EndEnergyPlus() ShowMessage( "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, "eplusout.end", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, CommandLineInterface::outputEndFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "EndEnergyPlus: Could not open file \"eplusout.end\" for output (write)." ); + DisplayString( "EndEnergyPlus: Could not open file " + CommandLineInterface::outputEndFile + " for output (write)." ); } gio::write( tempfl, fmtA ) << "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; gio::close( tempfl ); @@ -1597,10 +1613,10 @@ ShowErrorMessage( if ( TotalErrors == 0 && ! ErrFileOpened ) { StandardErrorOutput = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, "eplusout.err", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, CommandLineInterface::outputErrFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { DisplayString( "Trying to display error: \"" + ErrorMessage + "\"" ); - ShowFatalError( "ShowErrorMessage: Could not open file \"eplusout.err\" for output (write)." ); + ShowFatalError( "ShowErrorMessage: Could not open file "+CommandLineInterface::outputErrFile+" for output (write)." ); } gio::write( StandardErrorOutput, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; ErrFileOpened = true; diff --git a/src/EnergyPlus/UtilityRoutines.hh b/src/EnergyPlus/UtilityRoutines.hh index 33d62a4c0f7..2fe1cf28c01 100644 --- a/src/EnergyPlus/UtilityRoutines.hh +++ b/src/EnergyPlus/UtilityRoutines.hh @@ -9,6 +9,9 @@ namespace EnergyPlus { +std::string assignEndFile(std::string& _EndFileName); +std::string assignErrFile(std::string& _ErrFileName); + void AbortEnergyPlus( bool const NoIdf, // Set to true when "noidf" was found diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 61d4e59eb7e..7b85cb1eae1 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -215,7 +215,7 @@ main(int argc, const char * argv[]) using FluidProperties::ReportOrphanFluids; using Psychrometrics::ShowPsychrometricSummary; // CLI module - using namespace options; + using namespace CommandLineInterface; int status = 0; status = ProcessArgs(argc, argv); @@ -335,12 +335,12 @@ main(int argc, const char * argv[]) get_environment_variable( TraceHVACControllerEnvVar, cEnvValue ); if ( ! cEnvValue.empty() ) TraceHVACControllerEnvFlag = env_var_on( cEnvValue ); // Yes or True - { IOFlags flags; gio::inquire( "eplusout.end", flags ); FileExists = flags.exists(); } + { IOFlags flags; gio::inquire( outputEndFile, flags ); FileExists = flags.exists(); } if ( FileExists ) { LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, "eplusout.end", flags ); iostatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, outputEndFile, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"eplusout.end\" for input (read)." ); + ShowFatalError( "EnergyPlus: Could not open file "+ outputEndFile +" for input (read)." ); } { IOFlags flags; flags.DISPOSE( "delete" ); gio::close( LFN, flags ); } } diff --git a/third_party/CLI/ezOptionParser.hpp b/third_party/CLI/ezOptionParser.hpp index e76d606caca..b7a93def6e0 100644 --- a/third_party/CLI/ezOptionParser.hpp +++ b/third_party/CLI/ezOptionParser.hpp @@ -1963,7 +1963,7 @@ bool ezOptionParser::gotRequired(std::vector & badOptions) { for(i=0; i < (long int)groups.size(); ++i) { OptionGroup *g = groups[i]; // Simple case when required but user never set it. - if (g->isRequired && (!g->isSet)) { + if (g->isRequired && (!g->isSet)) { badOptions.push_back(*g->flags[0]); continue; } From 29a732af248c0fe4f6119b9c5e709d1f9563f349 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 19 Sep 2014 10:20:13 -0600 Subject: [PATCH 08/71] Typo fixed --- src/EnergyPlus/SolarShading.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 65e14acd25e..db2e4a85f0a 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -262,9 +262,9 @@ namespace SolarShading { if ( BeginSimFlag ) { OutputFileShading = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileShading, "eplusout.shd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileShading, outputShdFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "InitSolarCalculations: Could not open file \"eplustbl.shd\" for output (write)." ); + ShowFatalError( "InitSolarCalculations: Could not open file "+outputShdFile+" for output (write)." ); } if ( GetInputFlag ) { From 53e0a0361c97407923bc14450181d5f708c7a4a4 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 19 Sep 2014 11:48:26 -0600 Subject: [PATCH 09/71] Output files will be names without extension idf and epw --- src/EnergyPlus/CommandLineInterface.cc | 50 ++++++++++++++++---------- src/EnergyPlus/OutputReportTabular.cc | 20 +++++------ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index f9b287f892f..7155d4447f1 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -1,3 +1,5 @@ +//Standard C++ library +#include // CLI Headers #include @@ -110,7 +112,7 @@ ProcessArgs(int argc, const char * argv[]) } if(!opt.isSet("-h") && !opt.isSet("-v") && !opt.isSet("-i") && !opt.isSet("-o") && !opt.isSet("-w") && !opt.isSet("-e")){ - std::cout<<"Invalid option used. Exiting...\n"; + DisplayString("Invalid option used. Exiting...\n"); return 1; } @@ -177,23 +179,35 @@ ProcessArgs(int argc, const char * argv[]) inputEnergyFile = assignEFile(input_energyFile); - std::string output_File = input_filename+"_"+input_weatherFile+".csv"; - std::string output_AuditFile = input_filename+"_"+input_weatherFile+".audit"; - std::string output_BndFile = input_filename+"_"+input_weatherFile+".bnd"; - std::string output_DxfFile = input_filename+"_"+input_weatherFile+".dxf"; - std::string output_EioFile = input_filename+"_"+input_weatherFile+".eio"; - std::string output_EndFile = input_filename+"_"+input_weatherFile+".end"; - std::string output_ErrFile = input_filename+"_"+input_weatherFile+".err"; - std::string output_EsoFile = input_filename+"_"+input_weatherFile+".eso"; - std::string output_MtdFile = input_filename+"_"+input_weatherFile+".mtd"; - std::string output_MddFile = input_filename+"_"+input_weatherFile+".mdd"; - std::string output_MtrFile = input_filename+"_"+input_weatherFile+".mtr"; - std::string output_RddFile = input_filename+"_"+input_weatherFile+".rdd"; - std::string output_ShdFile = input_filename+"_"+input_weatherFile+".shd"; - std::string output_HtmFile = input_filename+"_"+input_weatherFile+".htm"; - std::string output_TabFile = input_filename+"_"+input_weatherFile+".tab"; - std::string output_TxtFile = input_filename+"_"+input_weatherFile+".txt"; - std::string output_XmlFile = input_filename+"_"+input_weatherFile+".xml"; + std::string s = inputFileName; + std::string ss = inputWeatherFile; + std::string delim = "."; + + auto start = 0U; + + DisplayString("Name of the input file without extension = " + s.substr(start, s.size()-4) + "\n"); + DisplayString("Name of the input weather file without extension = " + ss.substr(start, ss.size()-4) + "\n"); + + std::string fileName_input = s.substr(start, s.size()-4); + std::string fileName_weather = ss.substr(start, ss.size()-4); + + std::string output_File = fileName_input+"_"+fileName_weather+".csv"; + std::string output_AuditFile = fileName_input+"_"+fileName_weather+".audit"; + std::string output_BndFile = fileName_input+"_"+fileName_weather+".bnd"; + std::string output_DxfFile = fileName_input+"_"+fileName_weather+".dxf"; + std::string output_EioFile = fileName_input+"_"+fileName_weather+".eio"; + std::string output_EndFile = fileName_input+"_"+fileName_weather+".end"; + std::string output_ErrFile = fileName_input+"_"+fileName_weather+".err"; + std::string output_EsoFile = fileName_input+"_"+fileName_weather+".eso"; + std::string output_MtdFile = fileName_input+"_"+fileName_weather+".mtd"; + std::string output_MddFile = fileName_input+"_"+fileName_weather+".mdd"; + std::string output_MtrFile = fileName_input+"_"+fileName_weather+".mtr"; + std::string output_RddFile = fileName_input+"_"+fileName_weather+".rdd"; + std::string output_ShdFile = fileName_input+"_"+fileName_weather+".shd"; + std::string output_HtmFile = fileName_input+"_"+fileName_weather+".htm"; + std::string output_TabFile = fileName_input+"_"+fileName_weather+".tab"; + std::string output_TxtFile = fileName_input+"_"+fileName_weather+".txt"; + std::string output_XmlFile = fileName_input+"_"+fileName_weather+".xml"; if (opt.isSet("-o")) { std::ofstream output; diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 0da7a6dc2aa..127b98f5a61 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -410,8 +410,8 @@ namespace OutputReportTabular { // Functions std::string outputFile; std::string assignOFile(std::string& _OFileName){ - std::cout<<"== Module 'Output report tabular'::Name of the output file = "<<_OFileName< Date: Fri, 19 Sep 2014 18:00:17 -0600 Subject: [PATCH 10/71] Clean up Command Line Interface to have minimal changes in other files. --- src/EnergyPlus/CommandLineInterface.cc | 419 +++++++++---------------- src/EnergyPlus/CommandLineInterface.hh | 4 + src/EnergyPlus/DataSystemVariables.cc | 2 +- src/EnergyPlus/InputProcessor.cc | 39 +-- src/EnergyPlus/InputProcessor.hh | 13 +- src/EnergyPlus/OutputProcessor.cc | 23 +- src/EnergyPlus/OutputProcessor.hh | 4 - src/EnergyPlus/OutputReportTabular.cc | 37 +-- src/EnergyPlus/OutputReportTabular.hh | 13 +- src/EnergyPlus/OutputReports.cc | 7 - src/EnergyPlus/OutputReports.hh | 2 - src/EnergyPlus/Psychrometrics.cc | 2 +- src/EnergyPlus/ScheduleManager.cc | 2 +- src/EnergyPlus/SimulationManager.cc | 46 +-- src/EnergyPlus/SimulationManager.hh | 9 +- src/EnergyPlus/SolarShading.cc | 6 - src/EnergyPlus/SolarShading.hh | 1 - src/EnergyPlus/ThermalComfort.cc | 17 +- src/EnergyPlus/UtilityRoutines.cc | 38 +-- src/EnergyPlus/UtilityRoutines.hh | 3 - src/EnergyPlus/WeatherManager.cc | 13 +- src/EnergyPlus/main.cc | 7 +- src/EnergyPlus/main.hh | 1 - 23 files changed, 203 insertions(+), 505 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 7155d4447f1..555216d2c64 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -1,9 +1,10 @@ //Standard C++ library #include +#include +#include // CLI Headers #include -#include // Project headers #include @@ -17,298 +18,160 @@ #include #include #include -using namespace ez; namespace EnergyPlus{ namespace CommandLineInterface{ -using namespace DataStringGlobals; -using namespace InputProcessor; -using namespace SimulationManager; -using namespace OutputReportTabular; -using namespace OutputProcessor; -using namespace SolarShading; - -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 outputHtmFile; -std::string outputTabFile; -std::string outputTxtFile; -std::string outputXmlFile; - -void Usage(ezOptionParser& opt) { - std::string usage; - opt.getUsage(usage); - DisplayString(usage); -}; - -int -ProcessArgs(int argc, const char * argv[]) -{ - std::istream* instream; - std::string input_filename; - std::string input_weatherFile; - std::string input_energyFile; - - std::ifstream input; - std::ifstream input1; - std::ifstream input2; - - - ezOptionParser opt; - - opt.overview = "*******************************************\n"; - opt.overview += "Copyright (C) 1996-2014 \n"; // Add owners of copyright? - opt.overview += "Web: www.energyplus.gov\n"; - opt.overview += VerString; - opt.overview += "\n*******************************************\n"; - opt.syntax = "./EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -o OutFile.csv"; - - opt.add("", 0, 1, 0, "Usage information displayed on top", "-h", "--help"); - - opt.add("", 0, 1, 0, "Options to get version control", "-v", "--version"); - - opt.add("in.idf", 0, 1, 0, "Input file to process", "-i", "--input"); - - opt.add("in.epw", 0, 1, 0, "Input weather file to process", "-w", "--weather"); - - opt.add("Energy+.idd", 0, 1, 0, "Input energy file to process", "-e", "--energy"); - - opt.add("eplustbl.csv", 0, 0, 0, "Output file", "-o", "--output"); - - std::string usage; - opt.parse(argc, argv); - - if (opt.isSet("-h")) { - opt.getUsage(usage); - DisplayString(usage); - return 1; + using namespace DataStringGlobals; + using namespace InputProcessor; + using namespace SimulationManager; + using namespace OutputReportTabular; + using namespace OutputProcessor; + 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; + + int + ProcessArgs(int argc, const char * argv[]) + { + ezOptionParser opt; + + opt.overview = VerString; + opt.example = "EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -o"; + + opt.syntax = "EnergyPlus [options]"; + + opt.add("", 0, 0, 0, "Display this message", "-h", "--help"); + + opt.add("", 0, 0, 0, "Print version invormation", "-v", "--version"); + + opt.add("in.idf", 0, 1, 0, "Input Definition File (IDF) file path (default \".\\in.idf\")", "-i", "--idf"); + + opt.add("in.epw", 0, 1, 0, "EnergyPlus Weather (EPW) file path (default \".\\in.epw\")", "-w", "--weather"); + + opt.add("Energy+.idd", 0, 1, 0, "Input Data Dictionary (IDD) file path (default \".\\Energy+.idd\")", "-e", "--idd"); + + opt.add("", 0, 0, 0, "Rename output files to using the IDF and EPW file names", "-o", "--output"); + + // Parse arguments + opt.parse(argc, argv); + + // print arguments parsed (useful for debugging) + /* + std::string pretty; + + opt.prettyPrint(pretty); + + std::cout << pretty << std::endl; + */ + + std::string usage; + opt.getUsage(usage); + + // Handle bad options + std::vector badOptions; + + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("ERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + } + DisplayString(usage); + exit(EXIT_FAILURE); } - if (opt.isSet("-v")) { - DisplayString(VerString); - return 1; - } - - Usage(opt); //Ugly at the moment - - std::vector badOptions; - if(!opt.gotExpected(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) - DisplayString("ERROR: Got unexpected number of arguments for option " + badOptions[i] + ".\n\n"); - DisplayString("Usage information displayed above. \n"); - return 1; - } - - if(!opt.isSet("-h") && !opt.isSet("-v") && !opt.isSet("-i") && !opt.isSet("-o") && !opt.isSet("-w") && !opt.isSet("-e")){ - DisplayString("Invalid option used. Exiting...\n"); - return 1; - } - - if(!opt.gotRequired(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) - std::cerr << "ERROR: Missing required option " << badOptions[i] << ".\n\n"; - Usage(opt); - return 1; - } - - - if (opt.isSet("-i")) { - opt.get("-i")->getString(input_filename); - input.open( input_filename.c_str() ); - instream = &input; - DisplayString("\n\n====================================================================== \n"); - DisplayString("-- Input file request by the user = " + input_filename); - if (!input) { - DisplayString("\n -X- Error opening input file = " + input_filename + " -X- \n"); - DisplayString(" -X- Exiting -X- \n") ; - return -1; - } - } - - if (opt.isSet("-w")) { - opt.get("-w")->getString(input_weatherFile); - input1.open( input_weatherFile.c_str() ); - instream = &input1; - DisplayString("====================================================================== \n"); - DisplayString("-- Weather file requested by the user = " + input_weatherFile + "\n"); - if (!input1) { - DisplayString("\n -X- Error opening weather file = " + input_weatherFile + " -X- \n"); - DisplayString(" -X- Exiting -X- \n"); - return -1; - } - } - - if (opt.isSet("-e")) { - opt.get("-e")->getString(input_energyFile); - input2.open( input_energyFile.c_str() ); - instream = &input2; - DisplayString("====================================================================== \n"); - DisplayString("-- Energy file requested by the user = " + input_energyFile + "\n"); - DisplayString("====================================================================== "); - if (!input2) { - DisplayString("\n -X- Error opening energy file = " + input_energyFile + " -X- \n"); - DisplayString(" -X- Exiting -X- \n"); - return -1; - } - } - - if(input_filename.empty()) - input_filename = "in.idf"; - - inputFileName = assign(input_filename); - - if(input_weatherFile.empty()) - input_weatherFile = "in.epw"; - - inputWeatherFile = assignWFile(input_weatherFile); - - if(input_energyFile.empty()) - input_energyFile = "Energy+.idd"; - - inputEnergyFile = assignEFile(input_energyFile); - - std::string s = inputFileName; - std::string ss = inputWeatherFile; - std::string delim = "."; - - auto start = 0U; - - DisplayString("Name of the input file without extension = " + s.substr(start, s.size()-4) + "\n"); - DisplayString("Name of the input weather file without extension = " + ss.substr(start, ss.size()-4) + "\n"); - - std::string fileName_input = s.substr(start, s.size()-4); - std::string fileName_weather = ss.substr(start, ss.size()-4); - - std::string output_File = fileName_input+"_"+fileName_weather+".csv"; - std::string output_AuditFile = fileName_input+"_"+fileName_weather+".audit"; - std::string output_BndFile = fileName_input+"_"+fileName_weather+".bnd"; - std::string output_DxfFile = fileName_input+"_"+fileName_weather+".dxf"; - std::string output_EioFile = fileName_input+"_"+fileName_weather+".eio"; - std::string output_EndFile = fileName_input+"_"+fileName_weather+".end"; - std::string output_ErrFile = fileName_input+"_"+fileName_weather+".err"; - std::string output_EsoFile = fileName_input+"_"+fileName_weather+".eso"; - std::string output_MtdFile = fileName_input+"_"+fileName_weather+".mtd"; - std::string output_MddFile = fileName_input+"_"+fileName_weather+".mdd"; - std::string output_MtrFile = fileName_input+"_"+fileName_weather+".mtr"; - std::string output_RddFile = fileName_input+"_"+fileName_weather+".rdd"; - std::string output_ShdFile = fileName_input+"_"+fileName_weather+".shd"; - std::string output_HtmFile = fileName_input+"_"+fileName_weather+".htm"; - std::string output_TabFile = fileName_input+"_"+fileName_weather+".tab"; - std::string output_TxtFile = fileName_input+"_"+fileName_weather+".txt"; - std::string output_XmlFile = fileName_input+"_"+fileName_weather+".xml"; - - if (opt.isSet("-o")) { - std::ofstream output; - output.open( output_File.c_str() ); - DisplayString("====================================================================== \n"); - DisplayString("-- Output to be stored in file = " + output_File + "\n"); - DisplayString("====================================================================== "); - if (!output) { - DisplayString("\n -X- Error opening output file = " + output_File + " -X- \n"); - DisplayString(" -X- Exiting -X- \n"); - return -1; - } - } - - if(output_File.empty()) - output_File = "eplustbl.csv"; - - outputFile = assignOFile(output_File); - - if(output_AuditFile.empty()) - output_AuditFile = "eplusout.audit"; - - outputAuditFile = assignAuditFile(output_AuditFile); - - if(output_BndFile.empty()) - output_BndFile = "eplusout.bnd"; - - outputBndFile = assignBndFile(output_BndFile); - - if(output_DxfFile.empty()) - output_DxfFile = "eplusout.dxf"; - - outputDxfFile = assignDxfFile(output_DxfFile); - - if(output_EioFile.empty()) - output_EioFile = "eplusout.eio"; - - outputEioFile = assignEioFile(output_EioFile); - - if(output_EndFile.empty()) - output_EndFile = "eplusout.end"; - - outputEndFile = assignEndFile(output_EndFile); - - if(output_ErrFile.empty()) - output_ErrFile = "eplusout.err"; - - outputErrFile = assignErrFile(output_ErrFile); - - if(output_EsoFile.empty()) - output_EsoFile = "eplusout.eso"; - - outputEsoFile = assignEsoFile(output_EsoFile); - - if(output_MtdFile.empty()) - output_MtdFile = "eplusout.mtd"; - - outputMtdFile = assignMtdFile(output_MtdFile); - - if(output_MddFile.empty()) - output_MddFile = "eplusout.mdd"; - - outputMddFile = assignMddFile(output_MddFile); - - if(output_MtrFile.empty()) - output_MtrFile = "eplusout.mtr"; - - outputMtrFile = assignMtrFile(output_MtrFile); - - if(output_RddFile.empty()) - output_RddFile = "eplusout.rdd"; - - outputRddFile = assignRddFile(output_RddFile); - - if(output_ShdFile.empty()) - output_ShdFile = "eplusout.shd"; - - outputShdFile = assignShdFile(output_ShdFile); + 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"); + } + for(int i=0; i < opt.unknownArgs.size(); ++i) { + std::string arg(opt.unknownArgs[i]->c_str()); + DisplayString("ERROR: Invalid option: " + 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"); + } + DisplayString(usage); + exit(EXIT_FAILURE); + } - if(output_HtmFile.empty()) - output_HtmFile = "eplustbl.htm"; + if(!opt.gotRequired(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("ERROR: Missing required option " + badOptions[i] + "\n"); + } + DisplayString(usage); + exit(EXIT_FAILURE); + } - outputHtmFile = assignHtmFile(output_HtmFile); + // Process arguments + if (opt.isSet("-h")) { + DisplayString(usage); + exit(EXIT_SUCCESS); + } - if(output_TabFile.empty()) - output_TabFile = "eplustbl.tab"; + if (opt.isSet("-v")) { + DisplayString(VerString); + exit(EXIT_SUCCESS); + } - outputTabFile = assignTabFile(output_TabFile); + opt.get("-i")->getString(inputFileName); - if(output_TxtFile.empty()) - output_TxtFile = "eplustbl.txt"; + opt.get("-w")->getString(inputWeatherFile); - outputTxtFile = assignTxtFile(output_TxtFile); + opt.get("-e")->getString(inputEnergyFile); - if(output_XmlFile.empty()) - output_XmlFile = "eplustbl.xml"; + std::string outputFilePrefix; - outputXmlFile = assignXmlFile(output_XmlFile); + if (opt.isSet("-o")) { + outputFilePrefix = + inputFileName.substr(0, inputFileName.size()-4) + "_" + + inputWeatherFile.substr(0, inputWeatherFile.size()-4) + "_"; + } + else { + outputFilePrefix = "eplus"; + } - return 0; - ///////////////////////////////////////////////////// -} + 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 } //EnergyPlus namespace diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index e55e69bfba3..40012bb235d 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -18,10 +18,14 @@ namespace CommandLineInterface { 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; // Process command line arguments int diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index d09ddb280a1..632e67e01ee 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -187,7 +187,7 @@ namespace DataSystemVariables { std::string::size_type pos; if ( firstTime ) { - EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); + EchoInputFile = FindUnitNumber( outputAuditFile ); get_environment_variable( cInputPath1, envinputpath1 ); if ( envinputpath1 != blank ) { pos = index( envinputpath1, pathChar, true ); // look backwards for pathChar diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index bfe15e02f7e..cbbb3dbe94a 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -15,9 +15,6 @@ #include #include -//Standard C++ library -#include - namespace EnergyPlus { namespace InputProcessor { @@ -65,8 +62,7 @@ namespace InputProcessor { using DataSystemVariables::SortedIDD; using DataSystemVariables::iASCII_CR; using DataSystemVariables::iUnicode_end; - - + // Use statements for access to subroutines in other modules // Data @@ -92,8 +88,6 @@ namespace InputProcessor { Real64 const DefAutoCalculateValue( AutoCalculate ); static gio::Fmt const fmtLD( "*" ); static gio::Fmt const fmtA( "(A)" ); - std::string inputFileName; - std::string inputEnergyFile; // DERIVED TYPE DEFINITIONS @@ -172,25 +166,6 @@ namespace InputProcessor { FArray1D< LineDefinition > IDFRecords; // All the objects read from the IDF FArray1D< SecretObjects > RepObjects; // Secret Objects that could replace old ones - std::string assign(std::string& _FileName){ - DisplayString("====================================================================== \n"); - DisplayString("== Module 'Input Processor'::Name of the input file = " + _FileName + "\n"); - return _FileName; - } - - std::string assignEFile(std::string& _EFileName){ - DisplayString("== Module 'Input Processor'::Name of the energy file = " + _EFileName + "\n"); - DisplayString("====================================================================== \n\n"); - return _EFileName; - } - - std::string assignAuditFile(std::string& _AuditFileName){ - DisplayString("== Module 'Input Processor'::Name of the output (audit) file = " +_AuditFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _AuditFileName; - } - - // MODULE SUBROUTINES: //************************************************************************* @@ -252,14 +227,14 @@ namespace InputProcessor { int endcol; int write_stat; int read_stat; - + InitSecretObjects(); EchoInputFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( EchoInputFile, CommandLineInterface::outputAuditFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( EchoInputFile, outputAuditFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "Could not open (write) "+ CommandLineInterface::outputAuditFile + " ." ); - ShowFatalError( "ProcessInput: Could not open file " + CommandLineInterface::outputAuditFile + " for output (write)." ); + DisplayString( "Could not open (write) "+ outputAuditFile + " ." ); + ShowFatalError( "ProcessInput: Could not open file " + outputAuditFile + " for output (write)." ); } { IOFlags flags; gio::inquire( "eplusout.iperr", flags ); FileExists = flags.exists(); } @@ -275,7 +250,7 @@ namespace InputProcessor { { IOFlags flags; flags.ACTION( "write" ); gio::open( CacheIPErrorFile, "eplusout.iperr", flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { DisplayString( "Could not open (write) eplusout.iperr." ); - ShowFatalError( "ProcessInput: Could not open file " + CommandLineInterface::outputAuditFile + " for output (write)." ); + ShowFatalError( "ProcessInput: Could not open file " + outputAuditFile + " for output (write)." ); } // FullName from StringGlobals is used to build file name with Path @@ -652,7 +627,7 @@ namespace InputProcessor { ErrorsFound = true; } } else { - ShowSevereError( "IP: Blank Sections not allowed. Review " + CommandLineInterface::outputAuditFile + " file.", EchoInputFile ); + ShowSevereError( "IP: Blank Sections not allowed. Review " + outputAuditFile + " file.", EchoInputFile ); errFlag = true; ErrorsFound = true; } diff --git a/src/EnergyPlus/InputProcessor.hh b/src/EnergyPlus/InputProcessor.hh index e90121b44b9..858183c1902 100644 --- a/src/EnergyPlus/InputProcessor.hh +++ b/src/EnergyPlus/InputProcessor.hh @@ -89,9 +89,7 @@ namespace InputProcessor { extern std::string CurrentFieldName; // Current Field Name (IDD) extern FArray1D_string ObsoleteObjectsRepNames; // Array of Replacement names for Obsolete objects extern std::string ReplacementName; - extern std::string inputFileName; - extern std::string inputEnergyFile; - + //Logical Variables for Module extern bool OverallErrorFlag; // If errors found during parse of IDF, will fatal at end extern bool EchoInputLine; // Usually True, if the IDD is backspaced, then is set to false, then back to true @@ -409,12 +407,9 @@ namespace InputProcessor { extern LineDefinition LineItem; // Description of current record extern FArray1D< LineDefinition > IDFRecords; // All the objects read from the IDF extern FArray1D< SecretObjects > RepObjects; // Secret Objects that could replace old ones - + // Functions - std::string assign(std::string& _FileName); - std::string assignEFile(std::string& _EFileName); - std::string assignAuditFile(std::string& _AuditFileName); - + void ProcessInput(); @@ -872,7 +867,7 @@ namespace InputProcessor { // NOTICE - // Copyright � 1996-2014 The Board of Trustees of the University of Illinois + // Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 80fb3d3d0fd..d7de5116592 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -243,25 +242,7 @@ namespace OutputProcessor { // UpdateDataandReport // UpdateMeterReporting - // Function - - std::string assignMtdFile(std::string& _MtdFileName){ - DisplayString("== Module 'Output Processor'::Name of the output (mtd) file = " +_MtdFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _MtdFileName; - } - - std::string assignMddFile(std::string& _MddFileName){ - DisplayString("== Module 'Output Processor'::Name of the output (mdd) file = " +_MddFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _MddFileName; - } - - std::string assignRddFile(std::string& _RddFileName){ - DisplayString("== Module 'Output Processor'::Name of the output (rdd) file = " +_RddFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _RddFileName; - } + // Functions void InitializeOutput() @@ -8500,7 +8481,7 @@ AddToOutputVariableList( } // NOTICE -// Copyright � 1996-2014 The Board of Trustees of the University of Illinois +// Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. // Portions of the EnergyPlus software package have been developed and copyrighted diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index 860e1ff6091..98abe4518fe 100644 --- a/src/EnergyPlus/OutputProcessor.hh +++ b/src/EnergyPlus/OutputProcessor.hh @@ -138,10 +138,6 @@ namespace OutputProcessor { extern int MaxNumSubcategories; - std::string assignMtdFile(std::string& _MtdFileName); - std::string assignMddFile(std::string& _MddFileName); - std::string assignRddFile(std::string& _RddFileName); - // All routines should be listed here whether private or not //PUBLIC ReallocateTVar //PUBLIC SetReportNow diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 127b98f5a61..6e3b76aab58 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -408,36 +408,6 @@ namespace OutputReportTabular { static gio::Fmt const fmtA( "(A)" ); // Functions - std::string outputFile; - std::string assignOFile(std::string& _OFileName){ - DisplayString("== Module 'Output report tabular'::Name of the output file = "+_OFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _OFileName; - } - - std::string assignHtmFile(std::string& _HtmFileName){ - DisplayString("== Module 'Output Report Tabular'::Name of the output (htm) file = " +_HtmFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _HtmFileName; - } - - std::string assignTabFile(std::string& _TabFileName){ - DisplayString("== Module 'Output Report Tabular'::Name of the output (tab) file = " +_TabFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _TabFileName; - } - - std::string assignTxtFile(std::string& _TxtFileName){ - DisplayString("== Module 'Output Report Tabular'::Name of the output (txt) file = " +_TxtFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _TxtFileName; - } - - std::string assignXmlFile(std::string& _XmlFileName){ - DisplayString("== Module 'Output Report Tabular'::Name of the output (xml) file = " +_XmlFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _XmlFileName; - } void UpdateTabularReports( int const IndexTypeKey ) // What kind of data to update (Zone, HVAC) @@ -3141,9 +3111,9 @@ namespace OutputReportTabular { curDel = del( iStyle ); if ( TableStyle( iStyle ) == tableStyleComma ) { DisplayString( "Writing tabular output file results using comma format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputCsvFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file (" + outputFile + ") for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file (" + outputCsvFile + ") for output (write)." ); } gio::write( curFH, fmtA ) << "Program Version:" + curDel + VerString; gio::write( curFH, fmtLD ) << "Tabular Output Report in Format: " + curDel + "Comma"; @@ -4835,7 +4805,6 @@ namespace OutputReportTabular { // report is added it can be added to the list here. // Locals - int EchoInputFile; // found unit number for 'eplusout.audit' FillWeatherPredefinedEntries(); @@ -4858,7 +4827,7 @@ namespace OutputReportTabular { WriteTimeBinTables(); } } - EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); + EchoInputFile = FindUnitNumber( outputAuditFile ); gio::write( EchoInputFile, fmtLD ) << "MonthlyInputCount=" << MonthlyInputCount; gio::write( EchoInputFile, fmtLD ) << "sizeMonthlyInput=" << sizeMonthlyInput; gio::write( EchoInputFile, fmtLD ) << "MonthlyFieldSetInputCount=" << MonthlyFieldSetInputCount; diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index 4139d973907..56419be37b7 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -20,13 +20,6 @@ namespace EnergyPlus { namespace OutputReportTabular { - extern std::string outputFile; - std::string assignOFile(std::string& _OFileName); - std::string assignHtmFile(std::string& _HtmFileName); - std::string assignTabFile(std::string& _TabFileName); - std::string assignTxtFile(std::string& _TxtFileName); - std::string assignXmlFile(std::string& _XmlFileName); - // Using/Aliasing // Data @@ -297,7 +290,6 @@ namespace OutputReportTabular { extern std::string activeReportName; extern std::string activeForName; extern std::string prevReportName; - // SUBROUTINE SPECIFICATIONS FOR MODULE PrimaryPlantLoops //PRIVATE DateToStr @@ -732,7 +724,7 @@ namespace OutputReportTabular { extern FArray1D< UnitConvType > UnitConv; // Functions - + void UpdateTabularReports( int const IndexTypeKey ); // What kind of data to update (Zone, HVAC) @@ -744,7 +736,6 @@ namespace OutputReportTabular { //====================================================================================================================== //====================================================================================================================== - void GetInputTabularMonthly(); @@ -1072,7 +1063,7 @@ namespace OutputReportTabular { // NOTICE - // Copyright � 1996-2014 The Board of Trustees of the University of Illinois + // Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index ee292db3800..e464458b5f9 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -30,12 +29,6 @@ namespace EnergyPlus { using namespace CommandLineInterface; static gio::Fmt const fmtLD( "*" ); -std::string assignDxfFile(std::string& _DxfFileName){ - DisplayString("== Module 'Output Reports'::Name of the output (dxf) file = " + _DxfFileName + "\n"); - DisplayString("====================================================================== \n\n"); - return _DxfFileName; - } - void ReportSurfaces() { diff --git a/src/EnergyPlus/OutputReports.hh b/src/EnergyPlus/OutputReports.hh index 23260c02612..3aedd06b25a 100644 --- a/src/EnergyPlus/OutputReports.hh +++ b/src/EnergyPlus/OutputReports.hh @@ -9,8 +9,6 @@ namespace EnergyPlus { -std::string assignDxfFile(std::string& _DxfFileName); - void ReportSurfaces(); diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index 57dc0803960..3cc7094ccb6 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -222,7 +222,7 @@ namespace Psychrometrics { Real64 AverageIterations; std::string istring; - EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); + EchoInputFile = FindUnitNumber( outputAuditFile ); if ( EchoInputFile == 0 ) return; if ( any_gt( NumTimesCalled, 0 ) ) { gio::write( EchoInputFile, fmtA ) << "RoutineName,#times Called,Avg Iterations"; diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 7d540cc6c81..b6c455f3693 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -474,7 +474,7 @@ namespace ScheduleManager { Schedule( 0 ).ScheduleTypePtr = 0; Schedule( 0 ).WeekSchedulePointer = 0; - UnitNumber = FindUnitNumber( CommandLineInterface::outputAuditFile ); + UnitNumber = FindUnitNumber( outputAuditFile ); gio::write( UnitNumber, fmtLD ) << " Processing Schedule Input -- Start"; //!! Get Schedule Types diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index ec1781063c0..e2cd8952ca4 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -152,38 +152,6 @@ namespace SimulationManager { // MODULE SUBROUTINES: // Functions - std::string inputWeatherFile; - - std::string assignWFile(std::string& _WFileName){ - DisplayString("====================================================================== \n"); - DisplayString("== Module 'Manage Simulation'::Name of the weather file = " + _WFileName +"\n"); - DisplayString("====================================================================== \n"); - return _WFileName; - } - - std::string assignBndFile(std::string& _BndFileName){ - DisplayString("== Module 'Manage Simulation'::Name of the output (bnd) file = " + _BndFileName +"\n"); - DisplayString("====================================================================== \n\n"); - return _BndFileName; - } - - std::string assignEioFile(std::string& _EioFileName){ - DisplayString("== Module 'Manage Simulation'::Name of the output (eio) file = " + _EioFileName +"\n"); - DisplayString("====================================================================== \n\n"); - return _EioFileName; - } - - std::string assignEsoFile(std::string& _EsoFileName){ - DisplayString("== Module 'Manage Simulation'::Name of the output (eso) file = " + _EsoFileName +"\n"); - DisplayString("====================================================================== \n\n"); - return _EsoFileName; - } - - std::string assignMtrFile(std::string& _MtrFileName){ - DisplayString("== Module 'Manage Simulation'::Name of the output (mtr) file = " + _MtrFileName +"\n"); - DisplayString("====================================================================== \n\n"); - return _MtrFileName; - } void ManageSimulation() @@ -285,8 +253,7 @@ namespace SimulationManager { // CHARACTER(len=70) :: tdstring // CHARACTER(len=138) :: tdstringlong - - + int EnvCount; // Formats @@ -468,8 +435,7 @@ namespace SimulationManager { if ( WarmupFlag ) { ++NumOfWarmupDays; cWarmupDay = TrimSigDigits( NumOfWarmupDays ); - // DisplayString( "Warming up {" + cWarmupDay + '}' ); - DisplayString( "Warming up {"+cWarmupDay+"}" ); + DisplayString( "Warming up {" + cWarmupDay + '}' ); } else if ( DayOfSim == 1 ) { DisplayString( "Starting Simulation at " + CurMnDy + " for " + EnvironmentName ); gio::write( OutputFileInits, Format_700 ) << NumOfWarmupDays; @@ -1241,9 +1207,9 @@ namespace SimulationManager { // FLOW: OutputFileStandard = GetNewUnitNumber(); StdOutputRecordCount = 0; - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileStandard, CommandLineInterface::outputEsoFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileStandard, outputEsoFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+CommandLineInterface::outputEsoFile+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+outputEsoFile+" for output (write)." ); } gio::write( OutputFileStandard, fmtA ) << "Program Version," + VerString; @@ -1348,7 +1314,7 @@ namespace SimulationManager { std::string cepEnvSetThreads; std::string cIDFSetThreads; - EchoInputFile = FindUnitNumber( CommandLineInterface::outputAuditFile ); + EchoInputFile = FindUnitNumber( outputAuditFile ); // Record some items on the audit file gio::write( EchoInputFile, fmtLD ) << "NumOfRVariable=" << NumOfRVariable_Setup; gio::write( EchoInputFile, fmtLD ) << "NumOfRVariable(Total)=" << NumTotalRVariable; @@ -2821,7 +2787,7 @@ Resimulate( } // NOTICE -// Copyright � 1996-2014 The Board of Trustees of the University of Illinois +// Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. // Portions of the EnergyPlus software package have been developed and copyrighted diff --git a/src/EnergyPlus/SimulationManager.hh b/src/EnergyPlus/SimulationManager.hh index e01a513abc4..9f003d86177 100644 --- a/src/EnergyPlus/SimulationManager.hh +++ b/src/EnergyPlus/SimulationManager.hh @@ -31,17 +31,10 @@ namespace SimulationManager { // MODULE VARIABLE DECLARATIONS: extern bool RunPeriodsInInput; extern bool RunControlInInput; - extern std::string inputWeatherFile; // SUBROUTINE SPECIFICATIONS FOR MODULE SimulationManager // Functions - - std::string assignWFile(std::string& _WFileName); - std::string assignBndFile(std::string& _BndFileName); - std::string assignEioFile(std::string& _EioFileName); - std::string assignEsoFile(std::string& _EsoFileName); - std::string assignMtrFile(std::string& _MtrFileName); void ManageSimulation(); @@ -97,7 +90,7 @@ Resimulate( ); // NOTICE -// Copyright � 1996-2014 The Board of Trustees of the University of Illinois +// Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. // Portions of the EnergyPlus software package have been developed and copyrighted diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index db2e4a85f0a..853dba9738e 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -210,12 +210,6 @@ namespace SolarShading { // Functions - std::string assignShdFile(std::string& _ShdFileName){ - DisplayString("== Module 'Solar shading'::Name of the output (shd) file = " +_ShdFileName+ "\n"); - DisplayString("====================================================================== \n\n"); - return _ShdFileName; - } - void InitSolarCalculations() { diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index 4c8bb0a829c..cc047ea23a1 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -120,7 +120,6 @@ namespace SolarShading { extern FArray1D< Real64 > YTEMP1; // Temporary 'Y' values for HC vertices of the overlap extern int maxNumberOfFigures; - std::string assignShdFile(std::string& _ShdFileName); // SUBROUTINE SPECIFICATIONS FOR MODULE SolarShading // Types diff --git a/src/EnergyPlus/ThermalComfort.cc b/src/EnergyPlus/ThermalComfort.cc index bc655d354c5..0497cce79df 100644 --- a/src/EnergyPlus/ThermalComfort.cc +++ b/src/EnergyPlus/ThermalComfort.cc @@ -10,6 +10,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include namespace EnergyPlus { @@ -59,6 +59,7 @@ namespace ThermalComfort { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using DataHeatBalance::MRT; @@ -2468,7 +2469,7 @@ namespace ThermalComfort { if ( initiate && weathersimulation ) { { IOFlags flags; gio::inquire( "in.stat", flags ); statFileExists = flags.exists(); } - { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFile, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( statFileExists ) { statFile = GetNewUnitNumber(); @@ -2493,9 +2494,9 @@ namespace ThermalComfort { useStatData = true; } else if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, SimulationManager::inputWeatherFile, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFile, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " +SimulationManager::inputWeatherFile+ " for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " + inputWeatherFile+ " for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } @@ -2719,13 +2720,13 @@ namespace ThermalComfort { } if ( initiate && weathersimulation ) { - { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFile, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, SimulationManager::inputWeatherFile, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFile, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+SimulationManager::inputWeatherFile+" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+inputWeatherFile+" for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } @@ -2929,7 +2930,7 @@ namespace ThermalComfort { // NOTICE - // Copyright � 1996-2014 The Board of Trustees of the University of Illinois + // Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 1d63905f4c2..97836ad6789 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -28,7 +28,6 @@ #include #include #include -#include //Added to pass inputEnergyFile (MS) #include #include #include @@ -40,20 +39,6 @@ namespace EnergyPlus { -// Functions - std::string assignEndFile(std::string& _EndFileName){ - DisplayString("== Module 'Utility Routines'::Name of the output (end) file = " + _EndFileName + "\n"); - DisplayString("====================================================================== \n\n"); - return _EndFileName; - } - - std::string assignErrFile(std::string& _ErrFileName){ - DisplayString("== Module 'Utility Routines'::Name of the output (err) file = " + _ErrFileName + "\n"); - DisplayString("====================================================================== \n\n"); - return _ErrFileName; - } - - void AbortEnergyPlus( bool const NoIdf, // Set to true when "noidf" was found @@ -183,12 +168,12 @@ AbortEnergyPlus( strip( NumSevereDuringSizing ); if ( NoIDD ) { - DisplayString( "No EnergyPlus Data Dictionary (" +InputProcessor::inputEnergyFile+") was found. It is possible " ); + DisplayString( "No EnergyPlus Data Dictionary (" + inputEnergyFile+") was found. It is possible " ); DisplayString( "you \"double-clicked\"EnergyPlus.exe rather than using one of the methods" ); DisplayString( "to run Energyplus as found in the GettingStarted document in the" ); DisplayString( "documentation folder. Using EP-Launch may be best -- " ); DisplayString( "it provides extra help for new users." ); - ShowMessage( "No EnergyPlus Data Dictionary (" +InputProcessor::inputEnergyFile+") was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); + ShowMessage( "No EnergyPlus Data Dictionary (" + inputEnergyFile+") was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); ShowMessage( "rather than using one of the methods to run Energyplus as found in the GettingStarted document" ); ShowMessage( "in the documentation folder. Using EP-Launch may be best -- it provides extra help for new users." ); { IOFlags flags; flags.ADVANCE( "NO" ); gio::write( OutFmt, flags ); } @@ -228,9 +213,9 @@ AbortEnergyPlus( ShowMessage( "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, CommandLineInterface::outputEndFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "AbortEnergyPlus: Could not open file "+ CommandLineInterface::outputEndFile +" for output (write)." ); + DisplayString( "AbortEnergyPlus: Could not open file "+ outputEndFile +" for output (write)." ); } gio::write( tempfl, fmtLD ) << "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; @@ -383,6 +368,7 @@ EndEnergyPlus() // na // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataSystemVariables; using namespace DataTimings; @@ -460,9 +446,9 @@ EndEnergyPlus() ShowMessage( "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, CommandLineInterface::outputEndFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "EndEnergyPlus: Could not open file " + CommandLineInterface::outputEndFile + " for output (write)." ); + DisplayString( "EndEnergyPlus: Could not open file " + outputEndFile + " for output (write)." ); } gio::write( tempfl, fmtA ) << "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; gio::close( tempfl ); @@ -825,6 +811,7 @@ ShowFatalError( // na // Using/Aliasing + using namespace CommandLineInterface; using namespace DataErrorTracking; using General::RoundSigDigits; @@ -846,7 +833,7 @@ ShowFatalError( ShowErrorMessage( " ** Fatal ** " + ErrorMessage, OutUnit1, OutUnit2 ); DisplayString( "**FATAL:" + ErrorMessage ); if ( has( ErrorMessage, "in.idf missing" ) ) NoIdf = true; - if ( has( ErrorMessage, InputProcessor::inputEnergyFile +" missing" ) ) NoIDD = true; + if ( has( ErrorMessage, inputEnergyFile +" missing" ) ) NoIDD = true; ShowErrorMessage( " ...Summary of Errors that led to program termination:", OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Reference severe error count=" + RoundSigDigits( TotalSevereErrors ), OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Last severe error=" + LastSevereError, OutUnit1, OutUnit2 ); @@ -1587,6 +1574,7 @@ ShowErrorMessage( // na // Using/Aliasing + using namespace CommandLineInterface; using DataStringGlobals::VerString; using DataStringGlobals::IDDVerString; using DataGlobals::DoingInputProcessing; @@ -1613,10 +1601,10 @@ ShowErrorMessage( if ( TotalErrors == 0 && ! ErrFileOpened ) { StandardErrorOutput = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, CommandLineInterface::outputErrFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, outputErrFile, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { DisplayString( "Trying to display error: \"" + ErrorMessage + "\"" ); - ShowFatalError( "ShowErrorMessage: Could not open file "+CommandLineInterface::outputErrFile+" for output (write)." ); + ShowFatalError( "ShowErrorMessage: Could not open file "+outputErrFile+" for output (write)." ); } gio::write( StandardErrorOutput, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; ErrFileOpened = true; @@ -1802,7 +1790,7 @@ ShowRecurringErrors() } // NOTICE -// Copyright � 1996-2014 The Board of Trustees of the University of Illinois +// Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. // Portions of the EnergyPlus software package have been developed and copyrighted diff --git a/src/EnergyPlus/UtilityRoutines.hh b/src/EnergyPlus/UtilityRoutines.hh index 2fe1cf28c01..33d62a4c0f7 100644 --- a/src/EnergyPlus/UtilityRoutines.hh +++ b/src/EnergyPlus/UtilityRoutines.hh @@ -9,9 +9,6 @@ namespace EnergyPlus { -std::string assignEndFile(std::string& _EndFileName); -std::string assignErrFile(std::string& _ErrFileName); - void AbortEnergyPlus( bool const NoIdf, // Set to true when "noidf" was found diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 613283b54d3..be13c5469de 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -10,6 +10,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include #include #include @@ -57,6 +57,7 @@ namespace WeatherManager { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataEnvironment; @@ -4390,7 +4391,7 @@ Label903: ; // FLOW: - { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); WeatherFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFile, flags ); WeatherFileExists = flags.exists(); } if ( WeatherFileExists ) { OpenEPlusWeatherFile( ErrorsFound, true ); @@ -4443,11 +4444,11 @@ Label903: ; bool EPWOpen; int unitnumber; - { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); WeatherFileUnitNumber = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, SimulationManager::inputWeatherFile, flags ); if ( flags.err() ) goto Label9999; } + { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, inputWeatherFile, flags ); if ( flags.err() ) goto Label9999; } if ( ProcessHeader ) { // Read in Header Information @@ -4531,7 +4532,7 @@ Label9999: ; // Make sure it's open - { IOFlags flags; gio::inquire( SimulationManager::inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); } @@ -9467,7 +9468,7 @@ Label9998: ; // NOTICE - // Copyright � 1996-2014 The Board of Trustees of the University of Illinois + // Copyright © 1996-2014 The Board of Trustees of the University of Illinois // and The Regents of the University of California through Ernest Orlando Lawrence // Berkeley National Laboratory. All rights reserved. diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 7b85cb1eae1..26db437a8b0 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -217,12 +217,7 @@ main(int argc, const char * argv[]) // CLI module using namespace CommandLineInterface; - int status = 0; - status = ProcessArgs(argc, argv); - if(status == 1 || status == -1) - return 0; - //ProcessArgs(argc, argv); - + ProcessArgs(argc, argv); // Enable floating point exceptions #ifndef NDEBUG diff --git a/src/EnergyPlus/main.hh b/src/EnergyPlus/main.hh index d3e620cb497..49c180de3c7 100644 --- a/src/EnergyPlus/main.hh +++ b/src/EnergyPlus/main.hh @@ -1,7 +1,6 @@ #ifndef main_hh_INCLUDED #define main_hh_INCLUDED -using namespace std; // C++ Headers #include From b01fc9552833a2348ca0312ef823bc832dbc7748 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Thu, 25 Sep 2014 11:23:58 -0600 Subject: [PATCH 11/71] All output files are a string now + replaced error messages in CommandLineInterface with ShowFatalError --- src/EnergyPlus/AirflowNetworkSolver.cc | 6 +- src/EnergyPlus/CommandLineInterface.cc | 168 +++++++++++++------- src/EnergyPlus/CommandLineInterface.hh | 63 +++++--- src/EnergyPlus/DataStringGlobals.cc | 2 +- src/EnergyPlus/DataStringGlobals.hh | 2 +- src/EnergyPlus/DataSystemVariables.cc | 2 +- src/EnergyPlus/DaylightingManager.cc | 36 +++-- src/EnergyPlus/EMSManager.cc | 6 +- src/EnergyPlus/HeatBalanceSurfaceManager.cc | 6 +- src/EnergyPlus/InputProcessor.cc | 46 +++--- src/EnergyPlus/OutputProcessor.cc | 40 ++--- src/EnergyPlus/OutputReportTabular.cc | 28 ++-- src/EnergyPlus/OutputReports.cc | 24 +-- src/EnergyPlus/ScheduleManager.cc | 2 +- src/EnergyPlus/SimulationManager.cc | 20 +-- src/EnergyPlus/SizingManager.cc | 26 +-- src/EnergyPlus/SolarShading.cc | 4 +- src/EnergyPlus/TARCOGOutput.cc | 6 +- src/EnergyPlus/ThermalComfort.cc | 18 +-- src/EnergyPlus/UtilityRoutines.cc | 22 +-- src/EnergyPlus/WeatherManager.cc | 8 +- src/EnergyPlus/WindTurbine.cc | 14 +- src/EnergyPlus/WindowManager.cc | 4 +- src/EnergyPlus/main.cc | 20 +-- 24 files changed, 329 insertions(+), 244 deletions(-) diff --git a/src/EnergyPlus/AirflowNetworkSolver.cc b/src/EnergyPlus/AirflowNetworkSolver.cc index a4ff5aaac2d..b70be9a08cf 100644 --- a/src/EnergyPlus/AirflowNetworkSolver.cc +++ b/src/EnergyPlus/AirflowNetworkSolver.cc @@ -9,6 +9,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -54,6 +55,7 @@ namespace AirflowNetworkSolver { // USE STATEMENTS: // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataGlobals::Pi; using DataGlobals::DegToRadians; @@ -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 ) { @@ -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 ); } diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 555216d2c64..e0f721aab8e 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -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[]) @@ -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 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); @@ -103,15 +184,15 @@ 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); @@ -119,13 +200,13 @@ namespace CommandLineInterface{ 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); @@ -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 diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 40012bb235d..91d905b9035 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -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 diff --git a/src/EnergyPlus/DataStringGlobals.cc b/src/EnergyPlus/DataStringGlobals.cc index 8cc9f5d04a3..9e90ab221f3 100644 --- a/src/EnergyPlus/DataStringGlobals.cc +++ b/src/EnergyPlus/DataStringGlobals.cc @@ -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) diff --git a/src/EnergyPlus/DataStringGlobals.hh b/src/EnergyPlus/DataStringGlobals.hh index 59d61e49f08..58fbef6d49d 100644 --- a/src/EnergyPlus/DataStringGlobals.hh +++ b/src/EnergyPlus/DataStringGlobals.hh @@ -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) diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index 632e67e01ee..e641c1a5b74 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -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 diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index f8ffb92fc7c..81a1a73ce5f 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -12,6 +12,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -91,6 +92,7 @@ namespace DaylightingManager { // DLUMEF DayltgLuminousEfficacy WeatherManager WeatherManager // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataHeatBalance; @@ -684,9 +686,9 @@ namespace DaylightingManager { // open a new file eplusout.dfs for saving the daylight factors if ( CreateDFSReportFile ) { OutputFileDFS = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDFS, "eplusout.dfs", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDFS, outputDfsFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "CalcDayltgCoefficients: Could not open file \"eplusout.dfs\" for output (write)." ); + ShowFatalError( "CalcDayltgCoefficients: Could not open file "+outputDfsFileName+" for output (write)." ); } else { gio::write( OutputFileDFS, fmtA ) << "This file contains daylight factors for all exterior windows of daylight zones."; gio::write( OutputFileDFS, fmtA ) << "If only one reference point the last 4 columns in the data will be zero."; @@ -4048,7 +4050,7 @@ namespace DaylightingManager { int TotDaylightingDElight; // Total Daylighting:DElight inputs Real64 dLatitude; // double for argument passing int iErrorFlag; // Error Flag for warning/errors returned from DElight - int iDElightErrorFile; // Unit number for reading DElight Error File (eplusout.delightdfdmp) + int iDElightErrorFile; // Unit number for reading DElight Error File (eplusout.delightdfdmp or outputDelightFile) int iReadStatus; // Error File Read Status std::string cErrorLine; // Each DElight Error line can be up to 210 characters long std::string cErrorMsg; // Each DElight Error Message can be up to 200 characters long @@ -4190,7 +4192,7 @@ namespace DaylightingManager { if ( iErrorFlag != 0 ) { // Open DElight Daylight Factors Error File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, "eplusout.delightdfdmp", flags ); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); } // Sequentially read lines in DElight Daylight Factors Error File // and process them using standard EPlus warning/error handling calls @@ -4231,7 +4233,7 @@ namespace DaylightingManager { } else { // Open, Close, and Delete DElight Daylight Factors Error File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, "eplusout.delightdfdmp", flags ); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); } { IOFlags flags; flags.DISPOSE( "DELETE" ); gio::close( iDElightErrorFile, flags ); } } SetupDElightOutput4EPlus(); @@ -9324,13 +9326,13 @@ namespace DaylightingManager { IllumMap( MapNum ).UnitNo = GetNewUnitNumber(); MapNoString = RoundSigDigits( MapNum ); if ( MapColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, "eplusmap.tab" + MapNoString, flags ); if ( flags.err() ) goto Label901; } + { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, outputMapTabFileName + MapNoString, flags ); if ( flags.err() ) goto Label901; } CommaDelimited = false; } else if ( MapColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, "eplusmap.csv" + MapNoString, flags ); if ( flags.err() ) goto Label902; } + { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, outputMapCsvFileName + MapNoString, flags ); if ( flags.err() ) goto Label902; } CommaDelimited = true; } else { - { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, "eplusmap.txt" + MapNoString, flags ); if ( flags.err() ) goto Label903; } + { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, outputMapTxtFileName + MapNoString, flags ); if ( flags.err() ) goto Label903; } CommaDelimited = false; } @@ -9436,15 +9438,15 @@ namespace DaylightingManager { return; Label901: ; - ShowFatalError( "ReportIllumMap: Could not open file \"eplusmap.tab" + MapNoString + "\" for output (write)." ); + ShowFatalError( "ReportIllumMap: Could not open file "+ outputMapTabFileName + MapNoString + "\" for output (write)." ); return; Label902: ; - ShowFatalError( "ReportIllumMap: Could not open file \"eplusmap.csv" + MapNoString + "\" for output (write)." ); + ShowFatalError( "ReportIllumMap: Could not open file "+ outputMapCsvFileName + MapNoString + "\" for output (write)." ); return; Label903: ; - ShowFatalError( "ReportIllumMap: Could not open file \"eplusmap.txt" + MapNoString + "\" for output (write)." ); + ShowFatalError( "ReportIllumMap: Could not open file "+ outputMapTxtFileName + MapNoString + "\" for output (write)." ); } @@ -9500,11 +9502,11 @@ Label903: ; // Write map header if ( MapColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, "eplusmap.tab", flags ); if ( flags.err() ) goto Label901; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, outputMapTabFileName, flags ); if ( flags.err() ) goto Label901; } } else if ( MapColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, "eplusmap.csv", flags ); if ( flags.err() ) goto Label902; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, outputMapCsvFileName, flags ); if ( flags.err() ) goto Label902; } } else { - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, "eplusmap.txt", flags ); if ( flags.err() ) goto Label903; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, outputMapTxtFileName, flags ); if ( flags.err() ) goto Label903; } } for ( MapNum = 1; MapNum <= TotIllumMaps; ++MapNum ) { @@ -9540,15 +9542,15 @@ Label903: ; return; Label901: ; - ShowFatalError( "CloseReportIllumMaps: Could not open file \"eplusmap.tab\" for output (write)." ); + ShowFatalError( "CloseReportIllumMaps: Could not open file "+outputMapTabFileName+" for output (write)." ); return; Label902: ; - ShowFatalError( "CloseReportIllumMaps: Could not open file \"eplusmap.csv\" for output (write)." ); + ShowFatalError( "CloseReportIllumMaps: Could not open file "+outputMapCsvFileName+" for output (write)." ); return; Label903: ; - ShowFatalError( "CloseReportIllumMaps: Could not open file \"eplusmap.txt\" for output (write)." ); + ShowFatalError( "CloseReportIllumMaps: Could not open file "+outputMapTxtFileName+" for output (write)." ); } diff --git a/src/EnergyPlus/EMSManager.cc b/src/EnergyPlus/EMSManager.cc index 993aad2b499..e96e78e0200 100644 --- a/src/EnergyPlus/EMSManager.cc +++ b/src/EnergyPlus/EMSManager.cc @@ -9,6 +9,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -46,6 +47,7 @@ namespace EMSManager { // METHODOLOGY EMPLOYED: // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataRuntimeLanguage; @@ -189,9 +191,9 @@ namespace EMSManager { if ( OutputEDDFile ) { // open up output file for EMS EDD file EMS Data and Debug OutputEMSFileUnitNum = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputEMSFileUnitNum, "eplusout.edd", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputEMSFileUnitNum, outputEddFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "CheckIFAnyEMS: Could not open file \"eplusout.edd\" for output (write)." ); + ShowFatalError( "CheckIFAnyEMS: Could not open file "+ outputEddFileName +" for output (write)." ); } } } else { diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index ba8580ba5ea..04eb777b8c8 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -13,6 +13,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -96,6 +97,7 @@ namespace HeatBalanceSurfaceManager { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataEnvironment; @@ -492,7 +494,7 @@ namespace HeatBalanceSurfaceManager { // Open DElight Electric Lighting Error File for reading iDElightErrorFile = GetNewUnitNumber(); // RJH 2008-03-07: open file with READWRITE - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, "eplusout.delighteldmp", flags ); iwriteStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); iwriteStatus = flags.ios(); } if ( iwriteStatus == 0 ) { elOpened = true; } else { @@ -536,7 +538,7 @@ namespace HeatBalanceSurfaceManager { // extract reference point illuminance values from DElight Electric Lighting dump file for reporting // Open DElight Electric Lighting Dump File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, "eplusout.delighteldmp", flags ); iwriteStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); iwriteStatus = flags.ios(); } // IF (iwriteStatus /= 0) THEN // CALL ShowFatalError('InitSurfaceHeatBalance: Could not open file "eplusout.delighteldmp" for output (readwrite).') // ENDIF diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index cbbb3dbe94a..2d7c2c081ec 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -231,50 +231,50 @@ namespace InputProcessor { InitSecretObjects(); EchoInputFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( EchoInputFile, outputAuditFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( EchoInputFile, outputAuditFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "Could not open (write) "+ outputAuditFile + " ." ); - ShowFatalError( "ProcessInput: Could not open file " + outputAuditFile + " for output (write)." ); + DisplayString( "Could not open (write) "+ outputAuditFileName + " ." ); + ShowFatalError( "ProcessInput: Could not open file " + outputAuditFileName + " for output (write)." ); } { IOFlags flags; gio::inquire( "eplusout.iperr", flags ); FileExists = flags.exists(); } if ( FileExists ) { CacheIPErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( CacheIPErrorFile, "eplusout.iperr", flags ); read_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "read" ); gio::open( CacheIPErrorFile, outputIperrFileName, flags ); read_stat = flags.ios(); } if ( read_stat != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"eplusout.iperr\" for input (read)." ); + ShowFatalError( "EnergyPlus: Could not open file "+outputIperrFileName+" for input (read)." ); } { IOFlags flags; flags.DISPOSE( "delete" ); gio::close( CacheIPErrorFile, flags ); } } CacheIPErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( CacheIPErrorFile, "eplusout.iperr", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( CacheIPErrorFile, outputIperrFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "Could not open (write) eplusout.iperr." ); - ShowFatalError( "ProcessInput: Could not open file " + outputAuditFile + " for output (write)." ); + DisplayString( "Could not open (write) "+outputIperrFileName ); + ShowFatalError( "ProcessInput: Could not open file " + outputAuditFileName + " for output (write)." ); } // FullName from StringGlobals is used to build file name with Path if ( len( ProgramPath ) == 0 ) { - FullName = inputEnergyFile; + FullName = inputIddFileName; } else { - FullName = ProgramPath + inputEnergyFile; + FullName = ProgramPath + inputIddFileName; } { IOFlags flags; gio::inquire( FullName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { DisplayString( "Missing " + FullName ); - ShowFatalError( "ProcessInput: " + inputEnergyFile + " missing. Program terminates. Fullname = " + FullName ); + ShowFatalError( "ProcessInput: " + inputIddFileName + " missing. Program terminates. Fullname = " + FullName ); } IDDFile = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "read" ); gio::open( IDDFile, FullName, flags ); read_stat = flags.ios(); } if ( read_stat != 0 ) { - DisplayString( "Could not open (read) " + inputEnergyFile ); - ShowFatalError( "ProcessInput: Could not open file " + inputEnergyFile + " for input (read)." ); + DisplayString( "Could not open (read) " + inputIddFileName ); + ShowFatalError( "ProcessInput: Could not open file " + inputIddFileName + " for input (read)." ); } gio::read( IDDFile, fmtA ) >> InputLine; endcol = len( InputLine ); if ( endcol > 0 ) { if ( int( InputLine[ endcol - 1 ] ) == iUnicode_end ) { - ShowSevereError( "ProcessInput: " + inputEnergyFile + " appears to be a Unicode or binary file." ); + ShowSevereError( "ProcessInput: " + inputIddFileName + " appears to be a Unicode or binary file." ); ShowContinueError( "...This file cannot be read by this program. Please save as PC or Unix file and try again" ); ShowFatalError( "Program terminates due to previous condition." ); } @@ -283,7 +283,7 @@ namespace InputProcessor { NumLines = 0; DoingInputProcessing = true; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputEnergyFile+") File -- Start"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputIddFileName+") File -- Start"; DisplayString( "Processing Data Dictionary" ); ProcessingIDD = true; @@ -313,7 +313,7 @@ namespace InputProcessor { } ProcessingIDD = false; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputEnergyFile+") File -- Complete"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputIddFileName+") File -- Complete"; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Alpha Args=" << MaxAlphaArgsFound; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Numeric Args=" << MaxNumericArgsFound; @@ -325,23 +325,23 @@ namespace InputProcessor { gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (inputFileName) -- Start"; - { IOFlags flags; gio::inquire( inputFileName, flags ); FileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputIdfFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - DisplayString( "Missing " + CurrentWorkingFolder + inputFileName ); - ShowFatalError( "ProcessInput: " + inputFileName + " missing. Program terminates." ); + DisplayString( "Missing " + CurrentWorkingFolder + inputIdfFileName ); + ShowFatalError( "ProcessInput: " + inputIdfFileName + " missing. Program terminates." ); } IDFFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( IDFFile, inputFileName, flags ); read_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( IDFFile, inputIdfFileName, flags ); read_stat = flags.ios(); } if ( read_stat != 0 ) { - DisplayString( "Could not open (read)" + inputFileName ); + DisplayString( "Could not open (read)" + inputIdfFileName ); ShowFatalError( "ProcessInput: Could not open file \"in.idf\" for input (read)." ); } gio::read( IDFFile, fmtA ) >> InputLine; endcol = len( InputLine ); if ( endcol > 0 ) { if ( int( InputLine[ endcol - 1 ] ) == iUnicode_end ) { - ShowSevereError( "ProcessInput: " + inputFileName +" appears to be a Unicode or binary file." ); + ShowSevereError( "ProcessInput: " + inputIdfFileName +" appears to be a Unicode or binary file." ); ShowContinueError( "...This file cannot be read by this program. Please save as PC or Unix file and try again" ); ShowFatalError( "Program terminates due to previous condition." ); } @@ -627,7 +627,7 @@ namespace InputProcessor { ErrorsFound = true; } } else { - ShowSevereError( "IP: Blank Sections not allowed. Review " + outputAuditFile + " file.", EchoInputFile ); + ShowSevereError( "IP: Blank Sections not allowed. Review " + outputAuditFileName + " file.", EchoInputFile ); errFlag = true; ErrorsFound = true; } diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index d7de5116592..6469c0bf150 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -1581,9 +1581,9 @@ namespace OutputProcessor { int write_stat; OutputFileMeterDetails = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMeterDetails, outputMtdFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMeterDetails, outputMtdFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "InitializeMeters: Could not open file "+outputMtdFile+" for output (write)." ); + ShowFatalError( "InitializeMeters: Could not open file "+outputMtdFileName+" for output (write)." ); } } @@ -6694,7 +6694,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptTS ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both " + outputEsoFile + " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both " + outputEsoFileName + " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptTS ) { @@ -6707,7 +6707,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccTS ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccTS ) { @@ -6722,7 +6722,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptHR ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFile + " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFileName + " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptHR ) { @@ -6736,7 +6736,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccHR ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFile + " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFileName + " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccHR ) { @@ -6752,7 +6752,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptDY ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Daily), " "already on \"Output:Meter\". Will report to both " +outputEsoFile+ " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Daily), " "already on \"Output:Meter\". Will report to both " +outputEsoFileName+ " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptDY ) { @@ -6766,7 +6766,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccDY ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccDY ) { @@ -6782,7 +6782,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptMN ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptMN ) { @@ -6796,7 +6796,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccMN ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+ " and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccMN ) { @@ -6812,7 +6812,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptSM ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+" and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+" and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptSM ) { @@ -6826,7 +6826,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccSM ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFile+" and " +outputMtrFile ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+" and " +outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccSM ) { @@ -8259,31 +8259,31 @@ ProduceRDDMDD() if ( ProduceReportVDD == ReportVDD_Yes ) { OutputFileRVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, outputRddFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, outputRddFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file "+outputRddFile+" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputRddFileName+" for output (write)." ); } gio::write( OutputFileRVDD, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileRVDD, fmtA ) << "Var Type (reported time step),Var Report Type,Variable Name [Units]"; OutputFileMVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, outputMddFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, outputMddFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file "+outputMddFile+" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputMddFileName+" for output (write)." ); } gio::write( OutputFileMVDD, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileMVDD, fmtA ) << "Var Type (reported time step),Var Report Type,Variable Name [Units]"; } else if ( ProduceReportVDD == ReportVDD_IDF ) { OutputFileRVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, outputRddFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileRVDD, outputRddFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file "+outputRddFile+" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputRddFileName+" for output (write)." ); } gio::write( OutputFileRVDD, fmtA ) << "! Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileRVDD, fmtA ) << "! Output:Variable Objects (applicable to this run)"; OutputFileMVDD = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, outputMddFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMVDD, outputMddFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "ProduceRDDMDD: Could not open file "+outputMddFile+" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file "+outputMddFileName+" for output (write)." ); } gio::write( OutputFileMVDD, fmtA ) << "! Program Version," + VerString + ',' + IDDVerString; gio::write( OutputFileMVDD, fmtA ) << "! Output:Meter Objects (applicable to this run)"; diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 6e3b76aab58..775acf1257e 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -3111,9 +3111,9 @@ namespace OutputReportTabular { curDel = del( iStyle ); if ( TableStyle( iStyle ) == tableStyleComma ) { DisplayString( "Writing tabular output file results using comma format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputCsvFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputTblCsvFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file (" + outputCsvFile + ") for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file (" + outputTblCsvFileName + ") for output (write)." ); } gio::write( curFH, fmtA ) << "Program Version:" + curDel + VerString; gio::write( curFH, fmtLD ) << "Tabular Output Report in Format: " + curDel + "Comma"; @@ -3127,9 +3127,9 @@ namespace OutputReportTabular { gio::write( curFH, fmtA ) << ""; } else if ( TableStyle( iStyle ) == tableStyleTab ) { DisplayString( "Writing tabular output file results using tab format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputTabFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputTblTabFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTabFile+" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTblTabFileName+" for output (write)." ); } gio::write( curFH, fmtA ) << "Program Version" + curDel + VerString; gio::write( curFH, fmtA ) << "Tabular Output Report in Format: " + curDel + "Tab"; @@ -3143,9 +3143,9 @@ namespace OutputReportTabular { gio::write( curFH, fmtA ) << ""; } else if ( TableStyle( iStyle ) == tableStyleHTML ) { DisplayString( "Writing tabular output file results using HTML format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputHtmFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputTblHtmFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputHtmFile+" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTblHtmFileName+" for output (write)." ); } gio::write( curFH, fmtA ) << ""; gio::write( curFH, fmtA ) << ""; @@ -3174,9 +3174,9 @@ namespace OutputReportTabular { gio::write( curFH, TimeStampFmt2 ) << " " << td( 5 ) << ":" << td( 6 ) << ":" << td( 7 ) << "

"; } else if ( TableStyle( iStyle ) == tableStyleXML ) { DisplayString( "Writing tabular output file results using XML format." ); - { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputXmlFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "WRITE" ); gio::open( curFH, outputTblXmlFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputXmlFile+" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTblXmlFileName+" for output (write)." ); } gio::write( curFH, fmtA ) << ""; gio::write( curFH, fmtA ) << ""; @@ -3195,9 +3195,9 @@ namespace OutputReportTabular { gio::write( curFH ); } else { DisplayString( "Writing tabular output file results using text format." ); - { IOFlags flags; flags.ACTION( "write" ); gio::open( curFH, outputTxtFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( curFH, outputTblTxtFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTxtFile+" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file "+outputTblTxtFileName+" for output (write)." ); } gio::write( curFH, fmtA ) << "Program Version: " + VerString; gio::write( curFH, fmtA ) << "Tabular Output Report in Format: " + curDel + "Fixed"; @@ -4827,7 +4827,7 @@ namespace OutputReportTabular { WriteTimeBinTables(); } } - EchoInputFile = FindUnitNumber( outputAuditFile ); + EchoInputFile = FindUnitNumber( outputAuditFileName ); gio::write( EchoInputFile, fmtLD ) << "MonthlyInputCount=" << MonthlyInputCount; gio::write( EchoInputFile, fmtLD ) << "sizeMonthlyInput=" << sizeMonthlyInput; gio::write( EchoInputFile, fmtLD ) << "MonthlyFieldSetInputCount=" << MonthlyFieldSetInputCount; @@ -4943,7 +4943,7 @@ namespace OutputReportTabular { bool coolingDesignlinepassed; bool desConditionlinepassed; - { IOFlags flags; gio::inquire( "in.stat", flags ); fileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inStatFileName, flags ); fileExists = flags.exists(); } readStat = 0; isASHRAE = false; iscalc = false; @@ -4956,9 +4956,9 @@ namespace OutputReportTabular { lineTypeinterim = 0; if ( fileExists ) { statFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, "in.stat", flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, inStatFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "FillWeatherPredefinedEntries: Could not open file \"in.stat\" for input (read)." ); + ShowFatalError( "FillWeatherPredefinedEntries: Could not open file "+inStatFileName+" for input (read)." ); } IOFlags flags; while ( readStat == 0 ) { //end of file, or error diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index e464458b5f9..9ffa038255d 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -232,9 +232,9 @@ LinesOut( std::string const & option ) optiondone = true; unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.sln", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputSlnFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "LinesOut: Could not open file \"eplusout.sln\" for output (write)." ); + ShowFatalError( "LinesOut: Could not open file "+ outputSlnFileName +" for output (write)." ); } if ( option != "IDF" ) { @@ -422,9 +422,9 @@ DXFOut( } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOut: Could not open file "+outputDxfFile+" for output (write)." ); + ShowFatalError( "DXFOut: Could not open file "+outputDxfFileName+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -915,9 +915,9 @@ DXFOutLines( std::string const & ColorScheme ) } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOutLines: Could not open file "+outputDxfFile+" for output (write)." ); + ShowFatalError( "DXFOutLines: Could not open file "+outputDxfFileName+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -1342,9 +1342,9 @@ DXFOutWireFrame( std::string const & ColorScheme ) } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOutWireFrame: Could not open file "+outputDxfFile+" for output (write)." ); + ShowFatalError( "DXFOutWireFrame: Could not open file "+outputDxfFileName+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -2118,9 +2118,9 @@ CostInfoOut() unit = GetNewUnitNumber(); // .sci = surface cost info - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.sci", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputSciFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "CostInfoOut: Could not open file \"eplusout.sci\" for output (write)." ); + ShowFatalError( "CostInfoOut: Could not open file "+outputSciFileName+" for output (write)." ); } gio::write( unit, fmtLD ) << TotSurfaces << int( count( uniqueSurf ) ); gio::write( unit, fmtLD ) << "data for surfaces useful for cost information"; @@ -2247,9 +2247,9 @@ VRMLOut( } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.wrl", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputWrlFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "VRMLOut: Could not open file \"eplusout.wrl\" for output (write)." ); + ShowFatalError( "VRMLOut: Could not open file "+ outputWrlFileName +" for output (write)." ); } gio::write( unit, Format_702 ); // Beginning diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index b6c455f3693..f76d255b4d6 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -474,7 +474,7 @@ namespace ScheduleManager { Schedule( 0 ).ScheduleTypePtr = 0; Schedule( 0 ).WeekSchedulePointer = 0; - UnitNumber = FindUnitNumber( outputAuditFile ); + UnitNumber = FindUnitNumber( outputAuditFileName ); gio::write( UnitNumber, fmtLD ) << " Processing Schedule Input -- Start"; //!! Get Schedule Types diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index e2cd8952ca4..d4669e317e3 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -1044,7 +1044,7 @@ namespace SimulationManager { NumDesignDays = GetNumObjectsFound( "SizingPeriod:DesignDay" ); NumRunPeriodDesign = GetNumObjectsFound( "SizingPeriod:WeatherFileDays" ) + GetNumObjectsFound( "SizingPeriod:WeatherFileConditionType" ); NumSizingDays = NumDesignDays + NumRunPeriodDesign; - { IOFlags flags; gio::inquire( inputWeatherFile, flags ); WeatherFileAttached = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); WeatherFileAttached = flags.exists(); } if ( RunControlInInput ) { if ( DoZoneSizing ) { @@ -1207,34 +1207,34 @@ namespace SimulationManager { // FLOW: OutputFileStandard = GetNewUnitNumber(); StdOutputRecordCount = 0; - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileStandard, outputEsoFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileStandard, outputEsoFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputEsoFile+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+outputEsoFileName+" for output (write)." ); } gio::write( OutputFileStandard, fmtA ) << "Program Version," + VerString; // Open the Initialization Output File OutputFileInits = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileInits, outputEioFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileInits, outputEioFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputEioFile+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+outputEioFileName+" for output (write)." ); } gio::write( OutputFileInits, fmtA ) << "Program Version," + VerString; // Open the Meters Output File OutputFileMeters = GetNewUnitNumber(); StdMeterRecordCount = 0; - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileMeters, outputMtrFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileMeters, outputMtrFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputMtrFile+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+outputMtrFileName+" for output (write)." ); } gio::write( OutputFileMeters, fmtA ) << "Program Version," + VerString; // Open the Branch-Node Details Output File OutputFileBNDetails = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileBNDetails, outputBndFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileBNDetails, outputBndFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputBndFile+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+outputBndFileName+" for output (write)." ); } gio::write( OutputFileBNDetails, fmtA ) << "Program Version," + VerString; @@ -1314,7 +1314,7 @@ namespace SimulationManager { std::string cepEnvSetThreads; std::string cIDFSetThreads; - EchoInputFile = FindUnitNumber( outputAuditFile ); + EchoInputFile = FindUnitNumber( outputAuditFileName ); // Record some items on the audit file gio::write( EchoInputFile, fmtLD ) << "NumOfRVariable=" << NumOfRVariable_Setup; gio::write( EchoInputFile, fmtLD ) << "NumOfRVariable(Total)=" << NumTotalRVariable; diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index 4c1abe69122..d2419e0f6ce 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -8,6 +8,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -54,6 +55,7 @@ namespace SizingManager { // OTHER NOTES: none // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace HeatBalanceManager; @@ -221,19 +223,19 @@ namespace SizingManager { Available = true; OutputFileZoneSizing = GetNewUnitNumber(); if ( SizingFileColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, "epluszsz.csv", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, outputZszCsvFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file \"epluszsz.csv\" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ outputZszCsvFileName +" for output (write)." ); } } else if ( SizingFileColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, "epluszsz.tab", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, outputZszTabFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file \"epluszsz.tab\" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+outputZszTabFileName+" for output (write)." ); } } else { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, "epluszsz.txt", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, outputZszTxtFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file \"epluszsz.txt\" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ outputZszTxtFileName +" for output (write)." ); } } @@ -433,19 +435,19 @@ namespace SizingManager { Available = true; OutputFileSysSizing = GetNewUnitNumber(); if ( SizingFileColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, "eplusssz.csv", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, outputSszCsvFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file \"eplusssz.csv\" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ outputSszCsvFileName +" for output (write)." ); } } else if ( SizingFileColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, "eplusssz.tab", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, outputSszTabFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file \"eplusssz.tab\" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ outputSszTabFileName +" for output (write)." ); } } else { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, "eplusssz.txt", flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, outputSszTxtFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file \"eplusssz.txt\" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+outputSszTxtFileName+ " for output (write)." ); } } SimAir = true; diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 853dba9738e..843289d4454 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -256,9 +256,9 @@ namespace SolarShading { if ( BeginSimFlag ) { OutputFileShading = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileShading, outputShdFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileShading, outputShdFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "InitSolarCalculations: Could not open file "+outputShdFile+" for output (write)." ); + ShowFatalError( "InitSolarCalculations: Could not open file "+outputShdFileName+" for output (write)." ); } if ( GetInputFlag ) { diff --git a/src/EnergyPlus/TARCOGOutput.cc b/src/EnergyPlus/TARCOGOutput.cc index 4b0cb5dbc3f..27cd1fa9daf 100644 --- a/src/EnergyPlus/TARCOGOutput.cc +++ b/src/EnergyPlus/TARCOGOutput.cc @@ -8,6 +8,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -43,6 +44,7 @@ namespace TARCOGOutput { // USE STATEMENTS: // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace TARCOGCommon; using namespace TARCOGGassesParams; @@ -1528,11 +1530,11 @@ namespace TARCOGOutput { TarcogIterationsFileNumber = GetNewUnitNumber(); // open(newunit=TarcogIterationsFileNumber, file=TRIM(DBGD)//'TarcogIterations.dbg', status='unknown', position='APPEND', & // form='formatted', iostat=nperr) - { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, DBGD + "TarcogIterations.dbg", flags ); nperr = flags.ios(); } + { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, DBGD + TarcogIterationsFileName, flags ); nperr = flags.ios(); } // if (nperr.ne.0) open(newunit=TarcogIterationsFileNumber, file='TarcogIterations.dbg',status='unknown', position='APPEND', & // & form='formatted', iostat=nperr) - if ( nperr != 0 ) { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, "TarcogIterations.dbg", flags ); nperr = flags.ios(); } + if ( nperr != 0 ) { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, TarcogIterationsFileName, flags ); nperr = flags.ios(); } IterationCSVFileNumber = GetNewUnitNumber(); // open(newunit=IterationCSVFileNumber, file=TRIM(DBGD)//TRIM(IterationCSVName), status='unknown', position='APPEND', & diff --git a/src/EnergyPlus/ThermalComfort.cc b/src/EnergyPlus/ThermalComfort.cc index 0497cce79df..67698a6edea 100644 --- a/src/EnergyPlus/ThermalComfort.cc +++ b/src/EnergyPlus/ThermalComfort.cc @@ -2468,14 +2468,14 @@ namespace ThermalComfort { } if ( initiate && weathersimulation ) { - { IOFlags flags; gio::inquire( "in.stat", flags ); statFileExists = flags.exists(); } - { IOFlags flags; gio::inquire( inputWeatherFile, flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inStatFileName, flags ); statFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( statFileExists ) { statFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, "in.stat", flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, inStatFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file \"in.stat\" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file "+inStatFileName+" for input (read)." ); } while ( readStat == 0 ) { { IOFlags flags; gio::read( statFile, fmtA, flags ) >> lineIn; readStat = flags.ios(); } @@ -2494,9 +2494,9 @@ namespace ThermalComfort { useStatData = true; } else if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFile, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " + inputWeatherFile+ " for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " + inputWeatherFileName+ " for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } @@ -2720,13 +2720,13 @@ namespace ThermalComfort { } if ( initiate && weathersimulation ) { - { IOFlags flags; gio::inquire( inputWeatherFile, flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFile, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+inputWeatherFile+" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+inputWeatherFileName+" for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 97836ad6789..a5c136bf30d 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -168,12 +168,12 @@ AbortEnergyPlus( strip( NumSevereDuringSizing ); if ( NoIDD ) { - DisplayString( "No EnergyPlus Data Dictionary (" + inputEnergyFile+") was found. It is possible " ); + DisplayString( "No EnergyPlus Data Dictionary (" + inputIddFileName+") was found. It is possible " ); DisplayString( "you \"double-clicked\"EnergyPlus.exe rather than using one of the methods" ); DisplayString( "to run Energyplus as found in the GettingStarted document in the" ); DisplayString( "documentation folder. Using EP-Launch may be best -- " ); DisplayString( "it provides extra help for new users." ); - ShowMessage( "No EnergyPlus Data Dictionary (" + inputEnergyFile+") was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); + ShowMessage( "No EnergyPlus Data Dictionary (" + inputIddFileName+") was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); ShowMessage( "rather than using one of the methods to run Energyplus as found in the GettingStarted document" ); ShowMessage( "in the documentation folder. Using EP-Launch may be best -- it provides extra help for new users." ); { IOFlags flags; flags.ADVANCE( "NO" ); gio::write( OutFmt, flags ); } @@ -213,9 +213,9 @@ AbortEnergyPlus( ShowMessage( "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "AbortEnergyPlus: Could not open file "+ outputEndFile +" for output (write)." ); + DisplayString( "AbortEnergyPlus: Could not open file "+ outputEndFileName +" for output (write)." ); } gio::write( tempfl, fmtLD ) << "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; @@ -446,9 +446,9 @@ EndEnergyPlus() ShowMessage( "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "EndEnergyPlus: Could not open file " + outputEndFile + " for output (write)." ); + DisplayString( "EndEnergyPlus: Could not open file " + outputEndFileName + " for output (write)." ); } gio::write( tempfl, fmtA ) << "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; gio::close( tempfl ); @@ -832,8 +832,9 @@ ShowFatalError( ShowErrorMessage( " ** Fatal ** " + ErrorMessage, OutUnit1, OutUnit2 ); DisplayString( "**FATAL:" + ErrorMessage ); - if ( has( ErrorMessage, "in.idf missing" ) ) NoIdf = true; - if ( has( ErrorMessage, inputEnergyFile +" missing" ) ) NoIDD = true; + + if ( has( ErrorMessage, inputIdfFileName +" missing" ) ) NoIdf = true; + if ( has( ErrorMessage, inputIddFileName +" missing" ) ) NoIDD = true; ShowErrorMessage( " ...Summary of Errors that led to program termination:", OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Reference severe error count=" + RoundSigDigits( TotalSevereErrors ), OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Last severe error=" + LastSevereError, OutUnit1, OutUnit2 ); @@ -1586,7 +1587,6 @@ ShowErrorMessage( // SUBROUTINE PARAMETER DEFINITIONS: static gio::Fmt const ErrorFormat( "(2X,A)" ); static gio::Fmt const fmtA( "(A)" ); - // INTERFACE BLOCK SPECIFICATIONS // na @@ -1601,10 +1601,10 @@ ShowErrorMessage( if ( TotalErrors == 0 && ! ErrFileOpened ) { StandardErrorOutput = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, outputErrFile, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, outputErrFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { DisplayString( "Trying to display error: \"" + ErrorMessage + "\"" ); - ShowFatalError( "ShowErrorMessage: Could not open file "+outputErrFile+" for output (write)." ); + ShowFatalError( "ShowErrorMessage: Could not open file "+outputErrFileName+" for output (write)." ); } gio::write( StandardErrorOutput, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; ErrFileOpened = true; diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index be13c5469de..f5f0496f78a 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -4391,7 +4391,7 @@ Label903: ; // FLOW: - { IOFlags flags; gio::inquire( inputWeatherFile, flags ); WeatherFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); WeatherFileExists = flags.exists(); } if ( WeatherFileExists ) { OpenEPlusWeatherFile( ErrorsFound, true ); @@ -4444,11 +4444,11 @@ Label903: ; bool EPWOpen; int unitnumber; - { IOFlags flags; gio::inquire( inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); WeatherFileUnitNumber = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, inputWeatherFile, flags ); if ( flags.err() ) goto Label9999; } + { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, inputWeatherFileName, flags ); if ( flags.err() ) goto Label9999; } if ( ProcessHeader ) { // Read in Header Information @@ -4532,7 +4532,7 @@ Label9999: ; // Make sure it's open - { IOFlags flags; gio::inquire( inputWeatherFile, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); } diff --git a/src/EnergyPlus/WindTurbine.cc b/src/EnergyPlus/WindTurbine.cc index 8cee95020d7..1aa15648a3f 100644 --- a/src/EnergyPlus/WindTurbine.cc +++ b/src/EnergyPlus/WindTurbine.cc @@ -9,6 +9,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -50,6 +51,7 @@ namespace WindTurbine { // OTHER NOTES: none // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGenerators; using DataGlobals::Pi; @@ -617,7 +619,7 @@ namespace WindTurbine { std::string::size_type lnPtr; // scan pointer for Line input int mon; // loop counter bool wsStatFound; // logical noting that wind stats were found - bool fileExists; // true if in.stat file exists + bool fileExists; // true if inStatFileName file exists bool warningShown; // true if the <365 warning has already been shown std::string lineIn; FArray1D< Real64 > MonthWS( 12 ); @@ -627,13 +629,13 @@ namespace WindTurbine { // Estimate average annual wind speed once if ( MyOneTimeFlag ) { wsStatFound = false; - { IOFlags flags; gio::inquire( "in.stat", flags ); fileExists = flags.exists(); } + { IOFlags flags; gio::inquire( inStatFileName, flags ); fileExists = flags.exists(); } if ( fileExists ) { statFile = GetNewUnitNumber(); ReadStatus = 0; - { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, "in.stat", flags ); ReadStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, inStatFileName, flags ); ReadStatus = flags.ios(); } if ( ReadStatus != 0 ) { - ShowFatalError( "InitWindTurbine: Could not open file \"in.stat\" for input (read)." ); + ShowFatalError( "InitWindTurbine: Could not open file "+inStatFileName+" for input (read)." ); } while ( ReadStatus == 0 ) { //end of file { IOFlags flags; gio::read( statFile, fmtA, flags ) >> lineIn; ReadStatus = flags.ios(); } @@ -660,14 +662,14 @@ namespace WindTurbine { } } else { // blank field if ( ! warningShown ) { - ShowWarningError( "InitWindTurbine: read from in.stat file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); + ShowWarningError( "InitWindTurbine: read from "+ inStatFileName +" file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); lineIn.erase( 0, lnPtr + 1 ); warningShown = true; } } } else { // two tabs in succession if ( ! warningShown ) { - ShowWarningError( "InitWindTurbine: read from in.stat file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); + ShowWarningError( "InitWindTurbine: read from "+ inStatFileName +" file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); lineIn.erase( 0, lnPtr + 1 ); warningShown = true; } diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index e5fb3979a36..8e90a89bfa3 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -9,6 +9,7 @@ #include // EnergyPlus Headers +#include #include #include #include @@ -69,6 +70,7 @@ namespace WindowManager { // for DOE-2, Lawrence Berkeley National Laboratory, Jan. 1996. // Using/Aliasing + using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataEnvironment; using namespace DataHeatBalance; @@ -7692,7 +7694,7 @@ namespace WindowManager { if ( PrintTransMap ) { ScreenTransUnitNo = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "unknown" ); gio::open( ScreenTransUnitNo, "eplusscreen.csv", flags ); if ( flags.err() ) goto Label99999; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "unknown" ); gio::open( ScreenTransUnitNo, outputScreenCsvFileName, flags ); if ( flags.err() ) goto Label99999; } // WRITE(ScreenTransUnitNo,*)' ' for ( ScreenNum = 1; ScreenNum <= NumSurfaceScreens; ++ScreenNum ) { MatNum = SurfaceScreens( ScreenNum ).MaterialNumber; diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 26db437a8b0..99fcf78a273 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -330,22 +330,22 @@ main(int argc, const char * argv[]) get_environment_variable( TraceHVACControllerEnvVar, cEnvValue ); if ( ! cEnvValue.empty() ) TraceHVACControllerEnvFlag = env_var_on( cEnvValue ); // Yes or True - { IOFlags flags; gio::inquire( outputEndFile, flags ); FileExists = flags.exists(); } + { IOFlags flags; gio::inquire( outputEndFileName, flags ); FileExists = flags.exists(); } if ( FileExists ) { LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, outputEndFile, flags ); iostatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, outputEndFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file "+ outputEndFile +" for input (read)." ); + ShowFatalError( "EnergyPlus: Could not open file "+ outputEndFileName +" for input (read)." ); } { IOFlags flags; flags.DISPOSE( "delete" ); gio::close( LFN, flags ); } } - { IOFlags flags; gio::inquire( "Energy+.ini", flags ); EPlusINI = flags.exists(); } + { IOFlags flags; gio::inquire( EnergyPlusIniFileName, flags ); EPlusINI = flags.exists(); } if ( EPlusINI ) { LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, "Energy+.ini", flags ); iostatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"Energy+.ini\" for input (read)." ); + ShowFatalError( "EnergyPlus: Could not open file "+EnergyPlusIniFileName+" for input (read)." ); } { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } // Relying on compiler to supply full path name here @@ -360,12 +360,12 @@ main(int argc, const char * argv[]) gio::close( LFN ); } else { - DisplayString( "Missing Energy+.ini" ); + DisplayString( "Missing " +EnergyPlusIniFileName ); ProgramPath = ""; LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( LFN, "Energy+.ini", flags ); iostatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"Energy+.ini\" for output (write)." ); + ShowFatalError( "EnergyPlus: Could not open file "+EnergyPlusIniFileName+" for output (write)." ); } // Relying on compiler to supply full path name here { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } @@ -384,7 +384,7 @@ main(int argc, const char * argv[]) DisplayString( VerString ); OutputFileDebug = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, "eplusout.dbg", flags ); iostatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, outputDbgFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { ShowFatalError( "EnergyPlus: Could not open file \"eplusout.dbg\" for output (write)." ); } From 393070e09c6294794862510f5127c4112fc07db5 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 26 Sep 2014 12:32:01 -0600 Subject: [PATCH 12/71] Minor clean up. --- src/EnergyPlus/CommandLineInterface.cc | 8 ++++---- src/EnergyPlus/DataStringGlobals.cc | 2 +- src/EnergyPlus/DataStringGlobals.hh | 2 +- src/EnergyPlus/DaylightingManager.cc | 2 +- src/EnergyPlus/WindTurbine.cc | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index e0f721aab8e..560f6bc1da9 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -123,10 +123,10 @@ namespace CommandLineInterface{ if (opt.isSet("-o")) { outputFilePrefix = inputIdfFileName.substr(0, inputIdfFileName.size()-4) + "_" + inputWeatherFileName.substr(0, inputWeatherFileName.size()-4) + "_"; - } - else { - outputFilePrefix = "eplus"; - } + } + else { + outputFilePrefix = "eplus"; + } outputAuditFileName = outputFilePrefix + "out.audit"; outputBndFileName = outputFilePrefix + "out.bnd"; diff --git a/src/EnergyPlus/DataStringGlobals.cc b/src/EnergyPlus/DataStringGlobals.cc index 9e90ab221f3..216a490f90a 100644 --- a/src/EnergyPlus/DataStringGlobals.cc +++ b/src/EnergyPlus/DataStringGlobals.cc @@ -67,7 +67,7 @@ namespace DataStringGlobals { // na // MODULE VARIABLE DECLARATIONS: - std::string ProgramPath; // Path for Program from EnergyPlusIniFileName + std::string ProgramPath; // Path for Program from INI file 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) diff --git a/src/EnergyPlus/DataStringGlobals.hh b/src/EnergyPlus/DataStringGlobals.hh index 58fbef6d49d..6bca0573731 100644 --- a/src/EnergyPlus/DataStringGlobals.hh +++ b/src/EnergyPlus/DataStringGlobals.hh @@ -35,7 +35,7 @@ namespace DataStringGlobals { // na // MODULE VARIABLE DECLARATIONS: - extern std::string ProgramPath; // Path for Program from EnergyPlusIniFileName + extern std::string ProgramPath; // Path for Program from INI file 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) diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 81a1a73ce5f..db1718f893c 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -4050,7 +4050,7 @@ namespace DaylightingManager { int TotDaylightingDElight; // Total Daylighting:DElight inputs Real64 dLatitude; // double for argument passing int iErrorFlag; // Error Flag for warning/errors returned from DElight - int iDElightErrorFile; // Unit number for reading DElight Error File (eplusout.delightdfdmp or outputDelightFile) + int iDElightErrorFile; // Unit number for reading DElight Error File int iReadStatus; // Error File Read Status std::string cErrorLine; // Each DElight Error line can be up to 210 characters long std::string cErrorMsg; // Each DElight Error Message can be up to 200 characters long diff --git a/src/EnergyPlus/WindTurbine.cc b/src/EnergyPlus/WindTurbine.cc index 1aa15648a3f..dfa3ea0f332 100644 --- a/src/EnergyPlus/WindTurbine.cc +++ b/src/EnergyPlus/WindTurbine.cc @@ -619,7 +619,7 @@ namespace WindTurbine { std::string::size_type lnPtr; // scan pointer for Line input int mon; // loop counter bool wsStatFound; // logical noting that wind stats were found - bool fileExists; // true if inStatFileName file exists + bool fileExists; // true if Stat file exists bool warningShown; // true if the <365 warning has already been shown std::string lineIn; FArray1D< Real64 > MonthWS( 12 ); From f2faabe2406a98367af2fe4c8dabb83624970a10 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 26 Sep 2014 14:26:42 -0600 Subject: [PATCH 13/71] File system handler in place --- src/EnergyPlus/CommandLineInterface.cc | 67 ++++++++++++++++++-------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index e0f721aab8e..c8d42842fd0 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -2,9 +2,14 @@ #include #include #include +#include +#include +#include +#include // CLI Headers #include +//#include // Project headers #include @@ -75,6 +80,22 @@ namespace CommandLineInterface{ std::string TarcogIterationsFileName; std::string eplusADSFileName; + std::string + returnFileName( std::string const& filename ) + { + return {std::find_if(filename.rbegin(), filename.rend(), [](char c) { return c == pathChar; }).base(), + filename.end()-4}; + } + + std::string + returnDirPathName( std::string const& filename ) + { + std::string::const_reverse_iterator pivot = std::find( filename.rbegin(), filename.rend(), pathChar ); + return pivot == filename.rend() + ? filename + : std::string( filename.begin(), pivot.base() - 1 ); + } + int ProcessArgs(int argc, const char * argv[]) { @@ -87,7 +108,7 @@ namespace CommandLineInterface{ opt.add("", 0, 0, 0, "Display this message", "-h", "--help"); - opt.add("", 0, 0, 0, "Print version invormation", "-v", "--version"); + opt.add("", 0, 0, 0, "Print version information", "-v", "--version"); opt.add("in.idf", 0, 1, 0, "Input Definition File (IDF) file path (default \".\\in.idf\")", "-i", "--idf"); @@ -101,32 +122,35 @@ namespace CommandLineInterface{ opt.parse(argc, argv); // print arguments parsed (useful for debugging) - /* - std::string pretty; + /*std::string pretty; opt.prettyPrint(pretty); + std::cout << pretty << std::endl;*/ - std::cout << pretty << std::endl; - */ - - std::string usage; + std::string usage, idfFileNameOnly, idfDirPathName; + std::string weatherFileNameOnly, weatherDirPathName; opt.getUsage(usage); + std::string outputFilePrefix; + opt.get("-i")->getString(inputIdfFileName); opt.get("-w")->getString(inputWeatherFileName); opt.get("-e")->getString(inputIddFileName); - std::string outputFilePrefix; + idfFileNameOnly = returnFileName(inputIdfFileName); + idfDirPathName = returnDirPathName(inputIdfFileName); - if (opt.isSet("-o")) { - outputFilePrefix = inputIdfFileName.substr(0, inputIdfFileName.size()-4) + "_" + - inputWeatherFileName.substr(0, inputWeatherFileName.size()-4) + "_"; - } - else { - outputFilePrefix = "eplus"; - } + weatherFileNameOnly = returnFileName(inputWeatherFileName); + weatherDirPathName = returnDirPathName(inputWeatherFileName); + + // std::cout<<"\n Name of the file = "< badOptions; - if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { - ShowFatalError("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); @@ -217,7 +239,10 @@ namespace CommandLineInterface{ exit(EXIT_SUCCESS); } + return 0; } -} //namespace options + } //namespace options } //EnergyPlus namespace + + From 4341dbf923f5e2a6eead94b90acbaa035b45ab99 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Thu, 2 Oct 2014 12:57:12 -0600 Subject: [PATCH 14/71] Flag to run ReadVARS + file system library is in place --- src/EnergyPlus/CommandLineInterface.cc | 119 ++++++++++++++++++++----- src/EnergyPlus/CommandLineInterface.hh | 5 ++ src/EnergyPlus/main.cc | 43 +++++++++ 3 files changed, 145 insertions(+), 22 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index c8d42842fd0..b9eae85bf79 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -1,4 +1,6 @@ //Standard C++ library +#include +#include #include #include #include @@ -6,6 +8,8 @@ #include #include #include +#include +#include // CLI Headers #include @@ -79,12 +83,21 @@ namespace CommandLineInterface{ std::string inStatFileName; std::string TarcogIterationsFileName; std::string eplusADSFileName; + std::string outputFilePrefix; + bool readVarsValue; + bool outputValue; + + void myterminate () { + std::cerr << "terminate handler called\n"; + abort(); // forces abnormal termination + } std::string returnFileName( std::string const& filename ) { - return {std::find_if(filename.rbegin(), filename.rend(), [](char c) { return c == pathChar; }).base(), - filename.end()-4}; + return {std::find_if(filename.rbegin(), filename.rend(), + [](char c) { return c == pathChar; }).base(), + filename.end()}; } std::string @@ -96,9 +109,26 @@ namespace CommandLineInterface{ : std::string( filename.begin(), pivot.base() - 1 ); } + std::string + returnFileExtension(const std::string& filename){ + std::string ext = ""; + + for(int i=0; igetString(inputIdfFileName); + opt.get("-i")->getString(inputIdfFileName); opt.get("-w")->getString(inputWeatherFileName); opt.get("-e")->getString(inputIddFileName); - idfFileNameOnly = returnFileName(inputIdfFileName); + idfFileNameWextn = returnFileName(inputIdfFileName); + + std::string idfFileNameOnly = idfFileNameWextn.substr(0,idfFileNameWextn.size()-4); + + std::cout<<"File name only = "< badOptions; if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { - ShowFatalError("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); } + if(!opt.gotRequired(badOptions)) { + DisplayString(usage); + for(int i=0; i < badOptions.size(); ++i) { + ShowFatalError("ERROR: Missing required option " + badOptions[i] + "\n"); + } + + exit(EXIT_FAILURE); + } + 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()); @@ -220,14 +274,6 @@ namespace CommandLineInterface{ exit(EXIT_FAILURE); } - if(!opt.gotRequired(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) { - ShowFatalError("ERROR: Missing required option " + badOptions[i] + "\n"); - } - DisplayString(usage); - exit(EXIT_FAILURE); - } - // Process standard arguments if (opt.isSet("-h")) { DisplayString(usage); @@ -239,6 +285,35 @@ namespace CommandLineInterface{ exit(EXIT_SUCCESS); } + struct stat st; + if(stat(idfDirPathName.c_str(),&st) == 0) + DisplayString(idfDirPathName + " is a valid (idf) directory.\n"); + else { + ShowFatalError(idfDirPathName + " is not a valid (idf) directory. \n"); + exit(EXIT_FAILURE); + } + + std::string extIdfFileName = returnFileExtension(inputIdfFileName); + if(extIdfFileName == "") + DisplayString("no file extension in " + idfFileNameOnly + " \n"); + else + DisplayString("Name of the extension = "+ extIdfFileName + " \n"); + + std::string extEpwfFileName = returnFileExtension(inputWeatherFileName); + if(extEpwfFileName == "") + DisplayString("no file extension in " + extEpwfFileName + " \n"); + else + DisplayString("Name of the extension = "+ extEpwfFileName + " \n"); + + if (extIdfFileName != "idf"){ + ShowFatalError("ERROR: Only idf files are allowed with [option] '-i' \n"); + exit(EXIT_FAILURE); + } + + if (opt.isSet("-w") && extEpwfFileName != "epw"){ + ShowFatalError("ERROR: Only epw files are allowed with [option] '-w' \n"); + exit(EXIT_FAILURE); + } return 0; } diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 91d905b9035..565bd876ef0 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -49,6 +49,11 @@ namespace CommandLineInterface { extern std::string inStatFileName; extern std::string TarcogIterationsFileName; extern std::string eplusADSFileName; + extern std::string weatherFileNameOnly; + extern std::string idfFileNameOnly; + extern std::string outputFilePrefix; + extern bool readVarsValue; + extern bool outputValue; // Process command line arguments int diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 99fcf78a273..86769f81522 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -5,6 +5,12 @@ #endif #endif +//Standard C++ library +#include +#include +#include +// CLI Headers + // ObjexxFCL Headers #include #include @@ -406,6 +412,43 @@ main(int argc, const char * argv[]) ReportOrphanFluids(); ReportOrphanSchedules(); + std::ofstream ifile; + std::ofstream nfile; + + if(outputValue) { + std::string esoFileName = outputFilePrefix + "out.eso"; + std::string csvFileName = outputFilePrefix + "out.csv"; + ifile.open("eplusout.rvi"); + ifile < Date: Thu, 2 Oct 2014 15:58:40 -0600 Subject: [PATCH 15/71] Flag for ReadVARS + file handler + directory for output files in place --- src/EnergyPlus/CommandLineInterface.cc | 56 ++++++++++++++++++++------ src/EnergyPlus/CommandLineInterface.hh | 2 +- src/EnergyPlus/main.cc | 48 ++++++++++------------ 3 files changed, 66 insertions(+), 40 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index b9eae85bf79..3a9d4048c71 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -9,7 +9,6 @@ #include #include #include -#include // CLI Headers #include @@ -84,8 +83,8 @@ namespace CommandLineInterface{ std::string TarcogIterationsFileName; std::string eplusADSFileName; std::string outputFilePrefix; + std::string dirPathName; bool readVarsValue; - bool outputValue; void myterminate () { std::cerr << "terminate handler called\n"; @@ -125,6 +124,36 @@ namespace CommandLineInterface{ } + bool mkpath( std::string path ) + { + bool bSuccess = false; + int nRC = ::mkdir( path.c_str(), 0775 ); + if( nRC == -1 ) + { + switch( errno ) + { + case ENOENT: + //parent didn't exist, try to create it + if( mkpath( path.substr(0, path.find_last_of('/')) ) ) + //Now, try to create again. + bSuccess = 0 == ::mkdir( path.c_str(), 0775 ); + else + bSuccess = false; + break; + case EEXIST: + //Done! + bSuccess = true; + break; + default: + bSuccess = false; + break; + } + } + else + bSuccess = true; + return bSuccess; + } + int ProcessArgs(int argc, const char * argv[]) { @@ -132,7 +161,7 @@ namespace CommandLineInterface{ ezOptionParser opt; opt.overview = VerString; - opt.example = "EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -o"; + opt.example = "EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -d DirPathName -o -r "; opt.syntax = "EnergyPlus [options]"; @@ -150,6 +179,8 @@ namespace CommandLineInterface{ opt.add("", 0, 0, 0, "Option to run readVARS", "-r", "--readVARS"); + opt.add("", 0, 1, 0, "Output directory pathname (default \".\\pwd\")", "-d", "--dirname"); + // Parse arguments opt.parse(argc, argv); @@ -170,11 +201,15 @@ namespace CommandLineInterface{ opt.get("-e")->getString(inputIddFileName); + opt.get("-d")->getString(dirPathName); + std::cout<<"Directory pathname = "< Date: Thu, 2 Oct 2014 16:12:33 -0600 Subject: [PATCH 16/71] Segfault error fixed --- src/EnergyPlus/CommandLineInterface.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 3a9d4048c71..5814fa4e473 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -86,11 +86,6 @@ namespace CommandLineInterface{ std::string dirPathName; bool readVarsValue; - void myterminate () { - std::cerr << "terminate handler called\n"; - abort(); // forces abnormal termination - } - std::string returnFileName( std::string const& filename ) { @@ -202,9 +197,9 @@ namespace CommandLineInterface{ opt.get("-e")->getString(inputIddFileName); opt.get("-d")->getString(dirPathName); - std::cout<<"Directory pathname = "< Date: Thu, 2 Oct 2014 16:16:24 -0600 Subject: [PATCH 17/71] Directory pathname check removed --- src/EnergyPlus/CommandLineInterface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 5814fa4e473..faeb453260b 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -197,7 +197,7 @@ namespace CommandLineInterface{ opt.get("-e")->getString(inputIddFileName); opt.get("-d")->getString(dirPathName); - // std::cout<<"Directory pathname = "< Date: Thu, 2 Oct 2014 16:21:35 -0600 Subject: [PATCH 18/71] Directory pathname check removed --- src/EnergyPlus/CommandLineInterface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index faeb453260b..d3d0db408a8 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -197,7 +197,7 @@ namespace CommandLineInterface{ opt.get("-e")->getString(inputIddFileName); opt.get("-d")->getString(dirPathName); - std::cout<<"Directory pathname = "< Date: Thu, 2 Oct 2014 16:23:47 -0600 Subject: [PATCH 19/71] Directory pathname check removed --- src/EnergyPlus/CommandLineInterface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index d3d0db408a8..5deba70b0ce 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -326,10 +326,10 @@ namespace CommandLineInterface{ DisplayString("Name of the extension = "+ extIdfFileName + " \n");*/ std::string extEpwfFileName = returnFileExtension(inputWeatherFileName); - if(extEpwfFileName == "") + /*if(extEpwfFileName == "") DisplayString("no file extension in " + extEpwfFileName + " \n"); else - DisplayString("Name of the extension = "+ extEpwfFileName + " \n"); + DisplayString("Name of the extension = "+ extEpwfFileName + " \n");*/ if (extIdfFileName != "idf"){ ShowFatalError("ERROR: Only idf files are allowed with [option] '-i' \n"); From f4663d549cf71ebf617c1f7b1cfa3252b6f4c1ce Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 3 Oct 2014 16:36:54 -0600 Subject: [PATCH 20/71] Change executable to lowercase to comply with standard command line conventions. --- cmake/ProjectMacros.cmake | 4 ++-- src/EnergyPlus/CMakeLists.txt | 17 +++++++++++------ tst/EnergyPlus/unit/CMakeLists.txt | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cmake/ProjectMacros.cmake b/cmake/ProjectMacros.cmake index 656c84ec360..86abb692a0c 100644 --- a/cmake/ProjectMacros.cmake +++ b/cmake/ProjectMacros.cmake @@ -128,7 +128,7 @@ function( ADD_SIMULATION_TEST ) add_test(NAME "integration.${IDF_NAME}" COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} - -DENERGYPLUS_EXE=$ + -DENERGYPLUS_EXE=$ #-DEXPANDOBJECTS_EXE=$ -DIDF_FILE=${ADD_SIM_TEST_IDF_FILE} -DEPW_FILE=${ADD_SIM_TEST_EPW_FILE} @@ -140,7 +140,7 @@ function( ADD_SIMULATION_TEST ) add_test(NAME "integration.${IDF_NAME}" COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} - -DENERGYPLUS_EXE=$ + -DENERGYPLUS_EXE=$ -DIDF_FILE=${ADD_SIM_TEST_IDF_FILE} -DEPW_FILE=${ADD_SIM_TEST_EPW_FILE} -DANNUAL_SIMULATION=${ANNUAL_SIMULATION} diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 194c75f0f4d..04b9092bfe5 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -518,17 +518,22 @@ SET( SRC ZoneTempPredictorCorrector.hh ) -ADD_LIBRARY(EnergyPlusLib STATIC ${SRC}) -ADD_EXECUTABLE(EnergyPlus main.cc main.hh) +ADD_LIBRARY(energypluslib STATIC ${SRC}) +ADD_EXECUTABLE(energyplus main.cc main.hh) -#TARGET_LINK_LIBRARIES( EnergyPlus DElight ) -TARGET_LINK_LIBRARIES( EnergyPlus EnergyPlusLib objexx sqlite bcvtb epexpat epfmiimport ) +#TARGET_LINK_LIBRARIES( energyplus DElight ) +TARGET_LINK_LIBRARIES( energyplus energypluslib objexx sqlite bcvtb epexpat epfmiimport ) if(CMAKE_HOST_UNIX) if(NOT APPLE) - TARGET_LINK_LIBRARIES( EnergyPlus dl ) + TARGET_LINK_LIBRARIES( energyplus dl ) endif() endif() +if(UNIX AND NOT APPLE) + ADD_CUSTOM_COMMAND(TARGET energyplus POST_BUILD + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/Products/" ln -s "energyplus" "EnergyPlus" + ) +endif() -INSTALL( TARGETS EnergyPlus DESTINATION ./ ) +INSTALL( TARGETS energyplus DESTINATION ./ ) diff --git a/tst/EnergyPlus/unit/CMakeLists.txt b/tst/EnergyPlus/unit/CMakeLists.txt index fb9819f5704..29e5fb226c3 100644 --- a/tst/EnergyPlus/unit/CMakeLists.txt +++ b/tst/EnergyPlus/unit/CMakeLists.txt @@ -13,7 +13,7 @@ set( test_src ) set( test_dependencies - EnergyPlusLib + energypluslib objexx sqlite bcvtb @@ -30,4 +30,4 @@ endif() # Executable name will be EnergyPlus_tests # Execute EnergyPlus_tests --help for options using gtest runner # Execute EnergyPlus_tests with no arguments to run all tests -CREATE_TEST_TARGETS( EnergyPlus "${test_src}" "${test_dependencies}" ) +CREATE_TEST_TARGETS( energyplus "${test_src}" "${test_dependencies}" ) From 8e7cb5428db2a485e53855b3680f9eb761ca3363 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Mon, 6 Oct 2014 14:22:49 -0600 Subject: [PATCH 21/71] Pater's suggestions implemented --- src/EnergyPlus/CommandLineInterface.cc | 335 +++++++++++++------------ src/EnergyPlus/CommandLineInterface.hh | 3 + src/EnergyPlus/InputProcessor.cc | 6 +- src/EnergyPlus/main.cc | 30 +-- 4 files changed, 196 insertions(+), 178 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 5deba70b0ce..650c78358f8 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -84,7 +84,12 @@ namespace CommandLineInterface{ std::string eplusADSFileName; std::string outputFilePrefix; std::string dirPathName; + std::string idfFileNameOnly; + std::string exePath; + std::string prefixOutName; + bool readVarsValue; + bool prefixValue; std::string returnFileName( std::string const& filename ) @@ -118,35 +123,27 @@ namespace CommandLineInterface{ return ext; } - - bool mkpath( std::string path ) + int + mkpath(std::string s,mode_t mode) { - bool bSuccess = false; - int nRC = ::mkdir( path.c_str(), 0775 ); - if( nRC == -1 ) - { - switch( errno ) - { - case ENOENT: - //parent didn't exist, try to create it - if( mkpath( path.substr(0, path.find_last_of('/')) ) ) - //Now, try to create again. - bSuccess = 0 == ::mkdir( path.c_str(), 0775 ); - else - bSuccess = false; - break; - case EEXIST: - //Done! - bSuccess = true; - break; - default: - bSuccess = false; - break; + size_t pre=0,pos; + std::string dir; + int mdret; + + if(s[s.size()-1]!=pathChar){ + // force trailing / so we can handle everything in loop + s+=pathChar; + } + + while((pos=s.find_first_of(pathChar,pre))!=std::string::npos){ + dir=s.substr(0,pos++); + pre=pos; + if(dir.size()==0) continue; // if leading / first time is 0 length + if((mdret=mkdir(dir.c_str(),mode)) && errno!=EEXIST){ + return mdret; } } - else - bSuccess = true; - return bSuccess; + return mdret; } int @@ -156,25 +153,25 @@ namespace CommandLineInterface{ ezOptionParser opt; opt.overview = VerString; - opt.example = "EnergyPlus -i InputFile.idf -e Energy+.idd -w WeatherFile.epw -d DirPathName -o -r "; + opt.example = "EnergyPlus -i custom.idd -w weather.epw -d output/ -p prefix -r input.idf"; - opt.syntax = "EnergyPlus [options]"; + opt.syntax = "EnergyPlus [options] [input file]"; opt.add("", 0, 0, 0, "Display this message", "-h", "--help"); - opt.add("", 0, 0, 0, "Print version information", "-v", "--version"); + opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); - opt.add("in.idf", 0, 1, 0, "Input Definition File (IDF) file path (default \".\\in.idf\")", "-i", "--idf"); + opt.add("in.idf", 0, 1, 0, "Input data file path (default in.idf)", ""); - opt.add("in.epw", 0, 1, 0, "EnergyPlus Weather (EPW) file path (default \".\\in.epw\")", "-w", "--weather"); + opt.add("in.epw", 0, 1, 0, "Weather file path (default in.epw)", "-w", "--weather"); - opt.add("Energy+.idd", 0, 1, 0, "Input Data Dictionary (IDD) file path (default \".\\Energy+.idd\")", "-e", "--idd"); + opt.add("Energy+.idd", 0, 1, 0, "Input data dictionary path (default Energy+.idd in executable directory)", "-i", "--idd"); - opt.add("", 0, 0, 0, "Rename output files to using the IDF and EPW file names", "-o", "--output"); + opt.add("", 0, 1, 0, "Prefix for output files (default same as input file name)", "-p", "--prefix"); - opt.add("", 0, 0, 0, "Option to run readVARS", "-r", "--readVARS"); + opt.add("", 0, 0, 0, "Run ReadVarsESO to generate time-series CSV", "-r", "--readvars"); - opt.add("", 0, 1, 0, "Output directory pathname (default \".\\pwd\")", "-d", "--dirname"); + opt.add("", 0, 1, 0, "Output directory (default current working directory)", "-d", "--dir"); // Parse arguments opt.parse(argc, argv); @@ -190,157 +187,179 @@ namespace CommandLineInterface{ opt.getUsage(usage); - opt.get("-i")->getString(inputIdfFileName); + //To check the path of EnergyPlus + char executable_path[100]; + realpath(argv[0], executable_path); + std::string mystring = std::string(executable_path); + exePath = returnDirPathName( mystring ); opt.get("-w")->getString(inputWeatherFileName); - opt.get("-e")->getString(inputIddFileName); + opt.get("-i")->getString(inputIddFileName); opt.get("-d")->getString(dirPathName); - // std::cout<<"Directory pathname = "< badOptions; + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + DisplayString(usage); + // ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + } + exit(EXIT_FAILURE); + } - if (opt.isSet("-o")) - // outputFilePrefix = dirPathName + idfFileNameOnly + "_" + weatherFileNameOnly + "_"; - outputFilePrefix = idfFileNameOnly + "_" + weatherFileNameOnly + "_"; - else - outputFilePrefix = dirPathName + "eplus"; + if(!opt.gotRequired(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); + DisplayString(usage); + // ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); + } + exit(EXIT_FAILURE); + } readVarsValue = false; if (opt.isSet("-r")){ readVarsValue = true; } - 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 = idfDirPathName+"eplusADS.inp"; - - // Handle bad options - std::vector badOptions; - if(!opt.gotExpected(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) { - ShowFatalError("ERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - } + // Process standard arguments + if (opt.isSet("-h")) { DisplayString(usage); - exit(EXIT_FAILURE); - } + exit(EXIT_SUCCESS); + } - if(!opt.gotRequired(badOptions)) { - DisplayString(usage); - for(int i=0; i < badOptions.size(); ++i) { - ShowFatalError("ERROR: Missing required option " + badOptions[i] + "\n"); + if (opt.isSet("-v")) { + DisplayString(VerString); + exit(EXIT_SUCCESS); + } + + if(opt.lastArgs.size() > 0 && opt.lastArgs.size() < 2){ + for(int i=0; i < opt.lastArgs.size(); ++i) { + std::string arg(opt.lastArgs[i]->c_str()); + inputIdfFileName = arg; + DisplayString("Input file to process: " + inputIdfFileName +"\n"); + + struct stat s; + if( stat(arg.c_str(),&s) != 0 ) { + char resolved_path[100]; + realpath(arg.c_str(), resolved_path); + printf("\n%s\n", resolved_path); + DisplayString(" is not a valid path. \n" ); + exit(EXIT_FAILURE); + } + } + } + + if(opt.lastArgs.size() > 1){ + for(int i=1; i < opt.lastArgs.size(); ++i) { + std::string arg(opt.lastArgs[i]->c_str()); + DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); + DisplayString(usage); + DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); } + exit(EXIT_FAILURE); + } + + if(inputIdfFileName.empty()) + inputIdfFileName = "in.idf"; + + idfFileNameWextn = returnFileName(inputIdfFileName); + + idfFileNameOnly = idfFileNameWextn.substr(0,idfFileNameWextn.size()-4); + idfDirPathName = returnDirPathName(inputIdfFileName); + + opt.get("-p")->getString(prefixOutName); + prefixValue = false; + if(opt.isSet("-p")) + prefixValue = true; + + + if (opt.isSet("-d") ){ + struct stat sb = {0}; + + if (stat(dirPathName.c_str(), &sb) == -1) { + int mkdirretval; + mkdirretval=mkpath(dirPathName,0755); + } + + if(dirPathName[dirPathName.size()-1]!=pathChar){ + // force trailing / so we can handle everything in loop + dirPathName+=pathChar; + } + + if(prefixValue) + outputFilePrefix = dirPathName + prefixOutName + "_"; + else + outputFilePrefix = dirPathName + idfFileNameOnly + "_"; + + } + 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"; + 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"; + outputDbgFileName = outputFilePrefix + ".dbg"; + EnergyPlusIniFileName = "Energy+.ini"; + inStatFileName = "in.stat"; + TarcogIterationsFileName = "TarcogIterations.dbg"; + eplusADSFileName = idfDirPathName+"eplusADS.inp"; - exit(EXIT_FAILURE); - } - if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0 || opt.lastArgs.size() > 0){ + // Handle bad options + if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ for(int i=1; i < opt.firstArgs.size(); ++i) { std::string arg(opt.firstArgs[i]->c_str()); - ShowFatalError("ERROR: Invalid option first arg: " + arg + "\n"); + DisplayString("\nERROR: Invalid option first arg: " + arg + "\n"); + DisplayString(usage); + ShowFatalError("\nERROR: 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 unknown arg: " + arg + "\n"); + DisplayString(usage); 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()); - ShowFatalError("ERROR: Invalid option last arg: " + arg + "\n"); - } - DisplayString(usage); exit(EXIT_FAILURE); } - - // Process standard arguments - if (opt.isSet("-h")) { - DisplayString(usage); - exit(EXIT_SUCCESS); - } - - if (opt.isSet("-v")) { - DisplayString(VerString); - exit(EXIT_SUCCESS); - } - - /* struct stat st; - if(stat(idfDirPathName.c_str(),&st) == 0) - DisplayString(idfDirPathName + " is a valid (idf) directory.\n"); - else { - ShowFatalError(idfDirPathName + " is not a valid (idf) directory. \n"); - exit(EXIT_FAILURE); - }*/ - - std::string extIdfFileName = returnFileExtension(inputIdfFileName); - /* if(extIdfFileName == "") - DisplayString("no file extension in " + idfFileNameOnly + " \n"); - else - DisplayString("Name of the extension = "+ extIdfFileName + " \n");*/ - - std::string extEpwfFileName = returnFileExtension(inputWeatherFileName); - /*if(extEpwfFileName == "") - DisplayString("no file extension in " + extEpwfFileName + " \n"); - else - DisplayString("Name of the extension = "+ extEpwfFileName + " \n");*/ - - if (extIdfFileName != "idf"){ - ShowFatalError("ERROR: Only idf files are allowed with [option] '-i' \n"); - exit(EXIT_FAILURE); - } - - if (opt.isSet("-w") && extEpwfFileName != "epw"){ - ShowFatalError("ERROR: Only epw files are allowed with [option] '-w' \n"); - exit(EXIT_FAILURE); - } - return 0; } } //namespace options diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 73ceee9b464..04977bafa9f 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -54,6 +54,9 @@ namespace CommandLineInterface { extern std::string outputFilePrefix; extern std::string dirPathName; extern bool readVarsValue; + extern bool prefixValue; + extern std::string exePath; + extern std::string prefixOutName; // Process command line arguments int diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 2b46fd17adf..8b27f2ad5ee 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -237,7 +237,7 @@ namespace InputProcessor { ShowFatalError( "ProcessInput: Could not open file " + outputAuditFileName + " for output (write)." ); } - { IOFlags flags; gio::inquire( "eplusout.iperr", flags ); FileExists = flags.exists(); } + { IOFlags flags; gio::inquire( outputIperrFileName, flags ); FileExists = flags.exists(); } if ( FileExists ) { CacheIPErrorFile = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "read" ); gio::open( CacheIPErrorFile, outputIperrFileName, flags ); read_stat = flags.ios(); } @@ -335,7 +335,7 @@ namespace InputProcessor { { IOFlags flags; flags.ACTION( "READ" ); gio::open( IDFFile, inputIdfFileName, flags ); read_stat = flags.ios(); } if ( read_stat != 0 ) { DisplayString( "Could not open (read)" + inputIdfFileName ); - ShowFatalError( "ProcessInput: Could not open file \"in.idf\" for input (read)." ); + ShowFatalError( "ProcessInput: Could not open file "+ inputIdfFileName +" for input (read)." ); } gio::read( IDFFile, fmtA ) >> InputLine; endcol = len( InputLine ); @@ -374,7 +374,7 @@ namespace InputProcessor { IDFRecordsGotten.allocate( NumIDFRecords ); IDFRecordsGotten = false; - gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (in.idf) -- Complete"; + gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File ("+inputIdfFileName+") -- Complete"; // WRITE(EchoInputFile,*) ' Number of IDF "Lines"=',NumIDFRecords gio::write( EchoInputFile, fmtLD ) << " Maximum number of Alpha IDF Args=" << MaxAlphaIDFArgsFound; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Numeric IDF Args=" << MaxNumericIDFArgsFound; diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index a8b530550c6..87958001dff 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -367,7 +367,7 @@ main(int argc, const char * argv[]) gio::close( LFN ); } else { DisplayString( "Missing " +EnergyPlusIniFileName ); - ProgramPath = ""; + ProgramPath = exePath + pathChar; LFN = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "write" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { @@ -392,7 +392,7 @@ main(int argc, const char * argv[]) OutputFileDebug = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, outputDbgFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"eplusout.dbg\" for output (write)." ); + ShowFatalError( "EnergyPlus: Could not open file "+outputDbgFileName+" for output (write)." ); } //Call ProcessInput to produce the IDF file which is read by all of the @@ -417,33 +417,29 @@ main(int argc, const char * argv[]) std::string esoFileName = outputFilePrefix + "out.eso"; std::string csvFileName = outputFilePrefix + "out.csv"; - ifile.open("eplusout.rvi"); + std::string RVIfile = idfFileNameOnly + ".rvi"; + ifile.open(RVIfile.c_str()); ifile < Date: Tue, 7 Oct 2014 14:48:23 -0600 Subject: [PATCH 22/71] Update executable name for USAGE and EXAMPLE. --- src/EnergyPlus/CommandLineInterface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 650c78358f8..506dfcb907d 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -153,9 +153,9 @@ namespace CommandLineInterface{ ezOptionParser opt; opt.overview = VerString; - opt.example = "EnergyPlus -i custom.idd -w weather.epw -d output/ -p prefix -r input.idf"; + opt.example = "energyplus -i custom.idd -w weather.epw -d output/ -p prefix -r input.idf"; - opt.syntax = "EnergyPlus [options] [input file]"; + opt.syntax = "energyplus [options] [input file]"; opt.add("", 0, 0, 0, "Display this message", "-h", "--help"); From ded88314d9acc6731c1923f9d125ad9254fa50ed Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Tue, 7 Oct 2014 15:08:58 -0600 Subject: [PATCH 23/71] precedence for idd implemented --- src/EnergyPlus/CommandLineInterface.cc | 54 +++++++++++++------------- src/EnergyPlus/CommandLineInterface.hh | 5 ++- src/EnergyPlus/InputProcessor.cc | 2 +- src/EnergyPlus/main.cc | 14 +++---- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 650c78358f8..3d9e3076554 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -85,7 +85,7 @@ namespace CommandLineInterface{ std::string outputFilePrefix; std::string dirPathName; std::string idfFileNameOnly; - std::string exePath; + std::string exePathName; std::string prefixOutName; bool readVarsValue; @@ -190,8 +190,8 @@ namespace CommandLineInterface{ //To check the path of EnergyPlus char executable_path[100]; realpath(argv[0], executable_path); - std::string mystring = std::string(executable_path); - exePath = returnDirPathName( mystring ); + std::string exePath = std::string(executable_path); + exePathName = returnDirPathName(exePath); opt.get("-w")->getString(inputWeatherFileName); @@ -199,29 +199,11 @@ namespace CommandLineInterface{ opt.get("-d")->getString(dirPathName); - /////////// For weather filename only (incase needed) /////////////////// + /////////// For weather filename only (incase needed) //////////////// //weatherFileNameWextn = returnFileName(inputWeatherFileName); //weatherDirPathName = returnDirPathName(inputWeatherFileName); //std::string weatherFileNameOnly = weatherFileNameWextn.substr(0,weatherFileNameWextn.size()-4); - - std::vector badOptions; - if(!opt.gotExpected(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) { - DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - DisplayString(usage); - // ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - } - exit(EXIT_FAILURE); - } - - if(!opt.gotRequired(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) { - DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); - DisplayString(usage); - // ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); - } - exit(EXIT_FAILURE); - } + ////////////////////////////////////////////////////////////////////// readVarsValue = false; if (opt.isSet("-r")){ @@ -243,14 +225,13 @@ namespace CommandLineInterface{ for(int i=0; i < opt.lastArgs.size(); ++i) { std::string arg(opt.lastArgs[i]->c_str()); inputIdfFileName = arg; - DisplayString("Input file to process: " + inputIdfFileName +"\n"); struct stat s; if( stat(arg.c_str(),&s) != 0 ) { char resolved_path[100]; realpath(arg.c_str(), resolved_path); - printf("\n%s\n", resolved_path); - DisplayString(" is not a valid path. \n" ); + std::string idfPath = std::string(resolved_path); + DisplayString(idfPath +" is not a valid path. \n" ); exit(EXIT_FAILURE); } } @@ -261,7 +242,6 @@ namespace CommandLineInterface{ std::string arg(opt.lastArgs[i]->c_str()); DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); DisplayString(usage); - DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); } exit(EXIT_FAILURE); } @@ -343,8 +323,26 @@ namespace CommandLineInterface{ TarcogIterationsFileName = "TarcogIterations.dbg"; eplusADSFileName = idfDirPathName+"eplusADS.inp"; + // Handle bad options + std::vector badOptions; + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + DisplayString(usage); + ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + } + exit(EXIT_FAILURE); + } + + if(!opt.gotRequired(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); + DisplayString(usage); + ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); + } + exit(EXIT_FAILURE); + } - // Handle bad options if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ for(int i=1; i < opt.firstArgs.size(); ++i) { std::string arg(opt.firstArgs[i]->c_str()); diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 04977bafa9f..008c5d843d3 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -53,10 +53,11 @@ namespace CommandLineInterface { extern std::string idfFileNameOnly; extern std::string outputFilePrefix; extern std::string dirPathName; + extern std::string exePathName; + extern std::string prefixOutName; + extern bool readVarsValue; extern bool prefixValue; - extern std::string exePath; - extern std::string prefixOutName; // Process command line arguments int diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 8b27f2ad5ee..29070a063b8 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -265,7 +265,7 @@ namespace InputProcessor { ShowFatalError( "ProcessInput: " + inputIddFileName + " missing. Program terminates. Fullname = " + FullName ); } IDDFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( IDDFile, FullName, flags ); read_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "read" ); gio::open( IDDFile, FullName, flags ); read_stat = flags.ios();} if ( read_stat != 0 ) { DisplayString( "Could not open (read) " + inputIddFileName ); ShowFatalError( "ProcessInput: Could not open file " + inputIddFileName + " for input (read)." ); diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 87958001dff..bce7cc065b9 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -45,7 +45,7 @@ main(int argc, const char * argv[]) // NOTICE - // Copyright © 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the + // Copyright � 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the // University of California through Ernest Orlando Lawrence Berkeley National Laboratory. All rights // reserved. @@ -120,11 +120,11 @@ main(int argc, const char * argv[]) // (Conjunction Of Multizone Infiltration Specialists) developed by a multinational, multi-institutional // effort under the auspices of the International Energy Agency's Buildings and Community Systems Agreement // working group focusing on multizone air flow modeling (Annex 23) and now administered by the Swiss Federal - // Laboratories for Materials Testing and Research (EMPA), Division 175, Überlandstrasse 129, CH-8600 Dübendorf, + // Laboratories for Materials Testing and Research (EMPA), Division 175, �berlandstrasse 129, CH-8600 D�bendorf, // Switzerland. // The EnergyPlus v1.2 model for displacement ventilation and cross-ventilation was developed - // by Guilherme Carrilho da Graça and Paul Linden of the Department of Mechanical and Aerospace + // by Guilherme Carrilho da Gra�a and Paul Linden of the Department of Mechanical and Aerospace // Engineering, University of California, San Diego. // The EnergyPlus models for UFAD served zones were developed by Anna Liu and Paul Linden at the Department @@ -366,8 +366,8 @@ main(int argc, const char * argv[]) gio::close( LFN ); } else { - DisplayString( "Missing " +EnergyPlusIniFileName ); - ProgramPath = exePath + pathChar; + DisplayString( "Missing " + EnergyPlusIniFileName ); + ProgramPath = exePathName + pathChar; LFN = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "write" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { @@ -432,8 +432,8 @@ main(int argc, const char * argv[]) nfile.close(); std::string ReadVars = "ReadVarsESO"; - std::string Total = "./"+ReadVars+" "+RVIfile+" "+"unlimited"; - std::string Total1 = "./"+ReadVars+" "+MVIfile+" "+"unlimited"; + std::string Total = "./"+ReadVars+" "+RVIfile+" unlimited"; + std::string Total1 = "./"+ReadVars+" "+MVIfile+" unlimited"; if(readVarsValue) { From 006cbc9785117725e9f727cc29c26dbd82774199 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Thu, 9 Oct 2014 17:31:29 -0600 Subject: [PATCH 24/71] Only --weather=filename implemented --- src/EnergyPlus/CommandLineInterface.cc | 147 +++++++++++++++++++++---- src/EnergyPlus/CommandLineInterface.hh | 3 + src/EnergyPlus/main.cc | 9 +- 3 files changed, 135 insertions(+), 24 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 42c885be9a9..b03f9516a69 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -6,13 +6,10 @@ #include #include #include -#include #include -#include // CLI Headers #include -//#include // Project headers #include @@ -87,9 +84,19 @@ namespace CommandLineInterface{ std::string idfFileNameOnly; std::string exePathName; std::string prefixOutName; + std::string inputIMFFileName; bool readVarsValue; bool prefixValue; + bool expandObjValue; + bool EPMacroValue; + + + bool fileExist(const std::string& filename) + { + std::ifstream infile(filename); + return infile.good(); + } std::string returnFileName( std::string const& filename ) @@ -113,7 +120,7 @@ namespace CommandLineInterface{ std::string ext = ""; for(int i=0; igetString(inputWeatherFileName); + instream = &input; + input.open( inputWeatherFileName.c_str() ); opt.get("-i")->getString(inputIddFileName); opt.get("-d")->getString(dirPathName); - /////////// For weather filename only (incase needed) //////////////// + opt.get("-ep")->getString(inputIMFFileName); + + /////////// For weather filename only (in case needed) //////////////// //weatherFileNameWextn = returnFileName(inputWeatherFileName); //weatherDirPathName = returnDirPathName(inputWeatherFileName); //std::string weatherFileNameOnly = weatherFileNameWextn.substr(0,weatherFileNameWextn.size()-4); @@ -259,6 +292,13 @@ namespace CommandLineInterface{ if(opt.isSet("-p")) prefixValue = true; + expandObjValue = false; + if(opt.isSet("-e")) + expandObjValue = true; + + EPMacroValue = false; + if(opt.isSet("-ep")) + EPMacroValue = true; if (opt.isSet("-d") ){ struct stat sb = {0}; @@ -327,20 +367,24 @@ namespace CommandLineInterface{ std::vector badOptions; if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { + if(badOptions[i] != "-w"){ DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); DisplayString(usage); ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + exit(EXIT_FAILURE); + } } - exit(EXIT_FAILURE); } if(!opt.gotRequired(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { + if(badOptions[i] != "-w"){ DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); DisplayString(usage); ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); + exit(EXIT_FAILURE); + } } - exit(EXIT_FAILURE); } if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ @@ -358,6 +402,71 @@ namespace CommandLineInterface{ } exit(EXIT_FAILURE); } + + /* std::string ExpandObjects = "ExpandObjects"; + std::string runExpandObjects = "./"+ExpandObjects; + if(expandObjValue) + system(runExpandObjects.c_str()); + + std::string expandIdfFile = "expanded.idf"; + bool expandIdfFileExist = fileExist(expandIdfFile); + if(expandIdfFileExist) { + std::string expidfFileName = outputFilePrefix + ".expidf"; + std::ifstream src(expandIdfFile.c_str()); + std::ofstream dst(expidfFileName.c_str()); + dst << src.rdbuf(); + remove(idfFileNameOnly.c_str()); + link(expidfFileName.c_str(), idfFileNameOnly.c_str()); + } + else + std::cout<<"ExpandObjects file does not exist. \n"; + + bool imfFileExist = fileExist(inputIMFFileName); + std::string defaultIMFFileName = "in.imf"; + + if(imfFileExist) + link(inputIMFFileName.c_str(), defaultIMFFileName.c_str()); + + std::string outIDFFileName = "out.idf"; + remove(outIDFFileName.c_str()); + std::string outAuditFileName = "audit.out"; + remove(outAuditFileName.c_str()); + std::string epmdetFileName = outputFilePrefix+".epmdet"; + remove(epmdetFileName.c_str()); + std::string epmidfFileName = outputFilePrefix+".epmidf"; + remove(epmidfFileName.c_str()); + + std::string EPMacroexe = "EPMacro"; + std::string runEPMacro = "./"+EPMacroexe; + if(EPMacroValue){ + system(runEPMacro.c_str()); + std::cout<<"Running EPMacro...\n"; + + bool AuditFileExist = fileExist(outAuditFileName); + if(AuditFileExist){ + std::string epmdetFileName = outputFilePrefix + ".epmdet"; + std::ifstream src(outAuditFileName.c_str()); + std::ofstream dst(epmdetFileName.c_str()); + dst << src.rdbuf(); + } + + bool outFileExist = fileExist(outIDFFileName); + if(outFileExist){ + std::string epmidfFileName = outputFilePrefix + ".epmidf"; + std::ifstream src(outIDFFileName.c_str()); + std::ofstream dst(epmidfFileName.c_str()); + dst << src.rdbuf(); + link(epmidfFileName.c_str(), idfFileNameOnly.c_str()); + DisplayString("Input file: " + inputIMFFileName + "\n"); + } + else{ + ShowFatalError("EPMacro did not produce "+ outIDFFileName + "with "+ inputIMFFileName +"\n"); + exit(EXIT_FAILURE); + } + }*/ + + + return 0; } } //namespace options diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 008c5d843d3..939e91522c1 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -55,9 +55,12 @@ namespace CommandLineInterface { extern std::string dirPathName; extern std::string exePathName; extern std::string prefixOutName; + extern std::string inputIMFFileName; extern bool readVarsValue; extern bool prefixValue; + extern bool expandObjValue; + extern bool EPMacroValue; // Process command line arguments int diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index bce7cc065b9..f488855b11c 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -36,7 +36,6 @@ #include #include - int main(int argc, const char * argv[]) { @@ -432,13 +431,13 @@ main(int argc, const char * argv[]) nfile.close(); std::string ReadVars = "ReadVarsESO"; - std::string Total = "./"+ReadVars+" "+RVIfile+" unlimited"; - std::string Total1 = "./"+ReadVars+" "+MVIfile+" unlimited"; + std::string ReadVarsRVI = "./"+ReadVars+" "+RVIfile+" unlimited"; + std::string ReadVarsMVI = "./"+ReadVars+" "+MVIfile+" unlimited"; if(readVarsValue) { - system(Total.c_str()); - system(Total1.c_str()); + system(ReadVarsRVI.c_str()); + system(ReadVarsMVI.c_str()); } EndEnergyPlus(); From 27e7399f10fdb2a32069a2520babff08b471f883 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 10 Oct 2014 10:30:10 -0600 Subject: [PATCH 25/71] --weather=filename & --idd=filename implemented --- src/EnergyPlus/CommandLineInterface.cc | 90 ++++++++++++++------------ 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index b03f9516a69..a64ccb4b63c 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -153,27 +153,33 @@ namespace CommandLineInterface{ return mdret; } + std::string EqualsToSpace(std::string text) + { + std::replace(text.begin(), text.end(), '=', ' '); + return text; + } + int ProcessArgs(int argc, const char * argv[]) { - - std::string weatherEquals; - std::string weatherLongOption; - std::ifstream input; - std::istream* instream; + std::ifstream inputW, inputIDD; + std::istream* instreamW; + std::istream* instreamIDD; for ( int i = 1; i < argc; ++i ) { std::string inputArg( argv[ i ] ); - if(inputArg.substr(0,9) == "--weather"){ - weatherLongOption = inputArg.substr(0,9); - inputWeatherFileName = returnFileExtension(inputArg); + if(inputArg.substr(0,10) == "--weather="){ + std::string weatherLongOption = EqualsToSpace(inputArg.substr(0,10)); argv[i] = weatherLongOption.c_str(); - weatherEquals = weatherLongOption + "="; + inputWeatherFileName = returnFileExtension(inputArg); } - } - if(weatherLongOption.empty()) - weatherLongOption = "--weather="; + if(inputArg.substr(0,6) == "--idd="){ + std::string iddLongOption = EqualsToSpace(inputArg.substr(0,6)); + argv[i] = iddLongOption.c_str(); + inputIddFileName = returnFileExtension(inputArg); + } + } ezOptionParser opt; @@ -186,12 +192,16 @@ namespace CommandLineInterface{ opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); - opt.add("in.idf", 0, 1, 0, "Input data file path (default in.idf)", ""); + // opt.add("in.idf", 0, 1, 0, "Input data file path (default in.idf)", ""); + + opt.add("in.epw", 0, 1, 0, "Weather file path (default in.epw)", "-w", "--weather"); - opt.add("in.epw", 0, 1, 0, "Weather file path (default in.epw)", "-w", "--weather", "--weather="); + opt.add("", 0, 0, 0, "Weather file path", "--weather "); opt.add("Energy+.idd", 0, 1, 0, "Input data dictionary path (default Energy+.idd in executable directory)", "-i", "--idd"); + opt.add("", 0, 0, 0, "Input data dictionary path", "--idd "); + opt.add("", 0, 1, 0, "Prefix for output files (default same as input file name)", "-p", "--prefix"); opt.add("", 0, 0, 0, "Run ReadVarsESO to generate time-series CSV", "-r", "--readvars"); @@ -221,23 +231,21 @@ namespace CommandLineInterface{ exePathName = returnDirPathName(exePath); if(inputWeatherFileName.empty()) - inputWeatherFileName = "in.epw"; + inputWeatherFileName = "in.epw"; + + instreamW = &inputW; + inputW.open( inputWeatherFileName.c_str() ); - instream = &input; - input.open( inputWeatherFileName.c_str() ); + if(inputIddFileName.empty()) + inputIddFileName = "Energy+.idd"; - opt.get("-i")->getString(inputIddFileName); + instreamIDD = &inputIDD; + inputIDD.open( inputIddFileName.c_str() ); opt.get("-d")->getString(dirPathName); opt.get("-ep")->getString(inputIMFFileName); - /////////// For weather filename only (in case needed) //////////////// - //weatherFileNameWextn = returnFileName(inputWeatherFileName); - //weatherDirPathName = returnDirPathName(inputWeatherFileName); - //std::string weatherFileNameOnly = weatherFileNameWextn.substr(0,weatherFileNameWextn.size()-4); - ////////////////////////////////////////////////////////////////////// - readVarsValue = false; if (opt.isSet("-r")){ readVarsValue = true; @@ -264,7 +272,7 @@ namespace CommandLineInterface{ char resolved_path[100]; realpath(arg.c_str(), resolved_path); std::string idfPath = std::string(resolved_path); - DisplayString(idfPath +" is not a valid path. \n" ); + DisplayString("ERROR: "+ idfPath +" is not a valid path. \n" ); exit(EXIT_FAILURE); } } @@ -309,7 +317,6 @@ namespace CommandLineInterface{ } if(dirPathName[dirPathName.size()-1]!=pathChar){ - // force trailing / so we can handle everything in loop dirPathName+=pathChar; } @@ -367,23 +374,19 @@ namespace CommandLineInterface{ std::vector badOptions; if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { - if(badOptions[i] != "-w"){ DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); DisplayString(usage); ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); exit(EXIT_FAILURE); - } } } if(!opt.gotRequired(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { - if(badOptions[i] != "-w"){ DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); DisplayString(usage); ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); exit(EXIT_FAILURE); - } } } @@ -405,21 +408,22 @@ namespace CommandLineInterface{ /* std::string ExpandObjects = "ExpandObjects"; std::string runExpandObjects = "./"+ExpandObjects; - if(expandObjValue) + if(expandObjValue) { system(runExpandObjects.c_str()); - std::string expandIdfFile = "expanded.idf"; - bool expandIdfFileExist = fileExist(expandIdfFile); - if(expandIdfFileExist) { - std::string expidfFileName = outputFilePrefix + ".expidf"; - std::ifstream src(expandIdfFile.c_str()); - std::ofstream dst(expidfFileName.c_str()); - dst << src.rdbuf(); - remove(idfFileNameOnly.c_str()); - link(expidfFileName.c_str(), idfFileNameOnly.c_str()); - } - else - std::cout<<"ExpandObjects file does not exist. \n"; + std::string expandIdfFile = "expanded.idf"; + bool expandIdfFileExist = fileExist(expandIdfFile); + if(expandIdfFileExist) { + std::string expidfFileName = outputFilePrefix + ".expidf"; + std::ifstream src(expandIdfFile.c_str()); + std::ofstream dst(expidfFileName.c_str()); + dst << src.rdbuf(); + remove(idfFileNameOnly.c_str()); + link(expidfFileName.c_str(), idfFileNameOnly.c_str()); + } + else + std::cout<<"ExpandObjects file does not exist. \n"; + } bool imfFileExist = fileExist(inputIMFFileName); std::string defaultIMFFileName = "in.imf"; From 603950cc18f8e087ede4eb7d49a9227121fbf38a Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 10 Oct 2014 12:40:29 -0600 Subject: [PATCH 26/71] Call to EPMacro preprocessor implemented --- src/EnergyPlus/CommandLineInterface.cc | 804 ++++++++++++------------- 1 file changed, 400 insertions(+), 404 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index a64ccb4b63c..34c7be784e9 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -28,452 +28,448 @@ namespace EnergyPlus{ namespace CommandLineInterface{ - using namespace DataStringGlobals; - using namespace InputProcessor; - using namespace SimulationManager; - using namespace OutputReportTabular; - using namespace OutputProcessor; - using namespace SolarShading; - using namespace ez; - - 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; - std::string outputFilePrefix; - std::string dirPathName; - std::string idfFileNameOnly; - std::string exePathName; - std::string prefixOutName; - std::string inputIMFFileName; - - bool readVarsValue; - bool prefixValue; - bool expandObjValue; - bool EPMacroValue; - - - bool fileExist(const std::string& filename) - { - std::ifstream infile(filename); - return infile.good(); - } - - std::string - returnFileName( std::string const& filename ) - { - return {std::find_if(filename.rbegin(), filename.rend(), - [](char c) { return c == pathChar; }).base(), - filename.end()}; - } - - std::string - returnDirPathName( std::string const& filename ) - { - std::string::const_reverse_iterator pivot = std::find( filename.rbegin(), filename.rend(), pathChar ); - return pivot == filename.rend() - ? filename - : std::string( filename.begin(), pivot.base() - 1 ); - } - - std::string - returnFileExtension(const std::string& filename){ - std::string ext = ""; - - for(int i=0; igetString(dirPathName); + + opt.get("-ep")->getString(inputIMFFileName); + + readVarsValue = false; + if (opt.isSet("-r")){ + readVarsValue = true; + } - opt.add("", 0, 1, 0, "Prefix for output files (default same as input file name)", "-p", "--prefix"); + // Process standard arguments + if (opt.isSet("-h")) { + DisplayString(usage); + exit(EXIT_SUCCESS); + } - opt.add("", 0, 0, 0, "Run ReadVarsESO to generate time-series CSV", "-r", "--readvars"); + if (opt.isSet("-v")) { + DisplayString(VerString); + exit(EXIT_SUCCESS); + } - opt.add("", 0, 0, 0, "Run ExpandObjects", "-e", "--expandObj"); + if(opt.lastArgs.size() > 0 && opt.lastArgs.size() < 2){ + for(int i=0; i < opt.lastArgs.size(); ++i) { + std::string arg(opt.lastArgs[i]->c_str()); + inputIdfFileName = arg; + + struct stat s; + if( stat(arg.c_str(),&s) != 0 ) { + char resolved_path[100]; + realpath(arg.c_str(), resolved_path); + std::string idfPath = std::string(resolved_path); + DisplayString("ERROR: "+ idfPath +" is not a valid path. \n" ); + exit(EXIT_FAILURE); + } + } + } - opt.add("", 0, 1, 0, "Run EPMacro", "-ep", "--epMacro"); + if(opt.lastArgs.size() > 1){ + for(int i=1; i < opt.lastArgs.size(); ++i) { + std::string arg(opt.lastArgs[i]->c_str()); + DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); + DisplayString(usage); + } + exit(EXIT_FAILURE); + } - opt.add("", 0, 1, 0, "Output directory (default current working directory)", "-d", "--dir"); + if(inputIdfFileName.empty()) + inputIdfFileName = "in.idf"; - // Parse arguments - opt.parse(argc, argv); + idfFileNameWextn = returnFileName(inputIdfFileName); - // print arguments parsed (useful for debugging) - //std::string pretty; - //opt.prettyPrint(pretty); - //std::cout << pretty << std::endl; + idfFileNameOnly = idfFileNameWextn.substr(0,idfFileNameWextn.size()-4); + idfDirPathName = returnDirPathName(inputIdfFileName); - std::string usage, idfFileNameWextn, idfDirPathName; - std::string weatherFileNameWextn, weatherDirPathName; - opt.getUsage(usage); + opt.get("-p")->getString(prefixOutName); + prefixValue = false; + if(opt.isSet("-p")) + prefixValue = true; - //To check the path of EnergyPlus - char executable_path[100]; - realpath(argv[0], executable_path); - std::string exePath = std::string(executable_path); - exePathName = returnDirPathName(exePath); + expandObjValue = false; + if(opt.isSet("-e")) + expandObjValue = true; - if(inputWeatherFileName.empty()) - inputWeatherFileName = "in.epw"; + EPMacroValue = false; + if(opt.isSet("-ep")) + EPMacroValue = true; - instreamW = &inputW; - inputW.open( inputWeatherFileName.c_str() ); + if (opt.isSet("-d") ){ + struct stat sb = {0}; - if(inputIddFileName.empty()) - inputIddFileName = "Energy+.idd"; + if (stat(dirPathName.c_str(), &sb) == -1) { + int mkdirretval; + mkdirretval=mkpath(dirPathName,0755); + } - instreamIDD = &inputIDD; - inputIDD.open( inputIddFileName.c_str() ); + if(dirPathName[dirPathName.size()-1]!=pathChar){ + dirPathName+=pathChar; + } - opt.get("-d")->getString(dirPathName); + if(prefixValue) + outputFilePrefix = dirPathName + prefixOutName + "_"; + else + outputFilePrefix = dirPathName + idfFileNameOnly + "_"; - opt.get("-ep")->getString(inputIMFFileName); + } + 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"; + 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"; + outputDbgFileName = outputFilePrefix + ".dbg"; + EnergyPlusIniFileName = "Energy+.ini"; + inStatFileName = "in.stat"; + TarcogIterationsFileName = "TarcogIterations.dbg"; + eplusADSFileName = idfDirPathName+"eplusADS.inp"; + + // Handle bad options + std::vector badOptions; + if(!opt.gotExpected(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + DisplayString(usage); + ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); + exit(EXIT_FAILURE); + } + } - readVarsValue = false; - if (opt.isSet("-r")){ - readVarsValue = true; - } + if(!opt.gotRequired(badOptions)) { + for(int i=0; i < badOptions.size(); ++i) { + DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); + DisplayString(usage); + ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); + exit(EXIT_FAILURE); + } + } - // Process standard arguments - if (opt.isSet("-h")) { + if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ + for(int i=1; i < opt.firstArgs.size(); ++i) { + std::string arg(opt.firstArgs[i]->c_str()); + DisplayString("\nERROR: Invalid option first arg: " + arg + "\n"); + DisplayString(usage); + ShowFatalError("\nERROR: 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 unknown arg: " + arg + "\n"); DisplayString(usage); - exit(EXIT_SUCCESS); - } - - if (opt.isSet("-v")) { - DisplayString(VerString); - exit(EXIT_SUCCESS); - } - - if(opt.lastArgs.size() > 0 && opt.lastArgs.size() < 2){ - for(int i=0; i < opt.lastArgs.size(); ++i) { - std::string arg(opt.lastArgs[i]->c_str()); - inputIdfFileName = arg; - - struct stat s; - if( stat(arg.c_str(),&s) != 0 ) { - char resolved_path[100]; - realpath(arg.c_str(), resolved_path); - std::string idfPath = std::string(resolved_path); - DisplayString("ERROR: "+ idfPath +" is not a valid path. \n" ); - exit(EXIT_FAILURE); - } - } - } - - if(opt.lastArgs.size() > 1){ - for(int i=1; i < opt.lastArgs.size(); ++i) { - std::string arg(opt.lastArgs[i]->c_str()); - DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); - DisplayString(usage); + ShowFatalError("ERROR: Invalid option unknown arg: " + arg + "\n"); + } + exit(EXIT_FAILURE); + } + + /*if(expandObjValue) { + std::string runExpandObjects = "./ExpandObjects"; + system(runExpandObjects.c_str()); + + std::string expandIdfFile = "expanded.idf"; + bool expandIdfFileExist = fileExist(expandIdfFile); + if(expandIdfFileExist) { + std::string expidfFileName = outputFilePrefix + ".expidf"; + std::ifstream src(expandIdfFile.c_str()); + std::ofstream dst(expidfFileName.c_str()); + dst << src.rdbuf(); + remove(inputIdfFileName.c_str()); + symlink(expidfFileName.c_str(), inputIdfFileName.c_str()); + } + //else + // DisplayString("ExpandObjects file does not exist. \n"); + }*/ + + if(EPMacroValue){ + bool imfFileExist = fileExist(inputIMFFileName); + std::string defaultIMFFileName = "in.imf"; + + if(imfFileExist){ + symlink(inputIMFFileName.c_str(), defaultIMFFileName.c_str()); + + std::string outIDFFileName = "out.idf"; + remove(outIDFFileName.c_str()); + std::string outAuditFileName = "audit.out"; + remove(outAuditFileName.c_str()); + std::string epmdetFileName = outputFilePrefix+".epmdet"; + remove(epmdetFileName.c_str()); + std::string epmidfFileName = outputFilePrefix+".epmidf"; + remove(epmidfFileName.c_str()); + + std::string runEPMacro = "./EPMacro"; + + system(runEPMacro.c_str()); + std::cout<<"Running EPMacro...\n"; + + bool AuditFileExist = fileExist(outAuditFileName); + if(AuditFileExist){ + std::string epmdetFileName = outputFilePrefix + ".epmdet"; + std::ifstream src(outAuditFileName.c_str()); + std::ofstream dst(epmdetFileName.c_str()); + dst << src.rdbuf(); } - exit(EXIT_FAILURE); - } - - if(inputIdfFileName.empty()) - inputIdfFileName = "in.idf"; - - idfFileNameWextn = returnFileName(inputIdfFileName); - - idfFileNameOnly = idfFileNameWextn.substr(0,idfFileNameWextn.size()-4); - idfDirPathName = returnDirPathName(inputIdfFileName); - - opt.get("-p")->getString(prefixOutName); - prefixValue = false; - if(opt.isSet("-p")) - prefixValue = true; - - expandObjValue = false; - if(opt.isSet("-e")) - expandObjValue = true; - - EPMacroValue = false; - if(opt.isSet("-ep")) - EPMacroValue = true; - - if (opt.isSet("-d") ){ - struct stat sb = {0}; - - if (stat(dirPathName.c_str(), &sb) == -1) { - int mkdirretval; - mkdirretval=mkpath(dirPathName,0755); - } - - if(dirPathName[dirPathName.size()-1]!=pathChar){ - dirPathName+=pathChar; - } - - if(prefixValue) - outputFilePrefix = dirPathName + prefixOutName + "_"; - else - outputFilePrefix = dirPathName + idfFileNameOnly + "_"; - - } - 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"; - 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"; - outputDbgFileName = outputFilePrefix + ".dbg"; - EnergyPlusIniFileName = "Energy+.ini"; - inStatFileName = "in.stat"; - TarcogIterationsFileName = "TarcogIterations.dbg"; - eplusADSFileName = idfDirPathName+"eplusADS.inp"; - - // Handle bad options - std::vector badOptions; - if(!opt.gotExpected(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) { - DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - DisplayString(usage); - ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - exit(EXIT_FAILURE); - } - } - - if(!opt.gotRequired(badOptions)) { - for(int i=0; i < badOptions.size(); ++i) { - DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); - DisplayString(usage); - ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); - exit(EXIT_FAILURE); - } - } - - if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ - for(int i=1; i < opt.firstArgs.size(); ++i) { - std::string arg(opt.firstArgs[i]->c_str()); - DisplayString("\nERROR: Invalid option first arg: " + arg + "\n"); - DisplayString(usage); - ShowFatalError("\nERROR: Invalid option first arg: " + arg + "\n"); + + bool outFileExist = fileExist(outIDFFileName); + if(outFileExist){ + std::string epmidfFileName = outputFilePrefix + ".epmidf"; + std::ifstream src(outIDFFileName.c_str()); + std::ofstream dst(epmidfFileName.c_str()); + dst << src.rdbuf(); + symlink(epmidfFileName.c_str(), inputIdfFileName.c_str()); + DisplayString("Input file: " + inputIMFFileName + "\n"); } - for(int i=0; i < opt.unknownArgs.size(); ++i) { - std::string arg(opt.unknownArgs[i]->c_str()); - DisplayString("ERROR: Invalid option unknown arg: " + arg + "\n"); - DisplayString(usage); - ShowFatalError("ERROR: Invalid option unknown arg: " + arg + "\n"); + else{ + ShowFatalError("EPMacro did not produce "+ outIDFFileName + "with "+ inputIMFFileName +"\n"); + exit(EXIT_FAILURE); } - exit(EXIT_FAILURE); } - - /* std::string ExpandObjects = "ExpandObjects"; - std::string runExpandObjects = "./"+ExpandObjects; - if(expandObjValue) { - system(runExpandObjects.c_str()); - - std::string expandIdfFile = "expanded.idf"; - bool expandIdfFileExist = fileExist(expandIdfFile); - if(expandIdfFileExist) { - std::string expidfFileName = outputFilePrefix + ".expidf"; - std::ifstream src(expandIdfFile.c_str()); - std::ofstream dst(expidfFileName.c_str()); - dst << src.rdbuf(); - remove(idfFileNameOnly.c_str()); - link(expidfFileName.c_str(), idfFileNameOnly.c_str()); - } - else - std::cout<<"ExpandObjects file does not exist. \n"; - } - - bool imfFileExist = fileExist(inputIMFFileName); - std::string defaultIMFFileName = "in.imf"; - - if(imfFileExist) - link(inputIMFFileName.c_str(), defaultIMFFileName.c_str()); - - std::string outIDFFileName = "out.idf"; - remove(outIDFFileName.c_str()); - std::string outAuditFileName = "audit.out"; - remove(outAuditFileName.c_str()); - std::string epmdetFileName = outputFilePrefix+".epmdet"; - remove(epmdetFileName.c_str()); - std::string epmidfFileName = outputFilePrefix+".epmidf"; - remove(epmidfFileName.c_str()); - - std::string EPMacroexe = "EPMacro"; - std::string runEPMacro = "./"+EPMacroexe; - if(EPMacroValue){ - system(runEPMacro.c_str()); - std::cout<<"Running EPMacro...\n"; - - bool AuditFileExist = fileExist(outAuditFileName); - if(AuditFileExist){ - std::string epmdetFileName = outputFilePrefix + ".epmdet"; - std::ifstream src(outAuditFileName.c_str()); - std::ofstream dst(epmdetFileName.c_str()); - dst << src.rdbuf(); - } - - bool outFileExist = fileExist(outIDFFileName); - if(outFileExist){ - std::string epmidfFileName = outputFilePrefix + ".epmidf"; - std::ifstream src(outIDFFileName.c_str()); - std::ofstream dst(epmidfFileName.c_str()); - dst << src.rdbuf(); - link(epmidfFileName.c_str(), idfFileNameOnly.c_str()); - DisplayString("Input file: " + inputIMFFileName + "\n"); - } - else{ - ShowFatalError("EPMacro did not produce "+ outIDFFileName + "with "+ inputIMFFileName +"\n"); - exit(EXIT_FAILURE); - } - }*/ - - - - return 0; } - } //namespace options + return 0; +} +} //CommandLineInterface namespace } //EnergyPlus namespace From 839e54238b949a8f836e135d19aa1d1fad6a5578 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 10 Oct 2014 16:18:49 -0600 Subject: [PATCH 27/71] ExpandObjects preprocessor implemented --- src/EnergyPlus/CommandLineInterface.cc | 21 +++++++++------------ src/EnergyPlus/CommandLineInterface.hh | 1 + src/EnergyPlus/main.cc | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 34c7be784e9..17a4a9339b3 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -86,10 +86,10 @@ std::string exePathName; std::string prefixOutName; std::string inputIMFFileName; -bool readVarsValue; -bool prefixValue; -bool expandObjValue; -bool EPMacroValue; +bool readVarsValue(false); +bool prefixValue(false); +bool expandObjValue(false); +bool EPMacroValue(false); bool fileExist(const std::string& filename) @@ -191,8 +191,6 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); - // opt.add("in.idf", 0, 1, 0, "Input data file path (default in.idf)", ""); - opt.add("in.epw", 0, 1, 0, "Weather file path (default in.epw)", "-w", "--weather"); opt.add("", 0, 0, 0, "Weather file path", "--weather "); @@ -207,6 +205,8 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Run ExpandObjects", "-e", "--expandObj"); + opt.add("", 0, 0, 0, "Force design-day-only simulation", "-dd", "--ddonly"); + opt.add("", 0, 1, 0, "Run EPMacro", "-ep", "--epMacro"); opt.add("", 0, 1, 0, "Output directory (default current working directory)", "-d", "--dir"); @@ -245,7 +245,6 @@ ProcessArgs(int argc, const char * argv[]) opt.get("-ep")->getString(inputIMFFileName); - readVarsValue = false; if (opt.isSet("-r")){ readVarsValue = true; } @@ -295,15 +294,13 @@ ProcessArgs(int argc, const char * argv[]) idfDirPathName = returnDirPathName(inputIdfFileName); opt.get("-p")->getString(prefixOutName); - prefixValue = false; + if(opt.isSet("-p")) prefixValue = true; - expandObjValue = false; if(opt.isSet("-e")) expandObjValue = true; - EPMacroValue = false; if(opt.isSet("-ep")) EPMacroValue = true; @@ -405,7 +402,7 @@ ProcessArgs(int argc, const char * argv[]) exit(EXIT_FAILURE); } - /*if(expandObjValue) { + if(expandObjValue) { std::string runExpandObjects = "./ExpandObjects"; system(runExpandObjects.c_str()); @@ -421,7 +418,7 @@ ProcessArgs(int argc, const char * argv[]) } //else // DisplayString("ExpandObjects file does not exist. \n"); - }*/ + } if(EPMacroValue){ bool imfFileExist = fileExist(inputIMFFileName); diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 939e91522c1..341eec3948a 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -61,6 +61,7 @@ namespace CommandLineInterface { extern bool prefixValue; extern bool expandObjValue; extern bool EPMacroValue; + extern bool DDOnlySimulation; // Process command line arguments int diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index f488855b11c..622161df54e 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -259,6 +259,7 @@ main(int argc, const char * argv[]) #endif CreateCurrentDateTimeString( CurrentDateTime ); VerString += "," + CurrentDateTime; + get_environment_variable( DDOnlyEnvVar, cEnvValue ); DDOnly = env_var_on( cEnvValue ); // Yes or True From 832a2fa22ce8a927e61952e0da939e8d284f7094 Mon Sep 17 00:00:00 2001 From: Monika Sharma Date: Fri, 10 Oct 2014 17:17:25 -0600 Subject: [PATCH 28/71] design-day-only & annual-only simulation implemented --- src/EnergyPlus/CommandLineInterface.cc | 27 +++++++++++++++++++++++--- src/EnergyPlus/CommandLineInterface.hh | 1 + src/EnergyPlus/main.cc | 4 ++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 17a4a9339b3..cdbb78f72f9 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,7 @@ namespace EnergyPlus{ namespace CommandLineInterface{ using namespace DataStringGlobals; +using namespace DataSystemVariables; using namespace InputProcessor; using namespace SimulationManager; using namespace OutputReportTabular; @@ -90,7 +92,8 @@ bool readVarsValue(false); bool prefixValue(false); bool expandObjValue(false); bool EPMacroValue(false); - +bool DDOnlySimulation(false); +bool AnnualSimulation(false); bool fileExist(const std::string& filename) { @@ -164,6 +167,8 @@ ProcessArgs(int argc, const char * argv[]) std::ifstream inputW, inputIDD; std::istream* instreamW; std::istream* instreamIDD; + bool annSimulation; + bool ddSimulation; for ( int i = 1; i < argc; ++i ) { std::string inputArg( argv[ i ] ); @@ -178,6 +183,12 @@ ProcessArgs(int argc, const char * argv[]) argv[i] = iddLongOption.c_str(); inputIddFileName = returnFileExtension(inputArg); } + + if(inputArg == "-a") + annSimulation = true; + + if(inputArg == "-dd") + ddSimulation = true; } ezOptionParser opt; @@ -205,7 +216,9 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Run ExpandObjects", "-e", "--expandObj"); - opt.add("", 0, 0, 0, "Force design-day-only simulation", "-dd", "--ddonly"); + opt.add("", 0, 0, 0, "Force design-day-only simulation", "-dd", "--designday"); + + opt.add("", 0, 0, 0, "Force design-day-only simulation", "-a", "--annual"); opt.add("", 0, 1, 0, "Run EPMacro", "-ep", "--epMacro"); @@ -245,8 +258,16 @@ ProcessArgs(int argc, const char * argv[]) opt.get("-ep")->getString(inputIMFFileName); - if (opt.isSet("-r")){ + if (opt.isSet("-r")) readVarsValue = true; + + + if (opt.isSet("-dd")) + DDOnlySimulation = true; + + if(!(annSimulation && ddSimulation)){ + if (opt.isSet("-a")) + AnnualSimulation = true; } // Process standard arguments diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 341eec3948a..c33f35a5af6 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -62,6 +62,7 @@ namespace CommandLineInterface { extern bool expandObjValue; extern bool EPMacroValue; extern bool DDOnlySimulation; + extern bool AnnualSimulation; // Process command line arguments int diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 622161df54e..fb70b9471de 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -262,12 +262,16 @@ main(int argc, const char * argv[]) get_environment_variable( DDOnlyEnvVar, cEnvValue ); DDOnly = env_var_on( cEnvValue ); // Yes or True + if(DDOnlySimulation) + DDOnly = true; get_environment_variable( ReverseDDEnvVar, cEnvValue ); ReverseDD = env_var_on( cEnvValue ); // Yes or True get_environment_variable( FullAnnualSimulation, cEnvValue ); FullAnnualRun = env_var_on( cEnvValue ); // Yes or True + if(AnnualSimulation) + FullAnnualRun = true; get_environment_variable( cDisplayAllWarnings, cEnvValue ); DisplayAllWarnings = env_var_on( cEnvValue ); // Yes or True From e771111d3fc0f971428ae9d68a6051d9b83ab4c5 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Mon, 13 Oct 2014 14:20:27 -0600 Subject: [PATCH 29/71] Clean up CLI. --- src/EnergyPlus/CommandLineInterface.cc | 180 ++++++++++++------------- src/EnergyPlus/CommandLineInterface.hh | 5 + src/EnergyPlus/InputProcessor.cc | 4 +- src/EnergyPlus/main.cc | 50 +++---- 4 files changed, 119 insertions(+), 120 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index cdbb78f72f9..be9d043a826 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -81,6 +81,10 @@ std::string EnergyPlusIniFileName; std::string inStatFileName; std::string TarcogIterationsFileName; std::string eplusADSFileName; +std::string outputCsvFileName; +std::string outputMtrCsvFileName; +std::string outputRvauditFileName; + std::string outputFilePrefix; std::string dirPathName; std::string idfFileNameOnly; @@ -94,6 +98,7 @@ bool expandObjValue(false); bool EPMacroValue(false); bool DDOnlySimulation(false); bool AnnualSimulation(false); +bool iddArgSet(false); bool fileExist(const std::string& filename) { @@ -118,19 +123,17 @@ returnDirPathName( std::string const& filename ) : std::string( filename.begin(), pivot.base() - 1 ); } +// Not currently used std::string returnFileExtension(const std::string& filename){ - std::string ext = ""; + int extensionPosition = filename.find_last_of("."); + return filename.substr(extensionPosition + 1, filename.size() - 1); +} - for(int i=0; i cStrArgs; + cStrArgs.reserve(arguments.size()); + for (int i = 0; i < arguments.size(); ++i) { + cStrArgs.push_back(arguments[i].c_str()); } ezOptionParser opt; opt.overview = VerString; - opt.example = "energyplus -i custom.idd -w weather.epw -d output/ -p prefix -r input.idf"; + opt.example = "energyplus -i custom.idd -w weather.epw -d output/ -p prefix -r input.idf\n"; opt.syntax = "energyplus [options] [input file]"; @@ -204,28 +209,24 @@ ProcessArgs(int argc, const char * argv[]) opt.add("in.epw", 0, 1, 0, "Weather file path (default in.epw)", "-w", "--weather"); - opt.add("", 0, 0, 0, "Weather file path", "--weather "); - opt.add("Energy+.idd", 0, 1, 0, "Input data dictionary path (default Energy+.idd in executable directory)", "-i", "--idd"); - opt.add("", 0, 0, 0, "Input data dictionary path", "--idd "); - opt.add("", 0, 1, 0, "Prefix for output files (default same as input file name)", "-p", "--prefix"); opt.add("", 0, 0, 0, "Run ReadVarsESO to generate time-series CSV", "-r", "--readvars"); - opt.add("", 0, 0, 0, "Run ExpandObjects", "-e", "--expandObj"); + opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expand"); - opt.add("", 0, 0, 0, "Force design-day-only simulation", "-dd", "--designday"); + opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--designday"); opt.add("", 0, 0, 0, "Force design-day-only simulation", "-a", "--annual"); - opt.add("", 0, 1, 0, "Run EPMacro", "-ep", "--epMacro"); + opt.add("", 0, 1, 0, "Run EPMacro", "-m", "--epmacro"); opt.add("", 0, 1, 0, "Output directory (default current working directory)", "-d", "--dir"); // Parse arguments - opt.parse(argc, argv); + opt.parse(cStrArgs.size(), &cStrArgs[0]); // print arguments parsed (useful for debugging) //std::string pretty; @@ -239,36 +240,27 @@ ProcessArgs(int argc, const char * argv[]) //To check the path of EnergyPlus char executable_path[100]; realpath(argv[0], executable_path); - std::string exePath = std::string(executable_path); - exePathName = returnDirPathName(exePath); + exePathName = returnDirPathName(std::string(executable_path)) + pathChar; - if(inputWeatherFileName.empty()) - inputWeatherFileName = "in.epw"; + opt.get("-w")->getString(inputWeatherFileName); - instreamW = &inputW; - inputW.open( inputWeatherFileName.c_str() ); + opt.get("-i")->getString(inputIddFileName); - if(inputIddFileName.empty()) - inputIddFileName = "Energy+.idd"; - - instreamIDD = &inputIDD; - inputIDD.open( inputIddFileName.c_str() ); + if (opt.isSet("-i")) + iddArgSet = true; + else + inputIddFileName = exePathName + inputIddFileName; opt.get("-d")->getString(dirPathName); - opt.get("-ep")->getString(inputIMFFileName); + opt.get("-m")->getString(inputIMFFileName); if (opt.isSet("-r")) readVarsValue = true; + DDOnlySimulation = opt.isSet("-D"); - if (opt.isSet("-dd")) - DDOnlySimulation = true; - - if(!(annSimulation && ddSimulation)){ - if (opt.isSet("-a")) - AnnualSimulation = true; - } + AnnualSimulation = opt.isSet("-a") && !DDOnlySimulation; // Process standard arguments if (opt.isSet("-h")) { @@ -281,7 +273,7 @@ ProcessArgs(int argc, const char * argv[]) exit(EXIT_SUCCESS); } - if(opt.lastArgs.size() > 0 && opt.lastArgs.size() < 2){ + if(opt.lastArgs.size() == 1){ for(int i=0; i < opt.lastArgs.size(); ++i) { std::string arg(opt.lastArgs[i]->c_str()); inputIdfFileName = arg; @@ -291,18 +283,19 @@ ProcessArgs(int argc, const char * argv[]) char resolved_path[100]; realpath(arg.c_str(), resolved_path); std::string idfPath = std::string(resolved_path); - DisplayString("ERROR: "+ idfPath +" is not a valid path. \n" ); + DisplayString("ERROR: "+ idfPath +" is not a valid path.\n" ); exit(EXIT_FAILURE); } } } if(opt.lastArgs.size() > 1){ - for(int i=1; i < opt.lastArgs.size(); ++i) { + DisplayString("ERROR: Multiple input files specified:"); + for(int i=0; i < opt.lastArgs.size(); ++i) { std::string arg(opt.lastArgs[i]->c_str()); - DisplayString("ERROR: Invalid option last arg: " + arg + "\n"); - DisplayString(usage); + DisplayString(" Input file #" + std::to_string(i+1) + ": " + arg); } + DisplayString(usage); exit(EXIT_FAILURE); } @@ -311,7 +304,7 @@ ProcessArgs(int argc, const char * argv[]) idfFileNameWextn = returnFileName(inputIdfFileName); - idfFileNameOnly = idfFileNameWextn.substr(0,idfFileNameWextn.size()-4); + idfFileNameOnly = removeFileExtension(idfFileNameWextn); idfDirPathName = returnDirPathName(inputIdfFileName); opt.get("-p")->getString(prefixOutName); @@ -319,10 +312,10 @@ ProcessArgs(int argc, const char * argv[]) if(opt.isSet("-p")) prefixValue = true; - if(opt.isSet("-e")) + if(opt.isSet("-x")) expandObjValue = true; - if(opt.isSet("-ep")) + if(opt.isSet("-m")) EPMacroValue = true; if (opt.isSet("-d") ){ @@ -336,16 +329,16 @@ ProcessArgs(int argc, const char * argv[]) if(dirPathName[dirPathName.size()-1]!=pathChar){ dirPathName+=pathChar; } - - if(prefixValue) - outputFilePrefix = dirPathName + prefixOutName + "_"; - else - outputFilePrefix = dirPathName + idfFileNameOnly + "_"; - } + + if(prefixValue) + outputFilePrefix = dirPathName + prefixOutName + "-"; + else if (argc > 1) + outputFilePrefix = dirPathName + idfFileNameOnly + "-"; else - outputFilePrefix = "eplus"; + outputFilePrefix = dirPathName + "eplus"; + // EnergyPlus files outputAuditFileName = outputFilePrefix + "out.audit"; outputBndFileName = outputFilePrefix + "out.bnd"; outputDxfFileName = outputFilePrefix + "out.dxf"; @@ -387,6 +380,11 @@ ProcessArgs(int argc, const char * argv[]) TarcogIterationsFileName = "TarcogIterations.dbg"; eplusADSFileName = idfDirPathName+"eplusADS.inp"; + // Readvars files + outputCsvFileName = outputFilePrefix + "out.csv"; + outputMtrCsvFileName = outputFilePrefix + "mtr.csv"; + outputRvauditFileName = outputFilePrefix + "out.rvaudit"; + // Handle bad options std::vector badOptions; if(!opt.gotExpected(badOptions)) { @@ -410,37 +408,19 @@ ProcessArgs(int argc, const char * argv[]) if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ for(int i=1; i < opt.firstArgs.size(); ++i) { std::string arg(opt.firstArgs[i]->c_str()); - DisplayString("\nERROR: Invalid option first arg: " + arg + "\n"); + DisplayString("\nERROR: Invalid option: " + arg + "\n"); DisplayString(usage); - ShowFatalError("\nERROR: Invalid option first arg: " + arg + "\n"); + ShowFatalError("\nERROR: Invalid option: " + arg + "\n"); } for(int i=0; i < opt.unknownArgs.size(); ++i) { std::string arg(opt.unknownArgs[i]->c_str()); - DisplayString("ERROR: Invalid option unknown arg: " + arg + "\n"); + DisplayString("ERROR: Invalid option: " + arg + "\n"); DisplayString(usage); - ShowFatalError("ERROR: Invalid option unknown arg: " + arg + "\n"); + ShowFatalError("ERROR: Invalid option: " + arg + "\n"); } exit(EXIT_FAILURE); } - if(expandObjValue) { - std::string runExpandObjects = "./ExpandObjects"; - system(runExpandObjects.c_str()); - - std::string expandIdfFile = "expanded.idf"; - bool expandIdfFileExist = fileExist(expandIdfFile); - if(expandIdfFileExist) { - std::string expidfFileName = outputFilePrefix + ".expidf"; - std::ifstream src(expandIdfFile.c_str()); - std::ofstream dst(expidfFileName.c_str()); - dst << src.rdbuf(); - remove(inputIdfFileName.c_str()); - symlink(expidfFileName.c_str(), inputIdfFileName.c_str()); - } - //else - // DisplayString("ExpandObjects file does not exist. \n"); - } - if(EPMacroValue){ bool imfFileExist = fileExist(inputIMFFileName); std::string defaultIMFFileName = "in.imf"; @@ -457,7 +437,7 @@ ProcessArgs(int argc, const char * argv[]) std::string epmidfFileName = outputFilePrefix+".epmidf"; remove(epmidfFileName.c_str()); - std::string runEPMacro = "./EPMacro"; + std::string runEPMacro = exePathName + "EPMacro"; system(runEPMacro.c_str()); std::cout<<"Running EPMacro...\n"; @@ -485,6 +465,18 @@ ProcessArgs(int argc, const char * argv[]) } } } + + if(expandObjValue) { + std::string runExpandObjects = exePathName + "ExpandObjects"; + symlink(inputIdfFileName.c_str(), "in.idf"); + system(runExpandObjects.c_str()); + remove("in.idf"); + remove("expandedidf.err"); + std::string outputExpidfFileName = outputFilePrefix + "out.expidf"; + rename("expanded.idf", outputExpidfFileName.c_str()); + inputIdfFileName = outputExpidfFileName; + } + return 0; } } //CommandLineInterface namespace diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index c33f35a5af6..3f80741457e 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -49,6 +49,10 @@ namespace CommandLineInterface { extern std::string inStatFileName; extern std::string TarcogIterationsFileName; extern std::string eplusADSFileName; + extern std::string outputCsvFileName; + extern std::string outputMtrCsvFileName; + extern std::string outputRvauditFileName; + extern std::string weatherFileNameOnly; extern std::string idfFileNameOnly; extern std::string outputFilePrefix; @@ -63,6 +67,7 @@ namespace CommandLineInterface { extern bool EPMacroValue; extern bool DDOnlySimulation; extern bool AnnualSimulation; + extern bool iddArgSet; // Process command line arguments int diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 29070a063b8..4768bff43d4 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -254,10 +254,10 @@ namespace InputProcessor { } // FullName from StringGlobals is used to build file name with Path - if ( len( ProgramPath ) == 0 ) { + if ( len( ProgramPath ) == 0 || iddArgSet) { FullName = inputIddFileName; } else { - FullName = ProgramPath + inputIddFileName; + FullName = ProgramPath + "Energy+.idd"; } { IOFlags flags; gio::inquire( FullName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index fb70b9471de..1019d3cda98 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -222,8 +222,6 @@ main(int argc, const char * argv[]) // CLI module using namespace CommandLineInterface; - ProcessArgs(argc, argv); - // Enable floating point exceptions #ifndef NDEBUG #ifdef __unix__ @@ -257,6 +255,10 @@ main(int argc, const char * argv[]) #ifdef EP_Detailed_Timings epStartTime( "EntireRun=" ); #endif + + // Process command line arguments + ProcessArgs(argc, argv); + CreateCurrentDateTimeString( CurrentDateTime ); VerString += "," + CurrentDateTime; @@ -371,7 +373,7 @@ main(int argc, const char * argv[]) gio::close( LFN ); } else { DisplayString( "Missing " + EnergyPlusIniFileName ); - ProgramPath = exePathName + pathChar; + ProgramPath = ""; LFN = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "write" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } if ( iostatus != 0 ) { @@ -416,33 +418,33 @@ main(int argc, const char * argv[]) ReportOrphanFluids(); ReportOrphanSchedules(); - std::ofstream ifile; - std::ofstream nfile; - - std::string esoFileName = outputFilePrefix + "out.eso"; - std::string csvFileName = outputFilePrefix + "out.csv"; - std::string RVIfile = idfFileNameOnly + ".rvi"; - ifile.open(RVIfile.c_str()); - ifile < Date: Tue, 14 Oct 2014 16:35:07 -0600 Subject: [PATCH 30/71] Finish clean up of CLI. --- src/EnergyPlus/CommandLineInterface.cc | 145 ++++++++++--------------- src/EnergyPlus/CommandLineInterface.hh | 9 +- src/EnergyPlus/main.cc | 4 +- 3 files changed, 60 insertions(+), 98 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index be9d043a826..64c223d7901 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -7,6 +7,7 @@ #include #include #include +#include // CLI Headers #include @@ -85,17 +86,10 @@ std::string outputCsvFileName; std::string outputMtrCsvFileName; std::string outputRvauditFileName; -std::string outputFilePrefix; -std::string dirPathName; std::string idfFileNameOnly; std::string exePathName; -std::string prefixOutName; -std::string inputIMFFileName; -bool readVarsValue(false); -bool prefixValue(false); -bool expandObjValue(false); -bool EPMacroValue(false); +bool runReadVars(false); bool DDOnlySimulation(false); bool AnnualSimulation(false); bool iddArgSet(false); @@ -107,20 +101,17 @@ bool fileExist(const std::string& filename) } std::string -returnFileName( std::string const& filename ) +returnFileName( std::string const& filepath ) { - return {std::find_if(filename.rbegin(), filename.rend(), - [](char c) { return c == pathChar; }).base(), - filename.end()}; + int pathCharPosition = filepath.find_last_of(pathChar); + return filepath.substr(pathCharPosition + 1, filepath.size() - 1); } std::string -returnDirPathName( std::string const& filename ) +returnDirPath( std::string const& filepath ) { - std::string::const_reverse_iterator pivot = std::find( filename.rbegin(), filename.rend(), pathChar ); - return pivot == filename.rend() - ? filename - : std::string( filename.begin(), pivot.base() - 1 ); + int pathCharPosition = filepath.find_last_of(pathChar); + return filepath.substr(0, pathCharPosition + 1); } // Not currently used @@ -170,7 +161,7 @@ ProcessArgs(int argc, const char * argv[]) bool annSimulation; bool ddSimulation; - // Expand longname options using "=" sign into two arguments + // Expand long-name options using "=" sign into two arguments std::vector arguments; int wildCardPosition = 2; @@ -219,9 +210,9 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--designday"); - opt.add("", 0, 0, 0, "Force design-day-only simulation", "-a", "--annual"); + opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); - opt.add("", 0, 1, 0, "Run EPMacro", "-m", "--epmacro"); + opt.add("", 0, 0, 0, "Run EPMacro", "-m", "--epmacro"); opt.add("", 0, 1, 0, "Output directory (default current working directory)", "-d", "--dir"); @@ -233,14 +224,16 @@ ProcessArgs(int argc, const char * argv[]) //opt.prettyPrint(pretty); //std::cout << pretty << std::endl; - std::string usage, idfFileNameWextn, idfDirPathName; - std::string weatherFileNameWextn, weatherDirPathName; + std::string usage, idfDirPathName; opt.getUsage(usage); //To check the path of EnergyPlus - char executable_path[100]; - realpath(argv[0], executable_path); - exePathName = returnDirPathName(std::string(executable_path)) + pathChar; + char executableAbsolutePath[1024]; + char executableRelativePath[1024]; + uint32_t pathSize = sizeof(executableRelativePath); + _NSGetExecutablePath(executableRelativePath, &pathSize); + realpath(executableRelativePath, executableAbsolutePath); + exePathName = returnDirPath(std::string(executableAbsolutePath)); opt.get("-w")->getString(inputWeatherFileName); @@ -251,16 +244,15 @@ ProcessArgs(int argc, const char * argv[]) else inputIddFileName = exePathName + inputIddFileName; - opt.get("-d")->getString(dirPathName); + std::string dirPathName; - opt.get("-m")->getString(inputIMFFileName); + opt.get("-d")->getString(dirPathName); - if (opt.isSet("-r")) - readVarsValue = true; + runReadVars = opt.isSet("-r"); DDOnlySimulation = opt.isSet("-D"); - AnnualSimulation = opt.isSet("-a") && !DDOnlySimulation; + AnnualSimulation = opt.isSet("-a"); // Process standard arguments if (opt.isSet("-h")) { @@ -302,21 +294,15 @@ ProcessArgs(int argc, const char * argv[]) if(inputIdfFileName.empty()) inputIdfFileName = "in.idf"; - idfFileNameWextn = returnFileName(inputIdfFileName); - - idfFileNameOnly = removeFileExtension(idfFileNameWextn); - idfDirPathName = returnDirPathName(inputIdfFileName); + idfFileNameOnly = removeFileExtension(returnFileName(inputIdfFileName)); + idfDirPathName = returnDirPath(inputIdfFileName); - opt.get("-p")->getString(prefixOutName); + bool runExpandObjects(false); + bool runEPMacro(false); - if(opt.isSet("-p")) - prefixValue = true; + runExpandObjects = opt.isSet("-x"); - if(opt.isSet("-x")) - expandObjValue = true; - - if(opt.isSet("-m")) - EPMacroValue = true; + runEPMacro = opt.isSet("-m"); if (opt.isSet("-d") ){ struct stat sb = {0}; @@ -331,8 +317,12 @@ ProcessArgs(int argc, const char * argv[]) } } - if(prefixValue) + std::string outputFilePrefix; + if(opt.isSet("-p")) { + std::string prefixOutName; + opt.get("-p")->getString(prefixOutName); outputFilePrefix = dirPathName + prefixOutName + "-"; + } else if (argc > 1) outputFilePrefix = dirPathName + idfFileNameOnly + "-"; else @@ -421,56 +411,35 @@ ProcessArgs(int argc, const char * argv[]) exit(EXIT_FAILURE); } - if(EPMacroValue){ - bool imfFileExist = fileExist(inputIMFFileName); - std::string defaultIMFFileName = "in.imf"; - - if(imfFileExist){ - symlink(inputIMFFileName.c_str(), defaultIMFFileName.c_str()); - - std::string outIDFFileName = "out.idf"; - remove(outIDFFileName.c_str()); - std::string outAuditFileName = "audit.out"; - remove(outAuditFileName.c_str()); - std::string epmdetFileName = outputFilePrefix+".epmdet"; - remove(epmdetFileName.c_str()); - std::string epmidfFileName = outputFilePrefix+".epmidf"; - remove(epmidfFileName.c_str()); - - std::string runEPMacro = exePathName + "EPMacro"; - - system(runEPMacro.c_str()); - std::cout<<"Running EPMacro...\n"; - - bool AuditFileExist = fileExist(outAuditFileName); - if(AuditFileExist){ - std::string epmdetFileName = outputFilePrefix + ".epmdet"; - std::ifstream src(outAuditFileName.c_str()); - std::ofstream dst(epmdetFileName.c_str()); - dst << src.rdbuf(); - } + // Error for cases where both design-day and annual simulation switches are set + if (DDOnlySimulation && AnnualSimulation) { + ShowFatalError("ERROR: Cannot force both design-day and annual simulations. Set either '-D' or '-a', but not both.\n"); + } - bool outFileExist = fileExist(outIDFFileName); - if(outFileExist){ - std::string epmidfFileName = outputFilePrefix + ".epmidf"; - std::ifstream src(outIDFFileName.c_str()); - std::ofstream dst(epmidfFileName.c_str()); - dst << src.rdbuf(); - symlink(epmidfFileName.c_str(), inputIdfFileName.c_str()); - DisplayString("Input file: " + inputIMFFileName + "\n"); - } - else{ - ShowFatalError("EPMacro did not produce "+ outIDFFileName + "with "+ inputIMFFileName +"\n"); - exit(EXIT_FAILURE); - } - } + bool inputFileNamedIn = (idfFileNameOnly == "in"); + + if(runEPMacro){ + if (!inputFileNamedIn) + symlink(inputIdfFileName.c_str(), "in.imf"); + std::string runEPMacro = exePathName + "EPMacro"; + DisplayString("Running EPMacro..."); + system(runEPMacro.c_str()); + if (!inputFileNamedIn) + remove("in.imf"); + std::string outputEpmdetFileName = outputFilePrefix + "out.epmdet"; + rename("audit.out",outputEpmdetFileName.c_str()); + std::string outputEpmidfFileName = outputFilePrefix + "out.epmidf"; + rename("out.idf",outputEpmidfFileName.c_str()); + inputIdfFileName = outputEpmidfFileName; } - if(expandObjValue) { + if(runExpandObjects) { std::string runExpandObjects = exePathName + "ExpandObjects"; - symlink(inputIdfFileName.c_str(), "in.idf"); + if (!inputFileNamedIn) + symlink(inputIdfFileName.c_str(), "in.idf"); system(runExpandObjects.c_str()); - remove("in.idf"); + if (!inputFileNamedIn) + remove("in.idf"); remove("expandedidf.err"); std::string outputExpidfFileName = outputFilePrefix + "out.expidf"; rename("expanded.idf", outputExpidfFileName.c_str()); diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 3f80741457e..58bf147d613 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -55,16 +55,9 @@ namespace CommandLineInterface { extern std::string weatherFileNameOnly; extern std::string idfFileNameOnly; - extern std::string outputFilePrefix; - extern std::string dirPathName; extern std::string exePathName; - extern std::string prefixOutName; - extern std::string inputIMFFileName; - extern bool readVarsValue; - extern bool prefixValue; - extern bool expandObjValue; - extern bool EPMacroValue; + extern bool runReadVars; extern bool DDOnlySimulation; extern bool AnnualSimulation; extern bool iddArgSet; diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 1019d3cda98..9dca79cf4ff 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -418,7 +418,7 @@ main(int argc, const char * argv[]) ReportOrphanFluids(); ReportOrphanSchedules(); - if(readVarsValue) { + if(runReadVars) { std::ofstream ifile; std::ofstream nfile; @@ -445,7 +445,7 @@ main(int argc, const char * argv[]) remove(MVIfile.c_str()); rename("readvars.audit", outputRvauditFileName.c_str()); - } + } EndEnergyPlus(); From d0f7906807c1f0976d6fbb1844bb495c7e71bd88 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 15 Oct 2014 13:28:11 -0600 Subject: [PATCH 31/71] Fix error statements related to CLI. --- src/EnergyPlus/CommandLineInterface.cc | 346 ++++++++++++++++++++----- src/EnergyPlus/CommandLineInterface.hh | 13 +- src/EnergyPlus/DataStringGlobals.in.cc | 1 - src/EnergyPlus/HeatBalanceManager.cc | 9 +- src/EnergyPlus/InputProcessor.cc | 19 +- src/EnergyPlus/UtilityRoutines.cc | 36 +-- src/EnergyPlus/UtilityRoutines.hh | 5 +- src/EnergyPlus/main.cc | 248 ++---------------- third_party/CLI/ezOptionParser.hpp | 6 +- 9 files changed, 328 insertions(+), 355 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 64c223d7901..e7dd2ff4a83 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -12,11 +12,15 @@ // CLI Headers #include +// ObjexxFCL Headers +#include + // Project headers #include -#include +#include #include #include +#include #include #include #include @@ -30,6 +34,7 @@ namespace EnergyPlus{ namespace CommandLineInterface{ +using namespace DataGlobals; using namespace DataStringGlobals; using namespace DataSystemVariables; using namespace InputProcessor; @@ -87,14 +92,14 @@ std::string outputMtrCsvFileName; std::string outputRvauditFileName; std::string idfFileNameOnly; -std::string exePathName; +std::string exeDirectory; bool runReadVars(false); bool DDOnlySimulation(false); bool AnnualSimulation(false); -bool iddArgSet(false); -bool fileExist(const std::string& filename) +bool +fileExist(const std::string& filename) { std::ifstream infile(filename); return infile.good(); @@ -114,6 +119,25 @@ returnDirPath( std::string const& filepath ) return filepath.substr(0, pathCharPosition + 1); } +std::string +returnAbsolutePath( std::string const& filepath ) +{ + char absolutePath[1024]; + realpath(filepath.c_str(), absolutePath); + return std::string(absolutePath); +} + +std::string +returnProgramPath() +{ + char executableRelativePath[1024]; + uint32_t pathSize = sizeof(executableRelativePath); + _NSGetExecutablePath(executableRelativePath, &pathSize); + + return std::string(executableRelativePath); +} + + // Not currently used std::string returnFileExtension(const std::string& filename){ @@ -190,63 +214,58 @@ ProcessArgs(int argc, const char * argv[]) ezOptionParser opt; opt.overview = VerString; - opt.example = "energyplus -i custom.idd -w weather.epw -d output/ -p prefix -r input.idf\n"; + opt.example = "energyplus -w weather.epw -o output -r input.idf"; opt.syntax = "energyplus [options] [input file]"; - opt.add("", 0, 0, 0, "Display this message", "-h", "--help"); + opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); - opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); + opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--designday"); - opt.add("in.epw", 0, 1, 0, "Weather file path (default in.epw)", "-w", "--weather"); + opt.add("", 0, 0, 0, "Display help information", "-h", "--help"); - opt.add("Energy+.idd", 0, 1, 0, "Input data dictionary path (default Energy+.idd in executable directory)", "-i", "--idd"); + opt.add("Energy+.idd", 0, 1, 0, "Input data dictionary path (default: Energy+.idd in executable directory)", "-i", "--idd"); - opt.add("", 0, 1, 0, "Prefix for output files (default same as input file name)", "-p", "--prefix"); + opt.add("", 0, 0, 0, "Run EPMacro", "-m", "--epmacro"); - opt.add("", 0, 0, 0, "Run ReadVarsESO to generate time-series CSV", "-r", "--readvars"); + opt.add("", 0, 1, 0, "Output directory path (default: current working directory)", "-o", "--output-directory"); - opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expand"); + opt.add("", 0, 1, 0, "Prefix for output file names (default: same as input file name)", "-p", "--output-prefix"); - opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--designday"); + opt.add("", 0, 0, 0, "Run ReadVarsESO", "-r", "--readvars"); - opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); + opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); - opt.add("", 0, 0, 0, "Run EPMacro", "-m", "--epmacro"); + opt.add("in.epw", 0, 1, 0, "Weather file path (default: in.epw)", "-w", "--weather"); + + opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expand"); - opt.add("", 0, 1, 0, "Output directory (default current working directory)", "-d", "--dir"); + std::string errorFollowUp = "Type 'energyplus --help' for usage."; // Parse arguments opt.parse(cStrArgs.size(), &cStrArgs[0]); // print arguments parsed (useful for debugging) - //std::string pretty; - //opt.prettyPrint(pretty); - //std::cout << pretty << std::endl; + /*std::string pretty; + opt.prettyPrint(pretty); + std::cout << pretty << std::endl;*/ std::string usage, idfDirPathName; opt.getUsage(usage); - //To check the path of EnergyPlus - char executableAbsolutePath[1024]; - char executableRelativePath[1024]; - uint32_t pathSize = sizeof(executableRelativePath); - _NSGetExecutablePath(executableRelativePath, &pathSize); - realpath(executableRelativePath, executableAbsolutePath); - exePathName = returnDirPath(std::string(executableAbsolutePath)); + // Set path of EnergyPlus program path + exeDirectory = returnDirPath(returnAbsolutePath(returnProgramPath())); opt.get("-w")->getString(inputWeatherFileName); opt.get("-i")->getString(inputIddFileName); - if (opt.isSet("-i")) - iddArgSet = true; - else - inputIddFileName = exePathName + inputIddFileName; + if (!opt.isSet("-i") && argc > 1) + inputIddFileName = exeDirectory + inputIddFileName; std::string dirPathName; - opt.get("-d")->getString(dirPathName); + opt.get("-o")->getString(dirPathName); runReadVars = opt.isSet("-r"); @@ -269,17 +288,10 @@ ProcessArgs(int argc, const char * argv[]) for(int i=0; i < opt.lastArgs.size(); ++i) { std::string arg(opt.lastArgs[i]->c_str()); inputIdfFileName = arg; - - struct stat s; - if( stat(arg.c_str(),&s) != 0 ) { - char resolved_path[100]; - realpath(arg.c_str(), resolved_path); - std::string idfPath = std::string(resolved_path); - DisplayString("ERROR: "+ idfPath +" is not a valid path.\n" ); - exit(EXIT_FAILURE); - } } } + if(inputIdfFileName.empty()) + inputIdfFileName = "in.idf"; if(opt.lastArgs.size() > 1){ DisplayString("ERROR: Multiple input files specified:"); @@ -287,16 +299,20 @@ ProcessArgs(int argc, const char * argv[]) std::string arg(opt.lastArgs[i]->c_str()); DisplayString(" Input file #" + std::to_string(i+1) + ": " + arg); } - DisplayString(usage); + DisplayString(errorFollowUp); exit(EXIT_FAILURE); } - if(inputIdfFileName.empty()) - inputIdfFileName = "in.idf"; - + if(opt.lastArgs.size() == 0 && argc > 0){ + DisplayString("ERROR: No input file provided."); + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); + } idfFileNameOnly = removeFileExtension(returnFileName(inputIdfFileName)); idfDirPathName = returnDirPath(inputIdfFileName); + std::string weatherFilePathWithoutExtension = removeFileExtension(inputWeatherFileName); + bool runExpandObjects(false); bool runEPMacro(false); @@ -304,7 +320,7 @@ ProcessArgs(int argc, const char * argv[]) runEPMacro = opt.isSet("-m"); - if (opt.isSet("-d") ){ + if (opt.isSet("-o") ){ struct stat sb = {0}; if (stat(dirPathName.c_str(), &sb) == -1) { @@ -364,9 +380,9 @@ ProcessArgs(int argc, const char * argv[]) outputSszTabFileName = outputFilePrefix + "ssz.tab"; outputSszTxtFileName = outputFilePrefix + "ssz.txt"; outputScreenCsvFileName = outputFilePrefix + "screen.csv"; - outputDbgFileName = outputFilePrefix + ".dbg"; + outputDbgFileName = outputFilePrefix + "out.dbg"; EnergyPlusIniFileName = "Energy+.ini"; - inStatFileName = "in.stat"; + inStatFileName = weatherFilePathWithoutExtension + ".stat"; TarcogIterationsFileName = "TarcogIterations.dbg"; eplusADSFileName = idfDirPathName+"eplusADS.inp"; @@ -379,49 +395,101 @@ ProcessArgs(int argc, const char * argv[]) std::vector badOptions; if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { - DisplayString("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - DisplayString(usage); - ShowFatalError("\nERROR: Unexpected number of arguments for option " + badOptions[i] + "\n"); - exit(EXIT_FAILURE); + DisplayString("ERROR: Unexpected number of arguments for option " + badOptions[i]); } + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } + // This is a place holder in case there are required options in the future if(!opt.gotRequired(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { - DisplayString("\nERROR: Missing required option " + badOptions[i] + "\n"); - DisplayString(usage); - ShowFatalError("\nERROR: Missing required option " + badOptions[i] + "\n"); - exit(EXIT_FAILURE); + DisplayString("ERROR: Missing required option " + badOptions[i]); } + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } if(opt.firstArgs.size() > 1 || opt.unknownArgs.size() > 0){ for(int i=1; i < opt.firstArgs.size(); ++i) { std::string arg(opt.firstArgs[i]->c_str()); - DisplayString("\nERROR: Invalid option: " + arg + "\n"); - DisplayString(usage); - ShowFatalError("\nERROR: Invalid option: " + arg + "\n"); + DisplayString("ERROR: Invalid option: " + arg); } for(int i=0; i < opt.unknownArgs.size(); ++i) { std::string arg(opt.unknownArgs[i]->c_str()); - DisplayString("ERROR: Invalid option: " + arg + "\n"); - DisplayString(usage); - ShowFatalError("ERROR: Invalid option: " + arg + "\n"); + DisplayString("ERROR: Invalid option: " + arg); } + DisplayString(errorFollowUp); exit(EXIT_FAILURE); } // Error for cases where both design-day and annual simulation switches are set if (DDOnlySimulation && AnnualSimulation) { - ShowFatalError("ERROR: Cannot force both design-day and annual simulations. Set either '-D' or '-a', but not both.\n"); + DisplayString("ERROR: Cannot force both design-day and annual simulations. Set either '-D' or '-a', but not both."); + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } + // Read path from INI file if it exists + bool EPlusINI; + int LFN; // Unit Number for reads + std::string::size_type TempIndx; + int iostatus; + bool FileExists; + + // Check for IDD and IDF files + { IOFlags flags; gio::inquire( EnergyPlusIniFileName, flags ); EPlusINI = flags.exists(); } + if ( EPlusINI ) { + LFN = GetNewUnitNumber(); + { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } + if ( iostatus != 0 ) { + ShowFatalError( "EnergyPlus: Could not open file "+EnergyPlusIniFileName+" for input (read)." ); + } + { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } + // Relying on compiler to supply full path name here + TempIndx = index( CurrentWorkingFolder, pathChar, true ); + if ( TempIndx == std::string::npos ) { + CurrentWorkingFolder = ""; + } else { + CurrentWorkingFolder.erase( TempIndx + 1 ); + } + // Get directories from ini file + ReadINIFile( LFN, "program", "dir", ProgramPath ); + + gio::close( LFN ); + + inputIddFileName = ProgramPath + "Energy+.idd"; + } + + // Check if specified files exist + { IOFlags flags; gio::inquire( inputIddFileName, flags ); FileExists = flags.exists(); } + if ( ! FileExists ) { + ShowFatalError( "EnergyPlus: Could not find input data dictionary: " + returnAbsolutePath(inputIddFileName) + "." ); + } + + { IOFlags flags; gio::inquire( inputIdfFileName, flags ); FileExists = flags.exists(); } + if ( ! FileExists ) { + ShowFatalError( "EnergyPlus: Could not find input data file: " + returnAbsolutePath(inputIdfFileName) + "." ); + } + + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); FileExists = flags.exists(); } + if ( ! FileExists ) { + ShowFatalError( "EnergyPlus: Could not find weather file: " + returnAbsolutePath(inputWeatherFileName) + "." ); + } + + OutputFileDebug = GetNewUnitNumber(); + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, outputDbgFileName, flags ); iostatus = flags.ios(); } + if ( iostatus != 0 ) { + ShowFatalError( "EnergyPlus: Could not open output debug file: " + outputDbgFileName + "." ); + } + + // Preprocessors (These will likely move to a new file) bool inputFileNamedIn = (idfFileNameOnly == "in"); if(runEPMacro){ if (!inputFileNamedIn) symlink(inputIdfFileName.c_str(), "in.imf"); - std::string runEPMacro = exePathName + "EPMacro"; + std::string runEPMacro = exeDirectory + "EPMacro"; DisplayString("Running EPMacro..."); system(runEPMacro.c_str()); if (!inputFileNamedIn) @@ -434,7 +502,7 @@ ProcessArgs(int argc, const char * argv[]) } if(runExpandObjects) { - std::string runExpandObjects = exePathName + "ExpandObjects"; + std::string runExpandObjects = exeDirectory + "ExpandObjects"; if (!inputFileNamedIn) symlink(inputIdfFileName.c_str(), "in.idf"); system(runExpandObjects.c_str()); @@ -446,8 +514,158 @@ ProcessArgs(int argc, const char * argv[]) inputIdfFileName = outputExpidfFileName; } + return 0; } + +void +ReadINIFile( + int const UnitNumber, // Unit number of the opened INI file + std::string const & Heading, // Heading for the parameters ('[heading]') + std::string const & KindofParameter, // Kind of parameter to be found (String) + std::string & DataOut // Output from the retrieval +) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Linda K. Lawrie + // DATE WRITTEN September 1997 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This routine reads the .ini file and retrieves + // the path names for the files from it. + + // METHODOLOGY EMPLOYED: + // Duplicate the kind of reading the Windows "GetINISetting" would + // do. + + // REFERENCES: + // na + + // Using/Aliasing + using namespace EnergyPlus; + using namespace DataStringGlobals; + using namespace DataSystemVariables; + + // Locals + // SUBROUTINE ARGUMENT DEFINITIONS: + + // SUBROUTINE PARAMETER DEFINITIONS: + + // INTERFACE BLOCK SPECIFICATIONS + // na + + // DERIVED TYPE DEFINITIONS + // na + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + static std::string LINE; + static std::string LINEOut; + std::string Param; + std::string::size_type ILB; + std::string::size_type IRB; + std::string::size_type IEQ; + std::string::size_type IPAR; + std::string::size_type IPOS; + std::string::size_type ILEN; + int ReadStat; + bool EndofFile; + bool Found; + bool NewHeading; + + // Formats + static gio::Fmt const Format_700( "(A)" ); + + DataOut = " "; + + // I tried ADJUSTL(TRIM(KindofParameter)) and got an internal compiler error + + Param = KindofParameter; + strip( Param ); + ILEN = len( Param ); + gio::rewind( UnitNumber ); + EndofFile = false; + Found = false; + NewHeading = false; + + while ( ! EndofFile && ! Found ) { + { IOFlags flags; gio::read( UnitNumber, Format_700, flags ) >> LINE; ReadStat = flags.ios(); } + if ( ReadStat < GoodIOStatValue ) { + EndofFile = true; + break; + } + + if ( len( LINE ) == 0 ) continue; // Ignore Blank Lines + + ConvertCaseToLower( LINE, LINEOut ); // Turn line into lower case + // LINE=LINEOut + + if ( ! has( LINEOut, Heading ) ) continue; + + // See if [ and ] are on line + ILB = index( LINEOut, '[' ); + IRB = index( LINEOut, ']' ); + if ( ILB == std::string::npos && IRB == std::string::npos ) continue; + if ( ! has( LINEOut, '[' + Heading + ']' ) ) continue; // Must be really correct heading line + + // Heading line found, now looking for Kind + while ( ! EndofFile && ! NewHeading ) { + { IOFlags flags; gio::read( UnitNumber, Format_700, flags ) >> LINE; ReadStat = flags.ios(); } + if ( ReadStat < GoodIOStatValue ) { + EndofFile = true; + break; + } + strip( LINE ); + + if ( len( LINE ) == 0 ) continue; // Ignore Blank Lines + + ConvertCaseToLower( LINE, LINEOut ); // Turn line into lower case + // LINE=LINEOut + + ILB = index( LINEOut, '[' ); + IRB = index( LINEOut, ']' ); + NewHeading = ( ILB != std::string::npos && IRB != std::string::npos ); + + // Should be a parameter line + // KindofParameter = string + IEQ = index( LINEOut, '=' ); + IPAR = index( LINEOut, Param ); + if ( IEQ == std::string::npos ) continue; + if ( IPAR == std::string::npos ) continue; + if ( IPAR != 0 ) continue; + if ( ! has( LINEOut, Param + '=' ) ) continue; // needs to be param= + + // = found and parameter found. + if ( IPAR > IEQ ) continue; + + // parameter = found + // Set output string to start with non-blank character + + DataOut = stripped( LINE.substr( IEQ + 1 ) ); + Found = true; + break; + + } + + } + + if ( Param == "dir" ) { + IPOS = len( DataOut ); + if ( IPOS != 0 ) { + // Non-blank make sure last position is valid path character + // (Set in DataStringGlobals) + + if ( DataOut[ IPOS - 1 ] != pathChar ) { + DataOut += pathChar; + } + + } + } + +} + } //CommandLineInterface namespace } //EnergyPlus namespace diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 58bf147d613..cd29911b6c7 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -55,16 +55,25 @@ namespace CommandLineInterface { extern std::string weatherFileNameOnly; extern std::string idfFileNameOnly; - extern std::string exePathName; + extern std::string exeDirectory; extern bool runReadVars; extern bool DDOnlySimulation; extern bool AnnualSimulation; - extern bool iddArgSet; // Process command line arguments int ProcessArgs( int argc, const char * argv[] ); + + void + ReadINIFile( + int const UnitNumber, // Unit number of the opened INI file + std::string const & Heading, // Heading for the parameters ('[heading]') + std::string const & KindofParameter, // Kind of parameter to be found (String) + std::string & DataOut // Output from the retrieval + ); + } + } #endif diff --git a/src/EnergyPlus/DataStringGlobals.in.cc b/src/EnergyPlus/DataStringGlobals.in.cc index cfc60e85537..7b50b0e0f5f 100644 --- a/src/EnergyPlus/DataStringGlobals.in.cc +++ b/src/EnergyPlus/DataStringGlobals.in.cc @@ -69,7 +69,6 @@ namespace DataStringGlobals { // MODULE VARIABLE DECLARATIONS: std::string ProgramPath; // Path for Program from INI file 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) std::string VerString( "EnergyPlus, Version ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH}-${CMAKE_VERSION_BUILD}" ); // String that represents version information std::string MatchVersion( "${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH}" ); // String to be matched by Version object diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index 8b446587f52..966be32bea4 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -3827,20 +3827,21 @@ namespace HeatBalanceManager { // A FrameAndDivider object will also be created if window on data file has a // frame or divider.) + std::string window5DataFileName; if ( ConstructAlphas( 1 ) == "" ) { - FullName = CurrentWorkingFolder + "Window5DataFile.dat"; + window5DataFileName = CurrentWorkingFolder + "Window5DataFile.dat"; } else { - FullName = ConstructAlphas( 1 ); + window5DataFileName = ConstructAlphas( 1 ); } DisplayString( "Searching Window5 data file for Construction=" + ConstructAlphas( 0 ) ); - SearchWindow5DataFile( FullName, ConstructAlphas( 0 ), ConstructionFound, EOFonW5File, ErrorsFound ); + SearchWindow5DataFile( window5DataFileName, ConstructAlphas( 0 ), ConstructionFound, EOFonW5File, ErrorsFound ); if ( EOFonW5File || ! ConstructionFound ) { DisplayString( "--Construction not found" ); ErrorsFound = true; ShowSevereError( "No match on WINDOW5 data file for Construction=" + ConstructAlphas( 0 ) + ", or error in data file." ); - ShowContinueError( "...Looking on file=" + FullName ); + ShowContinueError( "...Looking on file=" + window5DataFileName ); continue; } diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 4768bff43d4..1635d2b7028 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -253,19 +253,8 @@ namespace InputProcessor { ShowFatalError( "ProcessInput: Could not open file " + outputAuditFileName + " for output (write)." ); } - // FullName from StringGlobals is used to build file name with Path - if ( len( ProgramPath ) == 0 || iddArgSet) { - FullName = inputIddFileName; - } else { - FullName = ProgramPath + "Energy+.idd"; - } - { IOFlags flags; gio::inquire( FullName, flags ); FileExists = flags.exists(); } - if ( ! FileExists ) { - DisplayString( "Missing " + FullName ); - ShowFatalError( "ProcessInput: " + inputIddFileName + " missing. Program terminates. Fullname = " + FullName ); - } IDDFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( IDDFile, FullName, flags ); read_stat = flags.ios();} + { IOFlags flags; flags.ACTION( "read" ); gio::open( IDDFile, inputIddFileName, flags ); read_stat = flags.ios();} if ( read_stat != 0 ) { DisplayString( "Could not open (read) " + inputIddFileName ); ShowFatalError( "ProcessInput: Could not open file " + inputIddFileName + " for input (read)." ); @@ -325,12 +314,6 @@ namespace InputProcessor { gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (inputFileName) -- Start"; - { IOFlags flags; gio::inquire( inputIdfFileName, flags ); FileExists = flags.exists(); } - if ( ! FileExists ) { - DisplayString( "Missing " + CurrentWorkingFolder + inputIdfFileName ); - ShowFatalError( "ProcessInput: " + inputIdfFileName + " missing. Program terminates." ); - } - IDFFile = GetNewUnitNumber(); { IOFlags flags; flags.ACTION( "READ" ); gio::open( IDFFile, inputIdfFileName, flags ); read_stat = flags.ios(); } if ( read_stat != 0 ) { diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index c6b0838f601..27927f4a1e3 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -46,10 +46,7 @@ extern "C" { namespace EnergyPlus { void -AbortEnergyPlus( - bool const NoIdf, // Set to true when "noidf" was found - bool const NoIDD // Set to true when "noidd" was found -) +AbortEnergyPlus() { // SUBROUTINE INFORMATION: @@ -173,31 +170,6 @@ AbortEnergyPlus( NumSevereDuringSizing = RoundSigDigits( TotalSevereErrorsDuringSizing ); strip( NumSevereDuringSizing ); - if ( NoIDD ) { - DisplayString( "No EnergyPlus Data Dictionary (" + inputIddFileName+") was found. It is possible " ); - DisplayString( "you \"double-clicked\"EnergyPlus.exe rather than using one of the methods" ); - DisplayString( "to run Energyplus as found in the GettingStarted document in the" ); - DisplayString( "documentation folder. Using EP-Launch may be best -- " ); - DisplayString( "it provides extra help for new users." ); - ShowMessage( "No EnergyPlus Data Dictionary (" + inputIddFileName+") was found. It is possible you \"double-clicked\" EnergyPlus.exe " ); - ShowMessage( "rather than using one of the methods to run Energyplus as found in the GettingStarted document" ); - ShowMessage( "in the documentation folder. Using EP-Launch may be best -- it provides extra help for new users." ); - { IOFlags flags; flags.ADVANCE( "NO" ); gio::write( OutFmt, flags ); } - gio::read( "*" ); - } - - if ( NoIdf ) { - DisplayString( "No input file (in.idf) was found. It is possible you \"double-clicked\"" ); - DisplayString( "EnergyPlus.exe rather than using one of the methods to run Energyplus" ); - DisplayString( "as found in the GettingStarted document in the documentation folder." ); - DisplayString( "Using EP-Launch may be best -- it provides extra help for new users." ); - ShowMessage( "No input file (in.idf) was found. It is possible you \"double-clicked\" EnergyPlus.exe rather than" ); - ShowMessage( "using one of the methods to run Energyplus as found in the GettingStarted document in the documentation" ); - ShowMessage( "folder. Using EP-Launch may be best -- it provides extra help for new users." ); - { IOFlags flags; flags.ADVANCE( "NO" ); gio::write( OutFmt, flags ); } - gio::read( "*" ); - } - // catch up with timings if in middle Time_Finish = epElapsedTime(); if ( Time_Finish < Time_Start ) Time_Finish += 24.0 * 3600.0; @@ -833,21 +805,17 @@ ShowFatalError( // na // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static bool NoIdf( false ); - static bool NoIDD( false ); ShowErrorMessage( " ** Fatal ** " + ErrorMessage, OutUnit1, OutUnit2 ); DisplayString( "**FATAL:" + ErrorMessage ); - if ( has( ErrorMessage, inputIdfFileName +" missing" ) ) NoIdf = true; - if ( has( ErrorMessage, inputIddFileName +" missing" ) ) NoIDD = true; ShowErrorMessage( " ...Summary of Errors that led to program termination:", OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Reference severe error count=" + RoundSigDigits( TotalSevereErrors ), OutUnit1, OutUnit2 ); ShowErrorMessage( " ..... Last severe error=" + LastSevereError, OutUnit1, OutUnit2 ); if ( sqlite && sqlite->writeOutputToSQLite() ) { sqlite->createSQLiteErrorRecord( 1, 2, ErrorMessage, 1 ); } - AbortEnergyPlus( NoIdf, NoIDD ); + AbortEnergyPlus(); } diff --git a/src/EnergyPlus/UtilityRoutines.hh b/src/EnergyPlus/UtilityRoutines.hh index 33d62a4c0f7..50804c13211 100644 --- a/src/EnergyPlus/UtilityRoutines.hh +++ b/src/EnergyPlus/UtilityRoutines.hh @@ -10,10 +10,7 @@ namespace EnergyPlus { void -AbortEnergyPlus( - bool const NoIdf, // Set to true when "noidf" was found - bool const NoIDD // Set to true when "noidd" was found -); +AbortEnergyPlus(); void CloseMiscOpenFiles(); diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 9dca79cf4ff..29f764a3544 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -233,8 +233,6 @@ main(int argc, const char * argv[]) // PROGRAM PARAMETER DEFINITIONS: // Note: General Parameters for the entire EnergyPlus program are contained // in "DataGlobals.f90" - gio::Fmt const EPlusiniFormat( "(/,'[',A,']',/,'dir=',A)" ); - std::string const BlankString; // INTERFACE BLOCK SPECIFICATIONS // na @@ -243,12 +241,7 @@ main(int argc, const char * argv[]) // na // PROGRAM LOCAL VARIABLE DECLARATIONS: - int LFN; // Unit Number for reads - bool EPlusINI; - std::string::size_type TempIndx; static std::string cEnvValue; - int iostatus; - bool FileExists; // INITIALIZE VARIABLES Time_Start = epElapsedTime(); @@ -342,68 +335,11 @@ main(int argc, const char * argv[]) get_environment_variable( TraceHVACControllerEnvVar, cEnvValue ); if ( ! cEnvValue.empty() ) TraceHVACControllerEnvFlag = env_var_on( cEnvValue ); // Yes or True - { IOFlags flags; gio::inquire( outputEndFileName, flags ); FileExists = flags.exists(); } - if ( FileExists ) { - LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, outputEndFileName, flags ); iostatus = flags.ios(); } - if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file "+ outputEndFileName +" for input (read)." ); - } - { IOFlags flags; flags.DISPOSE( "delete" ); gio::close( LFN, flags ); } - } - - { IOFlags flags; gio::inquire( EnergyPlusIniFileName, flags ); EPlusINI = flags.exists(); } - if ( EPlusINI ) { - LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } - if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file "+EnergyPlusIniFileName+" for input (read)." ); - } - { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } - // Relying on compiler to supply full path name here - TempIndx = index( CurrentWorkingFolder, pathChar, true ); - if ( TempIndx == std::string::npos ) { - CurrentWorkingFolder = ""; - } else { - CurrentWorkingFolder.erase( TempIndx + 1 ); - } - // Get directories from ini file - ReadINIFile( LFN, "program", "dir", ProgramPath ); - - gio::close( LFN ); - } else { - DisplayString( "Missing " + EnergyPlusIniFileName ); - ProgramPath = ""; - LFN = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( LFN, EnergyPlusIniFileName, flags ); iostatus = flags.ios(); } - if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file "+EnergyPlusIniFileName+" for output (write)." ); - } - // Relying on compiler to supply full path name here - { IOFlags flags; gio::inquire( LFN, flags ); CurrentWorkingFolder = flags.name(); } - TempIndx = index( CurrentWorkingFolder, pathChar, true ); - if ( TempIndx == std::string::npos ) { - CurrentWorkingFolder = ""; - } else { - CurrentWorkingFolder.erase( TempIndx + 1 ); - } - gio::write( LFN, EPlusiniFormat ) << "program" << ProgramPath; - gio::close( LFN ); - } TestAllPaths = true; DisplayString( "EnergyPlus Starting" ); DisplayString( VerString ); - OutputFileDebug = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDebug, outputDbgFileName, flags ); iostatus = flags.ios(); } - if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file "+outputDbgFileName+" for output (write)." ); - } - - //Call ProcessInput to produce the IDF file which is read by all of the - // Get input routines in the rest of the simulation - ProcessInput(); ManageSimulation(); @@ -419,24 +355,33 @@ main(int argc, const char * argv[]) ReportOrphanSchedules(); if(runReadVars) { - std::ofstream ifile; - std::ofstream nfile; - std::string RVIfile = idfFileNameOnly + ".rvi"; - ifile.open(RVIfile.c_str()); - ifile << outputEsoFileName + "\n"; - ifile << outputCsvFileName + "\n"; - ifile.close(); - std::string MVIfile = idfFileNameOnly + ".mvi"; - nfile.open(MVIfile.c_str()); - nfile << outputMtrFileName + "\n"; - nfile << outputMtrCsvFileName + "\n"; - nfile.close(); + int fileUnitNumber; + int iostatus; + gio::Fmt const readvarsFmt( "(A)" ); + + fileUnitNumber = GetNewUnitNumber(); + { IOFlags flags; flags.ACTION( "write" ); gio::open( fileUnitNumber, RVIfile, flags ); iostatus = flags.ios(); } + if ( iostatus != 0 ) { + ShowFatalError( "EnergyPlus: Could not open file \"" + RVIfile + "\" for output (write)." ); + } + gio::write( fileUnitNumber, readvarsFmt ) << outputEsoFileName; + gio::write( fileUnitNumber, readvarsFmt ) << outputCsvFileName; + gio::close( fileUnitNumber ); + + fileUnitNumber = GetNewUnitNumber(); + { IOFlags flags; flags.ACTION( "write" ); gio::open( fileUnitNumber, MVIfile, flags ); iostatus = flags.ios(); } + if ( iostatus != 0 ) { + ShowFatalError( "EnergyPlus: Could not open file \"" + MVIfile + "\" for output (write)." ); + } + gio::write( fileUnitNumber, readvarsFmt ) << outputMtrFileName; + gio::write( fileUnitNumber, readvarsFmt ) << outputMtrCsvFileName; + gio::close( fileUnitNumber ); std::string ReadVars = "ReadVarsESO"; - std::string ReadVarsRVI = exePathName + ReadVars + " " + RVIfile + " unlimited"; - std::string ReadVarsMVI = exePathName + ReadVars + " " + MVIfile + " unlimited"; + std::string ReadVarsRVI = exeDirectory + ReadVars + " " + RVIfile + " unlimited"; + std::string ReadVarsMVI = exeDirectory + ReadVars + " " + MVIfile + " unlimited"; system(ReadVarsRVI.c_str()); system(ReadVarsMVI.c_str()); @@ -508,150 +453,3 @@ CreateCurrentDateTimeString( std::string & CurrentDateTimeString ) } -void -ReadINIFile( - int const UnitNumber, // Unit number of the opened INI file - std::string const & Heading, // Heading for the parameters ('[heading]') - std::string const & KindofParameter, // Kind of parameter to be found (String) - std::string & DataOut // Output from the retrieval -) -{ - - // SUBROUTINE INFORMATION: - // AUTHOR Linda K. Lawrie - // DATE WRITTEN September 1997 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This routine reads the .ini file and retrieves - // the path names for the files from it. - - // METHODOLOGY EMPLOYED: - // Duplicate the kind of reading the Windows "GetINISetting" would - // do. - - // REFERENCES: - // na - - // Using/Aliasing - using namespace EnergyPlus; - using namespace DataStringGlobals; - using namespace DataSystemVariables; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static std::string LINE; - static std::string LINEOut; - std::string Param; - std::string::size_type ILB; - std::string::size_type IRB; - std::string::size_type IEQ; - std::string::size_type IPAR; - std::string::size_type IPOS; - std::string::size_type ILEN; - int ReadStat; - bool EndofFile; - bool Found; - bool NewHeading; - - // Formats - static gio::Fmt const Format_700( "(A)" ); - - DataOut = " "; - - // I tried ADJUSTL(TRIM(KindofParameter)) and got an internal compiler error - - Param = KindofParameter; - strip( Param ); - ILEN = len( Param ); - gio::rewind( UnitNumber ); - EndofFile = false; - Found = false; - NewHeading = false; - - while ( ! EndofFile && ! Found ) { - { IOFlags flags; gio::read( UnitNumber, Format_700, flags ) >> LINE; ReadStat = flags.ios(); } - if ( ReadStat < GoodIOStatValue ) { - EndofFile = true; - break; - } - - if ( len( LINE ) == 0 ) continue; // Ignore Blank Lines - - ConvertCaseToLower( LINE, LINEOut ); // Turn line into lower case - // LINE=LINEOut - - if ( ! has( LINEOut, Heading ) ) continue; - - // See if [ and ] are on line - ILB = index( LINEOut, '[' ); - IRB = index( LINEOut, ']' ); - if ( ILB == std::string::npos && IRB == std::string::npos ) continue; - if ( ! has( LINEOut, '[' + Heading + ']' ) ) continue; // Must be really correct heading line - - // Heading line found, now looking for Kind - while ( ! EndofFile && ! NewHeading ) { - { IOFlags flags; gio::read( UnitNumber, Format_700, flags ) >> LINE; ReadStat = flags.ios(); } - if ( ReadStat < GoodIOStatValue ) { - EndofFile = true; - break; - } - strip( LINE ); - - if ( len( LINE ) == 0 ) continue; // Ignore Blank Lines - - ConvertCaseToLower( LINE, LINEOut ); // Turn line into lower case - // LINE=LINEOut - - ILB = index( LINEOut, '[' ); - IRB = index( LINEOut, ']' ); - NewHeading = ( ILB != std::string::npos && IRB != std::string::npos ); - - // Should be a parameter line - // KindofParameter = string - IEQ = index( LINEOut, '=' ); - IPAR = index( LINEOut, Param ); - if ( IEQ == std::string::npos ) continue; - if ( IPAR == std::string::npos ) continue; - if ( IPAR != 0 ) continue; - if ( ! has( LINEOut, Param + '=' ) ) continue; // needs to be param= - - // = found and parameter found. - if ( IPAR > IEQ ) continue; - - // parameter = found - // Set output string to start with non-blank character - - DataOut = stripped( LINE.substr( IEQ + 1 ) ); - Found = true; - break; - - } - - } - - if ( Param == "dir" ) { - IPOS = len( DataOut ); - if ( IPOS != 0 ) { - // Non-blank make sure last position is valid path character - // (Set in DataStringGlobals) - - if ( DataOut[ IPOS - 1 ] != pathChar ) { - DataOut += pathChar; - } - - } - } - -} diff --git a/third_party/CLI/ezOptionParser.hpp b/third_party/CLI/ezOptionParser.hpp index b7a93def6e0..bc070363531 100644 --- a/third_party/CLI/ezOptionParser.hpp +++ b/third_party/CLI/ezOptionParser.hpp @@ -1781,11 +1781,11 @@ void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { usage.append("\n\n"); usage.append("USAGE: "); usage.append(syntax); - usage.append("\n\nOPTIONS:\n\n"); + usage.append("\n\nOPTIONS:\n"); getUsageDescriptions(usage, width, layout); if (!example.empty()) { - usage.append("EXAMPLES:\n\n"); + usage.append("\nEXAMPLE: "); usage.append(example); } @@ -1828,7 +1828,7 @@ void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout opts.append( *groups[k]->flags[j] ); if (groups[k]->expectArgs) { - opts.append(" ARG"); + opts.append("=[ARG]"); if (groups[k]->delim) { opts.append("1["); From 263135fadaf6d7f05472ab758bd496b811f8ac72 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 15 Oct 2014 18:28:32 -0600 Subject: [PATCH 32/71] Change output file name suffixes to be consistent with shell script. --- src/EnergyPlus/CommandLineInterface.cc | 191 ++++++++++++++------ src/EnergyPlus/CommandLineInterface.hh | 7 +- src/EnergyPlus/DElightManagerF.cc | 7 +- src/EnergyPlus/DaylightingManager.cc | 4 +- src/EnergyPlus/HeatBalanceSurfaceManager.cc | 4 +- src/EnergyPlus/InputProcessor.cc | 2 +- src/EnergyPlus/SQLiteProcedures.cc | 7 +- third_party/CLI/ezOptionParser.hpp | 12 +- 8 files changed, 156 insertions(+), 78 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index e7dd2ff4a83..79a4c9edcf1 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -66,7 +66,10 @@ std::string inputIddFileName; std::string inputWeatherFileName; std::string outputAdsFileName; std::string outputDfsFileName; -std::string outputDelightFileName; +std::string outputDelightInFileName; +std::string outputDelightOutFileName; +std::string outputDelightEldmpFileName; +std::string outputDelightDfdmpFileName; std::string outputMapTabFileName; std::string outputMapCsvFileName; std::string outputMapTxtFileName; @@ -83,6 +86,8 @@ std::string outputSszCsvFileName; std::string outputSszTabFileName; std::string outputSszTxtFileName; std::string outputScreenCsvFileName; +std::string outputSqlFileName; +std::string outputSqliteErrFileName; std::string EnergyPlusIniFileName; std::string inStatFileName; std::string TarcogIterationsFileName; @@ -211,16 +216,22 @@ ProcessArgs(int argc, const char * argv[]) cStrArgs.push_back(arguments[i].c_str()); } + int argCount = cStrArgs.size(); + + bool legacyMode = (argCount == 1); + + // Define options ezOptionParser opt; opt.overview = VerString; - opt.example = "energyplus -w weather.epw -o output -r input.idf"; opt.syntax = "energyplus [options] [input file]"; opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); - opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--designday"); + opt.add("", 0, 1, 0, "Output directory path (default: current working directory)", "-d", "--output-directory"); + + opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--design-day"); opt.add("", 0, 0, 0, "Display help information", "-h", "--help"); @@ -228,8 +239,6 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Run EPMacro", "-m", "--epmacro"); - opt.add("", 0, 1, 0, "Output directory path (default: current working directory)", "-o", "--output-directory"); - opt.add("", 0, 1, 0, "Prefix for output file names (default: same as input file name)", "-p", "--output-prefix"); opt.add("", 0, 0, 0, "Run ReadVarsESO", "-r", "--readvars"); @@ -238,12 +247,14 @@ ProcessArgs(int argc, const char * argv[]) opt.add("in.epw", 0, 1, 0, "Weather file path (default: in.epw)", "-w", "--weather"); - opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expand"); + opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expandobjects"); + + opt.example = "energyplus -w weather.epw -d output -r input.idf"; std::string errorFollowUp = "Type 'energyplus --help' for usage."; // Parse arguments - opt.parse(cStrArgs.size(), &cStrArgs[0]); + opt.parse(argCount, &cStrArgs[0]); // print arguments parsed (useful for debugging) /*std::string pretty; @@ -260,12 +271,12 @@ ProcessArgs(int argc, const char * argv[]) opt.get("-i")->getString(inputIddFileName); - if (!opt.isSet("-i") && argc > 1) + if (!opt.isSet("-i") && !legacyMode) inputIddFileName = exeDirectory + inputIddFileName; std::string dirPathName; - opt.get("-o")->getString(dirPathName); + opt.get("-d")->getString(dirPathName); runReadVars = opt.isSet("-r"); @@ -303,7 +314,7 @@ ProcessArgs(int argc, const char * argv[]) exit(EXIT_FAILURE); } - if(opt.lastArgs.size() == 0 && argc > 0){ + if(opt.lastArgs.size() == 0 && !legacyMode){ DisplayString("ERROR: No input file provided."); DisplayString(errorFollowUp); exit(EXIT_FAILURE); @@ -320,7 +331,7 @@ ProcessArgs(int argc, const char * argv[]) runEPMacro = opt.isSet("-m"); - if (opt.isSet("-o") ){ + if (opt.isSet("-d") ){ struct stat sb = {0}; if (stat(dirPathName.c_str(), &sb) == -1) { @@ -337,59 +348,119 @@ ProcessArgs(int argc, const char * argv[]) if(opt.isSet("-p")) { std::string prefixOutName; opt.get("-p")->getString(prefixOutName); - outputFilePrefix = dirPathName + prefixOutName + "-"; + outputFilePrefix = dirPathName + prefixOutName; } - else if (argc > 1) - outputFilePrefix = dirPathName + idfFileNameOnly + "-"; + else if (!legacyMode) + outputFilePrefix = dirPathName + idfFileNameOnly; else outputFilePrefix = dirPathName + "eplus"; - // EnergyPlus files - 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"; - 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"; - outputDbgFileName = outputFilePrefix + "out.dbg"; - EnergyPlusIniFileName = "Energy+.ini"; - inStatFileName = weatherFilePathWithoutExtension + ".stat"; - TarcogIterationsFileName = "TarcogIterations.dbg"; - eplusADSFileName = idfDirPathName+"eplusADS.inp"; - - // Readvars files - outputCsvFileName = outputFilePrefix + "out.csv"; - outputMtrCsvFileName = outputFilePrefix + "mtr.csv"; - outputRvauditFileName = outputFilePrefix + "out.rvaudit"; + if (legacyMode) { + // EnergyPlus files + 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"; + outputDelightInFileName = "eplusout.delightin"; + outputDelightOutFileName = "eplusout.delightout"; + outputDelightEldmpFileName = "eplusout.delighteldmp"; + outputDelightDfdmpFileName = "eplusout.delightdfdmp"; + outputMapTabFileName = outputFilePrefix + "map.tab"; + outputMapCsvFileName = outputFilePrefix + "map.csv"; + outputMapTxtFileName = outputFilePrefix + "map.txt"; + outputEddFileName = outputFilePrefix + "out.edd"; + outputIperrFileName = outputFilePrefix + "out.iperr"; + 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"; + outputSqlFileName = outputFilePrefix + "out.sql"; + outputSqliteErrFileName = dirPathName + "sqlite.err"; + outputDbgFileName = outputFilePrefix + "out.dbg"; + EnergyPlusIniFileName = "Energy+.ini"; + inStatFileName = weatherFilePathWithoutExtension + ".stat"; + TarcogIterationsFileName = "TarcogIterations.dbg"; + eplusADSFileName = idfDirPathName+"eplusADS.inp"; + + // Readvars files + outputCsvFileName = outputFilePrefix + "out.csv"; + outputMtrCsvFileName = outputFilePrefix + "mtr.csv"; + outputRvauditFileName = outputFilePrefix + "out.rvaudit"; + } + else { + // EnergyPlus files + outputAuditFileName = outputFilePrefix + ".audit"; + outputBndFileName = outputFilePrefix + ".bnd"; + outputDxfFileName = outputFilePrefix + ".dxf"; + outputEioFileName = outputFilePrefix + ".eio"; + outputEndFileName = outputFilePrefix + ".end"; + outputErrFileName = outputFilePrefix + ".err"; + outputEsoFileName = outputFilePrefix + ".eso"; + outputMtdFileName = outputFilePrefix + ".mtd"; + outputMddFileName = outputFilePrefix + ".mdd"; + outputMtrFileName = outputFilePrefix + ".mtr"; + outputRddFileName = outputFilePrefix + ".rdd"; + outputShdFileName = outputFilePrefix + ".shd"; + outputTblCsvFileName = outputFilePrefix + "Table.csv"; + outputTblHtmFileName = outputFilePrefix + "Table.htm"; + outputTblTabFileName = outputFilePrefix + "Table.tab"; + outputTblTxtFileName = outputFilePrefix + "Table.txt"; + outputTblXmlFileName = outputFilePrefix + "Table.xml"; + outputAdsFileName = outputFilePrefix + "ADS.out"; + outputDfsFileName = outputFilePrefix + ".dfs"; + outputDelightInFileName = "eplusout.delightin"; + outputDelightOutFileName = "eplusout.delightout"; + outputDelightEldmpFileName = "eplusout.delighteldmp"; + outputDelightDfdmpFileName = "eplusout.delightdfdmp"; + outputMapTabFileName = outputFilePrefix + "Map.tab"; + outputMapCsvFileName = outputFilePrefix + "Map.csv"; + outputMapTxtFileName = outputFilePrefix + "Map.txt"; + outputEddFileName = outputFilePrefix + ".edd"; + outputIperrFileName = outputFilePrefix + ".iperr"; + outputSlnFileName = outputFilePrefix + ".sln"; + outputSciFileName = outputFilePrefix + ".sci"; + outputWrlFileName = outputFilePrefix + ".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"; + outputSqlFileName = outputFilePrefix + ".sql"; + outputSqliteErrFileName = outputFilePrefix + "SQLite.err"; + outputDbgFileName = outputFilePrefix + ".dbg"; + EnergyPlusIniFileName = "Energy+.ini"; + inStatFileName = weatherFilePathWithoutExtension + ".stat"; + TarcogIterationsFileName = "TarcogIterations.dbg"; + eplusADSFileName = idfDirPathName+"eplusADS.inp"; + + // Readvars files + outputCsvFileName = outputFilePrefix + ".csv"; + outputMtrCsvFileName = outputFilePrefix + "Meter.csv"; + outputRvauditFileName = outputFilePrefix + ".rvaudit"; + } // Handle bad options std::vector badOptions; diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index cd29911b6c7..f3d53515577 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -28,7 +28,10 @@ namespace CommandLineInterface { extern std::string inputWeatherFileName; extern std::string outputAdsFileName; extern std::string outputDfsFileName; - extern std::string outputDelightFileName; + extern std::string outputDelightInFileName; + extern std::string outputDelightOutFileName; + extern std::string outputDelightEldmpFileName; + extern std::string outputDelightDfdmpFileName; extern std::string outputMapTabFileName; extern std::string outputMapCsvFileName; extern std::string outputMapTxtFileName; @@ -45,6 +48,8 @@ namespace CommandLineInterface { extern std::string outputSszTabFileName; extern std::string outputSszTxtFileName; extern std::string outputScreenCsvFileName; + extern std::string outputSqlFileName; + extern std::string outputSqliteErrFileName; extern std::string EnergyPlusIniFileName; extern std::string inStatFileName; extern std::string TarcogIterationsFileName; diff --git a/src/EnergyPlus/DElightManagerF.cc b/src/EnergyPlus/DElightManagerF.cc index e948f89eaba..d91f78b21a6 100644 --- a/src/EnergyPlus/DElightManagerF.cc +++ b/src/EnergyPlus/DElightManagerF.cc @@ -10,6 +10,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -81,6 +82,7 @@ namespace DElightManagerF { // This subroutine creates a DElight input file from EnergyPlus processed input. // USE STATEMENTS: + using namespace CommandLineInterface; using namespace DataGlobals; // Gives access to too many things to keep track of using namespace DataHeatBalance; // Gives access to Building, Zone(izone)%var and Lights(ilights) data using namespace DataEnvironment; // Gives access to Site data @@ -184,11 +186,10 @@ namespace DElightManagerF { // Open a file for writing DElight input from EnergyPlus data unit = GetNewUnitNumber(); - // Hardwire file name to eplusout.delightin in the current working directory { - IOFlags flags; flags.ACTION( "write" ); gio::open( unit, "eplusout.delightin", flags ); + IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDelightInFileName, flags ); if ( flags.err() ) { - ShowFatalError( "DElightInputGenerator: Could not open file \"eplusout.delightin\" for output (write)." ); + ShowFatalError( "DElightInputGenerator: Could not open file \""+ outputDelightInFileName + "\" for output (write)." ); } } diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index dc1441f2beb..09c7e00f5fa 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -4192,7 +4192,7 @@ namespace DaylightingManager { if ( iErrorFlag != 0 ) { // Open DElight Daylight Factors Error File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); } // Sequentially read lines in DElight Daylight Factors Error File // and process them using standard EPlus warning/error handling calls @@ -4233,7 +4233,7 @@ namespace DaylightingManager { } else { // Open, Close, and Delete DElight Daylight Factors Error File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); } { IOFlags flags; flags.DISPOSE( "DELETE" ); gio::close( iDElightErrorFile, flags ); } } SetupDElightOutput4EPlus(); diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 04eb777b8c8..fb3a2a060e8 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -494,7 +494,7 @@ namespace HeatBalanceSurfaceManager { // Open DElight Electric Lighting Error File for reading iDElightErrorFile = GetNewUnitNumber(); // RJH 2008-03-07: open file with READWRITE - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); iwriteStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); iwriteStatus = flags.ios(); } if ( iwriteStatus == 0 ) { elOpened = true; } else { @@ -538,7 +538,7 @@ namespace HeatBalanceSurfaceManager { // extract reference point illuminance values from DElight Electric Lighting dump file for reporting // Open DElight Electric Lighting Dump File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightFileName, flags ); iwriteStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); iwriteStatus = flags.ios(); } // IF (iwriteStatus /= 0) THEN // CALL ShowFatalError('InitSurfaceHeatBalance: Could not open file "eplusout.delighteldmp" for output (readwrite).') // ENDIF diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 1635d2b7028..5aa74b966e8 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -250,7 +250,7 @@ namespace InputProcessor { { IOFlags flags; flags.ACTION( "write" ); gio::open( CacheIPErrorFile, outputIperrFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { DisplayString( "Could not open (write) "+outputIperrFileName ); - ShowFatalError( "ProcessInput: Could not open file " + outputAuditFileName + " for output (write)." ); + ShowFatalError( "ProcessInput: Could not open file " + outputIperrFileName + " for output (write)." ); } IDDFile = GetNewUnitNumber(); diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index f0a447fb423..5ca2c32358d 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -1,6 +1,7 @@ // ObjexxFCL Headers // EnergyPlus Headers +#include "CommandLineInterface.hh" #include "SQLiteProcedures.hh" #include "DataGlobals.hh" #include "DataStringGlobals.hh" @@ -40,7 +41,7 @@ SQLite::SQLite() m_writeTabularDataToSQLite(false), m_sqlDBTimeIndex(0), m_db(nullptr), - m_dbName("eplusout.sql"), + m_dbName(CommandLineInterface::outputSqlFileName), m_reportVariableDataInsertStmt(nullptr), m_reportVariableExtendedDataInsertStmt(nullptr), m_timeIndexInsertStmt(nullptr), @@ -108,12 +109,12 @@ SQLite::SQLite() if( m_writeOutputToSQLite ) { int rc = -1; bool ok = true; - m_errorStream.open("sqlite.err", std::ofstream::out | std::ofstream::trunc); + m_errorStream.open(CommandLineInterface::outputSqliteErrFileName, std::ofstream::out | std::ofstream::trunc); // Test if we can write to the sqlite error file // Does there need to be a seperate sqlite.err file at all? Consider using eplusout.err if( m_errorStream.is_open() ) { - m_errorStream << "SQLite3 message, sqlite.err open for processing!" << std::endl; + m_errorStream << "SQLite3 message, " + CommandLineInterface::outputSqliteErrFileName + " open for processing!" << std::endl; } else { ok = false; } diff --git a/third_party/CLI/ezOptionParser.hpp b/third_party/CLI/ezOptionParser.hpp index bc070363531..41cda554173 100644 --- a/third_party/CLI/ezOptionParser.hpp +++ b/third_party/CLI/ezOptionParser.hpp @@ -1778,14 +1778,14 @@ OptionGroup * ezOptionParser::get(const char * name) { void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { usage.append(overview); - usage.append("\n\n"); - usage.append("USAGE: "); + usage.append("\n"); + usage.append("Usage: "); usage.append(syntax); - usage.append("\n\nOPTIONS:\n"); + usage.append("\nOptions:\n"); getUsageDescriptions(usage, width, layout); if (!example.empty()) { - usage.append("\nEXAMPLE: "); + usage.append("Example: "); usage.append(example); } @@ -1818,7 +1818,7 @@ void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout k = stringPtrToIndexMap[stringPtrs[i]]; opts.clear(); for(j=0; j < groups[k]->flags.size()-1; ++j) { - opts.append(*groups[k]->flags[j]); + opts.append(" " + *groups[k]->flags[j]); opts.append(", "); if ((long int)opts.size() > width) @@ -1828,7 +1828,7 @@ void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout opts.append( *groups[k]->flags[j] ); if (groups[k]->expectArgs) { - opts.append("=[ARG]"); + opts.append(" ARG"); if (groups[k]->delim) { opts.append("1["); From e8745babec1c8ee8c3e5997956fe70f6fe858409 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 16 Oct 2014 09:07:37 -0600 Subject: [PATCH 33/71] Support user created RVI/MVI files. --- src/EnergyPlus/CommandLineInterface.cc | 3 +- src/EnergyPlus/CommandLineInterface.hh | 1 + src/EnergyPlus/main.cc | 52 ++++++++++++++++---------- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 79a4c9edcf1..af184f36f28 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -97,6 +97,7 @@ std::string outputMtrCsvFileName; std::string outputRvauditFileName; std::string idfFileNameOnly; +std::string idfDirPathName; std::string exeDirectory; bool runReadVars(false); @@ -261,7 +262,7 @@ ProcessArgs(int argc, const char * argv[]) opt.prettyPrint(pretty); std::cout << pretty << std::endl;*/ - std::string usage, idfDirPathName; + std::string usage; opt.getUsage(usage); // Set path of EnergyPlus program path diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index f3d53515577..81bbf8bbb5c 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -59,6 +59,7 @@ namespace CommandLineInterface { extern std::string outputRvauditFileName; extern std::string weatherFileNameOnly; + extern std::string idfDirPathName; extern std::string idfFileNameOnly; extern std::string exeDirectory; diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 29f764a3544..4742a6c60fd 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -355,29 +355,39 @@ main(int argc, const char * argv[]) ReportOrphanSchedules(); if(runReadVars) { - std::string RVIfile = idfFileNameOnly + ".rvi"; - std::string MVIfile = idfFileNameOnly + ".mvi"; + std::string RVIfile = idfDirPathName + idfFileNameOnly + ".rvi"; + std::string MVIfile = idfDirPathName + idfFileNameOnly + ".mvi"; + int fileUnitNumber; int iostatus; + bool rviFileExists; + bool mviFileExists; + gio::Fmt const readvarsFmt( "(A)" ); - fileUnitNumber = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( fileUnitNumber, RVIfile, flags ); iostatus = flags.ios(); } - if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"" + RVIfile + "\" for output (write)." ); + { IOFlags flags; gio::inquire( RVIfile, flags ); rviFileExists = flags.exists(); } + if (!rviFileExists) { + fileUnitNumber = GetNewUnitNumber(); + { IOFlags flags; flags.ACTION( "write" ); gio::open( fileUnitNumber, RVIfile, flags ); iostatus = flags.ios(); } + if ( iostatus != 0 ) { + ShowFatalError( "EnergyPlus: Could not open file \"" + RVIfile + "\" for output (write)." ); + } + gio::write( fileUnitNumber, readvarsFmt ) << outputEsoFileName; + gio::write( fileUnitNumber, readvarsFmt ) << outputCsvFileName; + gio::close( fileUnitNumber ); } - gio::write( fileUnitNumber, readvarsFmt ) << outputEsoFileName; - gio::write( fileUnitNumber, readvarsFmt ) << outputCsvFileName; - gio::close( fileUnitNumber ); - - fileUnitNumber = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( fileUnitNumber, MVIfile, flags ); iostatus = flags.ios(); } - if ( iostatus != 0 ) { - ShowFatalError( "EnergyPlus: Could not open file \"" + MVIfile + "\" for output (write)." ); + + { IOFlags flags; gio::inquire( MVIfile, flags ); mviFileExists = flags.exists(); } + if (!mviFileExists) { + fileUnitNumber = GetNewUnitNumber(); + { IOFlags flags; flags.ACTION( "write" ); gio::open( fileUnitNumber, MVIfile, flags ); iostatus = flags.ios(); } + if ( iostatus != 0 ) { + ShowFatalError( "EnergyPlus: Could not open file \"" + MVIfile + "\" for output (write)." ); + } + gio::write( fileUnitNumber, readvarsFmt ) << outputMtrFileName; + gio::write( fileUnitNumber, readvarsFmt ) << outputMtrCsvFileName; + gio::close( fileUnitNumber ); } - gio::write( fileUnitNumber, readvarsFmt ) << outputMtrFileName; - gio::write( fileUnitNumber, readvarsFmt ) << outputMtrCsvFileName; - gio::close( fileUnitNumber ); std::string ReadVars = "ReadVarsESO"; std::string ReadVarsRVI = exeDirectory + ReadVars + " " + RVIfile + " unlimited"; @@ -386,8 +396,12 @@ main(int argc, const char * argv[]) system(ReadVarsRVI.c_str()); system(ReadVarsMVI.c_str()); - remove(RVIfile.c_str()); - remove(MVIfile.c_str()); + if (!rviFileExists) + remove(RVIfile.c_str()); + + if (!mviFileExists) + remove(MVIfile.c_str()); + rename("readvars.audit", outputRvauditFileName.c_str()); } From 79034d08d71ff522611bafc68444405561698f6d Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 16 Oct 2014 11:13:34 -0600 Subject: [PATCH 34/71] Move file system functions into separate source file. --- src/EnergyPlus/CMakeLists.txt | 2 + src/EnergyPlus/CommandLineInterface.cc | 183 +++++++++---------------- src/EnergyPlus/FileSystem.cc | 104 ++++++++++++++ src/EnergyPlus/FileSystem.hh | 43 ++++++ src/EnergyPlus/main.cc | 15 +- 5 files changed, 218 insertions(+), 129 deletions(-) create mode 100644 src/EnergyPlus/FileSystem.cc create mode 100644 src/EnergyPlus/FileSystem.hh diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 14ee2ba6c16..4bf725d8827 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -210,6 +210,8 @@ SET( SRC Fans.hh FaultsManager.cc FaultsManager.hh + FileSystem.cc + FileSystem.hh FluidCoolers.cc FluidCoolers.hh FluidProperties.cc diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index af184f36f28..7bfa1fab807 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -1,14 +1,3 @@ -//Standard C++ library -#include -#include -#include -#include -#include -#include -#include -#include -#include - // CLI Headers #include @@ -22,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +27,7 @@ namespace CommandLineInterface{ using namespace DataGlobals; using namespace DataStringGlobals; using namespace DataSystemVariables; +using namespace FileSystem; using namespace InputProcessor; using namespace SimulationManager; using namespace OutputReportTabular; @@ -104,87 +95,6 @@ bool runReadVars(false); bool DDOnlySimulation(false); bool AnnualSimulation(false); -bool -fileExist(const std::string& filename) -{ - std::ifstream infile(filename); - return infile.good(); -} - -std::string -returnFileName( std::string const& filepath ) -{ - int pathCharPosition = filepath.find_last_of(pathChar); - return filepath.substr(pathCharPosition + 1, filepath.size() - 1); -} - -std::string -returnDirPath( std::string const& filepath ) -{ - int pathCharPosition = filepath.find_last_of(pathChar); - return filepath.substr(0, pathCharPosition + 1); -} - -std::string -returnAbsolutePath( std::string const& filepath ) -{ - char absolutePath[1024]; - realpath(filepath.c_str(), absolutePath); - return std::string(absolutePath); -} - -std::string -returnProgramPath() -{ - char executableRelativePath[1024]; - uint32_t pathSize = sizeof(executableRelativePath); - _NSGetExecutablePath(executableRelativePath, &pathSize); - - return std::string(executableRelativePath); -} - - -// Not currently used -std::string -returnFileExtension(const std::string& filename){ - int extensionPosition = filename.find_last_of("."); - return filename.substr(extensionPosition + 1, filename.size() - 1); -} - -std::string -removeFileExtension(const std::string& filename){ - int extensionPosition = filename.find_last_of("."); - return filename.substr(0, extensionPosition); -} - -int -mkpath(std::string s,mode_t mode) -{ - size_t pre=0,pos; - std::string dir; - int mdret; - - if(s[s.size()-1]!=pathChar){ - s+=pathChar; - } - - while((pos=s.find_first_of(pathChar,pre))!=std::string::npos){ - dir=s.substr(0,pos++); - pre=pos; - if(dir.size()==0) continue; // if leading / first time is 0 length - if((mdret=mkdir(dir.c_str(),mode)) && errno!=EEXIST){ - return mdret; - } - } - return mdret; -} - -std::string EqualsToSpace(std::string text) -{ - std::replace(text.begin(), text.end(), '=', ' '); - return text; -} - int ProcessArgs(int argc, const char * argv[]) { @@ -266,7 +176,7 @@ ProcessArgs(int argc, const char * argv[]) opt.getUsage(usage); // Set path of EnergyPlus program path - exeDirectory = returnDirPath(returnAbsolutePath(returnProgramPath())); + exeDirectory = getDirectoryPath(getAbsolutePath(getProgramPath())); opt.get("-w")->getString(inputWeatherFileName); @@ -320,8 +230,8 @@ ProcessArgs(int argc, const char * argv[]) DisplayString(errorFollowUp); exit(EXIT_FAILURE); } - idfFileNameOnly = removeFileExtension(returnFileName(inputIdfFileName)); - idfDirPathName = returnDirPath(inputIdfFileName); + idfFileNameOnly = removeFileExtension(getFileName(inputIdfFileName)); + idfDirPathName = getDirectoryPath(inputIdfFileName); std::string weatherFilePathWithoutExtension = removeFileExtension(inputWeatherFileName); @@ -333,18 +243,16 @@ ProcessArgs(int argc, const char * argv[]) runEPMacro = opt.isSet("-m"); if (opt.isSet("-d") ){ - struct stat sb = {0}; - - if (stat(dirPathName.c_str(), &sb) == -1) { - int mkdirretval; - mkdirretval=mkpath(dirPathName,0755); - } - + // Add the trailing path character if necessary if(dirPathName[dirPathName.size()-1]!=pathChar){ dirPathName+=pathChar; } + + // Create directory if it doesn't already exist + makeDirectory(dirPathName); } + // File naming scheme std::string outputFilePrefix; if(opt.isSet("-p")) { std::string prefixOutName; @@ -356,6 +264,13 @@ ProcessArgs(int argc, const char * argv[]) else outputFilePrefix = dirPathName + "eplus"; + + std::string outputEpmdetFileName; + std::string outputEpmidfFileName; + + std::string outputExpidfFileName; + std::string outputExperrFileName; + if (legacyMode) { // EnergyPlus files outputAuditFileName = outputFilePrefix + "out.audit"; @@ -408,6 +323,14 @@ ProcessArgs(int argc, const char * argv[]) outputCsvFileName = outputFilePrefix + "out.csv"; outputMtrCsvFileName = outputFilePrefix + "mtr.csv"; outputRvauditFileName = outputFilePrefix + "out.rvaudit"; + + // EPMacro files + outputEpmdetFileName = outputFilePrefix + "out.epmdet"; + outputEpmidfFileName = outputFilePrefix + "out.epmidf"; + + // ExpandObjects files + outputExpidfFileName = outputFilePrefix + "out.expidf"; + outputExperrFileName = outputFilePrefix + "out.experr"; } else { // EnergyPlus files @@ -461,6 +384,14 @@ ProcessArgs(int argc, const char * argv[]) outputCsvFileName = outputFilePrefix + ".csv"; outputMtrCsvFileName = outputFilePrefix + "Meter.csv"; outputRvauditFileName = outputFilePrefix + ".rvaudit"; + + // EPMacro files + outputEpmdetFileName = outputFilePrefix + ".epmdet"; + outputEpmidfFileName = outputFilePrefix + ".epmidf"; + + // ExpandObjects files + outputExpidfFileName = outputFilePrefix + ".expidf"; + outputExperrFileName = outputFilePrefix + ".experr"; } // Handle bad options @@ -536,17 +467,17 @@ ProcessArgs(int argc, const char * argv[]) // Check if specified files exist { IOFlags flags; gio::inquire( inputIddFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - ShowFatalError( "EnergyPlus: Could not find input data dictionary: " + returnAbsolutePath(inputIddFileName) + "." ); + ShowFatalError( "EnergyPlus: Could not find input data dictionary: " + getAbsolutePath(inputIddFileName) + "." ); } { IOFlags flags; gio::inquire( inputIdfFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - ShowFatalError( "EnergyPlus: Could not find input data file: " + returnAbsolutePath(inputIdfFileName) + "." ); + ShowFatalError( "EnergyPlus: Could not find input data file: " + getAbsolutePath(inputIdfFileName) + "." ); } { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - ShowFatalError( "EnergyPlus: Could not find weather file: " + returnAbsolutePath(inputWeatherFileName) + "." ); + ShowFatalError( "EnergyPlus: Could not find weather file: " + getAbsolutePath(inputWeatherFileName) + "." ); } OutputFileDebug = GetNewUnitNumber(); @@ -556,33 +487,41 @@ ProcessArgs(int argc, const char * argv[]) } // Preprocessors (These will likely move to a new file) - bool inputFileNamedIn = (idfFileNameOnly == "in"); - if(runEPMacro){ + bool inputFileNamedIn = + (getAbsolutePath(inputIdfFileName) == getAbsolutePath("in.imf")); + if (!inputFileNamedIn) - symlink(inputIdfFileName.c_str(), "in.imf"); - std::string runEPMacro = exeDirectory + "EPMacro"; + linkFile(inputIdfFileName.c_str(), "in.imf"); + std::string epMacroCommand = exeDirectory + "EPMacro"; DisplayString("Running EPMacro..."); - system(runEPMacro.c_str()); + systemCall(epMacroCommand); if (!inputFileNamedIn) - remove("in.imf"); - std::string outputEpmdetFileName = outputFilePrefix + "out.epmdet"; - rename("audit.out",outputEpmdetFileName.c_str()); - std::string outputEpmidfFileName = outputFilePrefix + "out.epmidf"; - rename("out.idf",outputEpmidfFileName.c_str()); + removeFile("in.imf"); + moveFile("audit.out",outputEpmdetFileName); + moveFile("out.idf",outputEpmidfFileName); inputIdfFileName = outputEpmidfFileName; } if(runExpandObjects) { - std::string runExpandObjects = exeDirectory + "ExpandObjects"; + bool inputFileNamedIn = + (getAbsolutePath(inputIdfFileName) == getAbsolutePath("in.idf")); + + bool iddFileNamedEnergy = + (getAbsolutePath(inputIddFileName) == getAbsolutePath("Energy+.idd")); + + std::string expandObjectsCommand = exeDirectory + "ExpandObjects"; if (!inputFileNamedIn) - symlink(inputIdfFileName.c_str(), "in.idf"); - system(runExpandObjects.c_str()); + linkFile(inputIdfFileName.c_str(), "in.idf"); + if (!iddFileNamedEnergy) + linkFile(inputIddFileName,"Energy+.idd"); + systemCall(expandObjectsCommand); if (!inputFileNamedIn) - remove("in.idf"); - remove("expandedidf.err"); - std::string outputExpidfFileName = outputFilePrefix + "out.expidf"; - rename("expanded.idf", outputExpidfFileName.c_str()); + removeFile("in.idf"); + if (!iddFileNamedEnergy) + removeFile("Energy+.idd"); + moveFile("expandedidf.err", outputExperrFileName); + moveFile("expanded.idf", outputExpidfFileName); inputIdfFileName = outputExpidfFileName; } diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc new file mode 100644 index 00000000000..30e9141169d --- /dev/null +++ b/src/EnergyPlus/FileSystem.cc @@ -0,0 +1,104 @@ +//Standard C++ library +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// EnergyPlus Headers +#include +#include + + +namespace EnergyPlus{ + +namespace FileSystem { + +using DataStringGlobals::pathChar; + + +std::string +getFileName( std::string const& filePath ) +{ + int pathCharPosition = filePath.find_last_of(pathChar); + return filePath.substr(pathCharPosition + 1, filePath.size() - 1); +} + +std::string getDirectoryPath( std::string const& filePath ) +{ + int pathCharPosition = filePath.find_last_of(pathChar); + return filePath.substr(0, pathCharPosition + 1); +} + +std::string +getAbsolutePath( std::string const& filePath ) +{ + char absolutePath[1024]; + realpath(filePath.c_str(), absolutePath); + return std::string(absolutePath); +} + +std::string +getProgramPath() +{ + char executableRelativePath[1024]; + uint32_t pathSize = sizeof(executableRelativePath); + _NSGetExecutablePath(executableRelativePath, &pathSize); + + return std::string(executableRelativePath); +} + +std::string +getFileExtension(const std::string& fileName){ + int extensionPosition = fileName.find_last_of("."); + return fileName.substr(extensionPosition + 1, fileName.size() - 1); +} + +std::string +removeFileExtension(const std::string& fileName){ + int extensionPosition = fileName.find_last_of("."); + return fileName.substr(0, extensionPosition); +} + +void +makeDirectory(std::string directoryName) +{ + struct stat info; + + if ( info.st_mode & S_IFDIR ){ // directory already exists + } + else { // directory does not already exist + mkdir(directoryName.c_str(), 0755); + } +} + +void +moveFile(std::string filePath, std::string destination){ + rename(filePath.c_str(), destination.c_str()); +} + +void +systemCall(std::string command) +{ + system(command.c_str()); +} + +void +removeFile(std::string fileName) +{ + remove(fileName.c_str()); +} + +void +linkFile(std::string fileName, std::string link) +{ + symlink(fileName.c_str(), link.c_str()); +} + +} +} diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh new file mode 100644 index 00000000000..5c3a520eed7 --- /dev/null +++ b/src/EnergyPlus/FileSystem.hh @@ -0,0 +1,43 @@ +#ifndef FileSystem_hh_INCLUDED +#define FileSystem_hh_INCLUDED + +namespace EnergyPlus{ + +namespace FileSystem { + +std::string +getFileName( std::string const& filePath ); + +std::string +getDirectoryPath( std::string const& filePath ); + +std::string +getAbsolutePath( std::string const& filePath ); + +std::string getProgramPath(); + +std::string +getFileExtension(const std::string& fileName); + +std::string +removeFileExtension(const std::string& fileName); + +void +makeDirectory(std::string directoryName); + +void +moveFile(std::string filePath, std::string destination); + +void +systemCall(std::string command); + +void +removeFile(std::string fileName); + +void +linkFile(std::string fileName, std::string link); + + +} +} +#endif diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index 4742a6c60fd..b7721a804f8 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -213,14 +214,14 @@ main(int argc, const char * argv[]) using DataEnvironment::IgnoreBeamRadiation; using DataEnvironment::IgnoreDiffuseRadiation; // routine modules + using namespace CommandLineInterface; + using namespace FileSystem; using namespace InputProcessor; using namespace OutputProcessor; using namespace SimulationManager; using ScheduleManager::ReportOrphanSchedules; using FluidProperties::ReportOrphanFluids; using Psychrometrics::ShowPsychrometricSummary; - // CLI module - using namespace CommandLineInterface; // Enable floating point exceptions #ifndef NDEBUG @@ -393,16 +394,16 @@ main(int argc, const char * argv[]) std::string ReadVarsRVI = exeDirectory + ReadVars + " " + RVIfile + " unlimited"; std::string ReadVarsMVI = exeDirectory + ReadVars + " " + MVIfile + " unlimited"; - system(ReadVarsRVI.c_str()); - system(ReadVarsMVI.c_str()); + systemCall(ReadVarsRVI); + systemCall(ReadVarsMVI); if (!rviFileExists) - remove(RVIfile.c_str()); + removeFile(RVIfile.c_str()); if (!mviFileExists) - remove(MVIfile.c_str()); + removeFile(MVIfile.c_str()); - rename("readvars.audit", outputRvauditFileName.c_str()); + moveFile("readvars.audit", outputRvauditFileName); } From de3794b8aa71a696f0dd79251cb2d215a8b7a70b Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 16 Oct 2014 19:57:37 -0600 Subject: [PATCH 35/71] Make CLI work on linux. --- src/EnergyPlus/CMakeLists.txt | 2 +- src/EnergyPlus/FileSystem.cc | 7 ++++++- third_party/CLI/ezOptionParser.hpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 4bf725d8827..760a166bbea 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -533,7 +533,7 @@ endif() if(UNIX AND NOT APPLE) ADD_CUSTOM_COMMAND(TARGET energyplus POST_BUILD - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/Products/" ln -s "energyplus" "EnergyPlus" + COMMAND cd \"${CMAKE_BINARY_DIR}/Products/\"\;if [ ! -f EnergyPlus ]\; then ln -s energyplus EnergyPlus\;fi ) endif() diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 30e9141169d..fc32404e66d 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -7,8 +7,9 @@ #include #include #include +#ifdef __APPLE__ #include - +#endif // EnergyPlus Headers #include @@ -47,8 +48,12 @@ std::string getProgramPath() { char executableRelativePath[1024]; +#ifdef __APPLE__ uint32_t pathSize = sizeof(executableRelativePath); _NSGetExecutablePath(executableRelativePath, &pathSize); +#elif __linux__ + readlink("/proc/self/exe", executableRelativePath, sizeof(executableRelativePath)-1); +#endif return std::string(executableRelativePath); } diff --git a/third_party/CLI/ezOptionParser.hpp b/third_party/CLI/ezOptionParser.hpp index 41cda554173..97aaea59d01 100644 --- a/third_party/CLI/ezOptionParser.hpp +++ b/third_party/CLI/ezOptionParser.hpp @@ -1924,7 +1924,7 @@ void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout usage.append("\n"); } - if (this->doublespace) usage.append("\n"); + //if (this->doublespace) usage.append("\n"); for(cIter=desc.begin(); cIter != desc.end(); ++cIter) delete *cIter; From c069bbcc2bbcfe7a2dcab50f1c3f8dbfadd32dad Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 16 Oct 2014 21:31:29 -0600 Subject: [PATCH 36/71] Fix directory creation. --- src/EnergyPlus/FileSystem.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index fc32404e66d..924f9e37c74 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -12,8 +12,9 @@ #endif // EnergyPlus Headers -#include #include +#include +#include namespace EnergyPlus{ @@ -75,7 +76,12 @@ makeDirectory(std::string directoryName) { struct stat info; - if ( info.st_mode & S_IFDIR ){ // directory already exists + if ( stat(getAbsolutePath(directoryName).c_str(), &info) == 0){ // path already exists + if ( !(info.st_mode & S_IFDIR) ) + { + DisplayString("ERROR: " + getAbsolutePath(directoryName) + " is not a directory."); + exit(EXIT_FAILURE); + } } else { // directory does not already exist mkdir(directoryName.c_str(), 0755); From b30b615ce746c02fd16a61c58bc6bb05b3fe92c3 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 17 Oct 2014 13:53:01 -0600 Subject: [PATCH 37/71] Make CLI work on Windows. --- src/EnergyPlus/CommandLineInterface.cc | 4 ++-- src/EnergyPlus/FileSystem.cc | 21 +++++++++++++++++++++ src/EnergyPlus/main.cc | 23 ++++++++--------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 7bfa1fab807..04a5a846a33 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -493,7 +493,7 @@ ProcessArgs(int argc, const char * argv[]) if (!inputFileNamedIn) linkFile(inputIdfFileName.c_str(), "in.imf"); - std::string epMacroCommand = exeDirectory + "EPMacro"; + std::string epMacroCommand = "\"" + exeDirectory + "EPMacro\""; DisplayString("Running EPMacro..."); systemCall(epMacroCommand); if (!inputFileNamedIn) @@ -510,7 +510,7 @@ ProcessArgs(int argc, const char * argv[]) bool iddFileNamedEnergy = (getAbsolutePath(inputIddFileName) == getAbsolutePath("Energy+.idd")); - std::string expandObjectsCommand = exeDirectory + "ExpandObjects"; + std::string expandObjectsCommand = "\"" + exeDirectory + "ExpandObjects\""; if (!inputFileNamedIn) linkFile(inputIdfFileName.c_str(), "in.idf"); if (!iddFileNamedEnergy) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 924f9e37c74..1153caed505 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -6,7 +6,13 @@ #include #include #include + +#ifdef _WIN32 +#include +#else #include +#endif + #ifdef __APPLE__ #include #endif @@ -41,7 +47,11 @@ std::string getAbsolutePath( std::string const& filePath ) { char absolutePath[1024]; +#ifdef _WIN32 + GetFullPathName(filePath.c_str(), sizeof(absolutePath), absolutePath, NULL); +#else realpath(filePath.c_str(), absolutePath); +#endif return std::string(absolutePath); } @@ -49,11 +59,14 @@ std::string getProgramPath() { char executableRelativePath[1024]; + #ifdef __APPLE__ uint32_t pathSize = sizeof(executableRelativePath); _NSGetExecutablePath(executableRelativePath, &pathSize); #elif __linux__ readlink("/proc/self/exe", executableRelativePath, sizeof(executableRelativePath)-1); +#elif _WIN32 + GetModuleFileName(NULL, executableRelativePath, sizeof(executableRelativePath)); #endif return std::string(executableRelativePath); @@ -84,7 +97,11 @@ makeDirectory(std::string directoryName) } } else { // directory does not already exist +#ifdef _WIN32 + CreateDirectory(directoryName.c_str(), NULL); +#else mkdir(directoryName.c_str(), 0755); +#endif } } @@ -108,7 +125,11 @@ removeFile(std::string fileName) void linkFile(std::string fileName, std::string link) { +#ifdef _WIN32 + CopyFile(fileName.c_str(), link.c_str(), false); +#else symlink(fileName.c_str(), link.c_str()); +#endif } } diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index b7721a804f8..64f41c966c3 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -5,12 +5,6 @@ #endif #endif -//Standard C++ library -#include -#include -#include -// CLI Headers - // ObjexxFCL Headers #include #include @@ -45,7 +39,7 @@ main(int argc, const char * argv[]) // NOTICE - // Copyright � 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the + // Copyright (c) 1996-2014 The Board of Trustees of the University of Illinois and The Regents of the // University of California through Ernest Orlando Lawrence Berkeley National Laboratory. All rights // reserved. @@ -120,11 +114,11 @@ main(int argc, const char * argv[]) // (Conjunction Of Multizone Infiltration Specialists) developed by a multinational, multi-institutional // effort under the auspices of the International Energy Agency's Buildings and Community Systems Agreement // working group focusing on multizone air flow modeling (Annex 23) and now administered by the Swiss Federal - // Laboratories for Materials Testing and Research (EMPA), Division 175, �berlandstrasse 129, CH-8600 D�bendorf, + // Laboratories for Materials Testing and Research (EMPA), Division 175, Uberlandstrasse 129, CH-8600 Dubendorf, // Switzerland. // The EnergyPlus v1.2 model for displacement ventilation and cross-ventilation was developed - // by Guilherme Carrilho da Gra�a and Paul Linden of the Department of Mechanical and Aerospace + // by Guilherme Carrilho da Graca and Paul Linden of the Department of Mechanical and Aerospace // Engineering, University of California, San Diego. // The EnergyPlus models for UFAD served zones were developed by Anna Liu and Paul Linden at the Department @@ -390,12 +384,11 @@ main(int argc, const char * argv[]) gio::close( fileUnitNumber ); } - std::string ReadVars = "ReadVarsESO"; - std::string ReadVarsRVI = exeDirectory + ReadVars + " " + RVIfile + " unlimited"; - std::string ReadVarsMVI = exeDirectory + ReadVars + " " + MVIfile + " unlimited"; + std::string readVarsRviCommand = "\"" + exeDirectory + "ReadVarsESO\"" + " " + RVIfile + " unlimited"; + std::string readVarsMviCommand = "\"" + exeDirectory + "ReadVarsESO\"" + " " + MVIfile + " unlimited"; - systemCall(ReadVarsRVI); - systemCall(ReadVarsMVI); + systemCall(readVarsRviCommand); + systemCall(readVarsMviCommand); if (!rviFileExists) removeFile(RVIfile.c_str()); @@ -408,7 +401,7 @@ main(int argc, const char * argv[]) } EndEnergyPlus(); - + return 0; } From ad957c4cf008ca99572f4d17c6729ce52f0e9d3a Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 17 Oct 2014 15:17:27 -0600 Subject: [PATCH 38/71] Fix CLI error handling/messages. --- src/EnergyPlus/CommandLineInterface.cc | 25 ++++++++++++++----------- src/EnergyPlus/UtilityRoutines.cc | 1 - 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 04a5a846a33..f8f47356d18 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -212,7 +212,7 @@ ProcessArgs(int argc, const char * argv[]) inputIdfFileName = arg; } } - if(inputIdfFileName.empty()) + if(opt.lastArgs.size() == 0) inputIdfFileName = "in.idf"; if(opt.lastArgs.size() > 1){ @@ -225,11 +225,6 @@ ProcessArgs(int argc, const char * argv[]) exit(EXIT_FAILURE); } - if(opt.lastArgs.size() == 0 && !legacyMode){ - DisplayString("ERROR: No input file provided."); - DisplayString(errorFollowUp); - exit(EXIT_FAILURE); - } idfFileNameOnly = removeFileExtension(getFileName(inputIdfFileName)); idfDirPathName = getDirectoryPath(inputIdfFileName); @@ -467,17 +462,25 @@ ProcessArgs(int argc, const char * argv[]) // Check if specified files exist { IOFlags flags; gio::inquire( inputIddFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - ShowFatalError( "EnergyPlus: Could not find input data dictionary: " + getAbsolutePath(inputIddFileName) + "." ); + DisplayString("ERROR: Could not find input data dictionary: " + getAbsolutePath(inputIddFileName) + "." ); + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } { IOFlags flags; gio::inquire( inputIdfFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { - ShowFatalError( "EnergyPlus: Could not find input data file: " + getAbsolutePath(inputIdfFileName) + "." ); + DisplayString("ERROR: Could not find input data file: " + getAbsolutePath(inputIdfFileName) + "." ); + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); FileExists = flags.exists(); } - if ( ! FileExists ) { - ShowFatalError( "EnergyPlus: Could not find weather file: " + getAbsolutePath(inputWeatherFileName) + "." ); + if (opt.isSet("-w")) { + { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); FileExists = flags.exists(); } + if ( ! FileExists ) { + DisplayString("ERROR: Could not find weather file: " + getAbsolutePath(inputWeatherFileName) + "." ); + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); + } } OutputFileDebug = GetNewUnitNumber(); diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 27927f4a1e3..9f5f7f09fce 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -90,7 +90,6 @@ AbortEnergyPlus() // SUBROUTINE PARAMETER DEFINITIONS: static gio::Fmt const fmtLD( "*" ); - static gio::Fmt const OutFmt( "('Press ENTER to continue after reading above message>')" ); static gio::Fmt const ETimeFmt( "(I2.2,'hr ',I2.2,'min ',F5.2,'sec')" ); // INTERFACE BLOCK SPECIFICATIONS From c4ed4117d165059ed8476736f2ca3243c1bde2a3 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 17 Oct 2014 15:50:57 -0600 Subject: [PATCH 39/71] Revise output directory/file name scheme. --- src/EnergyPlus/CommandLineInterface.cc | 48 +++++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index f8f47356d18..57f0f7e7950 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -140,7 +140,7 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); - opt.add("", 0, 1, 0, "Output directory path (default: current working directory)", "-d", "--output-directory"); + opt.add("", 0, 1, 0, "Output directory path (default: INPUTFILE-output)", "-d", "--output-directory"); opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--design-day"); @@ -150,7 +150,7 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Run EPMacro", "-m", "--epmacro"); - opt.add("", 0, 1, 0, "Prefix for output file names (default: same as input file name)", "-p", "--output-prefix"); + opt.add("", 0, 1, 0, "Prefix for output file names (default: ep)", "-p", "--output-prefix"); opt.add("", 0, 0, 0, "Run ReadVarsESO", "-r", "--readvars"); @@ -160,7 +160,7 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expandobjects"); - opt.example = "energyplus -w weather.epw -d output -r input.idf"; + opt.example = "energyplus -w weather.epw -r input.idf"; std::string errorFollowUp = "Type 'energyplus --help' for usage."; @@ -246,6 +246,12 @@ ProcessArgs(int argc, const char * argv[]) // Create directory if it doesn't already exist makeDirectory(dirPathName); } + else if (!legacyMode) + { + dirPathName = idfFileNameOnly + "-output" + pathChar; + // Create directory if it doesn't already exist + makeDirectory(dirPathName); + } // File naming scheme std::string outputFilePrefix; @@ -255,7 +261,7 @@ ProcessArgs(int argc, const char * argv[]) outputFilePrefix = dirPathName + prefixOutName; } else if (!legacyMode) - outputFilePrefix = dirPathName + idfFileNameOnly; + outputFilePrefix = dirPathName + "ep"; else outputFilePrefix = dirPathName + "eplus"; @@ -341,34 +347,34 @@ ProcessArgs(int argc, const char * argv[]) outputMtrFileName = outputFilePrefix + ".mtr"; outputRddFileName = outputFilePrefix + ".rdd"; outputShdFileName = outputFilePrefix + ".shd"; - outputTblCsvFileName = outputFilePrefix + "Table.csv"; - outputTblHtmFileName = outputFilePrefix + "Table.htm"; - outputTblTabFileName = outputFilePrefix + "Table.tab"; - outputTblTxtFileName = outputFilePrefix + "Table.txt"; - outputTblXmlFileName = outputFilePrefix + "Table.xml"; - outputAdsFileName = outputFilePrefix + "ADS.out"; + outputTblCsvFileName = outputFilePrefix + "-table.csv"; + outputTblHtmFileName = outputFilePrefix + "-table.htm"; + outputTblTabFileName = outputFilePrefix + "-table.tab"; + outputTblTxtFileName = outputFilePrefix + "-table.txt"; + outputTblXmlFileName = outputFilePrefix + "-table.xml"; + outputAdsFileName = outputFilePrefix + "-ads.out"; outputDfsFileName = outputFilePrefix + ".dfs"; outputDelightInFileName = "eplusout.delightin"; outputDelightOutFileName = "eplusout.delightout"; outputDelightEldmpFileName = "eplusout.delighteldmp"; outputDelightDfdmpFileName = "eplusout.delightdfdmp"; - outputMapTabFileName = outputFilePrefix + "Map.tab"; - outputMapCsvFileName = outputFilePrefix + "Map.csv"; - outputMapTxtFileName = outputFilePrefix + "Map.txt"; + outputMapTabFileName = outputFilePrefix + "-map.tab"; + outputMapCsvFileName = outputFilePrefix + "-map.csv"; + outputMapTxtFileName = outputFilePrefix + "-map.txt"; outputEddFileName = outputFilePrefix + ".edd"; outputIperrFileName = outputFilePrefix + ".iperr"; outputSlnFileName = outputFilePrefix + ".sln"; outputSciFileName = outputFilePrefix + ".sci"; outputWrlFileName = outputFilePrefix + ".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"; + 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"; outputSqlFileName = outputFilePrefix + ".sql"; - outputSqliteErrFileName = outputFilePrefix + "SQLite.err"; + outputSqliteErrFileName = outputFilePrefix + "-sqlite.err"; outputDbgFileName = outputFilePrefix + ".dbg"; EnergyPlusIniFileName = "Energy+.ini"; inStatFileName = weatherFilePathWithoutExtension + ".stat"; From b35c858014e5abd202cc7ccf8df38531a92f4960 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 29 Oct 2014 08:27:32 -0600 Subject: [PATCH 40/71] Add man page for unix distributions. --- doc/man/energyplus.1 | 83 ++++++++++++++++++++++++++ src/EnergyPlus/CommandLineInterface.cc | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 doc/man/energyplus.1 diff --git a/doc/man/energyplus.1 b/doc/man/energyplus.1 new file mode 100644 index 00000000000..37b5c35588e --- /dev/null +++ b/doc/man/energyplus.1 @@ -0,0 +1,83 @@ +.TH EnergyPlus 1 +.SH NAME +energyplus - whole building energy simulator +.SH SYNOPSIS +.B energyplus +[\f[I]options\f[]] [\f[I]input-file\f[]] +.SH DESCRIPTION +.PP +EnergyPlus is a whole building energy simulation program that engineers, architects, and +researchers use to model energy and water use in buildings. Modeling the performance of a +building with EnergyPlus enables building professionals to optimize the building design to +use less energy and water. Each version of EnergyPlus is tested extensively before +release. +.PP +EnergyPlus models heating, cooling, lighting, ventilation, other energy flows, and water +use. EnergyPlus includes many innovative simulation capabilities: time-steps less than an +hour, modular systems and plant integrated with heat balance-based zone simulation, +multizone air flow, thermal comfort, water use, natural ventilation, and photovoltaic +systems. +.SS Using EnergyPlus +.PP +The \f[I]input-file\f[] is an input definition file (IDF) or input macro file (IMF). +.PP +If \f[I]options\f[] are specified, but no \f[I]input-file\f[] is provided, the program +will look for 'in.idf' by default. +.PP +If no \f[I]options\f[] AND no \f[I]input-file\f[] are specified, EnergyPlus will default +to its old behavior (looking for 'Energy+.idd', 'in.idf', and 'in.epw' in the current +working directory and prefixing all outputs with 'eplus'). +.SH OPTIONS +.TP +.B \-a, \-\-annual +Force annual simulation +.RS +.RE +.TP +.B \-d, \-\-output\-directory \f[I]ARG\f[] +Output directory path (default: \f[I]INPUTFILE\f[]-output) +.RS +.RE +.TP +.B \-D, \-\-design-day +Force design-day-only simulation +.RS +.RE +.TP +.B \-h, \-\-help +Display help information +.RS +.RE +.TP +.B \-i, \-\-idd \f[I]ARG\f[] +Input data dictionary path (default: Energy+.idd in executable directory) +.RS +.RE +.TP +.B \-m, \-\-epmacro +Run EPMacro +.RS +.RE +.TP +.B \-p, \-\-output\-prefix \f[I]ARG\f[] +Prefix for output file names (default: ep) +.RS +.RE +.TP +.B \-r, \-\-readvars +Run ReadVarsESO +.RS +.RE +.TP +.B \-v, \-\-version +Display version information +.RS +.RE +.TP +.B \-w, \-\-weather \f[I]ARG\f[] +Weather file path (default: in.epw) +.RS +.RE +.TP +.B \-x, \-\-expandobjects +Run ExpandObjects \ No newline at end of file diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 57f0f7e7950..6e38e3ef924 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -136,7 +136,7 @@ ProcessArgs(int argc, const char * argv[]) opt.overview = VerString; - opt.syntax = "energyplus [options] [input file]"; + opt.syntax = "energyplus [options] [input-file]"; opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); From acf8594a30254e72f8504fc5615ef513416fe9e9 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 29 Oct 2014 14:38:09 -0600 Subject: [PATCH 41/71] Build IDD into Products directory (with the executable). --- CMakeLists.txt | 2 +- src/EnergyPlus/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a1175c3b9e..48d8f438278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ if( BUILD_FORTRAN ) cmake_add_fortran_subdirectory(src/ConvertESOMTR PROJECT ConvertESOMTR NO_EXTERNAL_INSTALL ) endif() -configure_file( idd/Energy+.idd.in "${CMAKE_BINARY_DIR}/Energy+.idd" ) +configure_file( idd/Energy+.idd.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Energy+.idd" ) if( BUILD_PACKAGE ) set(CPACK_INSTALL_CMAKE_PROJECTS diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 760a166bbea..99f0b596407 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -533,8 +533,8 @@ endif() if(UNIX AND NOT APPLE) ADD_CUSTOM_COMMAND(TARGET energyplus POST_BUILD - COMMAND cd \"${CMAKE_BINARY_DIR}/Products/\"\;if [ ! -f EnergyPlus ]\; then ln -s energyplus EnergyPlus\;fi - ) + COMMAND ${CMAKE_COMMAND} -E create_symlink energyplus EnergyPlus + COMMAND ${CMAKE_COMMAND} -E rename EnergyPlus "${CMAKE_BINARY_DIR}/Products/EnergyPlus") endif() INSTALL( TARGETS energyplus DESTINATION ./ ) From 13068f5cd0b7b11a6ff021cb9b8ccde507a4e97d Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 31 Oct 2014 15:24:23 -0600 Subject: [PATCH 42/71] Allow multiple short options stringed together. --- src/EnergyPlus/CommandLineInterface.cc | 41 +++++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 6e38e3ef924..09f1aa7c32e 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -102,19 +102,24 @@ ProcessArgs(int argc, const char * argv[]) bool ddSimulation; // Expand long-name options using "=" sign into two arguments + // and expand multiple short options into separate arguments std::vector arguments; - int wildCardPosition = 2; for ( int i = 0; i < argc; ++i ) { std::string inputArg( argv[ i ] ); - int beginningPosition = inputArg.find("--"); - int endingPosition = inputArg.find("="); + int doubleDashPosition = inputArg.find("--"); + int equalsPosition = inputArg.find("="); - if (beginningPosition == 0 && endingPosition != std::string::npos){ - arguments.push_back(inputArg.substr(0,endingPosition)); - arguments.push_back(inputArg.substr(endingPosition + 1,inputArg.size() - 1)); + if (doubleDashPosition == 0 && equalsPosition != std::string::npos){ + arguments.push_back(inputArg.substr(0,equalsPosition)); + arguments.push_back(inputArg.substr(equalsPosition + 1,inputArg.size() - 1)); + } + else if (inputArg.substr(0,1) == '-' && inputArg.substr(1,1) != '-' && inputArg.size() > 2){ + for (int c = 1; c < inputArg.size(); ++c){ + arguments.push_back("-" + inputArg.substr(c,1)); + } } else arguments.push_back(inputArg); @@ -215,14 +220,29 @@ ProcessArgs(int argc, const char * argv[]) if(opt.lastArgs.size() == 0) inputIdfFileName = "in.idf"; + std::vector badOptions; if(opt.lastArgs.size() > 1){ - DisplayString("ERROR: Multiple input files specified:"); + bool invalidOptionFound = false; for(int i=0; i < opt.lastArgs.size(); ++i) { std::string arg(opt.lastArgs[i]->c_str()); - DisplayString(" Input file #" + std::to_string(i+1) + ": " + arg); + if (arg.substr(0,1) == "-"){ + invalidOptionFound = true; + DisplayString("ERROR: Invalid option: " + arg); + } + } + if (invalidOptionFound){ + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); + } + else { + DisplayString("ERROR: Multiple input files specified:"); + for(int i=0; i < opt.lastArgs.size(); ++i) { + std::string arg(opt.lastArgs[i]->c_str()); + DisplayString(" Input file #" + std::to_string(i+1) + ": " + arg); + } + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } - DisplayString(errorFollowUp); - exit(EXIT_FAILURE); } idfFileNameOnly = removeFileExtension(getFileName(inputIdfFileName)); @@ -396,7 +416,6 @@ ProcessArgs(int argc, const char * argv[]) } // Handle bad options - std::vector badOptions; if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { DisplayString("ERROR: Unexpected number of arguments for option " + badOptions[i]); From fa61090c465a296a086ed61b7b11be461141050a Mon Sep 17 00:00:00 2001 From: nealkruis Date: Tue, 4 Nov 2014 15:30:35 -0700 Subject: [PATCH 43/71] Use CLI from API test. --- cmake/RunCallbackTest.cmake | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/cmake/RunCallbackTest.cmake b/cmake/RunCallbackTest.cmake index 9dbe8cbc210..314f5ef7c45 100644 --- a/cmake/RunCallbackTest.cmake +++ b/cmake/RunCallbackTest.cmake @@ -1,12 +1,6 @@ # Set up for convenience set(TEST_DIR "tst/api_callback") - set( ENV{DDONLY} y) - - # Currently the TestEnergyPlusCallbacks runner does not exit. Give it an idf and supporting files so that it will run. - execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${SOURCE_DIR}/testfiles/${IDF_FILE}" "${BINARY_DIR}/${TEST_DIR}/in.idf" ) - execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${SOURCE_DIR}/weather/${EPW_FILE}" "${BINARY_DIR}/${TEST_DIR}/in.epw" ) - execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINARY_DIR}/Energy+.idd" "${BINARY_DIR}/${TEST_DIR}/Energy+.idd" ) - + # Find and execute the test executable, passing the argument of the directory to run in if( WIN32 ) set(ECHO_CMD cmd /C echo.) @@ -14,14 +8,8 @@ set(ECHO_CMD "echo") endif() find_program(TEST_EXE TestEnergyPlusCallbacks PATHS "${BINARY_DIR}/Products/" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - execute_process(COMMAND ${ECHO_CMD} COMMAND "${TEST_EXE}" "${BINARY_DIR}/${TEST_DIR}") - - # Clean up - execute_process(COMMAND "${CMAKE_COMMAND}" -E remove "${BINARY_DIR}/${TEST_DIR}/Energy+.idd" "${BINARY_DIR}/${TEST_DIR}/in.epw" ) - - # Check the outputs and return appropriately - file(READ "${BINARY_DIR}/${TEST_DIR}/eplusout.end" FILE_CONTENT) - string(FIND "${FILE_CONTENT}" "EnergyPlus Completed Successfully" RESULT) + execute_process(COMMAND ${ECHO_CMD} COMMAND "${TEST_EXE}" -w "${SOURCE_DIR}/weather/${EPW_FILE}" -d "${BINARY_DIR}/${TEST_DIR}" -D "${SOURCE_DIR}/testfiles/${IDF_FILE}" RESULT_VARIABLE RESULT) + if( RESULT EQUAL 0 ) message("Test Passed") else() From 758ba793edcd09413634ef75d1fde17898152953 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 5 Nov 2014 13:41:18 -0700 Subject: [PATCH 44/71] Use CLI for CI simulation tests. --- cmake/ProjectMacros.cmake | 10 +- cmake/RunSimulation.cmake | 176 ++++++------------ src/EnergyPlus/CommandLineInterface.cc | 2 +- src/EnergyPlus/DataSystemVariables.cc | 11 ++ testfiles/1ZoneUncontrolled_win_1.idf | 2 +- testfiles/1ZoneUncontrolled_win_2.idf | 2 +- testfiles/5ZoneTDV.idf | 4 +- testfiles/CMakeLists.txt | 56 +++--- ...rface-functionalmockupunit-to-actuator.idf | 8 +- ...rface-functionalmockupunit-to-schedule.idf | 14 +- ...rface-functionalmockupunit-to-variable.idf | 8 +- 11 files changed, 126 insertions(+), 167 deletions(-) diff --git a/cmake/ProjectMacros.cmake b/cmake/ProjectMacros.cmake index 7a2d5870102..a0fb7c068f6 100644 --- a/cmake/ProjectMacros.cmake +++ b/cmake/ProjectMacros.cmake @@ -113,7 +113,7 @@ endmacro() function( ADD_SIMULATION_TEST ) set(options ANNUAL_SIMULATION DESIGN_DAY_ONLY EXPECT_FATAL) set(oneValueArgs IDF_FILE EPW_FILE) - set(multiValueArgs "") + set(multiValueArgs ENERGYPLUS_FLAGS) cmake_parse_arguments(ADD_SIM_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) if( DESIGN_DAY_ONLY ) @@ -124,6 +124,12 @@ function( ADD_SIMULATION_TEST ) set(ANNUAL_SIMULATION false) endif() + if(ANNUAL_SIMULATION) + set( ENERGYPLUS_FLAGS "${ADD_SIM_TEST_ENERGYPLUS_FLAGS} -a" ) + else() + set( ENERGYPLUS_FLAGS "${ADD_SIM_TEST_ENERGYPLUS_FLAGS} -D" ) + endif() + get_filename_component(IDF_NAME "${ADD_SIM_TEST_IDF_FILE}" NAME_WE) add_test(NAME "integration.${IDF_NAME}" COMMAND ${CMAKE_COMMAND} @@ -132,7 +138,7 @@ function( ADD_SIMULATION_TEST ) -DENERGYPLUS_EXE=$ -DIDF_FILE=${ADD_SIM_TEST_IDF_FILE} -DEPW_FILE=${ADD_SIM_TEST_EPW_FILE} - -DANNUAL_SIMULATION=${ANNUAL_SIMULATION} + -DENERGYPLUS_FLAGS=${ENERGYPLUS_FLAGS} -DBUILD_FORTRAN=${BUILD_FORTRAN} -P ${CMAKE_SOURCE_DIR}/cmake/RunSimulation.cmake ) diff --git a/cmake/RunSimulation.cmake b/cmake/RunSimulation.cmake index 6bb1df1dc5c..f416bc91105 100644 --- a/cmake/RunSimulation.cmake +++ b/cmake/RunSimulation.cmake @@ -5,67 +5,41 @@ # ENERGYPLUS_EXE # IDF_FILE # EPW_FILE -# ANNUAL_SIMULATION # BUILD_FORTRAN - -if(ANNUAL_SIMULATION) - set( ENV{FULLANNUALRUN} y ) -else() - set( ENV{DDONLY} y) -endif() +# ENERGYPLUS_FLAGS get_filename_component(IDF_NAME "${IDF_FILE}" NAME_WE) get_filename_component(IDF_EXT "${IDF_FILE}" EXT) +get_filename_component(EXE_PATH "${ENERGYPLUS_EXE}" PATH) +# Clean up old test directory execute_process(COMMAND "${CMAKE_COMMAND}" -E remove_directory "${BINARY_DIR}/testfiles/${IDF_NAME}" ) +execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${BINARY_DIR}/testfiles/${IDF_NAME}" ) -execute_process(COMMAND "${CMAKE_COMMAND}" -E copy - "${SOURCE_DIR}/testfiles/${IDF_FILE}" - "${BINARY_DIR}/testfiles/${IDF_NAME}/in${IDF_EXT}" ) +# Create path variables +set (OUTPUT_DIR_PATH "${BINARY_DIR}/testfiles/${IDF_NAME}/") +set (IDF_PATH "${SOURCE_DIR}/testfiles/${IDF_FILE}") +set (PRODUCT_PATH "${BINARY_DIR}/Products/") +set (EXE_PATH "${EXE_PATH}/") +set (EPW_PATH "${SOURCE_DIR}/weather/${EPW_FILE}") -execute_process(COMMAND "${CMAKE_COMMAND}" -E copy - "${SOURCE_DIR}/weather/${EPW_FILE}" - "${BINARY_DIR}/testfiles/${IDF_NAME}/in.epw" ) +# Read the file contents to check for special cases +file(READ "${IDF_PATH}" IDF_CONTENT) -execute_process(COMMAND "${CMAKE_COMMAND}" -E copy - "${BINARY_DIR}/Energy+.idd" - "${BINARY_DIR}/testfiles/${IDF_NAME}/Energy+.idd" ) +# Convert flags back to CMake list +string(STRIP ${ENERGYPLUS_FLAGS} ENERGYPLUS_FLAGS) +string(REPLACE " " ";" ENERGYPLUS_FLAGS_LIST ${ENERGYPLUS_FLAGS}) -# Read the file contents to check for special cases -file(READ "${BINARY_DIR}/testfiles/${IDF_NAME}/in${IDF_EXT}" IDF_CONTENT) - -# Handle setting up datasets files first -string( FIND "${IDF_CONTENT}" "Window5DataFile.dat" WINDOW_RESULT ) -if ( "${WINDOW_RESULT}" GREATER -1 ) - file( MAKE_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets" ) - file( COPY "${SOURCE_DIR}/datasets/Window5DataFile.dat" DESTINATION "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets" ) -endif () - -# Handle setting up TDV dataset files next -string(FIND "${IDF_CONTENT}" "TDV" TDV_RESULT) -if ( "${TDV_RESULT}" GREATER -1 ) - file( MAKE_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets" ) - file( MAKE_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets/TDV" ) - file( COPY "${SOURCE_DIR}/datasets/TDV/" DESTINATION "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets/TDV/" ) -endif () - -# Handle setting up External Interface FMU-import files next -# Note we only have FMUs for Win32 in the repo, this should be improved -string(FIND "${IDF_CONTENT}" "ExternalInterface:" EXTINT_RESULT) -if ( "${EXTINT_RESULT}" GREATER -1 ) - file( MAKE_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets" ) - file( MAKE_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets/FMUs" ) - file( COPY "${SOURCE_DIR}/datasets/FMUs/" DESTINATION "${BINARY_DIR}/testfiles/${IDF_NAME}/DataSets/FMUs/" ) -endif () - -# EPMacro should run here first -if( "${IDF_EXT}" STREQUAL ".imf" ) +# Use EPMacro if necessary +list(FIND ENERGYPLUS_FLAGS_LIST -m EPMACRO_RESULT) + +if("${EPMACRO_RESULT}" GREATER -1) # first bring in all imf files into the run folder file( GLOB SRC_IMF_FILES "${SOURCE_DIR}/testfiles/*.imf" ) foreach( IMF_FILE ${SRC_IMF_FILES} ) - file( COPY "${IMF_FILE}" DESTINATION "${BINARY_DIR}/testfiles/${IDF_NAME}/" ) + file( COPY "${IMF_FILE}" DESTINATION "${OUTPUT_DIR_PATH}" ) endforeach() - # find the appropriate macro file + # find the appropriate executable file if( UNIX AND NOT APPLE ) find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Linux" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -76,87 +50,63 @@ if( "${IDF_EXT}" STREQUAL ".imf" ) find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Windows" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) endif() - # execute EPMacro and rename the idf file - message("Executing EPMacro from ${EPMACRO_EXE}") - execute_process(COMMAND "${EPMACRO_EXE}" WORKING_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}") - file(RENAME "${BINARY_DIR}/testfiles/${IDF_NAME}/out.idf" "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf") + # Move EPMacro to executable directory + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EPMACRO_EXE}" "${EXE_PATH}") endif() - if(BUILD_FORTRAN) # Parametric preprocessor next string(FIND "${IDF_CONTENT}" "Parametric:" PAR_RESULT) if ( "${PAR_RESULT}" GREATER -1 ) - find_program(PARAMETRIC_EXE parametricpreprocessor PATHS "${BINARY_DIR}/Products/" + find_program(PARAMETRIC_EXE parametricpreprocessor PATHS "${PRODUCT_PATH}" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - message("Executing ParametricPreprocessor from ${PARAMETRIC_EXE}") - execute_process(COMMAND "${PARAMETRIC_EXE}" "in.idf" WORKING_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${IDF_PATH}" "${OUTPUT_DIR_PATH}") + execute_process(COMMAND "${PARAMETRIC_EXE}" "${IDF_FILE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") # this handles the LBuildingAppGRotPar parametric file - if (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/in-G000.idf") - message("Parametric: Trying to run: in-G000.idf") - FILE( RENAME "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf" "${BINARY_DIR}/testfiles/${IDF_NAME}/in-original.idf" ) - FILE( RENAME "${BINARY_DIR}/testfiles/${IDF_NAME}/in-G000.idf" "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf" ) + if (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-G000.idf") + set (IDF_PATH "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-G000.idf") # this handles the LBuildingAppGRotPar and ParametricInsulation-5ZoneAirCooled parametric files - elseif (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/in-000001.idf") - message("Parametric: Trying to run: in-000001.idf") - FILE( RENAME "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf" "${BINARY_DIR}/testfiles/${IDF_NAME}/in-original.idf" ) - FILE( RENAME "${BINARY_DIR}/testfiles/${IDF_NAME}/in-000001.idf" "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf" ) + elseif (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-000001.idf") + set (IDF_PATH "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-000001.idf") # this shouldn't happen unless a new parametric file is added with a different processed filename else () - message("Couldn't find parametric preprocessor output file, attempting to continue with original in.idf") + message("Couldn't find parametric preprocessor output file for ${IDF_NAME}, attempting to continue with original input file.") endif () endif () # parametric preprocessor definitions detected - - # ExpandObjects (and other preprocessors) as necessary - find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${BINARY_DIR}/Products/" - NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - message("Executing ExpandObjects from ${EXPANDOBJECTS_EXE}") - execute_process(COMMAND "${EXPANDOBJECTS_EXE}" WORKING_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}") - - if (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/expanded.idf") - # Copy the expanded idf into in.idf, which could be updated with ground stuff as well - if (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf") - file(REMOVE "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf") - endif() - file(RENAME "${BINARY_DIR}/testfiles/${IDF_NAME}/expanded.idf" "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf") - - # i f we have an expanded.idf, then ExpandObjects must have found something - # it is possible this includes ground heat transfer objects, so run them here if needed - # Need to copy in Slab/Basement IDDs before ExpandObjects if relevant for this file - string(FIND "${IDF_CONTENT}" "GroundHeatTransfer:Slab" SLAB_RESULT) - if ( "${SLAB_RESULT}" GREATER -1 ) - file ( COPY "${SOURCE_DIR}/idd/SlabGHT.idd" DESTINATION "${BINARY_DIR}/testfiles/${IDF_NAME}/" ) - # Find and run slab - find_program(SLAB_EXE Slab PATHS "${BINARY_DIR}/Products/" - NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - message("Executing Slab from ${SLAB_EXE}") - execute_process(COMMAND "${SLAB_EXE}" WORKING_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}") - # Then copy slab results into the expanded file - file(READ "${BINARY_DIR}/testfiles/${IDF_NAME}/SLABSurfaceTemps.TXT" SLAB_CONTENTS) - file(APPEND "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf" "${SLAB_CONTENTS}") - endif () + list(FIND ENERGYPLUS_FLAGS_LIST -x EXPAND_RESULT) + + if("${EXPAND_RESULT}" GREATER -1) + find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${PRODUCT_PATH}" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + # Move to executable directory + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EXPANDOBJECTS_EXE}" "${EXE_PATH}") - string(FIND "${IDF_CONTENT}" "GroundHeatTransfer:Basement" BASEMENT_RESULT) - if ( "${BASEMENT_RESULT}" GREATER -1 ) - file ( COPY "${SOURCE_DIR}/idd/BasementGHT.idd" DESTINATION "${BINARY_DIR}/testfiles/${IDF_NAME}/" ) - # Find and run basement - find_program(BASEMENT_EXE Basement PATHS "${BINARY_DIR}/Products/" - NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - message("Executing Basement from ${BASEMENT_EXE}") - execute_process(COMMAND "${BASEMENT_EXE}" WORKING_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}") - # Then copy basement results into the expanded file - file(READ "${BINARY_DIR}/testfiles/${IDF_NAME}/EPObjects.TXT" BASEMENT_CONTENTS) - file(APPEND "${BINARY_DIR}/testfiles/${IDF_NAME}/in.idf" "${BASEMENT_CONTENTS}") - endif () + find_program(BASEMENT_EXE Basement PATHS "${PRODUCT_PATH}" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + # Move Basement to executable directory + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${BASEMENT_EXE}" "${EXE_PATH}") + + find_program(SLAB_EXE Slab PATHS "${PRODUCT_PATH}" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + # Move Slab to executable directory + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SLAB_EXE}" "${EXE_PATH}") + endif() + + list(FIND ENERGYPLUS_FLAGS_LIST -r READVARS_RESULT) - endif() # expand objects found something and created expanded.idf + if("${READVARS_RESULT}" GREATER -1) + find_program(READVARS_EXE ReadVarsESO PATHS "${PRODUCT_PATH}" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + # Move to executable directory + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${READVARS_EXE}" "${EXE_PATH}") + endif() endif() # build fortran @@ -167,18 +117,10 @@ else() set(ECHO_CMD "echo") endif() - execute_process(COMMAND ${ECHO_CMD} - COMMAND "${ENERGYPLUS_EXE}" WORKING_DIRECTORY "${BINARY_DIR}/testfiles/${IDF_NAME}") - - -execute_process(COMMAND "${CMAKE_COMMAND}" -E remove - "${BINARY_DIR}/testfiles/${IDF_NAME}/Energy+.idd" - "${BINARY_DIR}/testfiles/${IDF_NAME}/in.epw" ) - -file(READ "${BINARY_DIR}/testfiles/${IDF_NAME}/eplusout.end" FILE_CONTENT) - -string(FIND "${FILE_CONTENT}" "EnergyPlus Completed Successfully" RESULT) + COMMAND "${ENERGYPLUS_EXE}" -w "${EPW_PATH}" -d "${OUTPUT_DIR_PATH}" ${ENERGYPLUS_FLAGS_LIST} "${IDF_PATH}" + WORKING_DIRECTORY "${OUTPUT_DIR_PATH}" + RESULT_VARIABLE RESULT) if( RESULT EQUAL 0 ) message("Test Passed") diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 09f1aa7c32e..0d87260b878 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -499,7 +499,7 @@ ProcessArgs(int argc, const char * argv[]) exit(EXIT_FAILURE); } - if (opt.isSet("-w")) { + if (opt.isSet("-w") && !DDOnlySimulation) { { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); FileExists = flags.exists(); } if ( ! FileExists ) { DisplayString("ERROR: Could not find weather file: " + getAbsolutePath(inputWeatherFileName) + "." ); diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index d5a5557f10b..234f217bff8 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -216,6 +216,17 @@ namespace DataSystemVariables { gio::write( EchoInputFile, fmtA ) << "not found (user input)=" + InputFileName; } + // Look relative to input file path + { IOFlags flags; gio::inquire( idfDirPathName + InputFileName, flags ); FileExist = flags.exists(); } + if ( FileExist ) { + FileFound = true; + CheckedFileName = idfDirPathName + InputFileName; + gio::write( EchoInputFile, fmtA ) << "found (idf)=" + CheckedFileName; + return; + } else { + gio::write( EchoInputFile, fmtA ) << "not found (idf)=" + idfDirPathName + InputFileName; + } + // Look relative to input path { IOFlags flags; gio::inquire( envinputpath1 + InputFileName, flags ); FileExist = flags.exists(); } if ( FileExist ) { diff --git a/testfiles/1ZoneUncontrolled_win_1.idf b/testfiles/1ZoneUncontrolled_win_1.idf index 174b8619e0c..5529bb2cc70 100644 --- a/testfiles/1ZoneUncontrolled_win_1.idf +++ b/testfiles/1ZoneUncontrolled_win_1.idf @@ -240,7 +240,7 @@ Construction:WindowDataFile, DoubleClear, !- Name - DataSets\Window5DataFile.dat; !- File Name + ..\datasets\Window5DataFile.dat; !- File Name Site:GroundTemperature:BuildingSurface,18.89,18.92,19.02,19.12,19.21,19.23,19.07,19.32,19.09,19.21,19.13,18.96; diff --git a/testfiles/1ZoneUncontrolled_win_2.idf b/testfiles/1ZoneUncontrolled_win_2.idf index fa16488820a..84c9c9c519a 100644 --- a/testfiles/1ZoneUncontrolled_win_2.idf +++ b/testfiles/1ZoneUncontrolled_win_2.idf @@ -240,7 +240,7 @@ Construction:WindowDataFile, DoubleClear, !- Name - DataSets\Window5DataFile.dat; !- File Name + ..\datasets\Window5DataFile.dat; !- File Name Site:GroundTemperature:BuildingSurface,18.89,18.92,19.02,19.12,19.21,19.23,19.07,19.32,19.09,19.21,19.13,18.96; diff --git a/testfiles/5ZoneTDV.idf b/testfiles/5ZoneTDV.idf index 8587f6259d0..067b35dbc5a 100644 --- a/testfiles/5ZoneTDV.idf +++ b/testfiles/5ZoneTDV.idf @@ -3234,7 +3234,7 @@ Schedule:File, elecTDVfromCZ06com, !- Name Any Number, !- Schedule Type Limits Name - DataSets\TDV\TDV_2008_kBtu_CTZ06.csv, !- File Name + ..\datasets\TDV\TDV_2008_kBtu_CTZ06.csv, !- File Name 1, !- Column Number 4, !- Rows to Skip at Top , !- Number of Hours of Data @@ -3245,7 +3245,7 @@ Schedule:File, natgasTDVfromCZ06com, !- Name Any Number, !- Schedule Type Limits Name - DataSets\TDV\TDV_2008_kBtu_CTZ06.csv, !- File Name + ..\datasets\TDV\TDV_2008_kBtu_CTZ06.csv, !- File Name 3, !- Column Number 4; !- Rows to Skip at Top diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 75c7902783d..a68f333749f 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -466,7 +466,7 @@ ADD_SIMULATION_TEST(IDF_FILE _VAVSingleDuctConstFlowBoiler_otherfuel.idf EPW_FIL ADD_SIMULATION_TEST(IDF_FILE gasAbsorptionChillerHeater.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) # Macro files -ADD_SIMULATION_TEST(IDF_FILE AbsorptionChiller_Macro.imf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) +ADD_SIMULATION_TEST(IDF_FILE AbsorptionChiller_Macro.imf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -m) # External interface files -- note we only have Windows 32-bit FMUs if ( MSVC AND ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") ) @@ -477,35 +477,35 @@ endif () IF (BUILD_FORTRAN) # ExpandObjects dependent files - ADD_SIMULATION_TEST(IDF_FILE HAMT_DailyProfileReport.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HAMT_HourlyProfileReport.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneBaseboardHeat.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneConstantVolumeChillerBoiler.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneDualDuct.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneFanCoil-DOAS.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneFanCoil.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneFurnaceDX.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePTAC-DOAS.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePTAC.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePTHP.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePackagedVAV.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePurchAir.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneUnitaryHeatPump.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneUnitarySystem.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVAVFanPowered.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVAVWaterCooled-ObjectReference.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVAVWaterCooled.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVRF.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneWaterToAirHeatPumpTowerBoiler.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE LBuilding-G000.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE LBuilding-G090.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE LBuilding-G180.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE LBuilding-G270.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) + ADD_SIMULATION_TEST(IDF_FILE HAMT_DailyProfileReport.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HAMT_HourlyProfileReport.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneBaseboardHeat.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x -r) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneConstantVolumeChillerBoiler.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneDualDuct.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneFanCoil-DOAS.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneFanCoil.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneFurnaceDX.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePTAC-DOAS.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePTAC.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePTHP.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePackagedVAV.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZonePurchAir.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneUnitaryHeatPump.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneUnitarySystem.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVAVFanPowered.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVAVWaterCooled-ObjectReference.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVAVWaterCooled.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneVRF.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE HVACTemplate-5ZoneWaterToAirHeatPumpTowerBoiler.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE LBuilding-G000.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE LBuilding-G090.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE LBuilding-G180.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE LBuilding-G270.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) # Parametric preprocessor dependent files - ADD_SIMULATION_TEST(IDF_FILE LBuildingAppGRotPar.idf EPW_FILE USA_FL_Miami.Intl.AP.722020_TMY3.epw) + ADD_SIMULATION_TEST(IDF_FILE LBuildingAppGRotPar.idf EPW_FILE USA_FL_Miami.Intl.AP.722020_TMY3.epw ENERGYPLUS_FLAGS -x) ADD_SIMULATION_TEST(IDF_FILE 1ZoneParameterAspect.idf EPW_FILE USA_CO_Golden-NREL.724666_TMY3.epw) ADD_SIMULATION_TEST(IDF_FILE ParametricInsulation-5ZoneAirCooled.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) # Basement/slab dependent files - ADD_SIMULATION_TEST(IDF_FILE 5ZoneAirCooledWithSlab.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) - ADD_SIMULATION_TEST(IDF_FILE LgOffVAVusingBasement.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) + ADD_SIMULATION_TEST(IDF_FILE 5ZoneAirCooledWithSlab.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE LgOffVAVusingBasement.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) ENDIF () diff --git a/testfiles/_ExternalInterface-functionalmockupunit-to-actuator.idf b/testfiles/_ExternalInterface-functionalmockupunit-to-actuator.idf index de422c68097..95b5caf74ce 100644 --- a/testfiles/_ExternalInterface-functionalmockupunit-to-actuator.idf +++ b/testfiles/_ExternalInterface-functionalmockupunit-to-actuator.idf @@ -1329,21 +1329,21 @@ FunctionalMockupUnitImport; !- Name of External Interface ExternalInterface:FunctionalMockupUnitImport, - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name 15, !- FMU Timeout {ms} 0; !- FMU LoggingOn ExternalInterface:FunctionalMockupUnitImport:From:Variable, Zn001:Wall001:Win001, !- Output:Variable Index Key Name Surface Outside Face Incident Solar Radiation Rate per Area, !- Output:Variable Name - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name Model1, !- FMU Instance Name ISolExt; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:From:Variable, WEST ZONE, !- Output:Variable Index Key Name Zone Mean Air Temperature, !- Output:Variable Name - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name Model1, !- FMU Instance Name TRoo; !- FMU Variable Name @@ -1352,7 +1352,7 @@ Zn001:Wall001:Win001, !- Actuated Component Unique Name Window Shading Control, !- Actuated Component Type Control Status, !- Actuated Component Control Type - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name Model1, !- FMU Instance Name yShade, !- FMU Variable Name 6; !- Initial Value diff --git a/testfiles/_ExternalInterface-functionalmockupunit-to-schedule.idf b/testfiles/_ExternalInterface-functionalmockupunit-to-schedule.idf index a67c949f5b9..fb8d7779edc 100644 --- a/testfiles/_ExternalInterface-functionalmockupunit-to-schedule.idf +++ b/testfiles/_ExternalInterface-functionalmockupunit-to-schedule.idf @@ -1196,42 +1196,42 @@ FunctionalMockupUnitImport; !- Name of External Interface ExternalInterface:FunctionalMockupUnitImport, - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name 15, !- FMU Timeout {ms} 0; !- FMU LoggingOn ExternalInterface:FunctionalMockupUnitImport:From:Variable, Environment, !- Output:Variable Index Key Name Site Outdoor Air Drybulb Temperature, !- Output:Variable Name - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name Model1, !- FMU Instance Name TDryBul; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:From:Variable, ZONE ONE, !- Output:Variable Index Key Name Zone Mean Air Temperature, !- Output:Variable Name - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name Model1, !- FMU Instance Name TRooMea; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:From:Variable, Environment, !- Output:Variable Index Key Name Site Outdoor Air Relative Humidity, !- Output:Variable Name - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name Model1, !- FMU Instance Name outRelHum; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:From:Variable, ZONE ONE, !- Output:Variable Index Key Name Zone Air Relative Humidity, !- Output:Variable Name - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name Model1, !- FMU Instance Name rooRelHum; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:To:Schedule, FMU_OthEquSen_ZoneOne, !- Name Any Number, !- Schedule Type Limits Names - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name Model1, !- FMU Instance Name QSensible, !- FMU Variable Name 0; !- Initial Value @@ -1239,7 +1239,7 @@ ExternalInterface:FunctionalMockupUnitImport:To:Schedule, FMU_OthEquLat_ZoneOne, !- Name Any Number, !- Schedule Type Limits Names - DataSets\FMUs\MoistAir.fmu, !- FMU File Name + ..\datasets\FMUs\MoistAir.fmu, !- FMU File Name Model1, !- FMU Instance Name QLatent, !- FMU Variable Name 0; !- Initial Value diff --git a/testfiles/_ExternalInterface-functionalmockupunit-to-variable.idf b/testfiles/_ExternalInterface-functionalmockupunit-to-variable.idf index 0e6248b9658..8c7bb6ea4b7 100644 --- a/testfiles/_ExternalInterface-functionalmockupunit-to-variable.idf +++ b/testfiles/_ExternalInterface-functionalmockupunit-to-variable.idf @@ -1332,27 +1332,27 @@ FunctionalMockupUnitImport; !- Name of External Interface ExternalInterface:FunctionalMockupUnitImport, - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name 15, !- FMU Timeout {ms} 0; !- FMU LoggingOn ExternalInterface:FunctionalMockupUnitImport:From:Variable, Zn001:Wall001:Win001, !- Output:Variable Index Key Name Surface Outside Face Incident Solar Radiation Rate per Area, !- Output:Variable Name - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name Model1, !- FMU Instance Name ISolExt; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:From:Variable, WEST ZONE, !- Output:Variable Index Key Name Zone Mean Air Temperature, !- Output:Variable Name - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name Model1, !- FMU Instance Name TRoo; !- FMU Variable Name ExternalInterface:FunctionalMockupUnitImport:To:Variable, Shade_Signal, !- Name - DataSets\FMUs\ShadingController.fmu, !- FMU File Name + ..\datasets\FMUs\ShadingController.fmu, !- FMU File Name Model1, !- FMU Instance Name yShade, !- FMU Variable Name 1; !- Initial Value From 9e7dd47bdbdeb5cdb0a8e51b4616c8e260b5700e Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 5 Nov 2014 13:55:22 -0700 Subject: [PATCH 45/71] Fix call to ExpandObjects when no file is created. --- src/EnergyPlus/CommandLineInterface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 0d87260b878..70da7699240 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -549,8 +549,11 @@ ProcessArgs(int argc, const char * argv[]) if (!iddFileNamedEnergy) removeFile("Energy+.idd"); moveFile("expandedidf.err", outputExperrFileName); - moveFile("expanded.idf", outputExpidfFileName); - inputIdfFileName = outputExpidfFileName; + { IOFlags flags; gio::inquire( "expanded.idf", flags ); FileExists = flags.exists(); } + if (FileExists){ + moveFile("expanded.idf", outputExpidfFileName); + inputIdfFileName = outputExpidfFileName; + } } From 1afd59c58a8d91068084cf0bd03c74d293215155 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 5 Nov 2014 14:56:54 -0700 Subject: [PATCH 46/71] Make GHT pre-processor tests work with CLI tests. --- cmake/RunSimulation.cmake | 60 ++++++++++++++++++++++++++++++--------- testfiles/CMakeLists.txt | 4 +-- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/cmake/RunSimulation.cmake b/cmake/RunSimulation.cmake index f416bc91105..7aa9c0cf269 100644 --- a/cmake/RunSimulation.cmake +++ b/cmake/RunSimulation.cmake @@ -65,12 +65,12 @@ if(BUILD_FORTRAN) execute_process(COMMAND "${PARAMETRIC_EXE}" "${IDF_FILE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") # this handles the LBuildingAppGRotPar parametric file - if (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-G000.idf") - set (IDF_PATH "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-G000.idf") + if (EXISTS "${OUTPUT_DIR_PATH}/${IDF_NAME}-G000.idf") + set (IDF_PATH "${OUTPUT_DIR_PATH}/${IDF_NAME}-G000.idf") # this handles the LBuildingAppGRotPar and ParametricInsulation-5ZoneAirCooled parametric files - elseif (EXISTS "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-000001.idf") - set (IDF_PATH "${BINARY_DIR}/testfiles/${IDF_NAME}/${IDF_NAME}-000001.idf") + elseif (EXISTS "${OUTPUT_DIR_PATH}/${IDF_NAME}-000001.idf") + set (IDF_PATH "${OUTPUT_DIR_PATH}/${IDF_NAME}-000001.idf") # this shouldn't happen unless a new parametric file is added with a different processed filename else () @@ -80,6 +80,48 @@ if(BUILD_FORTRAN) endif () # parametric preprocessor definitions detected + # Run ExpandObjects independently if there are ground heat transfer objects + string(FIND "${IDF_CONTENT}" "GroundHeatTransfer:Slab" SLAB_RESULT) + string(FIND "${IDF_CONTENT}" "GroundHeatTransfer:Basement" BASEMENT_RESULT) + + if ( "${SLAB_RESULT}" GREATER -1 OR "${BASEMENT_RESULT}" GREATER -1) + find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${BINARY_DIR}/Products/" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + message("Executing ExpandObjects from ${EXPANDOBJECTS_EXE}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${IDF_PATH}" "${OUTPUT_DIR_PATH}/in.idf") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${EPW_PATH}" "${OUTPUT_DIR_PATH}/in.epw") + execute_process(COMMAND "${EXPANDOBJECTS_EXE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") + + if ( "${SLAB_RESULT}" GREATER -1) + # Copy files needed for Slab + file ( COPY "${SOURCE_DIR}/idd/SlabGHT.idd" DESTINATION "${OUTPUT_DIR_PATH}" ) + # Find and run slab + find_program(SLAB_EXE Slab PATHS "${PRODUCT_PATH}" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + message("Executing Slab from ${SLAB_EXE}") + execute_process(COMMAND "${SLAB_EXE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") + # Then copy slab results into the expanded file + file(READ "${OUTPUT_DIR_PATH}/SLABSurfaceTemps.TXT" SLAB_CONTENTS) + file(APPEND "${OUTPUT_DIR_PATH}/expanded.idf" "${SLAB_CONTENTS}") + endif() + + if ( "${BASEMENT_RESULT}" GREATER -1) + # Copy files needed for Basement + file ( COPY "${SOURCE_DIR}/idd/BasementGHT.idd" DESTINATION "${OUTPUT_DIR_PATH}" ) + # Find and run basement + find_program(BASEMENT_EXE Basement PATHS "${PRODUCT_PATH}" + NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) + message("Executing Basement from ${BASEMENT_EXE}") + execute_process(COMMAND "${BASEMENT_EXE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") + # Then copy basement results into the expanded file + file(READ "${OUTPUT_DIR_PATH}/EPObjects.TXT" BASEMENT_CONTENTS) + file(APPEND "${OUTPUT_DIR_PATH}/expanded.idf" "${BASEMENT_CONTENTS}") + endif() + + set (IDF_PATH "${OUTPUT_DIR_PATH}/expanded.idf") + + endif() # expand objects found something and created expanded.idf + list(FIND ENERGYPLUS_FLAGS_LIST -x EXPAND_RESULT) if("${EXPAND_RESULT}" GREATER -1) @@ -87,16 +129,6 @@ if(BUILD_FORTRAN) NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) # Move to executable directory execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EXPANDOBJECTS_EXE}" "${EXE_PATH}") - - find_program(BASEMENT_EXE Basement PATHS "${PRODUCT_PATH}" - NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - # Move Basement to executable directory - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${BASEMENT_EXE}" "${EXE_PATH}") - - find_program(SLAB_EXE Slab PATHS "${PRODUCT_PATH}" - NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - # Move Slab to executable directory - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SLAB_EXE}" "${EXE_PATH}") endif() list(FIND ENERGYPLUS_FLAGS_LIST -r READVARS_RESULT) diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index a68f333749f..999dd455c9f 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -506,6 +506,6 @@ IF (BUILD_FORTRAN) ADD_SIMULATION_TEST(IDF_FILE 1ZoneParameterAspect.idf EPW_FILE USA_CO_Golden-NREL.724666_TMY3.epw) ADD_SIMULATION_TEST(IDF_FILE ParametricInsulation-5ZoneAirCooled.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) # Basement/slab dependent files - ADD_SIMULATION_TEST(IDF_FILE 5ZoneAirCooledWithSlab.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) - ADD_SIMULATION_TEST(IDF_FILE LgOffVAVusingBasement.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x) + ADD_SIMULATION_TEST(IDF_FILE 5ZoneAirCooledWithSlab.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) + ADD_SIMULATION_TEST(IDF_FILE LgOffVAVusingBasement.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) ENDIF () From 0af89f14ed387ade26003e7708534bcb04bfccd0 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 5 Nov 2014 15:29:31 -0700 Subject: [PATCH 47/71] Fix Linux warnings. --- src/EnergyPlus/FileSystem.cc | 10 +- src/EnergyPlus/FileSystem.hh | 2 +- third_party/CLI/ezOptionParser.hpp | 176 ++++++++++++++--------------- 3 files changed, 94 insertions(+), 94 deletions(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 1153caed505..2dd92e22ec7 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -50,7 +50,7 @@ getAbsolutePath( std::string const& filePath ) #ifdef _WIN32 GetFullPathName(filePath.c_str(), sizeof(absolutePath), absolutePath, NULL); #else - realpath(filePath.c_str(), absolutePath); + char *result = realpath(filePath.c_str(), absolutePath); #endif return std::string(absolutePath); } @@ -64,7 +64,7 @@ getProgramPath() uint32_t pathSize = sizeof(executableRelativePath); _NSGetExecutablePath(executableRelativePath, &pathSize); #elif __linux__ - readlink("/proc/self/exe", executableRelativePath, sizeof(executableRelativePath)-1); + ssize_t len = readlink("/proc/self/exe", executableRelativePath, sizeof(executableRelativePath)-1); #elif _WIN32 GetModuleFileName(NULL, executableRelativePath, sizeof(executableRelativePath)); #endif @@ -110,10 +110,10 @@ moveFile(std::string filePath, std::string destination){ rename(filePath.c_str(), destination.c_str()); } -void +int systemCall(std::string command) { - system(command.c_str()); + return system(command.c_str()); } void @@ -128,7 +128,7 @@ linkFile(std::string fileName, std::string link) #ifdef _WIN32 CopyFile(fileName.c_str(), link.c_str(), false); #else - symlink(fileName.c_str(), link.c_str()); + int status = symlink(fileName.c_str(), link.c_str()); #endif } diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index 5c3a520eed7..b46d3a8a624 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -28,7 +28,7 @@ makeDirectory(std::string directoryName); void moveFile(std::string filePath, std::string destination); -void +int systemCall(std::string command); void diff --git a/third_party/CLI/ezOptionParser.hpp b/third_party/CLI/ezOptionParser.hpp index 97aaea59d01..9d360b7adb8 100644 --- a/third_party/CLI/ezOptionParser.hpp +++ b/third_party/CLI/ezOptionParser.hpp @@ -41,14 +41,14 @@ static T fromString(const std::string* s) { T t; stream >> t; return t; -}; +} template static T fromString(const char* s) { std::istringstream stream (s); T t; stream >> t; return t; -}; +} /* ################################################################### */ static inline bool isdigit(const std::string & s, int i=0) { int n = s.length(); @@ -61,7 +61,7 @@ static inline bool isdigit(const std::string & s, int i=0) { } return true; -}; +} /* ################################################################### */ static bool isdigit(const std::string * s, int i=0) { int n = s->length(); @@ -74,7 +74,7 @@ static bool isdigit(const std::string * s, int i=0) { } return true; -}; +} /* ################################################################### */ /* Compare strings for opts, so short opt flags come before long format flags. @@ -117,7 +117,7 @@ static bool CmpOptStringPtr(std::string * s1, std::string * s2) { return true; return (s1->compare(*s2)<0); -}; +} /* ################################################################### */ /* Makes a vector of strings from one string, @@ -135,7 +135,7 @@ static void SplitDelim( const std::string& s, const char token, std::vectorpush_back(newstr); j = i; } -}; +} /* ################################################################### */ // Variant that uses deep copies and references instead of pointers (less efficient). static void SplitDelim( const std::string& s, const char token, std::vector & result) { @@ -150,7 +150,7 @@ static void SplitDelim( const std::string& s, const char token, std::vector & result) { @@ -165,135 +165,135 @@ static void SplitDelim( const std::string& s, const char token, std::listc_str()); } -}; +} /* ################################################################### */ static void ToS1(std::string ** strings, char * out, int n) { for(int i=0; i < n; ++i) { out[i] = (char)atoi(strings[i]->c_str()); } -}; +} /* ################################################################### */ static void ToU2(std::string ** strings, unsigned short * out, int n) { for(int i=0; i < n; ++i) { out[i] = (unsigned short)atoi(strings[i]->c_str()); } -}; +} /* ################################################################### */ static void ToS2(std::string ** strings, short * out, int n) { for(int i=0; i < n; ++i) { out[i] = (short)atoi(strings[i]->c_str()); } -}; +} /* ################################################################### */ static void ToS4(std::string ** strings, int * out, int n) { for(int i=0; i < n; ++i) { out[i] = atoi(strings[i]->c_str()); } -}; +} /* ################################################################### */ static void ToU4(std::string ** strings, unsigned int * out, int n) { for(int i=0; i < n; ++i) { out[i] = (unsigned int)strtoul(strings[i]->c_str(), NULL, 0); } -}; +} /* ################################################################### */ static void ToS8(std::string ** strings, long long * out, int n) { for(int i=0; i < n; ++i) { std::stringstream ss(strings[i]->c_str()); ss >> out[i]; } -}; +} /* ################################################################### */ static void ToU8(std::string ** strings, unsigned long long * out, int n) { for(int i=0; i < n; ++i) { std::stringstream ss(strings[i]->c_str()); ss >> out[i]; } -}; +} /* ################################################################### */ static void ToF(std::string ** strings, float * out, int n) { for(int i=0; i < n; ++i) { out[i] = (float)atof(strings[i]->c_str()); } -}; +} /* ################################################################### */ static void ToD(std::string ** strings, double * out, int n) { for(int i=0; i < n; ++i) { out[i] = (double)atof(strings[i]->c_str()); } -}; +} /* ################################################################### */ static void StringsToInts(std::vector & strings, std::vector & out) { for(int i=0; i < (long int)strings.size(); ++i) { out.push_back(atoi(strings[i].c_str())); } -}; +} /* ################################################################### */ static void StringsToInts(std::vector * strings, std::vector * out) { for(int i=0; i < (long int)strings->size(); ++i) { out->push_back(atoi(strings->at(i)->c_str())); } -}; +} /* ################################################################### */ static void StringsToLongs(std::vector & strings, std::vector & out) { for(int i=0; i < (long int)strings.size(); ++i) { out.push_back(atol(strings[i].c_str())); } -}; +} /* ################################################################### */ static void StringsToLongs(std::vector * strings, std::vector * out) { for(int i=0; i < (long int)strings->size(); ++i) { out->push_back(atol(strings->at(i)->c_str())); } -}; +} /* ################################################################### */ static void StringsToULongs(std::vector & strings, std::vector & out) { for(int i=0; i < (long int)strings.size(); ++i) { out.push_back(strtoul(strings[i].c_str(),0,0)); } -}; +} /* ################################################################### */ static void StringsToULongs(std::vector * strings, std::vector * out) { for(int i=0; i < (long int)strings->size(); ++i) { out->push_back(strtoul(strings->at(i)->c_str(),0,0)); } -}; +} /* ################################################################### */ static void StringsToFloats(std::vector & strings, std::vector & out) { for(int i=0; i < (long int)strings.size(); ++i) { out.push_back(atof(strings[i].c_str())); } -}; +} /* ################################################################### */ static void StringsToFloats(std::vector * strings, std::vector * out) { for(int i=0; i < (long int)strings->size(); ++i) { out->push_back(atof(strings->at(i)->c_str())); } -}; +} /* ################################################################### */ static void StringsToDoubles(std::vector & strings, std::vector & out) { for(int i=0; i < (long int)strings.size(); ++i) { out.push_back(atof(strings[i].c_str())); } -}; +} /* ################################################################### */ static void StringsToDoubles(std::vector * strings, std::vector * out) { for(int i=0; i < (long int)strings->size(); ++i) { out->push_back(atof(strings->at(i)->c_str())); } -}; +} /* ################################################################### */ static void StringsToStrings(std::vector * strings, std::vector * out) { for(int i=0; i < (long int)strings->size(); ++i) { out->push_back( *strings->at(i) ); } -}; +} /* ################################################################### */ static void ToLowerASCII(std::string & s) { int n = s.size(); @@ -385,7 +385,7 @@ static char** CommandLineToArgvA(char* CmdLine, int* _argc) { (*_argc) = argc; return argv; -}; +} /* ################################################################### */ // Create unique ids with static and still allow single header that avoids multiple definitions linker error. class ezOptionParserIDGenerator { @@ -454,7 +454,7 @@ class ezOptionValidator { float *f; double *d; std::string** t; - }; + }; char op; bool quiet; @@ -466,7 +466,7 @@ class ezOptionValidator { /* ------------------------------------------------------------------- */ ezOptionValidator::~ezOptionValidator() { reset(); -}; +} /* ------------------------------------------------------------------- */ void ezOptionValidator::reset() { #define CLEAR(TYPE,P) case TYPE: if (P) delete [] P; P = 0; break; @@ -494,71 +494,71 @@ void ezOptionValidator::reset() { size = 0; op = NOOP; type = NOTYPE; -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type) : s1(0), op(0), quiet(0), type(_type), size(0), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const char* list, int _size) : s1(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); s1 = new char[size]; memcpy(s1, list, size); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned char* list, int _size) : u1(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); u1 = new unsigned char[size]; memcpy(u1, list, size); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const short* list, int _size) : s2(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); s2 = new short[size]; memcpy(s2, list, size*sizeof(short)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned short* list, int _size) : u2(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); u2 = new unsigned short[size]; memcpy(u2, list, size*sizeof(unsigned short)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const int* list, int _size) : s4(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); s4 = new int[size]; memcpy(s4, list, size*sizeof(int)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned int* list, int _size) : u4(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); u4 = new unsigned int[size]; memcpy(u4, list, size*sizeof(unsigned int)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const long long* list, int _size) : s8(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); s8 = new long long[size]; memcpy(s8, list, size*sizeof(long long)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const unsigned long long* list, int _size) : u8(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); u8 = new unsigned long long[size]; memcpy(u8, list, size*sizeof(unsigned long long)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const float* list, int _size) : f(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); f = new float[size]; memcpy(f, list, size*sizeof(float)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const double* list, int _size) : d(0), op(_op), quiet(0), type(_type), size(_size), insensitive(0) { id = ezOptionParserIDGenerator::instance().next(); d = new double[size]; memcpy(d, list, size*sizeof(double)); -}; +} /* ------------------------------------------------------------------- */ ezOptionValidator::ezOptionValidator(char _type, char _op, const char** list, int _size, bool _insensitive) : t(0), op(_op), quiet(0), type(_type), size(_size), insensitive(_insensitive) { id = ezOptionParserIDGenerator::instance().next(); @@ -568,7 +568,7 @@ ezOptionValidator::ezOptionValidator(char _type, char _op, const char** list, in for(; i < size; ++i) { t[i] = new std::string(list[i]); } -}; +} /* ------------------------------------------------------------------- */ /* Less efficient but convenient ctor that parses strings to setup validator. _type: s1, u1, s2, u2, ..., f, d, t @@ -691,11 +691,11 @@ ezOptionValidator::ezOptionValidator(const char* _type, const char* _op, const c case T: t = strings; break; /* Don't erase strings array. */ default: break; } -}; +} /* ------------------------------------------------------------------- */ void ezOptionValidator::print() { printf("id=%d, op=%d, type=%d, size=%d, insensitive=%d\n", id, op, type, size, insensitive); -}; +} /* ------------------------------------------------------------------- */ bool ezOptionValidator::isValid(const std::string * valueAsString) { if (valueAsString == 0) return false; @@ -926,7 +926,7 @@ bool ezOptionValidator::isValid(const std::string * valueAsString) { } return true; -}; +} /* ################################################################### */ class OptionGroup { public: @@ -940,7 +940,7 @@ class OptionGroup { flags.clear(); parseIndex.clear(); clearArgs(); - }; + } inline void clearArgs(); inline void getInt(int&); @@ -995,7 +995,7 @@ void OptionGroup::clearArgs() { args.clear(); isSet = false; -}; +} /* ################################################################### */ void OptionGroup::getInt(int & out) { if (!isSet) { @@ -1010,7 +1010,7 @@ void OptionGroup::getInt(int & out) { out = atoi(args[0]->at(0)->c_str()); } } -}; +} /* ################################################################### */ void OptionGroup::getLong(long & out) { if (!isSet) { @@ -1025,7 +1025,7 @@ void OptionGroup::getLong(long & out) { out = atol(args[0]->at(0)->c_str()); } } -}; +} /* ################################################################### */ void OptionGroup::getLongLong(long long & out) { if (!isSet) { @@ -1043,7 +1043,7 @@ void OptionGroup::getLongLong(long long & out) { ss >> out; } } -}; +} /* ################################################################### */ void OptionGroup::getULong(unsigned long & out) { if (!isSet) { @@ -1058,7 +1058,7 @@ void OptionGroup::getULong(unsigned long & out) { out = strtoul(args[0]->at(0)->c_str(),0,0); } } -}; +} /* ################################################################### */ void OptionGroup::getULongLong(unsigned long long & out) { if (!isSet) { @@ -1076,7 +1076,7 @@ void OptionGroup::getULongLong(unsigned long long & out) { ss >> out; } } -}; +} /* ################################################################### */ void OptionGroup::getFloat(float & out) { if (!isSet) { @@ -1091,7 +1091,7 @@ void OptionGroup::getFloat(float & out) { out = (float)atof(args[0]->at(0)->c_str()); } } -}; +} /* ################################################################### */ void OptionGroup::getDouble(double & out) { if (!isSet) { @@ -1106,7 +1106,7 @@ void OptionGroup::getDouble(double & out) { out = atof(args[0]->at(0)->c_str()); } } -}; +} /* ################################################################### */ void OptionGroup::getString(std::string & out) { if (!isSet) { @@ -1118,7 +1118,7 @@ void OptionGroup::getString(std::string & out) { out = *args[0]->at(0); } } -}; +} /* ################################################################### */ void OptionGroup::getInts(std::vector & out) { if (!isSet) { @@ -1131,7 +1131,7 @@ void OptionGroup::getInts(std::vector & out) { if (!(args.empty() || args[0]->empty())) StringsToInts(args[0], &out); } -}; +} /* ################################################################### */ void OptionGroup::getLongs(std::vector & out) { if (!isSet) { @@ -1144,7 +1144,7 @@ void OptionGroup::getLongs(std::vector & out) { if (!(args.empty() || args[0]->empty())) StringsToLongs(args[0], &out); } -}; +} /* ################################################################### */ void OptionGroup::getULongs(std::vector & out) { if (!isSet) { @@ -1157,7 +1157,7 @@ void OptionGroup::getULongs(std::vector & out) { if (!(args.empty() || args[0]->empty())) StringsToULongs(args[0], &out); } -}; +} /* ################################################################### */ void OptionGroup::getFloats(std::vector & out) { if (!isSet) { @@ -1170,7 +1170,7 @@ void OptionGroup::getFloats(std::vector & out) { if (!(args.empty() || args[0]->empty())) StringsToFloats(args[0], &out); } -}; +} /* ################################################################### */ void OptionGroup::getDoubles(std::vector & out) { if (!isSet) { @@ -1183,7 +1183,7 @@ void OptionGroup::getDoubles(std::vector & out) { if (!(args.empty() || args[0]->empty())) StringsToDoubles(args[0], &out); } -}; +} /* ################################################################### */ void OptionGroup::getStrings(std::vector& out) { if (!isSet) { @@ -1194,7 +1194,7 @@ void OptionGroup::getStrings(std::vector& out) { if (!(args.empty() || args[0]->empty())) StringsToStrings(args[0], &out); } -}; +} /* ################################################################### */ void OptionGroup::getMultiInts(std::vector< std::vector >& out) { if (!isSet) { @@ -1213,7 +1213,7 @@ void OptionGroup::getMultiInts(std::vector< std::vector >& out) { } } } -}; +} /* ################################################################### */ void OptionGroup::getMultiLongs(std::vector< std::vector >& out) { if (!isSet) { @@ -1232,7 +1232,7 @@ void OptionGroup::getMultiLongs(std::vector< std::vector >& out) { } } } -}; +} /* ################################################################### */ void OptionGroup::getMultiULongs(std::vector< std::vector >& out) { if (!isSet) { @@ -1251,7 +1251,7 @@ void OptionGroup::getMultiULongs(std::vector< std::vector >& out) } } } -}; +} /* ################################################################### */ void OptionGroup::getMultiFloats(std::vector< std::vector >& out) { if (!isSet) { @@ -1270,7 +1270,7 @@ void OptionGroup::getMultiFloats(std::vector< std::vector >& out) { } } } -}; +} /* ################################################################### */ void OptionGroup::getMultiDoubles(std::vector< std::vector >& out) { if (!isSet) { @@ -1289,7 +1289,7 @@ void OptionGroup::getMultiDoubles(std::vector< std::vector >& out) { } } } -}; +} /* ################################################################### */ void OptionGroup::getMultiStrings(std::vector< std::vector >& out) { if (!isSet) { @@ -1310,7 +1310,7 @@ void OptionGroup::getMultiStrings(std::vector< std::vector >& out) } } } -}; +} /* ################################################################### */ typedef std::map< int, ezOptionValidator* > ValidatorMap; @@ -1399,7 +1399,7 @@ void ezOptionParser::reset() { validators.clear(); optionGroupIds.clear(); groupValidators.clear(); -}; +} /* ################################################################### */ void ezOptionParser::resetArgs() { int i; @@ -1417,7 +1417,7 @@ void ezOptionParser::resetArgs() { for(i=0; i < (long int)lastArgs.size(); ++i) delete lastArgs[i]; lastArgs.clear(); -}; +} /* ################################################################### */ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, ezOptionValidator* validator) { int id = this->groups.size(); @@ -1440,7 +1440,7 @@ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, c } else { groupValidators[id] = -1; } -}; +} /* ################################################################### */ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, ezOptionValidator* validator) { int id = this->groups.size(); @@ -1467,7 +1467,7 @@ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, c } else { groupValidators[id] = -1; } -}; +} /* ################################################################### */ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, const char * flag3, ezOptionValidator* validator) { int id = this->groups.size(); @@ -1497,7 +1497,7 @@ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, c } else { groupValidators[id] = -1; } -}; +} /* ################################################################### */ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, char delim, const char * help, const char * flag1, const char * flag2, const char * flag3, const char * flag4, ezOptionValidator* validator) { int id = this->groups.size(); @@ -1530,7 +1530,7 @@ void ezOptionParser::add(const char * defaults, bool required, int expectArgs, c } else { groupValidators[id] = -1; } -}; +} /* ################################################################### */ bool ezOptionParser::exportFile(const char * filename, bool all) { int i; @@ -1627,7 +1627,7 @@ bool ezOptionParser::exportFile(const char * filename, bool all) { file.close(); return true; -}; +} /* ################################################################### */ // Does not overwrite current options. // Returns true if file was read successfully. @@ -1747,7 +1747,7 @@ bool ezOptionParser::importFile(const char * filename, char comment) { delete *iter; return true; -}; +} /* ################################################################### */ int ezOptionParser::isSet(const char * name) { std::string sname(name); @@ -1757,7 +1757,7 @@ int ezOptionParser::isSet(const char * name) { } return 0; -}; +} /* ################################################################### */ int ezOptionParser::isSet(std::string & name) { if (this->optionGroupIds.count(name)) { @@ -1765,7 +1765,7 @@ int ezOptionParser::isSet(std::string & name) { } return 0; -}; +} /* ################################################################### */ OptionGroup * ezOptionParser::get(const char * name) { if (optionGroupIds.count(name)) { @@ -1773,7 +1773,7 @@ OptionGroup * ezOptionParser::get(const char * name) { } return 0; -}; +} /* ################################################################### */ void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { @@ -1792,7 +1792,7 @@ void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) { if (!footer.empty()) { usage.append(footer); } -}; +} /* ################################################################### */ // Creates 2 column formatted help descriptions for each option flag. void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout layout) { @@ -1933,7 +1933,7 @@ void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout } } -}; +} /* ################################################################### */ bool ezOptionParser::gotExpected(std::vector & badOptions) { int i,j; @@ -1955,7 +1955,7 @@ bool ezOptionParser::gotExpected(std::vector & badOptions) { } return badOptions.empty(); -}; +} /* ################################################################### */ bool ezOptionParser::gotRequired(std::vector & badOptions) { int i; @@ -1970,7 +1970,7 @@ bool ezOptionParser::gotRequired(std::vector & badOptions) { } return badOptions.empty(); -}; +} /* ################################################################### */ bool ezOptionParser::gotValid(std::vector & badOptions, std::vector & badArgs) { int groupid, validatorid; @@ -2000,7 +2000,7 @@ bool ezOptionParser::gotValid(std::vector & badOptions, std::vector } return badOptions.empty(); -}; +} /* ################################################################### */ void ezOptionParser::parse(int argc, const char * argv[]) { if (argc < 1) return; @@ -2081,7 +2081,7 @@ void ezOptionParser::parse(int argc, const char * argv[]) { for(k=lastOptIndex + 1; k < argc; ++k) { this->lastArgs.push_back(new std::string(argv[k])); } -}; +} /* ################################################################### */ void ezOptionParser::prettyPrint(std::string & out) { char tmp[256]; @@ -2152,7 +2152,7 @@ void ezOptionParser::prettyPrint(std::string & out) { sprintf(tmp, "%d: %s\n", i+1, unknownArgs[i]->c_str()); out += tmp; } -}; +} } /* ################################################################### */ #endif /* EZ_OPTION_PARSER_H */ From 145574b2a26942deaa46c35d73b49ed30cf10bd6 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 5 Nov 2014 16:03:45 -0700 Subject: [PATCH 48/71] Display errors if external executables are not found. --- src/EnergyPlus/CommandLineInterface.cc | 16 ++++++++++++++-- src/EnergyPlus/EnergyPlusPgm.cc | 14 +++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 70da7699240..97d9c734d8d 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -516,12 +516,18 @@ ProcessArgs(int argc, const char * argv[]) // Preprocessors (These will likely move to a new file) if(runEPMacro){ + std::string epMacroPath = exeDirectory + "EPMacro"; + { IOFlags flags; gio::inquire( epMacroPath, flags ); FileExists = flags.exists(); } + if (!FileExists){ + DisplayString("ERROR: Could not find EPMacro executable: " + getAbsolutePath(epMacroPath) + "." ); + exit(EXIT_FAILURE); + } + std::string epMacroCommand = "\"" + epMacroPath + "\""; bool inputFileNamedIn = (getAbsolutePath(inputIdfFileName) == getAbsolutePath("in.imf")); if (!inputFileNamedIn) linkFile(inputIdfFileName.c_str(), "in.imf"); - std::string epMacroCommand = "\"" + exeDirectory + "EPMacro\""; DisplayString("Running EPMacro..."); systemCall(epMacroCommand); if (!inputFileNamedIn) @@ -532,13 +538,19 @@ ProcessArgs(int argc, const char * argv[]) } if(runExpandObjects) { + std::string expandObjectsPath = exeDirectory + "ExpandObjects"; + { IOFlags flags; gio::inquire( expandObjectsPath, flags ); FileExists = flags.exists(); } + if (!FileExists){ + DisplayString("ERROR: Could not find ExpandObjects executable: " + getAbsolutePath(expandObjectsPath) + "." ); + exit(EXIT_FAILURE); + } + std::string expandObjectsCommand = "\"" + expandObjectsPath + "\""; bool inputFileNamedIn = (getAbsolutePath(inputIdfFileName) == getAbsolutePath("in.idf")); bool iddFileNamedEnergy = (getAbsolutePath(inputIddFileName) == getAbsolutePath("Energy+.idd")); - std::string expandObjectsCommand = "\"" + exeDirectory + "ExpandObjects\""; if (!inputFileNamedIn) linkFile(inputIdfFileName.c_str(), "in.idf"); if (!iddFileNamedEnergy) diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index 90948314727..0cf55e72611 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -359,7 +359,15 @@ EnergyPlusPgm(int argc, const char * argv[]) ReportOrphanSchedules(); if(runReadVars) { - std::string RVIfile = idfDirPathName + idfFileNameOnly + ".rvi"; + std::string readVarsPath = exeDirectory + "ReadVarsESO"; + bool FileExists; + { IOFlags flags; gio::inquire( readVarsPath, flags ); FileExists = flags.exists(); } + if (!FileExists){ + DisplayString("ERROR: Could not find ReadVarsESO executable: " + getAbsolutePath(readVarsPath) + "." ); + exit(EXIT_FAILURE); + } + + std::string RVIfile = idfDirPathName + idfFileNameOnly + ".rvi"; std::string MVIfile = idfDirPathName + idfFileNameOnly + ".mvi"; int fileUnitNumber; @@ -393,8 +401,8 @@ EnergyPlusPgm(int argc, const char * argv[]) gio::close( fileUnitNumber ); } - std::string readVarsRviCommand = "\"" + exeDirectory + "ReadVarsESO\"" + " " + RVIfile + " unlimited"; - std::string readVarsMviCommand = "\"" + exeDirectory + "ReadVarsESO\"" + " " + MVIfile + " unlimited"; + std::string readVarsRviCommand = "\"" + readVarsPath + "\"" + " " + RVIfile + " unlimited"; + std::string readVarsMviCommand = "\"" + readVarsPath + "\"" + " " + MVIfile + " unlimited"; systemCall(readVarsRviCommand); systemCall(readVarsMviCommand); From 55b9e3423dfbb03029244b9d86bb87a260afea37 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 5 Nov 2014 19:57:09 -0700 Subject: [PATCH 49/71] Fix executable checks on Windows. --- src/EnergyPlus/CommandLineInterface.cc | 4 ++-- src/EnergyPlus/EnergyPlusPgm.cc | 2 +- src/EnergyPlus/FileSystem.cc | 6 ++++++ src/EnergyPlus/FileSystem.hh | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 97d9c734d8d..46e20efba9c 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -516,7 +516,7 @@ ProcessArgs(int argc, const char * argv[]) // Preprocessors (These will likely move to a new file) if(runEPMacro){ - std::string epMacroPath = exeDirectory + "EPMacro"; + std::string epMacroPath = exeDirectory + "EPMacro" + exeExtension; { IOFlags flags; gio::inquire( epMacroPath, flags ); FileExists = flags.exists(); } if (!FileExists){ DisplayString("ERROR: Could not find EPMacro executable: " + getAbsolutePath(epMacroPath) + "." ); @@ -538,7 +538,7 @@ ProcessArgs(int argc, const char * argv[]) } if(runExpandObjects) { - std::string expandObjectsPath = exeDirectory + "ExpandObjects"; + std::string expandObjectsPath = exeDirectory + "ExpandObjects" + exeExtension; { IOFlags flags; gio::inquire( expandObjectsPath, flags ); FileExists = flags.exists(); } if (!FileExists){ DisplayString("ERROR: Could not find ExpandObjects executable: " + getAbsolutePath(expandObjectsPath) + "." ); diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index 0cf55e72611..a80ce922adf 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -359,7 +359,7 @@ EnergyPlusPgm(int argc, const char * argv[]) ReportOrphanSchedules(); if(runReadVars) { - std::string readVarsPath = exeDirectory + "ReadVarsESO"; + std::string readVarsPath = exeDirectory + "ReadVarsESO" + exeExtension; bool FileExists; { IOFlags flags; gio::inquire( readVarsPath, flags ); FileExists = flags.exists(); } if (!FileExists){ diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 2dd92e22ec7..b1b34234e65 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -29,6 +29,12 @@ namespace FileSystem { using DataStringGlobals::pathChar; +#ifdef _WIN32 +std::string const exeExtension(".exe"); +#else +std::string const exeExtension(""); +#endif + std::string getFileName( std::string const& filePath ) diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index b46d3a8a624..ff3db6d48f5 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -5,6 +5,8 @@ namespace EnergyPlus{ namespace FileSystem { +extern std::string const exeExtension; + std::string getFileName( std::string const& filePath ); From 06416bf85785e734dc0a06fb9dc19dcec8e5330c Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 6 Nov 2014 12:14:40 -0700 Subject: [PATCH 50/71] Convert path characters passed from CLI to native path characters. --- cmake/RunSimulation.cmake | 11 +++++--- src/EnergyPlus/CommandLineInterface.cc | 7 +++++ src/EnergyPlus/DataSystemVariables.cc | 36 ++++++++++++-------------- src/EnergyPlus/FileSystem.cc | 10 +++++-- src/EnergyPlus/FileSystem.hh | 5 ++++ 5 files changed, 44 insertions(+), 25 deletions(-) diff --git a/cmake/RunSimulation.cmake b/cmake/RunSimulation.cmake index 7aa9c0cf269..50e41be5f8d 100644 --- a/cmake/RunSimulation.cmake +++ b/cmake/RunSimulation.cmake @@ -12,10 +12,6 @@ get_filename_component(IDF_NAME "${IDF_FILE}" NAME_WE) get_filename_component(IDF_EXT "${IDF_FILE}" EXT) get_filename_component(EXE_PATH "${ENERGYPLUS_EXE}" PATH) -# Clean up old test directory -execute_process(COMMAND "${CMAKE_COMMAND}" -E remove_directory "${BINARY_DIR}/testfiles/${IDF_NAME}" ) -execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${BINARY_DIR}/testfiles/${IDF_NAME}" ) - # Create path variables set (OUTPUT_DIR_PATH "${BINARY_DIR}/testfiles/${IDF_NAME}/") set (IDF_PATH "${SOURCE_DIR}/testfiles/${IDF_FILE}") @@ -23,6 +19,13 @@ set (PRODUCT_PATH "${BINARY_DIR}/Products/") set (EXE_PATH "${EXE_PATH}/") set (EPW_PATH "${SOURCE_DIR}/weather/${EPW_FILE}") +# Copy IDD to Executable directory if it is not already there +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PRODUCT_PATH}/Energy+.idd" "${EXE_PATH}") + +# Clean up old test directory +execute_process(COMMAND "${CMAKE_COMMAND}" -E remove_directory "${OUTPUT_DIR_PATH}" ) +execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${OUTPUT_DIR_PATH}" ) + # Read the file contents to check for special cases file(READ "${IDF_PATH}" IDF_CONTENT) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 46e20efba9c..010b5fad82d 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -220,6 +220,12 @@ ProcessArgs(int argc, const char * argv[]) if(opt.lastArgs.size() == 0) inputIdfFileName = "in.idf"; + // Convert all paths to native paths + makeNativePath(inputIdfFileName); + makeNativePath(inputWeatherFileName); + makeNativePath(inputIddFileName); + makeNativePath(dirPathName); + std::vector badOptions; if(opt.lastArgs.size() > 1){ bool invalidOptionFound = false; @@ -278,6 +284,7 @@ ProcessArgs(int argc, const char * argv[]) if(opt.isSet("-p")) { std::string prefixOutName; opt.get("-p")->getString(prefixOutName); + makeNativePath(prefixOutName); outputFilePrefix = dirPathName + prefixOutName; } else if (!legacyMode) diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index 234f217bff8..cfe88453b14 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace EnergyPlus { @@ -40,6 +41,7 @@ namespace DataSystemVariables { using DataStringGlobals::altpathChar; using DataStringGlobals::CurrentWorkingFolder; using DataStringGlobals::ProgramPath; + using namespace FileSystem; // Data // -only module should be available to other modules and routines. @@ -200,20 +202,16 @@ namespace DataSystemVariables { CheckedFileName = blank; InputFileName = originalInputFileName; - pos = index( InputFileName, altpathChar ); - while ( pos != std::string::npos ) { - InputFileName[ pos ] = pathChar; - pos = index( InputFileName, altpathChar ); - } + makeNativePath(InputFileName); { IOFlags flags; gio::inquire( InputFileName, flags ); FileExist = flags.exists(); } if ( FileExist ) { FileFound = true; CheckedFileName = InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (user input)=" + InputFileName; + gio::write(EchoInputFile, fmtA) << "found (user input)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (user input)=" + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (user input)=" + getAbsolutePath(InputFileName); } // Look relative to input file path @@ -221,10 +219,10 @@ namespace DataSystemVariables { if ( FileExist ) { FileFound = true; CheckedFileName = idfDirPathName + InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (idf)=" + CheckedFileName; + gio::write(EchoInputFile, fmtA) << "found (idf)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (idf)=" + idfDirPathName + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (idf)=" + getAbsolutePath(idfDirPathName + InputFileName); } // Look relative to input path @@ -232,10 +230,10 @@ namespace DataSystemVariables { if ( FileExist ) { FileFound = true; CheckedFileName = envinputpath1 + InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (epin)=" + CheckedFileName; + gio::write(EchoInputFile, fmtA) << "found (epin)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (epin)=" + envinputpath1 + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (epin)=" + getAbsolutePath(envinputpath1 + InputFileName); } // Look relative to input path @@ -243,10 +241,10 @@ namespace DataSystemVariables { if ( FileExist ) { FileFound = true; CheckedFileName = envinputpath2 + InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (input_path)=" + CheckedFileName; + gio::write(EchoInputFile, fmtA) << "found (input_path)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (input_path)=" + envinputpath2 + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (input_path)=" + getAbsolutePath(envinputpath2 + InputFileName); } // Look relative to program path @@ -254,10 +252,10 @@ namespace DataSystemVariables { if ( FileExist ) { FileFound = true; CheckedFileName = envprogrampath + InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (program_path)=" + CheckedFileName; + gio::write(EchoInputFile, fmtA) << "found (program_path)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (program_path)=" + envprogrampath + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (program_path)=" + getAbsolutePath(envprogrampath + InputFileName); } if ( ! TestAllPaths ) return; @@ -267,10 +265,10 @@ namespace DataSystemVariables { if ( FileExist ) { FileFound = true; CheckedFileName = CurrentWorkingFolder + InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (CWF)=" + CheckedFileName; + gio::write(EchoInputFile, fmtA) << "found (CWF)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (CWF)=" + CurrentWorkingFolder + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (CWF)=" + getAbsolutePath(CurrentWorkingFolder + InputFileName); } // Look relative to program path @@ -278,10 +276,10 @@ namespace DataSystemVariables { if ( FileExist ) { FileFound = true; CheckedFileName = ProgramPath + InputFileName; - gio::write( EchoInputFile, fmtA ) << "found (program path - ini)=" + CheckedFileName; + gio::write(EchoInputFile, fmtA) << "found (program path - ini)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write( EchoInputFile, fmtA ) << "not found (program path - ini)=" + ProgramPath + InputFileName; + gio::write(EchoInputFile, fmtA) << "not found (program path - ini)=" + getAbsolutePath(ProgramPath + InputFileName); } } diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index b1b34234e65..18746f5509a 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -27,7 +27,7 @@ namespace EnergyPlus{ namespace FileSystem { -using DataStringGlobals::pathChar; +using namespace DataStringGlobals; #ifdef _WIN32 std::string const exeExtension(".exe"); @@ -35,6 +35,11 @@ std::string const exeExtension(".exe"); std::string const exeExtension(""); #endif +void +makeNativePath(std::string &path) +{ + std::replace(path.begin(), path.end(), altpathChar, pathChar); +} std::string getFileName( std::string const& filePath ) @@ -43,7 +48,8 @@ getFileName( std::string const& filePath ) return filePath.substr(pathCharPosition + 1, filePath.size() - 1); } -std::string getDirectoryPath( std::string const& filePath ) +std::string +getDirectoryPath( std::string const& filePath ) { int pathCharPosition = filePath.find_last_of(pathChar); return filePath.substr(0, pathCharPosition + 1); diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index ff3db6d48f5..5399e621e07 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -1,12 +1,17 @@ #ifndef FileSystem_hh_INCLUDED #define FileSystem_hh_INCLUDED +#include + namespace EnergyPlus{ namespace FileSystem { extern std::string const exeExtension; +void +makeNativePath(std::string &path); + std::string getFileName( std::string const& filePath ); From e0058490883dca7537bbb165ca2e7e27d5edc239 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 6 Nov 2014 17:10:28 -0700 Subject: [PATCH 51/71] Attempt to fix Unix issues with getAbsolutePath(). --- src/EnergyPlus/CommandLineInterface.cc | 4 +- src/EnergyPlus/FileSystem.cc | 97 ++++++++++++++++++++++---- src/EnergyPlus/FileSystem.hh | 13 +++- 3 files changed, 95 insertions(+), 19 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 010b5fad82d..5cd1686094f 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -181,7 +181,7 @@ ProcessArgs(int argc, const char * argv[]) opt.getUsage(usage); // Set path of EnergyPlus program path - exeDirectory = getDirectoryPath(getAbsolutePath(getProgramPath())); + exeDirectory = getParentDirectoryPath(getAbsolutePath(getProgramPath())); opt.get("-w")->getString(inputWeatherFileName); @@ -252,7 +252,7 @@ ProcessArgs(int argc, const char * argv[]) } idfFileNameOnly = removeFileExtension(getFileName(inputIdfFileName)); - idfDirPathName = getDirectoryPath(inputIdfFileName); + idfDirPathName = getParentDirectoryPath(inputIdfFileName); std::string weatherFilePathWithoutExtension = removeFileExtension(inputWeatherFileName); diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 18746f5509a..88d350d8fc0 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -49,22 +49,55 @@ getFileName( std::string const& filePath ) } std::string -getDirectoryPath( std::string const& filePath ) +getParentDirectoryPath( std::string const& path ) { - int pathCharPosition = filePath.find_last_of(pathChar); - return filePath.substr(0, pathCharPosition + 1); + std::string tempPath = path; + if (path.at(path.size()-1) == pathChar) + tempPath = path.substr(0, path.size()-1); + + int pathCharPosition = tempPath.find_last_of(pathChar); + tempPath = tempPath.substr(0, pathCharPosition + 1); + + if (tempPath == "") + tempPath = "."; + + return tempPath; } std::string -getAbsolutePath( std::string const& filePath ) +getAbsolutePath( std::string const& path ) { - char absolutePath[1024]; + #ifdef _WIN32 - GetFullPathName(filePath.c_str(), sizeof(absolutePath), absolutePath, NULL); + char absolutePath[1024]; + GetFullPathName(path.c_str(), sizeof(absolutePath), absolutePath, NULL); + return std::string(absolutePath); #else - char *result = realpath(filePath.c_str(), absolutePath); + // If the path doesn't exist, find which of it's parents' paths does exist + std::string parentPath = path; + while(!pathExists(parentPath)) { + parentPath = getParentDirectoryPath(parentPath); + } + + std::string pathTail; + if ( parentPath == "." ) + pathTail = pathChar + path; + else + pathTail = pathChar + path.substr(parentPath.size(), path.size() - parentPath.size()); + + char *absolutePathTemp = realpath(parentPath.c_str(), NULL); + if (absolutePathTemp != NULL) { + std::string absoluteParentPath(absolutePathTemp); + free(absolutePathTemp); + return absoluteParentPath + pathTail; + } + else { + DisplayString("ERROR: Could not resolve path for " + path + "."); + exit(EXIT_FAILURE); + } #endif - return std::string(absolutePath); + + } std::string @@ -97,26 +130,60 @@ removeFileExtension(const std::string& fileName){ } void -makeDirectory(std::string directoryName) +makeDirectory(std::string directoryPath) { - struct stat info; - - if ( stat(getAbsolutePath(directoryName).c_str(), &info) == 0){ // path already exists - if ( !(info.st_mode & S_IFDIR) ) + // Create a directory if doesn't already exist + if ( pathExists(directoryPath) ){ // path already exists + if ( !(directoryExists(directoryPath)) ) { - DisplayString("ERROR: " + getAbsolutePath(directoryName) + " is not a directory."); + DisplayString("ERROR: " + getAbsolutePath(directoryPath) + " is not a directory."); exit(EXIT_FAILURE); } } else { // directory does not already exist + std::string parentDirectoryPath = getParentDirectoryPath(directoryPath); + if (!pathExists(parentDirectoryPath)) + { + DisplayString("ERROR: " + getAbsolutePath(parentDirectoryPath) + " is not a directory."); + exit(EXIT_FAILURE); + } #ifdef _WIN32 CreateDirectory(directoryName.c_str(), NULL); #else - mkdir(directoryName.c_str(), 0755); + mkdir(directoryPath.c_str(), 0755); #endif } } +bool +pathExists(std::string path) +{ + struct stat info; + return (stat(path.c_str(), &info) == 0); +} + +bool +directoryExists(std::string directoryPath) +{ + struct stat info; + if ( stat(directoryPath.c_str(), &info) == 0){ + return (info.st_mode & S_IFDIR); + } + else + return false; +} + +bool +fileExists(std::string filePath) +{ + struct stat info; + if ( stat(filePath.c_str(), &info) == 0){ + return !(info.st_mode & S_IFDIR); + } + else + return false; +} + void moveFile(std::string filePath, std::string destination){ rename(filePath.c_str(), destination.c_str()); diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index 5399e621e07..645c9a9591a 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -16,7 +16,7 @@ std::string getFileName( std::string const& filePath ); std::string -getDirectoryPath( std::string const& filePath ); +getParentDirectoryPath( std::string const& filePath ); std::string getAbsolutePath( std::string const& filePath ); @@ -30,7 +30,16 @@ std::string removeFileExtension(const std::string& fileName); void -makeDirectory(std::string directoryName); +makeDirectory(std::string directoryPath); + +bool +pathExists(std::string path); + +bool +directoryExists(std::string directoryPath); + +bool +fileExists(std::string filePath); void moveFile(std::string filePath, std::string destination); From 2291f3468ba0b78e795933358cf1a0556775408f Mon Sep 17 00:00:00 2001 From: nealkruis Date: Fri, 7 Nov 2014 07:53:20 -0700 Subject: [PATCH 52/71] Fix makeDirectory() for Windows. --- src/EnergyPlus/FileSystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 88d350d8fc0..e2b77aa0a9f 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -148,7 +148,7 @@ makeDirectory(std::string directoryPath) exit(EXIT_FAILURE); } #ifdef _WIN32 - CreateDirectory(directoryName.c_str(), NULL); + CreateDirectory(directoryPath.c_str(), NULL); #else mkdir(directoryPath.c_str(), 0755); #endif From c3fd936523ce06677166b240a9072a5ddb6ed23c Mon Sep 17 00:00:00 2001 From: nealkruis Date: Sat, 8 Nov 2014 12:32:51 -0700 Subject: [PATCH 53/71] Use a different function for checking paths in Windows that works with CTest. --- src/EnergyPlus/CMakeLists.txt | 3 +++ src/EnergyPlus/FileSystem.cc | 43 +++++++++++++++++++++++++++-------- src/EnergyPlus/FileSystem.hh | 26 ++++++++++----------- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 6c94ff12242..3edbb81ac08 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -530,6 +530,9 @@ target_link_libraries( energypluslib objexx sqlite bcvtb epexpat epfmiimport DEl if(UNIX AND NOT APPLE) target_link_libraries( energypluslib dl ) endif() +if (WIN32) + target_link_libraries( energypluslib Shlwapi ) +endif() # second we will create the shared library that is actually packaged with EnergyPlus add_library( energyplusapi SHARED "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index e2b77aa0a9f..c10f74b3cf5 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -9,6 +9,7 @@ #ifdef _WIN32 #include +#include #else #include #endif @@ -118,20 +119,24 @@ getProgramPath() } std::string -getFileExtension(const std::string& fileName){ +getFileExtension(std::string const &fileName){ int extensionPosition = fileName.find_last_of("."); return fileName.substr(extensionPosition + 1, fileName.size() - 1); } std::string -removeFileExtension(const std::string& fileName){ +removeFileExtension(std::string const &fileName){ int extensionPosition = fileName.find_last_of("."); return fileName.substr(0, extensionPosition); } void -makeDirectory(std::string directoryPath) +makeDirectory(std::string const &directoryPath) { + if (!directoryExists(directoryPath)) + DisplayString("ERROR: " + getAbsolutePath(directoryPath) + " is not a directory."); + + // Create a directory if doesn't already exist if ( pathExists(directoryPath) ){ // path already exists if ( !(directoryExists(directoryPath)) ) @@ -156,53 +161,71 @@ makeDirectory(std::string directoryPath) } bool -pathExists(std::string path) +pathExists(std::string const &path) { +#ifdef _WIN32 + return PathFileExists(path.c_str()); +#else struct stat info; return (stat(path.c_str(), &info) == 0); +#endif } bool -directoryExists(std::string directoryPath) +directoryExists(std::string const &directoryPath) { +#ifdef _WIN32 + if (PathFileExists(directoryPath.c_str())) + return PathIsDirectory(directoryPath.c_str()); + else + return false; +#else struct stat info; if ( stat(directoryPath.c_str(), &info) == 0){ return (info.st_mode & S_IFDIR); } else return false; +#endif } bool -fileExists(std::string filePath) +fileExists(std::string const &filePath) { +#ifdef _WIN32 + if (PathFileExists(filePath.c_str())) + return !PathIsDirectory(filePath.c_str()); + else + return false; +#else struct stat info; if ( stat(filePath.c_str(), &info) == 0){ return !(info.st_mode & S_IFDIR); } else return false; +#endif } void -moveFile(std::string filePath, std::string destination){ +moveFile(std::string const &filePath, std::string const &destination){ rename(filePath.c_str(), destination.c_str()); } int -systemCall(std::string command) +systemCall(std::string const &command) { return system(command.c_str()); } void -removeFile(std::string fileName) +removeFile(std::string const &fileName) { remove(fileName.c_str()); } void -linkFile(std::string fileName, std::string link) +linkFile(std::string const &fileName, std::string const &link) { #ifdef _WIN32 CopyFile(fileName.c_str(), link.c_str(), false); diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index 645c9a9591a..f4a3936687d 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -13,45 +13,45 @@ void makeNativePath(std::string &path); std::string -getFileName( std::string const& filePath ); +getFileName( std::string const &filePath ); std::string -getParentDirectoryPath( std::string const& filePath ); +getParentDirectoryPath( std::string const &filePath ); std::string -getAbsolutePath( std::string const& filePath ); +getAbsolutePath( std::string const &filePath ); std::string getProgramPath(); std::string -getFileExtension(const std::string& fileName); +getFileExtension(std::string const &fileName); std::string -removeFileExtension(const std::string& fileName); +removeFileExtension(std::string const &fileName); void -makeDirectory(std::string directoryPath); +makeDirectory(std::string const &directoryPath); bool -pathExists(std::string path); +pathExists(std::string const &path); bool -directoryExists(std::string directoryPath); +directoryExists(std::string const &directoryPath); bool -fileExists(std::string filePath); +fileExists(std::string const &filePath); void -moveFile(std::string filePath, std::string destination); +moveFile(std::string const &filePath, std::string const &destination); int -systemCall(std::string command); +systemCall(std::string const &command); void -removeFile(std::string fileName); +removeFile(std::string const &fileName); void -linkFile(std::string fileName, std::string link); +linkFile(std::string const &fileName, std::string const &link); } From 8aefd07087cde0eb2307ddd7390abe6585d7569c Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 25 Nov 2014 08:54:43 -0700 Subject: [PATCH 54/71] Fix issues with command line branch: - Windows didnt like the dummy argv initialization, should be better now - Because of project name change, API defs were out of date, causing dll linkage warnings...fixed now [#1277852] --- src/EnergyPlus/EnergyPlusPgm.cc | 18 +++++++++++++----- src/EnergyPlus/public/EnergyPlusAPI.hh | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index 91580f1729c..a1ae1218342 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -350,16 +350,24 @@ EnergyPlusPgm( std::string filepath ) if ( ! cEnvValue.empty() ) TraceHVACControllerEnvFlag = env_var_on( cEnvValue ); // Yes or True if( ! filepath.empty() ) { + // if filepath is not empty, then we are using E+ as a library API call + // change the directory to the specified folder, and pass in dummy args to command line parser + // this will initialize the paths throughout E+ to the defaults #ifdef _WIN32 - int status = _chdir(filepath.c_str()); + int status = _chdir( filepath.c_str() ); #else - std::cout << "Trying to change directory to: " << filepath << std::endl; - int status = chdir(filepath.c_str()); - std::cout << "Chdir status = " << status << std::endl; + DisplayString( "EnergyPlus Library: Changing directory to: " + filepath ); + int status = chdir( filepath.c_str() ); + if ( status == 0 ) { + DisplayString( "Directory change successful." ); + } else { + DisplayString( "Couldn't change directory; aborting EnergyPlus" ); + return 1; + } #endif ProgramPath = filepath + pathChar; int dummy_argc = 0; - const char ** dummy_argv( 0 ); + const char * dummy_argv[] = { NULL }; ProcessArgs( dummy_argc, dummy_argv ); } diff --git a/src/EnergyPlus/public/EnergyPlusAPI.hh b/src/EnergyPlus/public/EnergyPlusAPI.hh index d8b02241628..2affc2d9229 100644 --- a/src/EnergyPlus/public/EnergyPlusAPI.hh +++ b/src/EnergyPlus/public/EnergyPlusAPI.hh @@ -2,7 +2,7 @@ #define ENERGYPLUS_LIB_ENERGYPLUSAPI_HPP #if _WIN32 || _MSC_VER - #if defined(EnergyPlusLib_EXPORTS) || defined(EnergyPlusAPI_EXPORTS) + #if defined(energypluslib_EXPORTS) || defined(energyplusapi_EXPORTS) #define ENERGYPLUSLIB_API __declspec(dllexport) #else #define ENERGYPLUSLIB_API __declspec(dllimport) From 5a59628e57cc14b604a5d979bafa536928ab7d87 Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Wed, 17 Dec 2014 09:15:13 -0600 Subject: [PATCH 55/71] Install man page [#76006798] --- cmake/CPack.STGZ_Header.sh.in | 2 ++ cmake/Install.cmake | 4 ++++ cmake/darwinpostflight.sh.in | 2 ++ 3 files changed, 8 insertions(+) diff --git a/cmake/CPack.STGZ_Header.sh.in b/cmake/CPack.STGZ_Header.sh.in index 85447a45f2a..7b68e590dc2 100644 --- a/cmake/CPack.STGZ_Header.sh.in +++ b/cmake/CPack.STGZ_Header.sh.in @@ -73,6 +73,8 @@ link_err () chmod o+w "${install_directory}/${package_name}/PreProcess/IDFVersionUpdater/" +mv "${install_directory}/${package_name}/energyplus.1" /usr/local/man/man1/ + if [ ! "$link_directory" = "n" ]; then uninstall="$install_directory/$package_name/uninstall.sh" echo "#!/usr/bin/env sh" > $uninstall diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 39bc29092a0..570dcbdc39e 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -304,6 +304,10 @@ if( APPLE ) set(CPACK_POSTFLIGHT_SCRIPT "${CMAKE_BINARY_DIR}/darwinpostflight.sh") endif() +if( UNIX) + install(FILES doc/man/energyplus.1 DESTINATION "./") +endif() + if( UNIX AND NOT APPLE ) install_remote(PROGRAMS "https://raw.github.com/NREL/EnergyPlusBuildSupport/v8.2.0/bin/EP-Compare/Run-Linux/EP-Compare" "PostProcess/EP-Compare/") install_remote(FILES "https://raw.github.com/NREL/EnergyPlusBuildSupport/v8.2.0/bin/EP-Compare/Run-Linux/EP-Compare%20Libs/EHInterfaces5001.so" "PostProcess/EP-Compare/EP-Compare Libs/") diff --git a/cmake/darwinpostflight.sh.in b/cmake/darwinpostflight.sh.in index b5f65d2573e..85a1d7d8d81 100644 --- a/cmake/darwinpostflight.sh.in +++ b/cmake/darwinpostflight.sh.in @@ -17,6 +17,8 @@ ln -sf "$2@CPACK_PACKAGING_INSTALL_PREFIX@/runreadvars" /usr/bin/ ln -sf "$2@CPACK_PACKAGING_INSTALL_PREFIX@/PreProcess/GrndTempCalc/Slab" /usr/bin/ ln -sf "$2@CPACK_PACKAGING_INSTALL_PREFIX@/PreProcess/GrndTempCalc/SlabGHT.idd" /usr/bin/ +mv "$2@CPACK_PACKAGING_INSTALL_PREFIX@/energyplus.1" /usr/local/man/man1/ + chmod -R a+w "$2@CPACK_PACKAGING_INSTALL_PREFIX@/ExampleFiles" chmod -R a+w "$2@CPACK_PACKAGING_INSTALL_PREFIX@/PreProcess/IDFVersionUpdater/IDFVersionUpdater.app/Contents/MacOS/" From c967b1ccd27cf4664388917af82ab7d9e921a2d7 Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Wed, 17 Dec 2014 09:54:51 -0600 Subject: [PATCH 56/71] Adjust manpage install path [#76006798] --- cmake/CPack.STGZ_Header.sh.in | 3 ++- cmake/darwinpostflight.sh.in | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/CPack.STGZ_Header.sh.in b/cmake/CPack.STGZ_Header.sh.in index 7b68e590dc2..2e0b8be23d9 100644 --- a/cmake/CPack.STGZ_Header.sh.in +++ b/cmake/CPack.STGZ_Header.sh.in @@ -73,7 +73,7 @@ link_err () chmod o+w "${install_directory}/${package_name}/PreProcess/IDFVersionUpdater/" -mv "${install_directory}/${package_name}/energyplus.1" /usr/local/man/man1/ +mv "${install_directory}/${package_name}/energyplus.1" /usr/local/share/man/man1/ if [ ! "$link_directory" = "n" ]; then uninstall="$install_directory/$package_name/uninstall.sh" @@ -125,6 +125,7 @@ if [ ! "$link_directory" = "n" ]; then rm -f "${link_directory}/Transition-V8-0-0-to-V8-1-0" rm -f "${link_directory}/V8-0-0-Energy+.idd" rm -f "${link_directory}/V8-1-0-Energy+.idd" + rm -f /usr/local/share/man/man1/energyplus.1 echo "Symbolic links to this installation of EnergyPlus have been removed." echo "You may remove the EnergyPlus directory to completely uninstall the software." HERE diff --git a/cmake/darwinpostflight.sh.in b/cmake/darwinpostflight.sh.in index 85a1d7d8d81..d4246c11d3a 100644 --- a/cmake/darwinpostflight.sh.in +++ b/cmake/darwinpostflight.sh.in @@ -17,7 +17,7 @@ ln -sf "$2@CPACK_PACKAGING_INSTALL_PREFIX@/runreadvars" /usr/bin/ ln -sf "$2@CPACK_PACKAGING_INSTALL_PREFIX@/PreProcess/GrndTempCalc/Slab" /usr/bin/ ln -sf "$2@CPACK_PACKAGING_INSTALL_PREFIX@/PreProcess/GrndTempCalc/SlabGHT.idd" /usr/bin/ -mv "$2@CPACK_PACKAGING_INSTALL_PREFIX@/energyplus.1" /usr/local/man/man1/ +mv "$2@CPACK_PACKAGING_INSTALL_PREFIX@/energyplus.1" /usr/local/share/man/man1/ chmod -R a+w "$2@CPACK_PACKAGING_INSTALL_PREFIX@/ExampleFiles" chmod -R a+w "$2@CPACK_PACKAGING_INSTALL_PREFIX@/PreProcess/IDFVersionUpdater/IDFVersionUpdater.app/Contents/MacOS/" From fff7d8e166aef870cb52e965c827e24dca258661 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 8 Jan 2015 15:43:52 -0700 Subject: [PATCH 57/71] Fix void function return. --- src/EnergyPlus/EnergyPlusPgm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index a1ae1218342..ac304d44a23 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -362,7 +362,7 @@ EnergyPlusPgm( std::string filepath ) DisplayString( "Directory change successful." ); } else { DisplayString( "Couldn't change directory; aborting EnergyPlus" ); - return 1; + exit(EXIT_FAILURE); } #endif ProgramPath = filepath + pathChar; From f207752e0a3de8362ecf213a12fae1d208a7d94c Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 8 Jan 2015 15:45:02 -0700 Subject: [PATCH 58/71] Fix erroneous error message. --- src/EnergyPlus/FileSystem.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index c10f74b3cf5..94a2b4d3e8b 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -133,10 +133,6 @@ removeFileExtension(std::string const &fileName){ void makeDirectory(std::string const &directoryPath) { - if (!directoryExists(directoryPath)) - DisplayString("ERROR: " + getAbsolutePath(directoryPath) + " is not a directory."); - - // Create a directory if doesn't already exist if ( pathExists(directoryPath) ){ // path already exists if ( !(directoryExists(directoryPath)) ) From 15c0542443056ae12603d1bb45c2c45cea6c7967 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 8 Jan 2015 16:13:58 -0700 Subject: [PATCH 59/71] Clarify options further in help documentation. --- doc/man/energyplus.1 | 10 +-- doc/running-energyplus-from-command-line.md | 73 +++++++++++++++++++++ src/EnergyPlus/CommandLineInterface.cc | 10 +-- 3 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 doc/running-energyplus-from-command-line.md diff --git a/doc/man/energyplus.1 b/doc/man/energyplus.1 index 37b5c35588e..8501f97f998 100644 --- a/doc/man/energyplus.1 +++ b/doc/man/energyplus.1 @@ -35,7 +35,7 @@ Force annual simulation .RE .TP .B \-d, \-\-output\-directory \f[I]ARG\f[] -Output directory path (default: \f[I]INPUTFILE\f[]-output) +Output directory path (default: \f[I]INPUTFILE\f[]-output in current directory) .RS .RE .TP @@ -55,7 +55,7 @@ Input data dictionary path (default: Energy+.idd in executable directory) .RE .TP .B \-m, \-\-epmacro -Run EPMacro +Run EPMacro prior to simulation .RS .RE .TP @@ -65,7 +65,7 @@ Prefix for output file names (default: ep) .RE .TP .B \-r, \-\-readvars -Run ReadVarsESO +Run ReadVarsESO after simulation .RS .RE .TP @@ -75,9 +75,9 @@ Display version information .RE .TP .B \-w, \-\-weather \f[I]ARG\f[] -Weather file path (default: in.epw) +Weather file path (default: in.epw in current directory) .RS .RE .TP .B \-x, \-\-expandobjects -Run ExpandObjects \ No newline at end of file +Run ExpandObjects prior to simulation \ No newline at end of file diff --git a/doc/running-energyplus-from-command-line.md b/doc/running-energyplus-from-command-line.md new file mode 100644 index 00000000000..2264afcce9d --- /dev/null +++ b/doc/running-energyplus-from-command-line.md @@ -0,0 +1,73 @@ +How to run EnergyPlus from the command line +=========================================== + +EnergyPlus has a command line interface. The options for running EnergyPlus can be shown by typing: + + energyplus --help + +This will give the following display of options: + + EnergyPlus, Version X.Y.Z + Usage: energyplus [options] [input-file] + Options: + -a, --annual Force annual simulation + -d, --output-directory ARG Output directory path (default: INPUTFILE-output + in current directory) + -D, --design-day Force design-day-only simulation + -h, --help Display help information + -i, --idd ARG Input data dictionary path (default: Energy+.idd + in executable directory) + -m, --epmacro Run EPMacro prior to simulation + -p, --output-prefix ARG Prefix for output file names (default: ep) + -r, --readvars Run ReadVarsESO after simulation + -v, --version Display version information + -w, --weather ARG Weather file path (default: in.epw in current + directory)) + -x, --expandobjects Run ExpandObjects prior to simulation + Example: energyplus -w weather.epw -r input.idf + +EnergyPlus can be run by specifying a number of options followed by the path to the input file (`input-file`). The file itself is usually in IDF (Input Data File) format, but it may also be in IMF (Input Macro File) format to be run with EPMacro using the `--epmacro` option. + +Each option has a short form (a single-character preceded by a single dash, e.g., "-h") and a long form (a more descriptive string of characters preceded by double dashes, e.g., "--help"). + +The options generally fall into four categories: + +1. Basic informational switches: + - `help` + - `version` +2. Input/output control flags: + - `idd` + - `weather` + - `output-directory` + - `output-prefix` +3. Pre- and post-processing switches: + - `epmacro` + - `expandobjects` + - `readvars` +4. Input override switches: + - `annual` + - `design-day` + +Examples +-------- + +1. Using a custom IDD file: + + `energyplus -i custom.idd -w weather input.idf` + +2. Pre-processing using EPMacro and ExpandObjects: + + `energyplus -w weather -m -x input.imf` + +3. Forcing design-day only simulations: + + `energyplus -D input.idf` + +4. Giving all output files the prefix being the same as the input file (`building.idf`) and placing them in a directory called `output`: + + `energyplus -w weather -p building -d output building.idf` + +Legacy Mode +----------- + +The command line interface is a new feature as of EnergyPlus 8.X. Prior to version 8.X, the EnergyPlus executable took no command line arguments, and instead expected the IDD (Input Data Dictionary) file and the IDF files to be located in the current working directory and named `Energy+.idd` and `in.idf` respectively. If a weather file was required by the simulation, then an `in.epw` file was also required in the same directory. This behavior is still respected if no arguments are passed on the command line. \ No newline at end of file diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 5cd1686094f..7a9b72b6f64 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -145,7 +145,7 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); - opt.add("", 0, 1, 0, "Output directory path (default: INPUTFILE-output)", "-d", "--output-directory"); + opt.add("", 0, 1, 0, "Output directory path (default: INPUTFILE-output in current directory)", "-d", "--output-directory"); opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--design-day"); @@ -153,17 +153,17 @@ ProcessArgs(int argc, const char * argv[]) opt.add("Energy+.idd", 0, 1, 0, "Input data dictionary path (default: Energy+.idd in executable directory)", "-i", "--idd"); - opt.add("", 0, 0, 0, "Run EPMacro", "-m", "--epmacro"); + opt.add("", 0, 0, 0, "Run EPMacro prior to simulation", "-m", "--epmacro"); opt.add("", 0, 1, 0, "Prefix for output file names (default: ep)", "-p", "--output-prefix"); - opt.add("", 0, 0, 0, "Run ReadVarsESO", "-r", "--readvars"); + opt.add("", 0, 0, 0, "Run ReadVarsESO after simulation", "-r", "--readvars"); opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); - opt.add("in.epw", 0, 1, 0, "Weather file path (default: in.epw)", "-w", "--weather"); + opt.add("in.epw", 0, 1, 0, "Weather file path (default: in.epw in current directory)", "-w", "--weather"); - opt.add("", 0, 0, 0, "Run ExpandObjects", "-x", "--expandobjects"); + opt.add("", 0, 0, 0, "Run ExpandObjects prior to simulation", "-x", "--expandobjects"); opt.example = "energyplus -w weather.epw -r input.idf"; From c5bedeb59fe2bba3ef6a1add15073bf89ed0ab0f Mon Sep 17 00:00:00 2001 From: nealkruis Date: Tue, 20 Jan 2015 14:36:23 -0700 Subject: [PATCH 60/71] Change default output file behavior to behave similarly to previous executables. --- doc/man/energyplus.1 | 24 +- doc/running-energyplus-from-command-line.md | 14 +- src/EnergyPlus/CommandLineInterface.cc | 248 ++++++++++---------- 3 files changed, 149 insertions(+), 137 deletions(-) diff --git a/doc/man/energyplus.1 b/doc/man/energyplus.1 index 8501f97f998..ac202ae7514 100644 --- a/doc/man/energyplus.1 +++ b/doc/man/energyplus.1 @@ -35,7 +35,7 @@ Force annual simulation .RE .TP .B \-d, \-\-output\-directory \f[I]ARG\f[] -Output directory path (default: \f[I]INPUTFILE\f[]-output in current directory) +Output directory path (default: current directory) .RS .RE .TP @@ -60,7 +60,7 @@ Run EPMacro prior to simulation .RE .TP .B \-p, \-\-output\-prefix \f[I]ARG\f[] -Prefix for output file names (default: ep) +Prefix for output file names (default: eplus) .RS .RE .TP @@ -69,6 +69,14 @@ Run ReadVarsESO after simulation .RS .RE .TP +.B \-s, \-\-output\-suffix \f[I]ARG\f[] +Suffix style for output file names (default: L) + L: Legacy (e.g., eplustbl.csv) + C: Capital (e.g., eplusTable.csv) + D: Dash (e.g., eplus-table.csv) +.RS +.RE +.TP .B \-v, \-\-version Display version information .RS @@ -80,4 +88,14 @@ Weather file path (default: in.epw in current directory) .RE .TP .B \-x, \-\-expandobjects -Run ExpandObjects prior to simulation \ No newline at end of file +Run ExpandObjects prior to simulation +.SH EXAMPLES +.SS Using a custom IDD file: +energyplus -i custom.idd -w weather.epw input.idf +.SS Pre-processing using EPMacro and ExpandObjects: + +energyplus -w weather.epw -m -x input.imf + +.SS Forcing design-day only simulations: + +energyplus -D input.idf \ No newline at end of file diff --git a/doc/running-energyplus-from-command-line.md b/doc/running-energyplus-from-command-line.md index 2264afcce9d..5f9363a9d6a 100644 --- a/doc/running-energyplus-from-command-line.md +++ b/doc/running-energyplus-from-command-line.md @@ -11,15 +11,18 @@ This will give the following display of options: Usage: energyplus [options] [input-file] Options: -a, --annual Force annual simulation - -d, --output-directory ARG Output directory path (default: INPUTFILE-output - in current directory) + -d, --output-directory ARG Output directory path (default: current directory) -D, --design-day Force design-day-only simulation -h, --help Display help information -i, --idd ARG Input data dictionary path (default: Energy+.idd in executable directory) -m, --epmacro Run EPMacro prior to simulation - -p, --output-prefix ARG Prefix for output file names (default: ep) + -p, --output-prefix ARG Prefix for output file names (default: eplus) -r, --readvars Run ReadVarsESO after simulation + -s, --output-suffix ARG Suffix style for output file names (default: L) + L: Legacy (e.g., eplustbl.csv) + C: Capital (e.g., eplusTable.csv) + D: Dash (e.g., eplus-table.csv) -v, --version Display version information -w, --weather ARG Weather file path (default: in.epw in current directory)) @@ -40,6 +43,7 @@ The options generally fall into four categories: - `weather` - `output-directory` - `output-prefix` + - `output-suffix` 3. Pre- and post-processing switches: - `epmacro` - `expandobjects` @@ -53,11 +57,11 @@ Examples 1. Using a custom IDD file: - `energyplus -i custom.idd -w weather input.idf` + `energyplus -i custom.idd -w weather.epw input.idf` 2. Pre-processing using EPMacro and ExpandObjects: - `energyplus -w weather -m -x input.imf` + `energyplus -w weather.epw -m -x input.imf` 3. Forcing design-day only simulations: diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 7a9b72b6f64..0057e9ed213 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -145,7 +145,7 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Force annual simulation", "-a", "--annual"); - opt.add("", 0, 1, 0, "Output directory path (default: INPUTFILE-output in current directory)", "-d", "--output-directory"); + opt.add("", 0, 1, 0, "Output directory path (default: current directory)", "-d", "--output-directory"); opt.add("", 0, 0, 0, "Force design-day-only simulation", "-D", "--design-day"); @@ -155,10 +155,12 @@ ProcessArgs(int argc, const char * argv[]) opt.add("", 0, 0, 0, "Run EPMacro prior to simulation", "-m", "--epmacro"); - opt.add("", 0, 1, 0, "Prefix for output file names (default: ep)", "-p", "--output-prefix"); + opt.add("", 0, 1, 0, "Prefix for output file names (default: eplus)", "-p", "--output-prefix"); opt.add("", 0, 0, 0, "Run ReadVarsESO after simulation", "-r", "--readvars"); + opt.add("L", 0, 1, 0, "Suffix style for output file names (default: L)\n L: Legacy (e.g., eplustbl.csv)\n C: Capital (e.g., eplusTable.csv)\n D: Dash (e.g., eplus-table.csv)", "-s", "--output-suffix"); + opt.add("", 0, 0, 0, "Display version information", "-v", "--version"); opt.add("in.epw", 0, 1, 0, "Weather file path (default: in.epw in current directory)", "-w", "--weather"); @@ -272,12 +274,6 @@ ProcessArgs(int argc, const char * argv[]) // Create directory if it doesn't already exist makeDirectory(dirPathName); } - else if (!legacyMode) - { - dirPathName = idfFileNameOnly + "-output" + pathChar; - // Create directory if it doesn't already exist - makeDirectory(dirPathName); - } // File naming scheme std::string outputFilePrefix; @@ -287,11 +283,12 @@ ProcessArgs(int argc, const char * argv[]) makeNativePath(prefixOutName); outputFilePrefix = dirPathName + prefixOutName; } - else if (!legacyMode) - outputFilePrefix = dirPathName + "ep"; else outputFilePrefix = dirPathName + "eplus"; + std::string suffixType; + opt.get("-s")->getString(suffixType); + std::string outputEpmdetFileName; std::string outputEpmidfFileName; @@ -299,129 +296,122 @@ ProcessArgs(int argc, const char * argv[]) std::string outputExpidfFileName; std::string outputExperrFileName; - if (legacyMode) { - // EnergyPlus files - 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"; - outputDelightInFileName = "eplusout.delightin"; - outputDelightOutFileName = "eplusout.delightout"; - outputDelightEldmpFileName = "eplusout.delighteldmp"; - outputDelightDfdmpFileName = "eplusout.delightdfdmp"; - outputMapTabFileName = outputFilePrefix + "map.tab"; - outputMapCsvFileName = outputFilePrefix + "map.csv"; - outputMapTxtFileName = outputFilePrefix + "map.txt"; - outputEddFileName = outputFilePrefix + "out.edd"; - outputIperrFileName = outputFilePrefix + "out.iperr"; - 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"; - outputSqlFileName = outputFilePrefix + "out.sql"; - outputSqliteErrFileName = dirPathName + "sqlite.err"; - outputDbgFileName = outputFilePrefix + "out.dbg"; - EnergyPlusIniFileName = "Energy+.ini"; - inStatFileName = weatherFilePathWithoutExtension + ".stat"; - TarcogIterationsFileName = "TarcogIterations.dbg"; - eplusADSFileName = idfDirPathName+"eplusADS.inp"; - - // Readvars files - outputCsvFileName = outputFilePrefix + "out.csv"; - outputMtrCsvFileName = outputFilePrefix + "mtr.csv"; - outputRvauditFileName = outputFilePrefix + "out.rvaudit"; - - // EPMacro files - outputEpmdetFileName = outputFilePrefix + "out.epmdet"; - outputEpmidfFileName = outputFilePrefix + "out.epmidf"; - - // ExpandObjects files - outputExpidfFileName = outputFilePrefix + "out.expidf"; - outputExperrFileName = outputFilePrefix + "out.experr"; + std::string normalSuffix; + std::string tableSuffix; + std::string mapSuffix; + std::string zszSuffix; + std::string sszSuffix; + std::string meterSuffix; + std::string sqliteSuffix; + std::string adsSuffix; + std::string screenSuffix; + + if (suffixType == "L" || suffixType == "l") { + + normalSuffix = "out"; + tableSuffix = "tbl"; + mapSuffix = "map"; + zszSuffix = "zsz"; + sszSuffix = "ssz"; + meterSuffix = "mtr"; + sqliteSuffix = "sqlite"; + adsSuffix = "ADS"; + screenSuffix = "screen"; + + } + else if (suffixType == "D" || suffixType == "d") { + + normalSuffix = ""; + tableSuffix = "-table"; + mapSuffix = "-map"; + zszSuffix = "-zsz"; + sszSuffix = "-ssz"; + meterSuffix = "-meter"; + sqliteSuffix = "-sqlite"; + adsSuffix = "-ads"; + screenSuffix = "-screen"; + + } + else if (suffixType == "C" || suffixType == "c") { + + normalSuffix = ""; + tableSuffix = "Table"; + mapSuffix = "Map"; + zszSuffix = "Zsz"; + sszSuffix = "Ssz"; + meterSuffix = "Meter"; + sqliteSuffix = "Sqlite"; + adsSuffix = "Ads"; + screenSuffix = "Screen"; + } else { - // EnergyPlus files - outputAuditFileName = outputFilePrefix + ".audit"; - outputBndFileName = outputFilePrefix + ".bnd"; - outputDxfFileName = outputFilePrefix + ".dxf"; - outputEioFileName = outputFilePrefix + ".eio"; - outputEndFileName = outputFilePrefix + ".end"; - outputErrFileName = outputFilePrefix + ".err"; - outputEsoFileName = outputFilePrefix + ".eso"; - outputMtdFileName = outputFilePrefix + ".mtd"; - outputMddFileName = outputFilePrefix + ".mdd"; - outputMtrFileName = outputFilePrefix + ".mtr"; - outputRddFileName = outputFilePrefix + ".rdd"; - outputShdFileName = outputFilePrefix + ".shd"; - outputTblCsvFileName = outputFilePrefix + "-table.csv"; - outputTblHtmFileName = outputFilePrefix + "-table.htm"; - outputTblTabFileName = outputFilePrefix + "-table.tab"; - outputTblTxtFileName = outputFilePrefix + "-table.txt"; - outputTblXmlFileName = outputFilePrefix + "-table.xml"; - outputAdsFileName = outputFilePrefix + "-ads.out"; - outputDfsFileName = outputFilePrefix + ".dfs"; - outputDelightInFileName = "eplusout.delightin"; - outputDelightOutFileName = "eplusout.delightout"; - outputDelightEldmpFileName = "eplusout.delighteldmp"; - outputDelightDfdmpFileName = "eplusout.delightdfdmp"; - outputMapTabFileName = outputFilePrefix + "-map.tab"; - outputMapCsvFileName = outputFilePrefix + "-map.csv"; - outputMapTxtFileName = outputFilePrefix + "-map.txt"; - outputEddFileName = outputFilePrefix + ".edd"; - outputIperrFileName = outputFilePrefix + ".iperr"; - outputSlnFileName = outputFilePrefix + ".sln"; - outputSciFileName = outputFilePrefix + ".sci"; - outputWrlFileName = outputFilePrefix + ".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"; - outputSqlFileName = outputFilePrefix + ".sql"; - outputSqliteErrFileName = outputFilePrefix + "-sqlite.err"; - outputDbgFileName = outputFilePrefix + ".dbg"; - EnergyPlusIniFileName = "Energy+.ini"; - inStatFileName = weatherFilePathWithoutExtension + ".stat"; - TarcogIterationsFileName = "TarcogIterations.dbg"; - eplusADSFileName = idfDirPathName+"eplusADS.inp"; - - // Readvars files - outputCsvFileName = outputFilePrefix + ".csv"; - outputMtrCsvFileName = outputFilePrefix + "Meter.csv"; - outputRvauditFileName = outputFilePrefix + ".rvaudit"; - - // EPMacro files - outputEpmdetFileName = outputFilePrefix + ".epmdet"; - outputEpmidfFileName = outputFilePrefix + ".epmidf"; - - // ExpandObjects files - outputExpidfFileName = outputFilePrefix + ".expidf"; - outputExperrFileName = outputFilePrefix + ".experr"; + DisplayString("ERROR: Unrecognized argument for output suffix style: " + suffixType); + DisplayString(errorFollowUp); + exit(EXIT_FAILURE); } + // EnergyPlus files + outputAuditFileName = outputFilePrefix + normalSuffix + ".audit"; + outputBndFileName = outputFilePrefix + normalSuffix + ".bnd"; + outputDxfFileName = outputFilePrefix + normalSuffix + ".dxf"; + outputEioFileName = outputFilePrefix + normalSuffix + ".eio"; + outputEndFileName = outputFilePrefix + normalSuffix + ".end"; + outputErrFileName = outputFilePrefix + normalSuffix + ".err"; + outputEsoFileName = outputFilePrefix + normalSuffix + ".eso"; + outputMtdFileName = outputFilePrefix + normalSuffix + ".mtd"; + outputMddFileName = outputFilePrefix + normalSuffix + ".mdd"; + outputMtrFileName = outputFilePrefix + normalSuffix + ".mtr"; + outputRddFileName = outputFilePrefix + normalSuffix + ".rdd"; + outputShdFileName = outputFilePrefix + normalSuffix + ".shd"; + outputDfsFileName = outputFilePrefix + normalSuffix + ".dfs"; + outputEddFileName = outputFilePrefix + normalSuffix + ".edd"; + outputIperrFileName = outputFilePrefix + normalSuffix + ".iperr"; + outputSlnFileName = outputFilePrefix + normalSuffix + ".sln"; + outputSciFileName = outputFilePrefix + normalSuffix + ".sci"; + outputWrlFileName = outputFilePrefix + normalSuffix + ".wrl"; + outputSqlFileName = outputFilePrefix + normalSuffix + ".sql"; + outputDbgFileName = outputFilePrefix + normalSuffix + ".dbg"; + outputTblCsvFileName = outputFilePrefix + tableSuffix + ".csv"; + outputTblHtmFileName = outputFilePrefix + tableSuffix + ".htm"; + outputTblTabFileName = outputFilePrefix + tableSuffix + ".tab"; + outputTblTxtFileName = outputFilePrefix + tableSuffix + ".txt"; + outputTblXmlFileName = outputFilePrefix + tableSuffix + ".xml"; + outputMapTabFileName = outputFilePrefix + mapSuffix + ".tab"; + outputMapCsvFileName = outputFilePrefix + mapSuffix + ".csv"; + outputMapTxtFileName = outputFilePrefix + mapSuffix + ".txt"; + outputZszCsvFileName = outputFilePrefix + zszSuffix + ".csv"; + outputZszTabFileName = outputFilePrefix + zszSuffix + ".tab"; + outputZszTxtFileName = outputFilePrefix + zszSuffix + ".txt"; + outputSszCsvFileName = outputFilePrefix + sszSuffix + ".csv"; + outputSszTabFileName = outputFilePrefix + sszSuffix + ".tab"; + outputSszTxtFileName = outputFilePrefix + sszSuffix + ".txt"; + outputAdsFileName = outputFilePrefix + adsSuffix + ".out"; + outputSqliteErrFileName = dirPathName + sqliteSuffix + ".err"; + outputScreenCsvFileName = outputFilePrefix + screenSuffix + ".csv"; + outputDelightInFileName = "eplusout.delightin"; + outputDelightOutFileName = "eplusout.delightout"; + outputDelightEldmpFileName = "eplusout.delighteldmp"; + outputDelightDfdmpFileName = "eplusout.delightdfdmp"; + EnergyPlusIniFileName = "Energy+.ini"; + inStatFileName = weatherFilePathWithoutExtension + ".stat"; + TarcogIterationsFileName = "TarcogIterations.dbg"; + eplusADSFileName = idfDirPathName+"eplusADS.inp"; + + // Readvars files + outputCsvFileName = outputFilePrefix + normalSuffix + ".csv"; + outputMtrCsvFileName = outputFilePrefix + meterSuffix + ".csv"; + outputRvauditFileName = outputFilePrefix + normalSuffix + ".rvaudit"; + + // EPMacro files + outputEpmdetFileName = outputFilePrefix + normalSuffix + ".epmdet"; + outputEpmidfFileName = outputFilePrefix + normalSuffix + ".epmidf"; + + // ExpandObjects files + outputExpidfFileName = outputFilePrefix + normalSuffix + ".expidf"; + outputExperrFileName = outputFilePrefix + normalSuffix + ".experr"; + + // Handle bad options if(!opt.gotExpected(badOptions)) { for(int i=0; i < badOptions.size(); ++i) { From 9c6e5bac232daa926bb6c34289b64181f8628e14 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Wed, 21 Jan 2015 09:17:29 -0700 Subject: [PATCH 61/71] Fix integration tests for reverted output file names. --- cmake/RunCallbackTest.cmake | 10 +++++----- cmake/RunCommandLineArgTest.cmake | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmake/RunCallbackTest.cmake b/cmake/RunCallbackTest.cmake index 5f047206e90..d95380af204 100644 --- a/cmake/RunCallbackTest.cmake +++ b/cmake/RunCallbackTest.cmake @@ -1,12 +1,12 @@ # Set up for convenience set(TEST_DIR "tst/api_callback") set( ENV{DDONLY} y) - + # Currently the TestEnergyPlusCallbacks runner does not exit. Give it an idf and supporting files so that it will run. execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${SOURCE_DIR}/testfiles/${IDF_FILE}" "${BINARY_DIR}/${TEST_DIR}/in.idf" ) execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${SOURCE_DIR}/weather/${EPW_FILE}" "${BINARY_DIR}/${TEST_DIR}/in.epw" ) execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINARY_DIR}/Energy+.idd" "${BINARY_DIR}/${TEST_DIR}/Energy+.idd" ) - + # Find and execute the test executable, passing the argument of the directory to run in if( WIN32 ) set(ECHO_CMD cmd /C echo.) @@ -17,12 +17,12 @@ message( "Executing TestEnergyPlusCallbacks from ${TEST_EXE}" ) message( "Passing run directory as ${TEST_DIR}" ) execute_process(COMMAND ${ECHO_CMD} COMMAND "${TEST_EXE}" "${BINARY_DIR}/${TEST_DIR}") - + # Clean up execute_process(COMMAND "${CMAKE_COMMAND}" -E remove "${BINARY_DIR}/${TEST_DIR}/Energy+.idd" "${BINARY_DIR}/${TEST_DIR}/in.epw" ) - + # Check the outputs and return appropriately - file(READ "${BINARY_DIR}/${TEST_DIR}/in-output/ep.end" FILE_CONTENT) + file(READ "${BINARY_DIR}/${TEST_DIR}/eplusout.end" FILE_CONTENT) string(FIND "${FILE_CONTENT}" "EnergyPlus Completed Successfully" RESULT) if( RESULT EQUAL 0 ) message("Test Passed") diff --git a/cmake/RunCommandLineArgTest.cmake b/cmake/RunCommandLineArgTest.cmake index f196e152f5f..3314e1cd8a5 100644 --- a/cmake/RunCommandLineArgTest.cmake +++ b/cmake/RunCommandLineArgTest.cmake @@ -1,6 +1,6 @@ # Set up for convenience set(TEST_DIR "tst/cli_args") - + # Find and execute the test executable, passing the argument of the directory to run in if( WIN32 ) set(ECHO_CMD cmd /C echo.) @@ -9,9 +9,9 @@ endif() find_program(TEST_EXE "energyplus" PATHS "${BINARY_DIR}/Products/" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) execute_process(COMMAND ${ECHO_CMD} COMMAND "${TEST_EXE}" -d "${BINARY_DIR}/${TEST_DIR}" -D "${SOURCE_DIR}/testfiles/${IDF_FILE}" RESULT_VARIABLE RESULT) - + # Check the outputs and return appropriately - file(READ "${BINARY_DIR}/${TEST_DIR}/ep.end" FILE_CONTENT) + file(READ "${BINARY_DIR}/${TEST_DIR}/eplusout.end" FILE_CONTENT) string(FIND "${FILE_CONTENT}" "EnergyPlus Completed Successfully" RESULT) if( RESULT EQUAL 0 ) message("Test Passed") From 7d6914daa247c11709133ea7f65f73bc7046c110 Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Wed, 21 Jan 2015 15:40:02 -0600 Subject: [PATCH 62/71] export CLI through API [#1277852] --- src/EnergyPlus/CMakeLists.txt | 6 +++--- src/EnergyPlus/CommandLineInterface.hh | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 37f92cc7074..fdfe07f50fb 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -44,8 +44,8 @@ SET( SRC ChillerIndirectAbsorption.hh ChillerReformulatedEIR.cc ChillerReformulatedEIR.hh - CommandLineInterface.cc - CommandLineInterface.hh + #CommandLineInterface.cc + #CommandLineInterface.hh CondenserLoopTowers.cc CondenserLoopTowers.hh ConductionTransferFunctionCalc.cc @@ -556,7 +556,7 @@ endif() # second we will create the shared library that is actually packaged with EnergyPlus -add_library( energyplusapi SHARED "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) +add_library( energyplusapi SHARED CommandLineInterface.hh CommandLineInterface.cc EnergyPlusPgm.cc public/EnergyPlusPgm.hh ) target_link_libraries( energyplusapi energypluslib energypluslib2 ) diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index 81bbf8bbb5c..fee2c319259 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -2,6 +2,7 @@ #define CommandLineInterface_hh_INCLUDED #include +#include namespace EnergyPlus{ namespace CommandLineInterface { @@ -69,7 +70,7 @@ namespace CommandLineInterface { // Process command line arguments int - ProcessArgs( int argc, const char * argv[] ); + ENERGYPLUSLIB_API ProcessArgs( int argc, const char * argv[] ); void ReadINIFile( From 2b140e0e4c467360c886105281e6d3a9a3c0bf67 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Thu, 22 Jan 2015 12:26:11 -0700 Subject: [PATCH 63/71] Fix bug in option parser header affecting MSVC Debug builds. --- third_party/CLI/ezOptionParser.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/third_party/CLI/ezOptionParser.hpp b/third_party/CLI/ezOptionParser.hpp index 9d360b7adb8..12be0aff89b 100644 --- a/third_party/CLI/ezOptionParser.hpp +++ b/third_party/CLI/ezOptionParser.hpp @@ -1871,9 +1871,10 @@ void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout // All the following split-fu could be optimized by just using substring (offset, length) tuples, but just to get it done, we'll do some not-too expensive string copying. SplitDelim(groups[k]->help, '\n', desc); // Split lines longer than allowable help width. - for(insertionIter=desc.begin(), cIter=insertionIter++; + for(insertionIter=desc.begin(), cIter=insertionIter; cIter != desc.end(); - cIter=insertionIter++) { + cIter=insertionIter) { + insertionIter++; if ((long int)((*cIter)->size()) > helpwidth) { // Get pointer to next string to insert new strings before it. std::string *rem = *cIter; From 40b725fa2ef0351baf04ffdef166659d9d19fdc4 Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Fri, 23 Jan 2015 15:59:18 -0600 Subject: [PATCH 64/71] Move global data out of CLI [#1277852] --- src/EnergyPlus/AirflowNetworkSolver.cc | 7 ++- src/EnergyPlus/CommandLineInterface.cc | 60 ------------------- src/EnergyPlus/CommandLineInterface.hh | 65 +-------------------- src/EnergyPlus/DElightManagerF.cc | 1 - src/EnergyPlus/DataGlobals.cc | 3 + src/EnergyPlus/DataGlobals.hh | 4 ++ src/EnergyPlus/DataStringGlobals.hh | 57 ++++++++++++++++++ src/EnergyPlus/DataStringGlobals.in.cc | 56 ++++++++++++++++++ src/EnergyPlus/DataSystemVariables.cc | 9 ++- src/EnergyPlus/DataTimings.cc | 1 - src/EnergyPlus/DaylightingManager.cc | 33 +++++------ src/EnergyPlus/EMSManager.cc | 6 +- src/EnergyPlus/EnergyPlusPgm.cc | 3 +- src/EnergyPlus/HeatBalanceSurfaceManager.cc | 6 +- src/EnergyPlus/InputProcessor.cc | 1 - src/EnergyPlus/OutputProcessor.cc | 41 +++++++------ src/EnergyPlus/OutputReportTabular.cc | 29 +++++---- src/EnergyPlus/OutputReports.cc | 26 ++++----- src/EnergyPlus/Psychrometrics.cc | 1 - src/EnergyPlus/SQLiteProcedures.cc | 6 +- src/EnergyPlus/ScheduleManager.cc | 3 +- src/EnergyPlus/SimulationManager.cc | 21 ++++--- src/EnergyPlus/SizingManager.cc | 25 ++++---- src/EnergyPlus/SolarShading.cc | 6 +- src/EnergyPlus/TARCOGOutput.cc | 6 +- src/EnergyPlus/ThermalComfort.cc | 20 +++---- src/EnergyPlus/UtilityRoutines.cc | 16 ++--- src/EnergyPlus/WeatherManager.cc | 10 ++-- src/EnergyPlus/WindTurbine.cc | 12 ++-- src/EnergyPlus/WindowManager.cc | 4 +- 30 files changed, 261 insertions(+), 277 deletions(-) diff --git a/src/EnergyPlus/AirflowNetworkSolver.cc b/src/EnergyPlus/AirflowNetworkSolver.cc index 72c24915dec..bac07f79d91 100644 --- a/src/EnergyPlus/AirflowNetworkSolver.cc +++ b/src/EnergyPlus/AirflowNetworkSolver.cc @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -55,7 +57,6 @@ namespace AirflowNetworkSolver { // USE STATEMENTS: // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataGlobals::Pi; using DataGlobals::DegToRadians; @@ -219,7 +220,7 @@ namespace AirflowNetworkSolver { LIST = 0; if ( LIST >= 1 ) { Unit21 = GetNewUnitNumber(); - gio::open( Unit21, outputAdsFileName ); + gio::open( Unit21, DataStringGlobals::outputAdsFileName ); } for ( n = 1; n <= NetworkNumOfNodes; ++n ) { @@ -244,7 +245,7 @@ namespace AirflowNetworkSolver { // Write an ouput file used for AIRNET input if ( LIST >= 5 ) { Unit11 = GetNewUnitNumber(); - gio::open( Unit11, eplusADSFileName ); + gio::open( Unit11, DataStringGlobals::eplusADSFileName ); for ( i = 1; i <= NetworkNumOfNodes; ++i ) { gio::write( Unit11, Format_901 ) << i << AirflowNetworkNodeData( i ).NodeTypeNum << AirflowNetworkNodeData( i ).NodeHeight << TZ( i ) << PZ( i ); } diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 0057e9ed213..2435e9aefb4 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -35,66 +35,6 @@ using namespace OutputProcessor; using namespace SolarShading; using namespace ez; -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 outputDelightInFileName; -std::string outputDelightOutFileName; -std::string outputDelightEldmpFileName; -std::string outputDelightDfdmpFileName; -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 outputSqlFileName; -std::string outputSqliteErrFileName; -std::string EnergyPlusIniFileName; -std::string inStatFileName; -std::string TarcogIterationsFileName; -std::string eplusADSFileName; -std::string outputCsvFileName; -std::string outputMtrCsvFileName; -std::string outputRvauditFileName; - -std::string idfFileNameOnly; -std::string idfDirPathName; -std::string exeDirectory; - -bool runReadVars(false); -bool DDOnlySimulation(false); -bool AnnualSimulation(false); - int ProcessArgs(int argc, const char * argv[]) { diff --git a/src/EnergyPlus/CommandLineInterface.hh b/src/EnergyPlus/CommandLineInterface.hh index fee2c319259..0df4e3015b6 100644 --- a/src/EnergyPlus/CommandLineInterface.hh +++ b/src/EnergyPlus/CommandLineInterface.hh @@ -7,67 +7,6 @@ namespace EnergyPlus{ namespace CommandLineInterface { - 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 outputDelightInFileName; - extern std::string outputDelightOutFileName; - extern std::string outputDelightEldmpFileName; - extern std::string outputDelightDfdmpFileName; - 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 outputSqlFileName; - extern std::string outputSqliteErrFileName; - extern std::string EnergyPlusIniFileName; - extern std::string inStatFileName; - extern std::string TarcogIterationsFileName; - extern std::string eplusADSFileName; - extern std::string outputCsvFileName; - extern std::string outputMtrCsvFileName; - extern std::string outputRvauditFileName; - - extern std::string weatherFileNameOnly; - extern std::string idfDirPathName; - extern std::string idfFileNameOnly; - extern std::string exeDirectory; - - extern bool runReadVars; - extern bool DDOnlySimulation; - extern bool AnnualSimulation; - // Process command line arguments int ENERGYPLUSLIB_API ProcessArgs( int argc, const char * argv[] ); @@ -80,7 +19,7 @@ namespace CommandLineInterface { std::string & DataOut // Output from the retrieval ); - } +} // CommandLineInterface -} +} // EnergyPlus #endif diff --git a/src/EnergyPlus/DElightManagerF.cc b/src/EnergyPlus/DElightManagerF.cc index afe2b6ae227..a4924ba46e6 100644 --- a/src/EnergyPlus/DElightManagerF.cc +++ b/src/EnergyPlus/DElightManagerF.cc @@ -82,7 +82,6 @@ namespace DElightManagerF { // This subroutine creates a DElight input file from EnergyPlus processed input. // USE STATEMENTS: - using namespace CommandLineInterface; using namespace DataGlobals; // Gives access to too many things to keep track of using namespace DataHeatBalance; // Gives access to Building, Zone(izone)%var and Lights(ilights) data using namespace DataEnvironment; // Gives access to Site data diff --git a/src/EnergyPlus/DataGlobals.cc b/src/EnergyPlus/DataGlobals.cc index a92bd1aca45..c83d196c1e9 100644 --- a/src/EnergyPlus/DataGlobals.cc +++ b/src/EnergyPlus/DataGlobals.cc @@ -42,6 +42,9 @@ namespace DataGlobals { // Data // -only module should be available to other modules and routines. // Thus, all variables in this module must be PUBLIC. + bool runReadVars(false); + bool DDOnlySimulation(false); + bool AnnualSimulation(false); // MODULE PARAMETER DEFINITIONS: int const BeginDay( 1 ); diff --git a/src/EnergyPlus/DataGlobals.hh b/src/EnergyPlus/DataGlobals.hh index 797b8281e58..1ebcb8880e4 100644 --- a/src/EnergyPlus/DataGlobals.hh +++ b/src/EnergyPlus/DataGlobals.hh @@ -16,6 +16,10 @@ namespace DataGlobals { // -only module should be available to other modules and routines. // Thus, all variables in this module must be PUBLIC. + extern bool runReadVars; + extern bool DDOnlySimulation; + extern bool AnnualSimulation; + // MODULE PARAMETER DEFINITIONS: extern int const BeginDay; extern int const DuringDay; diff --git a/src/EnergyPlus/DataStringGlobals.hh b/src/EnergyPlus/DataStringGlobals.hh index 79bbd407f2e..5d63326f65c 100644 --- a/src/EnergyPlus/DataStringGlobals.hh +++ b/src/EnergyPlus/DataStringGlobals.hh @@ -15,6 +15,63 @@ namespace DataStringGlobals { // -only module should be available to other modules and routines. // Thus, all variables in this module must be PUBLIC. + 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 outputDelightInFileName; + extern std::string outputDelightOutFileName; + extern std::string outputDelightEldmpFileName; + extern std::string outputDelightDfdmpFileName; + 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 outputSqlFileName; + extern std::string outputSqliteErrFileName; + extern std::string EnergyPlusIniFileName; + extern std::string inStatFileName; + extern std::string TarcogIterationsFileName; + extern std::string eplusADSFileName; + extern std::string outputCsvFileName; + extern std::string outputMtrCsvFileName; + extern std::string outputRvauditFileName; + + extern std::string weatherFileNameOnly; + extern std::string idfDirPathName; + extern std::string idfFileNameOnly; + extern std::string exeDirectory; + // MODULE PARAMETER DEFINITIONS: extern std::string const UpperCase; extern std::string const LowerCase; diff --git a/src/EnergyPlus/DataStringGlobals.in.cc b/src/EnergyPlus/DataStringGlobals.in.cc index 978343b8c70..35233783ea6 100644 --- a/src/EnergyPlus/DataStringGlobals.in.cc +++ b/src/EnergyPlus/DataStringGlobals.in.cc @@ -72,6 +72,62 @@ namespace DataStringGlobals { // na // MODULE VARIABLE DECLARATIONS: + 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 outputDelightInFileName; + std::string outputDelightOutFileName; + std::string outputDelightEldmpFileName; + std::string outputDelightDfdmpFileName; + 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 outputSqlFileName; + std::string outputSqliteErrFileName; + std::string EnergyPlusIniFileName; + std::string inStatFileName; + std::string TarcogIterationsFileName; + std::string eplusADSFileName; + std::string outputCsvFileName; + std::string outputMtrCsvFileName; + std::string outputRvauditFileName; + + std::string idfFileNameOnly; + std::string idfDirPathName; + std::string exeDirectory; + std::string ProgramPath; // Path for Program from INI file std::string CurrentWorkingFolder; // Current working directory for run std::string IDDVerString; // Version information from the IDD (line 1) diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index a0cc5042a98..1d048a351e8 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -35,7 +35,6 @@ namespace DataSystemVariables { // na // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataStringGlobals::pathChar; using DataStringGlobals::altpathChar; @@ -189,7 +188,7 @@ namespace DataSystemVariables { std::string::size_type pos; if ( firstTime ) { - EchoInputFile = FindUnitNumber( outputAuditFileName ); + EchoInputFile = FindUnitNumber( DataStringGlobals::outputAuditFileName ); get_environment_variable( cInputPath1, envinputpath1 ); if ( envinputpath1 != blank ) { pos = index( envinputpath1, pathChar, true ); // look backwards for pathChar @@ -215,14 +214,14 @@ namespace DataSystemVariables { } // Look relative to input file path - { IOFlags flags; gio::inquire( idfDirPathName + InputFileName, flags ); FileExist = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::idfDirPathName + InputFileName, flags ); FileExist = flags.exists(); } if ( FileExist ) { FileFound = true; - CheckedFileName = idfDirPathName + InputFileName; + CheckedFileName = DataStringGlobals::idfDirPathName + InputFileName; gio::write(EchoInputFile, fmtA) << "found (idf)=" + getAbsolutePath(CheckedFileName); return; } else { - gio::write(EchoInputFile, fmtA) << "not found (idf)=" + getAbsolutePath(idfDirPathName + InputFileName); + gio::write(EchoInputFile, fmtA) << "not found (idf)=" + getAbsolutePath(DataStringGlobals::idfDirPathName + InputFileName); } // Look relative to input path diff --git a/src/EnergyPlus/DataTimings.cc b/src/EnergyPlus/DataTimings.cc index 4d889ecf774..3233c8de97f 100644 --- a/src/EnergyPlus/DataTimings.cc +++ b/src/EnergyPlus/DataTimings.cc @@ -41,7 +41,6 @@ namespace DataTimings { // Using/Aliasing using namespace DataPrecisionGlobals; - using namespace CommandLineInterface; using DataSystemVariables::tabchar; using DataSystemVariables::DeveloperFlag; diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index ce15e3f4314..73ad78f22ae 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -92,7 +92,6 @@ namespace DaylightingManager { // DLUMEF DayltgLuminousEfficacy WeatherManager WeatherManager // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataHeatBalance; @@ -685,9 +684,9 @@ namespace DaylightingManager { // open a new file eplusout.dfs for saving the daylight factors if ( CreateDFSReportFile ) { OutputFileDFS = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDFS, outputDfsFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileDFS, DataStringGlobals::outputDfsFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "CalcDayltgCoefficients: Could not open file "+outputDfsFileName+" for output (write)." ); + ShowFatalError( "CalcDayltgCoefficients: Could not open file "+DataStringGlobals::outputDfsFileName+" for output (write)." ); } else { gio::write( OutputFileDFS, fmtA ) << "This file contains daylight factors for all exterior windows of daylight zones."; gio::write( OutputFileDFS, fmtA ) << "If only one reference point the last 4 columns in the data will be zero."; @@ -4188,7 +4187,7 @@ namespace DaylightingManager { if ( iErrorFlag != 0 ) { // Open DElight Daylight Factors Error File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, DataStringGlobals::outputDelightDfdmpFileName, flags ); } // Sequentially read lines in DElight Daylight Factors Error File // and process them using standard EPlus warning/error handling calls @@ -4229,7 +4228,7 @@ namespace DaylightingManager { } else { // Open, Close, and Delete DElight Daylight Factors Error File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, DataStringGlobals::outputDelightDfdmpFileName, flags ); } { IOFlags flags; flags.DISPOSE( "DELETE" ); gio::close( iDElightErrorFile, flags ); } } SetupDElightOutput4EPlus(); @@ -9309,13 +9308,13 @@ namespace DaylightingManager { IllumMap( MapNum ).UnitNo = GetNewUnitNumber(); MapNoString = RoundSigDigits( MapNum ); if ( MapColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, outputMapTabFileName + MapNoString, flags ); if ( flags.err() ) goto Label901; } + { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, DataStringGlobals::outputMapTabFileName + MapNoString, flags ); if ( flags.err() ) goto Label901; } CommaDelimited = false; } else if ( MapColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, outputMapCsvFileName + MapNoString, flags ); if ( flags.err() ) goto Label902; } + { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, DataStringGlobals::outputMapCsvFileName + MapNoString, flags ); if ( flags.err() ) goto Label902; } CommaDelimited = true; } else { - { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, outputMapTxtFileName + MapNoString, flags ); if ( flags.err() ) goto Label903; } + { IOFlags flags; flags.ACTION( "readwrite" ); flags.STATUS( "UNKNOWN" ); gio::open( IllumMap( MapNum ).UnitNo, DataStringGlobals::outputMapTxtFileName + MapNoString, flags ); if ( flags.err() ) goto Label903; } CommaDelimited = false; } @@ -9421,15 +9420,15 @@ namespace DaylightingManager { return; Label901: ; - ShowFatalError( "ReportIllumMap: Could not open file "+ outputMapTabFileName + MapNoString + "\" for output (write)." ); + ShowFatalError( "ReportIllumMap: Could not open file "+ DataStringGlobals::outputMapTabFileName + MapNoString + "\" for output (write)." ); return; Label902: ; - ShowFatalError( "ReportIllumMap: Could not open file "+ outputMapCsvFileName + MapNoString + "\" for output (write)." ); + ShowFatalError( "ReportIllumMap: Could not open file "+ DataStringGlobals::outputMapCsvFileName + MapNoString + "\" for output (write)." ); return; Label903: ; - ShowFatalError( "ReportIllumMap: Could not open file "+ outputMapTxtFileName + MapNoString + "\" for output (write)." ); + ShowFatalError( "ReportIllumMap: Could not open file "+ DataStringGlobals::outputMapTxtFileName + MapNoString + "\" for output (write)." ); } @@ -9485,11 +9484,11 @@ Label903: ; // Write map header if ( MapColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, outputMapTabFileName, flags ); if ( flags.err() ) goto Label901; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, DataStringGlobals::outputMapTabFileName, flags ); if ( flags.err() ) goto Label901; } } else if ( MapColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, outputMapCsvFileName, flags ); if ( flags.err() ) goto Label902; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, DataStringGlobals::outputMapCsvFileName, flags ); if ( flags.err() ) goto Label902; } } else { - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, outputMapTxtFileName, flags ); if ( flags.err() ) goto Label903; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( MapOutputFile, DataStringGlobals::outputMapTxtFileName, flags ); if ( flags.err() ) goto Label903; } } for ( MapNum = 1; MapNum <= TotIllumMaps; ++MapNum ) { @@ -9525,15 +9524,15 @@ Label903: ; return; Label901: ; - ShowFatalError( "CloseReportIllumMaps: Could not open file "+outputMapTabFileName+" for output (write)." ); + ShowFatalError( "CloseReportIllumMaps: Could not open file "+DataStringGlobals::outputMapTabFileName+" for output (write)." ); return; Label902: ; - ShowFatalError( "CloseReportIllumMaps: Could not open file "+outputMapCsvFileName+" for output (write)." ); + ShowFatalError( "CloseReportIllumMaps: Could not open file "+DataStringGlobals::outputMapCsvFileName+" for output (write)." ); return; Label903: ; - ShowFatalError( "CloseReportIllumMaps: Could not open file "+outputMapTxtFileName+" for output (write)." ); + ShowFatalError( "CloseReportIllumMaps: Could not open file "+DataStringGlobals::outputMapTxtFileName+" for output (write)." ); } diff --git a/src/EnergyPlus/EMSManager.cc b/src/EnergyPlus/EMSManager.cc index 5bb78bb1e75..f02a0c1bec2 100644 --- a/src/EnergyPlus/EMSManager.cc +++ b/src/EnergyPlus/EMSManager.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -47,7 +48,6 @@ namespace EMSManager { // METHODOLOGY EMPLOYED: // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataRuntimeLanguage; @@ -191,9 +191,9 @@ namespace EMSManager { if ( OutputEDDFile ) { // open up output file for EMS EDD file EMS Data and Debug OutputEMSFileUnitNum = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputEMSFileUnitNum, outputEddFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputEMSFileUnitNum, DataStringGlobals::outputEddFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "CheckIFAnyEMS: Could not open file "+ outputEddFileName +" for output (write)." ); + ShowFatalError( "CheckIFAnyEMS: Could not open file "+ DataStringGlobals::outputEddFileName +" for output (write)." ); } } } else { diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index ac304d44a23..cbce188cc44 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -220,7 +220,6 @@ EnergyPlusPgm( std::string filepath ) using DataEnvironment::IgnoreBeamRadiation; using DataEnvironment::IgnoreDiffuseRadiation; // routine modules - using namespace CommandLineInterface; using namespace FileSystem; using namespace InputProcessor; using namespace OutputProcessor; @@ -368,7 +367,7 @@ EnergyPlusPgm( std::string filepath ) ProgramPath = filepath + pathChar; int dummy_argc = 0; const char * dummy_argv[] = { NULL }; - ProcessArgs( dummy_argc, dummy_argv ); + CommandLineInterface::ProcessArgs( dummy_argc, dummy_argv ); } TestAllPaths = true; diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 65951e71281..ebfe54da73b 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -98,7 +99,6 @@ namespace HeatBalanceSurfaceManager { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataEnvironment; @@ -492,7 +492,7 @@ namespace HeatBalanceSurfaceManager { // Open DElight Electric Lighting Error File for reading iDElightErrorFile = GetNewUnitNumber(); // RJH 2008-03-07: open file with READWRITE - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); iwriteStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, DataStringGlobals::outputDelightDfdmpFileName, flags ); iwriteStatus = flags.ios(); } if ( iwriteStatus == 0 ) { elOpened = true; } else { @@ -536,7 +536,7 @@ namespace HeatBalanceSurfaceManager { // extract reference point illuminance values from DElight Electric Lighting dump file for reporting // Open DElight Electric Lighting Dump File for reading iDElightErrorFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, outputDelightDfdmpFileName, flags ); iwriteStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READWRITE" ); gio::open( iDElightErrorFile, DataStringGlobals::outputDelightDfdmpFileName, flags ); iwriteStatus = flags.ios(); } // IF (iwriteStatus /= 0) THEN // CALL ShowFatalError('InitSurfaceHeatBalance: Could not open file "eplusout.delighteldmp" for output (readwrite).') // ENDIF diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index fe2f8278fc6..ba7c9077932 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -55,7 +55,6 @@ namespace InputProcessor { // Use statements for data only modules // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataStringGlobals; using DataGlobals::MaxNameLength; diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 5bc9f192c59..71750bec743 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -59,7 +59,6 @@ namespace OutputProcessor { // na // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataGlobals::MaxNameLength; using DataGlobals::OutputFileMeters; @@ -1381,9 +1380,9 @@ namespace OutputProcessor { int write_stat; OutputFileMeterDetails = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMeterDetails, outputMtdFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileMeterDetails, DataStringGlobals::outputMtdFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "InitializeMeters: Could not open file "+outputMtdFileName+" for output (write)." ); + ShowFatalError( "InitializeMeters: Could not open file "+DataStringGlobals::outputMtdFileName+" for output (write)." ); } } @@ -6351,7 +6350,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptTS ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both " + outputEsoFileName + " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both " + DataStringGlobals::outputEsoFileName + " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptTS ) { @@ -6364,7 +6363,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccTS ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (TimeStep), " "already on \"Output:Meter\". Will report to both "+DataStringGlobals::outputEsoFileName+ " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccTS ) { @@ -6379,7 +6378,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptHR ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFileName + " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + DataStringGlobals::outputEsoFileName + " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptHR ) { @@ -6393,7 +6392,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccHR ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + outputEsoFileName + " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both " + DataStringGlobals::outputEsoFileName + " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccHR ) { @@ -6409,7 +6408,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptDY ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Daily), " "already on \"Output:Meter\". Will report to both " +outputEsoFileName+ " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Daily), " "already on \"Output:Meter\". Will report to both " +DataStringGlobals::outputEsoFileName+ " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptDY ) { @@ -6423,7 +6422,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccDY ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Hourly), " "already on \"Output:Meter\". Will report to both "+DataStringGlobals::outputEsoFileName+ " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccDY ) { @@ -6439,7 +6438,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptMN ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+DataStringGlobals::outputEsoFileName+ " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptMN ) { @@ -6453,7 +6452,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccMN ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+ " and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (Monthly), " "already on \"Output:Meter\". Will report to both "+DataStringGlobals::outputEsoFileName+ " and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccMN ) { @@ -6469,7 +6468,7 @@ SetInitialMeterReportingAndOutputNames( if ( ! CumulativeIndicator ) { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptSM ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+" and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"" + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+DataStringGlobals::outputEsoFileName+" and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptSM ) { @@ -6483,7 +6482,7 @@ SetInitialMeterReportingAndOutputNames( } else { if ( MeterFileOnlyIndicator ) { if ( EnergyMeters( WhichMeter ).RptAccSM ) { - ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+outputEsoFileName+" and " +outputMtrFileName ); + ShowWarningError( "Output:Meter:MeterFileOnly requested for \"Cumulative " + EnergyMeters( WhichMeter ).Name + "\" (RunPeriod), " "already on \"Output:Meter\". Will report to both "+DataStringGlobals::outputEsoFileName+" and " +DataStringGlobals::outputMtrFileName ); } } if ( ! EnergyMeters( WhichMeter ).RptAccSM ) { @@ -7863,28 +7862,28 @@ ProduceRDDMDD() std::ofstream rdd_stream; std::ofstream mdd_stream; if ( ProduceReportVDD == ReportVDD_Yes ) { - rdd_stream.open( outputRddFileName ); // Text mode so we use \n as terminator + rdd_stream.open( DataStringGlobals::outputRddFileName ); // Text mode so we use \n as terminator if ( ! rdd_stream ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"" + outputRddFileName + "\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file \"" + DataStringGlobals::outputRddFileName + "\" for output (write)." ); } rdd_stream << "Program Version," << VerString << ',' << IDDVerString << '\n'; rdd_stream << "Var Type (reported time step),Var Report Type,Variable Name [Units]" << '\n'; - mdd_stream.open( outputMddFileName ); + mdd_stream.open( DataStringGlobals::outputMddFileName ); if ( ! mdd_stream ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"" + outputMddFileName + "\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file \"" + DataStringGlobals::outputMddFileName + "\" for output (write)." ); } mdd_stream << "Program Version," << VerString << ',' << IDDVerString << '\n'; mdd_stream << "Var Type (reported time step),Var Report Type,Variable Name [Units]" << '\n'; } else if ( ProduceReportVDD == ReportVDD_IDF ) { - rdd_stream.open( outputRddFileName ); // Text mode so we use \n as terminator + rdd_stream.open( DataStringGlobals::outputRddFileName ); // Text mode so we use \n as terminator if ( ! rdd_stream ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"" + outputRddFileName + "\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file \"" + DataStringGlobals::outputRddFileName + "\" for output (write)." ); } rdd_stream << "! Program Version," << VerString << ',' << IDDVerString << '\n'; rdd_stream << "! Output:Variable Objects (applicable to this run)" << '\n'; - mdd_stream.open( outputMddFileName ); + mdd_stream.open( DataStringGlobals::outputMddFileName ); if ( ! mdd_stream ) { - ShowFatalError( "ProduceRDDMDD: Could not open file \"" + outputMddFileName + "\" for output (write)." ); + ShowFatalError( "ProduceRDDMDD: Could not open file \"" + DataStringGlobals::outputMddFileName + "\" for output (write)." ); } mdd_stream << "! Program Version," << VerString << ',' << IDDVerString << '\n'; mdd_stream << "! Output:Meter Objects (applicable to this run)" << '\n'; diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 7fff644426d..ad44d2a3bbe 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -88,7 +88,6 @@ namespace OutputReportTabular { // |--> MonthlyTable --> MonthlyColumns // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace InputProcessor; using DataGlobals::BigNumber; @@ -3074,9 +3073,9 @@ namespace OutputReportTabular { curDel = del( iStyle ); if ( TableStyle( iStyle ) == tableStyleComma ) { DisplayString( "Writing tabular output file results using comma format." ); - tbl_stream.open( outputTblCsvFileName ); + tbl_stream.open( DataStringGlobals::outputTblCsvFileName ); if ( ! tbl_stream ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + outputTblCsvFileName + "\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + DataStringGlobals::outputTblCsvFileName + "\" for output (write)." ); } tbl_stream << "Program Version:" << curDel << VerString << '\n'; tbl_stream << "Tabular Output Report in Format: " << curDel << "Comma\n"; @@ -3090,9 +3089,9 @@ namespace OutputReportTabular { tbl_stream << '\n'; } else if ( TableStyle( iStyle ) == tableStyleTab ) { DisplayString( "Writing tabular output file results using tab format." ); - tbl_stream.open( outputTblTabFileName ); + tbl_stream.open( DataStringGlobals::outputTblTabFileName ); if ( ! tbl_stream ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + outputTblTabFileName + "\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + DataStringGlobals::outputTblTabFileName + "\" for output (write)." ); } tbl_stream << "Program Version" << curDel << VerString << '\n'; tbl_stream << "Tabular Output Report in Format: " << curDel << "Tab\n"; @@ -3106,9 +3105,9 @@ namespace OutputReportTabular { tbl_stream << '\n'; } else if ( TableStyle( iStyle ) == tableStyleHTML ) { DisplayString( "Writing tabular output file results using HTML format." ); - tbl_stream.open( outputTblHtmFileName ); + tbl_stream.open( DataStringGlobals::outputTblHtmFileName ); if ( ! tbl_stream ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + outputTblHtmFileName + "\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + DataStringGlobals::outputTblHtmFileName + "\" for output (write)." ); } tbl_stream << "\n"; tbl_stream << "\n"; @@ -3137,9 +3136,9 @@ namespace OutputReportTabular { tbl_stream << " " << std::setw( 2 ) << td( 5 ) << ':' << std::setw( 2 ) << td( 6 ) << ':' << std::setw( 2 ) << td( 7 ) << std::setfill( ' ' ) << "

\n"; } else if ( TableStyle( iStyle ) == tableStyleXML ) { DisplayString( "Writing tabular output file results using XML format." ); - tbl_stream.open( outputTblXmlFileName ); + tbl_stream.open( DataStringGlobals::outputTblXmlFileName ); if ( ! tbl_stream ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + outputTblXmlFileName + "\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + DataStringGlobals::outputTblXmlFileName + "\" for output (write)." ); } tbl_stream << "\n"; tbl_stream << "\n"; @@ -3158,9 +3157,9 @@ namespace OutputReportTabular { tbl_stream << '\n'; } else { DisplayString( "Writing tabular output file results using text format." ); - tbl_stream.open( outputTblTxtFileName ); + tbl_stream.open( DataStringGlobals::outputTblTxtFileName ); if ( ! tbl_stream ) { - ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + outputTblTxtFileName + "\" for output (write)." ); + ShowFatalError( "OpenOutputTabularFile: Could not open file \"" + DataStringGlobals::outputTblTxtFileName + "\" for output (write)." ); } tbl_stream << "Program Version: " << VerString << '\n'; tbl_stream << "Tabular Output Report in Format: " << curDel << "Fixed\n"; @@ -4792,7 +4791,7 @@ namespace OutputReportTabular { WriteTimeBinTables(); } } - EchoInputFile = FindUnitNumber( outputAuditFileName ); + EchoInputFile = FindUnitNumber( DataStringGlobals::outputAuditFileName ); gio::write( EchoInputFile, fmtLD ) << "MonthlyInputCount=" << MonthlyInputCount; gio::write( EchoInputFile, fmtLD ) << "sizeMonthlyInput=" << sizeMonthlyInput; gio::write( EchoInputFile, fmtLD ) << "MonthlyFieldSetInputCount=" << MonthlyFieldSetInputCount; @@ -4908,7 +4907,7 @@ namespace OutputReportTabular { bool coolingDesignlinepassed; bool desConditionlinepassed; - { IOFlags flags; gio::inquire( inStatFileName, flags ); fileExists = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inStatFileName, flags ); fileExists = flags.exists(); } readStat = 0; isASHRAE = false; iscalc = false; @@ -4921,9 +4920,9 @@ namespace OutputReportTabular { lineTypeinterim = 0; if ( fileExists ) { statFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, inStatFileName, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, DataStringGlobals::inStatFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "FillWeatherPredefinedEntries: Could not open file "+inStatFileName+" for input (read)." ); + ShowFatalError( "FillWeatherPredefinedEntries: Could not open file "+DataStringGlobals::inStatFileName+" for input (read)." ); } IOFlags flags; while ( readStat == 0 ) { //end of file, or error diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index 8675a8e078e..ded7e716560 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ namespace EnergyPlus { -using namespace CommandLineInterface; static gio::Fmt fmtLD( "*" ); void @@ -232,9 +232,9 @@ LinesOut( std::string const & option ) optiondone = true; unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputSlnFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, DataStringGlobals::outputSlnFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "LinesOut: Could not open file "+ outputSlnFileName +" for output (write)." ); + ShowFatalError( "LinesOut: Could not open file "+ DataStringGlobals::outputSlnFileName +" for output (write)." ); } if ( option != "IDF" ) { @@ -422,9 +422,9 @@ DXFOut( } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, DataStringGlobals::outputDxfFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOut: Could not open file "+outputDxfFileName+" for output (write)." ); + ShowFatalError( "DXFOut: Could not open file "+DataStringGlobals::outputDxfFileName+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -915,9 +915,9 @@ DXFOutLines( std::string const & ColorScheme ) } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, DataStringGlobals::outputDxfFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOutLines: Could not open file "+outputDxfFileName+" for output (write)." ); + ShowFatalError( "DXFOutLines: Could not open file "+DataStringGlobals::outputDxfFileName+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -1342,9 +1342,9 @@ DXFOutWireFrame( std::string const & ColorScheme ) } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputDxfFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, DataStringGlobals::outputDxfFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "DXFOutWireFrame: Could not open file "+outputDxfFileName+" for output (write)." ); + ShowFatalError( "DXFOutWireFrame: Could not open file "+DataStringGlobals::outputDxfFileName+" for output (write)." ); } gio::write( unit, Format_702 ); // Start of Entities section @@ -2117,9 +2117,9 @@ CostInfoOut() unit = GetNewUnitNumber(); // .sci = surface cost info - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputSciFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, DataStringGlobals::outputSciFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "CostInfoOut: Could not open file "+outputSciFileName+" for output (write)." ); + ShowFatalError( "CostInfoOut: Could not open file "+DataStringGlobals::outputSciFileName+" for output (write)." ); } gio::write( unit, fmtLD ) << TotSurfaces << int( count( uniqueSurf ) ); gio::write( unit, fmtLD ) << "data for surfaces useful for cost information"; @@ -2246,9 +2246,9 @@ VRMLOut( } unit = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, outputWrlFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( unit, DataStringGlobals::outputWrlFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "VRMLOut: Could not open file "+ outputWrlFileName +" for output (write)." ); + ShowFatalError( "VRMLOut: Could not open file "+ DataStringGlobals::outputWrlFileName +" for output (write)." ); } gio::write( unit, Format_702 ); // Beginning diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index 41403a07346..122818d5d7d 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -51,7 +51,6 @@ namespace Psychrometrics { // more research on hfg calc // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; #ifdef EP_psych_errors using namespace DataGlobals; diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 162b2b34867..b017ad53154 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -42,7 +42,7 @@ SQLite::SQLite() m_writeTabularDataToSQLite(false), m_sqlDBTimeIndex(0), m_db(nullptr), - m_dbName(CommandLineInterface::outputSqlFileName), + m_dbName(DataStringGlobals::outputSqlFileName), m_reportDataInsertStmt(nullptr), m_reportExtendedDataInsertStmt(nullptr), m_reportDictionaryInsertStmt(nullptr), @@ -108,12 +108,12 @@ SQLite::SQLite() if( m_writeOutputToSQLite ) { int rc = -1; bool ok = true; - m_errorStream.open(CommandLineInterface::outputSqliteErrFileName, std::ofstream::out | std::ofstream::trunc); + m_errorStream.open(DataStringGlobals::outputSqliteErrFileName, std::ofstream::out | std::ofstream::trunc); // Test if we can write to the sqlite error file // Does there need to be a seperate sqlite.err file at all? Consider using eplusout.err if( m_errorStream.is_open() ) { - m_errorStream << "SQLite3 message, " + CommandLineInterface::outputSqliteErrFileName + " open for processing!" << std::endl; + m_errorStream << "SQLite3 message, " + DataStringGlobals::outputSqliteErrFileName + " open for processing!" << std::endl; } else { ok = false; } diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 41c7c7f2f60..6330790af45 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -47,7 +47,6 @@ namespace ScheduleManager { // OTHER NOTES: // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using DataGlobals::HourOfDay; using DataGlobals::OutputFileInits; @@ -465,7 +464,7 @@ namespace ScheduleManager { Schedule( 0 ).ScheduleTypePtr = 0; Schedule( 0 ).WeekSchedulePointer = 0; - UnitNumber = FindUnitNumber( outputAuditFileName ); + UnitNumber = FindUnitNumber( DataStringGlobals::outputAuditFileName ); gio::write( UnitNumber, fmtLD ) << " Processing Schedule Input -- Start"; //!! Get Schedule Types diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index ef6f775d64d..a0b5bea754d 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -126,7 +126,6 @@ namespace SimulationManager { // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataSizing; @@ -1065,7 +1064,7 @@ namespace SimulationManager { NumDesignDays = GetNumObjectsFound( "SizingPeriod:DesignDay" ); NumRunPeriodDesign = GetNumObjectsFound( "SizingPeriod:WeatherFileDays" ) + GetNumObjectsFound( "SizingPeriod:WeatherFileConditionType" ); NumSizingDays = NumDesignDays + NumRunPeriodDesign; - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); WeatherFileAttached = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inputWeatherFileName, flags ); WeatherFileAttached = flags.exists(); } if ( RunControlInInput ) { if ( DoZoneSizing ) { @@ -1228,36 +1227,36 @@ namespace SimulationManager { // FLOW: OutputFileStandard = GetNewUnitNumber(); StdOutputRecordCount = 0; - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileStandard, outputEsoFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileStandard, DataStringGlobals::outputEsoFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputEsoFileName+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+DataStringGlobals::outputEsoFileName+" for output (write)." ); } eso_stream = gio::out_stream( OutputFileStandard ); gio::write( OutputFileStandard, fmtA ) << "Program Version," + VerString; // Open the Initialization Output File OutputFileInits = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileInits, outputEioFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileInits, DataStringGlobals::outputEioFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputEioFileName+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+DataStringGlobals::outputEioFileName+" for output (write)." ); } gio::write( OutputFileInits, fmtA ) << "Program Version," + VerString; // Open the Meters Output File OutputFileMeters = GetNewUnitNumber(); StdMeterRecordCount = 0; - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileMeters, outputMtrFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileMeters, DataStringGlobals::outputMtrFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputMtrFileName+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+DataStringGlobals::outputMtrFileName+" for output (write)." ); } mtr_stream = gio::out_stream( OutputFileMeters ); gio::write( OutputFileMeters, fmtA ) << "Program Version," + VerString; // Open the Branch-Node Details Output File OutputFileBNDetails = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileBNDetails, outputBndFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "UNKNOWN" ); gio::open( OutputFileBNDetails, DataStringGlobals::outputBndFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( "OpenOutputFiles: Could not open file "+outputBndFileName+" for output (write)." ); + ShowFatalError( "OpenOutputFiles: Could not open file "+DataStringGlobals::outputBndFileName+" for output (write)." ); } gio::write( OutputFileBNDetails, fmtA ) << "Program Version," + VerString; @@ -1337,7 +1336,7 @@ namespace SimulationManager { std::string cepEnvSetThreads; std::string cIDFSetThreads; - EchoInputFile = FindUnitNumber( outputAuditFileName ); + EchoInputFile = FindUnitNumber( DataStringGlobals::outputAuditFileName ); // Record some items on the audit file gio::write( EchoInputFile, fmtLD ) << "NumOfRVariable=" << NumOfRVariable_Setup; gio::write( EchoInputFile, fmtLD ) << "NumOfRVariable(Total)=" << NumTotalRVariable; diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index f591857810b..e7d6e9d6f93 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -55,7 +55,6 @@ namespace SizingManager { // OTHER NOTES: none // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace HeatBalanceManager; @@ -223,19 +222,19 @@ namespace SizingManager { Available = true; OutputFileZoneSizing = GetNewUnitNumber(); if ( SizingFileColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, outputZszCsvFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, DataStringGlobals::outputZszCsvFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file "+ outputZszCsvFileName +" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ DataStringGlobals::outputZszCsvFileName +" for output (write)." ); } } else if ( SizingFileColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, outputZszTabFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, DataStringGlobals::outputZszTabFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file "+outputZszTabFileName+" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+DataStringGlobals::outputZszTabFileName+" for output (write)." ); } } else { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, outputZszTxtFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileZoneSizing, DataStringGlobals::outputZszTxtFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file "+ outputZszTxtFileName +" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ DataStringGlobals::outputZszTxtFileName +" for output (write)." ); } } @@ -435,19 +434,19 @@ namespace SizingManager { Available = true; OutputFileSysSizing = GetNewUnitNumber(); if ( SizingFileColSep == CharComma ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, outputSszCsvFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, DataStringGlobals::outputSszCsvFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file "+ outputSszCsvFileName +" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ DataStringGlobals::outputSszCsvFileName +" for output (write)." ); } } else if ( SizingFileColSep == CharTab ) { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, outputSszTabFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, DataStringGlobals::outputSszTabFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file "+ outputSszTabFileName +" for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+ DataStringGlobals::outputSszTabFileName +" for output (write)." ); } } else { - { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, outputSszTxtFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( OutputFileSysSizing, DataStringGlobals::outputSszTxtFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - ShowFatalError( RoutineName + "Could not open file "+outputSszTxtFileName+ " for output (write)." ); + ShowFatalError( RoutineName + "Could not open file "+DataStringGlobals::outputSszTxtFileName+ " for output (write)." ); } } SimAir = true; diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 2e1cb444227..cbddbfca9c0 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -82,7 +83,6 @@ namespace SolarShading { // na // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataEnvironment; @@ -255,9 +255,9 @@ namespace SolarShading { #endif if ( BeginSimFlag ) { - shd_stream.open( outputShdFileName ); + shd_stream.open( DataStringGlobals::outputShdFileName ); if ( ! shd_stream ) { - ShowFatalError( "InitSolarCalculations: Could not open file \"" + outputShdFileName + "\" for output (write)." ); + ShowFatalError( "InitSolarCalculations: Could not open file \"" + DataStringGlobals::outputShdFileName + "\" for output (write)." ); } if ( GetInputFlag ) { diff --git a/src/EnergyPlus/TARCOGOutput.cc b/src/EnergyPlus/TARCOGOutput.cc index 52585691145..1b0770e6616 100644 --- a/src/EnergyPlus/TARCOGOutput.cc +++ b/src/EnergyPlus/TARCOGOutput.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ namespace TARCOGOutput { // USE STATEMENTS: // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace TARCOGCommon; using namespace TARCOGGassesParams; @@ -1530,11 +1530,11 @@ namespace TARCOGOutput { TarcogIterationsFileNumber = GetNewUnitNumber(); // open(newunit=TarcogIterationsFileNumber, file=TRIM(DBGD)//'TarcogIterations.dbg', status='unknown', position='APPEND', & // form='formatted', iostat=nperr) - { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, DBGD + TarcogIterationsFileName, flags ); nperr = flags.ios(); } + { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, DBGD + DataStringGlobals::TarcogIterationsFileName, flags ); nperr = flags.ios(); } // if (nperr.ne.0) open(newunit=TarcogIterationsFileNumber, file='TarcogIterations.dbg',status='unknown', position='APPEND', & // & form='formatted', iostat=nperr) - if ( nperr != 0 ) { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, TarcogIterationsFileName, flags ); nperr = flags.ios(); } + if ( nperr != 0 ) { IOFlags flags; flags.FORM( "formatted" ); flags.STATUS( "unknown" ); flags.POSITION( "APPEND" ); gio::open( TarcogIterationsFileNumber, DataStringGlobals::TarcogIterationsFileName, flags ); nperr = flags.ios(); } IterationCSVFileNumber = GetNewUnitNumber(); // open(newunit=IterationCSVFileNumber, file=TRIM(DBGD)//TRIM(IterationCSVName), status='unknown', position='APPEND', & diff --git a/src/EnergyPlus/ThermalComfort.cc b/src/EnergyPlus/ThermalComfort.cc index c679327f93a..108dcc30db8 100644 --- a/src/EnergyPlus/ThermalComfort.cc +++ b/src/EnergyPlus/ThermalComfort.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,6 @@ namespace ThermalComfort { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using DataHeatBalance::MRT; @@ -2465,14 +2465,14 @@ namespace ThermalComfort { } if ( initiate && weathersimulation ) { - { IOFlags flags; gio::inquire( inStatFileName, flags ); statFileExists = flags.exists(); } - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inStatFileName, flags ); statFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inputWeatherFileName, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( statFileExists ) { statFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, inStatFileName, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, DataStringGlobals::inStatFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file "+inStatFileName+" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file "+DataStringGlobals::inStatFileName+" for input (read)." ); } while ( readStat == 0 ) { { IOFlags flags; gio::read( statFile, fmtA, flags ) >> lineIn; readStat = flags.ios(); } @@ -2491,9 +2491,9 @@ namespace ThermalComfort { useStatData = true; } else if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFileName, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, DataStringGlobals::inputWeatherFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " + inputWeatherFileName+ " for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveASH55: Could not open file " + DataStringGlobals::inputWeatherFileName+ " for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } @@ -2717,13 +2717,13 @@ namespace ThermalComfort { } if ( initiate && weathersimulation ) { - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); epwFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inputWeatherFileName, flags ); epwFileExists = flags.exists(); } readStat = 0; if ( epwFileExists ) { epwFile = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, inputWeatherFileName, flags ); readStat = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( epwFile, DataStringGlobals::inputWeatherFileName, flags ); readStat = flags.ios(); } if ( readStat != 0 ) { - ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+inputWeatherFileName+" for input (read)." ); + ShowFatalError( "CalcThermalComfortAdaptiveCEN15251: Could not open file "+DataStringGlobals::inputWeatherFileName+" for input (read)." ); } for ( i = 1; i <= 9; ++i ) { // Headers { IOFlags flags; gio::read( epwFile, fmtA, flags ); readStat = flags.ios(); } diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 963f09128df..3f9f28b42c4 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -67,7 +67,6 @@ AbortEnergyPlus() // na // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataSystemVariables; using namespace DataTimings; @@ -191,9 +190,9 @@ AbortEnergyPlus() ShowMessage( "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, DataStringGlobals::outputEndFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "AbortEnergyPlus: Could not open file "+ outputEndFileName +" for output (write)." ); + DisplayString( "AbortEnergyPlus: Could not open file "+ DataStringGlobals::outputEndFileName +" for output (write)." ); } gio::write( tempfl, fmtLD ) << "EnergyPlus Terminated--Fatal Error Detected. " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; @@ -346,7 +345,6 @@ EndEnergyPlus() // na // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataSystemVariables; using namespace DataTimings; @@ -424,9 +422,9 @@ EndEnergyPlus() ShowMessage( "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed ); DisplayString( "EnergyPlus Run Time=" + Elapsed ); tempfl = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, outputEndFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( tempfl, DataStringGlobals::outputEndFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { - DisplayString( "EndEnergyPlus: Could not open file " + outputEndFileName + " for output (write)." ); + DisplayString( "EndEnergyPlus: Could not open file " + DataStringGlobals::outputEndFileName + " for output (write)." ); } gio::write( tempfl, fmtA ) << "EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed; gio::close( tempfl ); @@ -789,7 +787,6 @@ ShowFatalError( // na // Using/Aliasing - using namespace CommandLineInterface; using namespace DataErrorTracking; using General::RoundSigDigits; @@ -1536,7 +1533,6 @@ ShowErrorMessage( // na // Using/Aliasing - using namespace CommandLineInterface; using DataStringGlobals::VerString; using DataStringGlobals::IDDVerString; using DataGlobals::DoingInputProcessing; @@ -1563,10 +1559,10 @@ ShowErrorMessage( if ( TotalErrors == 0 && ! ErrFileOpened ) { StandardErrorOutput = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, outputErrFileName, flags ); write_stat = flags.ios(); } + { IOFlags flags; flags.ACTION( "write" ); gio::open( StandardErrorOutput, DataStringGlobals::outputErrFileName, flags ); write_stat = flags.ios(); } if ( write_stat != 0 ) { DisplayString( "Trying to display error: \"" + ErrorMessage + "\"" ); - ShowFatalError( "ShowErrorMessage: Could not open file "+outputErrFileName+" for output (write)." ); + ShowFatalError( "ShowErrorMessage: Could not open file "+DataStringGlobals::outputErrFileName+" for output (write)." ); } gio::write( StandardErrorOutput, fmtA ) << "Program Version," + VerString + ',' + IDDVerString; ErrFileOpened = true; diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 9b78fd9c297..51ded30c797 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,6 @@ namespace WeatherManager { // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGlobals; using namespace DataEnvironment; @@ -4396,7 +4396,7 @@ Label903: ; // FLOW: - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); WeatherFileExists = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inputWeatherFileName, flags ); WeatherFileExists = flags.exists(); } if ( WeatherFileExists ) { OpenEPlusWeatherFile( ErrorsFound, true ); @@ -4449,11 +4449,11 @@ Label903: ; bool EPWOpen; int unitnumber; - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inputWeatherFileName, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); WeatherFileUnitNumber = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, inputWeatherFileName, flags ); if ( flags.err() ) goto Label9999; } + { IOFlags flags; flags.ACTION( "read" ); gio::open( WeatherFileUnitNumber, DataStringGlobals::inputWeatherFileName, flags ); if ( flags.err() ) goto Label9999; } if ( ProcessHeader ) { // Read in Header Information @@ -4537,7 +4537,7 @@ Label9999: ; // Make sure it's open - { IOFlags flags; gio::inquire( inputWeatherFileName, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inputWeatherFileName, flags ); unitnumber = flags.unit(); EPWOpen = flags.open(); } if ( EPWOpen ) gio::close( unitnumber ); } diff --git a/src/EnergyPlus/WindTurbine.cc b/src/EnergyPlus/WindTurbine.cc index 24d1a36c13b..18674dd6f1d 100644 --- a/src/EnergyPlus/WindTurbine.cc +++ b/src/EnergyPlus/WindTurbine.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,6 @@ namespace WindTurbine { // OTHER NOTES: none // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataGenerators; using DataGlobals::Pi; @@ -624,13 +624,13 @@ namespace WindTurbine { // Estimate average annual wind speed once if ( MyOneTimeFlag ) { wsStatFound = false; - { IOFlags flags; gio::inquire( inStatFileName, flags ); fileExists = flags.exists(); } + { IOFlags flags; gio::inquire( DataStringGlobals::inStatFileName, flags ); fileExists = flags.exists(); } if ( fileExists ) { statFile = GetNewUnitNumber(); ReadStatus = 0; - { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, inStatFileName, flags ); ReadStatus = flags.ios(); } + { IOFlags flags; flags.ACTION( "READ" ); gio::open( statFile, DataStringGlobals::inStatFileName, flags ); ReadStatus = flags.ios(); } if ( ReadStatus != 0 ) { - ShowFatalError( "InitWindTurbine: Could not open file "+inStatFileName+" for input (read)." ); + ShowFatalError( "InitWindTurbine: Could not open file "+DataStringGlobals::inStatFileName+" for input (read)." ); } while ( ReadStatus == 0 ) { //end of file { IOFlags flags; gio::read( statFile, fmtA, flags ) >> lineIn; ReadStatus = flags.ios(); } @@ -657,14 +657,14 @@ namespace WindTurbine { } } else { // blank field if ( ! warningShown ) { - ShowWarningError( "InitWindTurbine: read from "+ inStatFileName +" file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); + ShowWarningError( "InitWindTurbine: read from "+ DataStringGlobals::inStatFileName +" file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); lineIn.erase( 0, lnPtr + 1 ); warningShown = true; } } } else { // two tabs in succession if ( ! warningShown ) { - ShowWarningError( "InitWindTurbine: read from "+ inStatFileName +" file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); + ShowWarningError( "InitWindTurbine: read from "+ DataStringGlobals::inStatFileName +" file shows <365 days in weather file. " "Annual average wind speed used will be inaccurate." ); lineIn.erase( 0, lnPtr + 1 ); warningShown = true; } diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 036a4202a63..9e804e597d8 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,6 @@ namespace WindowManager { // for DOE-2, Lawrence Berkeley National Laboratory, Jan. 1996. // Using/Aliasing - using namespace CommandLineInterface; using namespace DataPrecisionGlobals; using namespace DataEnvironment; using namespace DataHeatBalance; @@ -7704,7 +7704,7 @@ namespace WindowManager { if ( PrintTransMap ) { ScreenTransUnitNo = GetNewUnitNumber(); - { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "unknown" ); gio::open( ScreenTransUnitNo, outputScreenCsvFileName, flags ); if ( flags.err() ) goto Label99999; } + { IOFlags flags; flags.ACTION( "write" ); flags.STATUS( "unknown" ); gio::open( ScreenTransUnitNo, DataStringGlobals::outputScreenCsvFileName, flags ); if ( flags.err() ) goto Label99999; } // WRITE(ScreenTransUnitNo,*)' ' for ( ScreenNum = 1; ScreenNum <= NumSurfaceScreens; ++ScreenNum ) { MatNum = SurfaceScreens( ScreenNum ).MaterialNumber; From beefe7a8a7543c5d5acfce80984efe42a7053274 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Mon, 26 Jan 2015 13:13:35 -0700 Subject: [PATCH 65/71] Add ExpandObjects for the LBuilding Par file --- testfiles/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 644ef5ca4ce..95186ec957c 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -508,7 +508,7 @@ IF (BUILD_FORTRAN) ADD_SIMULATION_TEST(IDF_FILE LBuilding-G180.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x COST 2) ADD_SIMULATION_TEST(IDF_FILE LBuilding-G270.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw ENERGYPLUS_FLAGS -x COST 2) # Parametric preprocessor dependent files - ADD_SIMULATION_TEST(IDF_FILE LBuildingAppGRotPar.idf EPW_FILE USA_FL_Miami.Intl.AP.722020_TMY3.epw COST 5) + ADD_SIMULATION_TEST(IDF_FILE LBuildingAppGRotPar.idf EPW_FILE USA_FL_Miami.Intl.AP.722020_TMY3.epw ENERGYPLUS_FLAGS -x COST 5) ADD_SIMULATION_TEST(IDF_FILE 1ZoneParameterAspect.idf EPW_FILE USA_CO_Golden-NREL.724666_TMY3.epw COST 5) ADD_SIMULATION_TEST(IDF_FILE ParametricInsulation-5ZoneAirCooled.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw COST 5) # Basement/slab dependent files From beef9e8907e4a53ce96bd6b953a8be8654f2bd7f Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Mon, 26 Jan 2015 14:16:31 -0700 Subject: [PATCH 66/71] Minor whitespace change --- src/EnergyPlus/InputProcessor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index 22eae7e2389..c82a94d7487 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -273,7 +273,7 @@ namespace InputProcessor { NumLines = 0; DoingInputProcessing = true; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary ("+inputIddFileName+") File -- Start"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary (" + inputIddFileName + ") File -- Start"; DisplayString( "Processing Data Dictionary" ); ProcessingIDD = true; ProcessDataDicFile( idd_stream, ErrorsInIDD ); From dfca3514dc48221af767567e1900f8e8e9e8d5e3 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Mon, 26 Jan 2015 15:45:30 -0600 Subject: [PATCH 67/71] Provide file names for unit tests where necessary. --- tst/EnergyPlus/unit/HeatBalanceManager.unit.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc index ef6b6632d6d..b38a24f6496 100644 --- a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc @@ -9,6 +9,7 @@ #include #include #include +#include using namespace EnergyPlus; using namespace EnergyPlus::HeatBalanceManager; @@ -38,6 +39,8 @@ TEST( ProcessZoneDataTest, Test1 ) int NumNumbers ( 9 ); cCurrentModuleObject = "Zone"; + DataStringGlobals::outputErrFileName = "eplusout.err"; + DataStringGlobals::outputMtdFileName = "eplusout.mtd"; NumOfZones = 2; Zone.allocate( NumOfZones ); From beef65057255e8126c3c3c4238e8354393ab8673 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 27 Jan 2015 09:29:39 -0700 Subject: [PATCH 68/71] Removing file paths from output; Currently only removing the idd and idf file paths, could remove more; Also leaving the paths in for **error** messages; Could add these back in later if desired --- src/EnergyPlus/InputProcessor.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/InputProcessor.cc b/src/EnergyPlus/InputProcessor.cc index c82a94d7487..714103e9030 100644 --- a/src/EnergyPlus/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessor.cc @@ -273,7 +273,7 @@ namespace InputProcessor { NumLines = 0; DoingInputProcessing = true; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary (" + inputIddFileName + ") File -- Start"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary -- Start"; DisplayString( "Processing Data Dictionary" ); ProcessingIDD = true; ProcessDataDicFile( idd_stream, ErrorsInIDD ); @@ -298,7 +298,7 @@ namespace InputProcessor { } ProcessingIDD = false; - gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary (" + inputIddFileName + ") File -- Complete"; + gio::write( EchoInputFile, fmtLD ) << " Processing Data Dictionary -- Complete"; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Alpha Args=" << MaxAlphaArgsFound; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Numeric Args=" << MaxNumericArgsFound; @@ -308,7 +308,7 @@ namespace InputProcessor { gio::write( EchoInputFile, fmtLD ) << " Total Number of Numeric Fields=" << NumNumericArgsFound; gio::write( EchoInputFile, fmtLD ) << " Total Number of Fields=" << NumAlphaArgsFound + NumNumericArgsFound; - gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (" + inputIdfFileName + ") -- Start"; + gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File -- Start"; if ( !DisplayInputInAudit ){ gio::write( EchoInputFile, fmtLD ) << " Echo of input lines is off. May be activated by setting the environmental variable DISPLAYINPUTINAUDIT=YES"; } @@ -336,7 +336,7 @@ namespace InputProcessor { IDFRecordsGotten.dimension( NumIDFRecords, false ); - gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File (" + inputIdfFileName + ") -- Complete"; + gio::write( EchoInputFile, fmtLD ) << " Processing Input Data File -- Complete"; // WRITE(EchoInputFile,*) ' Number of IDF "Lines"=',NumIDFRecords gio::write( EchoInputFile, fmtLD ) << " Maximum number of Alpha IDF Args=" << MaxAlphaIDFArgsFound; gio::write( EchoInputFile, fmtLD ) << " Maximum number of Numeric IDF Args=" << MaxNumericIDFArgsFound; From beefde2454181c99dd91670b5aba32e678e7779d Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 27 Jan 2015 14:20:22 -0700 Subject: [PATCH 69/71] Add weather file sizing period to multistory example; This should add more code coverage and get this branch in good terms there; This example file had a height varying site object; but I dont think its used on DDs only; Adding the weather file sizing period should hit many lines of code in DataEnvironment --- testfiles/MultiStory.idf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testfiles/MultiStory.idf b/testfiles/MultiStory.idf index 3802f1a4195..a8d7691e21b 100644 --- a/testfiles/MultiStory.idf +++ b/testfiles/MultiStory.idf @@ -104,6 +104,16 @@ 460, !- Wind Speed Profile Boundary Layer Thickness {m} 0.0065; !- Air Temperature Gradient Coefficient {K/m} + SizingPeriod:WeatherFileDays, + Weather File Sizing Period, !- Name + 7, !- Begin Month + 18, !- Begin Day of Month + 7, !- End Month + 25, !- End Day of Month + SummerDesignDay, !- Day of Week for Start Day + No, !- Use Weather File Daylight Saving Period + No; !- Use Weather File Rain and Snow Indicators + Timestep,6; ShadowCalculation, From a6df87c59104b9373684aee49375b4f9303e3b16 Mon Sep 17 00:00:00 2001 From: nealkruis Date: Tue, 27 Jan 2015 16:54:30 -0600 Subject: [PATCH 70/71] Provide default file names. Fix slab/basement pre-processor tests. --- cmake/RunSimulation.cmake | 47 +++++----- src/EnergyPlus/DataStringGlobals.in.cc | 90 +++++++++---------- .../unit/HeatBalanceManager.unit.cc | 2 - 3 files changed, 69 insertions(+), 70 deletions(-) diff --git a/cmake/RunSimulation.cmake b/cmake/RunSimulation.cmake index 50e41be5f8d..55f9ac19f3a 100644 --- a/cmake/RunSimulation.cmake +++ b/cmake/RunSimulation.cmake @@ -44,13 +44,13 @@ if("${EPMACRO_RESULT}" GREATER -1) endforeach() # find the appropriate executable file if( UNIX AND NOT APPLE ) - find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Linux" + find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Linux" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) elseif( APPLE ) - find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Mac" + find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Mac" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) else() # windows - find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Windows" + find_program(EPMACRO_EXE EPMacro PATHS "${SOURCE_DIR}/bin/EPMacro/Windows" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) endif() # Move EPMacro to executable directory @@ -62,44 +62,45 @@ if(BUILD_FORTRAN) # Parametric preprocessor next string(FIND "${IDF_CONTENT}" "Parametric:" PAR_RESULT) if ( "${PAR_RESULT}" GREATER -1 ) - find_program(PARAMETRIC_EXE parametricpreprocessor PATHS "${PRODUCT_PATH}" + find_program(PARAMETRIC_EXE parametricpreprocessor PATHS "${PRODUCT_PATH}" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${IDF_PATH}" "${OUTPUT_DIR_PATH}") execute_process(COMMAND "${PARAMETRIC_EXE}" "${IDF_FILE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") - + # this handles the LBuildingAppGRotPar parametric file if (EXISTS "${OUTPUT_DIR_PATH}/${IDF_NAME}-G000.idf") set (IDF_PATH "${OUTPUT_DIR_PATH}/${IDF_NAME}-G000.idf") - + # this handles the LBuildingAppGRotPar and ParametricInsulation-5ZoneAirCooled parametric files elseif (EXISTS "${OUTPUT_DIR_PATH}/${IDF_NAME}-000001.idf") set (IDF_PATH "${OUTPUT_DIR_PATH}/${IDF_NAME}-000001.idf") - + # this shouldn't happen unless a new parametric file is added with a different processed filename else () message("Couldn't find parametric preprocessor output file for ${IDF_NAME}, attempting to continue with original input file.") - + endif () endif () # parametric preprocessor definitions detected - + # Run ExpandObjects independently if there are ground heat transfer objects string(FIND "${IDF_CONTENT}" "GroundHeatTransfer:Slab" SLAB_RESULT) string(FIND "${IDF_CONTENT}" "GroundHeatTransfer:Basement" BASEMENT_RESULT) if ( "${SLAB_RESULT}" GREATER -1 OR "${BASEMENT_RESULT}" GREATER -1) - find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${BINARY_DIR}/Products/" + find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${BINARY_DIR}/Products/" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) message("Executing ExpandObjects from ${EXPANDOBJECTS_EXE}") - execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${IDF_PATH}" "${OUTPUT_DIR_PATH}/in.idf") - execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${EPW_PATH}" "${OUTPUT_DIR_PATH}/in.epw") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${IDF_PATH}" "${OUTPUT_DIR_PATH}/in.idf") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${EPW_PATH}" "${OUTPUT_DIR_PATH}/in.epw") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PRODUCT_PATH}/Energy+.idd" "${OUTPUT_DIR_PATH}") execute_process(COMMAND "${EXPANDOBJECTS_EXE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") - + if ( "${SLAB_RESULT}" GREATER -1) # Copy files needed for Slab file ( COPY "${SOURCE_DIR}/idd/SlabGHT.idd" DESTINATION "${OUTPUT_DIR_PATH}" ) # Find and run slab - find_program(SLAB_EXE Slab PATHS "${PRODUCT_PATH}" + find_program(SLAB_EXE Slab PATHS "${PRODUCT_PATH}" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) message("Executing Slab from ${SLAB_EXE}") execute_process(COMMAND "${SLAB_EXE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") @@ -107,12 +108,12 @@ if(BUILD_FORTRAN) file(READ "${OUTPUT_DIR_PATH}/SLABSurfaceTemps.TXT" SLAB_CONTENTS) file(APPEND "${OUTPUT_DIR_PATH}/expanded.idf" "${SLAB_CONTENTS}") endif() - + if ( "${BASEMENT_RESULT}" GREATER -1) # Copy files needed for Basement file ( COPY "${SOURCE_DIR}/idd/BasementGHT.idd" DESTINATION "${OUTPUT_DIR_PATH}" ) # Find and run basement - find_program(BASEMENT_EXE Basement PATHS "${PRODUCT_PATH}" + find_program(BASEMENT_EXE Basement PATHS "${PRODUCT_PATH}" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) message("Executing Basement from ${BASEMENT_EXE}") execute_process(COMMAND "${BASEMENT_EXE}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}") @@ -121,28 +122,28 @@ if(BUILD_FORTRAN) file(APPEND "${OUTPUT_DIR_PATH}/expanded.idf" "${BASEMENT_CONTENTS}") endif() - set (IDF_PATH "${OUTPUT_DIR_PATH}/expanded.idf") + set (IDF_PATH "${OUTPUT_DIR_PATH}/expanded.idf") endif() # expand objects found something and created expanded.idf - + list(FIND ENERGYPLUS_FLAGS_LIST -x EXPAND_RESULT) if("${EXPAND_RESULT}" GREATER -1) - find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${PRODUCT_PATH}" + find_program(EXPANDOBJECTS_EXE ExpandObjects PATHS "${PRODUCT_PATH}" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) # Move to executable directory execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EXPANDOBJECTS_EXE}" "${EXE_PATH}") endif() - + list(FIND ENERGYPLUS_FLAGS_LIST -r READVARS_RESULT) if("${READVARS_RESULT}" GREATER -1) - find_program(READVARS_EXE ReadVarsESO PATHS "${PRODUCT_PATH}" + find_program(READVARS_EXE ReadVarsESO PATHS "${PRODUCT_PATH}" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) # Move to executable directory execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${READVARS_EXE}" "${EXE_PATH}") endif() - + endif() # build fortran @@ -153,7 +154,7 @@ else() endif() execute_process(COMMAND ${ECHO_CMD} - COMMAND "${ENERGYPLUS_EXE}" -w "${EPW_PATH}" -d "${OUTPUT_DIR_PATH}" ${ENERGYPLUS_FLAGS_LIST} "${IDF_PATH}" + COMMAND "${ENERGYPLUS_EXE}" -w "${EPW_PATH}" -d "${OUTPUT_DIR_PATH}" ${ENERGYPLUS_FLAGS_LIST} "${IDF_PATH}" WORKING_DIRECTORY "${OUTPUT_DIR_PATH}" RESULT_VARIABLE RESULT) diff --git a/src/EnergyPlus/DataStringGlobals.in.cc b/src/EnergyPlus/DataStringGlobals.in.cc index 9dcc913fb71..14dfd27653b 100644 --- a/src/EnergyPlus/DataStringGlobals.in.cc +++ b/src/EnergyPlus/DataStringGlobals.in.cc @@ -72,57 +72,57 @@ namespace DataStringGlobals { // na // MODULE VARIABLE DECLARATIONS: - 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 outputAuditFileName("eplusout.audit"); + std::string outputBndFileName("eplusout.bnd"); + std::string outputDxfFileName("eplusout.dxf"); + std::string outputEioFileName("eplusout.eio"); + std::string outputEndFileName("eplusout.end"); + std::string outputErrFileName("eplusout.err"); + std::string outputEsoFileName("eplusout.eso"); + std::string outputMtdFileName("eplusout.mtd"); + std::string outputMddFileName("eplusout.mdd"); + std::string outputMtrFileName("eplusout.mtr"); + std::string outputRddFileName("eplusout.rdd"); + std::string outputShdFileName("eplusout.shd"); + std::string outputTblCsvFileName("eplustbl.csv"); + std::string outputTblHtmFileName("eplustbl.htm"); + std::string outputTblTabFileName("eplustbl.tab"); + std::string outputTblTxtFileName("eplustbl.txt"); + std::string outputTblXmlFileName("eplustbl.xml"); std::string inputIdfFileName; std::string inputIddFileName; std::string inputWeatherFileName; - std::string outputAdsFileName; - std::string outputDfsFileName; - std::string outputDelightInFileName; - std::string outputDelightOutFileName; - std::string outputDelightEldmpFileName; - std::string outputDelightDfdmpFileName; - 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 outputSqlFileName; - std::string outputSqliteErrFileName; + std::string outputAdsFileName("eplusADS.out"); + std::string outputDfsFileName("eplusout.dfs"); + std::string outputDelightInFileName("eplusout.delightin"); + std::string outputDelightOutFileName("eplusout.delightout"); + std::string outputDelightEldmpFileName("eplusout.delighteldmp"); + std::string outputDelightDfdmpFileName("eplusout.delightdfdmp"); + std::string outputMapTabFileName("eplusmap.tab"); + std::string outputMapCsvFileName("eplusmap.csv"); + std::string outputMapTxtFileName("eplusmap.txt"); + std::string outputEddFileName("eplusout.edd"); + std::string outputIperrFileName("eplusout.iperr"); + std::string outputDbgFileName("eplusout.dbg"); + std::string outputSlnFileName("eplusout.sln"); + std::string outputSciFileName("eplusout.sci"); + std::string outputWrlFileName("eplusout.wrl"); + std::string outputZszCsvFileName("epluszsz.csv"); + std::string outputZszTabFileName("epluszsz.tab"); + std::string outputZszTxtFileName("epluszsz.txt"); + std::string outputSszCsvFileName("eplusssz.csv"); + std::string outputSszTabFileName("eplusssz.tab"); + std::string outputSszTxtFileName("eplusssz.txt"); + std::string outputScreenCsvFileName("eplusscreen.csv"); + std::string outputSqlFileName("eplusout.sql"); + std::string outputSqliteErrFileName("eplussqlite.err"); std::string EnergyPlusIniFileName; std::string inStatFileName; - std::string TarcogIterationsFileName; + std::string TarcogIterationsFileName("TarcogIterations.dbg"); std::string eplusADSFileName; - std::string outputCsvFileName; - std::string outputMtrCsvFileName; - std::string outputRvauditFileName; + std::string outputCsvFileName("eplusout.csv"); + std::string outputMtrCsvFileName("eplusmtr.csv"); + std::string outputRvauditFileName("eplusout.rvaudit"); std::string idfFileNameOnly; std::string idfDirPathName; diff --git a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc index b38a24f6496..53b076308dc 100644 --- a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc @@ -39,8 +39,6 @@ TEST( ProcessZoneDataTest, Test1 ) int NumNumbers ( 9 ); cCurrentModuleObject = "Zone"; - DataStringGlobals::outputErrFileName = "eplusout.err"; - DataStringGlobals::outputMtdFileName = "eplusout.mtd"; NumOfZones = 2; Zone.allocate( NumOfZones ); From beef3d50dc138279d4185a33bc1c96eb4aab7b48 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Wed, 28 Jan 2015 08:02:29 -0700 Subject: [PATCH 71/71] Removing unnecessary CLI test --- cmake/RunCommandLineArgTest.cmake | 20 -------------------- src/EnergyPlus/CMakeLists.txt | 8 -------- 2 files changed, 28 deletions(-) delete mode 100644 cmake/RunCommandLineArgTest.cmake diff --git a/cmake/RunCommandLineArgTest.cmake b/cmake/RunCommandLineArgTest.cmake deleted file mode 100644 index 3314e1cd8a5..00000000000 --- a/cmake/RunCommandLineArgTest.cmake +++ /dev/null @@ -1,20 +0,0 @@ - # Set up for convenience - set(TEST_DIR "tst/cli_args") - - # Find and execute the test executable, passing the argument of the directory to run in - if( WIN32 ) - set(ECHO_CMD cmd /C echo.) - else() - set(ECHO_CMD "echo") - endif() - find_program(TEST_EXE "energyplus" PATHS "${BINARY_DIR}/Products/" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) - execute_process(COMMAND ${ECHO_CMD} COMMAND "${TEST_EXE}" -d "${BINARY_DIR}/${TEST_DIR}" -D "${SOURCE_DIR}/testfiles/${IDF_FILE}" RESULT_VARIABLE RESULT) - - # Check the outputs and return appropriately - file(READ "${BINARY_DIR}/${TEST_DIR}/eplusout.end" FILE_CONTENT) - string(FIND "${FILE_CONTENT}" "EnergyPlus Completed Successfully" RESULT) - if( RESULT EQUAL 0 ) - message("Test Passed") - else() - message("Test Failed") - endif() diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index fdfe07f50fb..4b13272f869 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -596,14 +596,6 @@ if( BUILD_TESTING ) -DIDF_FILE=1ZoneUncontrolled.idf -DEPW_FILE=USA_CO_Golden-NREL.724666_TMY3.epw -P ${CMAKE_SOURCE_DIR}/cmake/RunCallbackTest.cmake) - add_test(NAME "integration.TestCommandLineArguments" - COMMAND ${CMAKE_COMMAND} - -DSOURCE_DIR=${CMAKE_SOURCE_DIR} - -DBINARY_DIR=${CMAKE_BINARY_DIR} - -DIDF_FILE=1ZoneUncontrolled.idf - -P ${CMAKE_SOURCE_DIR}/cmake/RunCommandLineArgTest.cmake) - set_tests_properties("integration.TestEnergyPlusCallbacks" PROPERTIES PASS_REGULAR_EXPRESSION "Test Passed") - set_tests_properties("integration.TestEnergyPlusCallbacks" PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR;FAIL;Test Failed") endif() if(UNIX AND NOT APPLE)