main_e3sm.sh 5.86 KB
Newer Older
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
#clear

# 1/18 to run this script on E3SM v1

#(1) qsub -X -I -A PROJ# -lnodes=1,partition=gpu,walltime=1:00:00
# alter parameters below to match desired settings:
# Key settings: 
# job case, location (path), year start and end, 
# location of output (outpath)
# variables to postprocess (are not yet) set to those needed for LIVV postprocessing tools
# update specialty files used for masking and regridding

# total area of GrIS in model is 1.719e6
project=cli115
case=20180215.DECKv1b_H1.ne30_oEC.edison
year_start=1979
year_end=2005
base=/lustre/atlas1/$project/proj-shared/salil/archive
path=$base/$case/archive
obspath=/lustre/atlas1/$project/world-shared/$USER/obs_data
outpath=/lustre/atlas1/$project/world-shared/$USER/$case/postproc
area_file=/lustre/atlas1/$project/world-shared/$USER/surfdata_0.9x1.25_simyr1850_c110725.nc
map_file=/ccs/home/zender/data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc
mask_file=/lustre/atlas1/$project/world-shared/4ue/$case/postproc/mask_ne30np4_notime.nc
version=e3sm
if [[ $version = cesm1 ]]; then
atm_vars=("PSL" "CLDLOW" "CLDHGH" "CLDMED" "CLDTOT" "TREFHT" "TS" "TSMX" "TSMN" "PRECT" "PRECC" "PRECL")
lnd_h0_vars=("QICE" "TREFMNAV" "TREFMXAV" "TSA" "RAIN" "SNOW")
lnd_h1_vars=("QICE_FRZ" "QICE_MELT" "QSOIL_ICE" "QSNOMELT_ICE" "RAIN" "SNOW")
elif [[ $version = e3sm ]]; then
atm_vars=("PSL" "CLDLOW" "CLDHGH" "CLDMED" "CLDTOT" "TREFHT" "TS" "TSMX" "TSMN" "PRECC" "PRECL")
lnd_h0_vars=("FSDS" "QRUNOFF" "QSOIL" "TSA" "RAIN" "SNOW" "FIRA" "FLDS" "FSH" "QSNOMELT")
#glc_vars=("acab" "thk")
fi

postprocess=true
postprocess_obs=false
make_plots=true

mkdir -p $outpath

echo "$version"

#postprocess all components of coupled model 
if [ "$version" == "cesm1" ]; then
	glc=cism
	lnd=clm2 
	atm=cam2 
elif [ "$version" == "e3sm" ]; then
	glc=cism
	lnd=clm2 
	atm=cam 
else
  	echo "incorrect model version detected"
	exit	
fi

#run a check, is the requested data directory there?
if test -d $path; then
	echo "Directory $path exists"
else
	echo "Target directory $path does not exist"
	exit 
fi

#run a check, do you have the software to perform the postprocessing?
if [[ $(hostname -s) = rhea* ]]; then

export MODULEPATH=$HOME/.modulefiles:$MODULEPATH
module unload PE-pgi PE-gnu PE-intel
module unload nco ncl netcdf
module load PE-gnu/4.8.2

module load netcdf/4.4.1
module load gsl hdf5-parallel

module unload gcc
module load gcc
module load nco/4.6.9
module load ncl/6.3.0

module load anaconda-cli106/rhea
source deactivate && source activate LIVVpy2

module list

elif [[ $(hostname -s) = titan* ]]; then
  module load netcdf/cray
  module load nco/4.6.9
  module load ncl/6.3.0
else
  echo "machine not recognized, make sure your path: 
 	$PATH 
  	points to a version of nco/4.6.9 or later"
	exit
fi

# this is a hack- all files from E3SM runs we care about should have a gris_mask in the data
if [ "$version" == "cesm1" ]; then

if test -a $outpath/masks/${case}.$lnd.gris_mask.nc; then
        echo "already created gris_mask and area file, moving on"
else
        echo "gris_mask file does not exist, creating"

	mkdir -p $outpath/masks
       	ncks -O -v gris_mask,area $path/lnd/hist/${case}.${lnd}.h0.${year_start}-01.nc $outpath/masks/${case}.${lnd}.gris_mask_time.nc 
       	ncwa -a time $outpath/masks/${case}.${lnd}.gris_mask_time.nc $outpath/masks/${case}.${lnd}.gris_mask.nc 

fi # if mask file needs to be created

fi  # CESM vs E3SM

if [ "$postprocess_obs" = "true" ]; then

echo "process and remap cloud obs"
. atm_obs.sh 
echo "process RACMO"
. lnd_obs.sh 

if [ "$version" = "cesm1" ]; then
echo "remap RACMO to CESM"
./remap_RACMO_to_CESM_inline.sh
elif [ "$version" = "e3sm" ]; then
./remap_RACMO_to_CESM2_inline.sh
fi #CESM version

fi

echo "executing post processing of atm data for validation"
. atm.sh 

echo "executing post processing of lnd data for validation"
. lnd.sh  

if [ "$version" = "cesm1" ]; then
echo "executing post processing of glc data for validation"
. glc.sh

fi

if [ "$make_plots" = "true" ]; then
echo "make the atmosphere plots"
mkdir -p "$outpath/atm/plots"

if [ "$version" = "cesm1" ]; then

python plot_files/CESM_cldlow_ANN.py 
python plot_files/CESM_cldhgh_ANN.py
python plot_files/CESM_cldtot_ANN.py 
python plot_files/yearly_cycle_CLDTOT.py 
python plot_files/yearly_cycle_CLDHGH.py 
python plot_files/yearly_cycle_CLDLOW.py 

python plot_files/TimeSeries_TREFHT.py

echo "Areal annual avgd values of radiation vars: CESM"
python model_rad_aavg.py

elif [ "$version" = "e3sm" ]; then

python plot_files/E3SM_cldlow_ANN.py 
python plot_files/E3SM_cldhgh_ANN.py
python plot_files/E3SM_cldtot_ANN.py 
python plot_files/yearly_cycle_CLDTOT_e3sm.py 
python plot_files/yearly_cycle_CLDHGH_e3sm.py 
python plot_files/yearly_cycle_CLDLOW_e3sm.py 

echo "Areal annual avgd values of radiation vars: E3SM"
python e3sm_rad_aavg.py

fi

echo "Areal annual avgd values of radiation vars: RACMO"
python racmo_rad_aavg.py

echo "make the land plots"
mkdir -p "$outpath/lnd/plots"

if [ "$version" = "cesm1" ]; then
python plot_files/CESM_RACMO23_t2m_JJA.py
python plot_files/CESM_RACMO23_t2m_DJF.py 
python plot_files/CESM_RACMO23_t2m_ANN.py
python plot_files/CESM_RACMO23_albedo.py
python plot_files/CESM_RACMO23_latf.py 
python plot_files/CESM_RACMO23_senf.py
python plot_files/CESM_RACMO23_rnet.py
python plot_files/CESM_RACMO23_swsn.py
python plot_files/CESM_RACMO23_swsd.py
python plot_files/CESM_RACMO23_lwsn.py
python plot_files/CESM_RACMO23_lwsd.py

python plot_files/CESM_RACMO23_smb.py
python plot_files/TimeSeries_QICE.py 

elif [ "$version" = "e3sm" ]; then
python plot_files/E3SM_RACMO23_t2m_JJA.py
python plot_files/E3SM_RACMO23_t2m_DJF.py 
python plot_files/E3SM_RACMO23_albedo.py
python plot_files/E3SM_RACMO23_rnet.py
python plot_files/E3SM_RACMO23_smb.py
python plot_files/TimeSeries_smblike.py 
fi

if [ "$version" = "cesm1" ]; then
echo "make the glc plots"
mkdir -p "$outpath/glc/plots"

python plot_files/TimeSeries_acab.py
fi # cesm version

fi # to make plots or not