The Best of Creative Computing Volume 1 (published 1976)
Dynamic Modeling Using Fortran IV (required subroutines, example, program listing)
INPUT
read parameters;
print parameters used
INITIALIZATION
start clock;
set levels to initial values
AUXILIARIES & RATES
calculate auxiliaries and rates from present levels
OUTPUT
save values for plotter;
print values
YES
More cases?
No
LEVELS
update clock;
calculate new levels
NO
time up?
YES
STOP
Required Subroutines
The recipie described briefly above and in detail in the Appendix requires
additional subroutines to ease in writing DYNAMO-like programs. A limited subset
of those provided for DYNAMO users might include CLIP, NOISE, RAMP, STEP,
SWITCH, TABLE, and TABHL, as well as a simulation-plotter subroutine (SIMPLT).
The Appendix include source listings for the above.
It must be stressed that delays, which appear frequently in System Dynamics
models, are not simply functions or subroutines but "macros". Delays require
integration, and therefore the programming of a delay requires insertion of
FORTRAN source statements into several of the seven sections of the modeling
program. An example, first – and third-order information delays (DYNAMO macros
SMOOTH and DLINF3) are exhibited in the Appendix.
***
Output
The output of the program comprises three parts: a summary of parameters used in
the model, a printed table, and a plot of various rates, levels, or auxiliaries
as a function of time. The programmer may choose not to form a printed table or
not to form a plot if he wishes, or to present the output in some other way. In
the example, primary emphasis is placed upon a simple but crude print-plot,
which should be within reach of all computer systems.
Example
The FORTRAN transcription of Forrester's World model, taken from his World
Dynamics (reference 4) constitutes a simple and easily manageable program of
just over a hundred lines. World Dynamics is ample documentation for the model.
The source listing and "standard" simulation are shown here.
Appendices
Four appendices to this paper including a detailed explanation of the "Recipie",
various subprograms, and three additional examples are available (free) direct
from the author. The author has also offered to aid others in implementing these
models, and will supply (at cost) card copies, source listings, and further
documentation for each. Please write:
Jay Martin Anderson
Department of Chemistry
Bryn Mawr College
Bryn Mawr, Pennsylvania 19010
1 Forrester, J. W., Industrial Dynamics. MIT Press, Cambridge, Mass. 1961.
2 Forrester, J. W., Principles of Systems. Wright-Allen Press, Cambridge, Mass.
1968.
3 See, for example, Forrester, J. W., "Counterintuitive Behavior of Social
Systems." In Toward Global Equilibrium: Collected Papers. D. L. Meadows and D.
H. Meadows, editors. Wright-Allen Press, Cambridge, Mass. 1973. First published
in Technology Review 73(3): 3, January, 1971.
4 Forrester, J.W., World Dynamics. Wright-Allen Press, Cambridge, Mass. 1971.
5 Meadows, D.H., D.L. Meadows, J. Randers, and W.W. Behrens III. The Limits to
Growth. Universe Books, New York. 1972.
6 Pugh, A. L. III. DYNAMO II Users' Manual. 2nd edition. MIT Press, Cambridge,
Mass. 1973.
7 Anderson, J.M., "Computer Simulation in the Dynamics of Environmental
Systems." In Proceedings of the Fifth Conference on Computers in the
Undergraduate Curricula. Washington State University. Pullman, Washington. 1974.
***
PROGRAM LISTING
C WORLD2
C FROM WORLD DYNAMIC, By J.W. FORRESTER (C) WRIGHT-ALLEN PRESS. 1971
C FORTRAN IV (G1) TRANSCRIPTION. J.P.ANDERSON. SEPT 1974
C
C 1. SPECIFICATIONS
DIMENSION NAME (18) . PP (51). PNR (51). PCI (51), PPOL (51), PQL (51)
LOGICAL APLOT / . TRUE. /
COMMON T, PP, PNR, PCI, PPOL, PQL
REAL NR, NRUR, NRUN1, NREN, NAFR, MSL, NAMM, NR1, NRUN, LA
C TABLE ENTRIES FOR TABLE LOOKUP FUNCTIONS
REAL BRIPT (6)/1.2.1…85..75..7..7/.NREMT (5)/0…15..5..85.1./.
1 ORMMT (11)/3..1.8.1…8..7..6..53..5..5..5..5/.
2 ORPMT (7) /.92.1.3.2..3.2.4.8.6.8.9.2/.
3 ORFMT (9) / 30..3..2..1.4.1…7..6..5..5/.
4 DRCMT (6) , BRCMT (6) . BRFMT (5)/0..1..1.6.1.9.2./.
5 BRPMT (7)/1.02..9..7..4..25..15..1/.
6 FCMT (6)/2.4.1…6..4..3..2/ .FPCIT(7)/.5.1..1.4.1.7.1.9.2.05.2.2/ .
7 CIMT (6)/.1.1..1.0.2.4.2.6.3./.FPMT (7)/1.02..9..65..35..2..1..05/ .
8 POLCMT (6) / .05.1..3..5.4.7.4.8./ .
9 POLATT (7) / .6.2.5.5..8..11.5.15.5.20./.CF1FRT (5)/1…6..3..15..1/ .
A QLMT (6)/. 2.1..1.7.2.3.2.7.2.9/.QLF T (5) /0..1..1.A.2.4.2.7/.
B QLCT (11)/2..1.3.1..75..55..45..38..3..25..22..2/.
C QLPT (7)/1.04..85..6..3..15..05..02/ .CIQRT (5)/ .7..8.1..1.5.2./.
D NRMMT (11) / 0..1..1.8.2.4.2.9.3.3.3.6.3.8.3.9.3.95.4./
NAMELIST /PARMS/ NRUN1. POLN1. DRCMT. BRCMT. CIGNI. BRN1. FC1. DRN1. NR1.
1 CI DN1 . YEAR
DATA BRN..ECIRA. NRUN. DFN. LA. PDN. FC. FN. CIAFN. CIGN. CIDN. POLS. POLN.
1 C1AFT.QLS / . 04.1..1..028.135.E6.26.5.1..1…3..05..U25.3.6E9.
2 1..15..1./
C 2. FUNCTIONS
C THERE ARE NONE
C
C 3. INPUTS
READ (5.1001) NAME
1001 FORMAT (1624)
READ (5.*) NUPL. NLPR.NU.NCPU
NOCAL=NU*NCPU
NUPT=NUPL*NCPU
NUPH=NUPR*NCPU
OT=1./FLOAT (NCPU)
NCASE=0
1 READ (5.PARMS.END=100)
NCASE = CASE + 1
WRITE (6 + 1003 ) NAFL + NCASE
1003 FORMAT ("1", 18A4/ "CASE" , I2/3
WRITE (6.FARMS)
C
C 4. INITIALIZATION
NT=0
P=1.65E9
NR=NR1
CI=0.4E9
POL=0.2E9
CIAF=0.2
2 NPL=6
C
C 5. AUXILIARIES AND RATES
5 1=1900. + FLOAT(NT) / FLOAT (NCPU)
CR=P/(LA*PDN)
CIR=CI/P
NRCR = NR/PRI
CIRA=CI*CIAF/CIAF.
PCLR=POL/POLS
NREM=TAPLE (NRENT.NHFR.0..1…25)
ECIR=CIR* (1-CIAF)* NRC / (1-CIAFN)
MSL=LCIN /ECIRN
BRMM=TABML (BRKMT.FSL.0..5..1.)
DRMM=TABNL (DRFMT.MSL.0..5..5)
FCM=TABLE (FCMT.CR.0..5..1.)