Skip to content

Commit ed871d9

Browse files
committed
2 parents 3c98b8c + e3d0422 commit ed871d9

File tree

5 files changed

+40
-38
lines changed

5 files changed

+40
-38
lines changed

.github/workflows/CI.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ on:
44
branches:
55
- main
66
- ci
7-
tags: '*'
7+
tags: ['*']
88
pull_request:
9+
workflow_dispatch:
910
jobs:
1011
test:
1112
name: Julia ${{ matrix.group }} - ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
1213
runs-on: ${{ matrix.os }}
14+
timeout-minutes: 60
15+
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
16+
actions: write
17+
contents: read
1318
strategy:
1419
fail-fast: false
1520
matrix:
@@ -18,7 +23,7 @@ jobs:
1823
- Basic
1924
version:
2025
- '1'
21-
- '1.6'
26+
- '1.10'
2227
os:
2328
- ubuntu-latest
2429
arch:
@@ -30,15 +35,6 @@ jobs:
3035
version: ${{ matrix.version }}
3136
arch: ${{ matrix.arch }}
3237
- uses: julia-actions/cache@v2
33-
env:
34-
cache-name: cache-artifacts
35-
with:
36-
path: ~/.julia/artifacts
37-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
38-
restore-keys: |
39-
${{ runner.os }}-test-${{ env.cache-name }}-
40-
${{ runner.os }}-test-
41-
${{ runner.os }}-
4238
- uses: julia-actions/julia-buildpkg@v1
4339
- uses: julia-actions/julia-runtest@v1
4440
env:
@@ -48,27 +44,32 @@ jobs:
4844
with:
4945
file: lcov.info
5046
token: ${{ secrets.CODECOV_TOKEN }}
51-
fail_ci_if_error: false
47+
fail_ci_if_error: true
5248
docs:
5349
name: Documentation
5450
runs-on: ubuntu-latest
5551
steps:
5652
- uses: actions/checkout@v4
5753
- uses: julia-actions/setup-julia@v2
58-
with:
59-
version: '1'
6054
- uses: cjdoris/julia-downgrade-compat-action@v1
61-
if: ${{ matrix.version == '1.6' }}
55+
if: ${{ matrix.version == '1.10' }}
6256
with:
6357
skip: Pkg,TOML,Statistics
58+
- name: Configure doc environment
59+
shell: julia --project=docs --color=yes {0}
60+
run: |
61+
using Pkg
62+
Pkg.develop(PackageSpec(path=pwd()))
63+
Pkg.instantiate()
6464
- uses: julia-actions/julia-buildpkg@v1
6565
- uses: julia-actions/julia-docdeploy@v1
6666
env:
6767
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
69-
- run: |
70-
julia --project=docs -e '
71-
using Documenter: DocMeta, doctest
69+
- name: Run doctests
70+
shell: julia --project=docs --color=yes {0}
71+
run: |
72+
using Documenter: DocMeta, doctest
7273
using Bigleaf
7374
DocMeta.setdocmeta!(Bigleaf, :DocTestSetup, :(using Bigleaf); recursive=true)
7475
doctest(Bigleaf)

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ StatsBase = "0.33.12, 0.34"
3939
Suppressor = "0.2"
4040
Tables = "1.6.0"
4141
TimeZones = "1.6.1"
42-
julia = "1.6"
42+
julia = "1.10"
4343

4444
[workspace]
4545
projects = ["test", "docs"]

src/surface_roughness.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,26 @@ rp = roughness_parameters(Roughness_wind_profile(),df;zh,zr=40,d=0.8*zh)
146146
≈(rp.z0m, 0.55, rtol=0.1)
147147
# output
148148
true
149-
```
150-
"""
151-
function roughness_parameters(::RoughnessCanopyHeight, zh; frac_d=0.7, frac_z0m=0.1)
149+
```
150+
"""
151+
function roughness_parameters(::RoughnessCanopyHeight, zh::FT;
152+
frac_d=FT(0.7), frac_z0m=FT(0.1)) where FT
152153
d = frac_d*zh
153154
z0m = frac_z0m*zh
154155
z0m_se = missing
155156
(;d, z0m, z0m_se)
156157
end
157158

158-
function roughness_parameters(::RoughnessCanopyHeightLAI, zh, LAI;
159-
cd=0.2, hs=0.01)
159+
function roughness_parameters(::RoughnessCanopyHeightLAI, zh::FT, LAI;
160+
cd=FT(0.2), hs=FT(0.01)) where FT
160161
X = cd * LAI
161-
d = 1.1 * zh * log(1 + X^(1/4))
162-
z0m = ifelse(0 <= X <= 0.2, hs + 0.3 * X^(1/2), 0.3 * zh * (1 - d/zh))
162+
d = FT(1.1) * zh * log(1 + X^FT(1/4))
163+
z0m = ifelse(0 <= X <= FT(0.2), hs + FT(0.3) * X^(1/2), FT(0.3) * zh * (1 - d/zh))
163164
z0m_se = missing
164165
(;d, z0m, z0m_se)
165166
end
166167

167-
function roughness_parameters(::Roughness_wind_profile, ustar::AbstractVector{FT}, wind, psi_m;
168+
function roughness_parameters(::Roughness_wind_profile, ustar::AbstractVector{FT}, wind, psi_m;
168169
zh, zr, d = 0.7*zh, constants=BigleafConstants()
169170
) where FT
170171
FT == Missing && return((d = d, z0m = missing, z0m_se = missing))

src/unit_conversions.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ function Esat_slope(Tair::Number; Esat_formula=Sonntag1990(), constants=BigleafC
6060
Delta = Esat_from_Tair_deriv(Tair; Esat_formula, constants)
6161
Esat, Delta
6262
end,
63-
function Esat_from_Tair(Tair; Esat_formula=Sonntag1990(), constants=BigleafConstants())
64-
a,b,c = get_EsatCoef(Esat_formula)
65-
Esat = a * exp((b * Tair) / (c + Tair)) * constants.Pa2kPa
63+
function Esat_from_Tair(Tair::FT; Esat_formula=Sonntag1990(), constants=BigleafConstants()) where FT
64+
a,b,c = map(x -> convert(FT,x), get_EsatCoef(Esat_formula))
65+
Esat = a * exp((b * Tair) / (c + Tair)) * FT(constants.Pa2kPa)
6666
end,
67-
function Esat_from_Tair_deriv(Tair; Esat_formula=Sonntag1990(), constants=BigleafConstants())
67+
function Esat_from_Tair_deriv(Tair::FT; Esat_formula=Sonntag1990(), constants=BigleafConstants()) where FT
6868
# slope of the saturation vapor pressure curve
6969
#Delta = eval(D(expression(a * exp((b * Tair) / (c + Tair))),name="Tair"))
70-
a,b,c = get_EsatCoef(Esat_formula)
70+
a,b,c = map(x -> convert(FT,x), get_EsatCoef(Esat_formula))
7171
#Delta_Pa = @. a*(b / (Tair + c) + (-Tair*b) / ((Tair + c)^2))*exp((Tair*b) / (Tair + c))
72-
Delta_Pa = @. a * (exp((b * Tair)/(c + Tair)) * (b/(c + Tair) - (b * Tair)/(c + Tair)^2))
73-
Delta = Delta_Pa .* constants.Pa2kPa
72+
Delta_Pa = a * (exp((b * Tair)/(c + Tair)) * (b/(c + Tair) - (b * Tair)/(c + Tair)^2))
73+
Delta = Delta_Pa .* FT(constants.Pa2kPa)
7474
end
7575

7676
get_EsatCoef(::Sonntag1990) = (a=611.2,b=17.62,c=243.12)
@@ -145,12 +145,12 @@ true
145145
"""
146146
function ms_to_mol(G_ms,Tair,pressure; constants=BigleafConstants())
147147
Tair = Tair + oftype(Tair,constants.Kelvin)
148-
pressure = pressure * constants.kPa2Pa
148+
pressure = pressure * oftype(Tair, constants.kPa2Pa)
149149
G_mol = G_ms * pressure / (oftype(Tair, constants.Rgas) * Tair)
150150
end,
151151
function mol_to_ms(G_mol,Tair,pressure; constants=BigleafConstants())
152152
Tair = Tair + oftype(Tair,constants.Kelvin)
153-
pressure = pressure * constants.kPa2Pa
153+
pressure = pressure * oftype(Tair, constants.kPa2Pa)
154154
G_ms = G_mol * (oftype(Tair, constants.Rgas) * Tair) / (pressure)
155155
end
156156

test/unit_conversions_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Bigleaf, Test
22

33
@testset "Esat_from_Tair" begin
4-
Tair = 15
4+
Tair = 15.0
55
Esat_formula=Sonntag1990()
66
constants=BigleafConstants()
77
eSat = Esat_from_Tair(Tair; Esat_formula, constants)
@@ -25,7 +25,7 @@ end
2525
constants=BigleafConstants()
2626
Esat = Esat_from_Tair.(Tair)
2727
delta = Esat_from_Tair_deriv.(Tair)
28-
delta2 = diff(Esat)/step
28+
delta2 = diff(Esat)/step
2929
@test all(isapprox.(delta[2:end] - delta2, 0, atol=1e-3))
3030
Esat3, delta3 = Esat_slope(Tair[1])
3131
@test Esat3 Esat[1]

0 commit comments

Comments
 (0)