Skip to content

Commit

Permalink
Bugfix 1618 develop pb2nc (#1623)
Browse files Browse the repository at this point in the history
Co-authored-by: Howard Soh <[email protected]>
  • Loading branch information
hsoh-u and Howard Soh authored Jan 19, 2021
1 parent ca49ffc commit 12b0de0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
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

0 comments on commit 12b0de0

Please sign in to comment.