#!/bin/ksh # # add perturbations to unperturbed wind stress # # Set error trapping on # set -euvx # # Document command line options # usage="Usage:\n$0 -o -e expid -b bastime -N npert_tot -i input_dir_for_pert -D mesh_dir" # # Set defaults for command line options # expid=unknown basetime=unknown outdir=unknown prtdir=unknown inpdir=unknown fctot=unknown errflg=0 # # Get command line options # while getopts b:N:o:e:i:D: option do case $option in e) expid=$OPTARG;; b) basetime=$OPTARG;; N) fctot=$OPTARG;; o) outdir=$OPTARG;; i) prtdir=$OPTARG;; D) inpdir=$OPTARG;; \?) errflg=1;; esac done # # Check for errors # if [[ $errflg -ne 0 || $outdir = unknown || $expid = unknown || $fctot = unknown || $basetime = unknown || $prtdir = unknown || $inpdir = unknown ]] ; then print $usage exit 1 fi # # Check that directories exists. # CHECK_DIR $outdir year=$(substring $basetime 1 4) mon=$(substring $basetime 5 6) ln -sf $inpdir/mesh_mask.nc . ln -sf $inpdir/bathy_meter.nc . fcpert=1 while (( $fcpert < $fctot )) ;do fxout=$outdir/p${fcpert}_utau_y${year}m${mon}.nc fyout=$outdir/p${fcpert}_vtau_y${year}m${mon}.nc if [[ ! -s $fxout || ! -s $fyout ]] ;then cat >wstr_choice.in<