NCEPLIBS-bufr  11.7.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> | Date | Programmer | Comments |
28 C> | -----|------------|----------|
29 C> | 1994-01-06 | J. Woollen | Original author |
30 C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine ABORT with call to new internal routine bort() |
31 C> | 2000-09-19 | J. Woollen | Maximum message length increased from 10,000 to 20,000 bytes |
32 C> | 2004-08-09 | J. Ator | Maximum message length increased from 20,000 to 50,000 bytes |
33 C> | 2005-11-29 | J. Ator | Use rdmsgw() and iupbs01() |
34 C> | 2012-09-15 | J. Woollen | Modified for C/I/O/BUFR interface; use status() |
35 C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
36 C>
37  SUBROUTINE copybf(LUNIN,LUNOT)
38 
39  USE moda_mgwa
40 
41 C-----------------------------------------------------------------------
42 C-----------------------------------------------------------------------
43 
44 C CALL SUBROUTINE WRDLEN TO INITIALIZE SOME IMPORTANT INFORMATION
45 C ABOUT THE LOCAL MACHINE (IN CASE IT HAS NOT YET BEEN CALLED)
46 C ---------------------------------------------------------------
47 
48  CALL wrdlen
49 
50 C CHECK BUFR FILE STATUSES
51 C ------------------------
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 
58 C CONNECT THE FILES FOR READING/WRITING TO THE C-I-O INTERFACE
59 C ------------------------------------------------------------
60 
61  CALL openbf(lunin,'INX',lunin)
62  CALL openbf(lunot,'OUX',lunin)
63 
64 C READ AND COPY A BUFR FILE ON UNIT LUNIN TO UNIT LUNOT
65 C -----------------------------------------------------
66 
67 1 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 
73 C FREE UP THE FILE CONNECTIONS FOR THE TWO FILES
74 C ----------------------------------------------
75 
76  CALL closbf(lunin)
77  CALL closbf(lunot)
78 
79 C EXITS
80 C -----
81 
82  RETURN
83 900 CALL bort
84  . ('BUFRLIB: COPYBF - INPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
85 901 CALL bort
86  . ('BUFRLIB: COPYBF - OUTPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
87  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:54
subroutine copybf(LUNIN, LUNOT)
This subroutine copies an entire BUFR file from one Fortran logical unit to another.
Definition: copybf.f:37
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 closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
Definition: closbf.f:34
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.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:138
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:35
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message...
Definition: iupbs01.f:73