NCEPLIBS-bufr 11.7.1
posapx.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE READS TO THE END OF THE FILE POINTED TO BY
5C> ABS(LUNXX) AND POSITIONS IT FOR APPENDING. THE FILE MUST HAVE
6C> ALREADY BEEN OPENED FOR OUTPUT OPERATIONS. IF LUNXX > 0, THE FILE
7C> IS BACKSPACED BEFORE BEING POSITIONED FOR APPEND.
8C>
9C> PROGRAM HISTORY LOG:
10C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
11C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
12C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
13C> ROUTINE "BORT"
14C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
15C> 10,000 TO 20,000 BYTES
16C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
17C> INTERDEPENDENCIES
18C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
19C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
20C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
21C> TERMINATES ABNORMALLY
22C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
23C> 20,000 TO 50,000 BYTES
24C> 2009-03-23 J. ATOR -- MODIFIED TO HANDLE EMBEDDED BUFR TABLE
25C> (DICTIONARY) MESSAGES; ADDED LUNXX < 0
26C> OPTION TO SIMULATE POSAPN
27C> 2010-05-11 J. ATOR -- SET ISCODES TO -1 IF UNSUCCESSFUL
28C> 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
29C> REPLACE FORTRAN BACKSPACE WITH C BACKBUFR
30C> REMOVE UNECESSARY ERROR CHECKING LOGIC
31C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
32C>
33C> USAGE: CALL POSAPX (LUNXX)
34C> INPUT ARGUMENT LIST:
35C> LUNXX - INTEGER: ABSOLUTE VALUE IS FORTRAN LOGICAL UNIT NUMBER
36C> FOR BUFR FILE (IF LUNXX < 0, THEN THE FILE IS NOT
37C> BACKSPACED BEFORE POSITIONING FOR APPEND)
38C>
39C> INPUT FILES:
40C> UNIT "LUNIT" - BUFR FILE
41C>
42C> REMARKS:
43C> THIS ROUTINE CALLS: BORT IDXMSG RDBFDX RDMSGW
44C> STATUS BACKBUFR
45C> THIS ROUTINE IS CALLED BY: OPENBF
46C> Normally not called by any application
47C> programs.
48C>
49 SUBROUTINE posapx(LUNXX)
50
51 USE moda_mgwa
52
53C-----------------------------------------------------------------------
54C-----------------------------------------------------------------------
55
56 lunit = abs(lunxx)
57
58 CALL status(lunit,lun,il,im)
59 IF(il.EQ.0) GOTO 901
60 IF(il.LT.0) GOTO 902
61
62C TRY TO READ TO THE END OF THE FILE
63C ----------------------------------
64
651 CALL rdmsgw(lunit,mgwa,ier)
66 IF(ier.LT.0) RETURN
67 IF(idxmsg(mgwa).EQ.1) THEN
68
69C This is an internal dictionary message that was generated by the
70C BUFR archive library software. Backspace the file pointer and
71C then read and store all such dictionary messages (they should be
72C stored consecutively!) and reset the internal tables.
73
74 CALL backbufr(lun) !BACKSPACE LUNIT
75 CALL rdbfdx(lunit,lun)
76
77 ENDIF
78 GOTO 1
79
80C ERROR EXITS
81C -----------
82
83901 CALL bort('BUFRLIB: POSAPX - INPUT BUFR FILE IS CLOSED, IT MUST'//
84 . ' BE OPEN FOR OUTPUT')
85902 CALL bort('BUFRLIB: POSAPX - INPUT BUFR FILE IS OPEN FOR INPUT'//
86 . ', IT MUST BE OPEN FOR OUTPUT')
87 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
void backbufr(f77int *nfile)
This subroutine backspaces a BUFR file by one BUFR message.
Definition: cread.c:84
function idxmsg(MESG)
This function determines whether a given BUFR message contains DX BUFR tables information that was ge...
Definition: idxmsg.f:24
subroutine posapx(LUNXX)
THIS SUBROUTINE READS TO THE END OF THE FILE POINTED TO BY ABS(LUNXX) AND POSITIONS IT FOR APPENDING.
Definition: posapx.f:50
subroutine rdbfdx(LUNIT, LUN)
BEGINNING AT THE CURRENT FILE POINTER LOCATION WITHIN LUNIT, THIS SUBROUTINE READS A COMPLETE DICTION...
Definition: rdbfdx.f:71
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