Skip to content

Commit

Permalink
Merge #28
Browse files Browse the repository at this point in the history
28: Aj/add ci tests r=trontrytel a=trontrytel

This PR:
 - fixes our `Project.toml` (added package name, uuid and CliMA as authors)
 - adds simple CI test
 - adds  Codecov
 - adds Compat
 - trimms our dependencies

Don't know why, but the ubuntu ci is broken. Leaving it now as an open issue. 

Fixes #5 #13 

Co-authored-by: Anna Jaruga <[email protected]>
  • Loading branch information
bors[bot] and trontrytel authored May 26, 2022
2 parents a61f46c + ef86f1d commit 0acbbff
Show file tree
Hide file tree
Showing 11 changed files with 1,740 additions and 33 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CompatHelper
on:
schedule:
- cron: '00 00 * * *'
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} # optional
run: julia -e 'using CompatHelper; CompatHelper.main()'
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: ci
on:
push:
branches:
- main
- trying
- staging
tags: '*'
pull_request:

jobs:
test:
name: ci ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.7.2'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ docs/site/
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
test/Manifest.toml
30 changes: 11 additions & 19 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,31 @@ authors = ["Climate Modeling Alliance"]
version = "0.1.0"

[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
ClimaCommsMPI = "5f86816e-8b66-43b2-912e-75384f99de49"
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
ClimaCorePlots = "cf7c7e5a-b407-4c48-9047-11a94a308626"
ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70"
ClimaCoreVTK = "c8b6d40d-e815-466f-95ae-c48aefa668fa"
ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
CloudMicrophysics = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
DiffEqOperators = "9fdde737-9c7f-55bf-ade8-46b3f136cc48"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
OrdinaryDiffEq = "5.64.0"
CLIMAParameters = "0.4"
ClimaCore = "0.10"
ClimaCorePlots = "0.2"
CloudMicrophysics = "0.5"
NCDatasets = "0.12"
OrdinaryDiffEq = "6.13"
Plots = "1.29"
ProgressLogging = "0.1"
TerminalLoggers = "0.1"
Thermodynamics = "0.7"
UnPack = "1.0"

[extras]
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
39 changes: 28 additions & 11 deletions src/KiD_driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,27 @@
This should be turned into a test file
"""

include("KiD.jl")
include("Kinematic1D.jl")

import ClimaCore
import Thermodynamics
import CloudMicrophysics
import CLIMAParameters

import NCDatasets
import OrdinaryDiffEq
import UnPack

const FT = Float64

const CC = ClimaCore
const TD = Thermodynamics
const CP = CLIMAParameters
const NC = NCDatasets
const ODE = OrdinaryDiffEq

const KID = Kinematic1D

# Instantiate CliMA Parameters
struct EarthParameterSet{NT} <: CP.AbstractEarthParameterSet
nt::NT
Expand All @@ -31,38 +48,38 @@ q_surf = 0.016
ρw0 = 0.0

# initialize the timestepping struct
TS = TimeStepping(FT(Δt), FT(Δt_output), FT(t_end))
TS = KID.TimeStepping(FT(Δt), FT(Δt_output), FT(t_end))

# create the coordinates,
space, face_space = make_function_space(z_min, z_max, n_elem)
space, face_space = KID.make_function_space(FT, z_min, z_max, n_elem)

coord = CC.Fields.coordinate_field(space)
face_coord = CC.Fields.coordinate_field(face_space)

# initialize the netcdf output Stats struct
Stats = NetCDFIO_Stats("Output.nc", 1.0, vec(face_coord), vec(coord))
Stats = KID.NetCDFIO_Stats("Output.nc", 1.0, vec(face_coord), vec(coord))

# solve the initial value problem for density profile
ρ_profile = ρ_ivp(FT, params)
ρ_profile = KID.ρ_ivp(FT, params)
# create the initial condition profiles
init = map(coord -> init_1d_column(FT, params, ρ_profile, coord.z), coord)
init = map(coord -> KID.init_1d_column(FT, params, ρ_profile, coord.z), coord)

# create state vector and apply initial condition
Y = initialise_state(EquilibriumMoisture(), NoPrecipitation(), init)
Y = KID.initialise_state(KID.EquilibriumMoisture(), KID.NoPrecipitation(), init)

# create aux vector and apply initial condition
aux = initialise_aux(init, params, w_params, q_surf, ρw0, TS, Stats, face_space)
aux = KID.initialise_aux(init, params, w_params, q_surf, ρw0, TS, Stats, face_space)

# output the initial condition
KiD_output(aux, 0.0)
KID.KiD_output(aux, 0.0)

# Define callbacks for output
callback_io = ODE.DiscreteCallback(condition_io, affect_io!; save_positions = (false, false))
callback_io = ODE.DiscreteCallback(KID.condition_io, KID.affect_io!; save_positions = (false, false))
callbacks = ODE.CallbackSet(callback_io)

# collect all the tendencies into rhs function for ODE solver
# based on model choices for the solved equations
ode_rhs! = make_rhs_function(EquilibriumMoisture(), NoPrecipitation())
ode_rhs! = KID.make_rhs_function(KID.EquilibriumMoisture(), KID.NoPrecipitation())

# Solve the ODE operator
problem = ODE.ODEProblem(ode_rhs!, Y, (t_ini, t_end), aux)
Expand Down
4 changes: 3 additions & 1 deletion src/KiD_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Interface to ClimaCore.jl Returns an instance of space and face space
(which are a discretized function space over our computational domain).
"""
function make_function_space(z_min, z_max, n_elem)
function make_function_space(FT, z_min, z_max, n_elem)
domain = CC.Domains.IntervalDomain(
CC.Geometry.ZPoint{FT}(z_min),
CC.Geometry.ZPoint{FT}(z_max),
Expand Down Expand Up @@ -74,6 +74,8 @@ end
and passed to ODE solver via the `p` parameter of the ODEProblem.
"""
function initialise_aux(initial_profiles, params, w_params, q_surf, ρw0, TS, Stats, face_space)
FT = eltype(q_surf)

ρw = CC.Geometry.WVector.(zeros(FT, face_space))

return CC.Fields.FieldVector(;
Expand Down
4 changes: 4 additions & 0 deletions src/KiD.jl → src/Kinematic1D.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module Kinematic1D

import ClimaCore
import Thermodynamics
import CloudMicrophysics
Expand All @@ -24,3 +26,5 @@ include("NetCDFIO.jl")
include("callbacks.jl")
include("initial_condition.jl")
include("tendency.jl")

end
Loading

0 comments on commit 0acbbff

Please sign in to comment.