lnd.sh 2.58 KB
Newer Older
1
2
3
4
5
6
#!/bin/bash

# land

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

7
8
# regridding step to regrid to lat lon, currently regrids all years even if not requested
# this is not needed unless a mask file is needed in the sim output AND analysis of \hist, else regrid after climos made
9
if [ "$version" == "e3sm_old" ]; then
10
11

#uncomment if you have a new mask file with a time dimension
12
13
#ncwa -a -time $outpath/masks/mask_ne30np4_lnd.nc $outpath/masks/mask_ne30np4_lnd_notime.nc 

14
15
16
17
18
19
20
21
for fl in $path/lnd/hist/*h0*; do
echo "first add mask in original grid to monthly lnd output in $fl"
ncks -A -C -v gris_mask $mask_file $fl
done

h0lnd_path=$outpath/lnd/hist_regrid
mkdir -p "$h0lnd_path"
ls $path/lnd/hist/*h0* | ncremap -m $map_file -O $h0lnd_path
22
23
24
25

else 
h0lnd_path=$path/lnd/hist
fi
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

echo "make land h0 climos"
mkdir -p "$outpath/lnd/climos"

ncclimo -c $case -s ${year_start} -e ${year_end} -m ${lnd} -i ${h0lnd_path} -o ${outpath}/lnd/climos
if test -a $outpath/lnd/climos/${case}_ANN_climo.nc; then
       	echo "File $outpath/lnd/climos/${case}_ANN_climo.nc exists"
else
       	echo "File $outpath/lnd/climos/${case}_ANN_climo.nc does not exist"
	exit
fi

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

h0lnd_path=$outpath/lnd/climos

echo "average land monthly climos over ice sheet region"
43
44
45
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $outpath/lnd/climos/${case}_ANN_climo.nc $outpath/lnd/climos/${case}_ANN_aavg_climo.nc
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $outpath/lnd/climos/${case}_JJA_climo.nc $outpath/lnd/climos/${case}_JJA_aavg_climo.nc
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $outpath/lnd/climos/${case}_DJF_climo.nc $outpath/lnd/climos/${case}_DJF_aavg_climo.nc
46

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

49
50
51
# sum% glacier coverage over all elevations to create total % coverage
ncwa -N -a glc_nec -v PCT_GLC_MEC $outpath/lnd/climos/${case}_ANN_climo.nc $outpath/lnd/climos/${case}_ANN_climo_pct_glc.nc

52
climos_path=$outpath/lnd/climos
53
54

echo "average land monthly climos over ice sheet region"
55
56
57
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $climos_path/${case}_ANN_climo.nc $climos_path/${case}_ANN_aavg_climo.nc
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $climos_path/${case}_JJA_climo.nc $climos_path/${case}_JJA_aavg_climo.nc
ncwa -O -a lat,lon -w gris_area -B "gris_mask == 1" $climos_path/${case}_DJF_climo.nc $climos_path/${case}_DJF_aavg_climo.nc
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

fi

echo "loop over each variable to create and process time series for h0 vars"
mkdir -p "$outpath/lnd/tseries"

for ivar in "${lnd_h0_vars[@]}"
do

. tseries_lnd_h0.sh 

done

echo "LAND POSTPROCESSING COMPLETE"
echo "  "

fi # to postprocess or not