head 1.3; access; symbols; locks wmc:1.3; strict; comment @% @; 1.3 date 2004.09.13.11.13.59; author wmc; state Exp; branches; next 1.2; 1.2 date 2004.09.13.11.04.36; author wmc; state Exp; branches; next 1.1; 1.1 date 2004.09.13.11.04.25; author wmc; state Exp; branches; next ; desc @@ 1.3 log @Now that CLIMAT.pm does Permit_50_in_MM properly it doesn't need to be in the code here. @ text @#!/bin/perl -w # Wrapper to CLIMAT.pm to decode CLIMAT. # # Author # W. M. Connolley 2000 - 2004 # wmc@@bas.ac.uk / http://www.antarctica.ac.uk/met/wmc # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # http://www.gnu.org/copyleft/gpl.html use strict; use CLIMAT; my ($Filei, $text, @@text); my $DEBUG = 0; my $ORACLE = 0; # Output format for Oracle my $BRIEF =0; # Output format for quick-checks: subset of ORACLE my $MMJJJ; # Setup options eval "\$$1=\$2" while $ARGV[0] =~ /^(\w+)=(.*)/ && shift; if ($#ARGV eq -1) { print "Usage: CLIMAT.pl filenames-list\n"; exit; } # # Decode CLIMAT..., looping over files in arg list # while ( $Filei=shift @@ARGV ) { open(IN,$Filei); if ($DEBUG) { print "Opening $Filei\n" }; # # Inner-Main loop; split input file and pass to CLIMAT.pm in bits # Note that we remove CLIMAT TEMP text to avoid confusion on the split. # undef $/; $text=; close(IN); # Prefixing with " " ensures that the first thing split off is junk. Otherwise # we have to deal with the special case of CLIMAT being the very first thing. @@text=split(/(CLIMAT \d{5})/," ".$text); shift @@text; while (@@text) { # Irritatingly, we can have # CLIMAT MMJJJ # IIiii message= # IIiii message= # ... # NNNN # Get what should be CLIMAT MMJJJ $MMJJJ = shift @@text; # Get the rest, and remove trailing junk ($text = shift @@text) =~ s/\s*NNNN.*//sm; # Split on the "=" my @@text1 = split(/=/,$text); # Loop over the bits for $text (@@text1) { $text = $MMJJJ . $text; my $climat = CLIMAT::new(message => \$text, DEBUG=>$DEBUG); if ($climat->decode()) { if ($ORACLE) { print $climat->as_oracle . "\n" } elsif ($BRIEF) { print $climat->as_brief . "\n" } else { print $climat->as_text . "\n" }; } else { print $climat->{Error_message},"\n" unless ($ORACLE) }; }; }; }; @ 1.2 log @Add Permit_50_in_MM @ text @a26 4 my $Permit_50_in_MM=1; # WMO standards allow adding 50 to MM to represent speeds # in knots not m/s *but only in FM 75/76*. It makes no sense # for CLIMATs (FM 71) because there are no speeds! But people # occasionally make this mistake. @ 1.1 log @Initial revision @ text @d5 3 a7 2 # Copyright (C) W. M. Connolley June 2000 # wmc@@bas.ac.uk / http://www.antarctica.ac.uk/met/wmc d27 4 d37 1 a37 1 PRINT "Usage: CLIMAT.pl filenames-list\n"; @