Contact:  Matt Harrison, Giang Nong
Change History: WebCVS Log
Last Modified:  $Date: 2004/09/28 20:27:16 $
Language:  Perl/Tk


The script diag_table_tk is a GUI written in Perl/Tk for building diagnostics tables, which are used by the Diagnostics Manager for run-time specification of diagnostics.

The diagnostics table allows users to specify sampling rates and the choice of fields at run time. The table consists of comma-separated ASCII values and may be hand-edited. The preferred method of building a table is to use the provided GUI interface diag_table_tk. A default diag table is provided with each runscript.

The table is separated into three sections. Sign # is used for comment in diag_table.

  1. Global section: The first two lines of the table contain the experiment title and base date. The base date is the reference time used for the time units. The base date must be greater than or equal to the model start date. The date consists of six space-separated integers: year, month, day, hour, minute, and second.

  2. File section: File lines contain 6 fields - file name, output frequency, output frequency units, file format (currently only support NetCDF), time units and long name for time axis. The format is as follows:
             > 0  output frequency in "output_units"
             = 0  output frequency every time step
             =-1  output frequency at end of run
    output_freq_units = units used for output frequency
            (years, months, days, minutes, hours, seconds)
    format:   1 NetCDF (this is the ONLY supported format)
    time_units   = units used to label the time axis
             (days, minutes, hours, seconds)
    new_file_freq: frequency for closing existing file and creating a new file.
    new_file_freq_unit: time units for new_file_freq (from seconds to
    start_time: time to start the file for the first time

    Note: "new_file_freq","new_file_freq_unit","start_time" are optional

  3. Field section: Field lines contain 8 fields - module name, field name, output field name, file name, time sampling (for averaging, currently only support all timesteps), time average, other operations (for regional output) and pack value (1,2,4 or 8). The format is as follows:
    "module_name", "field_name", "output_name", "file_name" "time_sampling", 
    time_avg, "other_opts", packing
    module_name :  e.g. "atmos_mod", "land_mod"
    time_avg = .true. or .false.
    packing  = 1  double precision
             = 2  float
             = 4  packed 16-bit integers
             = 8  packed 1-byte (not tested?)
    other_opts is used to specify bounds of a region in regional output
  4. example of diag table
    "diag manager test"
    1999 1 1 0 0 0
    #output files
    10_days,               10, "days",1,"hours","Time"
    temp_local,             1, "days",1,"hours","Time"
    "file1_hr%hr3",         5, "days",1,"hours","Time", 15, "days"
    "file2_yr_dy%yr1%dy3",  5, "days",1,"hours","Time", 10, "days", "1 1 7 0 0 0"
    #output variables
    "ice_mod","ice","ice","10_days","all",.false.,"none", 2
    "ocean_mod","temp", "temp","temp_local",  "all",.false., "5 259.5 -59.5 59.5 1 1", 2


diag_table_tk requires the following perl modules:
use English;
use Tk;
use Cwd;
require Tk::FileSelect;
require Tk::Text;
use Tk::widgets qw/Dialog ErrorDialog ROText/;
use Tk::FileDialog;
use Tk::Balloon;
use File::Find;

Most of these are built by default in perl 5.004 and above; however, you may need to install the perl Tk modules.

Obtain Tk and Tk-FileDialog from:

Obtain Tk and Tk-FileDialog in RPM (red hat package manager) format from:


  1. Load and edit previously saved diag tables.
    Choose "Load Table" from the "File" menu.

  2. Quick parsing of f90 source code for fields which may be registered. Fields are grouped by module name.
    To obtain a list of available diagnostic fields, choose "Modify Output Field Entry" from the main menu. Enter the path to the directory containing your source code, and click "Search". After the search is complete, you can look in the "Field" menu for the list of available fields.

  3. Easy table editing, including ability to delete or edit selected lines.
    To edit the text of an entry, click the "Show Table" button, Select the entry you wish to edit by clicking on the "Entry List" button, then click "Edit Entry". A new window will open in which you can make changes. Click "Save Changes" when you are finished.

  4. Error checks to help ensure that your diag table will work properly.
    Ensures proper spacing and formatting.

  5. Online Help is available.
    Choose "Help" from the menubar.


The "cancel" button doesn't seem to work.

The Show Table window should be opened by default when you click "modify table a" or "modify table b". Visual feedback is good.

It should warn you if you make changes and quit without saving.