C ---------------------------------------------------------------------- INTEGER FUNCTION PRE_STEP_HOOKS(io,sim,net,act,veh) C ---------------------------------------------------------------------- C - Performs any procedures required before the beginning of a time C - step (e.g. printing simulation time to the screen). 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 INTEGER ires C - FUNCTIONS CALLED: INTEGER GET_NEXT_EQPATH C - RETURN VALUE: ! Simulation status C ---------------------------------------------------------------------- IF (sim.ipinit.EQ.1) THEN ires = GET_NEXT_EQPATH(io,sim,net) IF (ires.NE.0) sim.status = SIM_ERROR ENDIF Cr - Reset the green time allotted for the next timestep !INEFFICIENT DO i = 1,net.nlinks DO j = 1,net.link(i).numuslinks net.movement(net.link(i).usmoveptr(j)).green = 0 ENDDO CALL INCIDENT(sim,net,i) ENDDO CALL EXTERNAL_PRE_STEP_HOOKS(io,sim,net,act,veh) PRE_STEP_HOOKS = sim.status RETURN END C ---------------------------------------------------------------------- INTEGER FUNCTION POST_LINK_HOOKS(io,sim,net,lnum) C ---------------------------------------------------------------------- C - Performs any procedures required after the link update of a given C - link (basically after a link processing is complete for a given C - time step). C - INCLUDED FILES: #include "dyna.inc" #include "io.inc" #include "sim.inc" #include "network.inc" C - UNMODIFIED ARGUMENTS: INTEGER lnum RECORD /Io_Data/ io RECORD /Sim_Data/ sim C - MODIFIED ARGUMENTS: RECORD /Road_Network/ net C - MODIFIED GLOBAL DATA: ! NONE C - LOCAL VARIABLES: ! NONE C - FUNCTIONS CALLED: INTEGER EXTERNAL_POST_LINK_HOOKS C - RETURN VALUE: ! Non-zero if there was an error C ---------------------------------------------------------------------- POST_LINK_HOOKS = 0 POST_LINK_HOOKS = EXTERNAL_POST_LINK_HOOKS(io,sim,net,lnum) RETURN END C ---------------------------------------------------------------------- INTEGER FUNCTION POST_STEP_HOOKS(io,sim,net,act,veh) C ---------------------------------------------------------------------- C - Performs any procedures required after the completion of a time C - step (e.g. printing simulation time to the screen). 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 C - FUNCTIONS CALLED: ! EXTERNAL_POST_STEP_HOOKS C - RETURN VALUE: ! Simulation status C ---------------------------------------------------------------------- C - Verify that all vehicles that wanted to move were constrained by C - capacity. If they weren't, this indicates an error in the C - simulation. This is a relatively expensive debugging step which C - can be removed once the simulation is working properly. DO i = 1,net.nmoves IF (net.movement(i).moved+net.movement(i).queued.NE. + net.movement(i).demand) THEN WRITE(ostr,*) 'MOVES INCONSISTENT: ' + ,net.link(net.movement(i).fromlink).iunod + ,net.link(net.movement(i).fromlink).idnod + ,net.link(net.movement(i).tolink).idnod + ,net.movement(i).moved + ,net.movement(i).queued + ,net.movement(i).demand CALL DYNA_ERROR(ostr + ,DYNA_FATAL_ERROR + ,DYNA_LOGIC_BUG + ,DYNA_INCONST_MOVES) ENDIF ENDDO C - Update network activity statistics if (net.nin_tag.eq.net.oldnumcars) + net.icount_stop = net.icount_stop + 1 if (net.nin_tag.NE.net.oldnumcars) net.icount_stop = 0 net.oldnumcars = net.nin_tag C - Update Simulation Status IF (sim.iter.EQ.sim.maxiter) sim.status = SIM_MAX_TIME IF ((sim.time.minutes.GE.sim.endtm) + .AND. + (net.nin_tag.eq.0)) sim.status = SIM_COMPLETE C - Write out simulation status WRITE(ostr,599) sim.iter,sim.time.minutes+sim.timestep cr + ,sim.jj,net.ngen_tag,net.ngen_nontag + ,net.nin_tag+net.nin_nontag,net.nin_tag,net.nin_nontag + ,net.nout_tag+net.nout_nontag,net.nout_tag,net.nout_nontag + ,net.stationacc,CHAR(0) 599 FORMAT('-->'I5,F6.1,2(I7'['I6'+'I6']')' acc = 'F7.2,A) CALL SIMMSG(STATUS,ostr) CALL EXTERNAL_POST_STEP_HOOKS(io,sim,net,act,veh) POST_STEP_HOOKS = sim.status RETURN END C ---------------------------------------------------------------------- INTEGER FUNCTION VEH_EXIT_HOOKS(io,sim,net,act,veh) C ---------------------------------------------------------------------- C - Performs any procedures required when a vehicle exits the network C - E.g., statistics collection #include "dyna.inc" #include "io.inc" #include "sim.inc" #include "network.inc" #include "activity.inc" #include "vehicle.inc" RECORD /Io_Data/ io RECORD /Sim_Data/ sim RECORD /Road_Network/ net RECORD /Activity/ act RECORD /Vehicle_Data/ veh INTEGER EXTERNAL_VEH_EXIT_HOOKS !function INTEGER i VEH_EXIT_HOOKS = 0 CALL VEH_STAT(sim,net,act,veh) i = EXTERNAL_VEH_EXIT_HOOKS(io,sim,net,act,veh) RETURN END