-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_100day_means.sh
executable file
·37 lines (33 loc) · 1.09 KB
/
make_100day_means.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
#!/bin/bash
#$ -cwd
#Loads NCO module and creates the 100 day means
# inputs ($1 and $2) are the prefix (e.g. CloudTopv2)
# and the time slot (00000, 21600,..)
#module load nco/4.7.9-intel
cd /global/cscratch1/sd/terai/UP_analysis/Eastman_analysis/CAM5_1deg_run2/precip/
for time in $2 #00000 21600 43200 64800
do
mkdir ./Files_${time}_${1}
mv *${time}*nc ./Files_${time}_${1}
done
echo "Done moving"
# Within each of the directories, take the average (nces) over 100days,
# which corresponds to 100 consecutive files because they are sorted by time
# Name each file based on day 50
for time in $2 #00000 21600 43200 64800
do
cd ./Files_${time}_${1}
ALLFILES=($(ls ${1}_*.nc))
#ALLFILESarray = ($ALLFILES)
indexi=0
while [ $indexi -lt 265 ]
do
i50=50+indexi
file50=${ALLFILES[${i50}]}
#echo $file50
i100=99+indexi
filestoanalyze=${ALLFILES[@]:${indexi}:${i100}}
nces $filestoanalyze AVG100days_${file50}
(( indexi++ ))
done
done