mirror of https://github.com/ecmwf/eccodes.git
Scripts: Check column names. Add cfVarName.def file. Fix empty units
This commit is contained in:
parent
2e0987aa6c
commit
f7e05f7fd3
|
@ -29,7 +29,8 @@
|
|||
# scaleFactorOfSecondFixedSurface
|
||||
# typeOfStatisticalProcessing
|
||||
#
|
||||
# It outputs the def files: name.def paramId.def shortName.def units.def
|
||||
# It outputs the def files:
|
||||
# name.def paramId.def shortName.def units.def cfVarName.def
|
||||
#
|
||||
#######################################################################
|
||||
$|=1;
|
||||
|
@ -44,17 +45,39 @@ my $PARAMID_FILENAME = "paramId.def";
|
|||
my $SHORTNAME_FILENAME = "shortName.def";
|
||||
my $NAME_FILENAME = "name.def";
|
||||
my $UNITS_FILENAME = "units.def";
|
||||
my $CFVARNAME_FILENAME = "cfVarName.def";
|
||||
|
||||
open(OUT_PARAMID, ">$PARAMID_FILENAME") or die "$PARAMID_FILENAME: $!";
|
||||
open(OUT_SHORTNAME,">$SHORTNAME_FILENAME") or die "$SHORTNAME_FILENAME: $!";
|
||||
open(OUT_NAME, ">$NAME_FILENAME") or die "$NAME_FILENAME: $!";
|
||||
open(OUT_UNITS, ">$UNITS_FILENAME") or die "$UNITS_FILENAME: $!";
|
||||
open(OUT_CFVARNAME,">$CFVARNAME_FILENAME") or die "$CFVARNAME_FILENAME: $!";
|
||||
|
||||
my $first = 1;
|
||||
while (<>) {
|
||||
chomp;
|
||||
if ($first == 1) {
|
||||
die "Error: first line of input must contain the key names" if ( $_ !~ /^paramId/ );
|
||||
#die "Error: first line of input must contain the correct key names" if ( $_ !~ /^paramId/ );
|
||||
my @keys = split(/\t/);
|
||||
die "Error: column titles wrong: Column 1 should be paramId" if ($keys[0] ne "paramId");
|
||||
die "Error: column titles wrong: Column 2 should be shortName" if ($keys[1] ne "shortName");
|
||||
die "Error: column titles wrong: Column 3 should be name" if ($keys[2] ne "name");
|
||||
die "Error: column titles wrong: Column 4 should be units" if ($keys[3] ne "units");
|
||||
|
||||
die "Error: column titles wrong: Column 5 should be discipline" if ($keys[4] ne "discipline");
|
||||
die "Error: column titles wrong: Column 6 should be parameterCategory" if ($keys[5] ne "parameterCategory");
|
||||
die "Error: column titles wrong: Column 7 should be parameterNumber" if ($keys[6] ne "parameterNumber");
|
||||
|
||||
die "Error: column titles wrong: Column 8 should be #typeOfFirstFixedSurface" if ($keys[7] ne "typeOfFirstFixedSurface");
|
||||
die "Error: column titles wrong: Column 9 should be typeOfSecondFixedSurface" if ($keys[8] ne "typeOfSecondFixedSurface");
|
||||
|
||||
die "Error: column titles wrong: Column 10 should be scaledValueOfFirstFixedSurface" if ($keys[9] ne "scaledValueOfFirstFixedSurface");
|
||||
die "Error: column titles wrong: Column 11 should be scaleFactorOfFirstFixedSurface" if ($keys[10] ne "scaleFactorOfFirstFixedSurface");
|
||||
|
||||
die "Error: column titles wrong: Column 12 should be scaledValueOfSecondFixedSurface" if ($keys[11] ne "scaledValueOfSecondFixedSurface");
|
||||
die "Error: column titles wrong: Column 13 should be scaleFactorOfSecondFixedSurface" if ($keys[12] ne "scaleFactorOfSecondFixedSurface");
|
||||
die "Error: column titles wrong: Column 14 should be typeOfStatisticalProcessing" if ($keys[13] ne "typeOfStatisticalProcessing");
|
||||
|
||||
$first = 0;
|
||||
next;
|
||||
}
|
||||
|
@ -65,17 +88,22 @@ while (<>) {
|
|||
|
||||
die "Error: paramID \"$paramId\" is not an integer!" if (!is_integer($paramId));
|
||||
|
||||
$units = "~" if ($units eq "");
|
||||
|
||||
write_out_file(\*OUT_PARAMID, $name, $paramId);
|
||||
write_out_file(\*OUT_SHORTNAME, $name, $shortName);
|
||||
write_out_file(\*OUT_NAME, $name, $name);
|
||||
write_out_file(\*OUT_UNITS, $name, $units);
|
||||
write_out_file(\*OUT_CFVARNAME, $name, $shortName);
|
||||
}
|
||||
|
||||
print "Wrote output files: $PARAMID_FILENAME, $SHORTNAME_FILENAME, $NAME_FILENAME, $UNITS_FILENAME\n";
|
||||
print "Wrote output files: $PARAMID_FILENAME, $SHORTNAME_FILENAME, $NAME_FILENAME, $UNITS_FILENAME, $CFVARNAME_FILENAME\n";
|
||||
close(OUT_PARAMID) or die "$PARAMID_FILENAME: $!";
|
||||
close(OUT_SHORTNAME) or die "$SHORTNAME_FILENAME: $!";
|
||||
close(OUT_NAME) or die "$NAME_FILENAME: $!";
|
||||
close(OUT_UNITS) or die "$UNITS_FILENAME: $!";
|
||||
close(OUT_CFVARNAME) or die "$CFVARNAME_FILENAME: $!";
|
||||
|
||||
|
||||
sub write_out_file {
|
||||
my $outfile = $_[0];
|
||||
|
|
Loading…
Reference in New Issue