Changeset 3901


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

Location:
TOOLS/MOSAIX
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/ComputeNemoCoast.py

    r3725 r3901  
    2727 
    2828def usage () : 
    29     texte = """%(prog)s usage : 
    30 python %(prog)s [-d] [-i <orca grid file>] [-n <perio>] 
     29    texte = """Compute a mask for coastal point of NEMO domain 
     30 
     31    %(prog)s usage : 
     32python %(prog)s [-h|--help] [-d|--debug] [-i <orca grid file>] [-n <perio>] 
    3133 -d         | --debug         : debug 
    3234 -i <file>  | --input=<file>  : input file  (default: none) 
     
    4951## Command line options 
    5052try: 
    51     myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:n:h', [ 'input=', 'nperio=', 'debug=', '--help' ] ) 
     53    myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:n:h', [ 'input=', 'nperio=', 'debug=', 'help' ] ) 
    5254except getopt.GetoptError as cmdle : 
    5355    print ( "Command line error : "+str(cmdle)+"\n" ) 
     
    6668    sys.exit(-1) 
    6769 
    68 print ("Input file  :" + GridFile)    
     70print ("Input file : " + GridFile)    
    6971 
    7072## Open grid file 
     
    115117print ("Maximum number of neighbors : "+str(CoastCrit) ) 
    116118 
    117  
    118 Temp = nemo.lbc ( Temp,  nperio=4, cd_type='T' ) 
     119Temp = nemo.lbc ( Temp,  nperio=nperio, cd_type='T' ) 
    119120 
    120121OceCoastal = np.where (OceMask == 1, True, False) * np.where (Temp < CoastCrit, True, False) 
  • 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 
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r3734 r3901  
    3636#  $Id$ 
    3737#  $HeadURL$ 
     38export Bold=$(tput bold)   
     39export Unde=$(tput smul) ; export OffUnde=$(tput rmul) 
     40export Stou=$(tput smso) ; export OffStou=$(tput rmso) 
     41export Reve=$(tput rev )  
     42couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) 
     43for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done 
     44export Norm=$(tput sgr0 ) 
    3845 
    3946## 
     
    5865# =========================== 
    5966ListOCEGRID="T U V" 
    60 ListOrder="1st" # " 2nd 
     67ListOrder="1st" # 2nd" 
    6168ListNormalize="false true" 
    6269 
     
    7178# Defines computer 
    7279# ================ 
    73 if [[ $(hostname) = curie* ]]    ; then arch=curie ; center=tgcc ; fi 
    74 if [[ $(hostname) = irene* ]]    ; then arch=irene ; center=tgcc ; fi 
     80if [[ $(hostname) = curie*    ]] ; then arch=curie ; center=tgcc ; fi 
     81if [[ $(hostname) = irene*    ]] ; then arch=irene ; center=tgcc ; fi 
    7582if [[ $(hostname) = lsce3005* ]] ; then arch=spip  ; center=spip ; fi 
    7683 
     
    95102    MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 
    96103    ;;  
    97     ( * ) 
    98     exit -1 
    99     ;; 
     104    ( * ) exit -1 ;; 
    100105esac 
    101106 
     
    127132# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits 
    128133# --------------------------------------------------------------------------- 
    129 FL_FMT=64bit 
     134FMT_OASIS=64bit 
     135FMT_XIOS=netcdf4 
    130136 
    131137 
     
    133139cp ${SUBMIT_DIR}/*.py                . 
    134140 
    135 ## 
    136 ## NEMO T point towards ATM - 1st order 
    137 ## =========================================================================== 
     141 
    138142cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  . 
    139143cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . 
    140144 
    141 ln -s ${OCE}_coordinates_mask.nc  oce_grid.nc 
    142 ln -s ${ATM}_grid.nc              atm_grid.nc 
    143  
     145ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 
     146ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc                    ${ATM}_grid_${FMT_OASIS}.nc 
     147# 
     148# Creates OCEAN C grid : redundant point removed to compute proper integrals # A passer dans CreateWeights 
     149# ---------------------------------------------------------------------------- 
     150cat <<EOF >add_c_grid.nco 
     151nav_lon_grid_C    = nav_lon_grid_T    ; 
     152nav_lat_grid_C    = nav_lat_grid_T    ; 
     153bounds_lon_grid_C = bounds_lon_grid_T ; 
     154bounds_lat_grid_C = bounds_lat_grid_T ; 
     155area_grid_C       = area_grid_T       ; 
     156mask_C            = maskutil_T        ;  
     157EOF 
     158 
     159ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc 
     160ncks --overwrite --variable nav_lon_grid_C,nav_lat_grid_C,bounds_lon_grid_C,bounds_lat_grid_C,area_grid_C,mask_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
     161rm tmp_${OCE}_coordinates_mask_${FMT_OASIS}.nc 
     162ncrename --dimension x_grid_T,x_grid_C                C_${OCE}_coordinates_mask.nc 
     163ncrename --dimension y_grid_T,y_grid_C                C_${OCE}_coordinates_mask.nc 
     164ncrename --dimension nvertex_grid_T,nvertex_grid_C    C_${OCE}_coordinates_mask.nc 
     165ncks --append C_${OCE}_coordinates_mask.nc            ${OCE}_coordinates_mask.nc 
     166rm C_${OCE}_coordinates_mask.nc 
     167 
     168ncks --overwrite --fl_fmt=${FMT_OASIS} --history {OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 
     169 
     170ls -al 
     171 
     172## 
     173## NEMO T point towards ATM - 1st order 
     174## =========================================================================== 
    144175echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm} 
    145176cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   iodef.xml 
     
    162193 
    163194cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml 
     195ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
     196ln -fs ${ATM}_grid.nc              atm_grid.nc 
    164197 
    165198time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no 
     
    197230rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc 
    198231 
    199 ## 
    200 ## Creates mask of coastal OCE points 
    201 ## =========================================================================== 
    202 python ComputeNemoCoast.py  -n ${OcePerio} -i oce_grid.nc 
    203  
    204 ## 
    205 ## Creates mask of coastal ATM points 
    206 ## =========================================================================== 
    207 cat <<EOF > coastal.nco 
    208 AtmCoastal = OceFrac * 0.0 ; 
    209 where (OceFrac > 0.0 && OceFrac < 1.0 )  AtmCoastal = 1.0 ; 
    210 EOF 
    211 ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 
    212 ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    213 rm ${ATM}_coastal_maskFrom_${OCE}.nc 
     232 
    214233 
    215234## 
     
    247266                cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order_${normalize}.xml 
    248267                 
     268                ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
     269                ln -fs ${ATM}_grid.nc              atm_grid.nc 
    249270                time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 
    250271            fi 
     
    288309            cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.xml 
    289310             
     311            ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
     312            ln -fs ${ATM}_grid.nc              atm_grid.nc 
    290313            time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 
    291314             
     
    294317done 
    295318 
     319## 
     320## Creates mask of coastal OCE points 
     321## =========================================================================== 
     322python ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 
     323## 
     324## Creates mask of coastal ATM points 
     325## =========================================================================== 
     326cat <<EOF > coastal.nco 
     327AtmCoastal = OceFrac * 0.0 ; 
     328where (OceFrac > 0.0 && OceFrac < 1.0 )  AtmCoastal = 1.0 ; 
     329EOF 
     330ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 
     331ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     332rm ${ATM}_coastal_maskFrom_${OCE}.nc 
     333ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 
    296334## 
    297335## ATM towards NEMO points - runoff 
     
    312350    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 AtmCoastal 
    313351    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 OceCoastal 
    314     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_c${atm}_to_t${oce}_1storder_${normalize} 
    315     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_c${atm}_to_t${oce}_1storder_${normalize}.nc 
     352    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_o${atm}_to_c${oce}_1storder_${normalize} 
     353    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_o${atm}_to_c${oce}_1storder_${normalize}.nc 
    316354    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize} 
    317355     
    318     cp iodef.xml iodef_c${atm}_to_t${oce}_1storder_${normalize}.xml 
     356    cp iodef.xml iodef_o${atm}_to_c${oce}_1storder_${normalize}.xml 
    319357     
     358    ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
     359    ln -fs ${ATM}_grid.nc              atm_grid.nc 
    320360    time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 
    321 done 
    322 ## 
    323 ## Change all NetCDF files to NetCDF 3 format (needed for OASIS) 
     361 
     362    # Now we should divide weight par source (atm) grid area : run-off is a quantity/s integrated on the grid mox, not a flux  
     363done 
     364## 
     365## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) 
    324366## =========================================================================== 
    325367for InFile in *.nc ; do 
    326     mv ${InFile} tmp_${InFile} 
    327     ncks --alphabetize --fl_fmt=${FL_FMT} --history  tmp_${InFile}  ${InFile} 
     368    OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc 
     369    if [[ ! -f ${OuFile} ]] ; then 
     370        ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile} 
     371    fi 
    328372done 
    329373 
     
    334378#ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 
    335379ncap2 --overwrite --history --script 'defdim("time_counter",1) ;' ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     380ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 
    336381 
    337382if [[ ${atm} = ico ]] ; then 
     
    349394            ${ATM}_grid_maskFrom_${OCE}.nc 
    350395fi 
     396ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 
     397 
    351398if [[ ${atm} = lmd ]] ; then 
    352399    cat <<EOF > add_time.nco 
     
    364411fi 
    365412ncks --alphabetize --overwrite --mk_rec time_counter   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    366  
     413ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 
    367414 
    368415## 
     
    373420NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 
    374421PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) 
    375 for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do 
     422for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc; do 
    376423    ncatted --history \ 
    377424            --attribute uuid,global,d,,                                           \ 
     
    421468for rmpFile in rmp_*.nc ; do 
    422469    mv ${rmpFile} xios_${rmpFile} 
    423     ncap2 --fl_fmt=${FL_FMT} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} 
     470    ncap2 --fl_fmt=${FMT_OASIS} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} 
    424471     
    425472    ncrename --history --dimension n_weight,num_links   ${rmpFile} 
     
    460507## =========================================================================== 
    461508for rmpFile in rmp_* ; do 
     509    echo ${rmpFile} 
    462510    a_to_o=false ; o_to_a=false 
    463511    case ${rmpFile} in 
     
    466514    esac 
    467515 
    468     for Grid in t u v c ; do # Identify grids 
    469         case ${rmpFile} in 
    470             (  rmp_${Grid}${oce}_to_?${atm}_*.nc ) ogrid=${Grid} ;; 
    471             (  rmp_?${oce}_to_${Grid}${atm}_*.nc ) agrid=${Grid} ;; 
    472             (  rmp_${Grid}${atm}_to_?${oce}_*.nc ) agrid=${Grid} ;; 
    473             (  rmp_?${atm}_to_${Grid}${oce}_*.nc ) ogrid=${Grid} ;; 
    474         esac 
     516    for Grid in t u v o c ; do # Identify grids 
     517        [[ ${rmpFile} = rmp_${Grid}${oce}_to_?${atm}_*.nc ]] && ogrid=${Grid} 
     518        [[ ${rmpFile} = rmp_?${oce}_to_${Grid}${atm}_*.nc ]] && agrid=${Grid} 
     519        [[ ${rmpFile} = rmp_${Grid}${atm}_to_?${oce}_*.nc ]] && agrid=${Grid} 
     520        [[ ${rmpFile} = rmp_?${atm}_to_${Grid}${oce}_*.nc ]] && ogrid=${Grid} 
    475521    done 
    476522    OGRID=${ogrid^} 
     
    502548EOF 
    503549 
    504     [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile} 
     550    [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} 
    505551    sed --in-place "s/src_/dst_/g" add_varoce.nco 
    506     [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile} 
     552    [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} 
    507553                 
    508554    if [[ ${atm} = ico ]] ; then 
     
    532578EOF 
    533579        if [[ ${o_to_a} = true ]] ; then 
    534             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     580            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 
    535581            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 
    536582            mv rmp_tmp.nc ${rmpFile} 
     
    539585        sed --in-place "s/dst_/src_/g" add_varatm.nco 
    540586        if [[ ${a_to_o} = true ]] ; then 
    541             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     587            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 
    542588            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 
    543589            mv rmp_tmp.nc ${rmpFile} 
     
    573619EOF 
    574620        if [[ ${o_to_a} = true ]] ; then 
    575             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     621            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 
    576622            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 
    577623            mv rmp_tmp.nc ${rmpFile} 
     
    580626        sed --in-place "s/dst/src/g" add_varatm.nco 
    581627        if [[ ${a_to_o} = true ]] ; then 
    582             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     628            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 
    583629            ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 
    584630            mv rmp_tmp.nc ${rmpFile} 
     
    586632    fi 
    587633done 
    588  
     634ls -al ${OCE}_coordinates_mask.nc 
    589635## 
    590636## Save results 
Note: See TracChangeset for help on using the changeset viewer.