NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
fstag.f
Go to the documentation of this file.
1 C> @file
2 C> @author J @date 2014-10-02
3 
4 C> THIS SUBROUTINE FINDS THE (NUTAG)th OCCURRENCE OF MNEMONIC
5 C> UTAG WITHIN THE CURRENT OVERALL SUBSET DEFINITION, STARTING FROM
6 C> PARAMETER #(NIN) WITHIN THE SUBSET. THE SUBROUTINE SEARCHES FORWARD
7 C> FROM NIN IF NUTAG IS POSITIVE OR ELSE BACKWARD IF NUTAG IS NEGATIVE.
8 C>
9 C> PROGRAM HISTORY LOG:
10 C> 2014-10-02 J. ATOR -- ORIGINAL AUTHOR
11 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
12 C>
13 C> USAGE: CALL FSTAG (LUN, UTAG, NUTAG, NIN, NOUT, IRET)
14 C> INPUT ARGUMENT LIST:
15 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
16 C> UTAG - CHARACTER*(*): MNEMONIC
17 C> NUTAG - INTEGER: ORDINAL OCCURRENCE OF UTAG TO SEARCH FOR
18 C> WITHIN THE OVERALL SUBSET DEFINITION, COUNTING FROM
19 C> PARAMETER #(NIN) WITHIN THE SUBSET. THE SUBROUTINE
20 C> WILL SEARCH IN A FORWARD DIRECTION FROM PARAMETER
21 C> #(NIN) IF NUTAG IS POSITIVE OR ELSE IN A BACKWARD
22 C> DIRECTION IF NUTAG IS NEGATIVE.
23 C> NIN - INTEGER: LOCATION WITHIN THE OVERALL SUBSET DEFINITION
24 C> FROM WHICH TO BEGIN SEARCHING FOR UTAG.
25 C>
26 C> OUTPUT ARGUMENT LIST:
27 C> NOUT - INTEGER: LOCATION OF (NUTAG)th OCCURRENCE OF UTAG
28 C> IRET - INTEGER: RETURN CODE
29 C> 0 = NORMAL RETURN
30 C> -1 = REQUESTED MNEMONIC COULD NOT BE FOUND, OR SOME
31 C> OTHER ERROR OCCURRED
32 C>
33 C> REMARKS:
34 C> THIS ROUTINE CALLS: PARSTR
35 C> THIS ROUTINE IS CALLED BY: GETTAGPR GETTAGRE GETVALNB NEMSPECS
36 C> SETVALNB UFDUMP
37 C> Normally not called by any application
38 C> programs.
39 C>
40  SUBROUTINE fstag ( LUN, UTAG, NUTAG, NIN, NOUT, IRET )
41 
42  USE moda_usrint
43  USE moda_tables
44 
45  CHARACTER*10 tgs(15)
46 
47  CHARACTER*(*) utag
48 
49  DATA maxtg /15/
50 
51 C----------------------------------------------------------------------
52 C----------------------------------------------------------------------
53 
54  iret = -1
55 
56 C Confirm that there is only one mnemonic in the input string.
57 
58  CALL parstr( utag, tgs, maxtg, ntg, ' ', .true. )
59  IF ( ntg .ne .1 ) RETURN
60 
61 C Starting from NIN, search either forward or backward for the
62 C (NUTAG)th occurrence of UTAG.
63 
64  IF ( nutag .EQ. 0 ) RETURN
65  istep = isign( 1, nutag )
66  itagct = 0
67  nout = nin + istep
68  DO WHILE ( ( nout .GE. 1 ) .AND. ( nout .LE. nval(lun) ) )
69  IF ( tgs(1) .EQ. tag(inv(nout,lun)) ) THEN
70  itagct = itagct + 1
71  IF ( itagct .EQ. iabs(nutag) ) THEN
72  iret = 0
73  RETURN
74  ENDIF
75  ENDIF
76  nout = nout + istep
77  ENDDO
78 
79  RETURN
80  END
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS...
Definition: parstr.f:37
This module contains array and variable declarations used to store the internal jump/link table...
Definition: moda_tables.F:13
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:40