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