forked from nichollsh/AGNI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_earth.jl
executable file
·82 lines (67 loc) · 2.42 KB
/
demo_earth.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env -S julia --color=yes --startup-file=no
# -------------
# AGNI executable file for standalone execution
# -------------
tbegin = time()
println("Begin Earth demo")
# Get AGNI root directory
ROOT_DIR = dirname(abspath(@__FILE__))
ENV["GKSwstype"] = "100"
# Include libraries
using Revise
# Include local jl files
include("socrates/julia/src/SOCRATES.jl")
push!(LOAD_PATH, joinpath(ROOT_DIR,"src"))
import atmosphere
import setpt
import plotting
import solver_accel
import phys
# Configuration options
tstar = 300.0 # LW uflux bottom boundary condition [kelvin]
toa_heating = 1367.0 # Daytime instellation flux [W m-2]
radius = 6.37e6 # metres
gravity = 9.81 # m s-2
nlev_centre = 150
p_surf = 1.0 # bar
p_top = 1e-7 # bar
mf_path = "doc/example_earth/equ.csv"
spfile_name = "res/spectral_files/Reach/Reach"
star_file = "res/stellar_spectra/sun.txt"
output_dir = "out/"
# Create output directory
rm(output_dir,force=true,recursive=true)
if !isdir(output_dir) && !isfile(output_dir)
mkdir(output_dir)
end
# Setup atmosphere
println("Setting up")
atmos = atmosphere.Atmos_t()
atmosphere.setup!(atmos, ROOT_DIR, output_dir,
spfile_name,
toa_heating, tstar,
gravity, radius,
nlev_centre, p_surf, p_top,
mf_path=mf_path,
flag_gcontinuum=true,
flag_rayleigh=false, # the RFM profile does not include scattering
zenith_degrees=30.0,
overlap_method=4
)
atmosphere.allocate!(atmos;stellar_spectrum=star_file)
# Call solver
println("Starting solver")
solver_euler.solve_accel!(atmos, surf_state=1, modplot=2, verbose=true, extrap=false,
dry_convect=true, h2o_convect=true, sens_heat=true,
dt_max=2.0, max_steps=300)
# Write arrays
atmosphere.write_pt(atmos, joinpath(atmos.OUT_DIR,"pt.csv"))
atmosphere.write_fluxes(atmos, joinpath(atmos.OUT_DIR,"fl.csv"))
# Save plots
plotting.plot_x(atmos, joinpath(atmos.OUT_DIR,"mf.pdf"))
plotting.plot_pt(atmos, joinpath(atmos.OUT_DIR,"pt.pdf"))
plotting.plot_fluxes(atmos, joinpath(atmos.OUT_DIR,"fl.pdf"))
# Deallocate atmosphere
println("Deallocating arrays")
atmosphere.deallocate!(atmos)
println("Goodbye")