NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
copybf.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Copy an entire BUFR file.
3 
4 C> This subroutine copies an entire BUFR file from one Fortran
5 C> logical unit to another.
6 C>
7 C> @author J. Woollen
8 C> @date 1994-01-06
9 C>
10 C> @param[in] LUNIN - integer: Fortran logical unit number for
11 C> source BUFR file
12 C> @param[in] LUNOT - integer: Fortran logical unit number for
13 C> target BUFR file
14 C>
15 C> <p>The logical unit numbers LUNIN and LUNOT must already be
16 C> associated with actual filenames on the local system, typically
17 C> via a Fortran "OPEN" statement.
18 C>
19 C> @remarks
20 C> - This subroutine uses subroutine msgwrt() to copy each BUFR
21 C> message from LUNIN to LUNOT; therefore, this subroutine can be
22 C> used to create a copy of LUNIN where each corresponding message
23 C> in LUNOT contains any or all of the updates described in the
24 C> documentation for subroutine msgwrt().
25 C>
26 C> <b>Program history log:</b>
27 C> - 1994-01-06 J. Woollen -- Original author
28 C> - 1998-07-08 J. Woollen -- Replaced call to Cray library routine ABORT
29 C> with call to new internal routine bort()
30 C> - 2000-09-19 J. Woollen -- Maximum message length increased
31 C> from 10,000 to 20,000 bytes
32 C> - 2004-08-09 J. Ator -- Maximum message length increased
33 C> from 20,000 to 50,000 bytes
34 C> - 2005-11-29 J. Ator -- Use rdmsgw() and iupbs01()
35 C> - 2012-09-15 J. Woollen -- Modified for C/I/O/BUFR interface;
36 C> use status()
37 C> - 2014-12-10 J. Ator -- Use modules instead of COMMON blocks
38 C>
39  SUBROUTINE copybf(LUNIN,LUNOT)
40 
41  USE moda_mgwa
42 
43 C-----------------------------------------------------------------------
44 C-----------------------------------------------------------------------
45 
46 C CALL SUBROUTINE WRDLEN TO INITIALIZE SOME IMPORTANT INFORMATION
47 C ABOUT THE LOCAL MACHINE (IN CASE IT HAS NOT YET BEEN CALLED)
48 C ---------------------------------------------------------------
49 
50  CALL wrdlen
51 
52 C CHECK BUFR FILE STATUSES
53 C ------------------------
54 
55  CALL status(lunin,lun,il,im)
56  IF(il.NE.0) goto 900
57  CALL status(lunot,lun,il,im)
58  IF(il.NE.0) goto 901
59 
60 C CONNECT THE FILES FOR READING/WRITING TO THE C-I-O INTERFACE
61 C ------------------------------------------------------------
62 
63  CALL openbf(lunin,'INX',lunin)
64  CALL openbf(lunot,'OUX',lunin)
65 
66 C READ AND COPY A BUFR FILE ON UNIT LUNIN TO UNIT LUNOT
67 C -----------------------------------------------------
68 
69 1 CALL rdmsgw(lunin,mgwa,ier)
70  IF(ier.EQ.0) THEN
71  CALL msgwrt(lunot,mgwa,iupbs01(mgwa,'LENM'))
72  goto 1
73  ENDIF
74 
75 C FREE UP THE FILE CONNECTIONS FOR THE TWO FILES
76 C ----------------------------------------------
77 
78  CALL closbf(lunin)
79  CALL closbf(lunot)
80 
81 C EXITS
82 C -----
83 
84  RETURN
85 900 CALL bort
86  . ('BUFRLIB: COPYBF - INPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
87 901 CALL bort
88  . ('BUFRLIB: COPYBF - OUTPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
89  END
subroutine msgwrt(LUNIT, MESG, MGBYT)
This subroutine performs final checks and updates on a BUFR message before writing it to a specified ...
Definition: msgwrt.f:69
subroutine copybf(LUNIN, LUNOT)
This subroutine copies an entire BUFR file from one Fortran logical unit to another.
Definition: copybf.f:39
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
Definition: closbf.F:36
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
Definition: openbf.F:157
subroutine rdmsgw(LUNIT, MESG, IRET)
THIS SUBROUTINE READS THE NEXT BUFR MESSAGE FROM LOGICAL UNIT LUNIT AS AN ARRAY OF INTEGER WORDS...
Definition: rdmsgw.f:37
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:61
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:43
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message...
Definition: iupbs01.f:72