source: TOOLS/MOSAIX/Utils/CreateLMDgrid.bash @ 4168

Last change on this file since 4168 was 4168, checked in by omamce, 3 years ago

O.M. : to create final MOSAIX grid files for LMD

  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 3.9 KB
Line 
1#!/bin/bash
2
3
4### ===========================================================================
5##
6## Default configuration
7## ===========================================================================
8
9### ===========================================================================
10###
11### You should not change anything below this line ....
12###
13### ===========================================================================
14
15##
16## Command line parameters
17## ===========================================================================
18set -o verbose
19set -o xtrace
20set -e
21
22
23while [[ ${1} = -* ]] ; do
24    case ${1} in
25        ( -- ) shift ; break ;;
26        ( -v | --verbose    ) set -o verbose   ;;
27        ( -x | --xtrace     ) set -o xtrace    ;;
28        ( -e                ) set -e           ;;
29        ( -V | --noverbose  ) set +o verbose   ;;
30        ( -X | --noxtrace   ) set +o xtrace    ;;
31        ( -E                ) set +e           ;;
32        ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;;
33    esac
34    shift
35done
36
37##
38#AtmFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc}
39AtmFile=${1:-/ccc/scratch/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/TEST/pdControl/TEST-CM617-MR-pd-5DBLE/ATM/Output/DA/TEST-CM617-MR-pd-5DBLE_18500101_18500105_1D_grid_p8.nc}
40
41dim_lat=$(ncdump -h ${AtmFile} | grep "lat *=" | awk '{print $3}' )
42dim_lon=$(ncdump -h ${AtmFile} | grep "lon *=" | awk '{print $3}' )
43(( dim_lat = dim_lat - 1 ))
44
45GridFile=LMD${dim_lon}${dim_lat}_grid.nc
46
47ncks --overwrite -h -d time_counter,0,1 -v lon,lat,aire_p8,fract_oce_p8,fract_sic_p8 ${AtmFile}   ${GridFile}
48#ncwa --overwrite -h -a time_counter                     ${GridFile}  tmp_${GridFile} ; mv tmp_${GridFile} ${GridFile}
49ncrename -v aire_p8,aire           ${GridFile}
50ncrename -v fract_oce_p8,fract_oce ${GridFile}
51ncrename -v fract_sic_p8,fract_sic ${GridFile}
52
53ncatted -h -a coordinates,aire,m,c,"lat lon"       ${GridFile}
54ncatted -h -a coordinates,fract_oce,m,c,"lat lon"  ${GridFile}
55ncatted -h -a coordinates,fract_sic,m,c,"lat lon"  ${GridFile}
56
57ncks --overwrite -h --xcl -v time_counter,time_centered,time_counter_bounds ${GridFile} tmp_${GridFile} ; mv tmp_${GridFile} ${GridFile}
58
59cat <<EOF >add_fields.nco
60defdim("time_counter",1) ;
61defdim("axis_nbounds",2) ;
62time_centered        [time_counter]               = {  43200.0 } ;
63time_centered_bounds [time_counter, axis_nbounds] = { 0.0, 86400.0 } ;
64fract_oce_plus_sic = fract_oce + fract_sic ;
65where (fract_oce_plus_sic <   0.00001 )  fract_oce_plus_sic=0.0 ;
66where (fract_oce_plus_sic >   0.99999 )  fract_oce_plus_sic=1.0 ;
67// Fill masked values to land values
68OceMask[time_counter,lat,lon] = 0.0 ;
69where (fract_oce_plus_sic >  0.0 )  OceMask=1.0 ;
70EOF
71
72ncap2 -h --overwrite --script-file add_fields.nco ${GridFile} tmp_${GridFile}  ; mv tmp_${GridFile} ${GridFile}
73
74ncatted -h \
75        -a coordinates,OceMask,c,c,"time_centered lat lon"             \
76        -a standard_name,time_centered,c,c,"time"                      \
77        -a long_name,time_centered,c,c,"Time axis"                     \
78        -a calendar,time_centered,c,c,"360_day"                        \
79        -a units,time_centered,c,c,"seconds since 2000-01-01 00:00:00" \
80        -a time_origin,time_centered,c,c,"2000-01-01 00:00:00"         \
81        -a bounds,time_centered,c,c,"time_centered_bounds"             \
82        ${GridFile}
83
84ncks -O --mk_rec time_counter ${GridFile} tmp_${GridFile}  ; mv tmp_${GridFile} ${GridFile}
85
86ncatted -h \
87        -a long_name,aire,c,c,"Grid area"    \
88        -a units,aire,c,c,"m^2"              \
89        -a online_operation,aire,c,c,"once"  \
90        -a coordinates,aire,c,c,"lat lon"    \
91        ${GridFile}
92
93### ===========================================================================
94rm -f add_fields.nco
95
96
97### ===========================================================================
98###
99###                               That's all folk's !!!
100###
101### ===========================================================================
102
Note: See TracBrowser for help on using the repository browser.