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