NCEPLIBS-bufr  12.0.0
copybf.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Copy an entire BUFR file.
3 C>
4 C> @author J. Woollen @date 1994-01-06
5 
6 C> This subroutine copies an entire BUFR file from one Fortran
7 C> logical unit to another.
8 C>
9 C> @param[in] LUNIN -- integer: Fortran logical unit number for
10 C> source BUFR file
11 C> @param[in] LUNOT -- integer: Fortran logical unit number for
12 C> target BUFR file
13 C>
14 C> The logical unit numbers LUNIN and LUNOT must already be
15 C> associated with actual filenames on the local system, typically
16 C> via a Fortran "OPEN" statement.
17 C>
18 C> @remarks
19 C> - This subroutine uses subroutine msgwrt() to copy each BUFR
20 C> message from LUNIN to LUNOT; therefore, this subroutine can be
21 C> used to create a copy of LUNIN where each corresponding message
22 C> in LUNOT contains any or all of the updates described in the
23 C> documentation for subroutine msgwrt().
24 C>
25 C> @author J. Woollen @date 1994-01-06
26  RECURSIVE SUBROUTINE copybf(LUNIN,LUNOT)
27 
28  USE moda_mgwa
29  USE modv_im8b
30 
31 C-----------------------------------------------------------------------
32 C-----------------------------------------------------------------------
33 
34 C CHECK FOR I8 INTEGERS
35 C ---------------------
36  IF(im8b) THEN
37  im8b=.false.
38 
39  CALL x84(lunin,my_lunin,1)
40  CALL x84(lunot,my_lunot,1)
41  CALL copybf(my_lunin,my_lunot)
42 
43  im8b=.true.
44  RETURN
45  ENDIF
46 
47 C CALL SUBROUTINE WRDLEN TO INITIALIZE SOME IMPORTANT INFORMATION
48 C ABOUT THE LOCAL MACHINE (IN CASE IT HAS NOT YET BEEN CALLED)
49 C ---------------------------------------------------------------
50 
51  CALL wrdlen
52 
53 C CHECK BUFR FILE STATUSES
54 C ------------------------
55 
56  CALL status(lunin,lun,il,im)
57  IF(il.NE.0) GOTO 900
58  CALL status(lunot,lun,il,im)
59  IF(il.NE.0) GOTO 901
60 
61 C CONNECT THE FILES FOR READING/WRITING TO THE C-I-O INTERFACE
62 C ------------------------------------------------------------
63 
64  CALL openbf(lunin,'INX',lunin)
65  CALL openbf(lunot,'OUX',lunin)
66 
67 C READ AND COPY A BUFR FILE ON UNIT LUNIN TO UNIT LUNOT
68 C -----------------------------------------------------
69 
70 1 CALL rdmsgw(lunin,mgwa,ier)
71  IF(ier.EQ.0) THEN
72  CALL msgwrt(lunot,mgwa,iupbs01(mgwa,'LENM'))
73  GOTO 1
74  ENDIF
75 
76 C FREE UP THE FILE CONNECTIONS FOR THE TWO FILES
77 C ----------------------------------------------
78 
79  CALL closbf(lunin)
80  CALL closbf(lunot)
81 
82 C EXITS
83 C -----
84 
85  RETURN
86 900 CALL bort
87  . ('BUFRLIB: COPYBF - INPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
88 901 CALL bort
89  . ('BUFRLIB: COPYBF - OUTPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
90  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive subroutine closbf(LUNIT)
Close the connection between logical unit LUNIT and the NCEPLIBS-bufr software.
Definition: closbf.f:24
recursive subroutine copybf(LUNIN, LUNOT)
This subroutine copies an entire BUFR file from one Fortran logical unit to another.
Definition: copybf.f:27
recursive function iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
subroutine msgwrt(LUNIT, MESG, MGBYT)
Perform final checks and updates on a BUFR message before writing it to a specified Fortran logical u...
Definition: msgwrt.f:38
This module contains a declaration for an array used by various subroutines and functions to hold a t...
integer, dimension(:), allocatable mgwa
Temporary working copy of BUFR message.
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
recursive subroutine openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124
subroutine rdmsgw(lunit, mesg, iret)
Read the next BUFR message from logical unit lunit as an array of integer words.
Definition: rdmsgw.F90:16
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36
subroutine wrdlen
Determine important information about the local machine.
Definition: wrdlen.F:25
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19