NCEPLIBS-bufr 11.7.1
fstag.f
Go to the documentation of this file.
1C> @file
2C> @author J @date 2014-10-02
3
4C> THIS SUBROUTINE FINDS THE (NUTAG)th OCCURRENCE OF MNEMONIC
5C> UTAG WITHIN THE CURRENT OVERALL SUBSET DEFINITION, STARTING FROM
6C> PARAMETER #(NIN) WITHIN THE SUBSET. THE SUBROUTINE SEARCHES FORWARD
7C> FROM NIN IF NUTAG IS POSITIVE OR ELSE BACKWARD IF NUTAG IS NEGATIVE.
8C>
9C> PROGRAM HISTORY LOG:
10C> 2014-10-02 J. ATOR -- ORIGINAL AUTHOR
11C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
12C>
13C> USAGE: CALL FSTAG (LUN, UTAG, NUTAG, NIN, NOUT, IRET)
14C> INPUT ARGUMENT LIST:
15C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
16C> UTAG - CHARACTER*(*): MNEMONIC
17C> NUTAG - INTEGER: ORDINAL OCCURRENCE OF UTAG TO SEARCH FOR
18C> WITHIN THE OVERALL SUBSET DEFINITION, COUNTING FROM
19C> PARAMETER #(NIN) WITHIN THE SUBSET. THE SUBROUTINE
20C> WILL SEARCH IN A FORWARD DIRECTION FROM PARAMETER
21C> #(NIN) IF NUTAG IS POSITIVE OR ELSE IN A BACKWARD
22C> DIRECTION IF NUTAG IS NEGATIVE.
23C> NIN - INTEGER: LOCATION WITHIN THE OVERALL SUBSET DEFINITION
24C> FROM WHICH TO BEGIN SEARCHING FOR UTAG.
25C>
26C> OUTPUT ARGUMENT LIST:
27C> NOUT - INTEGER: LOCATION OF (NUTAG)th OCCURRENCE OF UTAG
28C> IRET - INTEGER: RETURN CODE
29C> 0 = NORMAL RETURN
30C> -1 = REQUESTED MNEMONIC COULD NOT BE FOUND, OR SOME
31C> OTHER ERROR OCCURRED
32C>
33C> REMARKS:
34C> THIS ROUTINE CALLS: PARSTR
35C> THIS ROUTINE IS CALLED BY: GETTAGPR GETTAGRE GETVALNB NEMSPECS
36C> SETVALNB UFDUMP
37C> Normally not called by any application
38C> programs.
39C>
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
51C----------------------------------------------------------------------
52C----------------------------------------------------------------------
53
54 iret = -1
55
56C 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
61C Starting from NIN, search either forward or backward for the
62C (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 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:41
This module contains array and variable declarations used to store the internal jump/link table.
Definition: moda_tables.F:13
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
Definition: moda_tables.F:132
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:38