Dynamic data storage in FORTRAN

Arizona State Universily, Tempe. ... NSF: Directorate for Science and Engineering Education.) ... Montana State university that uses our computer lab ...
6 downloads 0 Views 1MB Size
computer mrief. 115

edited by JAMES P. BIRK Arizona State Universily, Tempe. AZ 85281

Bits and Pieces, 44 Guidelines for Authors of Bits and Pieces appeared in July 1986; the number of Bits and Pieces manuscripts is expected to decrease in the future--see the July 1988 and March 1989 issues. Bits and Pieces authors who describe programs will make available listings andlor machine-readable iersions of their programs. Please read each description carefully to deter&e compatibility with your owncomputing environment before requesting materials from any of the authors. Several nroerams described in this article and marked as such are avazable from Project SERAPHIM a t $5 per 51/4-in.disk, $10 per 3lI2-in. disk; program listings and other written materials are available for $2 each; $2 domestic or $10 foreign nostaee and handling is reauired for each shinment. Make ;he& payable to ~;oject SERAPHIM. T o order, or get a Project SERAPHIM Catalogue, write to: John W. Moore, Director, Project SERAPHIM, Department of Chemistry, University of Wisconsin-Madison, 1101 University Avenue, Madison, WI 53706. (Project SERAPHIM is supported by NSF: Directorate for Science and Engineering Education.)

Dynamic Data Storage in FORTRAN Allce Chung-Phllllps Miami University Oxford, OH 45056 The purpose of this article is to promote the use of dynamic storage allocation in FORTRAN to chemistry instructors and students in the present computing environment. This programming technique (I) is not new but is worthy of reneated nublicitv because of its manv advantaees. consider a typical scientific pro$am that contains many arrays for the storage of data. Most arrays may be classified as dynamic arrays because the number of elements in the array varies from case t o case. In FORTRAN the maximum size of each array must be stated someplace in the program so that sufficient storage can be reserved for the computation. This generally presents no problem since the programmer can usually anticipate the largest case and set the sizes accordinelv. C&cumstances mav arise. however. when these "maxim;; sizes"must be altered. hi$ can be atedious task if the program was not initially designed for such changes. A useful strategy is to use variable DIMENSION statements for the dvnamic arravs in the subroutines: thesestatements will remain unchanged regardless of how the amount of data vary. In the MAIN routine the arrays are placed end to end to form a single storage block for which a fixed DIMENSION statement is issued. If the maximum size assigned to the block becomes obsolete, only one size in MAIN needs be changed. In the microcomputer environment, MAIN can be conveniently made into a separate file for compilation. When the size of the storage block is changed, only MAIN needs be re-compiled. This is a method of introducing dynamic data storage without the use of extra software. An effective way to demonstrate the algorithm is to show how a program with static data storage is converted to one 500

Journal of Chemlcal Education

with dynamic data storage. As an example, a test scoring program has been written both in the static form, TESCOR, and in its dynamic form, TESCOR-DYNAM (1, 2). The subject "test scoring" is chosen so as not to challenge the readers with the complexity of a scientific problem. The program, on the other hand, is constructed to exemplify programming techniques commonly found in more complex problems. For those interested in implementing dynamic data storaee. a learnine mide has been nrenared (2). The tutorial Gckage includes documentatio' files that 'give detailed instructions on the aleorithm. FORTRAN files for the 'l'ESCOR and TESCOR~DYNAMprograms, sample inputloutput files, and files for compilation and linking associated with this programming procedure. Acknowledgment he algorithm for dynamic data storage was initially developed by Robert W. Rosen. The author is deeply indebted to David B. Phillips for his invaluable assistance with the IBM PCIAT.

Applying KC?DISCOVERER in the Introductory Chemistry Laboratory Ronald P. Furrtenau and John R. Amend Montana State University Bozeman, MT 59717 We have been usine comouter interfacine with laboratorv experiments for the paat three years in our general chemistry laboratories ( 3 ) .Since thecomoutersarealreadv in the lahoratories, i t is easy to incorporate computer tutorials and other computer-assisted instruction to reinforce concepts being taught in both lecture and laboratory. One such computer program is KC?DISCOVERER, developed under Project SERAPHIM (4.5). KC?DISCOVERER is a particularly useful niece of software to incorporate into labs where IBM-compatible computers are available. KC?DISCOVERER contains a wide varietv of nhvsical and chemical orooerties of the elements. These properties can be displaye'd i i graphical and tabular form in wavs that are limited onlv bv the imaeination of the , beuscdin acomputstudent. ~ L u sKC?DISCOVERERE~~ er-eauio~edlaboratorv to comnare exnerimental results immediatefy with d o ~ u ~ e n t values. ed We have developed a chemical neriodicitv laboratow a t Montana State university that uses our computer lab interface system to obtain electrical conductivity data on elemental samples. This laboratory is based on alaboratory initially developed by Braydich a t the U.S. Air Force Academy (6). Students first obtain qualitative results using the lab interface system as a conductivity probe. They use the property of electrical conductivitv to eroun these elements on the periodic table. Then, s t i d e n t i colbpare their experimental results with values from KC?DISCOVERER. Since our computers are already in thelab to gather data, KC?DISCOVERER can be used immediately after the measurements

. ..