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