	SUBROUTINE FMTNRB(NRB,NRBID,IDCNT)

C.begin.doc ************************** begin.doc
C  
C .c ;MODULE
C .c ;^&FMTNRB\&
C .nf
C .x FMTNRB>Defined
C Source:FMTNRB.FTN
C Designer           :DAVE LUECK
C Author             :DAVE LUECK
C Date of last update:17-MAR-87
C Revision level     :1.0
C  
C .C ;Formal Parameter List
C Receives:
C  
C    NRB                        NRB ARRAY
C  
C    NRBID                      NRB MESSAGE ID ARRAY
C
C    IDCNT                      NUMBER OF MESSAGE IDS ROUTED BY NRB
C
C Returns:
C  
C Accesses common(s):
C  
C .X RTRDBS>Common
C    RTRDBS                     RESIDENT COMMON ROUTING DATABASE
C  
C Accesses file(s):
C  
C Other modules referenced:
C .SK
C .fill
C .SK
C Description:
C .sk    
C	This subroutine formats and displays the contents of each NRB
C in the routing database.  For each NRB, the message ids routed by the
C NRB are also formated and displayed.
C end.doc ****************************** end.doc  

	IMPLICIT COMPLEX (A-Z)

	PARAMETER	NRBSIZ = 93		! SIZE OF NRB IN WORDS (NOT
						!   INCLUDING MSG ID PART)
	PARAMETER	IDSIZ  = 11		! SIZE OF 1 MSG ID PART OF NRB
						!   IN WORDS

	INTEGER*2	NRB(NRBSIZ)		! CONTENTS OF AN NRB 
	INTEGER*2	IDCNT			! NUMBER OF MESG ID'S DEFINED
						!   FOR NRB
	INTEGER*2	NRBID((IDCNT+1)*IDSIZ)	! CONTENTS OF MESG ID PART OF 
						!   NRB
	CHARACTER*1	REPLY			! USER RESPONSE
	INTEGER*2	INDEX,I,K		! INDEXES
C
C	FORMAT OF AN NRB
C
C	NRB(01)    = LUN USED FOR LOGICAL LINK TO REMOTE NODE
C	NRB(02)    = NODE STATUS
C	NRB(03)    = LINK TO NEXT NRB
C	NRB(04-06) = CURRENT NODE 
C	NRB(07-09) = PRIMARY NODE NAME
C	NRB(10-12) = SECONDARY NODE NAME
C	NRB(13-42) = ACCESS CONTROL STRING
C	NRB(43-78) = NETWORK CONNECT BLOCK
C	NRB(79)    = TOTAL MSG ID'S ROUTED BY THIS NODE
C	NRB(80)    = LINK TO INPUT BUFFER
C	NRB(81)    = ADDRESS OF NETWORK RECEIVE I/O STATUS BLOCK
C	NRB(82-83) = NETWORK RECEIVE I/O STATSU BLOCK
C	NRB(84)    = ADDRESS OF CONNECT/DISCONNECT I/O STATUS BLOCK
C	NRB(85-86) = CONNECT/DISCONNECT I/O STATUS BLOCK
C	NRB(87)    = ADDRESS OF NETWORK DATA I/O STATUS BLOCK
C	NRB(88-89) = NETWORK DATA I/O STATSU BLOCK
C	NRB(90)    = INBOUND LINK SEQUENCE NUMBER
C	NRB(91)    = OUTBOUND LINK SEQUENCE NUMBER
C	NRB(92)    = ADDRESS OF LAST SCANNED OUTBOUND NRBID
C	NRB(93)    = CONNECT/DISCONNECT STATUS FOR WRITE TO QUEUE
C
C
C	FORMAT OF AN NRBID (MESSAGE ID)
C
C	NRBID(01)    = ADDRESS OF MESSAGE ID LISTHEAD (REGION 'QUEHED')
C	NRBID(02)    = RNA OF THIS MESSAGE ID
C	NRBID(03)    = MESSAGE ID STATUS
C	NRBID(04-11) = MESSAGE ID NAME
C

C	PROMPT USER TO ENTER CONTINUE OR EXIT RESPONSE

	WRITE (5,900)
900	FORMAT(/'$HIT <RETURN> TO DISPLAY NRB; <CTRL-Z> TO EXIT: ')
	READ  (5,950,END=5000) REPLY
950	FORMAT(A1)

C	FORMAT AND DISPLAY NRB CONTENTS (PART 1)

	WRITE (5,1000) 
1000	FORMAT(///' NRB Display'/)

	WRITE (5,1100) (NRB(I),I=4,6)
1100	FORMAT('    Current node ................................ ',3A2)

	WRITE (5,1110) (NRB(I),I=7,9)
1110	FORMAT('    Primary node name ........................... ',3A2)

	WRITE (5,1120) (NRB(I),I=10,12)
1120	FORMAT('    Secondary node name ......................... ',3A2)

	WRITE (5,1130) NRB(2)
1130	FORMAT(/'    NRB status word ............................. ',O6.6,
	1      /'    Current NRB status ...... ')

C	DETERMINE WHICH STATUS BITS ARE SET AND DISPLAY APPROPRIATE MSG

	IF ((NRB(2).AND."000001) .NE. 0) WRITE (5,1140)	
	IF ((NRB(2).AND."000002) .NE. 0) WRITE (5,1141)	
	IF ((NRB(2).AND."000004) .NE. 0) WRITE (5,1142)	
	IF ((NRB(2).AND."000010) .NE. 0) WRITE (5,1143)	
	IF ((NRB(2).AND."000020) .NE. 0) WRITE (5,1144)	
	IF ((NRB(2).AND."000040) .NE. 0) WRITE (5,1145)	
	IF ((NRB(2).AND."000100) .NE. 0) WRITE (5,1146)	
	IF ((NRB(2).AND."000200) .NE. 0) WRITE (5,1147)	
	IF ((NRB(2).AND."000400) .NE. 0) WRITE (5,1148)	
	IF ((NRB(2).AND."001000) .NE. 0) WRITE (5,1149)	
	
1140	FORMAT('       node is available')
1141	FORMAT('       node is down')
1142	FORMAT('       local connect in progress')
1143	FORMAT('       connect timer is active')
1144	FORMAT('       secondary node is selected')
1145	FORMAT('       primary node is selected')
1146	FORMAT('       remote node requested the connection')
1147	FORMAT('       primary node name is a logical node name')
1148	FORMAT('       the node the service is currently on is defined')
1149	FORMAT('       local disconnect in progress')

	WRITE (5,1190) NRB(1)
1190	FORMAT(/'    Logical Unit Number used to connect ......... ',I6)

	WRITE (5,1195) NRB(79)
1195	FORMAT('    Number of message ids routed to this node ... ',I6)

	WRITE (5,1200) NRB(90)
1200	FORMAT('    Inbound sequence number ..................... ',I6)

	WRITE (5,1210) NRB(90)
1210	FORMAT('    Outbound sequence number .................... ',I6)

C	PROMPT USER TO ENTER CONTINUE OR EXIT RESPONSE

	WRITE (5,1212)
1212	FORMAT(/'$HIT <RETURN> TO DISPLAY REST OF NRB; <CTRL-Z> TO EXIT: ')
	READ  (5,1215,END=5000) REPLY
1215	FORMAT(A1)

C	FORMAT AND DISPLAY NRB CONTENTS (PART 2)

	WRITE (5,1220) (NRB(I),I=13,42)
1220	FORMAT(/'    Access Control String (between ''*'') ......... '/
	1      7X,'*',30A2,'*')

	WRITE (5,1225) (NRB(I),I=43,45),(NRB(I),I=48,55),
	1	       (NRB(I),I=57,64),(NRB(I),I=66,78)
1225	FORMAT(/'    Network Contol Block (between ''*'') .......... '/
	1      7X,'*',3A2,8A2,8A2,13A2,'*')

	WRITE (5,1230) NRB(3)
1230	FORMAT(/'    Address of next NRB ......................... ',O6.6)

	WRITE (5,1235) NRB(80)
1235	FORMAT('    Address of input buffer ..................... ',O6.6)

	WRITE (5,1240) NRB(92)
1240	FORMAT('    Address of last NRBID scanned for output .... ',O6.6)

C	PROMPT USER TO ENTER CONTINUE OR EXIT RESPONSE

	WRITE (5,3000)
3000	FORMAT(/'$HIT <RETURN> TO DISPLAY NRBID LIST; <CTRL-Z> TO EXIT: ')
	READ  (5,3100,END=5000) REPLY
3100	FORMAT(A1)

C	CHECK FOR NRBID INFO TO DISPLAY; RETURN IF NONE

	IF (IDCNT.EQ.0) THEN
		WRITE (5,3500)
3500		FORMAT(///' No NRBID LIST; No messages routed to this node')
		RETURN
	END IF

C	FORMAT AND DISPLAY NRBID CONTENTS 

	WRITE (5,4000) 
4000	FORMAT(///' NRBID Display')
	
	K = 0

	DO 4500 INDEX=1,IDCNT

		WRITE (5,4100) (NRBID(I),I=K+4,K+11)
4100		FORMAT(/'    Message Id ........................... ',8A2)
		
		WRITE (5,4110) NRBID(K+1)
4110		FORMAT('       Address of header in ''QUEHED'' ..... ',O6.6)

		WRITE (5,4115) NRBID(K+2)
4115		FORMAT('       RNA ............................... ',I6)

		WRITE (5,4120) NRBID(K+3)
4120		FORMAT('       NRB status word ................... ',O6.6,
	1      	       /'       Current NRB status ...... ')

		IF ((NRBID(K+3).AND."000001) .NE. 0) WRITE (5,4130)	
		IF ((NRBID(K+3).AND."000001) .EQ. 0) WRITE (5,4140)	

4130		FORMAT('          messages are not being routed')
4140		FORMAT('          messages can be routed')

C		DISPLAY ONLY THREE NRBID'S (MESSAGE ID'S) AT ONE TIME
C		PROMPT USER TO CONTINUE OR EXIT

		IF (IMOD(INDEX,3).NE.0 .OR. INDEX.EQ.IDCNT) GOTO 4300

		WRITE (5,4200)
4200		FORMAT(/'$HIT <RETURN> TO DISPLAY REST OF NRBID; ',
	1      	       '<CTRL-Z> TO EXIT: ')
		READ  (5,4210,END=5000) REPLY
4210		FORMAT(A1)

4300		K = K + IDSIZ

4500	CONTINUE

	RETURN

5000	CONTINUE
	WRITE (5,5100)
5100	FORMAT(//' NRBDMP -- EXIT'//)
	CALL EXIT

	END	
