-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_realistic_ocean.sh
executable file
·149 lines (116 loc) · 4.35 KB
/
run_realistic_ocean.sh
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# Let's first specify the enviromental variables
# ====================================================== #
# ================ USER SPECIFIED INPUTS =============== #
# ====================================================== #
# Grid size
export RESOLUTION=12
export NZ=100
# Experiment details
export EXPERIMENT="RealisticOcean"
export WITHFLUXES=1
export WITHRESTORING=1
export PRECISION="Float64"
# Might increase performance when using a lot of cores (i.e. improves scalability)
export LOADBALANCE=1
# Do we want to profile or run a simulation?
export PROFILE=0
# How many nodes are we running on?
export NNODES=2
# For :RealisticOcean the simulation always starts from 01/01/1995, when does it end?
export FINALYEAR=1996
export FINALMONTH=1
# If REPEATYEAR == true then we repeat year 1995
export REPEATYEAR=true
# Restart from interpolated fields ? "" : "numer_of_iteration_to_restart_from"
export RESTART=""
# Shall we regenerate fluxes? Shall we regenerate initial conditions?
export REGENERATEFLUXES=0
export REGENERATEINITIALCONDITIONS=0
export REGENERATERESTORING=0
# Server specific enviromental variables and modules
source satori/setup_satori.sh
# ====================================================== #
# ================ PREPARATORY ACTIONS ================= #
# ====================================================== #
#####
##### We need to first generate a bathymetry
#####
cd bathymetry
BATHYMETRY="bathymetry$RESOLUTION.jld2"
cat > generate_bathymetry.jl << EoF_s
include("GenerateBathymetry.jl")
using .GenerateBathymetry
res = parse(Int, get(ENV, "RESOLUTION", "3"))
bat = interpolate_bathymetry_from_ETOPO1(res, 75; interpolation_method = LinearInterpolation(passes = 5))
write_bathymetry_to_file(res, bat)
EoF_s
# check that the bathymetry exists and regenerate it if needed
if test -f $BATHYMETRY || test $EXPERIMENT != "RealisticOcean" ; then
echo "the bathymetry file already exists or we are running the DoubleDrake experiment."
else
echo "regenerating bathymetry"
$JULIA --project --check-bounds=no generate_bathymetry.jl
fi
rm generate_bathymetry.jl
# #####
# ##### Now we need to generate daily fluxes and initial conditions
# #####
cd ../data
# check we want to regenerate fluxes otherwise proceed
cat > write_fluxes.jl << EoF_s
include("generate_fluxes.jl")
res = parse(Int, get(ENV, "RESOLUTION", "3"))
generate_fluxes(res; arch = GPU())
EoF_s
if test $REGENERATEFLUXES == 0 ; then
echo "we are not regenerating the fluxes"
else
if test $EXPERIMENT != "RealisticOcean" || test $WITHFLUXES == 0 ; then
echo "WARNING!! we are regenerating the fluxes but they are not needed for this simulation"
fi
echo "regenerating fluxes"
$JULIA --project --check-bounds=no write_fluxes.jl
fi
rm write_fluxes.jl
# check we want to regenerate fluxes otherwise proceed
cat > write_restoring.jl << EoF_s
include("generate_fluxes.jl")
res = parse(Int, get(ENV, "RESOLUTION", "3"))
generate_restoring(res; arch=GPU())
EoF_s
if test $REGENERATERESTORING == 0 ; then
echo "we are not regenerating the restoring data"
else
if test $EXPERIMENT != "RealisticOcean" || test $WITHRESTORING == 0 ; then
echo "WARNING!! we are regenerating the restoring data but it is not needed for this simulation"
fi
echo "regenerating restoring data"
$JULIA --project --check-bounds=no write_restoring.jl
fi
rm write_restoring.jl
# check we want to regrid initial conditions otherwise proceed
cat > generate_initial_conditions.jl << EoF_s
include("regrid_initial_conditions.jl")
res = parse(Int, get(ENV, "RESOLUTION", "3"))
Nz = parse(Int, get(ENV, "NZ", "100"))
regrid_initial_conditions(res, Nz; arch = GPU())
EoF_s
if test $REGENERATEINITIALCONDITIONS == 0 ; then
echo "we are not regenerating the initial conditions"
else
if test ! -z $RESTART || test $EXPERIMENT != "RealisticOcean" ; then
echo "WARNING!! we are regenerating the initial conditions but it is not needed for this simulation"
fi
echo "regenerating initial conditions"
$JULIA --project --check-bounds=no generate_initial_conditions.jl
fi
rm generate_initial_conditions.jl
# ====================================================== #
# ============ LET'S RUN THE SIMULATION!!! ============= #
# ====================================================== #
#####
##### Now we can finally run our simulation
#####
cd ../
sbatch -N ${NNODES} satori_job.sh