#!/usr/bin/perl -w

my $op = $ARGV[0];

use strict;
use warnings;

my @descs = (
	[ 0, q{Average} ],
	[ 1, q{Accumulation} ],
	[ 2, q{Maximum} ],
	[ 3, q{Minimum} ],
	[ 4, q{Difference (value at the end of the time range minus value at the beginning)} ],
	[ 5, q{Root Mean Square} ],
	[ 6, q{Standard Deviation} ],
	[ 7, q{Covariance (temporal variance)} ],
	[ 8, q{Difference (value at the beginning of the time range minus value at the end)} ],
	[ 9, q{Ratio} ],
	[ 51, q{Climatological Mean Value} ],
	[ '10-191', q{Reserved} ],
	[ '192-254', q{Reserved for Local Use} ],
	[ 200, q{Vectorial mean} ],
	[ 201, q{Mode} ],
	[ 202, q{Standard deviation vectorial mean} ],
	[ 203, q{Vectorial maximum} ],
	[ 204, q{Vectorial minimum} ],
	[ 205, q{Product with a valid time ranging inside the given period} ],
	[ 254, q{Istantaneous value} ],
);

my @notes = (
	q{Validity time is defined as the time at which the data are measured or at which forecast is valid; for statistically processed data, the validity time is the end of the time interval.},

	q{Reference time is defined as the nominal time of an observation for observed values, or as the time at which a model forecast starts for forecast values.},

	q{The date and time in DB-All.e are always the validity date and time of a value, regardless of the value being an observation or a forecast.},

	q{P1 is defined as the difference in seconds between validity time and reference time. For forecasts it is the positive forecast time. For observed values, the reference time is usually the same as the validity time, therefore P1 is zero. However P1 < 0 is a valid case for reports containing data in the past with respect to the nominal report time.},
	
	q{P2 is defined as the duration of the period over which statistical processing is performed, and is always nonnegative. Note that, for instantaneous values, P2 is always zero.},

#	q{The Eta (NAM) vertical coordinate system involves normalizing the pressure at some point on a specific level by the mean sea level pressure at that point.},
);


if ($op eq 'dox')
{
	print q{/**@defgroup trange_table Time range values
@ingroup tables

Definition of the main concepts related to the description of time
range and statistical processing for observed and forecast data:

};

	for my $n (@notes)
	{
		$n =~ s/\n+/\n/g;
		print '\\li ', $n;
	}

	print q{

The following table lists the possible values for pindicator and the
interpretation of the corresponding values of P1 and P2 specifying a
time range:
};

	for my $d (@descs)
	{
		print '\\li \b ', $d->[0], " ";
		my $desc = $d->[1];
		$desc =~ s/\n+/\n/g;
		print $desc;
	}


	print "*/\n";
}
elsif ($op eq 'tex')
{
	print q( 
Definition of the main concepts related to the description of time
range and statistical processing for observed and forecast data:

\\begin{itemize}
);

	for my $n (@notes)
	{
		print '\\item ', $n, "\n";
	}

	print q(\\end{itemize}

The following table lists the possible values for pindicator and the
interpretation of the corresponding values of P1 and P2 specifying a
time range:

\\begin{description}
);

	for my $d (@descs)
	{
		print '\\item [', $d->[0], "]\n";
		print $d->[1];
	}

	print q(\\end{description}
);
} else {
	print STDERR "Unknown operation: $op\n";
	exit 1;
}

exit 0;
