C ---------------------------------------------------------------------- INTEGER FUNCTION DYNAINIT(io,sim,net,act,veh) C ---------------------------------------------------------------------- C - Performs all initialization of simulation storage, reads in C - network data from the input data set... C - INCLUDED FILES: #include "dyna.inc" #include "io.inc" #include "sim.inc" #include "network.inc" #include "activity.inc" #include "vehicle.inc" C - UNMODIFIED ARGUMENTS: ! NONE C - MODIFIED ARGUMENTS: RECORD /Io_Data/ io RECORD /Sim_Data/ sim RECORD /Road_Network/ net RECORD /Activity/ act RECORD /Vehicle_Data/ veh(NU_VE) C - MODIFIED GLOBAL DATA: ! NONE C - LOCAL VARIABLES: INTEGER i,j,k,iz,ico INTEGER i1,i2,ix,iy INTEGER i3,i4 INTEGER interval,izz INTEGER izn INTEGER ires C - FUNCTIONS CALLED: INTEGER NODE_SIGFUN ! function INTEGER LINK_PENALTYCAL ! function INTEGER INIT_PATHS ! function INTEGER EXTERNAL_INIT ! function C - RETURN VALUE: ! Simulation status C ---------------------------------------------------------------------- CALL SIMMSG(STATUS,'') C - Clear simulation, network, and demand data CALL SIM_CLEAR(sim) CALL NETWORK_CLEAR(net) CALL ACTIVITY_CLEAR(act) C - Read simulation options REWIND(PARAMETER_FILE) CALL READSTAT('simulation options',PARAMETER_FILE) CALL OPTIONS_READ(PARAMETER_FILE,sim,net,act) C - Initialize simulation parameters CALL SIM_INIT(io,sim) net.spd.p.kay = sim.kay C - Initialize (including read) network data CALL NETWORK_INIT(sim,net) C - Initialize (including read) demand data CALL ACTIVITY_INIT(sim,act) C - Connect the network and the activity CALL RECONCILE(net,act) C - Initialize vehicle data CALL VEHICLE_INIT(sim,net,veh) C - Initialize statistics collection CALL STATS_INIT(sim,net,act) C - Initialize intersection movement capacities DO i = 1,net.nnodes j = NODE_SIGFUN(sim,net,i) ENDDO C - initialize penalty arrays for first call to C - shortest path routine (so that movements not C - specified in move.dat cannot be part of a C - shortest path). DO i = 1,net.nlinks j = LINK_PENALTYCAL(sim,net,i) ENDDO C - Initialize externals ires = EXTERNAL_INIT(io,sim,net,act,veh) IF (ires.NE.0) THEN CALL DYNA_ERROR('Error in EXTERNAL_INIT'//CHAR(0) + ,DYNA_FATAL_ERROR + ,DYNA_LOGIC_BUG + ,DYNA_EXTERNAL_INIT_ERROR) ENDIF C - Initialize path data ires = INIT_PATHS(io,sim,net,act) IF (ires.NE.0) THEN CALL DYNA_ERROR('Error in INIT_PATHS'//CHAR(0) + ,DYNA_FATAL_ERROR + ,DYNA_LOGIC_BUG + ,DYNA_INIT_PATHS_ERROR) ENDIF C - Send a blank line to the screen WRITE(ostr,'(A)') CHAR(0) CALL SIMMSG(STATUS,ostr) Cr - Flag simulation status as ready to run IF (sim.status.NE.SIM_ERROR) sim.status = SIM_IN_PROGRESS DYNAINIT = sim.status RETURN END BLOCK DATA INIT_GLOBAL_DATA #include "dyna.inc" #include "move.inc" #include "link.inc" DATA movestring /'left','through','right','u-turn' + ,'other','connector','unknown'/ DATA linkstring /'freeway','unknown','on-ramp','off-ramp' + ,'arterial','connector'/ END C ---------------------------------------------------------------------- SUBROUTINE RECONCILE(net,act) C ---------------------------------------------------------------------- C - Reconciles the road network data in net with the demand data in C - act. Basically, this routine handles the "connecting" of the C - network data structures with the activity data structures #include "dyna.inc" #include "network.inc" #include "activity.inc" RECORD /Road_Network/ net RECORD /Activity/ act INTEGER i,j,i1,iz,idz C - Convert the temporarily stored user zone number to a DYNASMART C - (internal) zone index DO i = 1,net.nnodes IF (net.node(i).izone.GT.0 + .AND. + net.node(i).izone.LE.act.nzones) THEN net.node(i).izone = act.zonelist(net.node(i).izone) ELSE ! The node is not in a zone net.node(i).izone = 0 ENDIF ENDDO C - Connect zonal generation links to network links DO i = 1,net.nlinks IF (net.link(i).ildem.GT.0 + .AND. + net.link(i).ildem.LE.net.nnodes) THEN IF (net.link(i).type.NE.CONNECTOR + .AND. + net.link(i).type.NE.ARTERIAL) THEN WRITE(ostr,69899) linkstring(net.link(i).type) + (1:LTR(linkstring(net.link(i).type))) + ,net.node(net.link(i).iunod).number + ,net.node(net.link(i).idnod).number + ,CHAR(0) 69899 FORMAT(A' link ['I5'->'I5'] is a generation link.'A) CALL DYNA_ERROR(ostr + ,DYNA_NONFATAL_WARNING + ,DYNA_INPUT_ERROR + ,DYNA_BAD_GENERATION_TYPE) ENDIF i1 = net.node(net.link(i).ildem).izone IF (i1.GT.0.AND.i1.LE.MAX_ZN_NU) THEN i1 = act.zonelist(i1) IF (i1.LE.0) THEN STOP 'Invalid zone number' ENDIF C - Count the number of generation links act.zone(i1).numgenlink = act.zone(i1).numgenlink + 1 IF (act.zone(i1).numgenlink.GT. + MAX_GENERATION_LINKS) THEN C - Number of generation links exceeds max WRITE(ostr,69797) i1 + ,act.zone(i1).numgenlink + ,MAX_GENERATION_LINKS 69797 FORMAT('Number of generation links for zone ' + I3' ('I5') exceeds the max allowed ('I5')') CALL DYNA_ERROR(ostr + ,DYNA_FATAL_ERROR + ,DYNA_INPUT_ERROR + ,DYNA_TOO_MANY_GENLINKS) ENDIF C - Store the P-Z numbers of the generation links in IZLIN act.zone(i1).genlink(act.zone(i1).numgenlink) = i act.zone(i1).totlmz = act.zone(i1).totlmz + + net.link(i).nlanes*net.link(i).length 40002 FORMAT('ERROR: NODE',I4 + ,' WAS DEFINED AS THE DESTINATION ' + ,'NODE FOR ZONE',I4, + /'BUT LATER WAS DEFINED AS BEING ','IN ZONE'A) ELSE net.link(i).ildem = 0 WRITE(ostr,'(A,I5,A,I5,A,I5,A,A)') + 'link ' + ,net.node(net.link(i).iunod).number + ,'->' + ,net.node(net.link(i).idnod).number + ,' demand defined from node [' + ,net.node(net.link(i).ildem).number + ,'] which has no zone, setting link for no demand' + ,CHAR(0) CALL DYNA_ERROR(ostr + ,DYNA_NONFATAL_WARNING + ,DYNA_INPUT_ERROR + ,DYNA_INVALID_NODENUM) ENDIF ELSE net.link(i).ildem = 0 ENDIF ENDDO C - Connect zonal destination nodes to network nodes DO iz = 1,act.nzones C - Convert the temporarily stored user destnode number to C - DYNASMART internal node index IF (act.zone(iz).destnode.NE.0) THEN act.zone(iz).destnode = net.nodenum(act.zone(iz).destnode) net.node(act.zone(iz).destnode).nidest = + act.zone(iz).destindex ENDIF C - Verify that all destination zones have a destination node IF (act.zone(iz).destnode.NE.0) THEN !If a zone doesn't have a destination, skip check IF (net.node(act.zone(iz).destnode).izone.NE.iz) THEN WRITE(ostr,40002) net.node(act.zone(iz).destnode).number + ,act.zone(iz).number + ,net.node(act.zone(iz).destnode).izone,CHAR(0) CALL DYNA_ERROR(ostr + ,DYNA_FATAL_ERROR + ,DYNA_INPUT_ERROR + ,DYNA_DEST_ZONE_DISCREP) ENDIF ENDIF C - Verify that each zone has at least one generation link IF (act.zone(iz).numgenlink.LE.0) THEN WRITE(ostr,'(A,I5,A)') + 'Zone [',act.zone(iz).number + ,'] has no generation links.'//CHAR(0) CALL DYNA_ERROR(ostr + ,DYNA_NONFATAL_WARNING + ,DYNA_INPUT_ERROR + ,DYNA_NO_GEN_LINKS) ENDIF ENDDO C - Convert the temporarily stored user destnode number to C - DYNASMART node number DO idz = 1,act.ndests act.destlist(idz)=net.nodenum(act.destlist(idz)) ENDDO C - INITIALIZE SHORTEST PATH VARIABLES (for LEFTCON) WRITE(ostr,'(2A)') 'Initializing Path Arrays',CHAR(0) CALL SIMMSG(STATUS,ostr) net.spd.nd.noofdestinations = act.ndests net.spd.nd.destin = act.ndests net.spd.nd.nzones = act.nzones RETURN END C ----------------------------------------------------------------------