Ignore:
Timestamp:
12/05/18 11:17:10 (6 years ago)
Author:
omamce
Message:

O.M. :

  • More documentation
  • Update run-off weights computation
  • Update calving weights computation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r4159 r4172  
    3838#  $HeadURL$ 
    3939# 
     40set +vx 
    4041export Bold=$(tput bold)   
    4142export Unde=$(tput smul) ; export OffUnde=$(tput rmul) 
     
    4546for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done 
    4647export Norm=$(tput sgr0 ) 
     48export Titre=${Bold}${Blue} 
    4749 
    4850## 
     
    5254 
    5355# 
    54 # Defines models 
     56echo ${Titre}"Defines models"${Norm} 
    5557# ============== 
    56 #OCE=ORCA2.3 
     58OCE=ORCA2.3 
    5759#OCE=eORCA1.2 
    58 OCE=eORCA025 
     60#OCE=eORCA025 
    5961 
    6062#ATM=ICO30 
     
    6365ATM=LMD9695 
    6466#ATM=LMD144142 
     67#ATM=LMD256256 
     68 
     69# Runoff parameter (LMDZ grids only) 
     70atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=1000.0 
     71 
     72if [[ ${OCE} = ORCA2.3  && ${ATM} = LMD9695   ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi 
     73if [[ ${OCE} = ORCA2.3  && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi 
     74if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD9695   ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi 
     75if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi 
    6576 
    6677# Default values, used to create ocean fraction on atmospheric grid  
    6778DefaultValues=( Direction=o2a,oceGrid=t,atmGrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false ) 
    6879 
    69 # List of weights to build 
    70 CommandList=( \ 
    71     Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true  \ 
    72     Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true  \ 
    73     Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true  \ 
    74     Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true  \ 
    75     Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true   \ 
    76     ) 
    77  
    78 # Each item in CommandList describes the property of interpolation weights to generate.  
     80## List of weights to build 
     81## ==================================================================================================================================== 
     82# 
     83# Each item in CommandList describes the properties of interpolation weights to generate.  
    7984# White spaces separate analysis. No spaces in any analysis. 
     85# 
     86# Specific commands : 'Runoff', 'Calving' 
    8087# 
    8188# Keywords :  
     
    8592#                 or intensive value (temperature, salinity, sea-ice fraction, ...) 
    8693#   Renormalize : used when source grid is masked, to use values on non masked points only 
    87 #   oceGrid     : t, u or v point for OPA grid 
     94#   oceGrid     : t, u or v point for NEMO C grid 
    8895#   atmGrid     : up to know, only t grid used in the atmosphere 
    8996#   useArea     : if true area from the model metrics is used. If false, areas are computed by XIOS from grid corners 
     
    9198#   maskDst     : true to use the destination grid mask, false to use all grid points 
    9299# 
     100# Classic cases  
     101AtmOceFluxes=" Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # Heat and water fluxes 
     102OceAtmTemp="   Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # Temperature, sea-ice fraction, albedo 
     103AtmOceStressU="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO U point 
     104AtmOceStressV="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# Other cases 
     106OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # e.g. CO2 fluxes 
     107AtmOceTemp="   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 
     108AtmOceCoastal="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 
     110CommandList=( ${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 
     122 
     123 
     124Comment="Preliminary attempt - Do not trust !" 
     125#Version 
    93126 
    94127## =========================================================================== 
     
    169202    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
    170203    PROGRAM=${BRIDGE_MSUB_REQNAME} 
    171     MPIRUN=ccc_mprun 
     204    MpiRun="time ccc_mprun" 
     205    PyRun="ccc_mprun -n 1" 
    172206    source ${SUBMIT_DIR}/arch.env 
    173207    module load nco 
    174     module load cdo 
    175208    #source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene 
    176     module load python/2.7.8 
     209    module load python3  
    177210    module load datadir/igcmg 
    178211    module list 
     
    182215    TMPDIR=${HOME}/Scratch/TMP 
    183216    SUBMIT_DIR=$(pwd) 
    184     MPIRUN=/opt/local/bin/mpirun -n 4 
     217    MpiRun="/opt/local/bin/mpirun -n 4" 
     218    PyRun="time" 
    185219    ;;  
    186220    ( * ) exit -1 ;; 
     
    209243case ${OCE} in # Periodicity type of ORCA grid 
    210244    ( ORCA2.3*             ) OcePerio=4 ;; 
    211     ( ORCA1* | eORCA1*     ) OcePerio=6 ;; 
     245    ( ORCA1*   | eORCA1*   ) OcePerio=6 ;; 
    212246    ( ORCA025* | eORCA025  ) OcePerio=6 ;; 
    213247esac 
    214248# 
    215 # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits 
     249echo ${Titre}"Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits"${Norm} 
    216250# --------------------------------------------------------------------------- 
    217251FMT_OASIS=64bit 
     
    229263ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc             ${ATM}_grid_${FMT_OASIS}.nc 
    230264# 
    231 # Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights 
     265echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm} 
    232266# -------------------------------------------------------------------------------------------------------- 
    233267cat <<EOF >add_c_grid.nco 
     
    258292 
    259293## 
    260 ## NEMO T point towards ATM - 1st order 
     294echo ${Titre}"NEMO T point towards ATM - 1st order"${Norm} 
    261295## =========================================================================== 
    262296echo "Command parameters : ${Command}" 
     
    267301cp iodef_oce_to_atm.xml   iodef.xml 
    268302 
    269 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]'   -k name  -v maskutil_T 
    270 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="area_src"]'   -k name  -v area_grid_T 
    271 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${srcDomainType} 
    272 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${dstDomainType} 
    273 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
    274 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity    -v false 
    275 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false 
    276 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false 
    277 python 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_T 
    278 python 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_T 
    279 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix} 
    280 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${SRC} mask interpolated to ${DST}" 
    281 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} 
    282 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${dstDomainType} 
    283 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
    284 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${srcDomainType} 
    285 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${dstDomainType} 
    286 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc 
    287 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order -v 1 
    288 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false 
    289 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t false 
    290 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t false 
    291 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v false 
    292 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v false 
    293 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v false 
     303python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]'   -k name  -v maskutil_T 
     304python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="area_src"]'   -k name  -v area_grid_T 
     305python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${srcDomainType} 
     306python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${dstDomainType} 
     307python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
     308python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity    -v false 
     309python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false 
     310python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false 
     311python3 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_T 
     312python3 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_T 
     313python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix} 
     314python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${SRC} mask interpolated to ${DST}" 
     315python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} 
     316python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${dstDomainType} 
     317python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
     318python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${srcDomainType} 
     319python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${dstDomainType} 
     320python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc 
     321python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order -v 1 
     322python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false 
     323python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t false 
     324python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t false 
     325python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v false 
     326python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v false 
     327python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v false 
    294328 
    295329cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml 
     
    297331ln -fs ${ATM}_grid.nc              atm_grid.nc 
    298332 
    299 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
    300 ## 
    301 ## Correct spurious values (extremes) 
     333${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
     334 
     335## 
     336echo ${Titre}"Correct spurious values (extremes)"${Norm} 
    302337## =========================================================================== 
    303338cat <<EOF > correction_masque.nco 
     
    313348 
    314349## 
    315 ##  Creates ocean fractions on ATM grid 
     350echo ${Titre}"Creates ocean fractions on ATM grid"${Norm} 
    316351## =========================================================================== 
    317352cp dia_t${oce}_to_t${atm}_${Suffix}.nc  dia_t${oce}_to_t${atm}_${Suffix}_mask.nc 
     
    330365rm dia_t${oce}_to_t${atm}_${Suffix}_mask.nc 
    331366 
    332 # Change dimension names, and some attributes accordingly 
     367echo "Change dimension names, and some attributes accordingly" 
    333368if [[ $(ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc | grep domain_dst | wc -l) -gt 0 ]] ; then 
    334369    case ${atm} in 
     
    357392 
    358393## 
    359 ## Creates mask of coastal OCE points 
    360 ## =========================================================================== 
    361 ccc_mprun -n 1 python -u ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 
    362 ## 
    363 ## Creates mask of coastal ATM points 
     394echo ${Titre}"Creates mask of coastal OCE points"${Norm} 
     395## =========================================================================== 
     396${PyRun} python3 -u ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 
     397 
     398## 
     399echo ${Titre}"Creates mask of coastal ATM points"${Norm} 
    364400## =========================================================================== 
    365401cat <<EOF > coastal.nco 
     
    374410 
    375411## 
    376 ## Other weights files 
     412echo ${Titre}"Other weights files"${Norm} 
    377413## =========================================================================== 
    378414# Loop on commands 
     
    382418    read_Command ${DefaultValues} 
    383419    read_Command ${Command} 
     420 
     421    if [[ ${Command} = "Runoff"  ]] ; then okRunoff=yes  ; continue ; fi 
     422    if [[ ${Command} = "Calving" ]] ; then okCalving=yes ; continue ; fi 
     423     
    384424    setValues 
    385425     
     
    391431        cp iodef_oce_to_atm.xml iodef.xml 
    392432         
    393         python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]'   -k name -v mask_${DSTGRID}  
    394         python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]'   -k name -v OceMask 
     433        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}  
     434        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 
    395435         
    396         python 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} 
    397         python 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} 
    398         python 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 
    399         python 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 
     436        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} 
     437        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} 
     438        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 
     439        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 
    400440        ;; 
    401441        ( a2o ) 
    402442        cp iodef_atm_to_oce.xml iodef.xml 
    403443         
    404         python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]'   -k name -v OceMask 
    405         python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]'   -k name -v mask_${DSTGRID} 
     444        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 
     445        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} 
    406446         
    407         python 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 
    408         python 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 
    409         python 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} 
    410         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]'   -k name  -v area_grid_${DSTGRID} 
     447        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 
     448        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 
     449        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} 
     450        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 area_grid_${DSTGRID} 
    411451        ;; 
    412452    esac 
    413453     
    414     python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${dstDomainType} 
    415     python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${srcDomainType} 
    416      
    417     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${srcDomainType} 
    418     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${dstDomainType} 
    419      
    420     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc 
    421     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order       -v ${numOrder} 
    422     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v ${Quantity} 
    423     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v ${Renormalize} 
    424     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v ${useArea} 
    425      
    426     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                                 -k name -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix} 
    427     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'         -t "${SRC} mask interpolated to ${DST}" 
    428     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'     -t ${dstDomainType} 
    429     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]'   -t ${srcDomainType} 
    430     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize} 
    431     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${numOrder}    
    432     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${Quantity} 
    433     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t ${useArea} 
     454    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${dstDomainType} 
     455    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${srcDomainType} 
     456     
     457    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${srcDomainType} 
     458    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${dstDomainType} 
     459     
     460    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc 
     461    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order       -v ${numOrder} 
     462    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v ${Quantity} 
     463    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v ${Renormalize} 
     464    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v ${useArea} 
     465     
     466    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                                 -k name -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix} 
     467    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'         -t "${SRC} mask interpolated to ${DST}" 
     468    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'     -t ${dstDomainType} 
     469    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]'   -t ${srcDomainType} 
     470    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize} 
     471    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${numOrder}    
     472    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${Quantity} 
     473    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t ${useArea} 
    434474     
    435475    cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml 
    436     time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
     476    ${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
    437477done 
    438478 
    439479## 
    440 ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) 
     480echo ${Titre}"Copy all NetCDF files to NetCDF 3 format (needed for OASIS)"${Norm} 
    441481## =========================================================================== 
    442482for InFile in *.nc ; do 
     
    446486 
    447487## 
    448 ## Add time axis and coordinates information 
     488echo ${Titre}"Add time axis and coordinates information"${Norm} 
    449489## (needed if files need to be read by XIOS) 
    450490## =========================================================================== 
     
    491531 
    492532## 
    493 ## Add some metadata in file headers 
     533echo ${Titre}"Add some metadata in file headers"${Norm} 
    494534## =========================================================================== 
    495535 
    496536UUID=$(uuid) 
    497537NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 
    498 PYTHON_VER=$( python -c "import sys ; print (sys.version.split(' ')[0])" ) 
     538PYTHON_VER=$( python3 -c "import sys ; print (sys.version.split(' ')[0])" ) 
    499539for InFile in $(ls *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 2>/dev/null) ; do 
    500540    ncatted --history \ 
     
    520560            --attribute LOGNAME,global,o,c,"$(whoami)"                            \ 
    521561            --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ 
    522             --attribute Python,global,o,c,"Python version ${PYTHON_VER}"          \ 
     562            --attribute Python,global,o,c,"Python3 version ${PYTHON_VER}"          \ 
    523563            --attribute OS,global,o,c,"$(uname -o)"                               \ 
    524564            --attribute release,global,o,c,"$(uname -r)"                          \ 
    525565            --attribute directory,global,o,c,"$(pwd)"                             \ 
    526566            --attribute description,global,o,c,"Generated with XIOS http://forge.ipsl.jussieu.fr/ioserver and MOSAIX https://forge.ipsl.jussieu.fr/igcmg/browser/TOOLS/MOSAIX" \ 
    527             --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ 
    528567            --attribute SVN_Author,global,o,c,'$Author$'                 \ 
    529568            --attribute SVN_Date,global,o,c,'$Date$'                            \ 
     
    533572done 
    534573## 
    535 ## Update and complete weight files to fit OASIS requested format 
     574echo ${Titre}"Update and complete weight files to fit OASIS requested format"${Norm} 
    536575## =========================================================================== 
    537576cat <<EOF > add_dim.nco 
     
    582621 
    583622## 
    584 ## Add missing variables in rmp files 
     623echo ${Titre}"Add missing variables in rmp files"${Norm} 
    585624## =========================================================================== 
    586625for $(ls rmpFile in rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc* 2>/dev/null) ; do 
     
    721760 
    722761## 
    723 ## Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc 
     762echo ${Titre}"Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc"${Norm} 
    724763## ============================================================================ 
    725764bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} 
     765 
     766 
     767 
     768## 
     769echo ${Titre}"Runoff weights"${Norm} 
     770## =========================================================================== 
     771if [[ "X${okRunoff}" = "Xyes" && "${atm}" = "lmd" ]] ; then 
     772    ${PyRun} python3 -u cotes_etal.py --oce=${OCE} --atm=${ATM} \ 
     773              --atmCoastWidth=${atmCoastWidth} --oceCoastWidth=${oceCoastWidth} --searchRadius=${searchRadius} \ 
     774              --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} 
     777fi 
     778 
     779## 
     780echo ${Titre}"Calving weights"${Norm} 
     781## =========================================================================== 
     782if [[ "X${okCalving}" = "Xyes" ]] ; then 
     783    case ${OCE} in 
     784        ( 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=. 
     788        ${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 
     790        ${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 
     792        ${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 
     794        ;; 
     795         
     796        ( eORCA1.2 ) 
     797        cp ${R_IN}/OCE/NEMO/ORCA1_LIM3_PISCES/v3.6_stable/runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc . 
     798        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth_${FMT_OASIS}.nc  --fmt=${FMT_OASIS}\ 
     799                  --oce=${OCE} --atm=${ATM} --type=nosouth  --dir=.  
     800        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg_${FMT_OASIS}.nc  --fmt=${FMT_OASIS}\ 
     801                  --oce=${OCE} --atm=${ATM} --type=iceberg  --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=Icb_flux 
     802        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf_${FMT_OASIS}.nc --fmt=${FMT_OASIS}\ 
     803                  --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=sornfisf 
     804        ;; 
     805         
     806        ( * ) 
     807        ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_full_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 
     808                  --oce=${OCE} --atm=${ATM} --type=full     --dir=. 
     809        ;; 
     810 
     811    esac 
     812fi 
     813 
     814## 
     815echo ${Titre}"Save results"${Norm} 
     816## =========================================================================== 
     817 
     818cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} 
     819for File in dia_*.nc rmp_*.nc  
     820do 
     821    ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File} 
     822    [[ "X${Comment}" != "X" ]] && ncatted --history --attribute Comment,global,o,c,"${Comment}"  ${File} 
     823    [[ "X${Version}" != "X" ]] && ncatted --history --attribute Version,global,o,c,"${Version}"  ${File} 
     824     
     825    NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) 
     826    cp ${File} ${SUBMIT_DIR}/${NewFile} 
     827done 
    726828 
    727829cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
     
    729831cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} 
    730832 
    731 ## 
    732 ## Calving weights 
    733 ## =========================================================================== 
    734 case ${OCE} in 
    735     ( eORCA025 ) 
    736     ccc_mprun -n 1 python -u CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=full     --dir=. 
    737     ;; 
    738      
    739     ( eORCA1.2 ) 
    740     cp ${R_IN}/OCE/NEMO/ORCA1_LIM3_PISCES/v3.6_stable/runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc . 
    741     ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=nosouth  --dir=.  
    742     ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=iceberg  --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=Icb_flux 
    743     ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=sornfisf 
    744     ;; 
    745      
    746     ( * ) 
    747     ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=full     --dir=. 
    748     ;; 
    749 esac 
    750  
    751 ## 
    752 ## Save results 
    753 ## =========================================================================== 
    754 cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} 
    755 for File in dia_*.nc rmp_*.nc 
    756 do 
    757     ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File} 
    758     NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) 
    759     cp ${File} ${SUBMIT_DIR}/${NewFile} 
    760 done 
    761  
    762 ## 
    763 ## Creates a README.txt file 
     833 
     834## 
     835echo ${Titre}"Creates a README.txt file"${Norm} 
    764836## =========================================================================== 
    765837[[ -f README.txt ]] && rm README.txt 
     
    802874echo '$HeadURL$ ' >> README.txt 
    803875 
    804 # Compute checksums and add thmer to README 
     876echo ${Titre}"Compute checksums and add them to README"${Norm} 
    805877# ----------------------------------------- 
    806878cat << EOF >> README.txt 
     
    824896## =========================================================================== 
    825897## 
    826 ##                               That's all folk's !!! 
    827 ## 
    828 ## =========================================================================== 
    829  
     898echo ${Titre}"     That's all folk's !!!    "${Norm} 
     899## 
     900## =========================================================================== 
     901 
Note: See TracChangeset for help on using the changeset viewer.