Changeset 3901 for TOOLS/MOSAIX/CreateWeightsMask.bash
- Timestamp:
- 06/07/18 15:59:11 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/CreateWeightsMask.bash
r3734 r3901 36 36 # $Id$ 37 37 # $HeadURL$ 38 export Bold=$(tput bold) 39 export Unde=$(tput smul) ; export OffUnde=$(tput rmul) 40 export Stou=$(tput smso) ; export OffStou=$(tput rmso) 41 export Reve=$(tput rev ) 42 couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) 43 for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done 44 export Norm=$(tput sgr0 ) 38 45 39 46 ## … … 58 65 # =========================== 59 66 ListOCEGRID="T U V" 60 ListOrder="1st" # " 2nd67 ListOrder="1st" # 2nd" 61 68 ListNormalize="false true" 62 69 … … 71 78 # Defines computer 72 79 # ================ 73 if [[ $(hostname) = curie* ]]; then arch=curie ; center=tgcc ; fi74 if [[ $(hostname) = irene* ]]; then arch=irene ; center=tgcc ; fi80 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 81 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 75 82 if [[ $(hostname) = lsce3005* ]] ; then arch=spip ; center=spip ; fi 76 83 … … 95 102 MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 96 103 ;; 97 ( * ) 98 exit -1 99 ;; 104 ( * ) exit -1 ;; 100 105 esac 101 106 … … 127 132 # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits 128 133 # --------------------------------------------------------------------------- 129 FL_FMT=64bit 134 FMT_OASIS=64bit 135 FMT_XIOS=netcdf4 130 136 131 137 … … 133 139 cp ${SUBMIT_DIR}/*.py . 134 140 135 ## 136 ## NEMO T point towards ATM - 1st order 137 ## =========================================================================== 141 138 142 cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . 139 143 cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . 140 144 141 ln -s ${OCE}_coordinates_mask.nc oce_grid.nc 142 ln -s ${ATM}_grid.nc atm_grid.nc 143 145 ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 146 ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc ${ATM}_grid_${FMT_OASIS}.nc 147 # 148 # Creates OCEAN C grid : redundant point removed to compute proper integrals # A passer dans CreateWeights 149 # ---------------------------------------------------------------------------- 150 cat <<EOF >add_c_grid.nco 151 nav_lon_grid_C = nav_lon_grid_T ; 152 nav_lat_grid_C = nav_lat_grid_T ; 153 bounds_lon_grid_C = bounds_lon_grid_T ; 154 bounds_lat_grid_C = bounds_lat_grid_T ; 155 area_grid_C = area_grid_T ; 156 mask_C = maskutil_T ; 157 EOF 158 159 ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc 160 ncks --overwrite --variable nav_lon_grid_C,nav_lat_grid_C,bounds_lon_grid_C,bounds_lat_grid_C,area_grid_C,mask_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 161 rm tmp_${OCE}_coordinates_mask_${FMT_OASIS}.nc 162 ncrename --dimension x_grid_T,x_grid_C C_${OCE}_coordinates_mask.nc 163 ncrename --dimension y_grid_T,y_grid_C C_${OCE}_coordinates_mask.nc 164 ncrename --dimension nvertex_grid_T,nvertex_grid_C C_${OCE}_coordinates_mask.nc 165 ncks --append C_${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask.nc 166 rm C_${OCE}_coordinates_mask.nc 167 168 ncks --overwrite --fl_fmt=${FMT_OASIS} --history {OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 169 170 ls -al 171 172 ## 173 ## NEMO T point towards ATM - 1st order 174 ## =========================================================================== 144 175 echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm} 145 176 cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml iodef.xml … … 162 193 163 194 cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml 195 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 196 ln -fs ${ATM}_grid.nc atm_grid.nc 164 197 165 198 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no … … 197 230 rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc 198 231 199 ## 200 ## Creates mask of coastal OCE points 201 ## =========================================================================== 202 python ComputeNemoCoast.py -n ${OcePerio} -i oce_grid.nc 203 204 ## 205 ## Creates mask of coastal ATM points 206 ## =========================================================================== 207 cat <<EOF > coastal.nco 208 AtmCoastal = OceFrac * 0.0 ; 209 where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; 210 EOF 211 ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 212 ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 213 rm ${ATM}_coastal_maskFrom_${OCE}.nc 232 214 233 215 234 ## … … 247 266 cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order_${normalize}.xml 248 267 268 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 269 ln -fs ${ATM}_grid.nc atm_grid.nc 249 270 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 250 271 fi … … 288 309 cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.xml 289 310 311 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 312 ln -fs ${ATM}_grid.nc atm_grid.nc 290 313 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 291 314 … … 294 317 done 295 318 319 ## 320 ## Creates mask of coastal OCE points 321 ## =========================================================================== 322 python ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 323 ## 324 ## Creates mask of coastal ATM points 325 ## =========================================================================== 326 cat <<EOF > coastal.nco 327 AtmCoastal = OceFrac * 0.0 ; 328 where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; 329 EOF 330 ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 331 ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 332 rm ${ATM}_coastal_maskFrom_${OCE}.nc 333 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 296 334 ## 297 335 ## ATM towards NEMO points - runoff … … 312 350 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v AtmCoastal 313 351 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v OceCoastal 314 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_${normalize}315 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_${normalize}.nc352 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_o${atm}_to_c${oce}_1storder_${normalize} 353 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_o${atm}_to_c${oce}_1storder_${normalize}.nc 316 354 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${normalize} 317 355 318 cp iodef.xml iodef_ c${atm}_to_t${oce}_1storder_${normalize}.xml356 cp iodef.xml iodef_o${atm}_to_c${oce}_1storder_${normalize}.xml 319 357 358 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 359 ln -fs ${ATM}_grid.nc atm_grid.nc 320 360 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 321 done 322 ## 323 ## Change all NetCDF files to NetCDF 3 format (needed for OASIS) 361 362 # Now we should divide weight par source (atm) grid area : run-off is a quantity/s integrated on the grid mox, not a flux 363 done 364 ## 365 ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) 324 366 ## =========================================================================== 325 367 for InFile in *.nc ; do 326 mv ${InFile} tmp_${InFile} 327 ncks --alphabetize --fl_fmt=${FL_FMT} --history tmp_${InFile} ${InFile} 368 OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc 369 if [[ ! -f ${OuFile} ]] ; then 370 ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile} 371 fi 328 372 done 329 373 … … 334 378 #ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 335 379 ncap2 --overwrite --history --script 'defdim("time_counter",1) ;' ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 380 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 336 381 337 382 if [[ ${atm} = ico ]] ; then … … 349 394 ${ATM}_grid_maskFrom_${OCE}.nc 350 395 fi 396 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 397 351 398 if [[ ${atm} = lmd ]] ; then 352 399 cat <<EOF > add_time.nco … … 364 411 fi 365 412 ncks --alphabetize --overwrite --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 366 413 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 367 414 368 415 ## … … 373 420 NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 374 421 PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) 375 for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do422 for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc; do 376 423 ncatted --history \ 377 424 --attribute uuid,global,d,, \ … … 421 468 for rmpFile in rmp_*.nc ; do 422 469 mv ${rmpFile} xios_${rmpFile} 423 ncap2 --fl_fmt=${F L_FMT} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile}470 ncap2 --fl_fmt=${FMT_OASIS} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} 424 471 425 472 ncrename --history --dimension n_weight,num_links ${rmpFile} … … 460 507 ## =========================================================================== 461 508 for rmpFile in rmp_* ; do 509 echo ${rmpFile} 462 510 a_to_o=false ; o_to_a=false 463 511 case ${rmpFile} in … … 466 514 esac 467 515 468 for Grid in t u v c ; do # Identify grids 469 case ${rmpFile} in 470 ( rmp_${Grid}${oce}_to_?${atm}_*.nc ) ogrid=${Grid} ;; 471 ( rmp_?${oce}_to_${Grid}${atm}_*.nc ) agrid=${Grid} ;; 472 ( rmp_${Grid}${atm}_to_?${oce}_*.nc ) agrid=${Grid} ;; 473 ( rmp_?${atm}_to_${Grid}${oce}_*.nc ) ogrid=${Grid} ;; 474 esac 516 for Grid in t u v o c ; do # Identify grids 517 [[ ${rmpFile} = rmp_${Grid}${oce}_to_?${atm}_*.nc ]] && ogrid=${Grid} 518 [[ ${rmpFile} = rmp_?${oce}_to_${Grid}${atm}_*.nc ]] && agrid=${Grid} 519 [[ ${rmpFile} = rmp_${Grid}${atm}_to_?${oce}_*.nc ]] && agrid=${Grid} 520 [[ ${rmpFile} = rmp_?${atm}_to_${Grid}${oce}_*.nc ]] && ogrid=${Grid} 475 521 done 476 522 OGRID=${ogrid^} … … 502 548 EOF 503 549 504 [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile}550 [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} 505 551 sed --in-place "s/src_/dst_/g" add_varoce.nco 506 [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile}552 [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} 507 553 508 554 if [[ ${atm} = ico ]] ; then … … 532 578 EOF 533 579 if [[ ${o_to_a} = true ]] ; then 534 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}580 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 535 581 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 536 582 mv rmp_tmp.nc ${rmpFile} … … 539 585 sed --in-place "s/dst_/src_/g" add_varatm.nco 540 586 if [[ ${a_to_o} = true ]] ; then 541 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}587 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 542 588 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 543 589 mv rmp_tmp.nc ${rmpFile} … … 573 619 EOF 574 620 if [[ ${o_to_a} = true ]] ; then 575 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}621 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 576 622 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 577 623 mv rmp_tmp.nc ${rmpFile} … … 580 626 sed --in-place "s/dst/src/g" add_varatm.nco 581 627 if [[ ${a_to_o} = true ]] ; then 582 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}628 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 583 629 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 584 630 mv rmp_tmp.nc ${rmpFile} … … 586 632 fi 587 633 done 588 634 ls -al ${OCE}_coordinates_mask.nc 589 635 ## 590 636 ## Save results
Note: See TracChangeset
for help on using the changeset viewer.