; 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\STMAT00A.PRN" MSG='Write out station zone, parking cost and terminal time to matrix'
FILEO MATO[1] = "{SCENARIO_DIR}\output\ST2STPK_bus_{alt}{year}.MAT",
 MO=1,21-24,
 NAME=FromStation_pnrb,StationTAZ_pnrb,PKParkCost_pnrb,termtimpnr,termtimknr
FILEI LOOKUPI[1] = "{SCENARIO_DIR}\output\STATION_{alt}{year}.DAT"
FILEI MATI[1] = "{SCENARIO_DIR}\output\ST2STPK3_{alt}{year}.DBF",
 PATTERN=IJM:V FIELDS=I,J,0,FROMNODE

PAR ZONES={ZONESA} zonemsg=100

;STATION PARKING COST INTO A LOOKUP TABLE - station, statnumber, spaces,pnrterm,knrterm,nearestzone(distance),nearestzone(statdata input),ampnrcost,mdpnrcost

LOOKUP LOOKUPI=1, 
  NAME=STATIONS,
  LOOKUP[1]=2, RESULT=3,; STATION ZONE
  LOOKUP[2]=2, RESULT=6,; Peak Period Pakring Cost
  LOOKUP[3]=2,result=8,
  LOOKUP[4]=2,result=9,
  FAIL=0

  MW[1]=MI.1.1 

JLOOP
 ;FIRST FIGURE OUT THE STATION EQUIVALENT FOR EACH CELL, 0 IF NO MATCH
 ;NEXT, ASSIGN THE STATION EQUIVALENT FOR EACH CELL TO A WORK MATRIX
  STATZONE1=STATIONS(1,MW[1][J],0)
  PARKINGCOST1=STATIONS(2,MW[1][J],0)
  termtimpnr=stations(3,MW[1][j],0)
  termtimknr=stations(4,MW[1][j],0)
  MW[21][J]=STATZONE1
  MW[22][J]=PARKINGCOST1
  MW[23][j]=termtimpnr
  MW[24][j]=termtimknr

; If no station for a zone, write 0 as the station
 IF(MW[21][J] == 0) MW[1][J]=0

ENDJLOOP

ENDRUN
