Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 1618 develop pb2nc #1623

Merged
merged 2 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion met/src/tools/other/pb2nc/numpbmsg.f
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,29 @@ SUBROUTINE NUMPBMSG ( FID, NMSG )
C*
END



SUBROUTINE NUMPBMSG_NEW ( PBFILE, FID, NMSG )
C*
INCLUDE 'readpb.prm'
C*
CHARACTER PBFILE*(FILEMXSTRL)
INTEGER FID, FID2
INTEGER NMSG
REAL*8 R8ARR(1, 1)
C*
C-----------------------------------------------------------------------
C*
C* Call UFBTAB to figure out how many messages the PrepBufr file
C* attached to FID contains
C*
OPEN ( UNIT = FID, FILE = PBFILE, FORM = 'UNFORMATTED' )
FID2 = -FID
CALL UFBTAB ( FID2, R8ARR, 1, 1, NMSG, ' ' )
CLOSE ( UNIT = FID )
C*
END


SUBROUTINE GET_TMIN ( FID, TMIN )
C*
INTEGER FID, TMIN
Expand Down
9 changes: 5 additions & 4 deletions met/src/tools/other/pb2nc/pb2nc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ static NcFile *f_out = (NcFile *) 0;

extern "C" {
void numpbmsg_(int *, int *);
void numpbmsg_new_(const char *, int *, int *);
void openpb_(const char *, int *);
void closepb_(int *);
void readpb_(int *, int *, int *, double[mxr8pm],
Expand Down Expand Up @@ -2050,14 +2051,14 @@ void process_pbfile_metadata(int i_pb) {
<< "Invalid file ID [" << unit << "] between 1 and 99.\n\n";
}

// Open the blocked temp PrepBufr file for reading
openpb_(blk_file.c_str(), &unit);

// Compute the number of PrepBufr records in the current file.
numpbmsg_(&unit, &npbmsg);
numpbmsg_new_(blk_file.c_str(), &unit, &npbmsg);
mlog << Debug(1) << method_name << " -> "
<< "the number of records: " << npbmsg << "\n";

// Open the blocked temp PrepBufr file for reading
openpb_(blk_file.c_str(), &unit);

// Use the number of records requested by the user if there
// are enough present.
if(nmsg >= 0 && nmsg <= npbmsg) {
Expand Down