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