Changeset 4298 for TOOLS/MOSAIX/CreateWeightsMask.bash
- Timestamp:
- 02/28/19 14:10:31 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/CreateWeightsMask.bash
r4259 r4298 37 37 # $HeadURL$ 38 38 # 39 # CplModel=eORCA1.2xLMD144142 ; qsub -r ${CplModel} -o Out_${CplModel} -e Out_${CplModel} CreateWeightsMask.bash 39 # export CplModel=eORCA1.2xLMD144142 ; qsub -r ${CplModel} -o Out_${CplModel} -e Out_${CplModel} CreateWeightsMask.bash 40 # export CplModel=ORCA2.3xLMD9695 41 # export CplModel=ORCA2.3xICO30 42 # export CplModel=ORCA2.3xICO40 43 # export CplModel=eORCA1.2xICO40 44 # export CplModel=eORCA1.2xLMD256256 45 # export CplModel=eORCA1.2xICO450 46 # export CplModel=eORCA025.1xLMD256256 40 47 # 41 48 … … 58 65 echo ${Titre}"Defines models"${Norm} 59 66 # ================================== 60 #OCE=ORCA2.361 OCE=eORCA1.262 #OCE=eORCA025 63 64 #ATM=ICO3067 OCE=ORCA2.3 68 #OCE=eORCA1.2 69 #OCE=eORCA025.1 70 71 ATM=ICO30 65 72 #ATM=ICO40 66 73 #ATM=ICO450 67 74 #ATM=LMD9695 68 ATM=LMD14414275 #ATM=LMD144142 69 76 #ATM=LMD256256 70 77 71 78 72 79 Comment="Preliminary attempt - Do not trust !" 73 Version="v 0"80 Version="v2" 74 81 75 82 CplModel=${OCE}x${ATM} 83 # If available, get model names from job name 76 84 if [[ X${SLURM_JOB_NAME} = X*ORC* || X${SLURM_JOB_NAME} = X*LMD* || X${SLURM_JOB_NAME} = X*ICO* ]] ; then 77 85 CplModel=${SLURM_JOB_NAME} ; OCE=${CplModel//x*} ; ATM=${CplModel##*x} … … 84 92 # Runoff parameter. atmCoastWidth and oceCoastWidth in grid points, searchRadius in km 85 93 atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=600.0 86 runOff_atmQuantity=Quantity runOff_oceQuantity=Surfacic87 88 [[ ${ATM} = ICO* ]] && atmCoastWidth=0 # Parameter relevant for LMD rectilinear grid only89 [[ ${ATM} = LMD* ]] && atmCoastWidth=290 [[ ${OCE} = ORCA2.3 ]] && oceCoastWidth=191 [[ ${OCE} = eORCA1.2 ]] && oceCoastWidth=392 [[ ${OCE} = eORCA025 ]] && oceCoastWidth=194 runOff_atmQuantity=Quantity ; runOff_oceQuantity=Surfacic 95 96 [[ ${ATM} = ICO* ]] && atmCoastWidth=0 # Parameter relevant for LMD rectilinear grid only 97 [[ ${ATM} = LMD* ]] && atmCoastWidth=2 98 [[ ${OCE} = ORCA2.3 ]] && oceCoastWidth=1 99 [[ ${OCE} = eORCA1.2 ]] && oceCoastWidth=3 100 [[ ${OCE} = eORCA025* ]] && oceCoastWidth=1 93 101 94 102 … … 105 113 # 106 114 # Keywords : 107 # Direction : o2a for ocean to atmosphere, a2o for atmosphere to ocean 108 # Order : 1st or 2nd 115 # Direction : o2a for ocean to atmosphere, a2o for atmosphere to ocean. 116 # Order : 1st or 2nd. 109 117 # Quantity : true if integrated quantity over a grid box, false for flux (quantity / m^2) 110 # or intensive value (temperature, salinity, sea-ice fraction, ...) 111 # Renormalize : used when source grid is masked, to use values on non masked points only 112 # oceGrid : t, u or v point for NEMO C grid 113 # atmGrid : up to know, only t grid used in the atmosphere 114 # useArea : if true area from the model metrics is used. If false, areas are computed by XIOS from grid corners 115 # maskSrc : true to use the source grid mask, false to used all grid points 116 # maskDst : true to use the destination grid mask, false to use all grid points 118 # or intensive value (temperature, salinity, sea-ice fraction, ...). 119 # Renormalize : used when source grid is masked, to use values on non masked points only. 120 # oceGrid : t, u or v point for NEMO C grid. 121 # atmGrid : up to know, only t grid used in the atmosphere. 122 # useArea : if true area from the model metrics is used. If false, areas are computed by XIOS from grid corners. 123 # maskSrc : true to use the source grid mask, false to used all grid points. 124 # maskDst : true to use the destination grid mask, false to use all grid points. 117 125 # 118 126 ## Classic cases for IPSLCM6 119 127 AtmOceFluxes=" Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes 120 AtmOceFluxes2nd="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes121 128 OceAtmTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=TempIceAlb" # Temperature, sea-ice fraction, albedo 122 129 OceAtmTemp2nd=" Direction=o2a,Order=2nd,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=TempIceAlb" # Temperature, sea-ice fraction, albedo … … 124 131 AtmOceStressV=" Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true,Name=WindStress" # Wind stress to NEMO V point 125 132 AtmOceQuantity=" Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=t,oceGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=Quantity" # e.g. runoff 126 # Other cases 133 # For new parameterization 134 AtmOceTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=OceTemp" # e.g. T and S correction from DWL parametrization 127 135 OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=OceAtmFluxes" # e.g. CO2 fluxes 136 # Test to do with 2nd order 137 AtmOceFluxes2nd="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes 128 138 OceAtmFluxes2nd="Direction=o2a,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=OceAtmFluxes" # e.g. CO2 fluxes 129 AtmOceTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=OceTemp" # e.g. T and S correction from DWL parametrization130 139 AtmOceTemps2nd=" Direction=o2a,Order=2nd,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=OceTemp" # e.g. T and S correction from DWL parametrization 131 140 … … 136 145 137 146 # More comprehensive list for IPSLCM6 with new features 138 #CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids )147 CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids ) 139 148 140 149 # With 2nd order 141 CommandList=( ${AtmOceFluxes} ${AtmOceFluxes2nd} ${OceAtmTemp} ${OceAtmTemp2nd} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${OceAtmFluxes2nd} ${AtmOceTemp} ${AtmOceTemp2nd} Runoff Calving Grids )150 #CommandList=( ${AtmOceFluxes} ${AtmOceFluxes2nd} ${OceAtmTemp} ${OceAtmTemp2nd} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${OceAtmFluxes2nd} ${AtmOceTemp} ${AtmOceTemp2nd} Runoff Calving Grids ) 142 151 143 152 # Debugs … … 280 289 281 290 case ${OCE} in # Periodicity type of ORCA grid 282 ( ORCA2 .3*) OcePerio=4 ;;291 ( ORCA2* ) OcePerio=4 ;; 283 292 ( ORCA1* | eORCA1* ) OcePerio=6 ;; 284 ( ORCA025* | eORCA025 293 ( ORCA025* | eORCA025* ) OcePerio=6 ;; 285 294 esac 286 295 # … … 371 380 where (OceFrac > 1.0 ) OceFrac=0.0 ; 372 381 where (OceFrac < 0.0 ) OceFrac=0.0 ; 382 OceMask = OceFrac ; 373 383 EOF 374 384 ncap2 --history --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_${FullName}.nc tmp_dia_t${oce}_to_t${atm}_${FullName}.nc ; mv tmp_dia_t${oce}_to_t${atm}_${FullName}.nc dia_t${oce}_to_t${atm}_${FullName}.nc 375 385 ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_${FullName}.nc 376 377 ## 378 echo ${Titre}"Creates ocean fractions on ATM grid"${Norm} 386 ncatted --history -a missing_value,OceMask,d,,"" -a _FillValue,OceMask,d,,"" dia_t${oce}_to_t${atm}_${FullName}.nc 387 388 ## 389 echo ${Titre}"Creates mask on ATM grid"${Norm} 379 390 ## =========================================================================== 380 391 cp dia_t${oce}_to_t${atm}_${FullName}.nc dia_t${oce}_to_t${atm}_${FullName}_mask.nc 381 ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_${FullName}_mask.nc 392 ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_${FullName}_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc 382 393 383 394 cat <<EOF > creation_masque.nco 384 where (OceFrac > 0.0 ) OceFrac=1 ; 385 where (OceFrac <= 0.0 ) OceFrac=0 ; 395 Oce2AtmMask = OceMask ; 396 where (OceMask > 0.0 ) Oce2AtmMask=1 ; 397 where (OceMask <= 0.0 ) Oce2AtmMask=0 ; 386 398 EOF 387 399 388 ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_${FullName}_mask.nc tmp_dia_t${oce}_to_t${atm}_${FullName}_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_${FullName}_mask.nc dia_t${oce}_to_t${atm}_${FullName}_mask.nc 389 ncrename --history --variable OceFrac,OceMask dia_t${oce}_to_t${atm}_${FullName}_mask.nc 390 391 ncks --overwrite --history --variable OceMask dia_t${oce}_to_t${atm}_${FullName}_mask.nc tmp_OceMask.nc 392 ncks --history --append tmp_OceMask.nc ${ATM}_grid_maskFrom_${OCE}.nc 393 rm dia_t${oce}_to_t${atm}_${FullName}_mask.nc 400 ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_${FullName}.nc tmp_dia_${ATM}_grid_maskFrom_${OCE}.nc 401 ncks --overwrite --history --variable OceMask,OceFrac,Oce2AtmMask tmp_dia_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 394 402 395 403 echo "Change dimension names, and some attributes accordingly" 404 ## =========================================================== 396 405 if [[ $(ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc | grep domain_dst | wc -l) -gt 0 ]] ; then 397 406 case ${atm} in … … 413 422 ncatted --history --attribute coordinates,OceFrac,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 414 423 ncatted --history --attribute coordinates,OceMask,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 424 ncatted --history --attribute coordinates,Oce2AtmMask,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 415 425 416 426 fi … … 418 428 ncks --history --alphabetize --append --variable aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 419 429 [[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 430 431 ## 432 433 #cp ${ATM}_grid.nc ${ATM}_gridFromOce.nc 434 420 435 421 436 ## … … 448 463 449 464 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 450 ln -fs ${ATM}_grid.nc atm_grid.nc 465 #ln -fs ${ATM}_grid.nc atm_grid.nc 466 ln -fs ${ATM}_grid_maskFrom_${OCE}.nc atm_grid.nc 451 467 452 468 case ${Direction} in … … 455 471 456 472 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v mask_${DSTGRID} 457 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v Oce Mask473 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v Oce2AtmMask 458 474 459 475 python3 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_${SRCGRID} 460 476 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v area_grid_${SRCGRID} 461 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]' -k name -v Oce Mask477 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]' -k name -v Oce2AtmMask 462 478 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]' -k name -v aire 463 479 ;; … … 465 481 cp iodef_atm_to_oce.xml iodef.xml 466 482 467 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v Oce Mask483 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v Oce2AtmMask 468 484 python3 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_${DSTGRID} 469 485 470 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v Oce Mask486 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v Oce2AtmMask 471 487 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v aire 472 488 python3 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_${DSTGRID} … … 504 520 ## =========================================================================== 505 521 506 UUID=$(uuid)507 522 NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 508 523 PYTHON_VER=$( python3 -c "import sys ; print (sys.version.split(' ')[0])" ) 509 524 for InFile in $(ls *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc 2> /dev/null) ; do 510 525 ncatted --history \ 511 --attribute uuid,global,d,, \512 526 --attribute LongName,global,d,, \ 513 527 --attribute nco_openmp_thread_number,global,d,, \ … … 526 540 --attribute Program,global,o,c,"Generated by ${PROGRAM}" \ 527 541 --attribute timeStamp,global,o,c,"$(date)" \ 528 --attribute uuid,global,o,c,"${UUID}" \529 542 --attribute HOSTNAME,global,o,c,"$(hostname)" \ 530 543 --attribute LOGNAME,global,o,c,"$(whoami)" \ … … 663 676 dst_grid_area [dst_grid_size] = 0.0d ; 664 677 dst_grid_frac [dst_grid_size] = 1.0d ; 665 dst_grid_imask (:) = 1 - Oce Mask(:) ;678 dst_grid_imask (:) = 1 - Oce2AtmMask(:) ; 666 679 dst_grid_imask.int() ; 667 680 dst_grid_area (:) = aire(:) ; … … 707 720 dst_grid_area [dst_grid_size] = 0.0d ; 708 721 dst_grid_frac [dst_grid_size] = 1.0d ; 709 dst_grid_imask (:) = 1 - Oce Mask(:,:) ;722 dst_grid_imask (:) = 1 - Oce2AtmMask(:,:) ; 710 723 dst_grid_imask.int() ; 711 724 dst_grid_area (:) = aire(:,:) ; … … 754 767 if [[ "X${okCalving}" = "Xyes" ]] ; then 755 768 case ${OCE} in 756 ( eORCA025 )769 ( eORCA025* ) 757 770 cp /ccc/work/cont003/gencmip6/deshayej/eORCA_R025_runoff_v1.2.nc . 758 771 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth.nc --fmt=${FMT_XIOS} \ … … 830 843 ## =========================================================================== 831 844 [[ -f README.txt ]] && rm README.txt 845 UUID=$(uuid) 832 846 833 847 cat <<EOF > README.txt … … 871 885 # ------------------------------------------------------------ 872 886 cat << EOF >> README.txt 873 UUID common to all files : ${UUID}874 887 875 888 Files produced, with checksum produced by Unix command shasum (version $(shasum --version)) with default algorithm … … 878 891 879 892 for file in $(ls dia_*.nc rmp_*.nc ${ATM}_grid_maskFrom_${OCE}*.nc areas_${OCE}x${ATM}*.nc grids_${OCE}x${ATM}*.nc masks_${OCE}x${ATM}*.nc 2> /dev/null ) ; do 893 ncatted --attribute uuid,global,o,c,"${UUID}" ${file} 880 894 echo "$(shasum ${file})" >> README.txt 881 895 done
Note: See TracChangeset
for help on using the changeset viewer.