Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 8e7be56

Browse files
committed
AMR/FF: Create output dir if needed
1 parent 58254dd commit 8e7be56

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pyFAST/fastfarm/AMRWindSimulation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
from pathlib import Path
2+
import os
33

44
class AMRWindSimulation:
55
'''
@@ -363,12 +363,15 @@ def write_sampling_params(self, outdir=None):
363363
outdir: str
364364
Input file
365365
'''
366-
outfile = Path(outdir, 'sampling_config.i')
367-
if outfile.is_file():
366+
outfile = os.path.join(outdir, 'sampling_config.i')
367+
if not os.path.exists(outdir):
368+
print(f'Path {outdir} does not exist. Creating it')
369+
os.makedirs(outdir)
370+
if os.path.isfile(outfile):
368371
raise FileExistsError(f"{str(outfile)} already exists! Aborting...")
369372

370373
print(f"Writing to {outfile} ...")
371-
with outfile.open("w") as out:
374+
with open(outfile,"w") as out:
372375
# Write high-level info for sampling
373376
sampling_labels_str = " ".join(str(item) for item in self.sampling_labels)
374377
out.write(f"# Sampling info generated by AMRWindSamplingCreation.py\n")

0 commit comments

Comments
 (0)