Ticket #367: make_B.sh

File make_B.sh, 1.4 KB (added by Ian Culverwell, 11 years ago)
Line 
1#/usr/bin/ksh
2
3export nlev=60
4export nlev=91
5export nlev=137
6
7export corr_file=bg_ses_ecmwf_error_corr_L${nlev}.nc
8
9export sigma_file=ec_ses_diagonal${nlev}.2012
10
11
12# Remove sigma from corr file
13
14ncks -h -a -x -vsigma $corr_file -O temp1.nc
15
16
17# Dump out sigma
18
19ncks -h -vsigma $corr_file -O temp2.nc
20
21ncdump temp2.nc > temp2.ncdump
22
23
24# Remove -, and replace by values in sigma file
25
26head --lines=-3 temp2.ncdump |sed -es/'_,'/' '/g > temp3.ncdump
27
28cat $sigma_file | awk '{print $0","}' >> temp3.ncdump
29
30head --lines=-1 temp3.ncdump > temp4.ncdump
31
32tail --lines=1 temp3.ncdump |sed -es/','/';'/g >> temp4.ncdump
33
34echo '}' >> temp4.ncdump
35
36
37# Correct n_state
38
39n_state1=`grep "n_state = " temp4.ncdump |cut -d'=' -f2 |cut -d';' -f1`
40
41n_state2=`expr 2 \* $nlev \+ 1`
42
43cat temp4.ncdump |sed -es/"n_state =$n_state1"/"n_state = $n_state2"/g > temp5.ncdump
44
45
46# Generate cov file
47
48ncgen -o temp5.nc temp5.ncdump
49
50
51# Correct the sigma file
52
53ncatted -h -aunits,sigma,o,c,"K, 1, 1" temp5.nc
54
55ncatted -h -aauthor,global,o,c,"J K Nielsen, DMI and I D Culverwell, Met Office" temp5.nc
56
57ncatted -h -atitle,global,o,c,"B-matrix generated by the Scaled Ensemble Standard Deviation method of Holm et al, ECMWF Tech Memo 680, 2012" temp5.nc
58
59ncatted -h -anotes,global,o,c,"Requires use_logp = use_logq = .TRUE. to be used in ropp_1dvar" temp5.nc
60
61
62# Append to the correlations
63
64ncks -h temp5.nc -A temp1.nc
65
66mv temp1.nc ropp_${corr_file}
67
68
69# Clean up
70
71rm temp*.nc*
72
73
74