Changeset 4186


Ignore:
Timestamp:
12/12/18 11:26:20 (22 months ago)
Author:
omamce
Message:

O.M. :

Runoff weight for both ICO and LMDZ
Correct corc grid

Location:
TOOLS/MOSAIX
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CalvingWeights.py

    r4172 r4186  
    4343parser.add_argument ('--repartition_var' , help='Variable name for iceshelf'      , type=str, default=None) 
    4444parser.add_argument ('--output'  , help='output rmp file name', default='rmp_tlmd_to_torc_calving_64bit.nc' ) 
    45 parser.add_argument ('--fmt'     , help='NetCDF file format, using nco syntax', default='64bits', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] ) 
     45parser.add_argument ('--fmt'     , help='NetCDF file format, using nco syntax', default='64bit', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] ) 
    4646 
    4747# Parse command line 
     
    308308f_calving.Program         = "Generated by " + sys.argv[0] + " with flags " + str(sys.argv[1:]) 
    309309f_calving.repartitionType = myargs.type 
    310 if myargs.type in ['iceberg', 'iceshelf' ] : 
     310if myargs.type in [ 'iceberg', 'iceshelf' ] : 
    311311    f_calving.repartitionFile = myargs.repartition_file 
    312312    f_calving.repartitionVar  = repartitionVar 
     
    333333f_calving.SVN_HeadURL     = "$HeadURL$" 
    334334 
    335 d_nb_zone          = f_calving.createDimension ('nb_zone'         ,   nb_zone ) 
    336 d_num_links        = f_calving.createDimension ('num_links'       , num_links ) 
    337 d_num_wgts         = f_calving.createDimension ('num_wgts'        ,         1 ) 
     335d_nb_zone   = f_calving.createDimension ('nb_zone'         ,   nb_zone ) 
     336d_num_links = f_calving.createDimension ('num_links'       , num_links ) 
     337d_num_wgts  = f_calving.createDimension ('num_wgts'        ,         1 ) 
    338338 
    339339d_src_grid_size    = f_calving.createDimension ('src_grid_size'   , src_grid_size ) 
    340340d_src_grid_corners = f_calving.createDimension ('src_grid_corners', src_clo.shape[0]  ) 
    341 D_src_grid_rank    = f_calving.createDimension ('src_grid_rank'   ,        2  ) 
     341d_src_grid_rank    = f_calving.createDimension ('src_grid_rank'   ,        2  ) 
    342342 
    343343d_dst_grid_size    = f_calving.createDimension ('dst_grid_size'   , dst_grid_size ) 
     
    398398v_dst_repartition = f_calving.createVariable ( 'dst_repartition' , 'f8', ('nb_zone', 'dst_grid_size',)  ) 
    399399 
     400v_dst_southLimit = f_calving.createVariable ('dst_southLimit', 'f4', ('nb_zone',) ) 
     401v_dst_northLimit = f_calving.createVariable ('dst_northLimit', 'f4', ('nb_zone',) ) 
     402v_dst_southLimit[:] = np.min(limit_lat, axis=(1,) )  
     403v_dst_northLimit[:] = np.max(limit_lat, axis=(1,) )  
     404 
    400405v_dst_grid_dims      [:] = ( dst_jpi, dst_jpi )  
    401406v_dst_grid_center_lon[:] = dst_lon[:].ravel() 
  • TOOLS/MOSAIX/CreateOasisGrids.bash

    r4172 r4186  
    5454PROGRAM=$(basename ${0}) 
    5555 
    56 case ${arch} in 
    57     ( curie | irene ) 
    58     set +vx 
    59     module unload cdo nco ferret 
    60     module unload netcdf hdf5 
    61     module load python # /2.7.12 
    62     module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS 
    63     module load nco 
    64     R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
    65     TMPDIR=${SCRATCHDIR}/TMP 
    66     SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
    67     ;; 
    68     ( spip ) 
    69     R_IN=${HOME}/Scratch/IGCM 
    70     TMPDIR=${HOME}/Scratch/TMP 
    71     SUBMIT_DIR=$(pwd) 
    72     MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 
    73     ;;  
    74     ( * ) exit -1 ;; 
    75 esac 
     56# case ${arch} in 
     57#     ( curie | irene ) 
     58#     set +vx 
     59#     module unload cdo nco ferret 
     60#     module unload netcdf hdf5 
     61#     module load python # /2.7.12 
     62#     module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS 
     63#     module load nco 
     64#     R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
     65#     TMPDIR=${SCRATCHDIR}/TMP 
     66#     SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
     67#     ;; 
     68#     ( spip ) 
     69#     R_IN=${HOME}/Scratch/IGCM 
     70#     TMPDIR=${HOME}/Scratch/TMP 
     71#     SUBMIT_DIR=$(pwd) 
     72#     MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 
     73#     ;;  
     74#     ( * ) exit -1 ;; 
     75# esac 
    7676 
    7777## 
     
    185185 
    186186ncks --fl_fmt=${FL_FMT3} --history -C --variable OceMask         ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc OceMask_tmp.nc 
     187ncwa --history --overwrite --average time_counter OceMask_tmp.nc OceMask_tmp2.nc # Suppress time dimension 
    187188ncatted --history \ 
     189        --attribute cell_methods,OceMask,d,c,       \ 
    188190        --attribute coordinates,OceMask,d,,         \ 
    189191        --attribute online_operation,OceMask,d,,    \ 
     
    191193        --attribute missing_value,OceMask,d,,       \ 
    192194        OceMask_tmp.nc 
    193 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "OceMask=int(1-OceMask)"            OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 
     195ncap2 --fl_fmt=${FL_FMT3} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp2.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 
    194196rm OceMask_tmp.nc 
    195197ncatted --history \ 
     
    216218 
    217219# 
    218 echo ${Titre}"DYNAMICO grids : 1) Set correct order of dimensions, 2) Add a dimension"${Norm} 
    219 # ---------------------------------------------------------------------------- 
    220220if [[ ${atm} = dynamico* || ${atm} = ico* ]] ; then 
     221    echo ${Titre}"DYNAMICO grids : 1) Set correct order of dimensions, 2) Add a dimension"${Norm} 
     222    # ------------------------------------------------------------------------------------------- 
    221223    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    222224    ncpdq --permute nvertex,ycell,xcell  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    223      
     225 
    224226    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    225227    cat <<EOF >add_dim.nco 
     
    232234// 
    233235EOF 
    234      
     236    
    235237    ncap2 --fl_fmt=${FL_FMT3} --history --append --script-file add_dim.nco  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    236238     
    237239    mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
    238     ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)'  masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
     240    ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) '   masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
     241    mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
     242    ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'OceMask[ycell,xcell]=OceMask'  masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
    239243 
    240244    mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
    241     ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; '                    areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     245    ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
    242246 
    243247    rm -f grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 
    244248fi 
    245  
     249  
    246250# 
    247251echo ${Titre}"Some changes specific to LMDZ lon/lat grid"${Norm} 
     
    292296 
    293297# 
     298  
    294299echo ${Titre}"Generates grid o${atm}, 'o' meaning 'one'"${Norm} 
    295300# same as t${atm} grid, with surfaces set to 1 
     
    308313rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 
    309314 
     315 
     316echo ${Titre}"Generates grid o${oce}, 'o' meaning 'one'"${Norm} 
     317# same as t${oce} grid, with surfaces set to 1 
     318# and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 
     319# This grid is used when field are quantities instead of fluxes (i.e river flow) 
     320# -------------------------------------------------------------------------------------------------------- 
     321mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
     322ncap2 --fl_fmt=${FL_FMT3} --history --script "nav_lon_grid_O=nav_lon_grid_T; nav_lat_grid_O=nav_lat_grid_T; bounds_lon_grid_O=bounds_lon_grid_T; bounds_lat_grid_O=bounds_o${oce}_lat=bounds_lat_grid_T; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     323 
     324mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
     325ncap2 --fl_fmt=${FL_FMT3} --history --script "area_grid_O=area_grid_T*0.0d+1.0d;"   areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     326 
     327ncks -C --history --overwrite -v maskutil_T ${OCE}_coordinates_mask_${FL_FMT3}.nc maskutil_T_${FL_FMT3}.nc 
     328ncap2 --fl_fmt=${FL_FMT3} --history --append --script "mask_O=maskutil_T; " maskutil_T_${FL_FMT3}.nc masks_${CplModel}.nc 
     329 
     330rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc  
     331 
     332 
     333echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals"${Norm} 
     334# -------------------------------------------------------------------------------------------------------- 
     335 
     336mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
     337ncap2 --fl_fmt=${FL_FMT3} --history --script "nav_lon_grid_C=nav_lon_grid_T; nav_lat_grid_C=nav_lat_grid_T; bounds_lon_grid_C=bounds_lon_grid_T; bounds_lat_grid_C=bounds_o${oce}_lat=bounds_lat_grid_T; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     338 
     339mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
     340ncap2 --fl_fmt=${FL_FMT3} --history --script "area_grid_C=area_grid_T ; "   areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     341 
     342#mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
     343ncap2 --fl_fmt=${FL_FMT3} --history --append --script "mask_C=maskutil_T; " maskutil_T_${FL_FMT3}.nc masks_${CplModel}.nc 
     344 
     345rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc maskutil_T_${FL_FMT3}.nc 
     346 
    310347# 
    311348echo ${Titre}"Final renaming"${Norm} 
    312349# ---------------------------------------------------------------------------- 
    313 for OCEGRID in T U V 
     350for OCEGRID in T U V O C 
    314351do 
    315352    ocegrid=${OCEGRID~} # To lowercase 
     
    342379ncrename --history --variable bounds_o${atm}_lat,o${atm}.cla  grids_${CplModel}.nc 
    343380 
    344 for atmgrid in t o ; do 
     381for ATMGRID in T O ; do 
     382    atmgrid=${ATMGRID~} # To lowercase 
    345383    ncatted --history \ 
    346384            --attribute bounds,${atmgrid}${atm}.lon,c,c,"${atmgrid}${atm}.clo"   \ 
     
    414452 
    415453## =========================================================================== 
    416 echo ${Titre}"exit from CreateOasisGrids "${Norm} 
     454echo ${Titre}"Exit from CreateOasisGrids "${Norm} 
    417455 
    418456## =========================================================================== 
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r4172 r4186  
    55#MSUB -eo 
    66#MSUB -n 16                 # Number of processors 
    7 #MSUB -T 1800               # Time limit (seconds) 
     7#MSUB -T 7200               # Time limit (seconds) 
    88#MSUB -q skylake 
    9 #MSUB -Q test 
    109#MSUB -p gen2212 
    1110#MSUB -m work 
     
    4544couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) 
    4645for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done 
    47 export Norm=$(tput sgr0 ) 
     46export Norm=$(tput sgr0) 
    4847export Titre=${Bold}${Blue} 
    4948 
     
    5655echo ${Titre}"Defines models"${Norm} 
    5756# ============== 
    58 OCE=ORCA2.3 
    59 #OCE=eORCA1.2 
     57#OCE=ORCA2.3 
     58OCE=eORCA1.2 
    6059#OCE=eORCA025 
    6160 
    6261#ATM=ICO30 
    63 #ATM=ICO40 
     62ATM=ICO40 
    6463#ATM=ICO450 
    65 ATM=LMD9695 
     64#ATM=LMD9695 
    6665#ATM=LMD144142 
    6766#ATM=LMD256256 
    6867 
    69 # Runoff parameter (LMDZ grids only) 
    70 atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=1000.0 
    71  
    72 if [[ ${OCE} = ORCA2.3  && ${ATM} = LMD9695   ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi 
    73 if [[ ${OCE} = ORCA2.3  && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi 
    74 if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD9695   ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi 
    75 if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi 
     68echo ${Titre}"ATM model : ${ATM}"${Norm} 
     69echo ${Titre}"OCE model : ${OCE}"${Norm} 
     70 
     71# Runoff parameter. atmCoastWidth and oceCoastWidth in grid points, searchRadius in km 
     72atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=600.0 
     73runOff_atmQuantity=Quantity runOff_oceQuantity=Surfacic 
     74 
     75[[ ${ATM} = ICO*     ]] && atmCoastWidth=0 # Parameter relevant for LMD rectilinear grid only 
     76[[ ${ATM} = LMD*     ]] && atmCoastWidth=2 
     77[[ ${OCE} = ORCA2.3  ]] && oceCoastWidth=1 
     78[[ ${OCE} = eORCA1.2 ]] && oceCoastWidth=3 
     79[[ ${OCE} = eORCA025 ]] && oceCoastWidth=1 
     80 
    7681 
    7782# Default values, used to create ocean fraction on atmospheric grid  
    78 DefaultValues=( Direction=o2a,oceGrid=t,atmGrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false ) 
     83DefaultValues=( Direction=o2a,oceGrid=t,atmGrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false,Name=OceFrac ) 
    7984 
    8085## List of weights to build 
     
    98103#   maskDst     : true to use the destination grid mask, false to use all grid points 
    99104# 
    100 # Classic cases  
    101 AtmOceFluxes=" Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # Heat and water fluxes 
    102 OceAtmTemp="   Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # Temperature, sea-ice fraction, albedo 
    103 AtmOceStressU="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO U point 
    104 AtmOceStressV="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO V point 
     105# Classic cases for IPSLCM6 
     106AtmOceFluxes="  Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes 
     107OceAtmTemp="    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 
     108AtmOceStressU=" Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true,Name=WindStress" # Wind stress to NEMO U point 
     109AtmOceStressV=" 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 
     110AtmOceQuantity="Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=t,oceGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=Quantity"   # e.g. runoff 
    105111# Other cases 
    106 OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # e.g. CO2 fluxes 
    107 AtmOceTemp="   Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # e.g. T and S correction from DWL parametrization 
    108 AtmOceCoastal="Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true"  # Runoff atm to oce, limited to oce coastal points 
    109  
    110 CommandList=( ${AtmOceFluxes} Runoff Calving ) 
    111  
    112 #CommandList=( Runoff Calving ) #\ 
    113 #    Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true  \ 
    114 #    Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true  \ 
    115 #    Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true  \ 
    116 #    Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true  \ 
    117 #    Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true   \ 
    118 #    Calving \ 
    119 #    Runoff  \ 
    120 #    ) 
    121  
     112OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=OceAtmFluxes" # e.g. CO2 fluxes 
     113AtmOceTemp="   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 
     114 
     115# Standard list for IPSLCM6 
     116#CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} Runoff Calving Grids ) 
     117 
     118# More comprehesive list for IPSLCM6 with new features 
     119CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids ) 
     120 
     121# Debugs 
     122#CommandList=( Runoff ) 
     123#CommandList=( ${AtmOceFluxes} ${OceAtmTemp} Runoff Calving Grids ) 
     124#CommandList=( Calving ) 
     125#CommandList=( Grids ) 
    122126 
    123127 
    124128Comment="Preliminary attempt - Do not trust !" 
    125 #Version 
     129Version="_v0" 
    126130 
    127131## =========================================================================== 
     
    130134## 
    131135## =========================================================================== 
     136Tag="_MOSAIX" 
    132137SUBMIT_DIR=$(pwd) 
    133138 
     
    152157function setValues { 
    153158    # 
     159    read_Command "Direction=None,Order=None,Quantity=None,Renormalize=None,atmGrid=None,oceGrid=None,useArea=None,maskSrc=None,maskDst=None" 
     160    read_Command ${1} 
     161    # 
    154162    oceGrid=${oceGrid,,} ; atmGrid=${atmGrid,,} 
    155163    OCEGRID=${oceGrid^^} ; ATMGRID=${atmGrid^^} 
     
    171179        ( false ) AreaName=NoArea ;; 
    172180    esac 
    173      
    174     Suffix=${Order}Order_${NormName}_${QuantName}_${AreaName} 
     181 
     182    if [[ "${Name}" != "None" ]] ; then 
     183        Suffix=${Name} 
     184    else 
     185        Suffix=${Order}Order_${NormName}_${QuantName}_${AreaName} 
     186    fi 
    175187 
    176188    case ${Direction} in 
     
    184196        ;; 
    185197    esac 
    186     echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName}  "${Norm}              
     198    echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName}  "${Norm} 
     199    echo ${Green}"Suffix : ${Suffix}"${Norm} 
    187200} 
    188      
     201 
    189202# 
    190203# Defines computer 
     
    203216    PROGRAM=${BRIDGE_MSUB_REQNAME} 
    204217    MpiRun="time ccc_mprun" 
    205     PyRun="ccc_mprun -n 1" 
     218    PyRun="time ccc_mprun -n 1" 
    206219    source ${SUBMIT_DIR}/arch.env 
    207220    module load nco 
     
    263276ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc             ${ATM}_grid_${FMT_OASIS}.nc 
    264277# 
    265 echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm} 
    266 # -------------------------------------------------------------------------------------------------------- 
    267 cat <<EOF >add_c_grid.nco 
    268 defdim("x_grid_C", \$x_grid_T.size) ; 
    269 defdim("y_grid_C", \$y_grid_T.size) ; 
    270 defdim("nvertex_grid_C",  4)         ; 
    271 nav_lon_grid_C[y_grid_C,x_grid_C]    = nav_lon_grid_T(:,:)    ; 
    272 nav_lat_grid_C[y_grid_C,x_grid_C]    = nav_lat_grid_T(:,:)    ; 
    273 bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ; 
    274 bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ; 
    275 mask_C[y_grid_C,x_grid_C]            = maskutil_T(:,:)        ;  
    276 area_grid_C[y_grid_C,x_grid_C]       = area_grid_T(:,:)       ; 
    277 EOF 
    278  
    279 ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc 
    280 ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc 
    281 ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc 
    282 ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C       tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
    283 ncks --history --append    --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
    284 ncks --history --append    --variable area_grid_C             tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc  
    285  
    286 ncks --history --append C_${OCE}_coordinates_mask.nc            ${OCE}_coordinates_mask.nc 
    287 rm C_${OCE}_coordinates_mask.nc 
    288  
    289 ncks --history --overwrite --fl_fmt=${FMT_OASIS} ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 
    290  
    291 ls -al 
     278# echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm} 
     279# # -------------------------------------------------------------------------------------------------------- 
     280# cat <<EOF >add_c_grid.nco 
     281# defdim("x_grid_C", \$x_grid_T.size) ; 
     282# defdim("y_grid_C", \$y_grid_T.size) ; 
     283# defdim("nvertex_grid_C",  4)         ; 
     284# nav_lon_grid_C[y_grid_C,x_grid_C]    = nav_lon_grid_T(:,:)    ; 
     285# nav_lat_grid_C[y_grid_C,x_grid_C]    = nav_lat_grid_T(:,:)    ; 
     286# bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ; 
     287# bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ; 
     288# mask_C[y_grid_C,x_grid_C]            = maskutil_T(:,:)        ;  
     289# area_grid_C[y_grid_C,x_grid_C]       = area_grid_T(:,:)       ; 
     290# EOF 
     291 
     292# ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc 
     293# ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc 
     294# ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc 
     295# ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C       tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
     296# ncks --history --append    --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
     297# ncks --history --append    --variable area_grid_C             tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc  
     298 
     299# ncks --history --append C_${OCE}_coordinates_mask.nc            ${OCE}_coordinates_mask.nc 
     300# rm C_${OCE}_coordinates_mask.nc 
     301 
     302# ncks --history --overwrite --fl_fmt=${FMT_OASIS} ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 
     303 
     304# ls -al 
    292305 
    293306## 
     
    295308## =========================================================================== 
    296309echo "Command parameters : ${Command}" 
    297 read_Command ${DefaultValues} 
    298 read_Command ${Command} 
    299 setValues 
     310setValues ${DefaultValues} 
    300311 
    301312cp iodef_oce_to_atm.xml   iodef.xml 
     
    416427do 
    417428    echo "Command parameters : ${Command}" 
    418     read_Command ${DefaultValues} 
    419     read_Command ${Command} 
    420  
     429    setValues ${Command} 
    421430    if [[ ${Command} = "Runoff"  ]] ; then okRunoff=yes  ; continue ; fi 
    422431    if [[ ${Command} = "Calving" ]] ; then okCalving=yes ; continue ; fi 
    423      
    424     setValues 
     432    if [[ ${Command} = "Grids"   ]] ; then okGrids=yes   ; continue ; fi 
    425433     
    426434    ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
     
    620628done 
    621629 
     630ls 
    622631## 
    623632echo ${Titre}"Add missing variables in rmp files"${Norm} 
    624633## =========================================================================== 
    625 for $(ls rmpFile in rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc* 2>/dev/null) ; do 
     634for rmpFile in $(ls rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc 2>/dev/null) ; do 
    626635    echo ${rmpFile} 
    627636    a_to_o=false ; o_to_a=false 
     
    760769 
    761770## 
     771## ============================================================================ 
    762772echo ${Titre}"Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc"${Norm} 
    763 ## ============================================================================ 
    764 bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} 
    765  
     773cp ${SUBMIT_DIR}/CreateOasisGrids.bash . 
     774bash CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} 
    766775 
    767776 
     
    769778echo ${Titre}"Runoff weights"${Norm} 
    770779## =========================================================================== 
    771 if [[ "X${okRunoff}" = "Xyes" && "${atm}" = "lmd" ]] ; then 
     780#if [[ "X${okRunoff}" = "Xyes" && "${atm}" = "lmd" ]] ; then 
     781if [[ "X${okRunoff}" = "Xyes" ]] ; then 
    772782    ${PyRun} python3 -u cotes_etal.py --oce=${OCE} --atm=${ATM} \ 
    773783              --atmCoastWidth=${atmCoastWidth} --oceCoastWidth=${oceCoastWidth} --searchRadius=${searchRadius} \ 
    774784              --grids=grids_${OCE}x${ATM}.nc --areas=areas_${OCE}x${ATM}.nc --masks=masks_${OCE}x${ATM}.nc \ 
    775               --o2a=${ATM}_grid_maskFrom_${OCE}.nc --output=rmp_t${atm}_to_t${oce}_runoff_${FMT_OASIS}.nc \ 
    776               --fmt=${FMT_OASIS} 
     785              --o2a=${ATM}_grid_maskFrom_${OCE}.nc --output=rmp_t${atm}_to_t${oce}_runoff_${runOff_atmQuantity}_to_${runOff_oceQuantity}_${FMT_OASIS}.nc \ 
     786              --fmt=${FMT_OASIS} \ 
     787              --atmQuantity=${runOff_atmQuantity} --oceQuantity=${runOff_oceQuantity} 
    777788fi 
    778789 
     
    783794    case ${OCE} in 
    784795        ( eORCA025 ) 
    785         cp ${R_IN}/OCE/NEMO/ORCA025_LIM3_PISCES/v3.6_stable/eORCA_R025_runoff_v1.1.nc . 
    786         ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_full_${FMT_OASIS}.nc     --fmt=${FMT_OASIS} \ 
    787                   --oce=${OCE} --atm=${ATM} --type=full     --dir=. 
     796        # cp ${R_IN}/OCE/NEMO/ORCA025_LIM3_PISCES/v3.6_stable/eORCA_R025_runoff_v1.1.nc . 
     797        cp /ccc/work/cont003/gencmip6/deshayej/eORCA_R025_runoff_v1.2.nc . 
    788798        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth_${FMT_OASIS}.nc  --fmt=${FMT_OASIS} \ 
    789                   --oce=${OCE} --atm=${ATM} --type=nosouth  --dir=.  --repartition_file=eORCA_R025_runoff_v1.1.nc 
     799                  --oce=${OCE} --atm=${ATM} --type=nosouth  --dir=.  
    790800        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg_${FMT_OASIS}.nc  --fmt=${FMT_OASIS} \ 
    791                   --oce=${OCE} --atm=${ATM} --type=iceberg  --dir=.  --repartition_file=eORCA_R025_runoff_v1.1.nc --repartition_var=sornficbisf 
     801                  --oce=${OCE} --atm=${ATM} --type=iceberg  --dir=.  --repartition_file=eORCA_R025_runoff_v1.2.nc --repartition_var=Icb_flux 
    792802        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 
    793                   --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=.  --repartition_file=eORCA_R025_runoff_v1.1.nc --repartition_var=sofwfisf 
     803                  --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=.  --repartition_file=eORCA_R025_runoff_v1.2.nc --repartition_var=sornfisf 
    794804        ;; 
    795805         
     
    827837done 
    828838 
    829 cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
    830 cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
    831 cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
    832  
     839if [[ "X${okGrids}" = "Xyes" ]] ; then 
     840    cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
     841    cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
     842    cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
     843fi 
    833844 
    834845## 
     
    892903EOF 
    893904 
    894 cp README.txt ${SUBMIT_DIR}/README_${OCE}x${ATM}.txt 
     905cp README.txt ${SUBMIT_DIR}/README_${OCE}x${ATM}_MOSAIX.txt 
    895906 
    896907## =========================================================================== 
  • TOOLS/MOSAIX/cotes_etal.py

    r4172 r4186  
    3737epsfrac = np.dtype('float64').type(1.0E-10) 
    3838pi      = np.pi 
    39 rad     = pi/np.dtype('float64').type(180.0) 
     39rad     = pi/np.dtype('float64').type(180.0)  # Conversion from degrees to radian 
    4040ra      = np.dtype('float64').type(6371229.0) # Earth radius 
    4141 
     
    5656# Adding arguments 
    5757parser.add_argument ('--oce'          , help='oce model name', type=str, default='eORCA1.2', choices=['ORCA2.3', 'eORCA1.2', 'eORCA025'] ) 
    58 parser.add_argument ('--atm'          , help='atm model name (LMD*)', type=str, default='LMD9695'    ) 
     58parser.add_argument ('--atm'          , help='atm model name', type=str, default='LMD9695'    ) 
    5959parser.add_argument ('--atmCoastWidth', help='width of the coastal band in atmosphere (in grid points)', type=int, default=1 ) 
    6060parser.add_argument ('--oceCoastWidth', help='width of the coastal band in ocean (in grid points)'     , type=int, default=2 ) 
    61 parser.add_argument ('--searchRadius' , help='max distance to connect a land point to an ocean point (in km)', type=float, default=600000.0) 
     61parser.add_argument ('--atmQuantity'  , help='Quantity if atm provides quantities (m/s), Surfacic if atm provided flux (m/s/m2)'  , type=str, default='Quantity', choices=['Quantity', 'Surfacic'] ) 
     62parser.add_argument ('--oceQuantity'  , help='Quantity if oce requires quantities (ks/s), Surfacic if oce requires flux (m/s/m2)' , type=str, default='Surfacic', choices=['Quantity', 'Surfacic'] ) 
     63parser.add_argument ('--searchRadius' , help='max distance to connect a land point to an ocean point (in km)', type=float, default=600.0 ) 
    6264parser.add_argument ('--grids' , help='grids file name', default='grids.nc' ) 
    6365parser.add_argument ('--areas' , help='masks file name', default='areas.nc' ) 
     
    9395if myargs.fmt == 'netcdf4_classic' : FmtNetcdf = 'NETCDF4_CLASSIC' 
    9496 
     97# 
     98if atm_Name.find('LMD') >= 0 : atm_n = 'lmd' ; atmDomainType = 'rectilinear' 
     99if atm_Name.find('ICO') >= 0 : atm_n = 'ico' ; atmDomainType = 'unstructured' 
     100 
     101print ('atmQuantity : ' + str (myargs.atmQuantity) ) 
     102print ('oceQuantity : ' + str (myargs.oceQuantity) ) 
     103     
    95104### Read coordinates of all models 
    96105### 
     
    104113o2aFrac = np.where ( np.abs(o2aFrac) < 1E10, o2aFrac, 0.0) 
    105114 
    106 atm_grid_center_lat = gridFile['tlmd.lat'][:] 
    107 atm_grid_center_lon = gridFile['tlmd.lon'][:] 
    108 atm_grid_corner_lat = gridFile['tlmd.cla'][:] 
    109 atm_grid_corner_lon = gridFile['tlmd.clo'][:] 
    110  
    111 atm_grid_area       = areaFile['tlmd.srf'][:] 
    112 atm_grid_imask      = 1-maskFile['tlmd.msk'][:].squeeze() 
    113 atm_grid_dims       = atm_grid_area.shape 
    114 (atm_nvertex, atm_jpj, atm_jpi) = atm_grid_corner_lat.shape 
     115(atm_nvertex, atm_jpj, atm_jpi) = gridFile['t'+atm_n+'.clo'][:].shape 
     116atm_grid_size = atm_jpj*atm_jpi 
     117atm_grid_rank = len(gridFile['t'+atm_n+'.lat'][:].shape) 
     118 
     119atm_grid_center_lat = gridFile['t'+atm_n+'.lat'][:].ravel() 
     120atm_grid_center_lon = gridFile['t'+atm_n+'.lon'][:].ravel() 
     121atm_grid_corner_lat = np.reshape ( gridFile['t'+atm_n+'.cla'][:], (atm_nvertex, atm_grid_size) ) 
     122atm_grid_corner_lon = np.reshape ( gridFile['t'+atm_n+'.clo'][:], (atm_nvertex, atm_grid_size) ) 
     123atm_grid_area       = areaFile['t'+atm_n+'.srf'][:].ravel() 
     124atm_grid_imask      = 1-maskFile['t'+atm_n+'.msk'][:].squeeze().ravel() 
     125atm_grid_dims       = gridFile['t'+atm_n+'.lat'][:].shape 
     126 
    115127atm_perio = 0 
    116 atm_grid_pmask = nemo.lbc_mask (atm_grid_imask, 'T', atm_perio) 
    117 atm_address = np.reshape ( np.arange(atm_jpj*atm_jpi), (atm_jpj, atm_jpi) ) 
    118 atm_grid_size = atm_jpj*atm_jpi 
    119  
    120 oce_grid_center_lat = gridFile['torc.lat'][:] 
    121 oce_grid_center_lon = gridFile['torc.lon'][:] 
    122 oce_grid_corner_lat = gridFile['torc.cla'][:] 
    123 oce_grid_corner_lon = gridFile['torc.clo'][:] 
    124 oce_grid_area       = areaFile['torc.srf'][:] 
    125 oce_grid_imask      = 1-maskFile['torc.msk'][:] 
    126 oce_grid_dims       = oce_grid_area.shape 
    127 (oce_nvertex, oce_jpj, oce_jpi) = oce_grid_corner_lat.shape ; jpon=oce_jpj*oce_jpj 
     128atm_grid_pmask = atm_grid_imask 
     129atm_address = np.arange(atm_jpj*atm_jpi) 
     130 
     131 
     132(oce_nvertex, oce_jpj, oce_jpi) = gridFile['torc.cla'][:].shape ; jpon=oce_jpj*oce_jpj 
     133oce_grid_size = oce_jpj*oce_jpi 
     134oce_grid_rank = len(gridFile['torc.lat'][:].shape) 
     135 
     136oce_grid_center_lat = gridFile['torc.lat'][:].ravel() 
     137oce_grid_center_lon = gridFile['torc.lon'][:].ravel() 
     138oce_grid_corner_lat = np.reshape( gridFile['torc.cla'][:], (oce_nvertex, oce_grid_size) ) 
     139oce_grid_corner_lon = np.reshape( gridFile['torc.clo'][:], (oce_nvertex, oce_grid_size) ) 
     140oce_grid_area       = areaFile['torc.srf'][:].ravel() 
     141oce_grid_imask      = 1-maskFile['torc.msk'][:].ravel() 
     142oce_grid_dims       = gridFile['torc.lat'][:].shape 
    128143if oce_jpi ==  182 : oce_perio = 4 # ORCA 2 
    129144if oce_jpi ==  362 : oce_perio = 6 # ORCA 1 
    130145if oce_jpi == 1442 : oce_perio = 6 # ORCA 025 
    131 oce_grid_pmask = nemo.lbc_mask (oce_grid_imask, 'T', oce_perio) 
    132 oce_address = np.reshape ( np.arange(oce_jpj*oce_jpi), (oce_jpj, oce_jpi) ) 
    133 oce_grid_size = oce_jpj*oce_jpi 
     146oce_grid_pmask = nemo.lbc_mask (np.reshape(oce_grid_imask, (oce_jpj,oce_jpi)), 'T', oce_perio).ravel() 
     147oce_address = np.arange(oce_jpj*oce_jpi) 
    134148 
    135149## Fill closed sea with image processing library 
    136 oce_grid_imask = nemo.lbc_mask ( 1-ndimage.binary_fill_holes (1-nemo.lbc(oce_grid_imask, nperio=oce_perio, cd_type='T')), nperio=oce_perio, cd_type='T' ) 
    137  
     150oce_grid_imask2D = np.reshape(oce_grid_pmask,(oce_jpj,oce_jpi)) 
     151oce_grid_imask2D = nemo.lbc_mask ( 1-ndimage.binary_fill_holes (1-nemo.lbc(oce_grid_imask2D, nperio=oce_perio, cd_type='T')), nperio=oce_perio, cd_type='T' ) 
     152oce_grid_imask = oce_grid_imask2D.ravel() 
    138153##  
    139154print ("Determination d'une bande cotiere ocean") 
    140155 
    141 oceLand  = np.where (oce_grid_pmask[:] < 0.5, True, False) 
    142 oceOcean = np.where (oce_grid_pmask[:] > 0.5, True, False) 
     156oceLand2D  = np.reshape ( np.where (oce_grid_pmask[:] < 0.5, True, False), (oce_jpj, oce_jpi) ) 
     157oceOcean2D = np.reshape ( np.where (oce_grid_pmask[:] > 0.5, True, False), (oce_jpj, oce_jpi) ) 
    143158 
    144159NNocean = 1+2*oceCoastWidth 
    145 oceOceanFiltered = ndimage.uniform_filter(oceOcean.astype(float), size=NNocean) 
    146 oceCoast = np.where (oceOceanFiltered<(1.0-0.5/(NNocean**2)),True,False) & oceOcean 
    147 oceCoast = nemo.lbc_mask (oceCoast, oce_perio, 'T') 
     160oceOceanFiltered2D = ndimage.uniform_filter(oceOcean2D.astype(float), size=NNocean) 
     161oceCoast2D = np.where (oceOceanFiltered2D<(1.0-0.5/(NNocean**2)),True,False) & oceOcean2D 
     162oceCoast2D = nemo.lbc_mask (np.reshape(oceCoast2D,(oce_jpj,oce_jpi)), oce_perio, 'T').ravel() 
     163 
     164oceOceanFiltered = oceOceanFiltered2D.ravel() 
     165oceLand  = oceLand2D.ravel() 
     166oceOcean = oceOcean2D.ravel() 
     167oceCoast = oceCoast2D.ravel() 
    148168 
    149169print ('Number of points in oceLand  : ' + str(oceLand.sum()) ) 
     
    166186atmOceanFrac = np.where (o2aFrac[:] > epsfrac       , True, False) 
    167187 
    168 NNatm = 1+2*atmCoastWidth 
    169 atmLandFiltered = ndimage.uniform_filter(atmLand.astype(float), size=NNatm) 
    170 atmCoast = np.where (atmLandFiltered<(1.0-0.5/(NNatm**2)),True,False) & atmLandFrac 
    171 atmCoast = nemo.lbc_mask (atmCoast, 1, 'T') 
    172  
    173 print ('Number of points in atmLand  : ' + str(atmLand.sum()) ) 
    174 print ('Number of points in atmOcean : ' + str(atmOcean.sum()) ) 
    175 print ('Number of points in atmCoast : ' + str(atmCoast.sum()) ) 
    176  
     188## La suite marche avec LMDZ seulement !! 
     189if atmDomainType == 'rectilinear' : 
     190    NNatm = 1+2*atmCoastWidth 
     191    atmLand2D = np.reshape ( atmLand, ( atm_jpj, atm_jpi) ) 
     192 
     193    atmLandFiltered2D = ndimage.uniform_filter(atmLand2D.astype(float), size=NNatm) 
     194    atmCoast2D = np.where (atmLandFiltered2D<(1.0-0.5/(NNatm**2)),True,False) & atmLandFrac 
     195     
     196    atmLandFiltered = atmLandFiltered2D.ravel() 
     197    atmCoast = atmCoast2D.ravel() 
     198 
     199    print ('Number of points in atmLand  : ' + str(atmLand.sum())  ) 
     200    print ('Number of points in atmOcean : ' + str(atmOcean.sum()) ) 
     201    print ('Number of points in atmCoast : ' + str(atmCoast.sum()) ) 
     202 
     203else : 
     204    atmCoast = atmFrac 
     205     
     206     
    177207# Arrays with coastal points only 
    178208atmCoast_grid_center_lon = atm_grid_center_lon[atmCoast] 
     
    183213atmCoast_address         = atm_address        [atmCoast] 
    184214 
     215# Initialisations before the loop 
    185216remap_matrix = np.empty ( shape=(0), dtype=np.float64 ) 
    186217atm_address  = np.empty ( shape=(0), dtype=np.int32   ) 
     
    191222    z_dist = geodist ( atmCoast_grid_center_lon[ja], atmCoast_grid_center_lat[ja], oceCoast_grid_center_lon, oceCoast_grid_center_lat) 
    192223    z_mask = np.where ( z_dist*ra < searchRadius, True, False) 
    193     num_links = z_mask.sum() 
     224    num_links = np.int(z_mask.sum()) 
    194225    if num_links == 0 : continue 
    195226    z_area = oceCoast_grid_area[z_mask].sum() 
    196     poids = 1.0 / z_area 
    197     #print ( num_links, z_mask.sum(), z_area ) 
     227    poids = np.ones ((num_links),dtype=np.float64) / z_area 
     228    if myargs.atmQuantity == 'Surfacic' : poids = poids * atm_grid_area[ja] 
     229    if myargs.oceQuantity == 'Quantity' : poids = poids * oceCoast_grid_area[z_mask] 
     230    if  ja % (len(atmCoast_grid_pmask)//50) == 0 : # Control print 
     231        print ( 'ja:{:8d}, num_links:{:8d},  z_area:{:8.4e},  atm area:{:8.4e},  weights sum:{:8.4e}  '.format(ja, num_links, z_area, atm_grid_area[ja], poids.sum() ) ) 
    198232    # 
    199     matrix_local     = np.ones ((num_links),dtype=np.float64) * poids 
    200     # address on source grid : all links points to the same LMDZ point. 
     233    matrix_local = poids 
    201234    atm_address_local = np.ones(num_links, dtype=np.int32 ) * atmCoast_address[ja] 
    202     # address on destination grid 
     235    # Address on destination grid 
    203236    oce_address_local = oceCoast_address[z_mask] 
    204237    # Append to global tabs 
     
    252285f_runoff.SVN_HeadURL     = "$HeadURL$" 
    253286 
    254 d_num_links        = f_runoff.createDimension ('num_links'       , num_links ) 
    255 d_num_wgts         = f_runoff.createDimension ('num_wgts'        ,         1 ) 
     287d_num_links = f_runoff.createDimension ('num_links'       , num_links ) 
     288d_num_wgts  = f_runoff.createDimension ('num_wgts'        ,         1 ) 
    256289 
    257290d_atm_grid_size    = f_runoff.createDimension ('src_grid_size'   , atm_grid_size ) 
    258291d_atm_grid_corners = f_runoff.createDimension ('src_grid_corners', atm_grid_corner_lon.shape[0]  ) 
    259 d_atm_grid_rank    = f_runoff.createDimension ('src_grid_rank'   ,        2  ) 
     292d_atm_grid_rank    = f_runoff.createDimension ('src_grid_rank'   , atm_grid_rank  ) 
    260293 
    261294d_oce_grid_size    = f_runoff.createDimension ('dst_grid_size'   , oce_grid_size ) 
    262295d_oce_grid_corners = f_runoff.createDimension ('dst_grid_corners', oce_grid_corner_lon.shape[0] ) 
    263 d_oce_grid_rank    = f_runoff.createDimension ('dst_grid_rank'   ,        2  ) 
     296d_oce_grid_rank    = f_runoff.createDimension ('dst_grid_rank'   , oce_grid_rank  ) 
    264297 
    265298v_remap_matrix = f_runoff.createVariable ( 'remap_matrix', 'f8', ('num_links', 'num_wgts') ) 
     
    289322 
    290323v_atm_grid_dims      [:] = atm_grid_dims 
    291 v_atm_grid_center_lon[:] = atm_grid_center_lon[:].ravel() 
    292 v_atm_grid_center_lat[:] = atm_grid_center_lat[:].ravel() 
    293 v_atm_grid_corner_lon[:] = atm_grid_corner_lon.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) ) 
    294 v_atm_grid_corner_lat[:] = atm_grid_corner_lat.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) ) 
    295 v_atm_grid_area      [:] = atm_grid_area[:].ravel() 
    296 v_atm_grid_imask     [:] = atm_grid_imask[:].ravel() 
    297 v_atm_grid_pmask     [:] = atm_grid_pmask[:].ravel() 
     324v_atm_grid_center_lon[:] = atm_grid_center_lon[:] 
     325v_atm_grid_center_lat[:] = atm_grid_center_lat[:] 
     326v_atm_grid_corner_lon[:] = atm_grid_corner_lon 
     327v_atm_grid_corner_lat[:] = atm_grid_corner_lat 
     328v_atm_grid_area      [:] = atm_grid_area[:] 
     329v_atm_grid_imask     [:] = atm_grid_imask[:] 
     330v_atm_grid_pmask     [:] = atm_grid_pmask[:] 
    298331 
    299332# -- 
     
    316349 
    317350v_oce_grid_dims      [:] = oce_grid_dims 
    318 v_oce_grid_center_lon[:] = oce_grid_center_lon[:].ravel() 
    319 v_oce_grid_center_lat[:] = oce_grid_center_lat[:].ravel() 
    320 v_oce_grid_corner_lon[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) ) 
    321 v_oce_grid_corner_lat[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) ) 
    322 v_oce_grid_area      [:] = oce_grid_area[:].ravel() 
    323 v_oce_grid_imask     [:] = oce_grid_imask[:].ravel() 
    324 v_oce_grid_pmask     [:] = oce_grid_pmask[:].ravel() 
     351v_oce_grid_center_lon[:] = oce_grid_center_lon[:] 
     352v_oce_grid_center_lat[:] = oce_grid_center_lat[:] 
     353v_oce_grid_corner_lon[:] = oce_grid_corner_lon 
     354v_oce_grid_corner_lat[:] = oce_grid_corner_lon 
     355v_oce_grid_area      [:] = oce_grid_area[:] 
     356v_oce_grid_imask     [:] = oce_grid_imask[:] 
     357v_oce_grid_pmask     [:] = oce_grid_pmask[:] 
    325358 
    326359v_atm_lon_addressed   = f_runoff.createVariable ( 'src_lon_addressed'  , 'f8', ('num_links',) ) 
     
    338371v_atm_lon_addressed.long_name="Longitude" ; v_atm_lon_addressed.standard_name="longitude" ; v_atm_lon_addressed.units="degrees_east" 
    339372v_atm_lat_addressed.long_name="Latitude"  ; v_atm_lat_addressed.standard_name="latitude"  ; v_atm_lat_addressed.units="degrees_north" 
    340 v_atm_lon_addressed  [:] = atm_grid_center_lon.ravel()[atm_address].ravel() 
    341 v_atm_lat_addressed  [:] = atm_grid_center_lat.ravel()[atm_address].ravel() 
    342 v_atm_area_addressed [:] = atm_grid_area.ravel()[atm_address].ravel() 
    343 v_atm_imask_addressed[:] = 1-atm_grid_imask.ravel()[atm_address].ravel() 
    344 v_atm_pmask_addressed[:] = 1-atm_grid_pmask.ravel()[atm_address].ravel() 
     373v_atm_lon_addressed  [:] = atm_grid_center_lon[atm_address] 
     374v_atm_lat_addressed  [:] = atm_grid_center_lat[atm_address] 
     375v_atm_area_addressed [:] = atm_grid_area[atm_address] 
     376v_atm_imask_addressed[:] = 1-atm_grid_imask[atm_address] 
     377v_atm_pmask_addressed[:] = 1-atm_grid_pmask[atm_address] 
    345378 
    346379v_oce_lon_addressed.long_name="Longitude" ; v_oce_lon_addressed.standard_name="longitude" ; v_oce_lon_addressed.units="degrees_east" 
    347380v_oce_lat_addressed.long_name="Latitude"  ; v_oce_lat_addressed.standard_name="latitude"  ; v_oce_lat_addressed.units="degrees_north" 
    348 v_oce_lon_addressed  [:] = oce_grid_center_lon.ravel()[oce_address].ravel() 
    349 v_oce_lat_addressed  [:] = oce_grid_center_lat.ravel()[oce_address].ravel() 
    350 v_oce_area_addressed [:] = oce_grid_area.ravel()[oce_address].ravel() 
    351 v_oce_imask_addressed[:] = 1-oce_grid_imask.ravel()[oce_address].ravel() 
    352 v_oce_pmask_addressed[:] = 1-oce_grid_pmask.ravel()[oce_address].ravel() 
    353  
    354 v_atmLand         = f_runoff.createVariable ( 'atmLand'        , 'i4', ('src_grid_size',) ) 
    355 v_atmLandFiltered = f_runoff.createVariable ( 'atmLandFiltered', 'f4', ('src_grid_size',) ) 
    356 v_atmLandFrac     = f_runoff.createVariable ( 'atmLandFrac'    , 'i4', ('src_grid_size',) ) 
    357 v_atmFrac         = f_runoff.createVariable ( 'atmFrac'        , 'i4', ('src_grid_size',) ) 
    358 v_atmOcean        = f_runoff.createVariable ( 'atmOcean'       , 'i4', ('src_grid_size',) ) 
    359 v_atmOceanFrac    = f_runoff.createVariable ( 'atmOceanFrac'   , 'i4', ('src_grid_size',) ) 
    360 v_atmCoast        = f_runoff.createVariable ( 'atmCoast'       , 'i4', ('src_grid_size',) )  
    361  
    362 v_atmLand[:]         = atmLand.ravel() 
    363 v_atmLandFrac[:]     = atmLandFrac.ravel() 
    364 v_atmLandFiltered[:] = atmLandFiltered.ravel() 
    365 v_atmFrac[:]         = atmFrac.ravel() 
    366 v_atmOcean[:]        = atmOcean.ravel() 
    367 v_atmOceanFrac[:]    = atmOceanFrac.ravel() 
    368 v_atmCoast[:]        = atmCoast.ravel() 
     381v_oce_lon_addressed  [:] = oce_grid_center_lon[oce_address] 
     382v_oce_lat_addressed  [:] = oce_grid_center_lat[oce_address]#.ravel() 
     383v_oce_area_addressed [:] = oce_grid_area[oce_address] 
     384v_oce_imask_addressed[:] = 1-oce_grid_imask[oce_address] 
     385v_oce_pmask_addressed[:] = 1-oce_grid_pmask[oce_address] 
     386 
     387if atmDomainType == 'rectilinear' : 
     388    v_atmLand         = f_runoff.createVariable ( 'atmLand'        , 'i4', ('src_grid_size',) ) 
     389    v_atmLandFiltered = f_runoff.createVariable ( 'atmLandFiltered', 'f4', ('src_grid_size',) ) 
     390    v_atmLandFrac     = f_runoff.createVariable ( 'atmLandFrac'    , 'i4', ('src_grid_size',) ) 
     391    v_atmFrac         = f_runoff.createVariable ( 'atmFrac'        , 'i4', ('src_grid_size',) ) 
     392    v_atmOcean        = f_runoff.createVariable ( 'atmOcean'       , 'i4', ('src_grid_size',) ) 
     393    v_atmOceanFrac    = f_runoff.createVariable ( 'atmOceanFrac'   , 'i4', ('src_grid_size',) ) 
     394     
     395    v_atmLand[:]         = atmLand 
     396    v_atmLandFrac[:]     = atmLandFrac 
     397    v_atmLandFiltered[:] = atmLandFiltered 
     398    v_atmFrac[:]         = atmFrac 
     399    v_atmOcean[:]        = atmOcean 
     400    v_atmOceanFrac[:]    = atmOceanFrac 
     401 
     402v_atmCoast         = f_runoff.createVariable ( 'atmCoast'       , 'i4', ('src_grid_size',) )  
     403v_atmCoast[:]      = atmCoast 
    369404 
    370405v_oceLand          = f_runoff.createVariable ( 'oceLand'         , 'i4', ('dst_grid_size',) ) 
     
    373408v_oceCoast         = f_runoff.createVariable ( 'oceCoast'        , 'i4', ('dst_grid_size',) ) 
    374409 
    375 v_oceLand[:]      = oceLand.ravel() 
    376 v_oceOcean[:]     = oceOcean.ravel() 
    377 v_oceOceanFiltered[:]     = oceOceanFiltered.ravel() 
    378 v_oceCoast[:]     = oceCoast.ravel() 
     410v_oceLand[:]      = oceLand 
     411v_oceOcean[:]     = oceOcean 
     412v_oceOceanFiltered[:]     = oceOceanFiltered 
     413v_oceCoast[:]     = oceCoast 
    379414 
    380415f_runoff.sync () 
  • TOOLS/MOSAIX/rangement.bash

    r4172 r4186  
    1717# ============================================================ 
    1818 
    19 for ATM in LMD144142 LMD9695 LMD256256 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 
     19for ATM in LMD144142 LMD9695 LMD256256 LMD144x142 LMD96x95 LMD256x256 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 
    2020do 
    2121    for OCE in ORCA2.3 eORCA1.2 eORCA025 ORCA025  
    2222    do 
    23         Liste=$(ls README_${OCE}x${ATM}.txt *${ATM}*_*${OCE}*.nc *${OCE}*_*${ATM}*.nc  *${ATM}x${OCE}*.nc *${OCE}x${ATM}*.nc 2> /dev/null  ) 
     23        Liste=$(ls README_${OCE}x${ATM}*.txt *${ATM}*_*${OCE}*.nc *${OCE}*_*${ATM}*.nc  *${ATM}x${OCE}*.nc *${OCE}x${ATM}*.nc 2> /dev/null  ) 
    2424 
    2525        if [[ -z ${Liste} ]] ; then 
Note: See TracChangeset for help on using the changeset viewer.