Ignore:
Timestamp:
06/07/18 15:59:11 (6 years ago)
Author:
omamce
Message:

O.M. : add weight for coastal points only, to prepare computation

of weights for river run-off

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateOasisGrids.bash

    r3718 r3901  
    4444# Defines computer 
    4545# ================ 
    46 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 
    47 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 
     46if [[ $(hostname) = curie* ]]    ; then arch=curie ; center=tgcc ; fi 
     47if [[ $(hostname) = irene* ]]    ; then arch=irene ; center=tgcc ; fi 
     48if [[ $(hostname) = lsce3005* ]] ; then arch=spip  ; center=spip ; fi 
     49 
    4850PROGRAM=$(basename ${0}) 
    4951 
     
    6062    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
    6163    ;; 
    62     ( * ) 
    63     exit -1 
    64     ;; 
     64    ( spip ) 
     65    R_IN=${HOME}/Scratch/IGCM 
     66    TMPDIR=${HOME}/Scratch/TMP 
     67    SUBMIT_DIR=$(pwd) 
     68    MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 
     69    ;;  
     70    ( * ) exit -1 ;; 
    6571esac 
     72 
    6673## 
    6774## Command line parameters 
     
    112119# Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits 
    113120# --------------------------------------------------------------------------- 
    114 FL_FMT=64bit 
     121FL_FMT3=64bit 
    115122 
    116123# 
     
    123130# Creates NetCDF3 version of input files 
    124131# ---------------------------------------------------------------------------- 
    125 ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc      ${OCE}_coordinates_mask_${FL_FMT}.nc 
    126 ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc  ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc 
     132ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc      ${OCE}_coordinates_mask_${FL_FMT3}.nc 
     133ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc  ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc 
     134 
     135 
    127136# 
    128137# Creates ocean fields 
    129138# ---------------------------------------------------------------------------- 
    130  
    131 for OCEGRID in T U V ; do 
    132     ncks --fl_fmt=${FL_FMT} -C --history --append --variable nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc grids_${CplModel}.nc 
    133     ncks --fl_fmt=${FL_FMT} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc areas_${CplModel}.nc 
     139for OCEGRID in T U V C ; do 
     140    ncks --fl_fmt=${FL_FMT3} -C --history --append --variable nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc grids_${CplModel}.nc 
     141    ncks --fl_fmt=${FL_FMT3} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc areas_${CplModel}.nc 
    134142    # Inverts mask values and switch to integer 
    135     ncks --fl_fmt=${FL_FMT} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc 
     143    ncks --fl_fmt=${FL_FMT33} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc mask_${OCEGRID}_tmp.nc 
    136144    ncatted --history \ 
    137145            --attribute coordinates,mask_${OCEGRID},d,,         \ 
     
    140148    mask_${OCEGRID}_tmp.nc 
    141149     
    142     ncap2 --fl_fmt=${FL_FMT} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});"    mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 
     150    ncap2 --fl_fmt=${FL_FMT3} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});"    mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 
     151    rm mask_${OCEGRID}_tmp.nc 
    143152    ncatted --history \ 
    144153            --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \ 
     
    147156    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    148157    ncpdq --permute nvertex_grid_${OCEGRID},y_grid_${OCEGRID},x_grid_${OCEGRID} grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    149 done 
    150  
    151 ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 
    152  
     158    rm grids_${CplModel}_tmp.nc 
     159done 
     160 
     161ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc 
     162  
    153163# 
    154164# We need to have different names for dimensions and variables 
     
    158168 
    159169if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then  
    160     ncks --fl_fmt=${FL_FMT} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 
     170    ncks --fl_fmt=${FL_FMT3} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc 
    161171fi 
    162172 
    163 ncks --fl_fmt=${FL_FMT} --history -C --append --variable aire   ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc 
     173ncks --fl_fmt=${FL_FMT3} --history -C --append --variable aire   ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc areas_${CplModel}.nc 
    164174ncatted --history --attribute coordinates,aire,d,,     \ 
    165175        --attribute _FillValue,aire,d,,                \ 
     
    170180        areas_${CplModel}.nc 
    171181 
    172 ncks --fl_fmt=${FL_FMT} --history -C --variable OceMask         ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc 
     182ncks --fl_fmt=${FL_FMT3} --history -C --variable OceMask         ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc OceMask_tmp.nc 
    173183ncatted --history \ 
    174184        --attribute coordinates,OceMask,d,,         \ 
     
    177187        --attribute missing_value,OceMask,d,,       \ 
    178188        OceMask_tmp.nc 
    179 ncap2 --fl_fmt=${FL_FMT} --history --append --script "OceMask=int(1-OceMask)"            OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 
     189ncap2 --fl_fmt=${FL_FMT3} --history --append --script "OceMask=int(1-OceMask)"            OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 
     190rm OceMask_tmp.nc 
    180191ncatted --history \ 
    181192        --attribute long_name,OceMask,o,c,"Land-sea mask"   \ 
     
    220231EOF 
    221232     
    222     ncap2 --fl_fmt=${FL_FMT} --history --append --script-file add_dim.nco  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     233    ncap2 --fl_fmt=${FL_FMT3} --history --append --script-file add_dim.nco  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    223234     
    224235    mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
    225     ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)'  masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
     236    ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)'  masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
    226237 
    227238    mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
    228     ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; '                       areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     239    ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; '                    areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     240 
     241    rm -f grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 
    229242fi 
    230243 
     
    236249    # ----------------------------------------------------------------------- 
    237250    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    238     ncap2 --fl_fmt=${FL_FMT} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat"  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     251    ncap2 --fl_fmt=${FL_FMT3} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat"  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     252    rm -f grids_${CplModel}_tmp.nc 
    239253    ncatted --history \ 
    240254            --attribute long_name,alon,o,c,"Longitude"    \ 
     
    271285EOF 
    272286    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    273     ncap2 --fl_fmt=${FL_FMT} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     287    ncap2 --fl_fmt=${FL_FMT3} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     288    rm grids_${CplModel}_tmp.nc 
    274289fi 
    275290 
    276291# 
    277 # Generates grid "o${atm}e" : same as t${atm} grid, with surfaces set to 1 
     292# Generates grid "o${atm}", "o" meaning "one": same as t${atm} grid, with surfaces set to 1 
    278293# and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 
    279294# This grid is used when field are quantities instead of fluxes (i.e river flow) 
    280295# ---------------------------------------------------------------------------- 
    281296mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    282 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_lon=alon; o${atm}_lat=alat; bounds_o${atm}_lon=bounds_lon; bounds_o${atm}_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     297ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_lon=alon; o${atm}_lat=alat; bounds_o${atm}_lon=bounds_lon; bounds_o${atm}_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    283298 
    284299mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
    285 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_aire=aire*0.0d+1.0d; "   areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     300ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_aire=aire*0.0d+1.0d; "   areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
    286301 
    287302mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
    288 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
     303ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
     304 
     305rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 
    289306 
    290307# 
    291308# Final renaming 
    292309# ---------------------------------------------------------------------------- 
    293 for OCEGRID in T U V 
     310for OCEGRID in T U V C 
    294311do 
    295312    ocegrid=${OCEGRID~} # To lowercase 
     
    336353    if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then 
    337354        mv ${InFile} tmp_${InFile} 
    338         ncks --fl_fmt=${FL_FMT} --history  tmp_${InFile}  ${InFile} 
     355        ncks --fl_fmt=${FL_FMT3} --history  tmp_${InFile} ${InFile} 
     356        rm tmp_${InFile} 
    339357    fi 
    340358done 
     
    384402## Cleaning 
    385403## =========================================================================== 
    386 #rm  *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc *.nco 
     404#rm  *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc *.nco 
    387405 
    388406exit 
     
    390408# Name of the dimensions ?  
    391409# ---------------------------------------------------------------------------- 
    392 for OCEGRID in T U V ; do 
     410for OCEGRID in T U V C ; do 
    393411    ocegrid=${OCEGRID~} # Downcase name of grids 
    394412    ncrename --history --dimension  x_grid_${OCEGRID},x${ocegrid}${oce}         grids_${CplModel}.nc 
Note: See TracChangeset for help on using the changeset viewer.