[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 |
---|
[3966] | 6 | #MSUB -n 4 # Number of processors |
---|
| 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 | # ============== |
---|
[3686] | 54 | OCE=ORCA2.3 |
---|
| 55 | #OCE=eORCA1.2 |
---|
[3620] | 56 | #OCE=ORCA025 |
---|
| 57 | |
---|
[3734] | 58 | #ATM=ICO30 |
---|
[3620] | 59 | #ATM=ICO40 |
---|
| 60 | #ATM=ICO450 |
---|
[3734] | 61 | ATM=LMD9695 |
---|
[3620] | 62 | #ATM=LMD144X142 |
---|
| 63 | |
---|
| 64 | # |
---|
| 65 | # Defines OCE grids to handle |
---|
| 66 | # =========================== |
---|
| 67 | ListOCEGRID="T U V" |
---|
[3901] | 68 | ListOrder="1st" # 2nd" |
---|
[3719] | 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 ;; |
---|
| 145 | esac |
---|
[3620] | 146 | # |
---|
| 147 | # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits |
---|
| 148 | # --------------------------------------------------------------------------- |
---|
[3901] | 149 | FMT_OASIS=64bit |
---|
| 150 | FMT_XIOS=netcdf4 |
---|
[3620] | 151 | |
---|
| 152 | |
---|
[3723] | 153 | cp ${SUBMIT_DIR}/bin/interpol.exe . |
---|
| 154 | cp ${SUBMIT_DIR}/*.py . |
---|
[3620] | 155 | |
---|
[3901] | 156 | |
---|
[3620] | 157 | cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . |
---|
[3639] | 158 | cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . |
---|
[3620] | 159 | |
---|
[3901] | 160 | ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc |
---|
| 161 | ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc ${ATM}_grid_${FMT_OASIS}.nc |
---|
| 162 | # |
---|
| 163 | # Creates OCEAN C grid : redundant point removed to compute proper integrals # A passer dans CreateWeights |
---|
[3912] | 164 | # -------------------------------------------------------------------------------------------------------- |
---|
[3901] | 165 | cat <<EOF >add_c_grid.nco |
---|
| 166 | nav_lon_grid_C = nav_lon_grid_T ; |
---|
| 167 | nav_lat_grid_C = nav_lat_grid_T ; |
---|
| 168 | bounds_lon_grid_C = bounds_lon_grid_T ; |
---|
| 169 | bounds_lat_grid_C = bounds_lat_grid_T ; |
---|
[3912] | 170 | mask_C = maskutil_T ; |
---|
[3901] | 171 | area_grid_C = area_grid_T ; |
---|
| 172 | EOF |
---|
[3620] | 173 | |
---|
[3901] | 174 | ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc |
---|
[3912] | 175 | ncks --overwrite --variable nav_lon_grid_C,nav_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 176 | ncks --append --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 177 | #ncks --append --variable mask_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 178 | ncks --append --variable area_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 179 | |
---|
[3901] | 180 | ncrename --dimension x_grid_T,x_grid_C C_${OCE}_coordinates_mask.nc |
---|
| 181 | ncrename --dimension y_grid_T,y_grid_C C_${OCE}_coordinates_mask.nc |
---|
| 182 | ncrename --dimension nvertex_grid_T,nvertex_grid_C C_${OCE}_coordinates_mask.nc |
---|
| 183 | ncks --append C_${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask.nc |
---|
| 184 | rm C_${OCE}_coordinates_mask.nc |
---|
| 185 | |
---|
[3912] | 186 | ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc |
---|
[3901] | 187 | |
---|
| 188 | ls -al |
---|
| 189 | |
---|
| 190 | ## |
---|
| 191 | ## NEMO T point towards ATM - 1st order |
---|
| 192 | ## =========================================================================== |
---|
[3620] | 193 | echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm} |
---|
| 194 | cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml iodef.xml |
---|
| 195 | |
---|
| 196 | 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 |
---|
| 197 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
| 198 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
| 199 | 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] | 200 | 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] | 201 | 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}" |
---|
| 202 | 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} |
---|
| 203 | 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} |
---|
| 204 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1 |
---|
| 205 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
| 206 | 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] | 207 | 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] | 208 | 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] | 209 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false |
---|
| 210 | 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] | 211 | |
---|
[3719] | 212 | cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml |
---|
[3901] | 213 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 214 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3620] | 215 | |
---|
[3734] | 216 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no |
---|
[3620] | 217 | |
---|
| 218 | ## |
---|
| 219 | ## Correct spurious values (extremes) |
---|
| 220 | ## =========================================================================== |
---|
| 221 | cat <<EOF > correction_masque.nco |
---|
| 222 | where (OceFrac < 0.00001 ) OceFrac=OceFrac.get_miss() ; |
---|
| 223 | where (OceFrac > 0.99999 ) OceFrac=1.0 ; |
---|
| 224 | OceFrac.delete_miss() ; |
---|
| 225 | // Fill masked values to land values |
---|
| 226 | where (OceFrac > 1.0 ) OceFrac=0.0 ; |
---|
| 227 | where (OceFrac < 0.0 ) OceFrac=0.0 ; |
---|
| 228 | EOF |
---|
[3719] | 229 | 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 |
---|
| 230 | ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder_false.nc |
---|
[3620] | 231 | |
---|
| 232 | ## |
---|
| 233 | ## Creates mask on ATM grid |
---|
| 234 | ## =========================================================================== |
---|
[3719] | 235 | cp dia_t${oce}_to_t${atm}_1storder_false.nc dia_t${oce}_to_t${atm}_1storder_false_mask.nc |
---|
| 236 | ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_1storder_false_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 237 | ncks --alphabetize --history --append --variable aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 238 | [[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3620] | 239 | |
---|
| 240 | cat <<EOF > creation_masque.nco |
---|
| 241 | where (OceFrac > 0.0 ) OceFrac=1 ; |
---|
| 242 | where (OceFrac <= 0.0 ) OceFrac=0 ; |
---|
| 243 | EOF |
---|
[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 | |
---|
[3719] | 247 | ncks --alphabetize --history --append --variable OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3723] | 248 | rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc |
---|
[3620] | 249 | |
---|
| 250 | ## |
---|
| 251 | ## NEMO, other case, towards ATM |
---|
| 252 | ## =========================================================================== |
---|
[3719] | 253 | for order in ${ListOrder} ; do |
---|
[3620] | 254 | case ${order} in |
---|
| 255 | ( 1st ) num_order=1 ;; |
---|
| 256 | ( 2nd ) num_order=2 ;; |
---|
| 257 | esac |
---|
[3719] | 258 | for normalize in ${ListNormalize} ; do |
---|
| 259 | for OCEGRID in ${ListOCEGRID} ; do |
---|
| 260 | ocegrid=${OCEGRID,,} |
---|
[3620] | 261 | |
---|
[3719] | 262 | if [[ ! -f rmp_${ocegrid}${oce}_to_t${atm}_${order}order_${normalize}.nc ]] ; then |
---|
| 263 | |
---|
| 264 | echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}order - normalize: ${normalize}"${Norm} |
---|
| 265 | |
---|
| 266 | 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} |
---|
| 267 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
| 268 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
| 269 | 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} |
---|
| 270 | 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} |
---|
| 271 | 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}" |
---|
| 272 | 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} |
---|
| 273 | 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} |
---|
| 274 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${num_order} |
---|
| 275 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} |
---|
| 276 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${oce_domain_type} |
---|
| 277 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${atm_domain_type} |
---|
| 278 | 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} |
---|
| 279 | 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 |
---|
| 280 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${normalize} |
---|
| 281 | |
---|
| 282 | cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order_${normalize}.xml |
---|
| 283 | |
---|
[3901] | 284 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 285 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3734] | 286 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
[3719] | 287 | fi |
---|
| 288 | |
---|
| 289 | done |
---|
[3620] | 290 | done |
---|
| 291 | done |
---|
| 292 | |
---|
| 293 | ## |
---|
| 294 | ## ATM towards NEMO points |
---|
| 295 | ## =========================================================================== |
---|
| 296 | cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml iodef.xml |
---|
| 297 | |
---|
| 298 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
| 299 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
| 300 | 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}" |
---|
| 301 | 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} |
---|
| 302 | 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} |
---|
| 303 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
| 304 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
| 305 | |
---|
[3719] | 306 | for order in ${ListOrder} ; do |
---|
[3620] | 307 | case ${order} in |
---|
| 308 | ( 1st ) num_order=1 ;; |
---|
| 309 | ( 2nd ) num_order=2 ;; |
---|
| 310 | esac |
---|
[3719] | 311 | for normalize in ${ListNormalize} ; do |
---|
| 312 | 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} |
---|
| 313 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${num_order} |
---|
| 314 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} |
---|
| 315 | 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] | 316 | |
---|
[3719] | 317 | for OCEGRID in ${ListOCEGRID} ; do |
---|
| 318 | ocegrid=${OCEGRID,,} |
---|
| 319 | |
---|
| 320 | echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}order - normalize: ${normalize}"${Norm} |
---|
| 321 | 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} |
---|
| 322 | 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} |
---|
| 323 | 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} |
---|
| 324 | 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 |
---|
| 325 | cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.xml |
---|
| 326 | |
---|
[3901] | 327 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 328 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3734] | 329 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
[3719] | 330 | |
---|
| 331 | done |
---|
[3620] | 332 | done |
---|
| 333 | done |
---|
| 334 | |
---|
| 335 | ## |
---|
[3901] | 336 | ## Creates mask of coastal OCE points |
---|
| 337 | ## =========================================================================== |
---|
| 338 | python ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal |
---|
| 339 | ## |
---|
| 340 | ## Creates mask of coastal ATM points |
---|
| 341 | ## =========================================================================== |
---|
| 342 | cat <<EOF > coastal.nco |
---|
| 343 | AtmCoastal = OceFrac * 0.0 ; |
---|
| 344 | where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; |
---|
| 345 | EOF |
---|
| 346 | ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc |
---|
| 347 | ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 348 | rm ${ATM}_coastal_maskFrom_${OCE}.nc |
---|
| 349 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
| 350 | ## |
---|
[3718] | 351 | ## ATM towards NEMO points - runoff |
---|
| 352 | ## =========================================================================== |
---|
| 353 | cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml iodef.xml |
---|
[3719] | 354 | for normalize in ${ListNormalize} ; do |
---|
| 355 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
| 356 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
| 357 | 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}" |
---|
| 358 | 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} |
---|
| 359 | 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} |
---|
| 360 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${atm_domain_type} |
---|
| 361 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${oce_domain_type} |
---|
| 362 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 |
---|
| 363 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1 |
---|
| 364 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} |
---|
| 365 | 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} |
---|
| 366 | 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] | 367 | 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] | 368 | 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} |
---|
| 369 | 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] | 370 | python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${normalize} |
---|
| 371 | |
---|
[3901] | 372 | cp iodef.xml iodef_o${atm}_to_c${oce}_1storder_${normalize}.xml |
---|
[3719] | 373 | |
---|
[3901] | 374 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 375 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3734] | 376 | time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes |
---|
[3901] | 377 | |
---|
| 378 | # 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] | 379 | done |
---|
[3718] | 380 | ## |
---|
[3901] | 381 | ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) |
---|
[3620] | 382 | ## =========================================================================== |
---|
| 383 | for InFile in *.nc ; do |
---|
[3901] | 384 | OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc |
---|
| 385 | if [[ ! -f ${OuFile} ]] ; then |
---|
| 386 | ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile} |
---|
| 387 | fi |
---|
[3620] | 388 | done |
---|
| 389 | |
---|
| 390 | ## |
---|
| 391 | ## Add time axis and coordinates information |
---|
| 392 | ## (needed if files need to be read by XIOS) |
---|
| 393 | ## =========================================================================== |
---|
[3719] | 394 | #ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 395 | 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 |
---|
[3966] | 396 | ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 397 | |
---|
[3901] | 398 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
[3966] | 399 | ncdump -h ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
[3719] | 400 | |
---|
[3620] | 401 | if [[ ${atm} = ico ]] ; then |
---|
| 402 | cat <<EOF > add_time.nco |
---|
[3966] | 403 | OceFrac [time_counter,cell] = OceFrac [cell] ; |
---|
| 404 | OceMask [time_counter,cell] = OceMask [cell] ; |
---|
| 405 | AtmCoastal [time_counter,cell] = AtmCoastal [cell] ; |
---|
[3620] | 406 | EOF |
---|
[3719] | 407 | 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 |
---|
[3639] | 408 | ncatted --history \ |
---|
[3719] | 409 | -a coordinates,OceFrac,c,c,"time_counter cell" \ |
---|
| 410 | -a coordinates,OceMask,c,c,"time_counter cell" \ |
---|
| 411 | -a coordinates,AtmCoastal,c,c,"time_counter cell" \ |
---|
| 412 | -a coordinates,aire,c,c,"cell" \ |
---|
| 413 | ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3620] | 414 | fi |
---|
[3901] | 415 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
| 416 | |
---|
[3620] | 417 | if [[ ${atm} = lmd ]] ; then |
---|
| 418 | cat <<EOF > add_time.nco |
---|
[3966] | 419 | OceFrac [time_counter,lat,lon] = OceFrac [lat,lon] ; |
---|
| 420 | OceMask [time_counter,lat,lon] = OceMask [lat,lon] ; |
---|
| 421 | AtmCoastal [time_counter,lat,lon] = AtmCoastal [lat,lon] ; |
---|
[3620] | 422 | EOF |
---|
[3966] | 423 | ncap2 --overwrite --history --script-file add_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 424 | ncdump -h tmp_${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 425 | mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 426 | |
---|
[3639] | 427 | ncatted --history \ |
---|
[3966] | 428 | -a coordinates,OceFrac,m,c,"time_counter lat lon" \ |
---|
| 429 | -a coordinates,OceMask,m,c,"time_counter lat lon" \ |
---|
| 430 | -a coordinates,AtmCoastal,m,c,"time_counter lat lon" \ |
---|
| 431 | -a coordinates,aire,m,c,"lat lon" \ |
---|
[3719] | 432 | ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3620] | 433 | fi |
---|
[3719] | 434 | ncks --alphabetize --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 |
---|
[3901] | 435 | ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc |
---|
[3620] | 436 | |
---|
| 437 | ## |
---|
[3719] | 438 | ## Add some metadata in file headers |
---|
[3620] | 439 | ## =========================================================================== |
---|
| 440 | |
---|
| 441 | UUID=$(uuid) |
---|
| 442 | NCO="$(ncks --version |& tail -1|sed 's/ncks //')" |
---|
| 443 | PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) |
---|
[3901] | 444 | 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] | 445 | ncatted --history \ |
---|
[3620] | 446 | --attribute uuid,global,d,, \ |
---|
| 447 | --attribute LongName,global,d,, \ |
---|
| 448 | --attribute nco_openmp_thread_number,global,d,, \ |
---|
| 449 | --attribute Conventions,global,o,c,"CF-1.6" \ |
---|
| 450 | --attribute source,global,o,c,"IPSL Earth system model" \ |
---|
| 451 | --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center" \ |
---|
| 452 | --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr" \ |
---|
| 453 | --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu" \ |
---|
| 454 | --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \ |
---|
| 455 | --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \ |
---|
| 456 | --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc" \ |
---|
| 457 | --attribute associatedFiles,global,o,c,"grids_${OCE}x${ATM}.nc areas_${OCE}x${ATM}.nc masks_${OCE}x${ATM}.nc" \ |
---|
| 458 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
| 459 | --attribute description,global,o,c,"Fields needed by OASIS-MCT" \ |
---|
| 460 | --attribute title,global,o,c,"${InFile}.nc" \ |
---|
| 461 | --attribute Program,global,o,c,"Generated by ${PROGRAM}" \ |
---|
| 462 | --attribute timeStamp,global,o,c,"$(date)" \ |
---|
| 463 | --attribute uuid,global,o,c,"${UUID}" \ |
---|
| 464 | --attribute HOSTNAME,global,o,c,"$(hostname)" \ |
---|
| 465 | --attribute LOGNAME,global,o,c,"$(whoami)" \ |
---|
| 466 | --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ |
---|
| 467 | --attribute Python,global,o,c,"Python version ${PYTHON_VER}" \ |
---|
| 468 | --attribute OS,global,o,c,"$(uname -o)" \ |
---|
| 469 | --attribute release,global,o,c,"$(uname -r)" \ |
---|
| 470 | --attribute hardware,global,o,c,"$(uname -i)" \ |
---|
| 471 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
[3624] | 472 | --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] | 473 | --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ |
---|
[3665] | 474 | --attribute SVN_Author,global,o,c,"$Author$" \ |
---|
| 475 | --attribute SVN_Date,global,o,c,"$Date$" \ |
---|
| 476 | --attribute SVN_Revision,global,o,c,"$Revision$" \ |
---|
| 477 | --attribute SVN_Id,global,o,c,"$Id$" \ |
---|
[3620] | 478 | ${InFile} |
---|
| 479 | done |
---|
| 480 | |
---|
| 481 | |
---|
| 482 | ## |
---|
| 483 | ## Update and complete weights file to fit OASIS requested format |
---|
| 484 | ## =========================================================================== |
---|
| 485 | cat <<EOF > add_dim.nco |
---|
| 486 | defdim("num_wgts",1) ; |
---|
| 487 | weight[n_weight, num_wgts] = weight ; |
---|
| 488 | EOF |
---|
| 489 | |
---|
[3719] | 490 | for rmpFile in rmp_*.nc ; do |
---|
| 491 | mv ${rmpFile} xios_${rmpFile} |
---|
[3901] | 492 | ncap2 --fl_fmt=${FMT_OASIS} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} |
---|
[3620] | 493 | |
---|
[3719] | 494 | ncrename --history --dimension n_weight,num_links ${rmpFile} |
---|
| 495 | ncrename --history --variable src_idx,src_address ${rmpFile} |
---|
| 496 | ncrename --history --variable dst_idx,dst_address ${rmpFile} |
---|
| 497 | ncrename --history --variable weight,remap_matrix ${rmpFile} |
---|
| 498 | case ${rmpFile} in |
---|
| 499 | ( *_1storder_*.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order" ${rmpFile} ;; |
---|
| 500 | ( *_2ndorder_*.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order" ${rmpFile} ;; |
---|
[3620] | 501 | esac |
---|
[3719] | 502 | case ${rmpFile} in |
---|
| 503 | ( *_true.nc ) ncatted --history --attribute map_method,global,o,c,"Normalization: true" ${rmpFile} ;; |
---|
| 504 | ( *_false.nc ) ncatted --history --attribute map_method,global,o,c,"Normalization: false" ${rmpFile} ;; |
---|
| 505 | esac |
---|
| 506 | ncatted --history --attribute conventions,global,o,c,"SCRIP" ${rmpFile} |
---|
| 507 | ncatted --history --attribute normalization,global,o,c,"none" ${rmpFile} |
---|
[3620] | 508 | |
---|
[3719] | 509 | case ${rmpFile} in |
---|
[3620] | 510 | ( rmp_*${oce}_to_t${atm}_* ) |
---|
[3639] | 511 | ncatted --history \ |
---|
[3620] | 512 | --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \ |
---|
| 513 | --attribute source_grid,global,o,c,"${oce_domain_type}" \ |
---|
| 514 | --attribute dest_grid,global,o,c,"${atm_domain_type}" \ |
---|
[3719] | 515 | ${rmpFile} |
---|
[3620] | 516 | ;; |
---|
| 517 | ( rmp_*${atm}_to_*${oce}_* ) |
---|
[3639] | 518 | ncatted --history \ |
---|
[3620] | 519 | --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \ |
---|
| 520 | --attribute source_grid,global,o,c,"${atm_domain_type}" \ |
---|
| 521 | --attribute dest_grid,global,o,c,"${oce_domain_type}" \ |
---|
[3719] | 522 | ${rmpFile} |
---|
[3620] | 523 | ;; |
---|
| 524 | esac |
---|
| 525 | done |
---|
| 526 | |
---|
| 527 | ## |
---|
[3639] | 528 | ## Add missing variables in rmp files |
---|
| 529 | ## =========================================================================== |
---|
[3913] | 530 | for rmpFile in rmp_tlmd_to_[tuv]orc_*order_*.nc rmp_[tuv]orc_to_tlmd_*order_*.nc* ; do |
---|
[3901] | 531 | echo ${rmpFile} |
---|
[3719] | 532 | a_to_o=false ; o_to_a=false |
---|
| 533 | case ${rmpFile} in |
---|
| 534 | ( rmp_?${oce}_to_?${atm}_*.nc ) o_to_a=true ;; |
---|
| 535 | ( rmp_?${atm}_to_?${oce}_*.nc ) a_to_o=true ;; |
---|
| 536 | esac |
---|
| 537 | |
---|
[3901] | 538 | for Grid in t u v o c ; do # Identify grids |
---|
| 539 | [[ ${rmpFile} = rmp_${Grid}${oce}_to_?${atm}_*.nc ]] && ogrid=${Grid} |
---|
| 540 | [[ ${rmpFile} = rmp_?${oce}_to_${Grid}${atm}_*.nc ]] && agrid=${Grid} |
---|
| 541 | [[ ${rmpFile} = rmp_${Grid}${atm}_to_?${oce}_*.nc ]] && agrid=${Grid} |
---|
| 542 | [[ ${rmpFile} = rmp_?${atm}_to_${Grid}${oce}_*.nc ]] && ogrid=${Grid} |
---|
[3719] | 543 | done |
---|
| 544 | OGRID=${ogrid^} |
---|
| 545 | AGRID=${agrid^} |
---|
[3639] | 546 | |
---|
[3719] | 547 | cat <<EOF >add_varoce.nco |
---|
[3639] | 548 | defdim ("src_grid_size" , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; |
---|
| 549 | defdim ("src_grid_corners", 4) ; |
---|
| 550 | defdim ("src_grid_rank" , 2) ; |
---|
| 551 | // |
---|
| 552 | src_grid_dims[src_grid_rank] = { \$y_grid_${OGRID}.size, \$x_grid_${OGRID}.size } ; |
---|
| 553 | // |
---|
| 554 | src_grid_center_lat [src_grid_size] = 0.0d ; |
---|
| 555 | src_grid_center_lon [src_grid_size] = 0.0d ; |
---|
| 556 | src_grid_center_lat (:) = nav_lat_grid_${OGRID}(:,:) ; |
---|
| 557 | src_grid_center_lon (:) = nav_lon_grid_${OGRID}(:,:) ; |
---|
| 558 | // |
---|
| 559 | src_grid_corner_lat [src_grid_size, src_grid_corners] = 0.0d ; |
---|
| 560 | src_grid_corner_lon [src_grid_size, src_grid_corners] = 0.0d ; |
---|
| 561 | src_grid_corner_lat(:,:) = bounds_lat_grid_${OGRID}(:,:,:) ; |
---|
| 562 | src_grid_corner_lon(:,:) = bounds_lon_grid_${OGRID}(:,:,:) ; |
---|
| 563 | // |
---|
| 564 | src_grid_imask [src_grid_size] = 0 ; |
---|
| 565 | src_grid_area [src_grid_size] = 0.0d ; |
---|
| 566 | src_grid_frac [src_grid_size] = 1.0d ; |
---|
| 567 | src_grid_imask (:) = 1 - mask_${OGRID}(:,:) ; |
---|
| 568 | src_grid_imask.int() ; |
---|
| 569 | src_grid_area (:) = area_grid_${OGRID}(:,:) ; |
---|
| 570 | EOF |
---|
| 571 | |
---|
[3901] | 572 | [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 573 | sed --in-place "s/src_/dst_/g" add_varoce.nco |
---|
[3901] | 574 | [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 575 | |
---|
| 576 | if [[ ${atm} = ico ]] ; then |
---|
| 577 | cat <<EOF >add_varatm.nco |
---|
[3639] | 578 | defdim ("dst_grid_size" , \$cell.size) ; |
---|
| 579 | defdim ("dst_grid_corners", 6) ; |
---|
| 580 | defdim ("dst_grid_rank" , 2) ; |
---|
| 581 | // |
---|
| 582 | dst_grid_dims[dst_grid_rank] = { \$cell.size, 1 } ; |
---|
| 583 | // |
---|
| 584 | dst_grid_center_lat [dst_grid_size] = 0.0d ; |
---|
| 585 | dst_grid_center_lon [dst_grid_size] = 0.0d ; |
---|
| 586 | dst_grid_center_lat (:) = lat(:) ; |
---|
| 587 | dst_grid_center_lon (:) = lon(:) ; |
---|
| 588 | // |
---|
| 589 | dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 590 | dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 591 | dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; |
---|
| 592 | dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; |
---|
| 593 | // |
---|
| 594 | dst_grid_imask [dst_grid_size] = 0 ; |
---|
| 595 | dst_grid_area [dst_grid_size] = 0.0d ; |
---|
| 596 | dst_grid_frac [dst_grid_size] = 1.0d ; |
---|
| 597 | dst_grid_imask (:) = 1 - OceMask(0,:) ; |
---|
| 598 | dst_grid_imask.int() ; |
---|
| 599 | dst_grid_area (:) = aire(:) ; |
---|
[3966] | 600 | dst_grid_frac (:) = OceFrac(0,:) ; |
---|
[3639] | 601 | EOF |
---|
[3719] | 602 | if [[ ${o_to_a} = true ]] ; then |
---|
[3901] | 603 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 604 | 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 |
---|
| 605 | mv rmp_tmp.nc ${rmpFile} |
---|
| 606 | fi |
---|
[3718] | 607 | |
---|
[3719] | 608 | sed --in-place "s/dst_/src_/g" add_varatm.nco |
---|
| 609 | if [[ ${a_to_o} = true ]] ; then |
---|
[3901] | 610 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 611 | 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 |
---|
| 612 | mv rmp_tmp.nc ${rmpFile} |
---|
| 613 | fi |
---|
| 614 | fi |
---|
[3966] | 615 | |
---|
[3719] | 616 | if [[ ${atm} = lmd ]] ; then |
---|
| 617 | cat <<EOF >add_varatm.nco |
---|
[3639] | 618 | defdim ("dst_grid_size" , \$lon.size*\$lat.size) ; |
---|
| 619 | defdim ("dst_grid_corners", 4) ; |
---|
| 620 | defdim ("dst_grid_rank" , 2) ; |
---|
| 621 | // |
---|
| 622 | dst_grid_dims[dst_grid_rank] = { \$lat.size, \$lon.size } ; |
---|
| 623 | // |
---|
| 624 | dst_grid_center_lat [dst_grid_size] = 0.0d ; |
---|
| 625 | dst_grid_center_lon [dst_grid_size] = 0.0d ; |
---|
| 626 | lat0lon[lat,lon] = lat(:)+0*lon(:) ; |
---|
| 627 | lon0lat[lat,lon] = lon(:)+0*lat(:) ; |
---|
| 628 | dst_grid_center_lat (:) = lat0lon(:,:) ; |
---|
| 629 | dst_grid_center_lon (:) = lon0lat(:,:) ; |
---|
| 630 | // |
---|
| 631 | //dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; // Not available for LMDZ lon/lat grid |
---|
| 632 | //dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 633 | //dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; |
---|
| 634 | //dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; |
---|
| 635 | // |
---|
| 636 | dst_grid_imask [dst_grid_size] = 0 ; |
---|
| 637 | dst_grid_area [dst_grid_size] = 0.0d ; |
---|
| 638 | dst_grid_frac [dst_grid_size] = 1.0d ; |
---|
| 639 | dst_grid_imask (:) = 1 - OceMask(0,:,:) ; |
---|
| 640 | dst_grid_imask.int() ; |
---|
| 641 | dst_grid_area (:) = aire(:,:) ; |
---|
| 642 | dst_grid_frac (:) = OceFrac(0,:,:) ; |
---|
| 643 | EOF |
---|
[3719] | 644 | if [[ ${o_to_a} = 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_area,dst_grid_imask ${rmpFile} rmp_tmp.nc |
---|
| 647 | mv rmp_tmp.nc ${rmpFile} |
---|
| 648 | fi |
---|
| 649 | |
---|
| 650 | sed --in-place "s/dst/src/g" add_varatm.nco |
---|
| 651 | if [[ ${a_to_o} = true ]] ; then |
---|
[3901] | 652 | ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} |
---|
[3719] | 653 | 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 |
---|
| 654 | mv rmp_tmp.nc ${rmpFile} |
---|
| 655 | fi |
---|
| 656 | fi |
---|
[3639] | 657 | done |
---|
[3901] | 658 | ls -al ${OCE}_coordinates_mask.nc |
---|
[3639] | 659 | ## |
---|
[3620] | 660 | ## Save results |
---|
| 661 | ## =========================================================================== |
---|
| 662 | cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} |
---|
[3719] | 663 | for File in dia_*.nc rmp_*.nc |
---|
[3620] | 664 | do |
---|
[3719] | 665 | NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) |
---|
| 666 | cp ${File} ${SUBMIT_DIR}/${NewFile} |
---|
[3620] | 667 | done |
---|
| 668 | |
---|
| 669 | ## |
---|
| 670 | ## Creates and save auxiliary files for OASIS |
---|
| 671 | ## =========================================================================== |
---|
| 672 | bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} |
---|
| 673 | |
---|
| 674 | cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
| 675 | cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
| 676 | cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} |
---|
| 677 | |
---|
| 678 | |
---|
| 679 | ## =========================================================================== |
---|
| 680 | ## |
---|
| 681 | ## That's all folk's !!! |
---|
| 682 | ## |
---|
| 683 | ## =========================================================================== |
---|
| 684 | |
---|