source: TOOLS/MOSAIX/CreateWeightsMask.bash @ 4081

Last change on this file since 4081 was 4081, checked in by omamce, 6 years ago

O.M. : add output fields for diagnostics

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 38.4 KB
Line 
1#!/bin/bash
2#MSUB -r WeightsMask        # Job name
3#MSUB -o Out_WeightsMask    # Standard output
4#MSUB -e Out_WeightsMask    # Error output
5#MSUB -eo
6#MSUB -n 8                  # Number of processors
7#MSUB -T 1800               # Time limit (seconds)
8#MSUB -q skylake
9#MSUB -Q test
10#MSUB -p gen2212
11#MSUB -m work
12
13### ===========================================================================
14###
15### Creates interpolation weights between ORCA and atmosphere grids.
16### Interpolates ORCA mask to atmosphere grid.
17### Weight files are at OASIS-MCT format.
18###
19### Atmosphere grid may be lon/lat LMDZ or DYNAMICO icosahedron
20###
21### Documentation : https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM6/MOSAIX
22### ===========================================================================
23##
24##  Warning, to install, configure, run, use any of Olivier Marti's
25##  software or to read the associated documentation you'll need at least
26##  one (1) brain in a reasonably working order. Lack of this implement
27##  will void any warranties (either express or implied).
28##  O. Marti assumes no responsability for errors, omissions,
29##  data loss, or any other consequences caused directly or indirectly by
30##  the usage of his software by incorrectly or partially configured
31##  personal.
32##
33## SVN information
34#  $Author$
35#  $Date$
36#  $Revision$
37#  $Id$
38#  $HeadURL$
39export Bold=$(tput bold) 
40export Unde=$(tput smul) ; export OffUnde=$(tput rmul)
41export Stou=$(tput smso) ; export OffStou=$(tput rmso)
42export Reve=$(tput rev ) 
43couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" )
44for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done
45export Norm=$(tput sgr0 )
46
47##
48## Configuration
49## ===========================================================================
50
51#
52# Defines models
53# ==============
54#OCE=ORCA2.3
55OCE=eORCA1.2
56#OCE=ORCA025
57
58#ATM=ICO30
59ATM=ICO40
60#ATM=ICO450
61#ATM=LMD9695
62#ATM=LMD144X142
63
64#
65# Defines OCE grids to handle
66# ===========================
67ListOCEGRID="T U V"
68ListOrder="1st 2nd"
69ListNormalize="false true"
70
71## ===========================================================================
72##
73## You should not change anything below this line ....
74##
75## ===========================================================================
76SUBMIT_DIR=$(pwd)
77
78#
79# Defines computer
80# ================
81if [[ $(hostname) = curie*    ]] ; then arch=curie ; center=tgcc ; fi
82if [[ $(hostname) = irene*    ]] ; then arch=irene ; center=tgcc ; fi
83if [[ $(hostname) = lsce3005* ]] ; then arch=spip  ; center=spip ; fi
84
85PROGRAM=$(basename ${0})
86
87case ${arch} in
88    ( curie )
89    set +vx
90    module purge
91    source /ccc/cont003/home/dsm/p86ipsl/.env_intel17.0.2_curie;
92    source /ccc/cont003/home/dsm/p86ipsl/.env_netcdf4.3.3.1_curie
93    module load datadir/igcmg
94    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
95    TMPDIR=${SCRATCHDIR}/TMP
96    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
97    PROGRAM=${BRIDGE_MSUB_REQNAME}
98    MPIRUN=ccc_mprun
99    ;;
100    ( irene )
101    set +vx
102    module purge
103    source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene
104    module load python/2.7.8
105    module load datadir/igcmg
106    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
107    TMPDIR=${CCCWORKDIR}/TMP
108    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
109    PROGRAM=${BRIDGE_MSUB_REQNAME}
110    MPIRUN=ccc_mprun
111    module list
112    ;;
113    ( spip )
114    R_IN=${HOME}/Scratch/IGCM
115    TMPDIR=${HOME}/Scratch/TMP
116    SUBMIT_DIR=$(pwd)
117    MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2
118    ;;
119    ( * ) exit -1 ;;
120esac
121
122set -x ; set -e
123
124mkdir -p ${TMPDIR}/${OCE}x${ATM} || exit 1
125cd       ${TMPDIR}/${OCE}x${ATM} || exit 1
126rm -f *
127
128#
129# Suffixes
130# ---------------------------------------------------------------------------
131Listocegrid=${ListOCEGRID,,}
132
133case ${OCE} in
134    ( *ORC* )         oce=orc ; oce_domain_type=curvilinear   ;;
135esac
136case ${ATM} in
137    ( *dynamico*    ) atm=ico ; atm_domain_type=unstructured  ;;
138    ( *ICO*         ) atm=ico ; atm_domain_type=unstructured  ;;
139    ( *lmd* | *LMD* ) atm=lmd ; atm_domain_type=rectilinear   ;;
140esac
141
142case ${OCE} in
143    ( ORCA2.3*         ) OcePerio=4 ;;
144    ( ORCA1* | eORCA1* ) OcePerio=6 ;;
145    ( ORCA025*         ) OcePerio=6 ;;
146esac
147#
148# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
149# ---------------------------------------------------------------------------
150FMT_OASIS=64bit
151FMT_XIOS=netcdf4
152
153
154cp ${SUBMIT_DIR}/bin/interpol.exe    .
155cp ${SUBMIT_DIR}/*.py                .
156
157
158cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  .
159cp ${R_IN}/ATM/GRID/${ATM}_grid.nc .
160
161ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc
162ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc                    ${ATM}_grid_${FMT_OASIS}.nc
163#
164# Creates OCEAN C grid : redundant point removed to compute proper integrals # A passer dans CreateWeights
165# --------------------------------------------------------------------------------------------------------
166cat <<EOF >add_c_grid.nco
167defdim("x_grid_C", \$x_grid_T.size) ;
168defdim("y_grid_C", \$y_grid_T.size) ;
169defdim("nvertex_grid_C",  4)         ;
170nav_lon_grid_C[y_grid_C,x_grid_C]    = nav_lon_grid_T(:,:)    ;
171nav_lat_grid_C[y_grid_C,x_grid_C]    = nav_lat_grid_T(:,:)    ;
172bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ;
173bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ;
174mask_C[y_grid_C,x_grid_C]            = maskutil_T(:,:)        ;
175area_grid_C[y_grid_C,x_grid_C]       = area_grid_T(:,:)       ;
176EOF
177
178ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc
179ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc
180ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc
181ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C       tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
182ncks --history --append    --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
183ncks --history --append    --variable area_grid_C             tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
184
185ncks --history --append C_${OCE}_coordinates_mask.nc            ${OCE}_coordinates_mask.nc
186rm C_${OCE}_coordinates_mask.nc
187
188ncks --history --overwrite --fl_fmt=${FMT_OASIS} ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc
189
190ls -al
191
192##
193## NEMO T point towards ATM - 1st order
194## ===========================================================================
195echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm}
196cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   iodef.xml
197
198python 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
199python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${oce_domain_type}
200python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${atm_domain_type}
201python 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
202python 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_false
203python 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}"
204python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type}
205python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${atm_domain_type}
206python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1
207python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${oce_domain_type}
208python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${atm_domain_type}
209python 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_false.nc
210python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1
211python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false
212python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v false
213
214cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml
215ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
216ln -fs ${ATM}_grid.nc              atm_grid.nc
217
218time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no
219##
220## Correct spurious values (extremes)
221## ===========================================================================
222cat <<EOF > correction_masque.nco
223where (OceFrac <   0.00001 )  OceFrac=OceFrac.get_miss() ;
224where (OceFrac >   0.99999 )  OceFrac=1.0 ;
225OceFrac.delete_miss() ;
226// Fill masked values to land values
227where (OceFrac >  1.0 )  OceFrac=0.0 ;
228where (OceFrac <  0.0 )  OceFrac=0.0 ;
229EOF
230ncap2 --history --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder_false.nc tmp_dia_t${oce}_to_t${atm}_1storder_false.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_false.nc dia_t${oce}_to_t${atm}_1storder_false.nc
231ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder_false.nc
232
233##
234##  Creates mask on ATM grid
235## ===========================================================================
236cp dia_t${oce}_to_t${atm}_1storder_false.nc  dia_t${oce}_to_t${atm}_1storder_false_mask.nc
237ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_1storder_false_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc
238
239cat <<EOF > creation_masque.nco
240where (OceFrac >  0.0 )  OceFrac=1 ;
241where (OceFrac <= 0.0 )  OceFrac=0 ;
242EOF
243
244ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_false_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_false_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_false_mask.nc dia_t${oce}_to_t${atm}_1storder_false_mask.nc
245ncrename --history --variable OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc
246
247ncks --overwrite --history --variable OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc tmp_OceMask.nc
248ncks --history --append tmp_OceMask.nc ${ATM}_grid_maskFrom_${OCE}.nc
249rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc
250
251# Change dimension names, and some attributes accordingly
252if [[ $(ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc | grep domain_dst | wc -l) -gt 0 ]] ; then
253    case ${atm} in
254        ( *ico* ) 
255        ncrename --history --dimension cell_domain_dst,cell       ${ATM}_grid_maskFrom_${OCE}.nc
256        ;;
257        ( *lmd* ) 
258        ncrename --history --dimension x_domain_dst,x             ${ATM}_grid_maskFrom_${OCE}.nc
259        ncrename --history --dimension y_domain_dst,y             ${ATM}_grid_maskFrom_${OCE}.nc
260        ;;
261    esac
262    ncrename --history --dimension nvertex_domain_dst,nvertex        ${ATM}_grid_maskFrom_${OCE}.nc
263    ncrename --history --variable lat_domain_dst,lat                 ${ATM}_grid_maskFrom_${OCE}.nc
264    ncrename --history --variable lon_domain_dst,lon                 ${ATM}_grid_maskFrom_${OCE}.nc
265    ncrename --history --variable bounds_lat_domain_dst,bounds_lat   ${ATM}_grid_maskFrom_${OCE}.nc
266    ncrename --history --variable bounds_lon_domain_dst,bounds_lon   ${ATM}_grid_maskFrom_${OCE}.nc
267    ncatted  --history --attribute bounds,lat,m,c,"bounds_lat"       ${ATM}_grid_maskFrom_${OCE}.nc
268    ncatted  --history --attribute bounds,lon,m,c,"bounds_lon"       ${ATM}_grid_maskFrom_${OCE}.nc
269    ncatted  --history --attribute coordinates,OceFrac,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc
270    ncatted  --history --attribute coordinates,OceMask,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc
271fi
272
273ncks --history --alphabetize  --append    --variable aire    atm_grid.nc                                   ${ATM}_grid_maskFrom_${OCE}.nc
274[[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc
275
276
277##
278## NEMO, other case, towards ATM
279## ===========================================================================
280for order in ${ListOrder} ; do
281    case ${order} in
282        ( 1st ) num_order=1 ;;
283        ( 2nd ) num_order=2 ;;
284    esac
285    for normalize in ${ListNormalize} ; do
286        for OCEGRID in ${ListOCEGRID} ; do
287            ocegrid=${OCEGRID,,}
288           
289            if [[ ! -f rmp_${ocegrid}${oce}_to_t${atm}_${order}order_${normalize}.nc ]] ; then
290               
291                echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}order - normalize: ${normalize}"${Norm}
292               
293                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}
294                python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${oce_domain_type}
295                python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${atm_domain_type}
296                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}
297                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_${normalize}
298                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}"
299                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}
300                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}
301                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${num_order}
302                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize}
303                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${oce_domain_type}
304                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${atm_domain_type}
305                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}
306                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_${normalize}.nc
307                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize}
308               
309                cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order_${normalize}.xml
310               
311                ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
312                ln -fs ${ATM}_grid.nc              atm_grid.nc
313                time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes
314            fi
315           
316        done
317    done
318done
319
320##
321## ATM towards NEMO points
322## ===========================================================================
323cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml
324
325python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type}
326python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type}
327python 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}"
328python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${atm_domain_type}
329python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${oce_domain_type}
330python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type}
331python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type}
332           
333for order in ${ListOrder} ; do
334    case ${order} in
335        ( 1st ) num_order=1 ;;
336        ( 2nd ) num_order=2 ;;
337    esac
338    for normalize in ${ListNormalize} ; do
339        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}
340        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${num_order}   
341        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize}
342        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize     -v ${normalize}
343       
344        for OCEGRID in ${ListOCEGRID} ; do
345            ocegrid=${OCEGRID,,}
346           
347            echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}order - normalize: ${normalize}"${Norm}
348            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}
349            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}
350            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_${normalize}
351            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_${normalize}.nc
352            cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.xml
353           
354            ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
355            ln -fs ${ATM}_grid.nc              atm_grid.nc
356            time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes
357           
358        done
359    done
360done
361
362##
363## Creates mask of coastal OCE points
364## ===========================================================================
365python ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal
366##
367## Creates mask of coastal ATM points
368## ===========================================================================
369cat <<EOF > coastal.nco
370AtmCoastal = OceFrac * 0.0 ;
371where (OceFrac > 0.0 && OceFrac < 1.0 )  AtmCoastal = 1.0 ;
372EOF
373ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc
374cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n07.nc
375ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
376cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n08.nc
377rm ${ATM}_coastal_maskFrom_${OCE}.nc
378ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc
379cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n09.nc
380
381##
382## ATM towards NEMO points - runoff
383## ===========================================================================
384cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml
385for normalize in ${ListNormalize} ; do
386    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type}
387    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type}
388    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${ATM} coastal mask interpolated to ${OCE}"
389    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}
390    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}
391    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type}
392    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type}
393    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1
394    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1
395    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize}
396    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]'                         -k name  -v ${ATM}_grid_maskFrom_${OCE}
397    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 AtmCoastal
398    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 OceCoastal
399    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_o${atm}_to_c${oce}_1storder_${normalize}
400    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_o${atm}_to_c${oce}_1storder_${normalize}.nc
401    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize}
402   
403    cp iodef.xml iodef_o${atm}_to_c${oce}_1storder_${normalize}.xml
404   
405    ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
406    ln -fs ${ATM}_grid.nc              atm_grid.nc
407    time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes
408
409    # Now we should divide weight par source (atm) grid area : run-off is a quantity/s integrated on the grid mox, not a flux
410done
411##
412## Copy all NetCDF files to NetCDF 3 format (needed for OASIS)
413## ===========================================================================
414for InFile in *.nc ; do
415    OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc
416    if [[ ! -f ${OuFile} ]] ; then
417        ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile}
418    fi
419done
420
421##
422## Add time axis and coordinates information
423## (needed if files need to be read by XIOS)
424## ===========================================================================
425#ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc
426ncap2 --overwrite --history --script 'defdim("time_counter",1) ;' ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
427cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n10.nc
428
429ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc
430
431if [[ ${atm} = ico ]] ; then
432    cat <<EOF > add_time.nco
433OceFrac    [time_counter,cell] = OceFrac    [cell] ;
434OceMask    [time_counter,cell] = OceMask    [cell] ;
435AtmCoastal [time_counter,cell] = AtmCoastal [cell] ;
436EOF
437    ncap2 --overwrite --history --script-file 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
438    cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n11.nc
439    ncatted --history \
440            -a coordinates,OceFrac,m,c,"time_counter lat lon"    \
441            -a coordinates,OceMask,m,c,"time_counter lat lon"    \
442            -a coordinates,AtmCoastal,m,c,"time_counter lat lon" \
443            -a coordinates,aire,c,c,"lat lon" \
444            ${ATM}_grid_maskFrom_${OCE}.nc
445    cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n12.nc
446fi
447ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc
448
449if [[ ${atm} = lmd ]] ; then
450    cat <<EOF > add_time.nco
451OceFrac    [time_counter,lat,lon] = OceFrac    [lat,lon] ;
452OceMask    [time_counter,lat,lon] = OceMask    [lat,lon]  ;
453AtmCoastal [time_counter,lat,lon] = AtmCoastal [lat,lon]  ;
454EOF
455    ncap2 --overwrite --history --script-file add_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc
456    ncdump -h tmp_${ATM}_grid_maskFrom_${OCE}.nc
457    mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
458    cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n13.nc
459   
460    ncatted --history \
461            -a coordinates,OceFrac,m,c,"time_counter lat lon"    \
462            -a coordinates,OceMask,m,c,"time_counter lat lon"    \
463            -a coordinates,AtmCoastal,m,c,"time_counter lat lon" \
464            -a coordinates,aire,m,c,"lat lon" \
465            ${ATM}_grid_maskFrom_${OCE}.nc
466    cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n14.nc
467fi
468ncks --alphabetize --history --overwrite --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
469cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n15.nc
470ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc
471cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n16.nc
472
473##
474## Add some metadata in file headers
475## ===========================================================================
476
477UUID=$(uuid)
478NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
479PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" )
480for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc; do
481    ncatted --history \
482            --attribute uuid,global,d,,                                           \
483            --attribute LongName,global,d,,                                       \
484            --attribute nco_openmp_thread_number,global,d,,                       \
485            --attribute Conventions,global,o,c,"CF-1.6"                           \
486            --attribute source,global,o,c,"IPSL Earth system model"               \
487            --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
488            --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \
489            --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \
490            --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \
491            --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \
492            --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc"      \
493            --attribute associatedFiles,global,o,c,"grids_${OCE}x${ATM}.nc areas_${OCE}x${ATM}.nc masks_${OCE}x${ATM}.nc" \
494            --attribute directory,global,o,c,"$(pwd)"                             \
495            --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
496            --attribute title,global,o,c,"${InFile}.nc"                           \
497            --attribute Program,global,o,c,"Generated by ${PROGRAM}"              \
498            --attribute timeStamp,global,o,c,"$(date)"                            \
499            --attribute uuid,global,o,c,"${UUID}"                                 \
500            --attribute HOSTNAME,global,o,c,"$(hostname)"                         \
501            --attribute LOGNAME,global,o,c,"$(whoami)"                            \
502            --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
503            --attribute Python,global,o,c,"Python version ${PYTHON_VER}"          \
504            --attribute OS,global,o,c,"$(uname -o)"                               \
505            --attribute release,global,o,c,"$(uname -r)"                          \
506            --attribute hardware,global,o,c,"$(uname -i)"                         \
507            --attribute directory,global,o,c,"$(pwd)"                             \
508            --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" \
509            --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \
510            --attribute SVN_Author,global,o,c,"$Author$"                 \
511            --attribute SVN_Date,global,o,c,"$Date$"                            \
512            --attribute SVN_Revision,global,o,c,"$Revision$"               \
513            --attribute SVN_Id,global,o,c,"$Id$"                                \
514            ${InFile}
515done
516cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n20.nc
517##
518## Update and complete weights file to fit OASIS requested format
519## ===========================================================================
520cat <<EOF > add_dim.nco
521defdim("num_wgts",1) ;
522weight[n_weight, num_wgts] = weight ;
523EOF
524
525for rmpFile in rmp_*.nc ; do
526    mv ${rmpFile} xios_${rmpFile}
527    ncap2 --fl_fmt=${FMT_OASIS} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile}
528   
529    ncrename --history --dimension n_weight,num_links   ${rmpFile}
530    ncrename --history --variable  src_idx,src_address  ${rmpFile}
531    ncrename --history --variable  dst_idx,dst_address  ${rmpFile}
532    ncrename --history --variable  weight,remap_matrix  ${rmpFile}
533    case ${rmpFile} in
534        ( *_1storder_*.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${rmpFile} ;;
535        ( *_2ndorder_*.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${rmpFile} ;;
536    esac
537    case ${rmpFile} in
538        ( *_true.nc  ) ncatted --history --attribute map_method,global,o,c,"Normalization: true"  ${rmpFile} ;;
539        ( *_false.nc ) ncatted --history --attribute map_method,global,o,c,"Normalization: false" ${rmpFile} ;;
540    esac
541    ncatted --history --attribute conventions,global,o,c,"SCRIP"   ${rmpFile}
542    ncatted --history --attribute normalization,global,o,c,"none"  ${rmpFile}
543   
544    case ${rmpFile} in
545        ( rmp_*${oce}_to_t${atm}_* )
546        ncatted --history \
547                --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \
548                --attribute source_grid,global,o,c,"${oce_domain_type}" \
549                --attribute dest_grid,global,o,c,"${atm_domain_type}"   \
550                ${rmpFile}     
551        ;;
552        ( rmp_*${atm}_to_*${oce}_* )
553        ncatted --history \
554                --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \
555                --attribute source_grid,global,o,c,"${atm_domain_type}" \
556                --attribute dest_grid,global,o,c,"${oce_domain_type}"   \
557                ${rmpFile}
558        ;;
559    esac
560done
561
562##
563## Add missing variables in rmp files
564## ===========================================================================
565for rmpFile in rmp_?${atm}_to_[tuv]${oce}_*order_*.nc rmp_[tuv]${oce}_to_t${atm}_*order_*.nc* ; do
566    echo ${rmpFile}
567    a_to_o=false ; o_to_a=false
568    case ${rmpFile} in
569        (  rmp_?${oce}_to_?${atm}_*.nc ) o_to_a=true ;;
570        (  rmp_?${atm}_to_?${oce}_*.nc ) a_to_o=true ;;
571    esac
572
573    for Grid in t u v o c ; do # Identify grids
574        [[ ${rmpFile} = rmp_${Grid}${oce}_to_?${atm}_*.nc ]] && ogrid=${Grid}
575        [[ ${rmpFile} = rmp_?${oce}_to_${Grid}${atm}_*.nc ]] && agrid=${Grid}
576        [[ ${rmpFile} = rmp_${Grid}${atm}_to_?${oce}_*.nc ]] && agrid=${Grid}
577        [[ ${rmpFile} = rmp_?${atm}_to_${Grid}${oce}_*.nc ]] && ogrid=${Grid}
578    done
579    OGRID=${ogrid^}
580    AGRID=${agrid^}
581       
582    cat <<EOF >add_varoce.nco
583defdim ("src_grid_size"   , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ;
584defdim ("src_grid_corners", 4) ;
585defdim ("src_grid_rank"   , 2) ;
586//
587src_grid_dims[src_grid_rank] = { \$y_grid_${OGRID}.size, \$x_grid_${OGRID}.size } ;
588//
589src_grid_center_lat [src_grid_size] =  0.0d ;
590src_grid_center_lon [src_grid_size] =  0.0d ;
591src_grid_center_lat (:) = nav_lat_grid_${OGRID}(:,:)   ;
592src_grid_center_lon (:) = nav_lon_grid_${OGRID}(:,:)   ;
593//
594src_grid_corner_lat [src_grid_size, src_grid_corners] = 0.0d ;
595src_grid_corner_lon [src_grid_size, src_grid_corners] = 0.0d ;
596src_grid_corner_lat(:,:) = bounds_lat_grid_${OGRID}(:,:,:) ;
597src_grid_corner_lon(:,:) = bounds_lon_grid_${OGRID}(:,:,:) ;
598//
599src_grid_imask [src_grid_size] =    0 ;
600src_grid_area  [src_grid_size] = 0.0d ;
601src_grid_frac  [src_grid_size] = 1.0d ;
602src_grid_imask (:) = 1 - mask_${OGRID}(:,:) ;
603src_grid_imask.int() ;
604src_grid_area  (:) = area_grid_${OGRID}(:,:) ;
605EOF
606
607    [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile}
608    sed --in-place "s/src_/dst_/g" add_varoce.nco
609    [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile}
610               
611    if [[ ${atm} = ico ]] ; then
612        cat <<EOF >add_varatm.nco
613defdim ("dst_grid_size"   , \$cell.size) ;
614defdim ("dst_grid_corners", 6) ;
615defdim ("dst_grid_rank"   , 2) ;
616//
617dst_grid_dims[dst_grid_rank] = { \$cell.size, 1 } ;
618//
619dst_grid_center_lat [dst_grid_size] =  0.0d ;
620dst_grid_center_lon [dst_grid_size] =  0.0d ;
621dst_grid_center_lat (:) = lat(:)   ;
622dst_grid_center_lon (:) = lon(:)   ;
623//
624dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ;
625dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ;
626dst_grid_corner_lat(:,:) = bounds_lat(:,:) ;
627dst_grid_corner_lon(:,:) = bounds_lon(:,:) ;
628//
629dst_grid_imask [dst_grid_size] =    0 ;
630dst_grid_area  [dst_grid_size] = 0.0d ;
631dst_grid_frac  [dst_grid_size] = 1.0d ;
632dst_grid_imask (:) = 1 - OceMask(0,:) ;
633dst_grid_imask.int() ;
634dst_grid_area  (:) = aire(:) ;
635dst_grid_frac  (:) = OceFrac(0,:) ;
636EOF
637        if [[ ${o_to_a} = true ]] ; then
638            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile}
639            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc
640            mv rmp_tmp.nc ${rmpFile}
641        fi
642                   
643        sed --in-place "s/dst_/src_/g" add_varatm.nco
644        if [[ ${a_to_o} = true ]] ; then
645            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile}
646            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc
647            mv rmp_tmp.nc ${rmpFile}
648        fi
649    fi
650   
651    if [[ ${atm} = lmd ]] ; then
652        cat <<EOF >add_varatm.nco
653defdim ("dst_grid_size"   , \$lon.size*\$lat.size) ;
654defdim ("dst_grid_corners", 4) ;
655defdim ("dst_grid_rank"   , 2) ;
656//
657dst_grid_dims[dst_grid_rank] = { \$lat.size, \$lon.size } ;
658//
659dst_grid_center_lat [dst_grid_size] =  0.0d ;
660dst_grid_center_lon [dst_grid_size] =  0.0d ;
661lat0lon[lat,lon] = lat(:)+0*lon(:) ;
662lon0lat[lat,lon] = lon(:)+0*lat(:) ;
663dst_grid_center_lat (:) = lat0lon(:,:)   ;
664dst_grid_center_lon (:) = lon0lat(:,:)   ;
665//
666//dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; // Not available for LMDZ lon/lat grid
667//dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ;
668//dst_grid_corner_lat(:,:) = bounds_lat(:,:) ;
669//dst_grid_corner_lon(:,:) = bounds_lon(:,:) ;
670//
671dst_grid_imask [dst_grid_size] =    0 ;
672dst_grid_area  [dst_grid_size] = 0.0d ;
673dst_grid_frac  [dst_grid_size] = 1.0d ;
674dst_grid_imask (:) = 1 - OceMask(0,:,:) ;
675dst_grid_imask.int() ;
676dst_grid_area  (:) = aire(:,:) ;
677dst_grid_frac (:)  = OceFrac(0,:,:) ;
678EOF
679        if [[ ${o_to_a} = true ]] ; then
680            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile}
681            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc
682            mv rmp_tmp.nc ${rmpFile}
683        fi
684       
685        sed --in-place "s/dst/src/g" add_varatm.nco
686        if [[ ${a_to_o} = true ]] ; then
687            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile}
688            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc
689            mv rmp_tmp.nc ${rmpFile}
690        fi
691    fi
692done
693ls -al ${OCE}_coordinates_mask.nc
694##
695## Save results
696## ===========================================================================
697cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR}
698for File in dia_*.nc rmp_*.nc
699do
700    ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File}
701    NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" )
702    cp ${File} ${SUBMIT_DIR}/${NewFile}
703done
704
705##
706## Creates and save auxiliary files for OASIS
707## ===========================================================================
708bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM}
709
710cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR}
711cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR}
712cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR}
713
714
715## ===========================================================================
716##
717##                               That's all folk's !!!
718##
719## ===========================================================================
720
Note: See TracBrowser for help on using the repository browser.