| 1 | #/usr/bin/ksh
|
|---|
| 2 |
|
|---|
| 3 | export nlev=60
|
|---|
| 4 | export nlev=91
|
|---|
| 5 | export nlev=137
|
|---|
| 6 |
|
|---|
| 7 | export corr_file=bg_ses_ecmwf_error_corr_L${nlev}.nc
|
|---|
| 8 |
|
|---|
| 9 | export sigma_file=ec_ses_diagonal${nlev}.2012
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | # Remove sigma from corr file
|
|---|
| 13 |
|
|---|
| 14 | ncks -h -a -x -vsigma $corr_file -O temp1.nc
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | # Dump out sigma
|
|---|
| 18 |
|
|---|
| 19 | ncks -h -vsigma $corr_file -O temp2.nc
|
|---|
| 20 |
|
|---|
| 21 | ncdump temp2.nc > temp2.ncdump
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | # Remove -, and replace by values in sigma file
|
|---|
| 25 |
|
|---|
| 26 | head --lines=-3 temp2.ncdump |sed -es/'_,'/' '/g > temp3.ncdump
|
|---|
| 27 |
|
|---|
| 28 | cat $sigma_file | awk '{print $0","}' >> temp3.ncdump
|
|---|
| 29 |
|
|---|
| 30 | head --lines=-1 temp3.ncdump > temp4.ncdump
|
|---|
| 31 |
|
|---|
| 32 | tail --lines=1 temp3.ncdump |sed -es/','/';'/g >> temp4.ncdump
|
|---|
| 33 |
|
|---|
| 34 | echo '}' >> temp4.ncdump
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | # Correct n_state
|
|---|
| 38 |
|
|---|
| 39 | n_state1=`grep "n_state = " temp4.ncdump |cut -d'=' -f2 |cut -d';' -f1`
|
|---|
| 40 |
|
|---|
| 41 | n_state2=`expr 2 \* $nlev \+ 1`
|
|---|
| 42 |
|
|---|
| 43 | cat temp4.ncdump |sed -es/"n_state =$n_state1"/"n_state = $n_state2"/g > temp5.ncdump
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | # Generate cov file
|
|---|
| 47 |
|
|---|
| 48 | ncgen -o temp5.nc temp5.ncdump
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | # Correct the sigma file
|
|---|
| 52 |
|
|---|
| 53 | ncatted -h -aunits,sigma,o,c,"K, 1, 1" temp5.nc
|
|---|
| 54 |
|
|---|
| 55 | ncatted -h -aauthor,global,o,c,"J K Nielsen, DMI and I D Culverwell, Met Office" temp5.nc
|
|---|
| 56 |
|
|---|
| 57 | ncatted -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 |
|
|---|
| 59 | ncatted -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 |
|
|---|
| 64 | ncks -h temp5.nc -A temp1.nc
|
|---|
| 65 |
|
|---|
| 66 | mv temp1.nc ropp_${corr_file}
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | # Clean up
|
|---|
| 70 |
|
|---|
| 71 | rm temp*.nc*
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|