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