remap_RACMO_to_E3SM.sh 2.44 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
#!/bin/bash

# make sure top level call of this script loads ncl and nco/4.6.6 to have weight-generation command ESMF_RegridWeightGen used in ncremap

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

#module unload PE-intel # CSZ
#module load PE-gnu # CSZ
#module add gsl hdf5
#module load ncl/6.1.0

#export LD_LIBRARY_PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/lib:/sw/redhat6/szip/2.1/rhel6.6_gnu4.8.2/lib':${LD_LIBRARY_PATH}

#export PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/bin':${PATH}

#export LD_LIBRARY_PATH="~zender/lib_rhea":${LD_LIBRARY_PATH}
#export PATH="~zender/bin_rhea":${PATH}

#module load nco
#module unload nco/4.6.5

#else
#  echo "machine not recognized, make sure your path: 
#        $PATH 
#        points to a version of nco/4.6.6 or later"
#
#fi

#project=$project
obs_case=racmo23_GRN_monthly
#case=IGCLM45_MLI_titan
#path=/lustre/atlas1/$project/world-shared/$USER/$case
#obspath=/lustre/atlas1/$project/world-shared/$USER/$obs_case

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

echo $path
echo $obspath

mkdir -p $obspath/remapped_racmo

seasons=("DJF" "JJA" "ANN")
field_names=("swsn" "swsd" "lwsn" "lwsd" "senf" "latf" "t2m" "alb" "smb")

for seas in "${seasons[@]}"
do

for rvar in "${field_names[@]}"
do

# CHECK whether I need to point to file we will be comparing to
e3smfile=$path/lnd/hist/${case}.clm2.h0.${year_end}-01.nc
obsfile=$obspath/${obs_case}/climos/${obs_case}.${rvar}.1980-1999.${seas}.nc 
tmpfile=$obspath/${obs_case}/remapped_racmo/racmo23_with_latlon_tmpfile.nc
ReMapFile=$obspath/${obs_case}/remapped_racmo/racmo23_GRN_monthly.${rvar}.1980-1999.remap2e3sm.${seas}.nc 

#------- RACMO lat and lon data ---
racmolatlon=$obspath/${obs_case}/RACMO23_masks_ZGRN11.nc

## PROCEDURE: remap racmo to have same size as e3sm
##-first, append lat and lon from racmolatlon file to racmofile
ncks -C -v lat,lon $racmolatlon -O $tmpfile
ncks -C -v ${rvar} $obsfile -A $tmpfile

#-- change interpolation algorithm in -a switch causes value difference
ncremap -i $tmpfile -V TREFHT -a bilinear -d $e3smfile -v ${rvar} -m $obspath/remapped_racmo/RACMO_to_CESM_remap_bilin.nc -o $ReMapFile

done # variables
done #seasons