source: palm/trunk/SCRIPTS/palmplot @ 2821

Last change on this file since 2821 was 2718, checked in by maronga, 7 years ago

deleting of deprecated files; headers updated where needed

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 6.4 KB
RevLine 
[513]1#!/bin/ksh
[1046]2#--------------------------------------------------------------------------------#
[2696]3# This file is part of the PALM model system.
[1046]4#
5# PALM is free software: you can redistribute it and/or modify it under the terms
6# of the GNU General Public License as published by the Free Software Foundation,
7# either version 3 of the License, or (at your option) any later version.
8#
9# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# PALM. If not, see <http://www.gnu.org/licenses/>.
15#
[2718]16# Copyright 1997-2018  Leibniz Universitaet Hannover
[1046]17#--------------------------------------------------------------------------------#
18#
19# Current revisions:
20# -----------------
[2716]21#
22#
[1046]23# Former revisions:
24# -----------------
[513]25# $Id: palmplot 2718 2018-01-02 08:49:38Z knoop $
[2716]26# Corrected "Former revisions" section
[1047]27#
[2716]28# 2696 2017-12-14 17:12:51Z kanani
29# Change in file header (GPL part)
30#
31# 1310 2014-03-14 08:01:56Z raasch
32# update GPL copyright
33#
[1047]34# 1046 2012-11-09 14:38:45Z maronga
35# code put under GPL (PALM 3.9)
36#
[1046]37# palmplot - script for running the NCL scripts
[513]38    # Using the available NCL scripts via the shell script palmplot
39
40    # Last changes
41    # 16/03/10 - Rieke - initial revision
[526]42    # 30/03/10 - Rieke - substituting double quotes (") with a character
43    #                    variable (dq) containing double quotes
[529]44    # 31/03/10 - Rieke - list of variable names can be specified using
45    #                    blank separated lists instead of comma
46    #                    separated lists
[530]47    # 01/04/10 - Rieke - bugfix - treatment of special character *
48    #                    in NCL variables containing lists corrected
[566]49    # 23/08/10 - Rieke - bugfix - "" had to be added in if-queries
50    # 30/09/10 - Rieke - Link to new online documentation of PALM NCL scripts
[776]51    # 31/10/11 - Rieke - Adjustement so that palmplot also works on
52    #                    DKRZ (ibmh)
[513]53
54
55 # SHORT INTRODUCTION FOR USING THIS SCRIPT
56 if [[ "$1" = "?"  || "$1" = "--help" || "$1" = "-h" ]]
57  then
58    (printf "\n   palmplot is designed to run the NCL scripts of PALM \n"
59     printf "\n   palmplot can be called as follows:"
[529]60     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"
[513]61     printf "\n   script_identifier has to be one of the following:"
62     printf "\n    xy, xz, yz, pr, ts, sp"
[566]63     printf "\n   in dependence on the data that wants to be plotted\n"
[513]64     printf "\n   the further arguments control the plot"
65     printf "\n   they can also be set in the configuration file .ncl.config"
[566]66     printf "\n   a documentation is available at"
67     printf "\n   http://palm.muk.uni-hannover.de/wiki/doc/app/ncl \n\n")
[513]68     exit
69 fi
70
71
72 # DEFINITION OF VARIABLES
73 a=""
74 arg=""
[529]75 b=""
[513]76 key=""
77 script=""
78 value=""
79 CMDLINE=""
80 STRINGPARAMS=""
81 STRINGPARAMS_CO=""
82 STRINGPARAMS_CS=""
83 STRINGPARAMS_PR="" 
84 STRINGPARAMS_SP=""
85 STRINGPARAMS_TS=""
[529]86 STRINGPARAMS_VA=""
[513]87
88
89 # LIST OF THE PARAMETERS OF THE NCL SCRIPTS WHICH NCL EXPECTED TO BE STRINGS
90 # CO: PARAMETERS WHICH ARE COMMON FOR ALL NCL SCRIPTS
91 # CS: cross_sections.ncl PR: profiles.ncl SP: spectra.ncl TS: timeseries.ncl
[529]92 # VA: PARAMETERS WHICH CONTAIN LISTS OF VARIABLE NAMES
[513]93 STRINGPARAMS_CO="file_1 format_out file_out var "
94 STRINGPARAMS_CS="sort mode fill_mode unit_x unit_y unit_z vec1 vec2 plotvec"
95 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"
96 STRINGPARAMS_SP="sort unit_x unit_y"
97 STRINGPARAMS_TS="unit_t"
[529]98 STRINGPARAMS_VA="var c_var vec1 vec2 plotvec"
[513]99
100
101 # CHOICE OF THE PARTICULAR NCL SCRIPT
102 if [[ "$1" == "xy" ]]
103  then
104    script="cross_sections.ncl"
105    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
106    CMDLINE="xyc=1 "
107  elif [[ "$1" == "xz" ]]
108    then
109    script="cross_sections.ncl"
110    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
111    CMDLINE="xzc=1 "
112  elif [[ "$1" == "yz" ]]
113    then
114    script="cross_sections.ncl"
115    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
116    CMDLINE="yzc=1 "
117  elif [[ "$1" == "pr" ]]
118    then
119    script="profiles.ncl"
120    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_PR
121  elif [[ "$1" == "ts" ]]
122    then
123    script="timeseries.ncl"
124    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_TS
125  elif [[ "$1" == "sp" ]]
126    then
127    script="spectra.ncl"
128    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_SP
129   else
130     (printf "\n  first argument has to be one of the following:"
131      printf "\n   xy, xz, yz, pr, ts or sp \n" 
132      printf "\n  type \"palmplot ?\" for information about the usage of this script\n")
133     exit
134 fi
135
136 # SHIFTING THE FIRST COMMAND LINE ARGUMENT
137 shift 
138
139 # PROCESSING THE COMMAND LINE ARGUMENTS
140 while [ $# -gt 0 ] 
141 do
142    arg=$1
143    key=${arg%%=*}
144    value=${arg#*=}
[529]145
[513]146    # ALLOWING RELATIVE AND ABSOLUTE FILE PATHS
147    if [[ "$key" ==  @(file_*) && "$value" != @(~/*|/*) ]]
148    then
149       value=$PWD/$value
150    fi
151     
[526]152    # PROCESSING STRINGS
[513]153    for a in $STRINGPARAMS
154    do
155      if [ "$key" = "$a" ]
156      then
[529]157
158         # PROCESSING STRINGS CONTAINING LISTS OF VARIABLES
159         for b in $STRINGPARAMS_VA
160         do
161           if [ "$key" = "$b" ]
162           then
163              if [[ "$value" != "all" ]]
164              then
165                 # SUBSTITUTING BLANKS WITH COMMAS IN
166                 # PARAMETERS CONTAINING LISTS OF VARIABLES
[530]167                 value=`echo $value | sed 's/ /,/g'`   
[549]168                 # ALLOWING THE USAGE OF COMMA SEPARATED LIST AS WELL   
169           
170                 if [[ "$value" == "${value#,}" ]]
[529]171                 then
172                    value=,$value
173                 fi
[549]174                 if [[ "$value" == "${value%,}" ]]
[529]175                 then
176                    value=$value,
[549]177                 fi         
[530]178                 value=${value/%\*,,/\*,}                 
[529]179                 break
180              fi
181           fi
182         done
183
[526]184         # SUBSTITUTING DOUBLE QUOTES - REQUIRED BY NCL
185         value=`echo $value | sed 's/\"/\"+dq+\"/g'`
186         # SETTING ENTIRE STRING IN DOUBLE QUOTES - REQUIRED BY NCL
[513]187         value=\"$value\"
188      fi
189    done
190
[776]191    CMDLINE=$CMDLINE"$key=$value "
[513]192    shift
193 done
194
195 # EXECUTING THE PARTICULAR NCL SCRIPT
196 cd $PALM_BIN/NCL
[526]197 ncl 'dq=str_get_dq()' $script $CMDLINE 
[513]198
199
200
201
202
203
Note: See TracBrowser for help on using the repository browser.