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

Try to update the code to Julia1.10 #36

Merged
merged 32 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
911b4df
load julia1.10 in run_all.py
tomchor Jun 8, 2024
3a0d2b1
Merge branch 'main' into julia1.10
tomchor Jun 17, 2024
2e2ba82
update manifest
tomchor Jun 17, 2024
f5b4ce4
force hydrostatic separation
tomchor Jun 17, 2024
be9f381
better way to get info about GPU
tomchor Jun 17, 2024
72d264b
start investigating why grid metric writing is slow af
tomchor Jun 17, 2024
516a461
fix write_to_ds function
tomchor Jun 19, 2024
6d1284e
get versioninfo
tomchor Jun 30, 2024
26bf03b
Merge branch 'main' into julia1.10
tomchor Jul 25, 2024
48328e1
Merge branch 'main' into julia1.10
tomchor Jul 27, 2024
af020cb
test Oceananigans with corrected Averaging
tomchor Nov 14, 2024
1109944
bugfixes
tomchor Nov 14, 2024
005f679
fixes
tomchor Nov 14, 2024
a13e374
update DimData and Rasters
tomchor Nov 14, 2024
75b3750
make progess work
tomchor Nov 15, 2024
87b7aa2
update Oceanostics
tomchor Nov 15, 2024
c9008b1
fix plotting for python 3.12
tomchor Nov 16, 2024
f9a3973
fix hplot07
tomchor Nov 16, 2024
61aa454
fix hplot06
tomchor Nov 16, 2024
ea102c4
fix hplot12 and 13
tomchor Nov 16, 2024
82fc691
remove trailing white spaces
tomchor Nov 16, 2024
1a1554f
use oceananigans version with fixed bug
tomchor Nov 18, 2024
34fe487
Merge branch 'main' into julia1.10
tomchor Nov 26, 2024
332eca4
change color range in hplot13
tomchor Nov 27, 2024
911e351
Merge branch 'julia1.10' of github.com:tomchor/submesoscale-headland …
tomchor Nov 27, 2024
94e2850
shorter wall time limit
tomchor Nov 27, 2024
cff3967
plotted vertical shear in addition to v for hplot04
tomchor Nov 28, 2024
6c1195e
plotted dudz instead of v
tomchor Nov 28, 2024
521b66c
typo
tomchor Nov 28, 2024
26965b7
confirm that figures are fine
tomchor Nov 29, 2024
0e9c219
clean up of old scripts
tomchor Nov 29, 2024
1346e6f
renamed figures
tomchor Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,624 changes: 864 additions & 760 deletions Manifest.toml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions aux02_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
"v" : dict(vmin=-0.01, vmax=+0.01, cmap=plt.cm.RdBu_r),
"v̂" : dict(vmin=-1.2, vmax=+1.2, cmap=cm.balance),
"w" : dict(vmin=-0.003, vmax=+0.003, cmap=plt.cm.RdBu_r),
"∂u∂z" : dict(robust=True, cmap=plt.cm.RdBu_r),
"PV_norm" : dict(vmin=-5, vmax=5, cmap="RdBu_r"),
"PVᶻ_norm" : dict(vmin=-5, vmax=5, cmap="RdBu_r"),
"PVʰ_norm" : dict(vmin=-5, vmax=5, cmap="RdBu_r"),
Expand Down Expand Up @@ -302,6 +303,7 @@ def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
"PV_norm" : r"Normalized Ertel PV (PV$/f N^2_\infty$)",
"v" : r"$v$-velocity [m/s]",
"v̂" : r"Normalized $v$-velocity ($v/V_\infty$)",
"∂u∂z" : r"$\partial u / \partial z$",
}
#---

12 changes: 10 additions & 2 deletions diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ using Oceananigans.Operators
import NCDatasets as NCD
function write_to_ds(dsname, varname, data; coords=("xC", "yC", "zC"), dtype=Float64)
ds = NCD.NCDataset(dsname, "a")
if varname ∉ ds
if varname ∉ keys(ds)
newvar = NCD.defVar(ds, varname, dtype, coords)
newvar[:,:,:] = Array(data)
if length(size(data)) == 3
newvar[:,:,:] = Array(data)
elseif length(size(data)) == 2
newvar[:,:] = Array(data)
elseif length(size(data)) == 1
newvar[:] = Array(data)
else
newvar = data
end
end
NCD.close(ds)
end
Expand Down
9 changes: 5 additions & 4 deletions grid_metrics.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Oceananigans.Grids: xspacing, yspacing, zspacing, xnode, ynode, znode, boundary_node, inactive_node, destantiate
using Oceananigans: location

flip_loc(::Center) = Face()
flip_loc(::Face) = Center()
Expand Down Expand Up @@ -36,9 +37,9 @@ using Oceananigans.OutputWriters: fetch_and_convert_output, drop_output_dims,
using Oceananigans.Fields: AbstractField
using NCDatasets: defVar

define_timeconstant_variable!(dataset, output::AbstractField, name, array_type, compression, output_attributes, dimensions) =
define_timeconstant_variable!(dataset, output::AbstractField, name, array_type, deflatelevel, output_attributes, dimensions) =
defVar(dataset, name, eltype(array_type), netcdf_spatial_dimensions(output),
compression=compression, attrib=output_attributes)
deflatelevel=deflatelevel, attrib=output_attributes)

function save_output!(ds, output, model, ow, name)

Expand Down Expand Up @@ -123,8 +124,7 @@ function write_grid_metrics!(ow, metrics; user_indices = (:, :, :), with_halos=f
for (metric_name, metric_operation) in metrics
indices = output_indices(metric_operation, metric_operation.grid, user_indices, with_halos)
sliced_metric = Field(metric_operation, indices=indices)

if metric_name ∉ ds
if metric_name ∉ keys(ds)
define_timeconstant_variable!(ds, sliced_metric, metric_name, ow.array_type, 0, Dict(), ("xC", "yC", "zC"))
save_output!(ds, sliced_metric, model, ow, metric_name)
end
Expand All @@ -134,6 +134,7 @@ end

function add_grid_metrics_to!(ow; kwargs...)
Δξ_list = grid_spacings(grid, ow)
@info "Got Δξ_list"
write_grid_metrics!(ow, Δξ_list; kwargs...)
end

2 changes: 1 addition & 1 deletion h00_runall.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"NPN-R1F1",
]
modifiers = ["-f4", "-f2", "-S-f4", "-S-f2","-AMD-f4", "-AMD-f2",]
modifiers = ["-f4", "-f2", ""]
modifiers = ["-f2", "-S-f2", "", "-S"]
#---


Expand Down
2 changes: 1 addition & 1 deletion h01_energy_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from cycler import cycler
names = cycler(name=simnames)
modifiers = cycler(modifier = ["-f4", "-S-f4", "-f2", "-S-f2", "", "-S"])
modifiers = cycler(modifier = ["-f4",])
modifiers = cycler(modifier = ["-f2",])
simnames = [ nr["name"] + nr["modifier"] for nr in modifiers * names ]
#---

Expand Down
13 changes: 9 additions & 4 deletions headland_simulations/headland.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
if ("PBS_JOBID" in keys(ENV)) @info "Job ID" ENV["PBS_JOBID"] end # Print job ID if this is a PBS simulation
#using Pkg
#Pkg.instantiate()
using InteractiveUtils
println(versioninfo())
using DrWatson
using ArgParse
using Oceananigans
Expand Down Expand Up @@ -271,7 +275,8 @@ model = NonhydrostaticModel(grid = grid, timestepper = :RungeKutta3,
closure = closure,
boundary_conditions = bcs,
forcing = (u=Fᵤ, v=Fᵥ, w=Fw, b=Fb),
)
hydrostatic_pressure_anomaly = CenterField(grid),
)
@info "" model
if has_cuda_gpu() run(`nvidia-smi -i $(ENV["CUDA_VISIBLE_DEVICES"])`) end

Expand All @@ -282,15 +287,15 @@ set!(model, b=(x, y, z) -> b∞(x, y, z, 0, f_params), v=params.V_inf)
params = (; params..., T_advective_max = params.T_advective_spinup + params.T_advective_statistics)
simulation = Simulation(model, Δt=0.2*minimum_zspacing(grid.underlying_grid)/params.V_inf,
stop_time=params.T_advective_max * params.T_advective,
wall_time_limit=23.5hours,
wall_time_limit=23hours,
)

using Oceanostics.ProgressMessengers
walltime_per_timestep = StepDuration(with_prefix=false) # This needs to instantiated here, and not in the function below
walltime = Walltime()
progress(simulation) = @info (PercentageProgress(with_prefix=false, with_units=false)
+ "$(round(time(simulation)/params.T_advective; digits=2)) adv periods" + walltime
+ TimeStep() + MaxVelocities() + "CFL = "*AdvectiveCFLNumber(with_prefix=false)
+ TimeStep() + "CFL = "*AdvectiveCFLNumber(with_prefix=false)
+ "step dur = "*walltime_per_timestep)(simulation)
simulation.callbacks[:progress] = Callback(progress, IterationInterval(40))

Expand Down Expand Up @@ -324,7 +329,7 @@ checkpointer = construct_outputs(simulation,
write_xyz = true,
write_xiz = true,
write_xyi = true,
write_iyz = false,
write_iyz = true,
write_ttt = true,
write_tti = true,
debug = false,
Expand Down
5 changes: 3 additions & 2 deletions headland_simulations/run_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
from cycler import cycler
names = cycler(name=simnames)
resolutions = cycler(resolution = ["-f4", "-f2", ""])
resolutions = cycler(resolution = ["-f2", ""])
modifiers = cycler(rotation = ["", "-S", "-AMD"])
modifiers = cycler(rotation = ["",])
modifiers = cycler(rotation = ["", "-S"])
simnames = [ nr["name"] + nr["rotation"] + nr["resolution"] for nr in modifiers * resolutions * names ]
#---

Expand Down Expand Up @@ -58,7 +59,7 @@
module li
module --force purge
module load ncarenv/23.10
module load julia/1.9.2 cuda
module load julia/1.10.2 cuda
module li

#/glade/u/apps/ch/opt/usr/bin/dumpenv # Dumps environment (for debugging with CISL support)
Expand Down
2 changes: 1 addition & 1 deletion hplot04_v_snapshots.py → hplot04_dudz_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
slice_names = ["iyz",]
modifiers = ["-f2", "",]

varnames = ["v̂"]
varnames = ["∂u∂z",]
contour_variable_name = None #"water_mask_buffered"
contour_kwargs = dict(colors="y", linewidths=0.8, linestyles="--", levels=[0])
#---
Expand Down
2 changes: 1 addition & 1 deletion hplot08_dissip_scalings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
ax.grid(True)
ax.set_title("")
ax.set_xlabel("$S_h$")

letterize(axesf, x=0.05, y=0.9, fontsize=14)
fig.savefig(f"figures/dissip_scalings_buffer={buffer}m{modifier}.pdf")
#---
Expand Down
2 changes: 1 addition & 1 deletion hplot13_SPR_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
figsize = (8, 7)

#plot_kwargs = dict(vmin=-0.005, vmax=0.005, cmap=plt.cm.RdBu_r, rasterized=True)
plot_kwargs = dict(vmin=-8e-9, vmax=8e-9, cmap=cm.balance, rasterized=True)
plot_kwargs = dict(vmin=-8e-10, vmax=8e-10, cmap=cm.balance, rasterized=True)
#---

#+++ Create ageostrophic variables and pick subset of simulations
Expand Down
93 changes: 0 additions & 93 deletions hplot14_ageo_vels.py

This file was deleted.

63 changes: 0 additions & 63 deletions hplot22_filtered_qs.py

This file was deleted.

Loading