Ignore:
Timestamp:
03/23/18 10:55:23 (6 years ago)
Author:
omamce
Message:

O.M. : correct OIceFrc variable name.
More documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateOasisGrids.bash

    r3665 r3686  
    6767## Command line parameters 
    6868## =========================================================================== 
     69set -e 
    6970set -o verbose 
    7071set -o xtrace 
     
    106107## =========================================================================== 
    107108[[ -f ${OCE}_coordinates_mask.nc ]] || cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  . 
    108 [[ -f ${ATM}_grid.nc             ]] || cp ${R_IN}/ATM/${ATM}/${ATM}_grid.nc                   . 
     109[[ -f ${ATM}_grid.nc             ]] || cp ${R_IN}/ATM/GRID/${ATM}_grid.nc                   . 
    109110 
    110111# 
     
    129130 
    130131for OCEGRID in T U V ; do 
    131     ncks --fl_fmt=${FL_FMT} -C --history --append -v 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 
    132     ncks --fl_fmt=${FL_FMT} -C --history --append -v area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc areas_${CplModel}.nc 
     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 
    133134    # Inverts mask values and switch to integer 
    134     ncks --fl_fmt=${FL_FMT} --history -C -v mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc 
     135    ncks --fl_fmt=${FL_FMT} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc 
    135136    ncatted --history \ 
    136137            --attribute coordinates,mask_${OCEGRID},d,,         \ 
     
    139140    mask_${OCEGRID}_tmp.nc 
    140141     
    141     ncap2 --fl_fmt=${FL_FMT} --history --append -s "mask_${OCEGRID}=int(1-mask_${OCEGRID});"    mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 
     142    ncap2 --fl_fmt=${FL_FMT} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});"    mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 
    142143    ncatted --history \ 
    143144            --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \ 
     
    148149done 
    149150 
    150 ncks --history --append -v lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 
     151ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 
    151152 
    152153# 
    153154# We need to have different names for dimensions and variables 
    154155# ---------------------------------------------------------------------------- 
    155 ncrename --history -v lon,alon   grids_${CplModel}.nc 
    156 ncrename --history -v lat,alat   grids_${CplModel}.nc 
     156ncrename --history --variable lon,alon   grids_${CplModel}.nc 
     157ncrename --history --variable lat,alat   grids_${CplModel}.nc 
    157158 
    158159if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then  
    159     ncks --fl_fmt=${FL_FMT} --history --append -v bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 
     160    ncks --fl_fmt=${FL_FMT} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 
    160161fi 
    161162 
    162 ncks --fl_fmt=${FL_FMT} --history -C --append -v aire   ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc 
     163ncks --fl_fmt=${FL_FMT} --history -C --append --variable aire   ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc 
    163164ncatted --history --attribute coordinates,aire,d,,     \ 
    164165        --attribute _FillValue,aire,d,,                \ 
     
    169170        areas_${CplModel}.nc 
    170171 
    171 ncks --fl_fmt=${FL_FMT} --history -C -v OceMask         ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc 
     172ncks --fl_fmt=${FL_FMT} --history -C --variable OceMask         ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc 
    172173ncatted --history \ 
    173174        --attribute coordinates,OceMask,d,,         \ 
     
    176177        --attribute missing_value,OceMask,d,,       \ 
    177178        OceMask_tmp.nc 
    178 ncap2 --fl_fmt=${FL_FMT} --history --append -s "OceMask=int(1-OceMask)"            OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 
     179ncap2 --fl_fmt=${FL_FMT} --history --append --script "OceMask=int(1-OceMask)"            OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 
    179180ncatted --history \ 
    180181        --attribute long_name,OceMask,o,c,"Land-sea mask"   \ 
     
    186187 
    187188if [[ ${atm} = *dynamico* || ${atm} = ico* ]] ; then 
    188     ncrename --history -d cell,ycell grids_${CplModel}.nc 
    189     ncrename --history -d cell,ycell areas_${CplModel}.nc 
    190     ncrename --history -d cell,ycell masks_${CplModel}.nc 
     189    ncrename --history --dimension cell,ycell grids_${CplModel}.nc 
     190    ncrename --history --dimension cell,ycell areas_${CplModel}.nc 
     191    ncrename --history --dimension cell,ycell masks_${CplModel}.nc 
    191192fi 
    192193# if [[ ${atm} = *lmd* ]] ; then 
    193 #     ncrename -d lon,tlmdlon  grids_${CplModel}.nc 
    194 #     ncrename -d lat,tlmdlat  grids_${CplModel}.nc 
    195 #     ncrename -d lon,tlmdlon  masks_${CplModel}.nc 
    196 #     ncrename -d lat,tlmdlat  masks_${CplModel}.nc 
    197 #     ncrename -d lon,tlmdlon  areas_${CplModel}.nc 
    198 #     ncrename -d lat,tlmdlat  areas_${CplModel}.nc 
     194#     ncrename --dimension lon,tlmdlon  grids_${CplModel}.nc 
     195#     ncrename --dimension lat,tlmdlat  grids_${CplModel}.nc 
     196#     ncrename --dimension lon,tlmdlon  masks_${CplModel}.nc 
     197#     ncrename --dimension lat,tlmdlat  masks_${CplModel}.nc 
     198#     ncrename --dimension lon,tlmdlon  areas_${CplModel}.nc 
     199#     ncrename --dimension lat,tlmdlat  areas_${CplModel}.nc 
    199200# fi 
    200201 
     
    219220EOF 
    220221     
    221     ncap2 --fl_fmt=${FL_FMT} --history --append -S add_dim.nco  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     222    ncap2 --fl_fmt=${FL_FMT} --history --append --script-file add_dim.nco  grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    222223     
    223224    mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
    224     ncap2 --fl_fmt=${FL_FMT} --history --append -s 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)'  masks_${CplModel}_tmp.nc masks_${CplModel}.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 
    225226 
    226227    mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
    227     ncap2 --fl_fmt=${FL_FMT} --history --append -s 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; '                       areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     228    ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; '                       areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
    228229fi 
    229230 
     
    235236    # ----------------------------------------------------------------------- 
    236237    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    237     ncap2 --fl_fmt=${FL_FMT} --history --append -s "alon[lat,lon]=alon; alat[lat,lon]=alat"  grids_${CplModel}_tmp.nc grids_${CplModel}.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 
    238239    ncatted --history \ 
    239240            --attribute long_name,alon,o,c,"Longitude"    \ 
     
    270271EOF 
    271272    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    272     ncap2 --fl_fmt=${FL_FMT} --history -S add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     273    ncap2 --fl_fmt=${FL_FMT} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
    273274fi 
    274275 
    275276# 
    276 # Generates grid "aone" : same as t-ocean grid, with surfaces set to 1 
     277# Generates grid "o${atm}e" : same as t${atm} grid, with surfaces set to 1 
     278# and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 
    277279# This grid is used when field are quantities instead of fluxes (i.e river flow) 
    278280# ---------------------------------------------------------------------------- 
    279281mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 
    280 ncap2 --fl_fmt=${FL_FMT} --history -s "aone_lon=alon; aone_lat=alat; bounds_aone_lon=bounds_lon; bounds_aone_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 
     282ncap2 --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 
    281283 
    282284mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 
    283 ncap2 --fl_fmt=${FL_FMT} --history -s "aone_aire=aire*0+1; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
     285ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_aire=aire*0.0d+1.0d; "  areas_${CplModel}_tmp.nc areas_${CplModel}.nc 
    284286 
    285287mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 
    286 ncap2 --fl_fmt=${FL_FMT} --history -s "aone_mask=int(OceMask); " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
     288ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 
    287289 
    288290# 
     
    292294do 
    293295    ocegrid=${OCEGRID~} # To lowercase 
    294     ncrename --history -v nav_lon_grid_${OCEGRID},${ocegrid}${oce}.lon     grids_${CplModel}.nc 
    295     ncrename --history -v nav_lat_grid_${OCEGRID},${ocegrid}${oce}.lat     grids_${CplModel}.nc 
    296     ncrename --history -v bounds_lon_grid_${OCEGRID},${ocegrid}${oce}.clo  grids_${CplModel}.nc 
    297     ncrename --history -v bounds_lat_grid_${OCEGRID},${ocegrid}${oce}.cla  grids_${CplModel}.nc 
    298     ncrename --history -v mask_${OCEGRID},${ocegrid}${oce}.msk             masks_${CplModel}.nc 
    299     ncrename --history -v area_grid_${OCEGRID},${ocegrid}${oce}.srf        areas_${CplModel}.nc 
     296    ncrename --history --variable nav_lon_grid_${OCEGRID},${ocegrid}${oce}.lon     grids_${CplModel}.nc 
     297    ncrename --history --variable nav_lat_grid_${OCEGRID},${ocegrid}${oce}.lat     grids_${CplModel}.nc 
     298    ncrename --history --variable bounds_lon_grid_${OCEGRID},${ocegrid}${oce}.clo  grids_${CplModel}.nc 
     299    ncrename --history --variable bounds_lat_grid_${OCEGRID},${ocegrid}${oce}.cla  grids_${CplModel}.nc 
     300    ncrename --history --variable mask_${OCEGRID},${ocegrid}${oce}.msk             masks_${CplModel}.nc 
     301    ncrename --history --variable area_grid_${OCEGRID},${ocegrid}${oce}.srf        areas_${CplModel}.nc 
    300302     
    301303    ncatted --history \ 
     
    306308done 
    307309 
    308 ncrename --history -v alon,t${atm}.lon           grids_${CplModel}.nc 
    309 ncrename --history -v alat,t${atm}.lat           grids_${CplModel}.nc 
    310 ncrename --history -v aone_lon,o${atm}.lon       grids_${CplModel}.nc 
    311 ncrename --history -v aone_lat,o${atm}.lat       grids_${CplModel}.nc 
    312 ncrename --history -v OceMask,t${atm}.msk        masks_${CplModel}.nc 
    313 ncrename --history -v aone_mask,o${atm}.msk      masks_${CplModel}.nc 
    314 ncrename --history -v aire,t${atm}.srf           areas_${CplModel}.nc 
    315 ncrename --history -v aone_aire,o${atm}.srf      areas_${CplModel}.nc 
    316  
    317 ncrename --history -v bounds_lon,t${atm}.clo        grids_${CplModel}.nc 
    318 ncrename --history -v bounds_lat,t${atm}.cla        grids_${CplModel}.nc 
    319 ncrename --history -v bounds_aone_lon,o${atm}.clo   grids_${CplModel}.nc 
    320 ncrename --history -v bounds_aone_lat,o${atm}.cla   grids_${CplModel}.nc 
     310ncrename --history --variable alon,t${atm}.lon                grids_${CplModel}.nc 
     311ncrename --history --variable alat,t${atm}.lat                grids_${CplModel}.nc 
     312ncrename --history --variable o${atm}_lon,o${atm}.lon         grids_${CplModel}.nc 
     313ncrename --history --variable o${atm}_lat,o${atm}.lat         grids_${CplModel}.nc 
     314ncrename --history --variable OceMask,t${atm}.msk             masks_${CplModel}.nc 
     315ncrename --history --variable o${atm}_mask,o${atm}.msk        masks_${CplModel}.nc 
     316ncrename --history --variable aire,t${atm}.srf                areas_${CplModel}.nc 
     317ncrename --history --variable o${atm}_aire,o${atm}.srf        areas_${CplModel}.nc 
     318 
     319ncrename --history --variable bounds_lon,t${atm}.clo          grids_${CplModel}.nc 
     320ncrename --history --variable bounds_lat,t${atm}.cla          grids_${CplModel}.nc 
     321ncrename --history --variable bounds_o${atm}_lon,o${atm}.clo  grids_${CplModel}.nc 
     322ncrename --history --variable bounds_o${atm}_lat,o${atm}.cla  grids_${CplModel}.nc 
    321323 
    322324for atmgrid in t o ; do 
     
    324326            --attribute bounds,${atmgrid}${atm}.lon,c,c,"${atmgrid}${atm}.clo"   \ 
    325327            --attribute bounds,${atmgrid}${atm}.lat,c,c,"${atmgrid}${atm}.cla"   \ 
    326             --attribute units,${atmgrid}${atm}.clo,o,c,"degrees_east"         \ 
     328            --attribute units,${atmgrid}${atm}.clo,o,c,"degrees_east"            \ 
    327329            --attribute units,${atmgrid}${atm}.cla,o,c,"degrees_north"        grids_${CplModel}.nc 
    328330done 
     
    389391for OCEGRID in T U V ; do 
    390392    ocegrid=${OCEGRID~} # Downcase name of grids 
    391     ncrename --history -d  x_grid_${OCEGRID},x${ocegrid}${oce}         grids_${CplModel}.nc 
    392     ncrename --history -d  y_grid_${OCEGRID},y${ocegrid}${oce}         grids_${CplModel}.nc 
    393     ncrename --history -d  nvertex_grid_${OCEGRID},crn${ocegrid}${oce} grids_${CplModel}.nc 
     393    ncrename --history --dimension  x_grid_${OCEGRID},x${ocegrid}${oce}         grids_${CplModel}.nc 
     394    ncrename --history --dimension  y_grid_${OCEGRID},y${ocegrid}${oce}         grids_${CplModel}.nc 
     395    ncrename --history --dimension  nvertex_grid_${OCEGRID},crn${ocegrid}${oce} grids_${CplModel}.nc 
    394396done 
    395397 
Note: See TracChangeset for help on using the changeset viewer.