[513] | 1 | #!/bin/ksh |
---|
| 2 | # palmplot - script for running the NCL scripts |
---|
| 3 | # $Id: palmplot 526 2010-03-30 14:04:38Z heinze $ |
---|
| 4 | |
---|
| 5 | # Using the available NCL scripts via the shell script palmplot |
---|
| 6 | |
---|
| 7 | # Last changes |
---|
| 8 | # 16/03/10 - Rieke - initial revision |
---|
[526] | 9 | # 30/03/10 - Rieke - substituting double quotes (") with a character |
---|
| 10 | # variable (dq) containing double quotes |
---|
[513] | 11 | |
---|
| 12 | |
---|
| 13 | # SHORT INTRODUCTION FOR USING THIS SCRIPT |
---|
| 14 | if [[ "$1" = "?" || "$1" = "--help" || "$1" = "-h" ]] |
---|
| 15 | then |
---|
| 16 | (printf "\n palmplot is designed to run the NCL scripts of PALM \n" |
---|
| 17 | printf "\n palmplot can be called as follows:" |
---|
| 18 | printf "\n palmplot script_identifier file_1=OUTPUT/test.nc file_out=test format_out=pdf var=,pt,u, no_rows=2 ...\n" |
---|
| 19 | printf "\n script_identifier has to be one of the following:" |
---|
| 20 | printf "\n xy, xz, yz, pr, ts, sp" |
---|
| 21 | printf "\n in dependence of the data that wants to be plotted\n" |
---|
| 22 | printf "\n the further arguments control the plot" |
---|
| 23 | printf "\n they can also be set in the configuration file .ncl.config" |
---|
| 24 | printf "\n a documentation is available at $PALM_BIN/\NCL\/UserGuide_for_NCLscripts.pdf\n\n") |
---|
| 25 | exit |
---|
| 26 | fi |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | # DEFINITION OF VARIABLES |
---|
| 30 | a="" |
---|
| 31 | arg="" |
---|
| 32 | key="" |
---|
| 33 | script="" |
---|
| 34 | value="" |
---|
| 35 | CMDLINE="" |
---|
| 36 | STRINGPARAMS="" |
---|
| 37 | STRINGPARAMS_CO="" |
---|
| 38 | STRINGPARAMS_CS="" |
---|
| 39 | STRINGPARAMS_PR="" |
---|
| 40 | STRINGPARAMS_SP="" |
---|
| 41 | STRINGPARAMS_TS="" |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | # LIST OF THE PARAMETERS OF THE NCL SCRIPTS WHICH NCL EXPECTED TO BE STRINGS |
---|
| 45 | # CO: PARAMETERS WHICH ARE COMMON FOR ALL NCL SCRIPTS |
---|
| 46 | # CS: cross_sections.ncl PR: profiles.ncl SP: spectra.ncl TS: timeseries.ncl |
---|
| 47 | STRINGPARAMS_CO="file_1 format_out file_out var " |
---|
| 48 | STRINGPARAMS_CS="sort mode fill_mode unit_x unit_y unit_z vec1 vec2 plotvec" |
---|
| 49 | 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" |
---|
| 50 | STRINGPARAMS_SP="sort unit_x unit_y" |
---|
| 51 | STRINGPARAMS_TS="unit_t" |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | # CHOICE OF THE PARTICULAR NCL SCRIPT |
---|
| 55 | if [[ "$1" == "xy" ]] |
---|
| 56 | then |
---|
| 57 | script="cross_sections.ncl" |
---|
| 58 | STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS |
---|
| 59 | CMDLINE="xyc=1 " |
---|
| 60 | elif [[ "$1" == "xz" ]] |
---|
| 61 | then |
---|
| 62 | script="cross_sections.ncl" |
---|
| 63 | STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS |
---|
| 64 | CMDLINE="xzc=1 " |
---|
| 65 | elif [[ "$1" == "yz" ]] |
---|
| 66 | then |
---|
| 67 | script="cross_sections.ncl" |
---|
| 68 | STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS |
---|
| 69 | CMDLINE="yzc=1 " |
---|
| 70 | elif [[ "$1" == "pr" ]] |
---|
| 71 | then |
---|
| 72 | script="profiles.ncl" |
---|
| 73 | STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_PR |
---|
| 74 | elif [[ "$1" == "ts" ]] |
---|
| 75 | then |
---|
| 76 | script="timeseries.ncl" |
---|
| 77 | STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_TS |
---|
| 78 | elif [[ "$1" == "sp" ]] |
---|
| 79 | then |
---|
| 80 | script="spectra.ncl" |
---|
| 81 | STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_SP |
---|
| 82 | else |
---|
| 83 | (printf "\n first argument has to be one of the following:" |
---|
| 84 | printf "\n xy, xz, yz, pr, ts or sp \n" |
---|
| 85 | printf "\n type \"palmplot ?\" for information about the usage of this script\n") |
---|
| 86 | exit |
---|
| 87 | fi |
---|
| 88 | |
---|
| 89 | # SHIFTING THE FIRST COMMAND LINE ARGUMENT |
---|
| 90 | shift |
---|
| 91 | |
---|
| 92 | # PROCESSING THE COMMAND LINE ARGUMENTS |
---|
| 93 | while [ $# -gt 0 ] |
---|
| 94 | do |
---|
| 95 | arg=$1 |
---|
| 96 | key=${arg%%=*} |
---|
| 97 | value=${arg#*=} |
---|
| 98 | |
---|
| 99 | # ALLOWING RELATIVE AND ABSOLUTE FILE PATHS |
---|
| 100 | if [[ "$key" == @(file_*) && "$value" != @(~/*|/*) ]] |
---|
| 101 | then |
---|
| 102 | value=$PWD/$value |
---|
| 103 | fi |
---|
| 104 | |
---|
[526] | 105 | # PROCESSING STRINGS |
---|
[513] | 106 | for a in $STRINGPARAMS |
---|
| 107 | do |
---|
| 108 | if [ "$key" = "$a" ] |
---|
| 109 | then |
---|
[526] | 110 | # SUBSTITUTING DOUBLE QUOTES - REQUIRED BY NCL |
---|
| 111 | value=`echo $value | sed 's/\"/\"+dq+\"/g'` |
---|
| 112 | # SETTING ENTIRE STRING IN DOUBLE QUOTES - REQUIRED BY NCL |
---|
[513] | 113 | value=\"$value\" |
---|
| 114 | break |
---|
| 115 | fi |
---|
| 116 | done |
---|
| 117 | |
---|
| 118 | CMDLINE+="$key=$value " |
---|
| 119 | shift |
---|
| 120 | done |
---|
| 121 | |
---|
| 122 | # EXECUTING THE PARTICULAR NCL SCRIPT |
---|
| 123 | cd $PALM_BIN/NCL |
---|
[526] | 124 | ncl 'dq=str_get_dq()' $script $CMDLINE |
---|
[513] | 125 | |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|