Skip to content

Commit 1d737b2

Browse files
committed
remove times from constant runs and check if ice is none
1 parent 1a8b566 commit 1d737b2

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

dnora/executer/inputfile/inputfile_writers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,21 @@ def __call__(
274274
+ extension
275275
+ "' & \n"
276276
)
277-
file_out.write(
278-
"LAY 1 " + self.output_var + " OUTPUT " + STR_START + " 1 HR \n"
279-
)
277+
file_out.write("LAY 1 " + self.output_var)
278+
if not homog:
279+
file_out.write(" OUTPUT " + STR_START + " 1 HR ")
280+
file_out.write("\n")
280281
file_out.write("$ \n")
281282

282-
swan_spectral_output_points(file_out, model.grid(), STR_START)
283+
swan_spectral_output_points(file_out, model.grid(), STR_START, homog)
284+
285+
file_out.write("COMPUTE")
286+
if not homog:
287+
file_out.write(
288+
" " + STR_START + " %d MIN " % self.swan_timestep + STR_END
289+
)
290+
file_out.write("\n")
283291

284-
file_out.write(
285-
"COMPUTE "
286-
+ STR_START
287-
+ " %d MIN " % self.swan_timestep
288-
+ STR_END
289-
+ "\n"
290-
)
291292
file_out.write(
292293
"HOTFILE 'hotstart_"
293294
+ model.grid().name

dnora/executer/inputfile/swan_functions.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ def swan_current(
251251
def swan_ice(file_out, ice, STR_START, STR_END, factor: float, ice_path: str) -> None:
252252
"""Writes ice information to SWAN input file"""
253253

254+
if ice is None:
255+
msg.info(
256+
"No ice object provided. Ice information will NOT be written to SWAN input file!"
257+
)
258+
return
259+
254260
delta_Xf = np.round(np.diff(ice.edges("lon")), 5)[0]
255261
delta_Yf = np.round(np.diff(ice.edges("lat")), 5)[0]
256262
for i in range(len(ice_path)):
@@ -298,6 +304,8 @@ def swan_structures(file_out, structures: list[dict]) -> None:
298304
trans = None
299305
refl = 0.0
300306
closed = False
307+
if structures:
308+
file_out.write("$ Define obstacles (structures) \n")
301309
for structure in structures:
302310
trans = structure.get("trans") or trans
303311
if trans is None:
@@ -323,11 +331,12 @@ def swan_structures(file_out, structures: list[dict]) -> None:
323331
file_out.write("\n")
324332

325333

326-
def swan_spectral_output_points(file_out, grid, STR_START: str) -> None:
334+
def swan_spectral_output_points(file_out, grid, STR_START: str, homog: bool) -> None:
327335
"""Writes a list of spectral output points set in grid"""
328336
spec_lon, spec_lat = grid.output_points()
329337
if len(spec_lon) == 0:
330338
return
339+
file_out.write("$ Generate spectral output \n")
331340
file_out.write("POINTS 'pkt' &\n")
332341
for slon, slat in zip(spec_lon, spec_lat):
333342
file_out.write(str(slon) + " " + str(slat) + " &\n")
@@ -337,7 +346,9 @@ def swan_spectral_output_points(file_out, grid, STR_START: str) -> None:
337346
+ "_"
338347
+ STR_START.split(".")[0]
339348
+ "_spec"
340-
+ ".nc"
341-
+ "' & \n"
349+
+ ".nc'"
342350
)
343-
file_out.write("OUTPUT " + STR_START + " 1 HR \n")
351+
if not homog:
352+
file_out.write(" & \n OUTPUT " + STR_START + " 1 HR")
353+
354+
file_out.write(" \n")

0 commit comments

Comments
 (0)