Skip to content

Commit

Permalink
GPU vertical diffusion
Browse files Browse the repository at this point in the history
use of closure functions, to specify examples
  • Loading branch information
OsKnoth committed Nov 2, 2023
1 parent 2113200 commit 48effde
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 379 deletions.
48 changes: 47 additions & 1 deletion Examples/testExample.jl
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
using Examples
Base.@kwdef struct ParamGalewskiSphere
H0G = 10000.0
hH = 120.0
alphaG = 1.0/3.0
betaG = 1.0/15.0
lat0G = pi/7.0
lat1G = pi/2.0-lat0G
eN = exp(-4.0/(lat1G-lat0G)^2.0)
uM = 80.0
Omega = 2*pi/24.0/3600.0
end

Param = ParamGalewskiSphere()

abstract type Example end

Base.@kwdef struct Example1 <: Example end

mutable struct Model
Eddy::Any
Prof::Any
end



function (profile::Example1)(Param)
function local_profile(x)
FT = eltype(x)
A = 2 * x
return A
end
function eddy(x)
FT = eltype(x)
A = 3 * x
return A
end
return local_profile,eddy
end

Prof, Eddy = Example1()(Param)
@show eltype(Prof)
@show eltype(Eddy)
Model1 = Model(Prof,Eddy)

Prof(5)
Eddy(7)

16 changes: 11 additions & 5 deletions Examples/testNHSphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ ProfTheta = parsed_args["ProfTheta"]
PertTh = parsed_args["PertTh"]
ProfVel = parsed_args["ProfVel"]
ProfVelGeo = parsed_args["ProfVelGeo"]
RhoVPos = parsed_args["RhoVPos"]
RhoCPos = parsed_args["RhoCPos"]
RhoIPos = parsed_args["RhoIPos"]
RhoRPos = parsed_args["RhoRPos"]
HorLimit = parsed_args["HorLimit"]
Upwind = parsed_args["Upwind"]
Damping = parsed_args["Damping"]
Expand Down Expand Up @@ -161,10 +165,10 @@ Model.uPos = 2
Model.vPos = 3
Model.wPos = 4
Model.ThPos = 5
if Model.Equation == "CompressibleMoist"
Model.RhoVPos = 1
Model.RhoCPos = 2
end
Model.RhoVPos = RhoVPos
Model.RhoCPos = RhoCPos
Model.RhoIPos = RhoIPos
Model.RhoRPos = RhoRPos
Model.HorLimit = HorLimit
Model.Upwind = Upwind
Model.Damping = Damping
Expand Down Expand Up @@ -210,7 +214,9 @@ elseif Problem == "BaroWaveDrySphere"
elseif Problem == "HeldSuarezDrySphere"
Profile = Examples.HeldSuarezDryExample()(Param,Phys)
elseif Problem == "HeldSuarezMoistSphere"
Profile = Examples.HeldSuarezMoistExample()(Param,Phys)
Profile, Eddy = Examples.HeldSuarezMoistExample()(Param,Phys)
Model.InitialProfile = Profile
Model.Eddy = Eddy
end

@show "InitialConditions"
Expand Down
3 changes: 2 additions & 1 deletion Jobs/JobNHBaroWaveDrySphere
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mpirun -n 1 julia --project Examples/testNHSphere.jl \
--Problem="BaroWaveDrySphere" \
--Device="CPU_P" \
--Device="CPU" \
--GPUType="Metal" \
--FloatTypeBackend="Float32" \
--NumberThreadGPU=512 \
Expand All @@ -13,6 +13,7 @@ mpirun -n 1 julia --project Examples/testNHSphere.jl \
--Curl=false \
--ModelType="VectorInvariant" \
--Coriolis=true \
--VerticalDiffusion=true \
--Upwind=true \
--HorLimit=false \
--Buoyancy=true \
Expand Down
6 changes: 3 additions & 3 deletions Jobs/JobNHHeldSuarezDrySphere
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mpirun -n 8 julia --project Examples/testNHSphere.jl \
mpirun -n 1 julia --project Examples/testNHSphere.jl \
--Problem="HeldSuarezDrySphere" \
--Device="CPU" \
--GPUType="Metal" \
Expand Down Expand Up @@ -32,8 +32,8 @@ mpirun -n 8 julia --project Examples/testNHSphere.jl \
--Stretch=true \
--StretchType="Exp" \
--GridType="CubedSphere" \
--nz=64 \
--nPanel=30 \
--nz=30 \
--nPanel=16 \
--H=45000.0 \
--OrdPoly=3 \
--HyperVisc=true \
Expand Down
6 changes: 4 additions & 2 deletions Jobs/JobNHHeldSuarezMoistSphere
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
mpirun -n 1 julia --project Examples/testNHSphere.jl \
--Problem="HeldSuarezMoistSphere" \
--Device="CPU_P" \
--Device="CPU" \
--GPUType="Metal" \
--NumberThreadGPU=512 \
--FloatTypeBackend="Float32" \
--Equation="CompressibleMoist" \
--NumV=5 \
--NumTr=2 \
--RhoVPos=1 \
--RhoCPos=2 \
--ProfpBGrd="" \
--ProfRhoBGrd="" \
--Source=true \
--Force=true \
--Curl=false \
--ModelType="VectorInvariant" \
--VerticalDiffusion=true \
--Coriolis=true \
--Upwind=true \
--HorLimit=false \
Expand Down
176 changes: 0 additions & 176 deletions Notes

This file was deleted.

3 changes: 3 additions & 0 deletions ToDo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zS on equally spaced points,
Transformation to nodal points.

12 changes: 12 additions & 0 deletions src/DyCore/GlobalVariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ Base.@kwdef mutable struct ModelStruct{FT}
PertTh::Bool
RhoVPos::Int
RhoCPos::Int
RhoIPos::Int
RhoRPos::Int
NumV::Int
NumTr::Int
Equation::String
Expand Down Expand Up @@ -310,6 +312,8 @@ Base.@kwdef mutable struct ModelStruct{FT}
Curl::Bool
Stretch::Bool
StretchType::String
InitialProfile::Any
Eddy::Any
end

function ModelStruct{FT}() where FT <:AbstractFloat
Expand All @@ -332,6 +336,8 @@ function ModelStruct{FT}() where FT <:AbstractFloat
PertTh = false
RhoVPos = 0
RhoCPos = 0
RhoIPos = 0
RhoRPos = 0
NumV = 0
NumTr = 0
Equation = "Compressible"
Expand Down Expand Up @@ -367,6 +373,8 @@ function ModelStruct{FT}() where FT <:AbstractFloat
Curl = true
Stretch = false
StretchType = ""
InitialProfile = ""
Eddy = ""
return ModelStruct{FT}(
Problem,
Profile,
Expand All @@ -387,6 +395,8 @@ function ModelStruct{FT}() where FT <:AbstractFloat
PertTh,
RhoVPos,
RhoCPos,
RhoIPos,
RhoRPos,
NumV,
NumTr,
Equation,
Expand Down Expand Up @@ -422,6 +432,8 @@ function ModelStruct{FT}() where FT <:AbstractFloat
Curl,
Stretch,
StretchType,
InitialProfile,
Eddy,
)
end

Expand Down
Loading

0 comments on commit 48effde

Please sign in to comment.