#!/bin/ksh # palmplot - script for running the NCL scripts # $Id: palmplot 776 2011-10-31 08:02:51Z gryschka $ # Using the available NCL scripts via the shell script palmplot # Last changes # 16/03/10 - Rieke - initial revision # 30/03/10 - Rieke - substituting double quotes (") with a character # variable (dq) containing double quotes # 31/03/10 - Rieke - list of variable names can be specified using # blank separated lists instead of comma # separated lists # 01/04/10 - Rieke - bugfix - treatment of special character * # in NCL variables containing lists corrected # 23/08/10 - Rieke - bugfix - "" had to be added in if-queries # 30/09/10 - Rieke - Link to new online documentation of PALM NCL scripts # 31/10/11 - Rieke - Adjustement so that palmplot also works on # DKRZ (ibmh) # SHORT INTRODUCTION FOR USING THIS SCRIPT if [[ "$1" = "?" || "$1" = "--help" || "$1" = "-h" ]] then (printf "\n palmplot is designed to run the NCL scripts of PALM \n" printf "\n palmplot can be called as follows:" printf "\n palmplot script_identifier file_1=OUTPUT/test.nc file_out=test format_out=pdf var='pt w\"pt\" w*pt* u' no_rows=2 ...\n" printf "\n script_identifier has to be one of the following:" printf "\n xy, xz, yz, pr, ts, sp" printf "\n in dependence on the data that wants to be plotted\n" printf "\n the further arguments control the plot" printf "\n they can also be set in the configuration file .ncl.config" printf "\n a documentation is available at" printf "\n http://palm.muk.uni-hannover.de/wiki/doc/app/ncl \n\n") exit fi # DEFINITION OF VARIABLES a="" arg="" b="" key="" script="" value="" CMDLINE="" STRINGPARAMS="" STRINGPARAMS_CO="" STRINGPARAMS_CS="" STRINGPARAMS_PR="" STRINGPARAMS_SP="" STRINGPARAMS_TS="" STRINGPARAMS_VA="" # LIST OF THE PARAMETERS OF THE NCL SCRIPTS WHICH NCL EXPECTED TO BE STRINGS # CO: PARAMETERS WHICH ARE COMMON FOR ALL NCL SCRIPTS # CS: cross_sections.ncl PR: profiles.ncl SP: spectra.ncl TS: timeseries.ncl # VA: PARAMETERS WHICH CONTAIN LISTS OF VARIABLE NAMES STRINGPARAMS_CO="file_1 format_out file_out var " STRINGPARAMS_CS="sort mode fill_mode unit_x unit_y unit_z vec1 vec2 plotvec" STRINGPARAMS_PR="file_2 file_3 file_4 file_5 file_6 name_legend_1 name_legend_2 name_legend_3 name_legend_4 name_legend_5 name_legend_6 c_var" STRINGPARAMS_SP="sort unit_x unit_y" STRINGPARAMS_TS="unit_t" STRINGPARAMS_VA="var c_var vec1 vec2 plotvec" # CHOICE OF THE PARTICULAR NCL SCRIPT if [[ "$1" == "xy" ]] then script="cross_sections.ncl" STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS CMDLINE="xyc=1 " elif [[ "$1" == "xz" ]] then script="cross_sections.ncl" STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS CMDLINE="xzc=1 " elif [[ "$1" == "yz" ]] then script="cross_sections.ncl" STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS CMDLINE="yzc=1 " elif [[ "$1" == "pr" ]] then script="profiles.ncl" STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_PR elif [[ "$1" == "ts" ]] then script="timeseries.ncl" STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_TS elif [[ "$1" == "sp" ]] then script="spectra.ncl" STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_SP else (printf "\n first argument has to be one of the following:" printf "\n xy, xz, yz, pr, ts or sp \n" printf "\n type \"palmplot ?\" for information about the usage of this script\n") exit fi # SHIFTING THE FIRST COMMAND LINE ARGUMENT shift # PROCESSING THE COMMAND LINE ARGUMENTS while [ $# -gt 0 ] do arg=$1 key=${arg%%=*} value=${arg#*=} # ALLOWING RELATIVE AND ABSOLUTE FILE PATHS if [[ "$key" == @(file_*) && "$value" != @(~/*|/*) ]] then value=$PWD/$value fi # PROCESSING STRINGS for a in $STRINGPARAMS do if [ "$key" = "$a" ] then # PROCESSING STRINGS CONTAINING LISTS OF VARIABLES for b in $STRINGPARAMS_VA do if [ "$key" = "$b" ] then if [[ "$value" != "all" ]] then # SUBSTITUTING BLANKS WITH COMMAS IN # PARAMETERS CONTAINING LISTS OF VARIABLES value=`echo $value | sed 's/ /,/g'` # ALLOWING THE USAGE OF COMMA SEPARATED LIST AS WELL if [[ "$value" == "${value#,}" ]] then value=,$value fi if [[ "$value" == "${value%,}" ]] then value=$value, fi value=${value/%\*,,/\*,} break fi fi done # SUBSTITUTING DOUBLE QUOTES - REQUIRED BY NCL value=`echo $value | sed 's/\"/\"+dq+\"/g'` # SETTING ENTIRE STRING IN DOUBLE QUOTES - REQUIRED BY NCL value=\"$value\" fi done CMDLINE=$CMDLINE"$key=$value " shift done # EXECUTING THE PARTICULAR NCL SCRIPT cd $PALM_BIN/NCL ncl 'dq=str_get_dq()' $script $CMDLINE