Skip to content

Commit 70a76f2

Browse files
committed
Consistently use @warn for most problems, and @error for immediately critical problems. Update tests to only print @error calls, hiding @warn to avoid spam. Functions return success/failure more consistently.
1 parent 8a6c1f1 commit 70a76f2

18 files changed

Lines changed: 243 additions & 178 deletions

.zenodo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
],
2424
"title": "AGNI: An open-source model for extreme atmospheres on rocky exoplanets",
25-
"version": "1.9.3",
25+
"version": "1.9.4",
2626
"access_right": "open",
2727
"related_identifiers": [
2828
{

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ title: "AGNI: An open-source model for extreme atmospheres on rocky exoplanets"
1010
doi: 10.21105/joss.07726
1111
date-released: 2025-11-20
1212

13-
version: 1.9.3
13+
version: 1.9.4
1414
url: "https://github.com/nichollsh/AGNI"
1515
type: software
1616
license: "GPL-3.0"

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AGNI"
22
uuid = "ede838c1-9ec3-4ebe-8ae8-da4091b3f21c"
33
authors = ["Harrison Nicholls <contact@h-nicholls.space>"]
4-
version = "1.9.3"
4+
version = "1.9.4"
55

66
[deps]
77
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
"keywords": "exoplanets, radiation, astronomy, atmosphere, optimization, julia, fortran, convection, chemistry, magma, planetary, physics",
2020
"license": "GPL-3.0",
2121
"title": "AGNI",
22-
"version": "1.9.3"
22+
"version": "1.9.4"
2323
}

docs/src/tutorials/getting_started.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,28 @@ GNU/Linux and MacOS (including ARM) are supported.
1616
Do not install Julia using your system package manager. Install only from julialang.org as below.
1717

1818
## Installation
19-
Follow the steps below in order to setup the code.
20-
1. Install Julia's package manager: `curl -fsSL https://install.julialang.org | sh`
21-
2. Switch to Julia 1.11: `juliaup add 1.11 && juliaup default 1.11`
22-
3. Download AGNI: `git clone https://github.com/nichollsh/AGNI.git`
19+
Follow the ordered steps below
20+
1. Install Julia's package manager
21+
- `curl -fsSL https://install.julialang.org | sh`
22+
2. Switch to Julia 1.11
23+
- `juliaup add 1.11 && juliaup default 1.11`
24+
3. Download AGNI
25+
- `git clone https://github.com/nichollsh/AGNI.git`
2326
4. Change directory: `cd AGNI`
2427
5. Setup SOCRATES by doing either **ONE** of the following...
25-
- Follow the instructions on the [SOCRATES GitHub](https://github.com/FormingWorlds/SOCRATES) page
26-
- Run `./src/get_socrates.sh`
27-
6. Finally, install AGNI: `./src/get_agni.sh`
28-
AGNI is now installed as a package into the Julia environment of the AGNI
29-
directory. This will also have downloaded some basic input data and run the tests.
28+
a. Follow the instructions on the [SOCRATES GitHub](https://github.com/FormingWorlds/SOCRATES) page
29+
b. **OR**, run `./src/get_socrates.sh`
30+
6. Setup FastChem
31+
- `./src/get_fastchem.sh`
32+
7. Add `RAD_DIR` and `FC_DIR` to your environment and bashrc file
33+
8. Finally, install AGNI
34+
- `./src/get_agni.sh`
35+
36+
AGNI is now installed as a package of the Julia environment in the `AGNI/`
37+
directory. These steps will have downloaded some basic input data.
3038

3139
!!! warning
32-
The `RAD_DIR` environment variable must be set to your SOCRATES path whenever AGNI is being used.
33-
This is so that AGNI can locate the SOCRATES libraries.
40+
The `RAD_DIR` environment variable must be set to your SOCRATES path whenever AGNI is being used. This is so that AGNI can locate the SOCRATES libraries.
3441

3542
!!! tip
3643
Visit the [Troubleshooting](@ref) page if you encounter any problems. This page can

src/AGNI.jl

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ module AGNI
503503

504504
# Setup atmosphere
505505
@debug "Setup atmosphere "
506-
atmosphere.setup!(atmos, ROOT_DIR,output_dir,
506+
if !atmosphere.setup!(atmos, ROOT_DIR,output_dir,
507507
String(cfg["files" ]["input_sf"]),
508508
Float64(cfg["planet"]["instellation"]),
509509
Float64(cfg["planet"]["s0_fact"]),
@@ -537,10 +537,16 @@ module AGNI
537537
rfm_parfile=rfm_parfile,
538538
κ_grey_lw=κ_grey_lw,
539539
κ_grey_sw=κ_grey_sw
540-
) || return false
540+
)
541+
@error "Could not setup atmosphere object"
542+
return false
543+
end
541544

542545
# Allocate atmosphere
543-
atmosphere.allocate!(atmos,star_file; stellar_Teff=star_Teff) || return false
546+
if !atmosphere.allocate!(atmos,star_file; stellar_Teff=star_Teff)
547+
@error "Could not allocate atmosphere object"
548+
return false
549+
end
544550

545551
# Configure deep atmospheric heating
546552
if haskey(cfg["physics"],"deep_heating")
@@ -571,14 +577,21 @@ module AGNI
571577
else
572578
# Set T(p) by looping over requests in the config.
573579
# Each request may be a command, or an argument following a command
574-
setpt.request!(atmos, cfg["execution"]["initial_state"]) || return false
580+
if !setpt.request!(atmos, cfg["execution"]["initial_state"])
581+
@error "Could not set initial temperature profile"
582+
return false
583+
end
575584
end
576585

577586
# Write initial state
578587
save.write_profile(atmos, joinpath(atmos.OUT_DIR,"prof_initial.csv"))
579588

580589
# Run chemistry in the first instance
581-
chemistry.calc_composition!(atmos, oceans, chem, rainout)
590+
chem_state = chemistry.calc_composition!(atmos, oceans, chem, rainout)
591+
if chem_state == 1
592+
@error "Chemistry failed!"
593+
return false
594+
end
582595

583596
# Frame dir
584597
if plt_ani
@@ -588,7 +601,6 @@ module AGNI
588601
end
589602

590603
# Loop over requested solvers
591-
solver_success::Bool = true
592604
return_success::Bool = true
593605
allowed_solvers::Array{String,1} = ["newton", "gauss", "levenberg", "jacobinewton"]
594606
sol = strip(lowercase(cfg["execution"]["solver"]))
@@ -599,15 +611,15 @@ module AGNI
599611

600612
# No solve - just calc fluxes at the end
601613
if sol == "none"
602-
energy.calc_fluxes!(atmos, radiative=true, latent_heat=incl_latent,
614+
return_success &= energy.calc_fluxes!(atmos, radiative=true, latent_heat=incl_latent,
603615
convective=incl_convect, sens_heat=incl_sens,
604616
conductive=incl_conduct,
605617
deep=incl_deep,
606618
calc_cf=Bool(cfg["plots"]["contribution"]))
607619

608620
# Transparent atmosphere solver
609621
elseif sol == "transparent"
610-
solver_success = solver.solve_transparent!(atmos, sol_type=sol_type,
622+
return_success &= solver.solve_transparent!(atmos, sol_type=sol_type,
611623
conv_atol=conv_atol,
612624
conv_rtol=conv_rtol,
613625
max_steps=Int(cfg["execution"]["max_steps"]))
@@ -619,7 +631,7 @@ module AGNI
619631
modplot = 1
620632
end
621633
method_idx = findfirst(==(sol), allowed_solvers)
622-
solver_success = solver.solve_energy!(atmos, sol_type=sol_type,
634+
return_success &= solver.solve_energy!(atmos, sol_type=sol_type,
623635
conduct=incl_conduct, chem=chem,
624636
convect=incl_convect, latent=incl_latent,
625637
sens_heat=incl_sens, deep=incl_deep,
@@ -642,18 +654,17 @@ module AGNI
642654

643655
# Invalid selection
644656
else
645-
@error "Invalid solver '$sol'"
657+
@warn "Invalid solver '$sol'"
646658
return_success = false
647659
end
648660

649-
return_success &= solver_success
650661
@info " done"
651662
@info "Total radiative transfer evaluations: $(atmos.num_rt_eval)"
652663

653664
# RFM calculation?
654665
if atmos.flag_rfm
655666
@info "Running RFM line-by-line radiative transfer..."
656-
rfm.run_rfm(atmos, rfm_wn_min, rfm_wn_max)
667+
return_success &= rfm.run_rfm(atmos, rfm_wn_min, rfm_wn_max)
657668
@info " done"
658669
end
659670

src/atmosphere.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module atmosphere
3333
import ..spectrum
3434

3535
# Code versions
36-
const AGNI_VERSION::String = "1.9.3" # current agni version
36+
const AGNI_VERSION::String = "1.9.4" # current agni version
3737
const SOCVER_minimum::Float64 = 2407.2 # minimum required socrates version
3838

3939
# Hydrostatic+gravity+mass calculation (constants and limits)

src/chemistry.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ module chemistry
520520

521521
# Check that we have some hydrogen...
522522
if N_inp_t[1] < 1e-30
523-
@error "Cannot calculate metallicity of hydrogen-free mixture!"
523+
@warn "Cannot calculate metallicity of hydrogen-free mixture!"
524524
state = 1
525525
end
526526

@@ -546,7 +546,7 @@ module chemistry
546546
if isfinite(atmos.metal_calc[e])
547547
write(f, @sprintf("%s %.3f \n",e,log10(atmos.metal_calc[e]) + 12.0))
548548
else
549-
@error "Got non-finite metallicity for $e - adopting solar value"
549+
@warn "Got non-finite metallicity for $e - adopting solar value"
550550
write(f, @sprintf("%s %.3f \n",e,phys.consts._solar_metallicity[e]))
551551
end
552552

@@ -625,7 +625,7 @@ module chemistry
625625

626626
# Get gas chemistry output
627627
if !isfile(atmos.fastchem_chem)
628-
@error "Could not find fastchem output"
628+
@warn "Could not find FastChem output file '$(atmos.fastchem_chem)'"
629629
return 1
630630
end
631631
(data,head) = readdlm(atmos.fastchem_chem, '\t', Float64, header=true)

src/energy.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,17 @@ module energy
258258
# Check finite
259259
if !all(isfinite, atmos.radout.flux_down)
260260
if lw
261-
@error "Non-finite value in LW DN flux array"
261+
@warn "Non-finite value in LW DN flux array"
262262
else
263-
@error "Non-finite value in SW DN flux array"
263+
@warn "Non-finite value in SW DN flux array"
264264
end
265265
make_finite!(atmos.radout.flux_down, FILL_FINITE_FLUX)
266266
end
267267
if !all(isfinite, atmos.radout.flux_up)
268268
if lw
269-
@error "Non-finite value in LW UP flux array"
269+
@warn "Non-finite value in LW UP flux array"
270270
else
271-
@error "Non-finite value in SW UP flux array"
271+
@warn "Non-finite value in SW UP flux array"
272272
end
273273
make_finite!(atmos.radout.flux_up, FILL_FINITE_FLUX)
274274
end

src/get_agni.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55

66
# User arguments
77
if [ -z "$1" ]; then
8-
testsuite="all" # default
8+
testsuite="fast" # default
99
else
1010
testsuite="$1" # requested test suite
1111
fi
@@ -21,12 +21,21 @@ if [ -n "$RAD_DIR" ]; then
2121
echo "Found SOCRATES path: yes"
2222
else
2323
echo "Found SOCRATES path: no"
24-
echo "You need to install SOCRATES and set the RAD_DIR environment variable"
25-
echo "This requires modifying your shell rc file to export RAD_DIR"
26-
echo "Check the docs: https://www.h-nicholls.space/AGNI/"
24+
echo " You need to install SOCRATES and set the RAD_DIR environment variable"
25+
echo " This requires modifying your shell rc file to export RAD_DIR"
26+
echo " Check the docs: https://www.h-nicholls.space/AGNI/"
2727
exit 1
2828
fi
2929

30+
# FastChem?
31+
if [ -n "$FC_DIR" ]; then
32+
echo "Found FastChem path: yes"
33+
else
34+
echo "Found FastChem path: no"
35+
echo " It is highly recommended that you install FastChem and set the FC_DIR environment variable"
36+
echo " Check the docs: https://www.h-nicholls.space/AGNI/"
37+
fi
38+
3039
# Install
3140
echo "Installing AGNI..."
3241
rm -f Manifest.toml

0 commit comments

Comments
 (0)