Ignore:
Timestamp:
12/12/18 11:26:20 (5 years ago)
Author:
omamce
Message:

O.M. :

Runoff weight for both ICO and LMDZ
Correct corc grid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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## =========================================================================== 
Note: See TracChangeset for help on using the changeset viewer.