Changeset 4172


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

O.M. :

  • More documentation
  • Update run-off weights computation
  • Update calving weights computation
Location:
TOOLS/MOSAIX
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CalvingWeights.py

    r4159 r4172  
    4242parser.add_argument ('--repartition_file', help='Data files with iceberg melting' , type=str, default='./runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc' ) 
    4343parser.add_argument ('--repartition_var' , help='Variable name for iceshelf'      , type=str, default=None) 
     44parser.add_argument ('--output'  , help='output rmp file name', default='rmp_tlmd_to_torc_calving_64bit.nc' ) 
     45parser.add_argument ('--fmt'     , help='NetCDF file format, using nco syntax', default='64bits', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] ) 
    4446 
    4547# Parse command line 
     
    6365 
    6466nb_zone = len(limit_lat) 
     67 
     68if myargs.fmt == 'classic'         : FmtNetcdf = 'CLASSIC' 
     69if myargs.fmt == 'netcdf3'         : FmtNetcdf = 'CLASSIC' 
     70if myargs.fmt == '64bit'           : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 
     71if myargs.fmt == '64bit_data'      : FmtNetcdf = 'NETCDF3_64BIT_DATA' 
     72if myargs.fmt == '64bit_offset'    : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 
     73if myargs.fmt == 'netcdf4'         : FmtNetcdf = 'NETCDF4' 
     74if myargs.fmt == 'netcdf4_classic' : FmtNetcdf = 'NETCDF4_CLASSIC' 
    6575### ========================================================================================== 
    6676 
     
    258268        print ('  ') 
    259269 
     270 
     271 
    260272## End of loop 
    261273print (' ') 
     
    265277print ( 'Total num_links : {:10d}'.format(num_links) ) 
    266278 
     279# Diag : interpolate uniform field 
     280src_field = np.zeros(shape=(src_grid_size)) 
     281for n_bas in np.arange ( nb_zone ) : 
     282    index_src = ((src_grid_size - 1)*n_bas) // (nb_zone-1) + 1 
     283    src_field[index_src-1] = n_bas 
     284 
     285dst_field = np.zeros(shape=(dst_grid_size,)) 
     286for link in np.arange (num_links) : 
     287    dst_field [dst_address [link]-1] +=  remap_matrix[link] * src_field[src_address[link]-1] 
     288 
    267289### ===== Writing the weights file, for OASIS MCT ========================================== 
    268290 
    269291# Output file 
    270 calving = 'rmp_t' + src_Name + '_to_' + 't' + dst_Name + '_calving_' + myargs.type + '.nc' 
    271 f_calving = netCDF4.Dataset ( calving, 'w', format='NETCDF3_64BIT' ) 
    272  
     292calving = myargs.output 
     293f_calving = netCDF4.Dataset ( calving, 'w', format=FmtNetcdf ) 
     294     
    273295print ('Output file: ' + calving ) 
    274296 
     
    285307f_calving.title           = calving 
    286308f_calving.Program         = "Generated by " + sys.argv[0] + " with flags " + str(sys.argv[1:]) 
     309f_calving.repartitionType = myargs.type 
     310if myargs.type in ['iceberg', 'iceshelf' ] : 
     311    f_calving.repartitionFile = myargs.repartition_file 
     312    f_calving.repartitionVar  = repartitionVar 
     313f_calving.gridsFile       = grids 
     314f_calving.areasFile       = areas 
     315f_calving.masksFile       = masks 
    287316f_calving.timeStamp       = time.asctime() 
    288317f_calving.uuid            = f_areas.uuid 
     
    293322f_calving.release         = platform.release() 
    294323f_calving.hardware        = platform.machine() 
    295 f_calving.Comment         = "Preliminary attempt - Do not trust !" 
    296324f_calving.conventions     = "SCRIP" 
    297325if src_name == 'lmd' : f_calving.source_grid = "curvilinear" 
     
    381409v_dst_repartition[:] = key_repartition.reshape( (nb_zone,dst_grid_size) ) 
    382410 
    383 # Additoonnal fields for debugging 
     411# Additionnal fields for debugging 
    384412# ================================ 
    385413v_dst_grid_imaskutil      = f_calving.createVariable ( 'dst_grid_imaskutil'     , 'f8', ('dst_grid_size',)  ) 
     
    407435v_dst_imaskutil_addressed[:] = dst_mskutil.ravel()[dst_address-1].ravel() 
    408436 
     437v_src_field = f_calving.createVariable ( 'src_field', 'f8', ('src_grid_size',) ) 
     438v_dst_field = f_calving.createVariable ( 'dst_field', 'f8', ('dst_grid_size',) ) 
     439v_src_field[:] = src_field 
     440v_dst_field[:] = dst_field 
     441 
    409442f_calving.close () 
    410443 
  • TOOLS/MOSAIX/CreateOasisGrids.bash

    r3913 r4172  
    2525#  $HeadURL$ 
    2626 
    27 ## 
    28 ## Default configuration (may be overrided by command line parameters) 
     27set +vx 
     28 
     29echo ${Titre}"Starting CreateOasisGrids.bash"${Norm} 
     30 
     31## 
     32echo ${Titre}"Default configuration (may be overrided by command line parameters)"${Norm} 
    2933## =========================================================================== 
    3034OCE=ORCA2.3 
     
    3236ATM=ICO30 
    3337#ATM=ICO40 
    34 # ATM=ICO450 
    35 # ATM=LMD144142 
    36 # ATM=LMD9695 
     38#ATM=ICO450 
     39#ATM=LMD144142 
     40#ATM=LMD9695 
    3741 
    3842## =========================================================================== 
     
    4246## =========================================================================== 
    4347 
    44 # Defines computer 
     48echo ${Titre}"Defines computer"${Norm} 
    4549# ================ 
    4650if [[ $(hostname) = curie* ]]    ; then arch=curie ; center=tgcc ; fi 
     
    7276 
    7377## 
    74 ## Command line parameters 
     78echo ${Titre}"Command line parameters"${Norm} 
    7579## =========================================================================== 
    7680set -e 
     
    97101 
    98102## 
    99 ## Short names (grid names in Oasis)  
     103echo ${Titre}"Short names (grid names in Oasis)"${Norm} 
    100104## =========================================================================== 
    101105case ${OCE} in 
     
    111115 
    112116## 
    113 ## Get input files 
     117echo ${Titre}"Get input files"${Norm} 
    114118## =========================================================================== 
    115119[[ -f ${OCE}_coordinates_mask.nc ]] || cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  . 
     
    117121 
    118122# 
    119 # Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits 
     123echo ${Titre}"Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits"${Norm} 
    120124# --------------------------------------------------------------------------- 
    121125FL_FMT3=64bit 
    122126 
    123127# 
    124 # Cleaning 
     128echo ${Titre}"Cleaning"${Norm} 
    125129# ---------------------------------------------------------------------------- 
    126130rm -f grids_${CplModel}.nc masks_${CplModel}.nc areas_${CplModel}.nc 
     
    128132 
    129133# 
    130 # Creates NetCDF3 version of input files 
     134echo ${Titre}"Creates NetCDF3 version of input files"${Norm} 
    131135# ---------------------------------------------------------------------------- 
    132136ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc      ${OCE}_coordinates_mask_${FL_FMT3}.nc 
     
    135139 
    136140# 
    137 # Creates ocean fields 
     141echo ${Titre}"Creates ocean fields"${Norm} 
    138142# ---------------------------------------------------------------------------- 
    139143for OCEGRID in T U V ; do 
     
    162166  
    163167# 
    164 # We need to have different names for dimensions and variables 
     168echo ${Titre}"We need to have different names for dimensions and variables"${Norm} 
    165169# ---------------------------------------------------------------------------- 
    166170ncrename --history --variable lon,alon   grids_${CplModel}.nc 
     
    212216 
    213217# 
    214 # DYNAMICO grids : 
    215 #  - Set correct order of dimensions 
    216 #  - Add a dimension 
     218echo ${Titre}"DYNAMICO grids : 1) Set correct order of dimensions, 2) Add a dimension"${Norm} 
    217219# ---------------------------------------------------------------------------- 
    218220if [[ ${atm} = dynamico* || ${atm} = ico* ]] ; then 
     
    243245 
    244246# 
    245 # Some changes specific to LMDZ lon/lat grid 
     247echo ${Titre}"Some changes specific to LMDZ lon/lat grid"${Norm} 
    246248# ---------------------------------------------------------------------------- 
    247249if [[ ${atm} = lmd* ]] ; then 
    248     # Spreads lon and lat to get 2D fields 
     250    echo ${Titre}"Spreads lon and lat to get 2D fields"${Norm} 
    249251    # ----------------------------------------------------------------------- 
    250252    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
     
    261263            --attribute overlap,alat,o,i,0                grids_${CplModel}.nc 
    262264     
    263     # Generates cell corners 
     265    echo ${Titre}"Generates cell corners"${Norm} 
    264266    # ----------------------------------------------------------------------- 
    265267cat <<EOF > add_bounds.nco 
     
    290292 
    291293# 
    292 # Generates grid "o${atm}", "o" meaning "one": same as t${atm} grid, with surfaces set to 1 
     294echo ${Titre}"Generates grid o${atm}, 'o' meaning 'one'"${Norm} 
     295# same as t${atm} grid, with surfaces set to 1 
    293296# and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 
    294297# This grid is used when field are quantities instead of fluxes (i.e river flow) 
     
    306309 
    307310# 
    308 # Final renaming 
     311echo ${Titre}"Final renaming"${Norm} 
    309312# ---------------------------------------------------------------------------- 
    310313for OCEGRID in T U V 
     
    348351 
    349352## 
    350 ## Change all NetCDF files to NetCDF 3 format 
     353echo ${Titre}"Change all NetCDF files to NetCDF 3 format"${Norm} 
    351354## =========================================================================== 
    352355for InFile in areas_${CplModel}.nc grids_${CplModel}.nc masks_${CplModel}.nc ; do 
     
    359362 
    360363## 
    361 ## Add some useful information in NetCDF headers 
     364echo ${Titre}"Add some useful information in NetCDF headers"${Norm} 
    362365## =========================================================================== 
    363366UUID=$(uuid) 
     
    390393            --attribute release,global,o,c,"$(uname -r)"               \ 
    391394            --attribute hardware,global,o,c,"$(uname -i)"              \ 
    392             --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ 
    393395            --attribute SVN_Author,global,o,c,"$Author$"      \ 
    394396            --attribute SVN_Date,global,o,c,"$Date$" \ 
     
    399401done 
    400402 
    401 ## 
    402 ## Cleaning 
    403 ## =========================================================================== 
    404 #rm  *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc *.nco 
    405403 
    406404exit 
    407405# 
    408 # Name of the dimensions ?  
     406echo ${Titre}"Name of the dimensions ?"${Norm}  
    409407# ---------------------------------------------------------------------------- 
    410408for OCEGRID in T U V ; do 
     
    416414 
    417415## =========================================================================== 
    418 ## 
    419 ##                               That's all folk's !!! 
    420 ## 
    421 ## =========================================================================== 
     416echo ${Titre}"exit from CreateOasisGrids "${Norm} 
     417 
     418## =========================================================================== 
     419## 
     420echo ${Titre}"                  That's all folk's !!!   "${Norm} 
     421## 
     422## =========================================================================== 
  • 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 
  • TOOLS/MOSAIX/cotes_etal.py

    r4151 r4172  
    2525## 
    2626 
     27## Modules 
    2728import netCDF4 
    2829import numpy as np 
     
    3233 
    3334## Userful constants 
    34 zero = np.dtype('float64').type(0.0) 
    35 zone = np.dtype('float64').type(1.0) 
     35zero    = np.dtype('float64').type(0.0) 
     36zone    = np.dtype('float64').type(1.0) 
    3637epsfrac = np.dtype('float64').type(1.0E-10) 
    37 pi  = np.pi 
    38 rad = pi/np.dtype('float64').type(180.0) 
    39 ra = np.dtype('float64').type(6400000.0) # Earth radius 
     38pi      = np.pi 
     39rad     = pi/np.dtype('float64').type(180.0) 
     40ra      = np.dtype('float64').type(6371229.0) # Earth radius 
    4041 
    4142## Functions 
     
    4748      return geodist 
    4849 
    49  
    50     
    51  
    5250### ===== Reading command line parameters ================================================== 
    5351# Creating a parser 
     
    5755 
    5856# Adding arguments 
    59 parser.add_argument ('--oce'   , help='oce model name', type=str, default='eORCA1.2', choices=['ORCA2.3', 'eORCA1.2', 'eORCA025'] ) 
    60 parser.add_argument ('--atm'   , help='atm model name (LMD*)', type=str, default='LMD9695'    ) 
    61 parser.add_argument ('--atmCoastWidth', help='width of the coastal band in atmosphere (in grid points)', default=1 ) 
    62 parser.add_argument ('--oceCoastWidth', help='width of the coastal band in ocean (in grid points)'     , default=2 ) 
    63 parser.add_argument ('--grids', help='grids file name', default='grids.nc' ) 
    64 parser.add_argument ('--areas', help='masks file name', default='areas.nc' ) 
    65 parser.add_argument ('--masks', help='areas file name', default='masks.nc' ) 
    66 parser.add_argument ('--o2a'  , help='o2a file name', default='o2a.nc' ) 
    67 parser.add_argument ('--output', help='output rmp file name', default='rmp_tlmd_to_torc_runoff.nc' ) 
     57parser.add_argument ('--oce'          , help='oce model name', type=str, default='eORCA1.2', choices=['ORCA2.3', 'eORCA1.2', 'eORCA025'] ) 
     58parser.add_argument ('--atm'          , help='atm model name (LMD*)', type=str, default='LMD9695'    ) 
     59parser.add_argument ('--atmCoastWidth', help='width of the coastal band in atmosphere (in grid points)', type=int, default=1 ) 
     60parser.add_argument ('--oceCoastWidth', help='width of the coastal band in ocean (in grid points)'     , type=int, default=2 ) 
     61parser.add_argument ('--searchRadius' , help='max distance to connect a land point to an ocean point (in km)', type=float, default=600000.0) 
     62parser.add_argument ('--grids' , help='grids file name', default='grids.nc' ) 
     63parser.add_argument ('--areas' , help='masks file name', default='areas.nc' ) 
     64parser.add_argument ('--masks' , help='areas file name', default='masks.nc' ) 
     65parser.add_argument ('--o2a'   , help='o2a file name'  , default='o2a.nc' ) 
     66parser.add_argument ('--output', help='output rmp file name', default='rmp_tlmd_to_torc_runoff_64bit.nc' ) 
     67parser.add_argument ('--fmt'   , help='NetCDF file format, using nco syntax', default='64bit', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] ) 
    6868 
    6969# Parse command line 
     
    8383# Width of the coastal band (ocean points) in the ocean  
    8484oceCoastWidth = myargs.oceCoastWidth 
    85  
     85searchRadius  = myargs.searchRadius * 1000.0 # From km to meters 
     86# Netcdf format 
     87if myargs.fmt == 'classic'         : FmtNetcdf = 'CLASSIC' 
     88if myargs.fmt == 'netcdf3'         : FmtNetcdf = 'CLASSIC' 
     89if myargs.fmt == '64bit'           : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 
     90if myargs.fmt == '64bit_data'      : FmtNetcdf = 'NETCDF3_64BIT_DATA' 
     91if myargs.fmt == '64bit_offset'    : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 
     92if myargs.fmt == 'netcdf4'         : FmtNetcdf = 'NETCDF4' 
     93if myargs.fmt == 'netcdf4_classic' : FmtNetcdf = 'NETCDF4_CLASSIC' 
    8694 
    8795### Read coordinates of all models 
     
    93101maskFile   = netCDF4.Dataset ( masks ) 
    94102 
    95 o2aFrac             = diaFile ['field01_dst'][:].filled() 
     103o2aFrac             = diaFile ['OceFrac'][:].squeeze() 
    96104o2aFrac = np.where ( np.abs(o2aFrac) < 1E10, o2aFrac, 0.0) 
    97105 
    98 atm_grid_center_lat = gridFile['tlmd.lat'][:].filled() 
    99 atm_grid_center_lon = gridFile['tlmd.lon'][:].filled() 
    100 atm_grid_corner_lat = gridFile['tlmd.cla'][:].filled() 
    101 atm_grid_corner_lon = gridFile['tlmd.clo'][:].filled() 
    102  
    103 atm_grid_area       = areaFile['tlmd.srf'][:].filled() 
    104 atm_grid_imask      = 1-maskFile['tlmd.msk'][:].squeeze().filled() 
     106atm_grid_center_lat = gridFile['tlmd.lat'][:] 
     107atm_grid_center_lon = gridFile['tlmd.lon'][:] 
     108atm_grid_corner_lat = gridFile['tlmd.cla'][:] 
     109atm_grid_corner_lon = gridFile['tlmd.clo'][:] 
     110 
     111atm_grid_area       = areaFile['tlmd.srf'][:] 
     112atm_grid_imask      = 1-maskFile['tlmd.msk'][:].squeeze() 
    105113atm_grid_dims       = atm_grid_area.shape 
    106114(atm_nvertex, atm_jpj, atm_jpi) = atm_grid_corner_lat.shape 
     
    110118atm_grid_size = atm_jpj*atm_jpi 
    111119 
    112 oce_grid_center_lat = gridFile['torc.lat'][:].filled() 
    113 oce_grid_center_lon = gridFile['torc.lon'][:].filled() 
    114 oce_grid_corner_lat = gridFile['torc.cla'][:].filled() 
    115 oce_grid_corner_lon = gridFile['torc.clo'][:].filled() 
    116 oce_grid_area       = areaFile['torc.srf'][:].filled() 
    117 oce_grid_imask      = 1-maskFile['torc.msk'][:].filled() 
     120oce_grid_center_lat = gridFile['torc.lat'][:] 
     121oce_grid_center_lon = gridFile['torc.lon'][:] 
     122oce_grid_corner_lat = gridFile['torc.cla'][:] 
     123oce_grid_corner_lon = gridFile['torc.clo'][:] 
     124oce_grid_area       = areaFile['torc.srf'][:] 
     125oce_grid_imask      = 1-maskFile['torc.msk'][:] 
    118126oce_grid_dims       = oce_grid_area.shape 
    119127(oce_nvertex, oce_jpj, oce_jpi) = oce_grid_corner_lat.shape ; jpon=oce_jpj*oce_jpj 
     
    151159oceCoast_address         = oce_address        [oceCoast] 
    152160 
    153  
    154161print ("Determination d'une bande cotiere atmosphere " ) 
    155162atmLand      = np.where (o2aFrac[:] < epsfrac       , True, False) 
     
    183190for ja in np.arange(len(atmCoast_grid_pmask)) : 
    184191    z_dist = geodist ( atmCoast_grid_center_lon[ja], atmCoast_grid_center_lat[ja], oceCoast_grid_center_lon, oceCoast_grid_center_lat) 
    185     z_mask = np.where ( z_dist*ra < 600000.0, True, False) 
     192    z_mask = np.where ( z_dist*ra < searchRadius, True, False) 
    186193    num_links = z_mask.sum() 
    187194    if num_links == 0 : continue 
    188195    z_area = oceCoast_grid_area[z_mask].sum() 
    189196    poids = 1.0 / z_area 
    190     print ( num_links, z_mask.sum(), z_area ) 
     197    #print ( num_links, z_mask.sum(), z_area ) 
    191198    # 
    192199    matrix_local     = np.ones ((num_links),dtype=np.float64) * poids 
     
    199206    atm_address  = np.append ( atm_address , atm_address_local ) 
    200207    oce_address  = np.append ( oce_address , oce_address_local ) 
    201          
    202208 
    203209print ('End of loop') 
     
    207213### Output file 
    208214runoff = myargs.output 
    209 f_runoff = netCDF4.Dataset ( runoff, 'w', format='NETCDF3_64BIT' ) 
    210  
     215f_runoff = netCDF4.Dataset ( runoff, 'w', format=FmtNetcdf ) 
    211216print ('Output file: ' + runoff ) 
    212217 
     
    222227f_runoff.title           = runoff 
    223228f_runoff.Program         = "Generated by " + sys.argv[0] + " with flags " + str(sys.argv[1:]) 
     229f_runoff.atmCoastWidth   = str(atmCoastWidth) + " grid points" 
     230f_runoff.oceCoastWidth   = str(oceCoastWidth) + " grid points" 
     231f_runoff.searchRadius    = str(searchRadius/1000.) + " km" 
     232f_runoff.gridsFile       = grids 
     233f_runoff.areasFile       = areas 
     234f_runoff.masksFile       = masks 
     235f_runoff.o2aFile         = o2a 
    224236f_runoff.timeStamp       = time.asctime() 
    225237f_runoff.uuid            = areaFile.uuid 
     
    230242f_runoff.release         = platform.release() 
    231243f_runoff.hardware        = platform.machine() 
    232 f_runoff.Comment         = "Preliminary attempt - Do not trust !" 
    233244f_runoff.conventions     = "SCRIP" 
    234245f_runoff.source_grid     = "curvilinear" 
     
    241252f_runoff.SVN_HeadURL     = "$HeadURL$" 
    242253 
    243 num_links        = f_runoff.createDimension ('num_links'       , num_links ) 
    244 num_wgts         = f_runoff.createDimension ('num_wgts'        ,         1 ) 
    245  
    246 atm_grid_size    = f_runoff.createDimension ('src_grid_size'   , atm_grid_size ) 
    247 atm_grid_corners = f_runoff.createDimension ('src_grid_corners', atm_grid_corner_lon.shape[0]  ) 
    248 atm_grid_rank    = f_runoff.createDimension ('src_grid_rank'   ,        2  ) 
    249  
    250 oce_grid_size    = f_runoff.createDimension ('dst_grid_size'   , oce_grid_size ) 
    251 oce_grid_corners = f_runoff.createDimension ('dst_grid_corners', oce_grid_corner_lon.shape[0] ) 
    252 oce_grid_rank    = f_runoff.createDimension ('dst_grid_rank'   ,        2  ) 
     254d_num_links        = f_runoff.createDimension ('num_links'       , num_links ) 
     255d_num_wgts         = f_runoff.createDimension ('num_wgts'        ,         1 ) 
     256 
     257d_atm_grid_size    = f_runoff.createDimension ('src_grid_size'   , atm_grid_size ) 
     258d_atm_grid_corners = f_runoff.createDimension ('src_grid_corners', atm_grid_corner_lon.shape[0]  ) 
     259d_atm_grid_rank    = f_runoff.createDimension ('src_grid_rank'   ,        2  ) 
     260 
     261d_oce_grid_size    = f_runoff.createDimension ('dst_grid_size'   , oce_grid_size ) 
     262d_oce_grid_corners = f_runoff.createDimension ('dst_grid_corners', oce_grid_corner_lon.shape[0] ) 
     263d_oce_grid_rank    = f_runoff.createDimension ('dst_grid_rank'   ,        2  ) 
    253264 
    254265v_remap_matrix = f_runoff.createVariable ( 'remap_matrix', 'f8', ('num_links', 'num_wgts') ) 
     
    280291v_atm_grid_center_lon[:] = atm_grid_center_lon[:].ravel() 
    281292v_atm_grid_center_lat[:] = atm_grid_center_lat[:].ravel() 
    282 v_atm_grid_corner_lon[:] = atm_grid_corner_lon.reshape( (atm_jpi*atm_jpj, atm_grid_corners.__len__()) ) 
    283 v_atm_grid_corner_lat[:] = atm_grid_corner_lat.reshape( (atm_jpi*atm_jpj, atm_grid_corners.__len__()) ) 
     293v_atm_grid_corner_lon[:] = atm_grid_corner_lon.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) ) 
     294v_atm_grid_corner_lat[:] = atm_grid_corner_lat.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) ) 
    284295v_atm_grid_area      [:] = atm_grid_area[:].ravel() 
    285296v_atm_grid_imask     [:] = atm_grid_imask[:].ravel() 
     
    307318v_oce_grid_center_lon[:] = oce_grid_center_lon[:].ravel() 
    308319v_oce_grid_center_lat[:] = oce_grid_center_lat[:].ravel() 
    309 v_oce_grid_corner_lon[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, oce_grid_corners.__len__()) ) 
    310 v_oce_grid_corner_lat[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, oce_grid_corners.__len__()) ) 
     320v_oce_grid_corner_lon[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) ) 
     321v_oce_grid_corner_lat[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) ) 
    311322v_oce_grid_area      [:] = oce_grid_area[:].ravel() 
    312323v_oce_grid_imask     [:] = oce_grid_imask[:].ravel() 
    313324v_oce_grid_pmask     [:] = oce_grid_pmask[:].ravel() 
    314325 
    315 ## For diag, not used by OASIS 
    316326v_atm_lon_addressed   = f_runoff.createVariable ( 'src_lon_addressed'  , 'f8', ('num_links',) ) 
    317327v_atm_lat_addressed   = f_runoff.createVariable ( 'src_lat_addressed'  , 'f8', ('num_links',) ) 
     
    368378v_oceCoast[:]     = oceCoast.ravel() 
    369379 
    370 f_runoff.close () 
     380f_runoff.sync () 
     381 
     382##  
     383f_runoff.close() 
     384 
     385print ('The end') 
     386 
     387## ====================================================================================== 
  • TOOLS/MOSAIX/rangement.bash

    r4153 r4172  
    1717# ============================================================ 
    1818 
    19 for ATM in LMD144142 LMD9695 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 
     19for ATM in LMD144142 LMD9695 LMD256256 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 
    2020do 
    21     for OCE in ORCA2.3 eORCA1.2 ORCA025 
     21    for OCE in ORCA2.3 eORCA1.2 eORCA025 ORCA025  
    2222    do 
    2323        Liste=$(ls README_${OCE}x${ATM}.txt *${ATM}*_*${OCE}*.nc *${OCE}*_*${ATM}*.nc  *${ATM}x${OCE}*.nc *${OCE}x${ATM}*.nc 2> /dev/null  ) 
Note: See TracChangeset for help on using the changeset viewer.