NCEPLIBS-bufr  12.0.1
fstag.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Search for a specified occurrence of a specified mnemonic within
3 C> a data subset definition, starting from a specified location.
4 C>
5 C> @author J Ator @date 2014-10-02
6 
7 C> This subroutine finds the (NUTAG)th occurrence of mnemonic
8 C> UTAG within the current overall subset definition, starting from
9 C> parameter #(NIN) within the subset. The subroutine searches forward
10 C> from NIN if NUTAG is positive or else backward if NUTAG is negative.
11 C>
12 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
13 C> @param[in] UTAG - character*(*): mnemonic.
14 C> @param[in] NUTAG - integer: ordinal occurrence of UTAG to search for within
15 C> the overall subset definition, counting from parameter #(NIN) within the subset.
16 C> The subroutine will search in a forward direction from parameter #(NIN) if
17 C> NUTAG is positive or else in a backward direction if NUTAG is negative.
18 C> @param[in] NIN - integer: location within the overall subset definition from which to begin searching for UTAG.
19 C> @param[out] NOUT - integer: location of (NUTAG)th occurrence of UTAG.
20 C> @param[out] IRET - integer: return code.
21 C> - 0 Normal return.
22 C> - -1 Requested mnemonic could not be found, or some other error occurred.
23 C>
24 C> @author J. Ator @date 2014-10-02
25  SUBROUTINE fstag ( LUN, UTAG, NUTAG, NIN, NOUT, IRET )
26 
27  USE moda_usrint
28  USE moda_tables
29 
30  CHARACTER*10 TGS(15)
31 
32  CHARACTER*(*) UTAG
33 
34  DATA maxtg /15/
35 
36 C----------------------------------------------------------------------
37 C----------------------------------------------------------------------
38 
39  iret = -1
40 
41 C Confirm that there is only one mnemonic in the input string.
42 
43  CALL parstr( utag, tgs, maxtg, ntg, ' ', .true. )
44  IF ( ntg .ne .1 ) RETURN
45 
46 C Starting from NIN, search either forward or backward for the
47 C (NUTAG)th occurrence of UTAG.
48 
49  IF ( nutag .EQ. 0 ) RETURN
50  istep = isign( 1, nutag )
51  itagct = 0
52  nout = nin + istep
53  DO WHILE ( ( nout .GE. 1 ) .AND. ( nout .LE. nval(lun) ) )
54  IF ( tgs(1) .EQ. tag(inv(nout,lun)) ) THEN
55  itagct = itagct + 1
56  IF ( itagct .EQ. iabs(nutag) ) THEN
57  iret = 0
58  RETURN
59  ENDIF
60  ENDIF
61  nout = nout + istep
62  ENDDO
63 
64  RETURN
65  END
subroutine fstag(LUN, UTAG, NUTAG, NIN, NOUT, IRET)
This subroutine finds the (NUTAG)th occurrence of mnemonic UTAG within the current overall subset def...
Definition: fstag.f:26
This module contains array and variable declarations used to store the internal jump/link table.
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:), allocatable nval
Number of data values in BUFR data subset.
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
Parse a string containing one or more substrings into an array of substrings.
Definition: parstr.f:24