Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnergyPlus with option --expandobjects set fails when working directory is not on the same device as the output directory (on Linux) #8376

Closed
3 tasks
MaximilianAzendorf opened this issue Nov 12, 2020 · 1 comment · Fixed by #8410 or #8480
Assignees
Labels
AuxiliaryTool Related to an auxiliary tool, not EnergyPlus itself (readvars, preprocessor, ep-launch, etc.) Defect Includes code to repair a defect in EnergyPlus

Comments

@MaximilianAzendorf
Copy link

MaximilianAzendorf commented Nov 12, 2020

Issue overview

ExpandObjects writes two files named expanded.idf and expandedidf.err into the working directory and then moves them (via rename() unix syscall) into the output directory. This does not work if the working directory is not on the same device as the output directory (e.g. a working directory in /tmp while the output directory is under an externally mounted /home).

Details

Some additional details for this issue (if relevant):

  • Platform: Arch Linux x64 (linux 5.9.4)
  • Version of EnergyPlus: 9.4.0

Checklist

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Defect file added (list location of defect file here)
  • Ticket added to Pivotal for defect (development team task)
  • Pull request created (the pull request will have additional tasks related to reviewing changes that fix this defect)
@jmarrec jmarrec self-assigned this Dec 2, 2020
@jmarrec jmarrec added AuxiliaryTool Related to an auxiliary tool, not EnergyPlus itself (readvars, preprocessor, ep-launch, etc.) Defect Includes code to repair a defect in EnergyPlus labels Dec 2, 2020
jmarrec added a commit that referenced this issue Dec 4, 2020
@jmarrec
Copy link
Contributor

jmarrec commented Dec 4, 2020

@MaximilianAzendorf Thanks for the issue report.

This the Fortran OPEN command that is indeed used to create the file.

https://github.com/NREL/EnergyPlus/blob/4e2af181c66c3a55748df2f7167ae5aae41a7e15/src/ExpandObjects/epfilter.f90#L1935-L1962

The CLI will then move it via moveFile:

if (runExpandObjects) {
std::string expandObjectsPath = exeDirectory + "ExpandObjects" + exeExtension;
if (!fileExists(expandObjectsPath)) {
DisplayString(state, "ERROR: Could not find ExpandObjects executable: " + getAbsolutePath(expandObjectsPath) + ".");
exit(EXIT_FAILURE);
}
std::string expandObjectsCommand = "\"" + expandObjectsPath + "\"";
bool inputFileNamedIn = (getAbsolutePath(inputFileName) == getAbsolutePath("in.idf"));
// check if IDD actually exists since ExpandObjects still requires it
if (!fileExists(inputIddFileName)) {
DisplayString(state, "ERROR: Could not find input data dictionary: " + getAbsolutePath(inputIddFileName) + ".");
DisplayString(state, errorFollowUp);
exit(EXIT_FAILURE);
}
bool iddFileNamedEnergy = (getAbsolutePath(inputIddFileName) == getAbsolutePath("Energy+.idd"));
if (!inputFileNamedIn) linkFile(inputFileName.c_str(), "in.idf");
if (!iddFileNamedEnergy) linkFile(inputIddFileName, "Energy+.idd");
systemCall(expandObjectsCommand);
if (!inputFileNamedIn) removeFile("in.idf");
if (!iddFileNamedEnergy) removeFile("Energy+.idd");
moveFile("expandedidf.err", outputExperrFileName);
if (fileExists("expanded.idf")) {
moveFile("expanded.idf", outputExpidfFileName);
inputFileName = outputExpidfFileName;
}
}

moveFile does indeed use a rename syscall on Unix:

void moveFile(std::string const &filePath, std::string const &destination)
{
#ifdef _WIN32
//Note: on Windows, rename function doesn't always replace the existing file so MoveFileExA is used
MoveFileExA(filePath.c_str(), destination.c_str(), MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
#else
rename(filePath.c_str(), destination.c_str());
#endif
}

jmarrec added a commit that referenced this issue Jan 22, 2021
Myoldmopar added a commit that referenced this issue Feb 11, 2021
#8376 - EnergyPlus with option --expandobjects set fails when working directory is not on the same device as the output directory (on Unix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AuxiliaryTool Related to an auxiliary tool, not EnergyPlus itself (readvars, preprocessor, ep-launch, etc.) Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
2 participants