Re: How to enable user specified types of output

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 16 2009 - 14:15:21 MST

Here is a compact bit of code for selecting the output format on the
NCL command line:

   formats = (/ "ps", "eps", "pdf", "png", "x11" /) ; option table
   x11 = 1 ; default = X11 window
   ifmt = ind (isdefined (formats(:))) ; find option in table
   output = formats(ifmt(0)) ; use the first match

   wks = gsn_open_wks (output, outfilename)

Then on the command line, for example:

   ncl script.ncl pdf=1 # make a pdf file
   ncl script.ncl ps=1 # make a postscript file
   ncl script.ncl # default = X11 window on screen

This can be mixed with other command line options that you define,
as Mary showed in her example.

In general, I have found that the syntax "option=1" is the easiest
way to provide on/off NCL switch options that are entered repeatedly
on the command line.

If you prefer to have the options in something like a text namelist
file, then it should be fairly easy to use asciiread and the NCL
string functions to locate and parse a few keyword options in that file.

Dave Allured
CU/CIRES Climate Diagnostics Center (CDC)
http://cires.colorado.edu/science/centers/cdc/
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
http://www.esrl.noaa.gov/psd/psd1/

Wee-Beng Tay wrote:
> Hi,
>
> I've an ocean code and I'm using NCL to draw the plots. However, I will
> like the user to be able to select some options, like different kinds of
> output, output to screen/file etc.
>
> So how can this be done?
>
> I'm thinking of doing the following:
>
> 1. my code is in fortran. there's a namelist file with variables like :
>
> output_type=1 or 2 (contour=1, vector =2). So the user will enter the
> selection in the namelist.
>
> 2. this will create a file in the end for the ncl script to read in.
>
> 3. based on the different options, different types, number of plots will
> be generated.
>
> Is this the way to do it? Or is there a better way?
>
> Thanks
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 16 14:15:26 2009

This archive was generated by hypermail 2.1.8 : Thu Dec 17 2009 - 17:15:52 MST