source: BOL/Scripts_ce0l/SST_SIC_ERA/mk_prepa_daily-SST-SIC_ERA.sh @ 5138

Last change on this file since 5138 was 4979, checked in by musat, 6 months ago

Corrections lancement ferret et ajout script ferret go_sstk_stk.jnl
Ionela Musat

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/bin/bash
2
3echo
4echo This bash script gets the SSTs and SICc from
5echo hourly ERA5 data and prepares the input files
6echo containing daily values that should be used to
7echo create limit.nc boundary file for LMDZ.
8echo 
9echo The SST field contains sstk over ocean and skt over land.
10echo The SIC files contain either siconc field for the
11echo period 1979-2007 or ci field for the 2008-2017 period.
12echo See below !!!
13echo 
14echo This script was tested on spirit2 machine.
15echo 
16echo To execute this script you need to give the year as input
17echo ./mk_prepa_daily-SST-SIC_ERA.sh $yr 
18echo
19echo For exemple for 2020 year :
20echo ./mk_prepa_daily-SST-SIC_ERA.sh 2020
21echo
22echo Ionela Musat, 12/03/2024
23echo
24
25module load ferret
26
27local=`pwd`
28
29yr=$1
30
31data=ERA5
32res=GLOBAL_025
33ret=hourly
34dtype=AN_SF
35suff=as1e5
36
37echo din is the input directory containing ERA5 daily data
38echo for $yr year
39###din=/bdd/ERA5/NETCDF/GLOBAL_025/hourly/AN_SF/${yr}
40din=/bdd/${data}/NETCDF/${res}/${ret}/${dtype}/${yr}
41
42MONTHS="01 02 03 04 05 06 07 08 09 10 11 12"
43
44for mth in $MONTHS; do
45
46if [ "${mth}" == "02" ]; then
47### ndays=`mk_an_bissextile.sh ${yr}`
48
49echo
50echo Check if the year is a leap one or not
51echo
52echo A leap year is a year which is a multiple of 4,
53echo except for years evenly divisible by 100, but not by 400.
54echo
55let " yrs4 = ${yr} / 4"
56let " yrs100 = ${yr} / 100"
57let " yrs400 = ${yr} / 400"
58
59let "yrd4 = ${yrs4} *4 "
60let "yrd100 = ${yrs100} *100 "
61let "yrd400 = ${yrs400} *400 "
62
63ndays=28
64if [ ${yr} == ${yrd400} ]; then
65ndays=29
66elif [ ${yr} == ${yrd100} ]; then
67ndays=28
68elif [ ${yr} == ${yrd4} ]; then
69ndays=29
70fi
71
72if [ "${ndays}" == "29" ]; then
73 echo $yr is a leap year
74else
75 echo $yr is a noleap year
76fi
77
78fi
79
80case $mth in
81             01|03|05|07|08|10|12) ndays=31 ;;
82             04|06|09|11) ndays=30 ;;
83esac
84
85var=skt
86cp ${din}/${var}.${yr}${mth}.${suff}.${res}.nc .
87cdo daymean ${var}.${yr}${mth}.${suff}.${res}.nc ${var}_daily.${yr}${mth}.${res}.nc
88chmod u+w ${var}.${yr}${mth}.${suff}.${res}.nc
89\rm ${var}.${yr}${mth}.${suff}.${res}.nc
90
91var=sstk
92cp ${din}/${var}.${yr}${mth}.${suff}.${res}.nc .
93cdo daymean ${var}.${yr}${mth}.${suff}.${res}.nc ${var}_daily.${yr}${mth}.${res}.nc
94chmod u+w ${var}.${yr}${mth}.${suff}.${res}.nc
95\rm ${var}.${yr}${mth}.${suff}.${res}.nc
96
97if [ -f tmp.ps ]; then
98\rm tmp.ps
99fi
100
101\rm tmp.jnl
102cat<<eof>tmp.jnl
103go go_sstk_stk.jnl ${yr}${mth} ${ndays} ${res} ${data}
104quit
105eof
106
107 ###ferret -batch tmp.ps -script go_sstk_stk.jnl ${yr}${mth} ${ndays} ${res} ${data}
108ferret<tmp.jnl
109
110echo mth $mth ndays ${ndays}
111
112done
113
114#exit
115
116varnew=sst
117cdo cat ${varnew}_${data}.${yr}*.nc ${varnew}_daily_${data}.${yr}.nc
118
119echo
120echo Change dimensions and SST variable names and add the K unit.
121echo This are mandatory for using the SSTs/SICs files as input files to the
122echo create_eta0_limit.F90 main code.
123echo 
124var=sst
125varM=SST
126varnew=tosbcs
127fin=${var}_daily_${data}.${yr}.nc
128fout=${varnew}_daily_${data}.${yr}.nc
129ncrename -v LONGITUDE,longitude -d LONGITUDE,longitude ${fin}
130ncrename -v LATITUDE,latitude -d LATITUDE,latitude ${fin}
131ncrename -v TIME,time -d TIME,time ${fin}
132ncrename -v ${varM},${varnew} ${fin}
133ncatted -a units,${varnew},a,c,"K" ${fin}
134mv ${fin} ${fout}
135
136echo 
137echo Get SICs field : files named "ci" are containing the siconc or ci variable
138echo corresponding to sea-ice in 0-1 unit
139echo
140var=ci
141for mth in $MONTHS; do
142
143cp ${din}/${var}.${yr}${mth}.${suff}.${res}.nc .
144cdo daymean ${var}.${yr}${mth}.${suff}.${res}.nc ${var}_daily.${yr}${mth}.${res}.nc
145chmod u+w ${var}.${yr}${mth}.${suff}.${res}.nc
146\rm ${var}.${yr}${mth}.${suff}.${res}.nc
147
148done
149
150cdo cat ${var}_daily.${yr}*.${res}.nc ${var}_daily_${data}.${yr}.nc
151
152echo
153echo Rename siconc or ci variable as sicbcs, multiply it by 100 and change unit
154echo
155if [ $yr -ge 2008 ] && [ $yr -le 2017 ]; then
156varname=ci
157else
158varname=siconc
159fi
160
161fin=${var}_daily_${data}.${yr}.nc
162varnew=sicbcs
163mulc=100.
164fout=${varnew}_daily_${data}.${yr}.nc
165cdo mulc,$mulc ${fin} ${fout}
166ncrename -v ${varname},${varnew} ${fout}
167ncatted -a units,${varnew},o,c,"%" ${fout}
168
169\rm ci*nc sst*nc skt*nc
170
171exit
Note: See TracBrowser for help on using the repository browser.