-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregrid-GEOS_FP.bsub
69 lines (51 loc) · 2.29 KB
/
regrid-GEOS_FP.bsub
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
#BSUB -n 12
#BSUB -R "rusage[mem=150GB] span[hosts=1] order[-slots]"
#BSUB -q rvmartin
#BSUB -W 168:00
#BSUB -w "DownloadGEOSFP"
#BSUB -a 'docker(registry.gsc.wustl.edu/sleong/base-engineering-gcc)'
#BSUB -g /liam.bindle/downloads
#BSUB -J "RegridGEOSFP"
#BSUB -N
#BSUB -u [email protected]
#BSUB -o /storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/logs/regrid-GEOS_FP_${YEAR}${MONTH}-%J.txt
set -u
: "$YEAR" "$MONTH"
. /etc/bashrc
ulimit -s unlimited
cd /storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing
export GEOS_FP_DOWNLOAD_DIR=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/GEOS_FP-raw
export GEOS_FP_PROCESSING=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/GEOS_FP
export SCRATCH_DIR=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/scratch
export PATH=$PATH:$GEOS_FP_PROCESSING/bin
DAYS_IN_MONTH=$(cal $MONTH $YEAR | awk 'NF {DAYS = $NF}; END {print DAYS}')
sed -i "96s#.*#${GEOS_FP_DOWNLOAD_DIR}/${YEAR}/${MONTH}/#" GEOS_FP/bin/GeosFpDriver.input
sed -i "39s#.*#${GEOS_FP_DOWNLOAD_DIR}/${YEAR}/${MONTH}/#" GEOS_FP/perl/doGeosFp.input
sed -i "51s#.*#$SCRATCH_DIR/GEOS_FP/${YEAR}/${MONTH}/#" GEOS_FP/perl/doGeosFp.input
mkdir -p $SCRATCH_DIR/GEOS_FP/${YEAR}/${MONTH}
cd GEOS_FP/perl
for day in $(seq -w 1 ${DAYS_IN_MONTH}); do
date=$YEAR$MONTH$(printf '%02i' "${day#0}")
./doGeosFpMulti $date
done
cd $SCRATCH_DIR/GEOS_FP/${YEAR}/${MONTH}
mkdir -p nc4
#find -name 'GEOSFP.*.[AI]3*.nc' -maxdepth 1 -exec nccopy -w -k3 -d5 -c time/,lev/,lat/,lon/ {} nc4/{} \;
#find -name 'GEOSFP.*.[AI]1*.nc' -maxdepth 1 -exec nccopy -w -k3 -d5 -c time/,lat/,lon/ {} nc4/{} \;
for f in *.nc ; do
line=$(ncdump -h $f | grep "lat = ") #retrieve number of lats
subline=${line##*= }
nlat=${subline% ;*}
line=$(ncdump -h $f | grep "lon = ") #retrieve number of lons
subline=${line##*= }
nlon=${subline% ;*}
line=$(ncdump -h $f | grep -n "dimensions") #retrieve number of dimensions
line2=$(ncdump -h $f | grep -n "variables")
ndim=$((${line2%:v*}-${line%:d*}-1))
if [ $ndim == 3 ]; then #2-D fields
nccopy -w -k3 -d5 -c time/1,lat/$nlat,lon/$nlon $f nc4/$f
elif [ $ndim == 4 ]; then #3-D fields
nccopy -w -k3 -d5 -c time/1,lev/1,lat/$nlat,lon/$nlon $f nc4/$f
fi
done
exit 0