Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Last revision Both sides next revision | ||
bufr.pm:bufrextract.pl_source [2016-11-29 08:41:07] pals created |
bufr.pm:bufrextract.pl_source [2022-05-31 09:29:31] external edit |
||
---|---|---|---|
Line 1: | Line 1: | ||
<code perl> | <code perl> | ||
- | # | + | # |
- | # (C) Copyright 2010-2016 MET Norway | + | # (C) Copyright 2010-2019 MET Norway |
# | # | ||
# This program is free software; you can redistribute it and/or modify | # This program is free software; you can redistribute it and/or modify | ||
Line 22: | Line 22: | ||
use strict; | use strict; | ||
+ | use warnings; | ||
use Getopt:: | use Getopt:: | ||
use Pod::Usage qw(pod2usage); | use Pod::Usage qw(pod2usage); | ||
Line 31: | Line 32: | ||
| | ||
' | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
' | ' | ||
+ | ' | ||
' | ' | ||
+ | ' | ||
' | ' | ||
+ | ' | ||
) or pod2usage(-verbose => 0); | ) or pod2usage(-verbose => 0); | ||
Line 71: | Line 72: | ||
$OUT = *STDOUT; | $OUT = *STDOUT; | ||
} | } | ||
+ | binmode($OUT); | ||
# No need to decode section 4 here | # No need to decode section 4 here | ||
Line 133: | Line 135: | ||
last READLOOP if $current_subset_number == 0; | last READLOOP if $current_subset_number == 0; | ||
- | $current_message_number = $bufr-> | + | |
- | $current_ahl = $bufr-> | + | $current_ahl = $bufr-> |
- | # Must use \r\r\n after AHL, or else BUFR.pm will not | + | |
- | # recognize AHL. Should I change this in BUFR.pm? | + | if ($option{only_ahl}) { |
- | if ($current_ahl && !$bufr-> | + | print $OUT $current_ahl, |
- | | + | } elsif (!$option{without_ahl}) { |
- | print $OUT $current_ahl, | + | # Use \r\r\n after AHL, since this is the standard |
- | | + | # sequence used in GTS bulletins |
- | print $OUT $current_ahl . " | + | |
- | | + | } |
- | } | + | } |
- | next READLOOP if $option{only_ahl}; | + | next READLOOP if $option{only_ahl}; |
- | my $msg = $bufr-> | + | |
- | print $OUT $msg; | + | print $OUT $msg; |
} | } | ||
} | } | ||
Line 171: | Line 173: | ||
[--ahl < | [--ahl < | ||
[--only_ahl] | [--without_ahl] | [--only_ahl] | [--without_ahl] | ||
+ | [--outfile < | ||
[--reuse_ahl n] | [--reuse_ahl n] | ||
[--help] | [--help] | ||
- | [--outfile < | ||
[--verbose n] | [--verbose n] | ||
Line 195: | Line 197: | ||
| | ||
| | ||
+ | | ||
+ | Will print to < | ||
| | ||
only if immediately preceding | only if immediately preceding | ||
Line 201: | Line 205: | ||
| | ||
more info you might prefer to consult perldoc bufrextract.pl | more info you might prefer to consult perldoc bufrextract.pl | ||
- | | ||
- | Will print to < | ||
| | ||
Line 212: | Line 214: | ||
If the BUFR file(s) are known to consist solely of GTS bulletins, you | If the BUFR file(s) are known to consist solely of GTS bulletins, you | ||
- | probably should use C< | + | might consider setting |
- | extract all (and not only the first) BUFR messages in multi message | + | to extract all (and not only the first) BUFR messages in multi message |
- | bulletins | + | bulletins. Such bulletins are very rare nowadays, however, and see |
+ | also the L</" | ||
corresponding AHL is still extracted (and printed) only once. | corresponding AHL is still extracted (and printed) only once. | ||
Line 231: | Line 234: | ||
next if $bufr-> | next if $bufr-> | ||
+ | |||
+ | Or to extract BUFR messages with TM315009 only: | ||
+ | |||
+ | next if bufr-> | ||
=head1 CAVEAT | =head1 CAVEAT | ||
- | bufrextract.pl expects the character sequence CRCRLF (\r\r\n in perl) | + | Sometimes GTS bulletins are erroneously issued with extra characters |
- | between the AHL and the start of the BUFR message. | + | between the GTS AHL and the start of BUFR message |
- | messages has been prepared from a collection | + | standard character sequence CRCRLF), likely leading bufrextract.pl to |
- | this control character sequence has been removed, you should replace | + | miss the AHL. Also, if applying C< |
- | every ' | + | a GTS bulletin will then be wrongly associated with the AHL of the |
- | in order to get the AHLs or filter on AHL. | + | previous |
+ | kind of error is more of a concern than multi message bulletins, you | ||
+ | should probably refrain from making use of the C< | ||
=head1 AUTHOR | =head1 AUTHOR | ||
Line 247: | Line 256: | ||
=head1 COPYRIGHT | =head1 COPYRIGHT | ||
- | Copyright (C) 2010-2016 MET Norway | + | Copyright (C) 2010-2019 MET Norway |
=cut | =cut | ||
+ | |||
</ | </ |