sandialabs / CACTUS

CACTUS (Code for Axial and Cross-flow TUrbine Simulation) is a turbine performance simulation code, based on a free wake vortex method, to study wind turbines and marine hydrokinetic (MHK) devices.
BSD 3-Clause "New" or "Revised" License
20 stars 13 forks source link

Errors when output dir/files exist #10

Open whophil opened 8 years ago

whophil commented 8 years ago

Issue by petebachant Saturday Apr 16, 2016 at 00:34 GMT Originally opened as https://github.com/whophil/CACTUS-SNL/issues/32


Making a new output dir was a good idea, but it may already exist, and produce errors like

mkdir: cannot create directory ‘output’: File exists
mkdir: cannot create directory ‘output/field’: File exists
mkdir: cannot create directory ‘output/element’: File exists
whophil commented 8 years ago

Comment by whophil Saturday Apr 16, 2016 at 00:45 GMT


The system call to mkdir does produce errors if the directory exists, but it doesn't halt the code (at least not on my system). If the code continues, I'd say this is more of a warning than an error.

Does the code halt on your system?

whophil commented 8 years ago

Comment by petebachant Saturday Apr 16, 2016 at 00:47 GMT


Seems like it keeps running. Can we do something like mkdir -p?

whophil commented 8 years ago

Comment by whophil Saturday Apr 16, 2016 at 00:51 GMT


Unfortunately that would kill Windows compatibility. mkdir exists on Windows but it lacks the -p option. I think I looked briefly into a compiler and platform agnostic way to create directories on Linux/Windows and this was the easiest to implement at the time. There is probably a better way, though...

whophil commented 8 years ago

Comment by petebachant Saturday Apr 16, 2016 at 01:30 GMT


Ah! Oh well. I will just remove the directory each run.

whophil commented 8 years ago

Comment by whophil Monday Apr 18, 2016 at 18:05 GMT


I think I see the problem now which arises when you call CACTUS via script and it raises an "Error," potentially halting your script. Of course you could just clean the output directories before you call CACTUS. A more robust solution would be to compile different code bits under different environments using IFDEF statements, and then call the appropriate mkdir commands under each environment.

whophil commented 8 years ago

Comment by whophil Tuesday Apr 19, 2016 at 03:07 GMT


See https://github.com/whophil/CACTUS/commit/e5cb8da880f4e8086be8470ad07bf8c867437075

I haven't had time to test it on Windows or with Intel Fortran, but it works using GFortran on Linux, which I believe is your environment as well.

whophil commented 8 years ago

Comment by petebachant Tuesday Apr 19, 2016 at 03:37 GMT


Can confirm it works on Linux with GFortran. I don't have an environment setup to compile Fortran on Windows to test though.