#!/usr/bin/env perl
use strict;
my @dirs = ('../../ccsm_utils/Tools/per5lib', '../../ccsm_utils/Tools/perl5lib/Build');
unshift @INC, @dirs;
require Build::NamelistDefinition;
use lib "../../ccsm_utils/Tools/perl5lib";
my $image_dir = "./images";
print <<"END_of_Start";
CESM Component Models Namelist Definitions
Search or Browse POP2 Component Model Namelist Variables
This page contains the complete list of POP2 namelist variables available. They are grouped
by categories designed to aid browsing. Clicking on the name of a variable will display descriptive
information. If search terms are entered in the text box below, the list will be condensed to contain
only matched variables.
Found standard names matching query:
END_of_Start
my $nldef_file = "../../../models/ocn/pop2/bld/namelist_files/namelist_definition_pop2.xml";
my $nldef = Build::NamelistDefinition->new($nldef_file);
# Get list of categories in the definition file.
my @nldef_cats = $nldef->get_categories();
# Construct hash from @nldef_cats and use it to keep track of
# the categories that aren't treated explicitly below, then add them to the
# table at the end.
my %nldef_cats = ();
foreach my $k (@nldef_cats) {
$nldef_cats{$k} = '';
}
# The default output will organize the namelist variables according to the
# "category" attribute which is part of the definition. The ordering of the
# categories is set in the @categories array. The table headings are defined
# in the %cat_heading hash (order is not important in the hash definition).
my @categories = qw/
decomp
grid
io
timemgr
init_ts
diag
restart
history
solvers
vmix
kpp
tidal
hmix
state
baroclinic
ice
presgrad
topostress
forcing
coupled
swabs
transdiag
context
overflows
tavg
passive_tracers
ecosys
/;
my %cat_heading = (
'decomp' => 'POP2: Decomp Settings',
'grid' => 'POP2: Grid Settings',
'io' => 'POP2: IO Settings',
'timemgr' => 'POP2: Time Manager Settings',
'init_ts' => 'POP2: TS Initialization',
'diag' => 'POP2: Diagnostics',
'restart' => 'POP2: Restart Control',
'history' => 'POP2: History Output',
'solvers' => 'POP2: Solvers',
'vmix' => 'POP2: Vertical Mixing',
'kpp' => 'POP2: KPP',
'tidal' => 'POP2: Tidal',
'advect' => 'POP2: Advect',
'hmix' => 'POP2: Horizontal Mixing',
'state' => 'POP2: State Settings',
'baroclinic' => 'POP2: Baroclinic',
'ice' => 'POP2: Ice',
'presgrad' => 'POP2: Pressure Gradient',
'topostress' => 'POP2: Topo Stress',
'forcing' => 'POP2: Forcing',
'coupled' => 'POP2: Coupling Control',
'swabs' => 'POP2: Shortwave Absorbtion',
'transdiag' => 'POP2: Transport Diagnostic Control',
'context' => 'POP2: Context for Coupling POP2',
'overflows' => 'POP2: Overflows',
'tavg' => 'POP2: TAVG Settings',
'ecosys' => 'POP2: Ecosystem Settings',
'passive_tracers' =>'POP2: Passive Tracer Settings',
);
foreach my $cat (@categories) {
unless ($cat_heading{$cat} eq 'exclude') {
# Print table
print_start_table($cat, $cat_heading{$cat});
# get alphabetized list all the variable names in the category
my @vars = $nldef->get_var_names('category'=>$cat);
# get corresponding type and documentation
foreach my $var (@vars) {
my $var_local = $var;
my $type = $nldef->get_var_type($var);
my $doc = $nldef->get_var_doc_html($var);
my $grp = $nldef->get_group_name($var);
if ($grp eq 'derived') {
my @broken = split(/&/,$var);
$var_local = $broken[0];
$grp = $broken[1];
}
print_row($var_local, $type, $doc, $grp);
}
# Finish table
print_end_table();
}
$nldef_cats{$cat} = 'done';
}
# Finish
print <<"END_of_html";
END_of_html
#--------------------------------------------------------------------------------------------
sub print_start_table {
my $category = shift;
my $hdr = shift;
print <<"START_table";
$hdr
Namelist Variable
Type
Group
START_table
}
#--------------------------------------------------------------------------------------------
sub print_row {
my $name = shift;
my $type = shift;
my $doc = shift;
my $grp = shift;
print <<"END_of_row";