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