[3620] | 1 | #!/bin/bash |
---|
[3719] | 2 | #MSUB -r WeightsMask # Job name |
---|
| 3 | #MSUB -o Out_WeightsMask # Standard output |
---|
| 4 | #MSUB -e Out_WeightsMask # Error output |
---|
[3620] | 5 | #MSUB -eo |
---|
[4037] | 6 | #MSUB -n 8 # Number of processors |
---|
[3966] | 7 | #MSUB -T 1800 # Time limit (seconds) |
---|
| 8 | #MSUB -q skylake |
---|
[3620] | 9 | #MSUB -Q test |
---|
[3966] | 10 | #MSUB -p gen2212 |
---|
| 11 | #MSUB -m work |
---|
[3620] | 12 | |
---|
| 13 | ### =========================================================================== |
---|
| 14 | ### |
---|
[3719] | 15 | ### Creates interpolation weights between ORCA and atmosphere grids. |
---|
[3620] | 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 |
---|
[3627] | 20 | ### |
---|
| 21 | ### Documentation : https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM6/MOSAIX |
---|
[3620] | 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 | ## |
---|
[3623] | 33 | ## SVN information |
---|
[3665] | 34 | # $Author$ |
---|
| 35 | # $Date$ |
---|
| 36 | # $Revision$ |
---|
| 37 | # $Id$ |
---|
[3632] | 38 | # $HeadURL$ |
---|
[3901] | 39 | export Bold=$(tput bold) |
---|
| 40 | export Unde=$(tput smul) ; export OffUnde=$(tput rmul) |
---|
| 41 | export Stou=$(tput smso) ; export OffStou=$(tput rmso) |
---|
| 42 | export Reve=$(tput rev ) |
---|
| 43 | couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) |
---|
| 44 | for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done |
---|
| 45 | export Norm=$(tput sgr0 ) |
---|
[3620] | 46 | |
---|
| 47 | ## |
---|
| 48 | ## Configuration |
---|
| 49 | ## =========================================================================== |
---|
| 50 | |
---|
| 51 | # |
---|
| 52 | # Defines models |
---|
| 53 | # ============== |
---|
[4037] | 54 | #OCE=ORCA2.3 |
---|
[4081] | 55 | OCE=eORCA1.2 |
---|
| 56 | #OCE=ORCA025 |
---|
[3620] | 57 | |
---|
[4081] | 58 | #ATM=ICO30 |
---|
| 59 | ATM=ICO40 |
---|
[3620] | 60 | #ATM=ICO450 |
---|
[4037] | 61 | #ATM=LMD9695 |
---|
[3620] | 62 | #ATM=LMD144X142 |
---|
| 63 | |
---|
| 64 | # |
---|
| 65 | # Defines OCE grids to handle |
---|
| 66 | # =========================== |
---|
| 67 | ListOCEGRID="T U V" |
---|
[4081] | 68 | ListOrder="1st 2nd" |
---|
| 69 | ListNormalize="false true" |
---|
[3620] | 70 | |
---|
| 71 | ## =========================================================================== |
---|
| 72 | ## |
---|
| 73 | ## You should not change anything below this line .... |
---|
| 74 | ## |
---|
| 75 | ## =========================================================================== |
---|
| 76 | SUBMIT_DIR=$(pwd) |
---|
| 77 | |
---|
| 78 | # |
---|
| 79 | # Defines computer |
---|
| 80 | # ================ |
---|
[3901] | 81 | if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi |
---|
| 82 | if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi |
---|
[3734] | 83 | if [[ $(hostname) = lsce3005* ]] ; then arch=spip ; center=spip ; fi |
---|
| 84 | |
---|
[3620] | 85 | PROGRAM=$(basename ${0}) |
---|
| 86 | |
---|
| 87 | case ${arch} in |
---|
[3966] | 88 | ( curie ) |
---|
[3620] | 89 | set +vx |
---|
[3686] | 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 |
---|
[3966] | 93 | module load datadir/igcmg |
---|
[3620] | 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} |
---|
[3734] | 98 | MPIRUN=ccc_mprun |
---|
[3620] | 99 | ;; |
---|
[3966] | 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 | ;; |
---|
[3734] | 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 | ;; |
---|
[3901] | 119 | ( * ) exit -1 ;; |
---|
[3620] | 120 | esac |
---|
| 121 | |
---|
| 122 | set -x ; set -e |
---|
| 123 | |
---|
| 124 | mkdir -p ${TMPDIR}/${OCE}x${ATM} || exit 1 |
---|
| 125 | cd ${TMPDIR}/${OCE}x${ATM} || exit 1 |
---|
| 126 | rm -f * |
---|
| 127 | |
---|
| 128 | # |
---|
| 129 | # Suffixes |
---|
| 130 | # --------------------------------------------------------------------------- |
---|
[3719] | 131 | Listocegrid=${ListOCEGRID,,} |
---|
[3620] | 132 | |
---|
| 133 | case ${OCE} in |
---|
| 134 | ( *ORC* ) oce=orc ; oce_domain_type=curvilinear ;; |
---|
| 135 | esac |
---|
| 136 | case ${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 ;; |
---|
| 140 | esac |
---|
| 141 | |
---|
[3723] | 142 | case ${OCE} in |
---|
| 143 | ( ORCA2.3* ) OcePerio=4 ;; |
---|
| 144 | ( ORCA1* | eORCA1* ) OcePerio=6 ;; |
---|
[4037] | 145 | ( ORCA025* ) OcePerio=6 ;; |
---|
[3723] | 146 | esac |
---|
[3620] | 147 | # |
---|
| 148 | # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits |
---|
| 149 | # --------------------------------------------------------------------------- |
---|
[3901] | 150 | FMT_OASIS=64bit |
---|
| 151 | FMT_XIOS=netcdf4 |
---|
[3620] | 152 | |
---|
| 153 | |
---|
[3723] | 154 | cp ${SUBMIT_DIR}/bin/interpol.exe . |
---|
| 155 | cp ${SUBMIT_DIR}/*.py . |
---|
[3620] | 156 | |
---|
[3901] | 157 | |
---|
[3620] | 158 | cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . |
---|
[3639] | 159 | cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . |
---|
[3620] | 160 | |
---|
[3901] | 161 | ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc |
---|
| 162 | ncks --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 |
---|
[3912] | 165 | # -------------------------------------------------------------------------------------------------------- |
---|
[3901] | 166 | cat <<EOF >add_c_grid.nco |
---|
[4037] | 167 | defdim("x_grid_C", \$x_grid_T.size) ; |
---|
| 168 | defdim("y_grid_C", \$y_grid_T.size) ; |
---|
| 169 | defdim("nvertex_grid_C", 4) ; |
---|
| 170 | nav_lon_grid_C[y_grid_C,x_grid_C] = nav_lon_grid_T(:,:) ; |
---|
| 171 | nav_lat_grid_C[y_grid_C,x_grid_C] = nav_lat_grid_T(:,:) ; |
---|
| 172 | bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ; |
---|
| 173 | bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ; |
---|
| 174 | mask_C[y_grid_C,x_grid_C] = maskutil_T(:,:) ; |
---|
| 175 | area_grid_C[y_grid_C,x_grid_C] = area_grid_T(:,:) ; |
---|
[3901] | 176 | EOF |
---|
[3620] | 177 | |
---|
[3901] | 178 | ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc |
---|
[4037] | 179 | ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc |
---|
| 180 | ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc |
---|
| 181 | ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 182 | ncks --history --append --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 183 | ncks --history --append --variable area_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
[3912] | 184 | |
---|
[4037] | 185 | ncks --history --append C_${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask.nc |
---|
[3901] | 186 | rm C_${OCE}_coordinates_mask.nc |
---|
| 187 | |
---|
[4037] | 188 | ncks --history --overwrite --fl_fmt=${FMT_OASIS} ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc |
---|
[3901] | 189 | |
---|
| 190 | ls -al |
---|
| 191 | |
---|
| 192 | ## |
---|
| 193 | ## NEMO T point towards ATM - 1st order |
---|
| 194 | ## =========================================================================== |
---|
[3620] | 195 | echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm} |
---|
| 196 | cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml iodef.xml |
---|
| 197 | |
---|
| 198 | 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 |
---|
| 199 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
| 200 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
| 201 | 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 |
---|
[3719] | 202 | 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_false |
---|
[3620] | 203 | 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}" |
---|
| 204 | 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} |
---|
| 205 | 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} |
---|
| 206 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1 |
---|
| 207 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
| 208 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
[3719] | 209 | 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_false.nc |
---|
[3620] | 210 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 |
---|
[3719] | 211 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false |
---|
| 212 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false |
---|
[3620] | 213 | |
---|
[3719] | 214 | cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml |
---|
[3901] | 215 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 216 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3620] | 217 | |
---|
[3734] | 218 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no |
---|
[3620] | 219 | ## |
---|
| 220 | ## Correct spurious values (extremes) |
---|
| 221 | ## =========================================================================== |
---|
| 222 | cat <<EOF > correction_masque.nco |
---|
| 223 | where (OceFrac < 0.00001 ) OceFrac=OceFrac.get_miss() ; |
---|
| 224 | where (OceFrac > 0.99999 ) OceFrac=1.0 ; |
---|
| 225 | OceFrac.delete_miss() ; |
---|
| 226 | // Fill masked values to land values |
---|
| 227 | where (OceFrac > 1.0 ) OceFrac=0.0 ; |
---|
| 228 | where (OceFrac < 0.0 ) OceFrac=0.0 ; |
---|
| 229 | EOF |
---|
[3719] | 230 | ncap2 --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 |
---|
| 231 | ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder_false.nc |
---|
[3620] | 232 | |
---|
| 233 | ## |
---|
| 234 | ## Creates mask on ATM grid |
---|
| 235 | ## =========================================================================== |
---|
[3719] | 236 | cp dia_t${oce}_to_t${atm}_1storder_false.nc dia_t${oce}_to_t${atm}_1storder_false_mask.nc |
---|
| 237 | ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_1storder_false_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3620] | 238 | |
---|
| 239 | cat <<EOF > creation_masque.nco |
---|
| 240 | where (OceFrac > 0.0 ) OceFrac=1 ; |
---|
| 241 | where (OceFrac <= 0.0 ) OceFrac=0 ; |
---|
| 242 | EOF |
---|
[4081] | 243 | |
---|
[3719] | 244 | ncap2 --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 |
---|
| 245 | ncrename --history --variable OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc |
---|
[3620] | 246 | |
---|
[4081] | 247 | ncks --overwrite --history --variable OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc tmp_OceMask.nc |
---|
| 248 | ncks --history --append tmp_OceMask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3723] | 249 | rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc |
---|
[3620] | 250 | |
---|
[4081] | 251 | # Change dimension names, and some attributes accordingly |
---|
| 252 | if [[ $(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 |
---|
| 271 | fi |
---|
| 272 | |
---|
| 273 | ncks --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 | |
---|
[3620] | 277 | ## |
---|
| 278 | ## NEMO, other case, towards ATM |
---|
| 279 | ## =========================================================================== |
---|
[3719] | 280 | for order in ${ListOrder} ; do |
---|
[3620] | 281 | case ${order} in |
---|
| 282 | ( 1st ) num_order=1 ;; |
---|
| 283 | ( 2nd ) num_order=2 ;; |
---|
| 284 | esac |
---|
[3719] | 285 | for normalize in ${ListNormalize} ; do |
---|
| 286 | for OCEGRID in ${ListOCEGRID} ; do |
---|
| 287 | ocegrid=${OCEGRID,,} |
---|
[3620] | 288 | |
---|
[3719] | 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 | |
---|
[3901] | 311 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 312 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3734] | 313 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
[3719] | 314 | fi |
---|
| 315 | |
---|
| 316 | done |
---|
[3620] | 317 | done |
---|
| 318 | done |
---|
| 319 | |
---|
| 320 | ## |
---|
| 321 | ## ATM towards NEMO points |
---|
| 322 | ## =========================================================================== |
---|
| 323 | cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml iodef.xml |
---|
| 324 | |
---|
| 325 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
| 326 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
| 327 | 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}" |
---|
| 328 | 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} |
---|
| 329 | 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} |
---|
| 330 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
| 331 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
| 332 | |
---|
[3719] | 333 | for order in ${ListOrder} ; do |
---|
[3620] | 334 | case ${order} in |
---|
| 335 | ( 1st ) num_order=1 ;; |
---|
| 336 | ( 2nd ) num_order=2 ;; |
---|
| 337 | esac |
---|
[3719] | 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} |
---|
[3620] | 343 | |
---|
[3719] | 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 | |
---|
[3901] | 354 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 355 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3734] | 356 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
[3719] | 357 | |
---|
| 358 | done |
---|
[3620] | 359 | done |
---|
| 360 | done |
---|
| 361 | |
---|
| 362 | ## |
---|
[3901] | 363 | ## Creates mask of coastal OCE points |
---|
| 364 | ## =========================================================================== |
---|
| 365 | python ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal |
---|
| 366 | ## |
---|
| 367 | ## Creates mask of coastal ATM points |
---|
| 368 | ## =========================================================================== |
---|
| 369 | cat <<EOF > coastal.nco |
---|
| 370 | AtmCoastal = OceFrac * 0.0 ; |
---|
| 371 | where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; |
---|
| 372 | EOF |
---|
| 373 | ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc |
---|
[4081] | 374 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n07.nc |
---|
[3901] | 375 | ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4081] | 376 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n08.nc |
---|
[3901] | 377 | rm ${ATM}_coastal_maskFrom_${OCE}.nc |
---|
| 378 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
[4081] | 379 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n09.nc |
---|
| 380 | |
---|
[3901] | 381 | ## |
---|
[3718] | 382 | ## ATM towards NEMO points - runoff |
---|
| 383 | ## =========================================================================== |
---|
| 384 | cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml iodef.xml |
---|
[3719] | 385 | for 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 |
---|
[3723] | 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 |
---|
[3901] | 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 |
---|
[3719] | 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 | |
---|
[3901] | 403 | cp iodef.xml iodef_o${atm}_to_c${oce}_1storder_${normalize}.xml |
---|
[3719] | 404 | |
---|
[3901] | 405 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 406 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3734] | 407 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
[3901] | 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 |
---|
[3719] | 410 | done |
---|
[3718] | 411 | ## |
---|
[3901] | 412 | ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) |
---|
[3620] | 413 | ## =========================================================================== |
---|
| 414 | for InFile in *.nc ; do |
---|
[3901] | 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 |
---|
[3620] | 419 | done |
---|
| 420 | |
---|
| 421 | ## |
---|
| 422 | ## Add time axis and coordinates information |
---|
| 423 | ## (needed if files need to be read by XIOS) |
---|
| 424 | ## =========================================================================== |
---|
[3719] | 425 | #ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 426 | ncap2 --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 |
---|
[4081] | 427 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n10.nc |
---|
[3966] | 428 | |
---|
[3901] | 429 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
[3719] | 430 | |
---|
[3620] | 431 | if [[ ${atm} = ico ]] ; then |
---|
| 432 | cat <<EOF > add_time.nco |
---|
[3966] | 433 | OceFrac [time_counter,cell] = OceFrac [cell] ; |
---|
| 434 | OceMask [time_counter,cell] = OceMask [cell] ; |
---|
| 435 | AtmCoastal [time_counter,cell] = AtmCoastal [cell] ; |
---|
[3620] | 436 | EOF |
---|
[3719] | 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 |
---|
[4081] | 438 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n11.nc |
---|
[3639] | 439 | ncatted --history \ |
---|
[4081] | 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" \ |
---|
[3719] | 444 | ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4081] | 445 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n12.nc |
---|
[3620] | 446 | fi |
---|
[3901] | 447 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
| 448 | |
---|
[3620] | 449 | if [[ ${atm} = lmd ]] ; then |
---|
| 450 | cat <<EOF > add_time.nco |
---|
[3966] | 451 | OceFrac [time_counter,lat,lon] = OceFrac [lat,lon] ; |
---|
| 452 | OceMask [time_counter,lat,lon] = OceMask [lat,lon] ; |
---|
| 453 | AtmCoastal [time_counter,lat,lon] = AtmCoastal [lat,lon] ; |
---|
[3620] | 454 | EOF |
---|
[3966] | 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 |
---|
[4081] | 458 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n13.nc |
---|
[3966] | 459 | |
---|
[3639] | 460 | ncatted --history \ |
---|
[3966] | 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" \ |
---|
[3719] | 465 | ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4081] | 466 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n14.nc |
---|
[3620] | 467 | fi |
---|
[4037] | 468 | ncks --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 |
---|
[4081] | 469 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n15.nc |
---|
[3901] | 470 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
[4081] | 471 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n16.nc |
---|
[3620] | 472 | |
---|
| 473 | ## |
---|
[3719] | 474 | ## Add some metadata in file headers |
---|
[3620] | 475 | ## =========================================================================== |
---|
| 476 | |
---|
| 477 | UUID=$(uuid) |
---|
| 478 | NCO="$(ncks --version |& tail -1|sed 's/ncks //')" |
---|
| 479 | PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) |
---|
[3901] | 480 | for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc; do |
---|
[3639] | 481 | ncatted --history \ |
---|
[3620] | 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)" \ |
---|
[3624] | 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" \ |
---|
[3620] | 509 | --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ |
---|
[3665] | 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$" \ |
---|
[3620] | 514 | ${InFile} |
---|
| 515 | done |
---|
[4081] | 516 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_n20.nc |
---|
[3620] | 517 | ## |
---|
| 518 | ## Update and complete weights file to fit OASIS requested format |
---|
| 519 | ## =========================================================================== |
---|
| 520 | cat <<EOF > add_dim.nco |
---|
| 521 | defdim("num_wgts",1) ; |
---|
| 522 | weight[n_weight, num_wgts] = weight ; |
---|
| 523 | EOF |
---|
| 524 | |
---|
[3719] | 525 | for rmpFile in rmp_*.nc ; do |
---|
| 526 | mv ${rmpFile} xios_${rmpFile} |
---|
[3901] | 527 | ncap2 --fl_fmt=${FMT_OASIS} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} |
---|
[3620] | 528 | |
---|
[3719] | 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} ;; |
---|
[3620] | 536 | esac |
---|
[3719] | 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} |
---|
[3620] | 543 | |
---|
[3719] | 544 | case ${rmpFile} in |
---|
[3620] | 545 | ( rmp_*${oce}_to_t${atm}_* ) |
---|
[3639] | 546 | ncatted --history \ |
---|
[3620] | 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}" \ |
---|
[3719] | 550 | ${rmpFile} |
---|
[3620] | 551 | ;; |
---|
| 552 | ( rmp_*${atm}_to_*${oce}_* ) |
---|
[3639] | 553 | ncatted --history \ |
---|
[3620] | 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}" \ |
---|
[3719] | 557 | ${rmpFile} |
---|
[3620] | 558 | ;; |
---|
| 559 | esac |
---|
| 560 | done |
---|
| 561 | |
---|
| 562 | ## |
---|
[3639] | 563 | ## Add missing variables in rmp files |
---|
| 564 | ## =========================================================================== |
---|
[4037] | 565 | for rmpFile in rmp_?${atm}_to_[tuv]${oce}_*order_*.nc rmp_[tuv]${oce}_to_t${atm}_*order_*.nc* ; do |
---|
[3901] | 566 | echo ${rmpFile} |
---|
[3719] | 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 | |
---|
[3901] | 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} |
---|
[3719] | 578 | done |
---|
| 579 | OGRID=${ogrid^} |
---|
| 580 | AGRID=${agrid^} |
---|
[3639] | 581 | |
---|
[3719] | 582 | cat <<EOF >add_varoce.nco |
---|
[3639] | 583 | defdim ("src_grid_size" , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; |
---|
| 584 | defdim ("src_grid_corners", 4) ; |
---|
| 585 | defdim ("src_grid_rank" , 2) ; |
---|
| 586 | // |
---|
| 587 | src_grid_dims[src_grid_rank] = { \$y_grid_${OGRID}.size, \$x_grid_${OGRID}.size } ; |
---|
| 588 | // |
---|
| 589 | src_grid_center_lat [src_grid_size] = 0.0d ; |
---|
| 590 | src_grid_center_lon [src_grid_size] = 0.0d ; |
---|
| 591 | src_grid_center_lat (:) = nav_lat_grid_${OGRID}(:,:) ; |
---|
| 592 | src_grid_center_lon (:) = nav_lon_grid_${OGRID}(:,:) ; |
---|
| 593 | // |
---|
| 594 | src_grid_corner_lat [src_grid_size, src_grid_corners] = 0.0d ; |
---|
| 595 | src_grid_corner_lon [src_grid_size, src_grid_corners] = 0.0d ; |
---|
| 596 | src_grid_corner_lat(:,:) = bounds_lat_grid_${OGRID}(:,:,:) ; |
---|
| 597 | src_grid_corner_lon(:,:) = bounds_lon_grid_${OGRID}(:,:,:) ; |
---|
| 598 | // |
---|
| 599 | src_grid_imask [src_grid_size] = 0 ; |
---|
| 600 | src_grid_area [src_grid_size] = 0.0d ; |
---|
| 601 | src_grid_frac [src_grid_size] = 1.0d ; |
---|
| 602 | src_grid_imask (:) = 1 - mask_${OGRID}(:,:) ; |
---|
| 603 | src_grid_imask.int() ; |
---|
| 604 | src_grid_area (:) = area_grid_${OGRID}(:,:) ; |
---|
| 605 | EOF |
---|
| 606 | |
---|
[3901] | 607 | [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 608 | sed --in-place "s/src_/dst_/g" add_varoce.nco |
---|
[3901] | 609 | [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 610 | |
---|
| 611 | if [[ ${atm} = ico ]] ; then |
---|
| 612 | cat <<EOF >add_varatm.nco |
---|
[3639] | 613 | defdim ("dst_grid_size" , \$cell.size) ; |
---|
| 614 | defdim ("dst_grid_corners", 6) ; |
---|
| 615 | defdim ("dst_grid_rank" , 2) ; |
---|
| 616 | // |
---|
| 617 | dst_grid_dims[dst_grid_rank] = { \$cell.size, 1 } ; |
---|
| 618 | // |
---|
| 619 | dst_grid_center_lat [dst_grid_size] = 0.0d ; |
---|
| 620 | dst_grid_center_lon [dst_grid_size] = 0.0d ; |
---|
| 621 | dst_grid_center_lat (:) = lat(:) ; |
---|
| 622 | dst_grid_center_lon (:) = lon(:) ; |
---|
| 623 | // |
---|
| 624 | dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 625 | dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 626 | dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; |
---|
| 627 | dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; |
---|
| 628 | // |
---|
| 629 | dst_grid_imask [dst_grid_size] = 0 ; |
---|
| 630 | dst_grid_area [dst_grid_size] = 0.0d ; |
---|
| 631 | dst_grid_frac [dst_grid_size] = 1.0d ; |
---|
| 632 | dst_grid_imask (:) = 1 - OceMask(0,:) ; |
---|
| 633 | dst_grid_imask.int() ; |
---|
| 634 | dst_grid_area (:) = aire(:) ; |
---|
[3966] | 635 | dst_grid_frac (:) = OceFrac(0,:) ; |
---|
[3639] | 636 | EOF |
---|
[3719] | 637 | if [[ ${o_to_a} = true ]] ; then |
---|
[3901] | 638 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 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 |
---|
[3718] | 642 | |
---|
[3719] | 643 | sed --in-place "s/dst_/src_/g" add_varatm.nco |
---|
| 644 | if [[ ${a_to_o} = true ]] ; then |
---|
[3901] | 645 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 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 |
---|
[3966] | 650 | |
---|
[3719] | 651 | if [[ ${atm} = lmd ]] ; then |
---|
| 652 | cat <<EOF >add_varatm.nco |
---|
[3639] | 653 | defdim ("dst_grid_size" , \$lon.size*\$lat.size) ; |
---|
| 654 | defdim ("dst_grid_corners", 4) ; |
---|
| 655 | defdim ("dst_grid_rank" , 2) ; |
---|
| 656 | // |
---|
| 657 | dst_grid_dims[dst_grid_rank] = { \$lat.size, \$lon.size } ; |
---|
| 658 | // |
---|
| 659 | dst_grid_center_lat [dst_grid_size] = 0.0d ; |
---|
| 660 | dst_grid_center_lon [dst_grid_size] = 0.0d ; |
---|
| 661 | lat0lon[lat,lon] = lat(:)+0*lon(:) ; |
---|
| 662 | lon0lat[lat,lon] = lon(:)+0*lat(:) ; |
---|
| 663 | dst_grid_center_lat (:) = lat0lon(:,:) ; |
---|
| 664 | dst_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 | // |
---|
| 671 | dst_grid_imask [dst_grid_size] = 0 ; |
---|
| 672 | dst_grid_area [dst_grid_size] = 0.0d ; |
---|
| 673 | dst_grid_frac [dst_grid_size] = 1.0d ; |
---|
| 674 | dst_grid_imask (:) = 1 - OceMask(0,:,:) ; |
---|
| 675 | dst_grid_imask.int() ; |
---|
| 676 | dst_grid_area (:) = aire(:,:) ; |
---|
| 677 | dst_grid_frac (:) = OceFrac(0,:,:) ; |
---|
| 678 | EOF |
---|
[3719] | 679 | if [[ ${o_to_a} = true ]] ; then |
---|
[3901] | 680 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 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 |
---|
[3901] | 687 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 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 |
---|
[3639] | 692 | done |
---|
[3901] | 693 | ls -al ${OCE}_coordinates_mask.nc |
---|
[3639] | 694 | ## |
---|
[3620] | 695 | ## Save results |
---|
| 696 | ## =========================================================================== |
---|
| 697 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} |
---|
[3719] | 698 | for File in dia_*.nc rmp_*.nc |
---|
[3620] | 699 | do |
---|
[4037] | 700 | ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File} |
---|
[3719] | 701 | NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) |
---|
| 702 | cp ${File} ${SUBMIT_DIR}/${NewFile} |
---|
[3620] | 703 | done |
---|
| 704 | |
---|
| 705 | ## |
---|
| 706 | ## Creates and save auxiliary files for OASIS |
---|
| 707 | ## =========================================================================== |
---|
| 708 | bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} |
---|
| 709 | |
---|
| 710 | cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
| 711 | cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
| 712 | cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
| 713 | |
---|
| 714 | |
---|
| 715 | ## =========================================================================== |
---|
| 716 | ## |
---|
| 717 | ## That's all folk's !!! |
---|
| 718 | ## |
---|
| 719 | ## =========================================================================== |
---|
| 720 | |
---|