; Do not change filenames or add or remove FILEI/FILEO statements using an editor. Use Cube/Application Manager.
RUN PGM=MATRIX PRNFILE="{Scenario_Dir}\OUTPUT\HNMAT00A.PRN" MSG='Count Times Nodes Used by Links'
FILEO RECO[1] = "{Scenario_Dir}\OUTPUT\NODECNT.DBF",
FIELDS=N,TIMESUSED
FILEI RECI = "{Scenario_Dir}\OUTPUT\LINK4CNT.DBF"

ARRAY NODECNT=999999

NODECNT[RI.A]=NODECNT[RI.A]+1
NODECNT[RI.B]=NODECNT[RI.B]+1
IF (RI.A>HINODE) HINODE=RI.A
IF (RI.B>HINODE) HINODE=RI.B

IF (I=0)

  LOOP N=1,HINODE
    IF (NODECNT[N]>0)
     TIMESUSED=NODECNT[N] 
     WRITE RECO=1
    ENDIF
  ENDLOOP

ENDIF

; The MATRIX module does not have any explicit phases.  The module does run within an implied ILOOP
; where I is the origin zones.  All user statements in the module are processed once for each origin.
; Matrix computation (MW[#]=) are solved for all values of J for each I.  Thus for a given origin zone I
; the values for all destination zones J are automatically computed.  The user can control the computations
; at each J by using a JLOOP.

ENDRUN
