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