1 | #!/bin/bash |
---|
2 | #MSUB -r WeightsMask # nom de la requete |
---|
3 | #MSUB -o Out_WeightsMask # nom du fichier de sortie |
---|
4 | #MSUB -e Out_WeightsMask # nom du fichier de sortie |
---|
5 | #MSUB -eo |
---|
6 | #MSUB -n 4 # Reservation des processeurs pour le job |
---|
7 | #MSUB -T 1800 # Limite temps (en secondes) |
---|
8 | #MSUB -q standard |
---|
9 | #MSUB -Q test |
---|
10 | #MSUB -p devcmip6 |
---|
11 | |
---|
12 | ### =========================================================================== |
---|
13 | ### |
---|
14 | ### Creates interpolation weights between ORCA and atmospher grids. |
---|
15 | ### Interpolates ORCA mask to atmosphere grid. |
---|
16 | ### Weight files are at OASIS-MCT format. |
---|
17 | ### |
---|
18 | ### Atmosphere grid may be lon/lat LMDZ or DYNAMICO icosahedron |
---|
19 | ### =========================================================================== |
---|
20 | ## |
---|
21 | ## Warning, to install, configure, run, use any of Olivier Marti's |
---|
22 | ## software or to read the associated documentation you'll need at least |
---|
23 | ## one (1) brain in a reasonably working order. Lack of this implement |
---|
24 | ## will void any warranties (either express or implied). |
---|
25 | ## O. Marti assumes no responsability for errors, omissions, |
---|
26 | ## data loss, or any other consequences caused directly or indirectly by |
---|
27 | ## the usage of his software by incorrectly or partially configured |
---|
28 | ## personal. |
---|
29 | ## |
---|
30 | ## SVN information |
---|
31 | # $Author$ |
---|
32 | # $Date$ |
---|
33 | # $Revision$ |
---|
34 | # $Id$ |
---|
35 | # $Log: $ |
---|
36 | |
---|
37 | ## |
---|
38 | ## Configuration |
---|
39 | ## =========================================================================== |
---|
40 | |
---|
41 | # |
---|
42 | # Defines models |
---|
43 | # ============== |
---|
44 | OCE=ORCA2.3 |
---|
45 | #OCE=eORCA1.2 |
---|
46 | #OCE=ORCA025 |
---|
47 | |
---|
48 | ATM=ICO30 |
---|
49 | #ATM=ICO40 |
---|
50 | #ATM=ICO450 |
---|
51 | #ATM=LMD9695 |
---|
52 | #ATM=LMD144X142 |
---|
53 | |
---|
54 | # |
---|
55 | # Defines OCE grids to handle |
---|
56 | # =========================== |
---|
57 | ListOCEGRID="T U V" |
---|
58 | Listorder="1st" # " 2nd |
---|
59 | |
---|
60 | ## =========================================================================== |
---|
61 | ## |
---|
62 | ## You should not change anything below this line .... |
---|
63 | ## |
---|
64 | ## =========================================================================== |
---|
65 | SUBMIT_DIR=$(pwd) |
---|
66 | |
---|
67 | # |
---|
68 | # Defines computer |
---|
69 | # ================ |
---|
70 | if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi |
---|
71 | if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi |
---|
72 | PROGRAM=$(basename ${0}) |
---|
73 | |
---|
74 | case ${arch} in |
---|
75 | ( curie | irene ) |
---|
76 | set +vx |
---|
77 | module unload cdo nco ferret |
---|
78 | module unload netcdf hdf5 |
---|
79 | module load python # /2.7.12 |
---|
80 | module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS |
---|
81 | module load nco |
---|
82 | R_IN=$(ccc_home -u igcmg --cccwork)/IGCM |
---|
83 | TMPDIR=${SCRATCHDIR}/TMP |
---|
84 | SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} |
---|
85 | PROGRAM=${BRIDGE_MSUB_REQNAME} |
---|
86 | ;; |
---|
87 | ( * ) |
---|
88 | exit -1 |
---|
89 | ;; |
---|
90 | esac |
---|
91 | |
---|
92 | set -x ; set -e |
---|
93 | |
---|
94 | mkdir -p ${TMPDIR}/${OCE}x${ATM} || exit 1 |
---|
95 | cd ${TMPDIR}/${OCE}x${ATM} || exit 1 |
---|
96 | rm -f * |
---|
97 | |
---|
98 | # |
---|
99 | # Suffixes |
---|
100 | # --------------------------------------------------------------------------- |
---|
101 | Listocegrid=${ListOCEGRID~} |
---|
102 | |
---|
103 | case ${OCE} in |
---|
104 | ( *ORC* ) oce=orc ; oce_domain_type=curvilinear ;; |
---|
105 | esac |
---|
106 | case ${ATM} in |
---|
107 | ( *dynamico* ) atm=ico ; atm_domain_type=unstructured ;; |
---|
108 | ( *ICO* ) atm=ico ; atm_domain_type=unstructured ;; |
---|
109 | ( *lmd* | *LMD* ) atm=lmd ; atm_domain_type=rectilinear ;; |
---|
110 | esac |
---|
111 | |
---|
112 | # |
---|
113 | # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits |
---|
114 | # --------------------------------------------------------------------------- |
---|
115 | FL_FMT=64bit |
---|
116 | |
---|
117 | |
---|
118 | cp ${SUBMIT_DIR}/bin/interpol.exe . |
---|
119 | cp ${SUBMIT_DIR}/update_xml.py . |
---|
120 | |
---|
121 | ## |
---|
122 | ## NEMO T point towards ATM - 1st order |
---|
123 | ## =========================================================================== |
---|
124 | cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . |
---|
125 | cp ${R_IN}/ATM/${ATM}/${ATM}_grid.nc . |
---|
126 | |
---|
127 | ln -s ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
128 | ln -s ${ATM}_grid.nc atm_grid.nc |
---|
129 | |
---|
130 | echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm} |
---|
131 | cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml iodef.xml |
---|
132 | |
---|
133 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v maskutil_T |
---|
134 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
135 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
136 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v maskutil_T |
---|
137 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_t${oce}_to_t${atm}_1storder |
---|
138 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]' -t "${OCE} mask interpolated to ${ATM}" |
---|
139 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type} |
---|
140 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${atm_domain_type} |
---|
141 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1 |
---|
142 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
143 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
144 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_t${oce}_to_t${atm}_1storder.nc |
---|
145 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 |
---|
146 | |
---|
147 | cp iodef.xml iodef_t${oce}_to_t${atm}_1storder.xml |
---|
148 | |
---|
149 | time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=no |
---|
150 | |
---|
151 | ## |
---|
152 | ## Correct spurious values (extremes) |
---|
153 | ## =========================================================================== |
---|
154 | cat <<EOF > correction_masque.nco |
---|
155 | where (OceFrac < 0.00001 ) OceFrac=OceFrac.get_miss() ; |
---|
156 | where (OceFrac > 0.99999 ) OceFrac=1.0 ; |
---|
157 | OceFrac.delete_miss() ; |
---|
158 | // Fill masked values to land values |
---|
159 | where (OceFrac > 1.0 ) OceFrac=0.0 ; |
---|
160 | where (OceFrac < 0.0 ) OceFrac=0.0 ; |
---|
161 | EOF |
---|
162 | ncap2 -h --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder.nc tmp_dia_t${oce}_to_t${atm}_1storder.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder.nc |
---|
163 | ncatted -h -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc |
---|
164 | |
---|
165 | ## |
---|
166 | ## Creates mask on ATM grid |
---|
167 | ## =========================================================================== |
---|
168 | cp dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder_mask.nc |
---|
169 | ncks -h --overwrite -v OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
170 | ncks -h --append -v aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
171 | [[ ${atm} = *ico* ]] && ncks -h --append -v bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
172 | |
---|
173 | cat <<EOF > creation_masque.nco |
---|
174 | where (OceFrac > 0.0 ) OceFrac=1 ; |
---|
175 | where (OceFrac <= 0.0 ) OceFrac=0 ; |
---|
176 | EOF |
---|
177 | ncap2 -h --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc dia_t${oce}_to_t${atm}_1storder_mask.nc |
---|
178 | ncrename -h -v OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc |
---|
179 | |
---|
180 | ncks -h --append -v OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
181 | |
---|
182 | |
---|
183 | ## |
---|
184 | ## NEMO, other case, towards ATM |
---|
185 | ## =========================================================================== |
---|
186 | for order in ${Listorder} ; do |
---|
187 | case ${order} in |
---|
188 | ( 1st ) num_order=1 ;; |
---|
189 | ( 2nd ) num_order=2 ;; |
---|
190 | esac |
---|
191 | |
---|
192 | for OCEGRID in ${ListOCEGRID} ; do |
---|
193 | ocegrid=${OCEGRID~} |
---|
194 | |
---|
195 | if [[ !( ${order} = 1st && ${OCEGRID} = T ) ]] ; then |
---|
196 | |
---|
197 | echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}order"${Norm} |
---|
198 | |
---|
199 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v maskutil_${OCEGRID} |
---|
200 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
201 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
202 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v maskutil_${OCEGRID} |
---|
203 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_${ocegrid}${oce}_to_t${atm}_${order}order |
---|
204 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]' -t "${OCE} mask interpolated to ${ATM}" |
---|
205 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type} |
---|
206 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${atm_domain_type} |
---|
207 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${num_order} |
---|
208 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
209 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
210 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${num_order} |
---|
211 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${ocegrid}${oce}_to_t${atm}_${order}order.nc |
---|
212 | cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order.xml |
---|
213 | |
---|
214 | time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
215 | fi |
---|
216 | |
---|
217 | done |
---|
218 | done |
---|
219 | |
---|
220 | ## |
---|
221 | ## ATM towards NEMO points |
---|
222 | ## =========================================================================== |
---|
223 | cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml iodef.xml |
---|
224 | |
---|
225 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
226 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
227 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]' -t "${ATM} mask interpolated to ${OCE}" |
---|
228 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${atm_domain_type} |
---|
229 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${oce_domain_type} |
---|
230 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
231 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
232 | |
---|
233 | for order in ${Listorder} ; do |
---|
234 | case ${order} in |
---|
235 | ( 1st ) num_order=1 ;; |
---|
236 | ( 2nd ) num_order=2 ;; |
---|
237 | esac |
---|
238 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${num_order} |
---|
239 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${num_order} |
---|
240 | |
---|
241 | for OCEGRID in ${ListOCEGRID} ; do |
---|
242 | ocegrid=${OCEGRID~} |
---|
243 | |
---|
244 | echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}order"${Norm} |
---|
245 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v mask_${OCEGRID} |
---|
246 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]' -k name -v mask_${OCEGRID} |
---|
247 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_t${atm}_to_${ocegrid}${oce}_${order}order |
---|
248 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_t${atm}_to_${ocegrid}${oce}_${order}order.nc |
---|
249 | cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order.xml |
---|
250 | |
---|
251 | time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
252 | |
---|
253 | done |
---|
254 | done |
---|
255 | |
---|
256 | ## |
---|
257 | ## Change all NetCDF files to NetCDF 3 format (needed for OASIS) |
---|
258 | ## =========================================================================== |
---|
259 | for InFile in *.nc ; do |
---|
260 | if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then |
---|
261 | mv ${InFile} tmp_${InFile} |
---|
262 | ncks --fl_fmt=${FL_FMT} -h tmp_${InFile} ${InFile} |
---|
263 | fi |
---|
264 | done |
---|
265 | |
---|
266 | ## |
---|
267 | ## Add time axis and coordinates information |
---|
268 | ## (needed if files need to be read by XIOS) |
---|
269 | ## =========================================================================== |
---|
270 | if [[ ${atm} = ico ]] ; then |
---|
271 | cat <<EOF > add_time.nco |
---|
272 | defdim("time_counter",1) ; |
---|
273 | OceFrac [time_counter,cell] = OceFrac (:) ; |
---|
274 | OceMask [time_counter,cell] = OceMask (:) ; |
---|
275 | EOF |
---|
276 | ncap2 -O -h -S add_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
277 | ncks -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
278 | ncatted -h \ |
---|
279 | -a coordinates,OceFrac,c,c,"time_counter cell" \ |
---|
280 | -a coordinates,OceMask,c,c,"time_counter cell" \ |
---|
281 | -a coordinates,aire,c,c,"time_counter cell" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
282 | fi |
---|
283 | if [[ ${atm} = lmd ]] ; then |
---|
284 | cat <<EOF > add_time.nco |
---|
285 | defdim("time_counter",1) ; |
---|
286 | OceFrac [time_counter,lat,lon] = OceFrac (:,:) ; |
---|
287 | OceMask [time_counter,lat,lon] = OceMask (:,:) ; |
---|
288 | EOF |
---|
289 | ncap2 -O -h -S add_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
290 | ncks -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
291 | ncatted -h \ |
---|
292 | -a coordinates,OceFrac,c,c,"time_counter lat lon" \ |
---|
293 | -a coordinates,OceMask,c,c,"time_counter lat lon" \ |
---|
294 | -a coordinates,aire,c,c,"time_counter lat lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
295 | fi |
---|
296 | |
---|
297 | ## |
---|
298 | ## Add some information in file headers |
---|
299 | ## =========================================================================== |
---|
300 | |
---|
301 | UUID=$(uuid) |
---|
302 | NCO="$(ncks --version |& tail -1|sed 's/ncks //')" |
---|
303 | PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) |
---|
304 | for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do |
---|
305 | ncatted -h \ |
---|
306 | --attribute uuid,global,d,, \ |
---|
307 | --attribute LongName,global,d,, \ |
---|
308 | --attribute nco_openmp_thread_number,global,d,, \ |
---|
309 | --attribute Conventions,global,o,c,"CF-1.6" \ |
---|
310 | --attribute source,global,o,c,"IPSL Earth system model" \ |
---|
311 | --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center" \ |
---|
312 | --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr" \ |
---|
313 | --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu" \ |
---|
314 | --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \ |
---|
315 | --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \ |
---|
316 | --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc" \ |
---|
317 | --attribute associatedFiles,global,o,c,"grids_${OCE}x${ATM}.nc areas_${OCE}x${ATM}.nc masks_${OCE}x${ATM}.nc" \ |
---|
318 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
319 | --attribute description,global,o,c,"Fields needed by OASIS-MCT" \ |
---|
320 | --attribute title,global,o,c,"${InFile}.nc" \ |
---|
321 | --attribute Program,global,o,c,"Generated by ${PROGRAM}" \ |
---|
322 | --attribute timeStamp,global,o,c,"$(date)" \ |
---|
323 | --attribute uuid,global,o,c,"${UUID}" \ |
---|
324 | --attribute HOSTNAME,global,o,c,"$(hostname)" \ |
---|
325 | --attribute LOGNAME,global,o,c,"$(whoami)" \ |
---|
326 | --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ |
---|
327 | --attribute Python,global,o,c,"Python version ${PYTHON_VER}" \ |
---|
328 | --attribute OS,global,o,c,"$(uname -o)" \ |
---|
329 | --attribute release,global,o,c,"$(uname -r)" \ |
---|
330 | --attribute hardware,global,o,c,"$(uname -i)" \ |
---|
331 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
332 | --attribute description,global,o,c,"Generated with XIOS http://forge.ipsl.jussieu.fr/ioserver and MOSAIX https://forge.ipsl.jussieu.fr/igcmg/browser/TOOLS/MOSAIX" \ |
---|
333 | --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ |
---|
334 | --attribute SVN_Author,global,o,c,"$Author$" \ |
---|
335 | --attribute SVN_Date,global,o,c,"$Date$" \ |
---|
336 | --attribute SVN_Revision,global,o,c,"$Revision$" \ |
---|
337 | --attribute SVN_Id,global,o,c,"$Id$" \ |
---|
338 | --attribute SVN_Lo,global,o,c,"$Log: $" \ |
---|
339 | ${InFile} |
---|
340 | done |
---|
341 | |
---|
342 | |
---|
343 | ## |
---|
344 | ## Update and complete weights file to fit OASIS requested format |
---|
345 | ## =========================================================================== |
---|
346 | cat <<EOF > add_dim.nco |
---|
347 | defdim("num_wgts",1) ; |
---|
348 | weight[n_weight, num_wgts] = weight ; |
---|
349 | EOF |
---|
350 | |
---|
351 | for file in rmp_*${oce}_to_*${atm}_*.nc rmp_*${atm}_to_*${oce}_*.nc ; do |
---|
352 | mv ${file} xios_${file} |
---|
353 | ncap2 --fl_fmt=${FL_FMT} -h --script-file add_dim.nco xios_${file} ${file} |
---|
354 | |
---|
355 | ncrename -h --dimension n_weight,num_links ${file} |
---|
356 | ncrename -h --variable src_idx,src_address ${file} |
---|
357 | ncrename -h --variable dst_idx,dst_address ${file} |
---|
358 | ncrename -h --variable weight,remap_matrix ${file} |
---|
359 | case ${file} in |
---|
360 | ( *1storder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 1st order" ${file} ;; |
---|
361 | ( *2ndorder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 2nd order" ${file} ;; |
---|
362 | esac |
---|
363 | ncatted -h --attribute conventions,global,o,c,"SCRIP" ${file} |
---|
364 | ncatted -h --attribute normalization,global,o,c,"none" ${file} |
---|
365 | |
---|
366 | case ${file} in |
---|
367 | ( rmp_*${oce}_to_t${atm}_* ) |
---|
368 | ncatted -h \ |
---|
369 | --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \ |
---|
370 | --attribute source_grid,global,o,c,"${oce_domain_type}" \ |
---|
371 | --attribute dest_grid,global,o,c,"${atm_domain_type}" \ |
---|
372 | ${file} |
---|
373 | ;; |
---|
374 | ( rmp_*${atm}_to_*${oce}_* ) |
---|
375 | ncatted -h \ |
---|
376 | --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \ |
---|
377 | --attribute source_grid,global,o,c,"${atm_domain_type}" \ |
---|
378 | --attribute dest_grid,global,o,c,"${oce_domain_type}" \ |
---|
379 | ${file} |
---|
380 | ;; |
---|
381 | esac |
---|
382 | done |
---|
383 | |
---|
384 | ## |
---|
385 | ## Save results |
---|
386 | ## =========================================================================== |
---|
387 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} |
---|
388 | for order in ${Listorder} |
---|
389 | do |
---|
390 | cp dia_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/dia_t${OCE}_to_t${ATM}_${order}order.nc |
---|
391 | cp rmp_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/rmp_t${OCE}_to_t${ATM}_${order}order.nc |
---|
392 | for grid in ${Listocegrid} ; do |
---|
393 | cp rmp_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_t${ATM}_to_${grid}${OCE}_${order}order.nc |
---|
394 | cp dia_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/dia_t${ATM}_to_${grid}${OCE}_${order}order.nc |
---|
395 | done |
---|
396 | done |
---|
397 | |
---|
398 | ## |
---|
399 | ## Creates and save auxiliary files for OASIS |
---|
400 | ## =========================================================================== |
---|
401 | bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} |
---|
402 | |
---|
403 | cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
404 | cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
405 | cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
406 | |
---|
407 | |
---|
408 | ## =========================================================================== |
---|
409 | ## |
---|
410 | ## That's all folk's !!! |
---|
411 | ## |
---|
412 | ## =========================================================================== |
---|
413 | |
---|