Ignore:
Timestamp:
02/28/19 14:10:31 (5 years ago)
Author:
omamce
Message:

O.M. : corection on MOSAIX

  • add ORCA025.1 to known resolutions
  • Correct mask used to generate weigths
  • Suppress the second computation of uuid
  • OceMask? is now ocean fraction like it was in MOZAIC. OceFrac? still exists (and equals OceFrac?)
  • Add Oce2AtmMask as a 1/0 mask
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r4259 r4298  
    3737#  $HeadURL$ 
    3838# 
    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 
    4047# 
    4148 
     
    5865echo ${Titre}"Defines models"${Norm} 
    5966# ================================== 
    60 #OCE=ORCA2.3 
    61 OCE=eORCA1.2 
    62 #OCE=eORCA025 
    63  
    64 #ATM=ICO30 
     67OCE=ORCA2.3 
     68#OCE=eORCA1.2 
     69#OCE=eORCA025.1 
     70 
     71ATM=ICO30 
    6572#ATM=ICO40 
    6673#ATM=ICO450 
    6774#ATM=LMD9695 
    68 ATM=LMD144142 
     75#ATM=LMD144142 
    6976#ATM=LMD256256 
    7077 
    7178 
    7279Comment="Preliminary attempt - Do not trust !" 
    73 Version="v0" 
     80Version="v2" 
    7481 
    7582CplModel=${OCE}x${ATM} 
     83# If available, get model names from job name 
    7684if [[ X${SLURM_JOB_NAME} = X*ORC* ||  X${SLURM_JOB_NAME} = X*LMD*  ||  X${SLURM_JOB_NAME} = X*ICO* ]] ; then 
    7785    CplModel=${SLURM_JOB_NAME} ; OCE=${CplModel//x*} ; ATM=${CplModel##*x} 
     
    8492# Runoff parameter. atmCoastWidth and oceCoastWidth in grid points, searchRadius in km 
    8593atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=600.0 
    86 runOff_atmQuantity=Quantity runOff_oceQuantity=Surfacic 
    87  
    88 [[ ${ATM} = ICO*     ]] && atmCoastWidth=0 # Parameter relevant for LMD rectilinear grid only 
    89 [[ ${ATM} = LMD*     ]] && atmCoastWidth=2 
    90 [[ ${OCE} = ORCA2.3  ]] && oceCoastWidth=1 
    91 [[ ${OCE} = eORCA1.2 ]] && oceCoastWidth=3 
    92 [[ ${OCE} = eORCA025 ]] && oceCoastWidth=1 
     94runOff_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 
    93101 
    94102 
     
    105113# 
    106114# 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. 
    109117#   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. 
    117125# 
    118126## Classic cases for IPSLCM6 
    119127AtmOceFluxes="   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 fluxes 
    121128OceAtmTemp="     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 
    122129OceAtmTemp2nd="  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 
     
    124131AtmOceStressV="  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 
    125132AtmOceQuantity=" 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 
     134AtmOceTemp="     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 
    127135OceAtmFluxes="   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 
     137AtmOceFluxes2nd="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes 
    128138OceAtmFluxes2nd="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 parametrization 
    130139AtmOceTemps2nd=" 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 
    131140 
     
    136145 
    137146# More comprehensive list for IPSLCM6 with new features 
    138 #CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids ) 
     147CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids ) 
    139148 
    140149# 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 ) 
    142151 
    143152# Debugs 
     
    280289 
    281290case ${OCE} in # Periodicity type of ORCA grid 
    282     ( ORCA2.3*             ) OcePerio=4 ;; 
     291    ( ORCA2             ) OcePerio=4 ;; 
    283292    ( ORCA1*   | eORCA1*   ) OcePerio=6 ;; 
    284     ( ORCA025* | eORCA025  ) OcePerio=6 ;; 
     293    ( ORCA025* | eORCA025* ) OcePerio=6 ;; 
    285294esac 
    286295# 
     
    371380where (OceFrac >  1.0 )  OceFrac=0.0 ; 
    372381where (OceFrac <  0.0 )  OceFrac=0.0 ;  
     382OceMask = OceFrac ; 
    373383EOF 
    374384ncap2 --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 
    375385ncatted --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} 
     386ncatted --history -a missing_value,OceMask,d,,"" -a _FillValue,OceMask,d,,"" dia_t${oce}_to_t${atm}_${FullName}.nc 
     387  
     388## 
     389echo ${Titre}"Creates mask on ATM grid"${Norm} 
    379390## =========================================================================== 
    380391cp 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  ${ATM}_grid_maskFrom_${OCE}.nc 
     392ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_${FullName}_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    382393 
    383394cat <<EOF > creation_masque.nco 
    384 where (OceFrac >  0.0 )  OceFrac=1 ; 
    385 where (OceFrac <= 0.0 )  OceFrac=0 ; 
     395Oce2AtmMask = OceMask ;  
     396where (OceMask >  0.0 )  Oce2AtmMask=1 ; 
     397where (OceMask <= 0.0 )  Oce2AtmMask=0 ; 
    386398EOF 
    387399 
    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 
     400ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_${FullName}.nc tmp_dia_${ATM}_grid_maskFrom_${OCE}.nc  
     401ncks --overwrite --history --variable OceMask,OceFrac,Oce2AtmMask tmp_dia_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    394402 
    395403echo "Change dimension names, and some attributes accordingly" 
     404## =========================================================== 
    396405if [[ $(ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc | grep domain_dst | wc -l) -gt 0 ]] ; then 
    397406    case ${atm} in 
     
    413422    ncatted  --history --attribute coordinates,OceFrac,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 
    414423    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 
    415425  
    416426fi 
     
    418428ncks --history --alphabetize  --append    --variable aire    atm_grid.nc                                   ${ATM}_grid_maskFrom_${OCE}.nc 
    419429[[ ${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 
    420435 
    421436## 
     
    448463     
    449464    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 
    451467     
    452468    case ${Direction} in 
     
    455471         
    456472        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 OceMask 
     473        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 
    458474         
    459475        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} 
    460476        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 OceMask 
     477        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 
    462478        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 
    463479        ;; 
     
    465481        cp iodef_atm_to_oce.xml iodef.xml 
    466482         
    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 OceMask 
     483        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 
    468484        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} 
    469485         
    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 OceMask 
     486        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 
    471487        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 
    472488        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} 
     
    504520## =========================================================================== 
    505521 
    506 UUID=$(uuid) 
    507522NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 
    508523PYTHON_VER=$( python3 -c "import sys ; print (sys.version.split(' ')[0])" ) 
    509524for InFile in $(ls *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc 2> /dev/null) ; do 
    510525    ncatted --history \ 
    511             --attribute uuid,global,d,,                                           \ 
    512526            --attribute LongName,global,d,,                                       \ 
    513527            --attribute nco_openmp_thread_number,global,d,,                       \ 
     
    526540            --attribute Program,global,o,c,"Generated by ${PROGRAM}"              \ 
    527541            --attribute timeStamp,global,o,c,"$(date)"                            \ 
    528             --attribute uuid,global,o,c,"${UUID}"                                 \ 
    529542            --attribute HOSTNAME,global,o,c,"$(hostname)"                         \ 
    530543            --attribute LOGNAME,global,o,c,"$(whoami)"                            \ 
     
    663676dst_grid_area  [dst_grid_size] = 0.0d ; 
    664677dst_grid_frac  [dst_grid_size] = 1.0d ; 
    665 dst_grid_imask (:) = 1 - OceMask(:) ; 
     678dst_grid_imask (:) = 1 - Oce2AtmMask(:) ; 
    666679dst_grid_imask.int() ; 
    667680dst_grid_area  (:) = aire(:) ; 
     
    707720dst_grid_area  [dst_grid_size] = 0.0d ; 
    708721dst_grid_frac  [dst_grid_size] = 1.0d ; 
    709 dst_grid_imask (:) = 1 - OceMask(:,:) ; 
     722dst_grid_imask (:) = 1 - Oce2AtmMask(:,:) ; 
    710723dst_grid_imask.int() ; 
    711724dst_grid_area  (:) = aire(:,:) ; 
     
    754767if [[ "X${okCalving}" = "Xyes" ]] ; then 
    755768    case ${OCE} in 
    756         ( eORCA025 ) 
     769        ( eORCA025* ) 
    757770        cp /ccc/work/cont003/gencmip6/deshayej/eORCA_R025_runoff_v1.2.nc . 
    758771        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth.nc  --fmt=${FMT_XIOS} \ 
     
    830843## =========================================================================== 
    831844[[ -f README.txt ]] && rm README.txt 
     845UUID=$(uuid) 
    832846 
    833847cat <<EOF > README.txt 
     
    871885# ------------------------------------------------------------ 
    872886cat << EOF >> README.txt 
    873 UUID common to all files : ${UUID} 
    874887 
    875888Files produced, with checksum produced by Unix command shasum (version $(shasum --version)) with default algorithm 
     
    878891 
    879892for 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} 
    880894    echo "$(shasum ${file})" >> README.txt 
    881895done 
Note: See TracChangeset for help on using the changeset viewer.