#!/usr/bin/env bash # # interp, scrip_use and scrip_use_extrap have been written by Virginie Guemas # in 2011 based on SCRIP software that computes interpolation weights: # Spherical Coordinate Remapping and Interpolation Package # #~~~~~~~~~~~~~~~ # get arguments #~~~~~~~~~~~~~~~ if [ $# == 0 ]; then echo echo "USAGE: $(basename $0) " echo " can be bilinear/bicubic/conserv/distwgt" echo " and can be ORCA1t_v2.2/ORCA1t_v3.2/ORCA025t_v3.2/ERA40/ERAint/EcEarth2/EcEarth3/HadISST/NCEP/NOAAv3b/NSIDC" echo " optional argument in case default choices not convenient : TRUE/FALSE" exit 1 fi filein=$1 varin=$2 method=$3 gridin=$4 gridout=$5 fileout=$6 if [ $# == 7 ]; then debug=$7 else debug='FALSE' fi exec='scrip_use' #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # /cfu/data conventions or not ? #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ case $gridin in 'ORCA1t_v2.2'|'ORCA1t_v3.2'|'ORCA025t_v3.2'|'NSIDC') flag1='FALSE' ;; 'NCEP'|'ERAint'|'ERA40'|'EcEarth2'|'EcEarth3'|'HadISST'|'NOAAv3b') flag1='TRUE' ;; *) flag1='FALSE' ;; esac case $gridin in 'ERA40'|'ERAint'|'EcEarth2'|'EcEarth3'|'HadISST'|'NCEP'|'NOAAv3b'|'NSIDC') flag2='TRUE' ;; 'ORCA1t_v2.2'|'ORCA1t_v3.2'|'ORCA025t_v3.2') flag2='FALSE' ;; *) flag2='FALSE' ;; esac #~~~~~~~~~~~~~~~~~~~~ # land data or not ? #~~~~~~~~~~~~~~~~~~~~ case $varin in 'tas'|'prlr'|'g500'|'g200'|'psl'|'hflsd'|'hfssd'|'hus'|'rls'|'rss'|'rsds'|'vas'|'uas'|'tasmax'|'tasmin') ;; 'tos'|'ice'|'mld'|'sic'|'sit'|'sea_ice_area_fraction') gridin=${gridin}'_ocean' ;; 'ice_pres'|'somixhgt'|'sosstsst'|'sosaline'|'iicethic'|'ileadfra'|'isnowthi'|'iicetemp'|'somxl010'|'somxlheatc'|'somxlsaltc'|'sobarstfu'|'sobarstfv'|'sobarstf'|'heatc_sl'|'vertmeansal'|'votemper'|'vosaline'|'rhopn') gridout=${gridout}'_ocean' ;; *) echo "unexpected input variable : contact Virginie" ; exit 1 ;; esac #~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Weigths available or not ? #~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if [[ ! -e /cfu/pub/scripts/interpolation/weigths/rmp_${gridin}_to_${gridout}_${method}.nc ]] ; then echo "unexpected input or output grid : contact Virginie" exit 1 fi #~~~~~~~~~~~~~~~ # Interpolation #~~~~~~~~~~~~~~~ if [[ ! -e ${filein} ]] ; then echo ${filein}" does not exist" exit 1 fi vars=`cdo showvar ${filein}` exist='FALSE' for var in $vars ; do if [[ $var == ${varin} ]] ; then exist='TRUE' ; fi done if [[ $exist == 'FALSE' ]] ; then echo $var" is not in input file" exit 1 fi cat > scrip_use_in <