WXP has several methods for accessing and modifying resources. These include program defaults which are values hardcoded into the programs, the defaults file which stores primary defaults and override the program defaults, environment variables specified in the user shell or script, and finally the command line.
Each program has default values or actions for each resource. For example, the data_path resource defaults to the current directory. Of course, data would rarely be stored in the current directory so this resource is usually set to a directory on a data server where the data are stored.
Often, the program defaults are not appropriate. As a result, there needs to be a mechanism to change program defaults. The resource or defaults file is used to specify those resource values that rarely change. The syntax of the values in the file follows the syntax "resource: value". There are two types of resource specifications in the resource file. The first are global resources that are used by all programs.
*file_path: /home/wxp/etc *data_path: /mnt/noaaport/nwstg/data *con_path: /mnt/noaaport/nwstg/convert *model_path: /mnt/noaaport/nwstg/model *sat_path: /mnt/noaaport/goes/sat
This says that the data_path resource used by all programs is set to a mounted NOAAPORT data directory.
The second type of resource specification is a named resource. This specifies a resource setting that is specific to a program or the invocation of a program (through the "name" resource).
lightplot.data_path: /mnt/noaaport/nwstg/nldn satplot.color_table: sat.clr nids.in_file: nids nids.color_table: radar.clr nids.color_fill: bref.cfl
The last three specification don't use the name of a program. To use these, use the name resource:
to set a program environment. This would tell the radplot program to use NIDS data, specify a color table to use and the bref coloring scheme.
Resource File Location
The default resource file is "wxp.cfg". But WXP will look for the files ".wxpdef" and "Wxp.res" as well.; WXP will also look for the file in the following directories:
- current directory
If the resource file is not in any of those locations, it can be specified with the "default" resource. Usually this is done by setting the wxpdefault environment variable.
If this is the case, it is recommended that this location be set in the user's shell startup script (e.g. .bashrc for bash or .cshrc for c-shell).
To group system and local resource files, each file can be specified separated by a colon ':'.
The resource files are processed in the order listed so resources listed and the last resource file takes precedence. The resource file location can be changed on the command line of each program.
At times, program defaults need to be set for multiple program runs. It is unnecessary to continual modify the resource file is these situations. Also, it is not recommended to set those command line arguments every time a program is run. Therefore, a set of environment variables is provided for each resource. The name of the environment variable is just "wxp" + the resource name. So the current resource has an associated environment variable "wxpcurrent". For example:
will specify to use the latest (la) available file. Each program will use this value for the current resource until this environment variable is either reset or unset.
There are environment variable name shortcuts as well. For example, the data_path shortcut would be "wxpdpath". This are listed in the resource reference.
There are named environment variables as well. This works just like the resource file by specifying "wxp_" + program name + "_" + resource. So if you want color_data resource for only soundplot to be red, then you would specify:
Environment variables can be used to set temporary defaults, which can be handy for use with case studies, shell scripts or specialized situations.
Each resource can be specified on the command line. Of course these must be specified each time the program is run. If more permanent values are to be set, look at setting resource values via the resource file or environment variable.
The syntax for the command line is very similar to the to that for other methods. Most of the resources are keyed resources. To specify that the resource is a keyed resource, the resource name is preceded by a "-". The syntax is "-" + resource name + "=" (or space) + its value.
sfcplot -variable all
In many cases it would be nice to not list the entire resource name in the key. WXP provides two shortcuts. First, each resource has a 2 (sometimes 3) letter abbreviation associated with it that is listed below.
The term keyed resource means that since each value is keyed, many resources can be set each with its key and entered onto the command line in any order. For example:
sfcplot -pd=us -va=all -ti=US_PLOT
In most programs, there is a positional (non-keyed) resource. A positional parameter does not need to have the resource specified and ONLY its value is listed:
Some programs like allow you to specify more than positional value:
domain -pd=us earth2plot 40,-100
The term positional means that they are order dependent. For domain, it uses the first value as a type of transformation and the second as the input data point.
Keyed and positional resources can be intermixed on the command line:
sfcplot -pd=us -va=all 10030321_sao.wxp -ti=US_PLOT
Generic ResourcesEven though programs have predefined resources it will reference, generic resources can also be specified. When the resource file is read, all resources are read in, not just those that are predefined. To set a generic resource in the defaults file, just add it:
To change a generic resource on the command line, you must specify the full resource name on the command line.
These resources are not used automatically but can be specified in the name convention file and along with color resources.
In special cases, resources may need to be changed. For example, using a single defaults file to cover multiple environments.; An example of this is:
IF LAB1 *model_path: /mnt/wxserver/data/model ELIF TEST *model_path: /data/nwstg/model ELSE *model_path: /mnt/noaaport/nwstg/model END LDM
In this case, the first line is used if LAB1 is defined, otherwise the second if TEST is defined or the third otherwise. You can define LAB1 in two places. You can add a line to the resource file:
This carries over to all subsequent resource files. You can undefine a tag with:
The more common method is to add the definition to the wxpdefault environment variable:
setenv wxpdefault +lab1:/home/wxp/etc
grbcalc -default +lab1:/home/wxp/etc
For WXP version 6, there is a special definition "V6".
IF V6 *file_path: ~/wxp/etc:/home/wxp/etc *data_path: /mnt/noaaport/nwstg/data:/home/wxp/data *con_path: /mnt/noaaport/nwstg/convert:/home/wxp/convert ELSE *file_path: /home/wxp/etc *data_path: /mnt/noaaport/nwstg/data #*con_path: /home/wxp/convert *con_path: /mnt/noaaport/nwstg/convert END
This will handle any differences in the resource specification between version 6 and older versions of WXP.
Updated January 2021