The Geologic Retrieval and 

Synopsis Program (GRASP) 

GEOLOGICAL SURVEY PROFESSIONAL PAPER 966 

The Geologic Retrieval and 

Synopsis Program (GRASP) 

By ROGER W. BOWEN and JOSEPH MOSES BOTBOL 

GEOLOGICAL SURVEY PROFESSIONAL PAPER 966 

A portable data-retrieval system 

requiring minimal user training 

UNITED STATES GOVERNl\fENT PRINTING OFFICE, WASHINGTON 1975 
UNITED STATES DEPARTMENT OF THE INTERIOR 

THOMAS S. KLEPPE, Secretary 

GEOLOGICAL SURVEY 

V. E. McKelvey, Director 

First printing 197 5 

Second printing 1976 

Library of Congress Cataloging in Publication Data 

Bowen, Roger W. 

The geologic retrieval and synopsis program (GRASP) 

(Geological Survey professional paper; 966) 

Supt. of Docs. no.: I 19.16:966 

1. Information storage and retrieval systems--Geology. I. Botbol, Joseph Moses, joint author. II. Title. 

III. Series: United States. Geological Survey. Professional paper; 966. 

QE48.8.B68 029 '.9 '55 75-619314 

For sale by Branch of Distribution, U.S. Geological Survey, 

1200 South Eads Street, Arlington, VA 22202. 
Abstract _____ ----- ___________ ------------- ___ ---

Introduction _________________ ---------- ___ -------

Purpose and scope ---------------------------

General system description ------------------------

Design philosophy ----------------------------

Machine portability -----------------------

Data-base independence -------------------

User community -------------------------

Time sharing ----------------------------

Present utilization ----------------------------

COLFIL --------------------------------

MANFIL -------------------------------

RASS -----------------------------------

Future plans ---------------------------------

Detailed system description ------------------------

Data-file structures ---------------------------

Mask file --------------------------------

Definitions file ---------------------------

Dictionary file ---------------------------

Multiple-choice file -----------------------

Numeric Master file -----------------------· 

Data compression ---------------------

Machine dependencies -------------------------

Internal structure and functions ---------------

Processing user input -------------------------

Conditional expressions -------------------

Logical expressions -----------------------

Number lists ----------------------------- N arne lists ______________________________ _ 

Arithmetic expressions --------------------

Searches --------------------------------

Output ----------------------------------

Data-base implementation -------------------------

Use of GRASP ---------------------------------- References cited _________________________________ . 

GRASP software specifications ---------------------

Module name: DRIVER ----------------------

Subroutine name: ACCESS -------------------

Subroutine name: BDEF ---------------------

Subroutine name: BFIND -------------------· 

Subroutine name: BINIT ---------------------

Subroutine name: BINTYP -------------------

Subroutine name: BLIST ---------------------

CONTENTS 

Page 

1 

1 

1 

1 

1 

1 

2 

2 

2 

2 

2 

2: 

3 

3 

3 

3 

3 

4 

4 

4 

5 

5 

6 

6 

6 

6 

6 

8 

8 

8 

8 

9 

9 

10 

12 

13 

13 

15 

17 

19 

20 

21 

22 

GRASP software specifications-Continued 

Subroutine name: COLPNT -------------------

Function name: COMP -----------------------

Subroutine name: CONDS --------------------

Subroutine name: CONDTN ------------------

Subroutine name: DECOMP -------------------

Subroutine name: DEFINE -------------------

Subroutine name: DEFLST -------------------

Subroutine name: DUMPIT -------------------

Function name: EVAL -----------------------

Subroutine name: FDRIVE -------------------

Subroutine name: FILES ---------------------

Subroutine name: FIND ----------------------

Subroutine name: FINDGP -------------------

Subroutine name: FIT ------------------------

Subroutine name: FTNC ----------------------

Subroutine name: GETPUT -------------------

Subroutine name: HELP ---------------------

Function name: ICONV ----------------------

Subroutine name: IFILE ----------------------

Subroutine name: INIT -----------------------

Subroutine name: KEYBRD -------------------

Subroutine name: LENGTH ------------------

Subroutine name: LIST ----------------------

Subroutine name: LOGEXP -------------------

Subroutine name: MEAN --------------------

Subroutine name: NAME ---------------------

Subroutine name: OBEY ---------------------

Subroutine name: OFILE ---------------------

Subroutine name: OPREP --------------------

Subroutine name: PACK ---------------------

Subroutine name: PARSE --------------------

Subroutine name: PAUSE --------------------

Function name: PNTER ----------------------

Subroutine name: PREVAL -------------------

Subroutine name: QUIT ---------------------- Subroutine name: RELEXP ________________ _: __ 

Subroutine name: RETRVE ------------------

Subroutine name: RLIST ---------------------

Subroutine name: ROWPNT ------------------

Subroutine name: SCAN ---------------------

Subroutine name: START --------------------

Function name: UNCODE --------------------

Subroutine name: VLIST ---------------------

ILLUSTRATIONS 

FIGURE 1. 

2. 

3. 

Example of Mask-file and Dictionary-file arrangement ------------

Example of Numeric Master file arrangement prior to compression __ 

Pictorial summary of GRASP subroutine interrelationships ________ _ 

Page 

4 

5 

7 

III 

Page 

23 

25 

27 

28 

29 

31 

32 

33 

35 

37 

38 

39 

40 

41 

43 

45 

46 

47 

48 

49 

50 

51 

52 

53 

56 

58 

59 

61 

62 

63 

64 

68 

69 

71 

72 

73 

76 

79 

81 

83 

84 

85 

86 

THE GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

By RoGER W. BowEN and JosEPH ~losEs BoTBOL 

ABSTRACT 

The Geologic Retrieval and Synopsis Program (GRASP) 

was designed and written to specifically accommodate interactive access to earth-science data banks. GRASP is portable, 

easy to use, and data-base independent. 

Data banks accessed by GRASP must be partitioned and 

reformatted into five files which make up both data bank and 

pointers to parts of the bank. Machine dependencies include 

FORTRAN I/0 unit numbers, direct-(random-) access input, 

in-core read/write, and "prompting." GRASP isolates these 

dependencies to FORTRAN subroutines designed to serve 

these functions specifically. GRASP is manipulated by 11 user 

commands which select, describe, access, retrieve, summarize, 

and display data. 

INTRODUCTION 

The U.S. Geological Survey presently has the responsibility of developing and maintaining resourcedata banks. Initially, many storage and retrieval 

systems were critically reviewed for their data-bank 

characteristics, ease of use, flexibility, portability, 

and applicability to Surv·ey activity. The authors concluded that no available system was wholly adequate 

for the needs of the Survey data banks. Generally, 

the obs-erved systems were difficult to use, machine 

bound, or were oriented toward one type of data 

(for example, text oriented). The only logical alternative was to design, develop, and implem·ent a 

geologic-data storage and retrieval system to be 

used primarily by geologists. 

PURPOSE AND SCOPE 

The Geologic Retrieval and Synopsis Program 

(GRASP) was written to p·rovide a means of interactive access to geologic data stored in a timesharing computer. 

GRASP can be implemented on any time-sharing 

computer system that has a FORTRAN IV compiler. Data bases accessed by GRASP must contain fixed field data in alphameric, alphanumeric, 

and/or numeric modes. 

GENERAL SYSTEM DESCRIPTION 

To obtain a broad overview of the GRASP system, consideration should first be given to the 

philosophy governing the de,sign of the system, use 

of the present system, and future system plans. 

This overview provides the "framework" and the 

anticipated "operational environment" which are 

necessary for the development of any system. Both 

the present utilization and future system plans 

show the correctness of the parameters and techniques used as well as the original assumptions regarding "how," "by whom," and "where" the system will be used. 

DESIGN PHILOSOPHY 

Three vital questions that must be answered prior 

to the implementation of any system are: (1) On 

what computer(s) will this system be used? (2) 

What are the characteristics of the data to be processed? ( 3) Who will use the system? As is the case 

in many computer-system applications, these questions originally had no definite answers. A 3-month 

effort was necessary to establish criteria that would 

govern GRASP design. 

MACHINE PORTABILITY 

To serve as broad a spectrum of the scientific 

co-mmunity as possible, a system should be as portable as possible. Because of differences in computer 

design, no system can be used on all computers without some modification. ANSI FORTRAN IV is univers,ally accepted as a standard programming language. It may be used on the vast majority of present-day computers that have the capacity for implementing compiler-level l~anguages in a time-sharing 

mode of operation. For this reason, all the processing subroutines in GRASP are written in ANSI 

FORTRAN IV (machine-dependent features isolated to facilitate implementation). In this way, 

GRASP can be installed on virtually any modern 

1 
2 GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

time-sharing computer. By designing GRASP to be 

portable, a much wider spectrum of the scientific 

community can be served by the system. Data need 

not be transferred from their resident banks in 

order to be acoessed. GRASP could be used on most 

computers in order to access data files wherever 

they may reside. This machine independence eliminates the need for tedious data transformations to 

one system configuration, where the aggregating 

data eventually flood to the point of uselessness the 

peripheral storage of a central machine-dep·endent 

data bank. The authors believe that a common accessing system for data residing in different computers is preferable to an accessing system that can 

be used for data resident in only one computer. 

DATA-BASE INDEPENDENCE 

GRASP is designedto operate using any data base 

that can be represented in conventional matrix 

form. In matrix form, the records (that is, items to 

be described) are the rows, and the attributes of 

each record are the columns. The real structure of 

the data base can be thought of as the titles and 

arrangement of the columns of a data matrix where 

the rows are merely instances or occurrences described by the columns. For example, a geochemical 

data base would have a matrix representation in 

which the columns might represent chemical analyses of various elements, and each row would represent one S!ample. GRASP can function on any 

data matrix. The only requirement is that the variables (or columns) be defined ahead of time in 

terms of their types (that is, alpha or num·eric), 

and, where necessary, dictionaries of legitimate alphameric entries must be provided for alphameric 

variables. Thus, becapse of the matrix orientation 

of GRASP, any fixed field data base can be accommodated by the system. 

USER COMMUNITY 

GRASP is a retrieval system having its own rules 

and command language for operation. In other 

words, to use GRASP, the user doe·s not need to be 

familiar with FORTRAN or any other computer 

language. The GRASP command language is designed to provide users with the ability to ask questions of a data base and retain all items that answer "true" to the questions. The control language 

used to ask the questions (discussed in the section 

on "Use of GRASP" in this report) allows "retri~eve 

only" data access to any GRASP user and does not 

require prior user knowledge of computer languages 

or system functions. Thus, GRASP can be implemented for a wide variety of users. 

TIME SHARING 

Inasmuch as GRASP is portable, data-base independent, and serves a wide variety of users, 

GRASP should be implemented in a computational 

mode that has the most readily available user access, namely, time sharing. In its simplest form, 

time sharing allows any user to communicate with 

the computer from a ter·minal near a telephone. The 

entire design of GRASP is based on the premise 

that the user community will converse directly with 

a computer (via a terminal) in order to access, retrieve, manipulate, summarize, and display data. 

This mode of computation provides the "instant" 

response necessary for timely decisionmaking, and 

also allows access by the user from the environment 

in which the computer response is of most value, that 

is, the laboratory, field, office, or conference room. 

PRESENT UTILIZATION 

In 1975, the GRASP syste~m was being used to access data from six totally different data banks: (1) 

oil- and g~as~pool characteristics of Colorado, (2) 

mineral deposits of the world, ( 3) geochemical exploration data from the United States, ( 4) coal resources of the United States (prototypic data bank), 

(5) index of U.S. geologic map coverage (prototypic 

system), and (6) geothermal data bank (in Pisa, 

Italy). The first three of the above systems were 

implemented directly by the authors, and no attempt 

was made to redesign any of the original data-bank 

structures. 

COLFIL 

This file contains as many as 390. characteristics 

for each of 800 oil and (or) gas pools in Colorado. 

This file served as the original model for GRASP 

design and ultimately will contain 60,000 records. 

MANFIL 

The mineral deposits of the world (MANFIL) 

were the second file implemented using GRASP. It 

is a computerized batch-processing-oriented file containing geologic, production, and reserves data from 

about 4,000 nonferrous metal deposits throughout 

the world. Each record represents one deposit, and 

contains as many as 250 variables. Although GRASP 

was designed using the oil- and gas-pool file as a 

model, implementation of the world-mineral-deposits file showed the flexibility of GRASP with respect to its data-base independence. 
DETAILED SYSTEM DESCRIPTION 3 

RASS 

The RASS (Rock Analysis Storage System) file 

is ·a batch-oriented geochemical data bank containing limited geologic descriptions and comprehensive 

geochemical analyses of all samples processed by the 

laboratories of the U.S. Geological Survey. This file 

contains a unique type of numeric data called "qualified values." Because of the upper and lower detectability limits of analytic devices, elements whose 

presence is known but whose content is out·side the 

analytical range of a device are sometimes reported 

at a given analytical cutoff value, accompanied by a 

letter indicating whether the content is less than, 

greater than, or in interference with another element. Typical qualified entries would appear as 

L5000, GlOOO, or HlOO, where L signifies a content 

less than the attached value, G signifies a content 

greater than the attached value, and H signifies 

analytical interference at a concentration of the attached value. Because many of the RASS data were 

accompanied by alpha qualifiers, GRASP was modified to accept and process this type of data in addition to the conventional numeric- and alpham~ericdata types. 

All the above files are implemented in a retrieve 

mode only, and graphics have not yet been added. 

Input to the files is done by people who are responsible for data entry and does not fall in the domain 

of the user. 

FUTURE PLANS 

Currently, the development of GRASP is primarily oriented toward implementation of techniques 

for interactive graphics storage and retrieval. Three 

problem areas are presently being researched: automatic recognition of features on scanned input documents, annotation methods, and resolution of "intersecting feature" problems. Present research efforts are directed toward feature recognition and 

subsequent computational extraction of simple 

boundary vectors from scanned digital maps and 

photographs. In addition to recognition of features, 

methods are also being developed for annotation of 

both graphics-data entry and presentation of 

graphics data on output. 

One of the major anticipated technical and philosophical problems is concerned with the graphical 

resolution of intersecting features. Techniques are 

being developed that should resolve these problems 

for any particular data set. 

All the GRASP graphics output is being designed 

primarily for interactive graphics cathode ray tube 

(CRT) representation. This is in keeping with 

GRASP's original "totally interactive" design philosophy. 

DETAILED SYSTEM DESCRIPTION 

GRASP is designed as a highly modular, hierarchically structured set of subroutines (see section 

"GRASP Software Specifications"). Each subroutine performs a fixed task. The higher level subroutines are primarily concerned with the flow of 

control required to execute a user command. ~he 

lower level subroutines are primarily concerned With 

extremely independent and specific tasks (such as 

"get a record," "access a dictionary," and "accept 

user input," and so on). All information related to 

a specific data base is obtained from various files 

associated with that data base. Structuring the system in this way leads to a high degree of functional 

isolation. These design characteristics simplify the 

development, documentation, maintenance, growth, 

and inevitable change inherent in a system that supports a variety of data bases on a wide spectrum of 

computer main frames. The section on GRASP software specifications is intended for use by those familiar with FORTRAN language. 

DATA-FILE STRUCTURES 

Upon initial execution, the GRASP system reads 

an "index" file which contains the names of data 

bases available for access. Each record of the index 

file corresponds to a data base and contains the 

names of the files associated with that data base 

and a 40-character description of the data base. 

Each data base is composed of five files which contain the actual data, information on the structure 

of records, names which will be used to refer to particular items within records, descriptive information 

on the names themselves, and a grouping int~ categories of information. These files are called Mask, 

Definitions, Dictionary, Multiple-choice, and Numeric Master files. 

MASK FILE 

The Mask file contains the item names, item types 

(integer, real, character string, multiple choice, and 

qualified real), and pointers to the first entry in the 

Dictionary file for each character-type item. This 

file is read once and rewound when a data base is 

selected via the FILE command. An example of 

Mask file arrangement is shown in figure 1. 
4 GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

Conceptual noncomputerized dictionaries 

for three character type variables: 

Variable No.1 Variable No.2 Variable No.3 

Continent Country Province (State) 

North America USA California 

South America Canada Virginia 

Europe Mexico British Columbia 

Argentina Quebec 

Brazil Cordova 

Chile 

Germany 

l 

In the computer, the MASK File is arranged as follows: 

Mask File 

Variable N arne Variable Type Starting Position in 

Dictionary File 

..... 

-

...... 

~ 

In the computer, the Dictionary File 

is arranged as follows: 

Dictionary File 

Item No. Pointer to 

next item 

1 2 

2 3 

3 0 

4 5 

5 6 

6 7 

7 8 

8 9 

9 10 

10 0 

North America 

South America 

Europe 

USA 

Canada 

Mexico 

Argentina 

Brazil 

Chile 

Germany 

~ 11 12 California 

12 13 Continent Character 1 - Virginia 

Country Character 

Province (State) Character 

Production Numeric, real 

*Note: This variable is numeric, and does 

not require a pointer to the 

Dictionary File 

4 

11 

* 

13 

14 

15 

14 British Columbia 

15 Quebec 

0 Cordova 

("0" indicates end 

of list for particular 

variable) 

FIGURE 1.-Example of Mask-file and Dictionary-file arrangement. 

DEFINITIONS FILE 

The Definitions file contains the following information: 

1. The number of categories in the file. 

2. 'The maximum number of (computer) words in 

a category na.me. 

3. The category names. 

4. For each category the following information is 

recorded: 

(a) category number. 

(b) number of lines used to describe this category. 

(c) maximum length (in computer words) of 

a description in this category. 

(d) number of variables appearing in this 

category. In some cases this will be different from item b (the number of lines 

for deseription). 

(e) indices of the variables appearing in this 

category. 

(f) the variable names, types, and descriptions for this category. 

DICTIONARY FILE 

The Dictionary file contains all character-string 

values which are assumed by character-type items. 

Each record contains a pointer to the ~record containing the next value, followed by the current value. 

The last value assumed by a character-type item is 

indicated by a pointer value of zero (the record 

containing the first character-string value for a 

character-type item is pointed to by a v·alue in the 

Ma.sk file) . The Dictionary file is designed as a random-access file whose values form a linked list. Figure 1 shows an example of the Dictionary-file arrangement. 

MULTIPLE-CHOICE FILE 

The Multiple-choice file contains the acronyms and 

acronym meanings for the values assumed by mul-
DETAILED SYSTEM DESCRIPTION 5 

tiple-choice items. Each record of this file is composed of an item number indicating the multiplechoice item, the number of possible values this item 

assumes, the maximum length of an acronym value 

description, and a list of acronyms (which are 

double words) and their descriptions. 

NUMERIC MASTER FILE 

The Numeric Master file is composed of the records for a data base in a compressed form. Values 

for integer-type items are stored as integers. Values 

for floating-point- (or real-) type items are stored 

as real numbers. Values for character-type items are 

stored as integer pointers to the entry number in 

the Dictionary file. Values for multiple-choice-type 

items are stored as integers containing a binary encoding that r,epresents the value set. (For example, 

if the second and fifth bit of the word are "on," the 

value assumed is the second and fifth acronym 

value.) Each record of the compressed Master file 

is variable length in form and corresponds to an expanded 400-word record. Expansion of the compressed record is performed by subroutine GETPUT. Figure 2 shows an example of the Numeric 

Master file prior to compression. 

DATA COMPRESSION 

The compression technique used is a form of 

blank suppression. The words of the compressed 

record are one of the following four types : 

A. Integer value. 

B. Real value. 

C. Integer blank count. 

D. Integer word count. 

The first word of all records is of type D (above) 

and is used to give the length of the record. Subsequent words may be types A, B, and C. For types A 

and C, the last two bits give the type of the next 

word. The value of the word is obtained by dividing rby 4. The type of the next word is obtained via 

the rem1ainder modulo 4, wherre the numbers 1-3 

correspond to types A, B, and C. Type-A words are 

used for numeric integers, pointers to entries in 

character dictionaries, and binary encodings of multiple-choice-type items. Type-C words are used to 

count the number of consecutive blanks to be inserted in the expanded record. Type-B words are 

used for floating-point numeric values. The type of 

the next word is contained in the last 2 bits of the 

whole (integer) part of the words. For example, 

consider ,a data word having a value of 49.723. The 

Given the following two successive noncomputerized records to be entered into the Numeric Storage File: 

Continent* 

1 

2 

Continent ---------------------------------

Country ------------------------------------

Production __ ------------------------------

Identification No. ____________________ _ 

Province (or State) ___________________ _ 

Record 1 

North America 

United States 

39281.6 

38 

Virginia 

Record 2 

South America 

Argentina 

49298.7 

39 

Cordova 

Prior to compression, the computerized Numeric Storage File is arranged as follows: 

Country* Production ID No. Province* etc. 

39281.6 38 2 

11111111 

1 

4 49298.7 39 5 

*See figure 1-for dictionary codification of continent, country, and province 

FIGURE 2.-Example of Numeric-Master-file arrangement prior to compression. 
6 GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

floating-point value would be 12.723 (12=49/4), 

and the type of the next word would be 49 - ( 4 X 

12) =1 or A. 

MACHINE DEPENDENCIES 

Although most of the GRASP-system code is 

written in ANSI FORTRAN IV, certain isolated 

functions must be tailored to the particular FORTRAN compiler on any given machine. These functions deal with the dynamic as·sociation of data set 

names and FORTRAN I/0 unit numbers, direct-

(random-) access input, the method of accommodating "prompting," and internal (in-core) transfer 

(writes) using format control. 

For the dynamic association of data-set names 

and FORTRAN unit numbers, the routines IFILE, 

OFILE and DEFINE are used. Details of these 

routines can be found in the section "GRASP Software Specifications." 

Direct-access input is used to access the Dictionary file (in subroutine ACCESS). The FORTRAN 

unit number, an integer expression giving the record 

number, and an input list are supplied in the READ 

statement. This form of direct-access input is compatible with most FORTRAN compiler·s which support direct-access input. Systems not having directaccess capabilities can be accommodated by modifying the logic of this subroutine. This modification 

involves positioning of a sequential file to the appropriate record prior to execution of the READ 

statement. 

For systems which do not accept the "prompt" option in the READ statement, user "prompting" can 

be accomplished by using WRITE statements immediately preceding (in time) user input. The 

"prompt" message is contained in a FORMAT statement, along with a character which inhibits the 

g·eneration of the normal carriage-return/line-feed 

usually associated with output directed to a timeshare terminal. If a particular system does not ha~ve 

this capability, the "prompting" message will appear on a separate line immediately preceding the 

user input. 

The internal transfer of data under format control is accomplished via the ENCODE statement. 

The ENCODE statement is us·ed in subroutine 

COLPNT to construct a line of output. The only 

other use of ENCODE is in subroutine PACK which 

is used to convert characters from unpacked to 

packed form. Most non-IBM FORTRANS support 

this statement in one form or another. In the case 

of IBM FORTRAN, a routine must be provided that 

allows internal data transfer under format control. 

INTERNAL STRUCTURE AND FUNCTIONS 

GRASP is designed to accept a "command" (or 

directive) from the user. Once the command has 

been recognized, the appropriate subroutine is executed. This subroutine will, in most cases, call other 

subroutines in order to accom·plish its intended task. 

In some cases subroutine calls are nested to a depth 

of six. Figure 3 gives a pictorial summary of the 

calling hierarchy for subroutines which are in 

G RAS.P. This figure will be useful in implementing 

or modifying the GRASP system. 

PROCESSING USER INPUT 

All user input to GRASP is pass·ed to the system 

in unpacked character form. At the highest level 

are single words used to execute a GRASP "command." In this case, the characters are packed, and 

the result is compared to the list of available commands. After a command has been issued, supplementary user input is usually required. This supplementary input must then be "parsed" (that is, 

converted) into a form more meaningful to the 

GR.ASP system. This parsed form is entir·ely numeric in nature. The numbers themselves may represent values, integer encodings, or pointers. Supplem·entary input falls into five independent areas : 

conditional expressions, logical expressions, number 

lists, name lists, and arithmetic expressions. 

CONDITIONAL EXPRESSIONS 

A conditional expression is an attribute name, followed by a relation, followed by a value. The attribute name is identified using the binary-search 

technique. The relation is identified by a sequential 

table lookup. The value is converted to correspond 

in type with the attribute name referenced. This 

may result in a pointer to a character entry in the 

Dictionary file, a binary encoding of an acronym 

value in a record of the Multiple-choice file, or simply a numeric value. Each conditional expression 

entered is associated with a letter (A-Z). 

LOGICAL EXPRESSIONS 

Logical expressions are composed of letters referring to conditional expressions, the grouping symbols used to control the order of evaluation, and the 

logical operators .AND. (*), .OR. ( +), .NOT. (-). 

For ease of evaluation logical expressions are converted to reverse-Polish form. This is a parenthesisfree form which permits rapid evaluation using a 

push-down stack technique. For a detailed description of the conversion to and evaluation of reverse-
L 

·parreJ a.re lln{l saunno.rqns OllU!od sM.o.r.ru al{.L ·sd!l{Suonura.r.ra:J.U! aupno.rqns dSV'HD JO .A:.ruwums rupo+J!d-'f: :IHfl!H.!l 

.... .... .... 

.... .... 

' ' .... 

' .... ' .... 

.... .... .... .... .... .... 

.... 

..... .... ..... ..... 

..... 

.... .... 

..... .... 

.... .... 

.... 

.... 

' ' ' ' ..... 

.... 

' ' ..... 

..... ..... 

.... 

.... ~ .... 

' .... ..... 

trj "'%j < r.n ::0 ~ ::0 A) "t1 "t1 

< ..... t: ~ 0 trj trl C! z > 

> t"" > ~ t-3 t"" -t-3 ::0 trj en ~ ::0 trj t-3 trj en t"" en t-3 "t1 ~ z < >< ::0 trj 

t-3 trj '"l::j 

.... .... .... 

.... 

.... 

.... ' .... 

.... .... .... .... ' .... 

.... ' ' ' .... 

.... ..... 

.... .... ..... .... 

..... 

.... 

..... .... 

.... ' .... 

..... 

' ..... ' 

..... ' ' ' ' ' ' ' ' ' .... 

.... 

' .... ' .... 

' .... 

..... ' 

,, ..... 

0 0 z ~ t"" t"" ~ ..... ::I: "rj "'%j t:l 

"t1 ::a > trj 0 ..... trj '".rj trj ~ - C! 

::0 C1 en ><: ..... t"" z ~ 

trj t"" ~ > trj t-3 t"" ~ ttl 1-ij 0 trj trj z trj "t1 "t1 1-ij 

>< ::0 

t:l -t-3 

S3WVN 3NI.LflOHHflS 

NOI.LdiHOS30 W3.LSXS 03'11Y.L30 

.... 

.... 

.... 

.... 

.... .... .... 

.... 

..... .... ..... 

..... 

.... 

.... 

' ' 

..... 

..... 

.... 

.... t::l t:l 0 l.l 0 

tz:j trj 0 0 0 

"rj 0 z z t"" 

t"" 0 t:l t::l "t1 en ~ t-3 en z 

t-3 "t1 z ~ 

.... 

..... 

..... 

..... 

.... 

to 

t::l 

tz:j 

"rj 

3G08Nfl 

NV8S 

.LNdM.OH 

.LSI'lH 

dX3'13H 

'1VA3Hd 

3SflVd 

)J;)Vd 

d3Hd0 

..\.380 

H.LDN3'1 

GHHX.3)J 

.LIN I 

3'lldl 

AN081 

.Lfld.L3D 

dDGNid 

GNid 

3AIHGd 

'1VA3 

H3AIHG 

.LS'ld3G 

3Nid3G 

dW083G 

dWOJ 

.LNd'lOJ 

.LSI'lH 

dX..LNIH 

.LINIH 

GNidH 

d3GH 

SS388V 

en 

C! 

to 

::0 

0 

C! 

~ 

z 

trj 

z 

>· 

~ 

trj 

en 
8 GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

Polish form expressions, the reader is referred to 

Lee (1967, p. 162-180). 

NUMBER LISTS 

Number lists are composed of one or more integer numbers or number ranges (for example, 1, 

2-7, 10). Each pair of elements in a number list 

must be separated by a comma. Individual elements 

are generated from the unpacked character form by 

constructing each number, one digit at a time, using a sequential lookup on each character. Number 

ranges .are generated by filling in the interior numbers from the pair of extremes. 

NAME LISTS 

Name lists are composed of one or more names. 

When the name list contains a single element such 

as a file name, the packed form is obtained and associated with the appropriate FORTRAN unit number. If the name list is one or more attribute names, 

each pair of which is separated by a comma, each 

elem·ent is packed and looked up using the binarysearch technique. 

ARITHMETIC EXPRESSIONS 

Arithmetic expressions may be entered in the 

place of single attribute names as supplementary 

input to the LIST command. These arithmetic expressions may be composed of constants, the grouping symbols ( ) , attribute names, the arithmetic 

operators +, *, /, -, and the functions square 

(SQR), square root (SQRT), log base 10 (LOG) 

and power of 10 (EXP). The arithmetic expression 

is converted on input to reverse-·Polish form. Evaluation is done on output. If any of the attributes in 

the expression has no value for a given record, the 

expression is not evaluated. All conversion to reverse-Polish form is done using transition-matrix 

parsing. Bauer and Samelson (1960) give a discussion of this technique. 

SEARCHES 

The two general types of GRASP searches are external file and internal table. External-file searches 

are made on the Dictionary file, Multiple-choice file, 

and Numeric Master file. 

The Dictionary file i.s searched in two ways. The 

first way is as an indexed sequential file. When a condition relating an attribute name to a characterstring value is entered, the record number of the 

first entry of the dictionary for that attribute is 

obtained from the "unnamed" common area. That 

record is read (directly), giving the entry value and 

a pointer to the record containing the next entry. 

The entry value is compared with the characterstring value, and, if not equal, the record containing 

the next entry is read. This process continues until 

an entry is found that matches the character-string 

value, or until all entries of the dictionary have been 

read. The latter condition is detected by a nextrecord-pointer of zero. The second way of searching 

the Dictionary file is as a direct- (random-) access 

file. To display the value of a character-type attribute, its pointer is obtained from the current 

record of the selected Numeric Master file 1 and its 

value is obtained by a direct-access read on the 

Dictionary file. 

Multiple-choice acronym values are obtained when 

a condition is entered involving a multiple-choicetype attribute and when the value (s) of a multiplechoice-type attribute is to be displayed. Each record 

of the Multiple-choice file contains all the acronym 

values for a particular multiple-choice attribute. In 

all cases, the Multiple-choice file is read in direct-

( random-) ~access mode using a pointer from the 

"unnamed" common area. After the correct record 

has been obtained, the attribute values are available 

in a tabular (array) form. 

The Numeric Master file is searched in a purely sequential fashion. This search involves the application 

of a "question" to each record of the file where the 

"answer" can only be "yes" or "no." If the answer is 

"yes," the record is written on an output file. The 

question is posed by previously entering conditions 

and relating them by a logical expression. 

Internal table searches are made on attribute 

names and single characters. All lookups on attribute names are done using the "binary search" technique on a ~sorted list. The list of names are read 

and sorted by execution of the FILE command. The 

interval that possibly contains the desired name is 

~repeatedly halved until it is of length one. At that 

point, the position of the name is known, or the 

name is not in the list. 

Single characters are looked up s·equentially when 

the list of possibilities is short, as in the case of 

digits in a number. A "hash code" technique is 

applied for longer list1s such as alphabetic letters. 

This technique involves the initial storage of pos:sibilities in a position dictated by a function applied 

to the value itself. This is done in a table whos.e 

size is greater than the number of possibilities. If 

1 The selected Numeric Master file most probably will be some retrieved 

subset of the true Numeric Master file. 
DATA-BASE IMPLEMENTATION 9 

the position is already occupied, an additional function is applied to the value until an unoccupied 

position is found. Once the possibilities have been 

stored in this manner, the lookup of an arbitrary 

character is accomplished by applying the same procedure. If an empty position is detected during lookup, the character is not in the list. Bell and Kaman 

(1970) give a more detailed description of the technique. 

OUTPUT 

A data-retrieval system designed for interactive 

use should provide the user with information regarding us·e of the system, the structure and content of a particular data base, and the capability of 

displaying selective attribute values for records of 

some partition of a data base. These capabilities 

have been incorporated in GRASP and are individually discussed in the following paragraphs. 

Information regarding use of the GRASP system 

is provided in two ways. First, all us·er response is 

preceded by system-generated "prompts" which 

indicate the type of response desired. Secondly, a 

command (HELP) has been implemented that gives 

the user a brief description of each command recognized by the system. 

Information regarding the structure and content 

of a particular data base is obtainable via the 

NAMES and FUNCTION commands. The NAMES 

command allows the user to determine attribute 

names (acronyms) and corresponding data types. 

A brief description is provided for each attribute 

name printed. After the selected attribute names 

have been printed, the user may examine the set 

of possible values assumed by character-and 

multiple-choice-type attributes. For numeric-type 

attributes, the user may obtain arithmetic means 

and ranges by selecting the MEAN function after 

issuing the FUNCTION command. 

A partition of a data base is created when a 

retrieval has been made using the CONDITIONS, 

LOGIC, and SEARCH commands. The displaying of 

selective attribute values for records of this partition 

is accomplished by using the LIST or DUMP commands. The DUMP command permits the user to 

print all values present for attributes in a selected 

set of categories. The values are printed one to a 

line with the corresponding attribute name. The 

LIST command permits the selection of specific 

attribut·es or arithmetic expressions containing 

attribute names for printing. The printing is selectably formatted into columns or rows. For columnar 

output, the user may create a separate data set 

which could be used by other programs at a later 

time. 

DATA-BASE IMPLEMENTATION 

In the previous section on file description, it was 

noted that the various fHes were integral to and 

nec·essary for GRASP to function. There are approximately as many methods of data collection as 

there are data bases, and it is not the intention of 

the writers to dictate data-base structures or methods of data collection. However, the following suggestions will facilitate the construction of the files 

necessary for GRASP implementation. 

The structure of any GRASP data base must be 

such that it can be manifest in a tabular fashion. 

The table representing a data base is composed of 

columns that ·are attributes and rows that are items 

described by these attributes. For purposes of this 

report, the word "record" will be used in reference 

to rows. Before any files can be constructed, a comprehensive list of names of attributes (or column 

headings) must be compiled. Keep in mind that this 

arrangement of attributes will describe every record in the data base, and that although provision 

is made for all attributes, no record need contain 

data on every attribute. For each attribute that 

assumes a character-string value, a dictionary is 

compiled whose entries are the values assumed by 

that attribute. These dictionaries are used to create 

the Dictionary file. Once the Dictionary file is constructed, the record number (that is, pointer) of 

the first entry (that is, value) for each charactertype attribute is known. By using this information 

and the previously compiled list of names of attributes, the Mask file can be created. Next, all attributes should be grouped into categories of related 

information. This grouping provides the information necessary for the construction of the Definitions file. For multiple-choice-type attributes one 

simply needs to assign and to delineate value acronyms for each attribute in a record. Each group 

of value acronyms forms a set, and the collection of 

sets forms the Multiple-choice file. 

Finally, the Numeric Master file is constructed, 

one record at a time. The individual record is constructed by assigning values for each attribute in 

the order of its occurrence in the Mask file. For 

integer or r·eal attributes, the value is inserted directly. For character-type attributes, the entry number 

of the value in the appropriate dictionary is inserted. 
10 GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

For multiple-choice-type attributes, the binary encoded word that describes its value is inserted. The 

record is then compressed as described in the section "Data File Structures." 

USE OF GRASP 

From the viewpoint of a user, GRASP is a mechanism for obtaining information from a data bank 

in a very ~simplistic and rigid manner. The "language" which is used to "direct" GRASP is composed 

of 11 "commands." These commands can logically 

be divided into four groups. 

GROUP 1 (FILES, NAMES) is used to: 

A. Select or change the data bas·e of interest. 

B. Obtain information regarding the nomenclature 

and content of the selected data base. 

GROUP 2 (LIST, DUMP, FUNCTION) is used 

to: 

A. Examine a selected set of records that is called 

a file. 

B. Perform -selected computations of numeric attributes in a file. 

GROUP 3 (CONDITIONS, LOGIC, SEARCH) 

is used to perform a retrieval (SEARCH) on the 

data bank based on given criteria (CONDITIONS) which are combined via a logical expression (LOGIC), a shorthand method of indicating which records of the data bank are to be 

retrieved. 

GROUP 4 (HELP, REVIEW, QUIT) is used to: 

A. Obtain brief information about the commands 

that GRASP will accept. 

B. Obtain information regarding the history and 

status of the current session with GRASP. 

C. Terminate the current ses-sion with GRASP. 

All commands except HELP and REVIEW will 

ask for some type of response. Each response entered must end by striking the "cr" (RETURN) key. 

If a typing error or incorrect response is given, the 

system asks for another response. If at any point 

the system seems to be idle it is a good practice to 

strike the cr key. Certain commands (SEARCH, 

LIST, DUMP, FUNCTION) require an input file 

name. Entering a blank name in response to 

prompts generated by these commands (that is, cr 

only) results in the selection of the current Numeric 

Master file (as specified in the most recent FILE 

command). The LIST and DUMP commands also 

ask for the number of lines per pag·e. This causes the 

system to pause after each printing of this number 

of lines, awaiting a response from the user. The 

user may then make a hard copy and (or) clear 

the screen if using a CRT terminal. Also, the user 

may terminate the printing altogether. At each 

pause, the user should enter a nonblank character 

followed by a cr if it is desired to abort the rest of 

the printout; otherwise, only a cr will continue 

printing. The method of calling the GRASP system 

into execution will vary, depending on what computer is used. At the beginning of execution, the 

GRASP system will print out the names and descriptions of the data bases available. The data-base 

name corresponds. to the name of the Numeric 

Master file. Assume, for purposes of explanation, 

that a data consisting of oil and ga;s pools in the 

State of Colorado is available and named COLFIL. 

Following is a discussion of each command: 

FJLES.-This command is us~ed to select a data 

base and may be issued at any time during a session. 

The individual-attribute names for any one data 

ba:se will not be recognized by GRASP until this 

command has been issued. The user must enter a 

data-base name when the system asks for it. 

NAMES.-This command is used to list the acronyms which will be us.ed to identify individual 

attributes within a record (that is, pool) and their 

meaning. First, 17 categories are printed. Then the 

system asks the user to enter a list of numbers corresponding to the categories of interest. The list 

should be composed of individual numbers or number ranges (such as 2-5), each of which must be 

separated by a comma. The list must be terminated 

by the cr key: for example, 1, 2-5, 9 cr and 1--4, 

10, 11 cr. The system then lists each acronym 

and its meaning for all the categories of interest. After ~each category is· complete, the system pauses. At this point the user must enter 

cr to continue, or enter any letter (or digit) 

followed by cr to stop. After all categories have 

been completed, the system asks if the user would 

like to see the possible values of any character-type 

or multiple-choice-type item:s. The user must then 

enter Y or N followed by cr to indicate his decision. 

If the user enters N, the ~system will ask the user 

to enter his next command. If the user enters Y, the 

system asks for the names (acronyms) of the attributes of interest. The names are prompted and are 

given one per line followed by a cr. After each name 

is given, the system skips to the next line and prints 

a numeral. To end the list (a maximum of 10 names 

may appear), enter cr (with no name). The system 

then starts printing the attribute names and possibl·e values, pausing after each name is complete. A 

pause also occurs after 30 lines of print. At each 

paus·e, enter cr to continue or any letter (or digit) 
USE OF GRASP 11 

followed by cr to stop. After this process is completed, the system then asks if the user would like 

to see any more possible values. Again, enter Y for 

yes or N for no. 

LIST.-This command is used to output selected 

attribute values (or expressions) from a selected 

file. Output may be to an interactive terminal or to 

a specified data set which could be processed at some 

later time by other programs. The system first asks 

the user for the input-file name and the number of 

lines per page. The user· is next asked to enter C for 

column printing or R for row printing. If column 

output is selected, the user is ·asked if he wants output to be to a disk ~ata set in character form. If so, 

the system will ask for a data-set name. Column 

output prints the ·selected acronyms as headings and 

their respective values below. E-ach column is composed of 8 character positions in a field of 10. One 

line of column output corresponds to one record. 

Row output consists of lines, each of which contain 

an acronym and its corresponding value. If the 

value for a selected attribute is missing, the attribute name is not printed. Records are separated by 

a line of asterisks. Before output proceeds, the system asks for the names of attributes or expressions 

which are desired. This is done by prompting with 

index numbers. 

Expressions may optionally be preceded by some 

name. Five intrinsic functions are available: square 

root (SQRT), square (SQR), log base 10 (LOG), 

power of ten (TEN), and absolute value (ABS). 

Expressions may involve these intrinsic functions 

attribute names, numeric constants, the arithmeti~ operators ( +, -, *, /), and the grouping symbols 

( ) . The following is an example of a list to be 

output: 

1. POOL 

2. FIELD 

3. DEPTH 

4. LOG (DEPTH) 

5. WELLAV = CRUAN69/ (NUMPOOLTOTPROD) 

6. 

In the abov·e example, GRASP has prompted with 

the index numbers 1-6. Note that the list is terminated by a blank entry. 

DUMP.-This command is very similar to the 

LIST command having row printing specified. Instead of asking for a list of names, the system asks 

for a list of category numbers. It then prints (in 

row fashion) the attribute name and value for each 

attribute present in the selected categories of the 

specified file. 

FUNCTION.-This command performs functions 

on a file. Currently, the only functions available are 

the arithmetic mean (MEAN) and a linear leastsquare fit (FI1) of two attributes. The system a·sks 

for the name of the input file. Next, the user is asked 

for the name of the function and names of the arguments. The argument nam·es are the acronyms for 

attributes within a record; as many as five may be 

given. For instance, if MEAN DEPTH, TOTPROD, 

CRUCM70 cr were entered, the range, mean, root 

m·ean square, sum, and sum of squares for DEPTH, 

TOTPROD, and CRUCM70 would be computed and 

printed. If FIT DEPTH, ·TOTPROD cr were entered, the system would respond with the slope, 

intercept, and correlation coefficient. Values for all 

attributes in a record must be present for that record to be included in a computation. 

CONDITIONS.-This command is used to enter 

a set of retrieval criteria. Each criterion must be 

given in the form acronym relation value, where 

acronym is an attribute name (such as COUNTY, 

CRUCM69, POOL), where relation is EQ, NE, GT, 

LT, LE, GE, or BE, and where value is a number 

or a series of letters (such as ADAMS, 19342, MISSIS.SIPPIAN). The above relations have the following meanings : 

EQ-equal to. 

NE-not equal to. 

GT-greater than. 

LT -less than. 

LE-less than or equal to. 

GE-greater than or equal to. 

BE-between (numerically, inclusive). 

The system precedes each condition with a letter 

prompt (up to 26 may be entered) , which will be 

used in the logic expression that combines the conditions. Entering cr by itself terminates the list of 

conditions. Following is an example of a set of conditions: 

A. COUNTY 

B. DEPTH 

C. TOTPROD 

D. LITHOL 

E. COUNTY 

F. POOL 

G. 

EQ 

BE 

GE 

NE 

EQ 

NE 

BACA 

5000,6000 

10 

DOLOMITE 

ADAMS 

MISSISSIPIAN 

In the a-bove example, the system provided the letters A through G as prompts. 

LOGIC.-This command is used to enter a logical 

or connective expression which combines the pre-
12 GEOLOGIC RETRIEVAL AND SYNOPSIS PROGRAM (GRASP) 

viously entered conditions to form the retrieval criterion. The logical expression may be composed of 

the logical connectives (operators), the letters corresponding to the criteria entered via the CONDITIONS command, and the grouping symbols ( ) . 

The logical connectives ar·e AND, inclusive OR, and 

NOT (written .AND., .OR., .NOT.). Note that they 

are each bracketed by periods. Provision has also 

been made to use * (for AND), + (for OR), - (for 

NOT). Assume that the example conditions given 

in the preceding CONDITIONS command section 

had been entered. If the user wanted to retrieve the 

pools in B.aca County that had a depth of 5,000-6,000 

feet, the logic expre·ssion would be A .AND. B cr. 

If all the pools in Adams and Baca Counties except 

those of Mississippian age having dolomite lithology 

were desi~ed, the logic expression would be (A .OR. 

E) .AND. (D .AND. F) cr. Note that the last pair 

of parenth·eses is not really needed. The ANDs will 

be applied befo~e the ORs. NOTs are applied before 

ANDs and ORs. Hence, the first set (A. OR. E) is 

neces,sary so that the E is connected to A instead 

of to D. If one wanted to retrieve all pools with at 

least 10 producing wells having a depth greater than 

6,000 feet or less than 5,000 f·eet, the logic expression 

would be .NOT. B .AND. C cr. If one wanted to 

retriev·e all pools having less than 10 producing 

wells in the same range as above, one could use· 

.NOT. (B .OR. C) cr for a logic expression. This 

expression, in words, ~says "if the pool has a depth 

of 5,000-6,000 feet, or if it has 10 or more producing wells, I don't want it." 

SEARCH.-After the system has been given the 

conditions and connecting logic that compose the 

question to be asked of some file, an actual search 

of the data bank can be made. This is done with the 

SEARCH command. The system will ask for the 

name of the file to be searched (input file) and the 

name to call the file of records found (output file) . 

After the search has been made, the system types 

the number of records searched and the number of 

records found. The capability of entering both input 

and output file names allows the user to perform 

"nested" searches. This means searches of files that 

were the result of previous searches. Frequently 

this is the most economical way of performing 

multiple or complex retrievals. For instance, suppose one wanted information on ~several sets of 

pools, all of which were in one county. One would 

first create an output file that contained all the 

pools in that county and then use that file as the 

input file for subsequent searches. 

HELP.-This command is used to print a list of 

the possible commands and a brief description of 

their functions. 

REVIEW.-This command provides a review of 

the conditions and logic which are currently in 

effect. The nam,es of input and output files for the 

last 10 retrievals are also printed. This command 

is used to refresh one's memory on what was done 

rec·ently during the current session. 

QUIT.-This command is used to exit from the 

GRASP system. A list of the files created during 

this ~session is printed, and the user is permitted to 

.sav~e them for future use. Abnormal session interrupts and terminations will cause GRASP to cease 

functioning. However, all files created during the 

active session are either saved or not saved, according to the abnormal termination rules of the particular computing system. On abnormal termination, 

GRASP neither saves nor deletes files. 

REFERENCES CITED 

Bauer, F. L., and Samelson, K., 1960, Sequential formula 

translation: Assoc. Computing Machinery Commun., v. 

2, no. 2, p. 76-83. 

Bell, J. R., and Kaman, C. H., 1970, The linear quotient hash 

code: Assoc. Computing Machinery Commun., v. 13, no. 

I 11, p, 675-677, 

I 

Lee, J. A. N., 1967, The anatomy of a compiler: New York, 

, Reinhold Publishing Corp., 275 p. 
GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 13 

GRASP SOFTWARE SPECIFICATIONS 

MODULE NAME: DRIVER 

Purpose: DRIVER is used primarily as a switching/calling 

mechanism. User commands are accepted and decoded. Control is then passed to the routine designed to process the 

given command. This process continues until the user "quits." 

Subroutines called: START, KEYBRD, CONDTN, LOGEXP, 

RETRVE, FTNC, FILES, CONDS, HELP, DUMPIT, 

NAME, LIST, QUIT, PACK. 

Common data referenced: None 

Called by: None 

Error checking and reporting: The command entered by the 

user is checked against the list of legal commands. If a 

command is not recognized, it is echoed back to the user 

G R A S P S 0 U R C E 

terminal with a message suggesting use of the HELP command. 

Program logic: 

1. Initialization is performed by zeroing counters and calling START. 

2. An unpacked character string is accepted from the user 

via subroutine KEYBRD. 

3. A four-character command is formed by packing the above 

string into COMMAND. 

4. COMMAND is then compared with the list (WORDS) of 

acceptable command words (NAMES). When a match is 

found, control is transferred to the appropriate subroutine 

via a computed GO TO. 

5. Steps 2 through 4 are repeated until an end-of-file (EOF) 

condition is sensed on the terminal or until the QUIT command is executed. 

P R 0 G R A M 

INTEGER WORDS( 11) ,COMANO,NAMEPT(26) ,RCOOE(26 ), IVAL(26t ,POLISH(30)000000l 

1 ,IMAGE(5),IFILES(20),0FILES(20) 0000002 

DATA WORDS/ 1 COND' , 1 LOGI 1 , 1 SEAR','LIST 1 , 1 FILE', 1 QUIT','NAME','HELP'0000003 

1' I REV I • ' I DUMP.' I FUNC 1 /' I BLNK / 1 I I 

NFILES=O 

LPS=O 

CALL START 

110 TYPE 270 

COMAN D= I B LNK 

CALL KEYRRD(&260,1MAGE,4) 

CALL PACK(IMAGE,COMAND,4,41 

00 120 1=1, 11 

IF (COMANO.EQ.WORDS(l)) GO TO 130 

120 CONTINUE 

TYPE 290, COMAND 

GO TO 110 

130 GO TO (140,150,160,24G,190,260,230,210,180,220,170), 

140 CALL CONOTN(&llO,NAMEPT,RCOOE,IVAL,NREXP) 

GO TO 110 

150 CALL lOGEXP(&llO,POLISH,LPS,NREXP~ 

GO TO 110 

160 CALL RETRVE(&150,&11C,IFILES,OFILES,NFILES,POLlSH,LPS,NAMEPT, 

1 RCOOE,IVAL,NREXP) 

GO TO 110 

17C CALL FTNC(&1101 

GO TO 110 

190 CALL FILES(&110) 

GO TO 110 

180 CALL CONDS(NREXP,LPS) 

IF (NFILES.GT.OI GO TO 200 

TYPE 300 

GO TO 110 

20C TYPE 310, (IFILES(I),OFILES(I),l=1,NFILES) 

GO TO 110 

2 1 C C All HE L P ( W 0 RD S ) 

GO TO 110 

220 CAll DUMP IT 

GO TO 110 

OOOOJ04 

0000005 

0000006 

0000007 

ocoooos 

0000009 

OOOOJlO 

0000011 

0000012 

0000013 

0000014 

0000015 

0000016 

0000017 

0000018 

0000019 

0000020 

0000021 

0000022 

0000023 

0000024 

0000025 

0000026 

0000027 

0000028 

0000029 

0000030 

0000:131 

0000032 

0000033 

0000034 

0000035 

0000036 

0000037 

0000038 
14 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

230 CALL NAME(&l10t 

GO TO 110 

24C CALL LIST(&llO) 

GO TO 110 

260 CALL QUIT(OFILES,NFILES) 

STOP 

270 FORMAT ( // 1 ENTER COMMAND: ',S) 

290 FOR~AT (1X,A5, 1 ILLEGAL COMMAND. ENTER HELP IF YOU WISH TO SEE', 

l' THE LEGAL COMMANDS. 1 /) 

300 FORMAT ( 1 NO FILES HAVE BEEN USED AT THIS TIME.') 

310 FORMAT ( 1 INPUT: OUTPUT: 1 /(2X,A5,2X,A5/)) 

END 

0000039 

0000040 

0000041 

0000042 

0000043 

0000044 

0000045 

0000:>46 

0000047 

0000048 

0000049 

0000050 
GRASP SOFTWARE SPECIFICATIONS 15 

SUBROUTINE NAME: ACCESS 

Purpose: ACCESS looks up character-string values in dictionary files. In order to minimize disk accesses, five previous 

values are saved for as many as 100 distinct character-type 

items. 

Calling sequence: CALL ACCESS(NUMD,IVAL,TANK, 

NWORDS,ISWTCH) 

Arguments: 

NUMD-Item number of the character-type variable whose 

values are to be accessed. 

IV AL-Direct-access key under which value is stored. 

TANK-Contains the character value accessed. 

NWORDS-The number of words in TANK. 

ISWTCH-Switch to control which of the following four 

functions are desired : 

1. Initialization for dictionary lookup. 

2. Lookup a random item. 

3. Return the direct-access key of the first item in this 

dictionary. 

G R A S P S 0 U R C E 

4. Return the indicated (by IV AL) entry and the KEY for 

the next entry (that is, reset IVAL). 

Subroutines called: None 

Common data referenced: IDPT in /DACOMM/ 

Called by: BDEF, COLPNT, DUMPIT, PNTER, ROWPNT 

Error checking and reporting: None 

Program Logic: The logic is divided into four sections relating to values of. ISWTCH. 

1. If ISWTCH=1, initialize saved pointer arrays (USED, 

LASTDX) and set character variable counter NCVAR to 

zero. 

2. If ISWTCH=2, see if the value has been stored in BUFFER. If so, return it; otherwise access it on FORTRAN 

unit 21 and save its value (TANK), index (IVAL) and 

the item number (NUMD). 

3. If ISWTCH=3, return the direct-access key for the first 

entry of the dictionary pointed to by NUMD. 

4. If ISWTCH=4, access the entry pointed to by IVAL and 

reset IV AL to the key for the next entry in this dictionary. 

P R 0 G R A M 

SUBROUTINE ACCESS(NUMD,IVAL,TANK,NWORDS,ISWTCH) 

COMMON /DACOMM/ NV,IOPT 

0000051 

0000052 

0000053 

OOOOJ54 

0000055 

0000056 

0000057 

0000058 

0000059 

0000060 

0000061 

0000062 

0000063 

0000064 

0000065 

0000066 

0000067 

0000068 

OOOOQ6q 

0000070 

0000071 

0000072 

0000073 

0000074 

0000075 

0000076 

0000077 

0000078 

0000079 

0000080 

0000081 

0000082 

0000083 

0000084 

INTEGER TANK(l),BUFFER(5,100,5),USE0(100),1NDEX(l00), 

l LASTOX(5,100),10PT(500) 

DATA I B LNK, NO I C T / 1 1 , 21/ 

GO TO (5,15,100,150),ISWTCH 

5 NCVAR=O 

DO 10 J=l,lOO 

USED(J)=O 

DO 10 1=1,5 

10 LASTDX(I,J)=-999999 

GO TO 320 

15 IFCNCVAR.EQ.O) GO TO 30 

DO 20 KK-=l,t..cVAR IF(I~OEX(KK).EQ.NUMD) GO TO 40 

20 CONTINUE 

30 NCVAR-=NCVAR+l 

IF(NCVAR.GT.l00) NCVAR=lOO 

KK=NC VAR 

INDEX(KKJ=NUMD 

40 IF(USEO(KKI.EQ.O) GO TO 240 

DO 5C K=l,5 

IF(IVAL.EQ.LASTOX(K,KK)) GO TO 60 

50 CONTINUE 

GO TO 240 

60 NWORDS= 5 

DO 70 I=l,NWORDS 

7C TANK(I)=BUFFERCI,KK,K) 

GO TO 320 

100 IVAL=IOPT(NUMD) 

GO TO 320 

150 REAO(NOICT' !VAL) NP,NWORDS, (TANK (I), l=l,NWORDS. 

I VAL =NP 

GO TO 320 
16 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

240 ISTART=IDPT(NUMO) 

READ(NOICT'ISTART+IVAL-1) NP,NWOROS,(TANK(I),I=l,NWORDS) 

USED(KK)=MOO(USEO(KK),5)+1 

NUS ED=US EO( KK) 

DO 26C 1=1,5 

260 BUFFER(l,KK,NUSED)=IBLNK 

NWORO=MINO(NWOR0$,5) 

DO 27C I=l,NWORO 

270 BUFFER(l,KK,NUSED)~TANK(I) 

LASTOX(NUSED,KK)=lVAl 

320 RETURN 

END 

0000085 

0000086 

0000087 

0000088 

0000089 

0000090 

0000091 

0000092 

0000093 

0000094 

0000095 

0000096 
GRASP SOFTWARE SPECIFICATIONS 17 

SUBROUTINE NAME: BDEF 

Purpose: BDEF provides access to the character and multiplechoice dictionaries. 

Calling sequence: CALL BDEF (&n) 

Argument: 

n-Statement number (in caller) to which a branch is made 

if an EOF is sensed by KEYBRD. 

Subroutines called: KEYBRD, VLIST, ACCESS, PAUSE, 

BINTYP, IFILE 

Common data referenced: 

FNAMES, WHICH in /FILNAM/ 

ITYPE in blank common 

Called by: NAME 

Error checking and reporting: The user response to a "yes/ 

no'' question is checked. If illegal, a message is typed, and 

the user is prompted for another :vesponse. If i:m item is 

selected that is not a multiple-choice or character-type item, 

a message is typed, and the user is requested to reenter a 

list of item names. 

G R A S P S 0 U R C E 

SUBROUTINE BDEF(*) 

COMMON NAMES,ITYPE,IPTS,IPAD 

COMMON /FILNAM/ FNAMES,WHICH,PAO 

Program logic: The user is prompted to determine if a list of 

multiple-choice or character-type valu-es is desired. If the 

response (obtained from KEYBRD) is "N", a branch is 

made to the end of the routine. If the response is. "Y," a list 

of item names is obtained by a call to VLIST. If an EOF 

is sensed, the nonstandard return (from VLIST) exits via 

the nonstandard return of BDEF. The data type is determined for each name (TAGS) returned by VLIST. If the 

type is not multiple choice or character, that message is 

typed, and the next element of TAGS is considered. If the 

type is multiple choice, a call to BINTYP is used to obtain the permissible values, for printing. If the type is character, calls to ACCESS are made to obtain the possible 

values. When the second argument of ACCESS is returned 

as zero, all possible values have been referenced. A programmed pause is generated after each 30 lines of print 

and after each item in TAGS is processed. Just prior to return (standard or nonstandard) , unit 22 (the binary or 

multiple-choice file) is rewound, and the unit number is 

reassociated with the current file name via a call to IFILE. 

PROGRAM 

DOUBLE PRECISION LABEL(25),NAMES(500),TAGS(20) 

INTEGER IPTS(500),FNAMES(21t,WHICH,PA0(4t 

INTEGER BINL(20),YES,NO,REPLY,BITEM(15,25),1TYPE(500),TANK(25) 

EQUIVALENCE (BITEM(l,l),TANK(l)) 

0000:>97 

0000098 

0000099 

0000100 

0000101 

0000102 

0000103 

0000104 

0000105 

0000106 

0000107 

0000108 

0000109 

0000110 

0000111 

0000112 

0000113 

0000114 

0000115 

0000116 

0000117 

0000118 

0000119 

OJ00120 

0000121 

0000122 

C000123 

0000124 

0000125 

0000126 

0000127 

0000128 

0000129 

0000130 

0000131 

DATA YES,NO,NBIN/'V','N',22/ 

10 TYPE 120 

20 TYPE 130 

CALL KEYBRDC&llO,REPLY,l) 

IF (RfPLY.EQ.NO) GO TO 100 

IF (REPLY.EQ.YES) GO TO 30 

TYPE 150 

GO TO 20 

3 0 CAlL VL I S T ( & 110 , TAGS, B I Nl, NUM ) 

DO 90 N=l,NUM 

INDEX=BINL(NJ 

IF (ITYPE(INDEXt-3) 60,40,70 

40 TYPE 190, TAGS(NI 

CAll ACCESS (INDEX, K, TANK, NOM, 3) 

DO 50 J=l,lOOOO 

CALL ACCESS(INDEX,K,TANK,M,4) 

TYPF 160, (TANK(I),I=1,M) 

IF(K.EQ.O) GO TO 90 

IF (M0D(J,30).NE.O) GO TO 50 

CALL PAUSE(&100) 

50 CONTINUE 

60 TYPE 170, TAGS(N) 

GO TO 90 

70 IF(ITYPE(INDEXt.NE.4) GO TO 60 

CALL BINTYP(INOEX,LABEL,BITEM,K,M) 

TYPE 190, TAGS(Nt 

DO 80 J=l,M 

80 TYPE 180, LABEL(J),(BITEM(I,J),I=1,K) 
18 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

90 CALL PAUSE(&100f 

GO TO 10 

100 REWIND NBIN 

0000132 

0000133 

0000134 

0000135 

0000136 

0000137 

0000138 

110 

CALL IFILE(NBIN,FNAMESC16+WHICHt) 

RETURN 

REWIND NBIN 

CALL IFILE(NBIN,FNAMfS(l6+WHICHt) 

RETURN 1 0000139 

120 FORMAT (' WOULD YOU LIKE TO SEE THE POSSIBLE VALUES •,•OF MULTIPLE0000140 

0000141 

0000142 

0000143 

1 CHOICE'/' OR CHARACTER TYPE ITEMS?') 

130 FORMAT(' CENTER Y FOR YES, N FOR NO): •,S) 

150 FORMAT ( 1 YOUR REPLY WAS NOT UNDERSTOOD.') 

160 FORMAT (10X,l2A5J 

17C FORMAT (1X,A8, 1 IS NOT A MULTIPLE 

180 FORMAT (11X,A7, 1 - 1 ,15A4J 

190 FORMAT (1X,A8, 1 =1 ) 

END 

0000144 

CHOICE OR CHARACTER TYPE ITEM.•) 0000145 

0000146 

0000147 

0000148 
GRASP SOFTWARE SPECIFICATIONS 19 

SUBROUTINE NAME: BFIND 

Purpose: BFIND is used to look up a double-word-item name 

in a list of double-word-item names having a given sorted 

order. 

Calling sequence: CALL BFIND (&n,KEY~IPOST,KEYS, 

INDEX,K) 

Arguments: 

n-Statement number (in caller) to which a branch is made 

if the name KEY is not in the list of names KEYS. 

KEY-The double-word item to be looked up. 

!POST-The position in KEYS of the item KEY. 

G R A S P S 0 U R C E 

KEYS-The list of double-word names that will be used to 

look up KEY. 

INDEX-Gives the indices of the sorted form of KEYS. 

K-The number of elements in KEYS. 

Subroutines called: None 

Common data referenced: None 

Called by: DECOMP, PARSE, RELEXP, VLIST 

Error checking and reporting: None 

Program logic: The standard binary-search technique is used, 

which repeatedly halves the interval of search on a sorted 

list. If the interval of search goes negative, the element is 

not in the list and the nonstandard return is taken. 

PROGRAM 

SUBROUTINE BFIND(*,KEY,IPOST,KEYS,INOEX,K) 

DOUBLE PRECISION KEY,KEYS(l) 

0000149 

0000150 

0000151 

0000152 

0000153 

0000154 

0000155 

000015b 

0000157 

0000156 

0000159 

0000160 

0000161 

0.000162 

0000163 

0000164 

0000165 

0000166 

DIMENSION INDEX(l) 

ll=l 

LZ=K 

70 IF (l2.LT.Llt RETURN 1 

J=(ll+l2)/2 

I=INOEX(J) 

IF (DABS (KEVJ .GT .DABS(KEVS( I))) GO TO 90 

IF (OASS(KEY).LT.OABS(KEYS(I)Jt GG TO 80 

GO TO 100 

80 LZ=J-1 

GO TO 70 

90 l1=J + 1 

GO TO 70 

100 IPOST=I 

RETURN 

END 
20 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: BINIT 

Purpose: BINIT is used to sort a list of double-precision words 

(NAMES, in this instance) into ascending order and return an array of indices giving the sorted order of the 

elements in terms of the unsorted order. 

Calling sequence: CALL BINIT (KEYS,INDEX,M) 

Arguments: 

KEYS-The list of double-precision words to be sorted. 

INDEX-An array of indicies giving the unsorted order 

G R A S P S 0 U R C E 

SUBROUTINE BINIT(KEYS,INOEX,M) 

DOUBLE PRECISION KEYS(l),KTEMP 

INTE:GER INDEX( 1) 

DO 10 J=l ,M 

10 INDEX(J)=J 

MO=M 

20 IF tMO.LE.l) GO TO 60 

J=4 

IF (MO.GT.l5) J=8 

M0=2*(MO/J)+l 

KO=M-MO 

JO=l 

30 I=JO 

40 J= I+MO 

of KEYS. 

M-The number of words in the KEYS and INDEX arrays. 

Subroutines called: None 

Common data referenced: None 

Called by: FILES 

Error checking and reporting: None 

Program logic: An in-place sort is performed using the standard "Shell" technique .. The original order of KEYS is overwritten, and the sorted order is returned in INDEX. 

P R 0 G R A M 

IF (OABS(KEYS(l)).LE.DABS(KEYS(J))) GO TO 50 

KTEMP=KEYS(IJ 

0000167 

0000168 

0000169 

0000170 

OOC0171 

0000172 

0000173 

0000174 

0000175 

0000176 

0000177 

0000178 

0000179 

0000180 

0000181 

0000182 

0000183 

0000184 

0000185 

0000186 

0000187 

0000188 

0000189 

0000190 

0000191 

0000192 

0000193 

KEYS(IJ=KEYS(J) 

KEYS( J)=KTEMP 

ITEMP=INDEX(I) 

INDEX (I)= INDEX( J) 

INDEX(Jt=ITEMP 

I=I-MO 

IF ( I -1 ) 50 , 40, 40 

50 JO=JO+l 

IF (JO-KO) 30,30,20 

60 RETURN 

END 
GRASP SOFTWARE SPECIFICATIONS 21 

SUBROUTINE NAME: BINTYP 

Purpose: BINTYP reads the values (LABEL, BITEM) 

which can be assumed by the multiple-choice-type item 

whose number is NUMD. 

Calling sequence: CALL BINTYP,(NUMD,LABEL,BITEM, 

LNG,NUM) 

Arguments: 

NUMD-Integer specifying a multiple-choice-type item. 

LABEL-Set of values (double word) that may be assumed 

by this item. 

BITEM-Set of descriptions corresponding to elements of 

LABEL. 

G R A S P S 0 U R C E 

LNG-Maximum length of a description. 

NUM-The number of descriptions. 

Subroutines called: I FILE 

Common data referenced: FNAMES, WHICH in /FILNAM/ 

Called by: BDEF, COLPNT, DUMPIT, PNTER, ROWPNT 

Error checking and reporting: None 

Program logic: Records of the multiple-choice (binary) file 

are read sequentially until the correct record is obtained. 

If the fi,le was positioned past the desired record at call 

time, an EOF is sensed, the file is rewound, and the current multiple-choice file name is reassociated with unit 22. 

P R 0 G R A M 

SUBROUTINE BINTYP(NUMO,LABEL,BITEM,LNG,NUM) 

COMMON /FILNAM/ fNAMES,WHICH,PAD 

0000194 

0000195 

0000196 

0000197 

0000198 

0000199 

0000200 

0000201 

0000202 

0000203 

0000204 

0000205 

0000206 

DOUBLE PRECISION LABEL(l) 

INTEGER FNAMES{2l),WHICH,PA0(4),BITEM(l5,25) 

DATA NBIN/22/ 

300 REAO(NBIN,END=310) NAME,NUM,LNG, 

A (LABEl ( J) , (BIT EM ( I , J) , I= 1, LNG), J = 1, NUM ) 

JF(NUMD-NAME) 310,320,300 

310 REWIND NBIN 

CALL IFILE(NBIN,FNAMES(l6+WHICHtt 

GO TO 300 

320 RETURN 

END 
22 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: BLIST 

Purpose: BLIST returns a list of numbers giving the bit positions of the "ones" in a binary word. 

Calling sequence: CALL BLIST(LIST,NUML,ICODE) 

Arguments: 

LIST-Array of integers giving the bit positions in ICODE 

which are "ones," counting right to left. 

NUML-The number of items in LIST. 

ICODE-The binary word to be examined by BLIST. 

Subroutines called: None 

Common data referenced: None 

Called by: COLPNT, DUMPIT, ROWPNT 

Error checking and reporting: None 

Progrann logic: ICODE is moved to IDUM. IDUM is successively divided by 2, and the least significant bit is accessed by the MOD function. If the least significant bit is 

"one," the position counter ts added to LIST. 

G R A S P S 0 UR C E P R 0 G R A M 

SUBROUTINE BLIST(LIST,NUML,ICODE) 

INTEGER ll S T( 1) 

NUML=O 

IOUM-=ICODE 

DO 10 1-= 1, 2 5 

IF (IOUM.EQ.O) GO TO 20 

IF (M00(10UM,2).EQ.Ot GO TO 10 

NUML = NUML + 1 

LIST(NUMLI=I 

10 IDUM=IDUM/2 

20 RETURN 

END 

0000207 

OOOOZ08 

0000209 

0000210 

0000211 

0000212 

0000213 

0000214 

0000215 

0000216 

0000217 

0000218 
GRASP SOFTWARE SPECIFICATIONS 23 

SUBROUTINE NAME: COLPNT 

Purpose: COLPNT outputs the values of as many as 20 selected items or expressions. Output is columnar and is directed to the terminal or to a disk data set. 

Calling sequence: CALL COLPNT(&n,NPAGE) 

Arguments: 

n-Statement (in calling routine) to which a branch is 

made if the nonstandard return is taken from VLIST 

(KEYBRD senses EOF). 

NPAGE-Numbm- of lines between pauses per page of 

terminal output. 

Subroutines called: KEYBRD, OFILE, VLIST, ACCESS, 

GETPUT, PAUSE, EVAL, UNCODE, BINTYP, BLIST, 

PACK 

Common data referenced: 

POLISH, ICODE, LPS in/EXPRNS/ 

ITYPE in blank common 

G R A S P S 0 U R C E 

SUBROUTINE COLPNTl*rNPAGE) 

COMMON NAMES,ITYPE,IPTS,IDIM 

COMMON /EXPRNS/ POLISH,ICODE,LPS 

Called by: LIST 

Error checking and reporting: None 

Program logic: 

1. The user is asked if he would like the output to go to disk. 

His reply is returned by KEYBRD. If affirmative a logical 

flag is set, and he is prompted for a data-set name. This 

name is then associated with unit 24 via a call to OFILE. 

2. A call to VLIST returns the item names (or expression 

pointers) that· are selected. 

3. A call to ACCESS is made to initialize the lookup of 

character dictionary values. 

4. Each record of the selected file is then obtained via GETPUT, and a line (or record) of output is constructed. For 

numeric data, a format is constructed to maximize the number of significant digits displayed, and the constructed line 

is printed. 

P R 0 G R A M 

DIMENSION ITYPE(500),81TEM(l5,25),1TEMS(20),IRECC500),1PTS(500), 

1RECC500), NAMES(500), TANKC25), LABEL(25), LISTl25), POLISH( 

215,8), ICODEll5,8), LPS(8), IQUAL(6) 

0000219 

0000220 

0000221 

0000222 

0000223 

0000224 

0000225 

0000226 

0000227 

0000228 

0000229 

0000230 

0000231 

0000232 

0000233 

0000234 

0000235 

0000236 

0000237 

0000238 

0000239 

0000240 

0000241 

0000242 

0000243 

0000244 

0000245 

0000246 

0000247 

0000248 

0000249 

0000250 

0000251 

0000252 

0000253 

DOUBLE PRECISION DBLNK,AREA,LINE(20J,NAMES,LABEL 1 VNAMESl20), 

1 F M T ( 3) , F MT S( 8) 

INTEGER BLANK,TANK,YES 

LOGICAL BLNK,TTY 

EQUIVALENCE (REC,IREC),(IVAL,VAL),(TANK,LISTJ,(BLANK,IQUALJ 

DATA FMT,FMTS/'( •,• 1 , 1 ,Al) •, 1 F8.o •,•F8.5 •, 

1 'F8.4 '•'F8.3 1 , 1 f8.2 1 , 1 F8.1 1 , 1 F8.0 1 , 1 1PE8.1 1 /, 

2 OBLNK,YES,IQUAL/ 1 •,•y•,• 1 , 1 G1 , 1 H', 1 L1 , 1 N1 , 1 T1 / 

TYPE 100 

CALL KEYBRDC&290,1 9 1t 

T T Y = I • N E • YE S 

IFCTTY) GO TO 115 

NPAGE=lOOOOOOO 

TYPE 105 

CALL KEYBRDC&290,1TEMS,5) 

J:BLANK 

CALL PACK(ITEMS,I,5,5) 

CALL OFILE(24,1) 

115 KOUNT=O 

CALL VLIST(&290,VNAMES,ITEMS,NUM) 

IF (NUM.EQ.O) GO TO 280 

IF(TTYJ TYPE 300, (VNAMES(l),l=l,~UM) 

CALL ACCESS(II,IVAL,TANK,LK,lt 

120 CALL GETPUT(&270,1REC,1) 

K OUNT =K OUNT + 1 

IF (KOUNT.LE.NPAGE) GO TO 130 

KOUNT=O 

CALL PAUSE( &270) 

TYPE 300, (VNAMES(It,I=l,NUM) 
24 

65 

130 

140 

150 

160 

170 

180 

190 

200 

205 

210 

250 

260 

210 

280 

290 

100 

1C5 

215 

300 

310 

311 

320 

GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

DO 26C JJ-= 1, NUM 

AREA=OBLNK 

II=ITEMS(JJ) 

I F ( I I • G T • G ) G 0 T 0 140 

11=-II 

VAL=EVAL(IREC,ICODE(1 9 ll),POLISH(1,ll),LPS(II),BLNK) 

I F ( BL NK ) GO TO 26C 

GO TO 160 

IVAL=IREC(II) 

IF (IVAL.EQ.BLANK) GO TO 26C 

KIND=ITYPE(ll) 

GO TO ( 150, 160,210,250, 205), KINO 

ENCOOE:(8,320,AREA) IVAL 

GO TO 260 

IF (VAL.EQ.O.) GO TO 180 

A=ALOGlO(ABS(VAL)) 

IF (A.GE.5.) GO TO 190 

IF (A.LE.-4.) GO TO 190 

IF (A.LE.O.) GO TO 170 

._K-=IFIX(A)+2 

GO TO 200 

LK=1 

GO TO 200 

LK=2 

GO TO 200 

LK=8 

FMT ( 2 )= FMTS (LK) 

IF(KINO.NE.5) IQ=l 

ENCDDE(9,FMT,AREA) VAL,IQUAL(IQ) 

GO TO 260 

VAL=UNCOOE(VAL,IQ) 

GO TO 160 

CALL ACCESS(II,IVAL,TANK,LK,2) 

ENCODE(8,215,AREA) (TANK(l),l=l,LK) 

GO TO 260 

CALL BINTYP(II,LABEL,BITEM,K,Mt 

CALL BLISTCLIST,NUMS,IVAL) 

A R E A= LA B El ( l I S T ( 1 ) ) 

LINE(JJ)=AREA 

IF(TTY) GO TO 65 

W R I T E ( 2 4 , 31 0 ) { l I N E ( J J ) , J J = l , N UM ) 

GO TO 120 

TYPE 3ll,(LINE(JJ),JJ=l,NUM) 

GO TO 120 

CONTINUE 

If ( .N 0 T • T T Y ) R E W IN 0 2 4 

RETURN 

RETURN 1 

FORMAT(' WOULD YOU LIKE OUTPUT TO BE TO DISK? (Y OR N): •,$) 

FORMAT(' tNTER NAME OF DISK DATA SET TO BE CREATED: •,$) 

FORMAT(A5,A31 

F 0 RM AT ( Ill 1 X , 8 A 10 ) 

FORMAT ( 20A 10) 

FORM AT ( lX, 8A 10) 

FORMAT (18) 

END 

0000254 

0000255 

0000256 

0000257 

0000258 

0000259 

0000260 

0000261 

0000262 

0000263 

0000264 

0000265 

0000266 

0000267 

0000268 

0000269 

0000270 

0000271 

0000272 

0000273 

0000274 

0000275 

0000276 

0000277 

0000278 

0000279 

0000280 

0000281 

OOC0282 

0000283 

0000284 

0000285 

0000286 

0000287 

0000288 

0000289 

0000290 

0000291 

0000292 

0000293 

0000294 

0000295 

0000296 

0000297 

0000298 

0000299 

0000300 

0000301 

0000302 

0000303 

0000304 

0000305 

0000306 

0000307 

0000308 

0000309 
GRASP SOFTWARE SPECIFICATIONS 25 

FUNCTION NAME: COMP 

Purpose: COMP evaluates a relational expression. The relational operators may be (in FORTRAN notation) EQ, LT, 

GT, LE, GE, NE, or BE (denoting between). The evaluation .is performed on integer, real, or binary-(that is, bit) 

type data. 

Calling sequence: HIT = COMP(IVAR,IVAL,VAR,VAL, 

ICODE,ISWTCH), where HIT is of type LOGICAL. 

Arguments: 

IV AR, IV AL-Integer-type arguments to be compared if 

ISWTCH is 1. 

V AR, VAL-Real-type arguments to be compared if 

ISWTCH is 2. 

!CODE-Encoding of comparison to be made. Assumes 

values 1 through 7, respectively, indicating the relations 

EQ,LT,GT,LE,GE,NE,BE. 

ISWTCH-Indicates the type of arguments for the comparison (integer, real, or binary) . 

Subroutines called: None 

Common data referenced: IVALS in /BTWN/ 

Called by: RETRVE 

Error checking and reporting: If ISWTCH i·s 3 (that is, 

binary-type arguments), !CODE is tested for 1 or 6 (EQ 

or NE). If the test fails, a message is typed and COMP 

returns FALSE as a value. 

Program logic: 

1. The logical variable NONBLK is set to indicate nonblank 

operands. 

2. If ISWTCH is less than 3, the two operands are compared 

according to !CODE. If !CODE is 7 (indicating the between 

operator), the operands are obtained from IVALS in 

/BTWN I by use of IV AL as a pointer to the appropriate set. 

3. If ISWTCH is 3, a bit (binary) comparison is made by 

examining the IV AL'th bit in IV AR. 

G R A S P S 0 U R C E P R 0 G R A M 

LOGICAL FUNCTION COMPCIVAR,IVAL,VAR,VAL,ICOOE,ISWTCH) 

COMMON /BTWN/ IVALS,NBE 

DIMENSION IVALSC2,10), VALS(2 1 10) 

LOGICAL COMPAR,NONBLK 

EQUIVALENCE (IVALS(1,1),VALS(1,l)), (I,VI), (BLANK,IBLNK) 

DATA BLANK/ 1 1 / 

NONBLK=IVAR.NE.IBLNK.ANO.IVAL.NE.IBLNK 

IF(ISWTCH-2) 5,85,165 

5 GO T 0 ( 10, 20, 30, 40, 50, 6 0, 70), I CODE 

1 0 C OM PA R= I V AR • E Q. I VAL 

GO TO 160 

20 COMPAR=IVAR.LT.IVAL.ANO.NONBLK 

GO TO 160 

30 COMPAR=IVAR.GT.IVAL.AND.NONBLK 

GO TO 160 

40 COMPAR=IVAR.LE.IVAL.AND.NONBLK 

GO TO 160 

50 COMPAR=IVAR.GE.IVAL.AND.NONBLK 

GO TO 160 

60 COMPAR= IVAR .NE. IVAL 

GO TO 160 

70 COMPAR=IVAR.GE.IVALS(l,IVAL).AND.IVAP.Lf.IVALS(2,IVALt.AND.NONBLK 

GO TO 160 

85 NONBLK=VAR.NE.BLANK.AND.VAL.NE.BLANK 

G 0 T J ( 9 0 , 1 0 0 , 11 0 , 12 0 , 1 3 0 , 14 0 , 1 5 0) , I C 00 E 

90 COMPAR=VAR.EQ.VAL 

GO TO 160 

100 COM PAR=VAR.l T. VAL. AND .NONBLK 

GO TO 160 

110 COMPAR=VAR.GT.VAL.AND.NONBLK 

GO TO 160 

120 COMPAR=VAR.LE.VAL.ANO.NCNBLK 

GO TO 160 

130 COMPAR=VAR.GE.VAL.AND.NONBLK 

GO TO 160 

140 COMPAR=VAR.NE.VAL 

GO TO 160 

0000310 

0000311 

0000312 

0000313 

0000314 

0000315 

0000316 

JJJ0317 

0000318 

0000319 

0000320 

0000321 

0000322 

0000323 

0000324 

00003·25 

0000326 

000032 7 

0000328 

0000329 

0000330 

0000331 

~JJ0332 

0000333 

JJ00334 

0000335 

0000336 

0000337 

0000338 

0000339 

0000340 

0000341 

0000342 

0000343 

0000344 

0000345 

0000346 
26 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

150 VI=VAL 

COMPAR=VAR.GE.VALS(1,1).AND.VAR.LE.VALS(2,It.AND.NONBLK 

160 COMP-=CCMPAR 

GO TO 180 

165 IF(NONBLK) GO TO 170 

lf(ICODE.EQ.1) GO TO 10 

IFtiCODE.EQ.6) GO TO 60 

TYPE 200 

COMP=. FALSE. 

GO TO 180 

170 IDIGIT=IVAR/2**(1VAL-lt 

IF (ICODE.NE.l) GO TO 190 

COMP=MOD(IDIGIT,2).EQ.l 

GO TO 180 

190 IF (ICOOE.NE.6) TYPE 200 

COMP=MOD(IDIGIT,2).NE.l 

180 RETURN 

200 FORMAT (52H RELATION MUST BE .EQ.I.NE. FOR BINARY TYPE VARIABlE) 

END 

0000347 

0000348 

0000349 

0000350 

0000351 

0000352 

0000353 

0000354 

0000355 

0000356 

0000357 

0000358 

0000359 

0000360 

0000361 

0000362 

0000363 

0000364 

0000365 
GRASP SOFTWARE SPECIFICATIONS 27 

SUBROUTINE NAME: CONDS 

Purpose: CONDS types out the last set of conditions and logic 

entered. 

Calling sequence: CALL CONDS(NCONDS,LPS) 

Arguments: 

NCONDS-The number of conditions currently entered. 

LPS-The length of the current logical expression. 

Common data referenced: EXPR, LOGIC in /INPUT/ 

G R A S P S 0 U R C E 

Called by: DRIVER 

Error checking and reporting: None 

Program logic: 

1. If any conditions have been entered (that is, NCOND >O), 

they are typed out. 

2. If a logic expression has been entered (that is, LPS >0), it 

is typed out. 

P R 0 G R A M 

SUBROUTINE CONOS(NCOND,LPS) 0000366 

COMMON /INPUT/ EXPR,LOGIC 0000367 

Dl~ENSION LA8ELS(26) 0000368 

DOUBLE PRECISION EXPR(4,261,LOGIC(8) 0000369 

o A r A LA s E L s / 1 A I , I a • , • c I , I o I , I e • , • F I , • G I , • H • , • 1 • , • J • , I K • , I L • , • M • , I No o o o 3 1 o 

1 I ' • 0. ' • p. ' • Q. ' I R I ' Is • ' I T • ' I u. ' • v ' ' • w. ' I X I ' I y I ' • l • I 00003 71 

TYPE 40 0000372 

IF CNCOND.EQ.O) GO TO 20 0000373 

00 10 J=l,NCONO 0000374 

10 TYPE 50, LABELS(JI,(EXPR(l,JI,I=1,4) 0000375 

GO TO 30 0000376 

20 TYPE 60 0000377 

30 IF (LPS.NE.O) TYPE 70, LOGIC 0000378 

RETURN 0000379 

40 FORMAT (//) 0000380 

50 FORMAT (4X,Al,'• 1 ,4A10) 0000381 

60 FORMAT ( 1 NO CONDITIONS HAVE BEEN ENTERED YET.') 0000382 

70 FORMAT ( 1 LOGIC STATEMENT IS: 1 ,8Al0) 0000383 

END 0000384 
28 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: CONDTN 

Purpose : This subroutine is used to control the entry of 

"conditions" (see RELEXP). Conditions are entered via 

KEYBRD, decoded via RELEXP, and saved (in character form) in the common area named INPUT. 

Calling sequence: CALL CONDTN (&n,VARS,CODES,V ALS, 

NCOND) 

Arguments: 

n-Statement number (in caBer) to which a branch will 

be made on a nonstandard return. 

V ARS-Array of pointel'\s to items. referenced in the set of 

entered conditions. 

CODES-Array of integers giving the individual relational 

operators in the entered conditions. 

V ALS-Array of values associated with the conditions entered. 

NCOND-Counter giving the number of conditions entered. 

Subroutines called: KEYBRD, RELEXP, PACK 

Common data referenced: 

G R A S P S 0 U R C E 

NBE in IBTWNI 

EXPR in I INPUT I 

Called by: DRIVER 

Error checking and reporting: An error flag returned by 

RELEXP is tested. If set, a request to retype the condition 

is issued. 

Program logic: 

1. A letter (A-Z) is printed as a prompt. 

2. The user respontse (a condition) is obtained via KEYBRD 

and passed to RELEXP. 

3. If no errors have been detected by RELEXP, the user response is packed into AREA and then moved (first 40 characters) into the INPUT common block. 

4. Steps 1-3 are repeated and incrementally counted until 

an aU-blank response is entered. When this occurs, execution resumes at statement 40, which sets the number of 

conditions entered. Control returns to the caller. 

5. The nonstandard return is taken if an EOF i.s sensed from 

the terminal. 

PPOGRAM 

SUBROUTINE CONOTN(*,VARS,CODES,VALS,NCONO) 

COMMON /BTWN/ IVALS,NBE 

0000385 

0000386 

0000387 

0000388 

0000389 

0000390 

COMMON /INPUT/ EXPR,LOGIC 

DOUBLE PRECISION EXPR(4,26),AREA(4),LOGIC(8) 

INTEGER IMAGE(80J,VARS(l),VALS(l),CODEStl),IVALS(2,10t,PROMPT(26) 

LOGICAl ERR 

OAT A PR 0 M p T I I A. ' ' I B • I ' I c • ' ' • 0. ' ' • E • I ' • F. I ' I G. I ' I H •• ' I I • I ' • J •• ' • K. I 0 0 0 0 3 91 

1 ' I L. I ' • M. I ' • N •• ' I 0 •• ' • p •• ' I Q. ' ' • R •• , • s •• ' • T. I ' I u. ' , • v. I ' t w •• ' • x •• '00 003 92 

z•y.•,•z.•J 

NBE-=0 

J=l 

10 TYPE 50, PROMPT(J) 

CALL KEYBR0(&45,IMAGE,80) 

CALL RELEXP(&40,1MAGE,VARS(J),CODESCJt,VALS(J),ERR) 

IF (ERR) GO TO 30 

CALL PACK(IMAGE,AREA,40,40) 

DO 20 1=1,4 

20 EXPR(I,J)-=AREA( 1) 

J=J +1 

GO TO 10 

30 TYPE 60 

GO TO 10 

40 NCONO=J-1 

RETURN 

45 RETURN 1 

50 FORMAT (1X,A3,$) 

60 FORMAT ( 1 RE-TYPE CONDITION') 

END 

0000393 

0000394 

0000395 

0000396 

0000397 

0000398 

0000399 

0000400 

0000401 

0000402 

0000403 

0000404 

0000405 

0000406 

0000407 

0000408 

0000409 

0000410 

0000411 

0000412 
GRASP SOFTWARE SPECIFICATIONS 29 

SUBROUTINE NAME: DECOMP 

Purpose: DE CO MP extracts a list of item names and a corresponding list of item numbers from an unpacked character 

string. 

Callng sequence: CALL DECOMP(&l,&m,IMAGE,NLIST, 

LIST,N) 

Arguments: 

1-Statement (in caller) which will be branched to if an 

invalid item name is detected. 

m-Statement (in caller) which will be branched to if the 

input string contains no item names. 

IMAGE-Unpacked input-character string. 

NLIST-List of item names (offset by one from LIST). 

LIST-A function name followed by a li.st of item numbers. 

N-Total number of items in LIST. 

Subroutines called: BFIND, PACK 

Common data referenced: NAMES, IPTS, IDIM in blank 

common 

Called by: FTNC 

Error checking and reporting: BFIND takes the nonstandard 

return if a name is not found. This causes an error message 

to be typed and a new input to be requested. If a comma 

i·s detected before the list of item names begins, a message 

is typed and new input is requested. 

Program logic: The input-string IMAGE i.s scanned, a character at a time, via a transition matrix. The list of names 

is created and the list of item numbers is obtained via calls 

to BFIND. The following transition matrix is used: 

blank comma 

1 f(0)/1 error 2 f(2)/3 error 3 f(0)/3 f(0)/3 4 f(2)/3 f(2)/3 

where the f(i) are: 

!MAT (4, 3) 

non blank 

f(l)/2 

f(0)/2 

f(3)/4 

f(0)/4 

f(O)-No operation. 

f(l)-Mark first character. 

purpose 

start function name find end of function name start item name find end of item name 

f(2)-Mark last character. Pack and find index of item 

name (that is, find item number). 

f(3)-Increment list item counter and mark first character of new list item. 

The entire input stream is scanned, and control is returned 

to caller. Refer to pll'ogram logic section of LOGEXP for a 

more complete discussion of transition-matrix parsing. 

G R A S P S 0 U R C f P R 0 G R A M 

SUBROUTINE DECOMP(*t*tiMAGE,NLIST,LIST,N) 

COMMON NAMES, ITYPE, IPTS, IDIM 

DIMENSION ITYPE(500), IMAGE( 1), LIST(!), IPT$(500), IMAT(4,3) 

DOUBLE PRECISION NAMES(500),NA~E,DBLNK,NLIST(5) 

EQUIVALENCE (INAME,NAME) 

DATA OBLNK,IBLNK,ICOMMA/ 1 ',• ',• ,•! 

DATA IMAT/1,23,3,23,2*40,3,23,12,2,34,4/ 

N=l 

I ROW= 1 

DO 90 I= 1, 80 

IF (IMAGE(I).EQ.ICOMMA) GO TO 10 

IF (IMAGE( I ).NE.IBLNK) GO TO 20 

IVAL=IMAT(IROW,1) 

GO TO 30 

10 IVAL=IMAT(IPOW,2) 

GO TO 30 

20 IVAL=IMAT(IROW,3l 

30 IROW=MOO(IVAL,lO) 

JOB=I VAL/10 +l 

GO TO (90,50,70,40,120), JOB 

40 N=N+l 

50 IC=I 

GO TO 90 

70 LC=I-1 

NAME=DBLNK 

CALL PACK(IMAGE(IC),NAME,LC-IC+l,8) 

IF (N.GT.1t GO TO 80 

LIST( 11-=INAME 

GO TO 90 

80 CALL BFINO(&lOO,NAME,LIST(N),NAMES,IPTS,IDIMI 

Nll ST (N-1 t =NAME 

0000413 

0000414 

0000415 

0000416 

0000417 

0000418 

0000419 

0000420 

0000421 

0000422 

0000423 

0000424 

0000425 

0000426 

0000427 

0000428 

0000429 

0000430 

0000431 

0000432 

0000433 

0000434 

0000435 

0000436 

0000437 

0000438 

OC00439 

0000440 

0000441 

0000442 

0000443 
30 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

90 CONTINUE 

IF (N.EQ.1) RETURN 2 

RETURN 

100 TYPE 140, NAME 

110 RETURN 1 

120 TYPE 150 1 IMAGE(!) 

GO TO 110 

140 FORMAT (1X,A8, 1 1S AN INVALID NAME. RE-E~TER LINE.') 

150 FORMAT ( 1 PUNCTUATION ERROR CAUSED BY 1 1 Alt'• RE-ENTER LINE.') 

END 

0000444 

0000445 

0000446 

0000447 

0000448 

0000449 

0000450 

0000451 

00004-52 

0000453 
GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 31 

SUBROUTINE NAME: DEFINE 

Purpose: DEFINE is used to define the structure and name 

of a direct-access disk-data set having fixed-length records. 

Individual records may then be directly accessed by specifying the record number. 

Calling sequence: CALL DEFINE(U,S,V,F,PJ,PG) 

Arguments: 

U-The FORTRAN unit number expressed as an integer. 

S-The size of the records within the file, expressed as an 

integer. For formatted records, S gives the number of 

characters per record. For unformatted records, S gives 

the number of words per record. 

V-The associated integer val'liable. The record number 

which would be accessed next if II 0 were to continue 

sequentially is returned as an integer in the associated 

variable after each random read or write. 

F-The name of the file which will be accessed when an II 

0 statement references U (the above unit number) . 

PJ-The project number in octal of the disk area in which 

the file resides. 

PG-The programmer number in ootal of the disk area in 

which the file resides. 

Subroutines called: None 

Common data referenced: None 

Called by: FILES 

Error checking and reporting: None 

Program logic: This is a DEC 1070, TOPS-10 system resident routine. It provides the capab.i\lities referred to in the 

Purpose section above. If the GRASP system is to be implemented on some other main frame, a comparable routine 

must be written or acquired. No listing is shown here. 
32 GRASP SOFTWARE SPECIFICATIONS 

SUBROUTINE NAME: DEFLST 

Purpose: DEFLST outputs the category names to the user and 

allows him to indicate which categories are of interest. 

Error checking and reporting: All user response is checked 

for validity. If errors are detected, the response is requested 

again. 

Program logic: Calling sequence: CALL DEFLST(&m,&n,CAT,NUMC,MC, 

LIST) 

Arguments: 

m-Statement (in calling routine) that will be branched to 

if no category numbers are given when asked for. 

n-Statement (in calling routine) that will be branched to 

if an EOF is sensed in KEYBRD. 

CAT-Contains the category names as read from unit 20 

(the "definitions file"). 

NUMC-Number of categories selected by the user. 

MC-Maximum length in words of a category name. 

LIST-The category numbers selected. 

Subroutines called: !FILE, KEYBRD, LENGTH, RLIST 

Common data referenced: FNAMES, WHICH in /FILNAM/ 

Called by: NAME, DUMPIT 

G R A S P S 0 U R C f 

1. A call to !FILE associates the "definitions" file name with 

FORTRAN unit 20, and the category names are read from 

this file. 

2. The user is asked if he lis interested in all categories. His 

response is checked against "Y" or "N." If invalid, an 

error message is typed, and he is asked to respond again. 

3. If the user's response was "Y ," LIST is set to all the 

category numbers and control is returned to the calling 

routine. 

4. If the response was "N," the user is asked to enter a list 

of category numbers of interest. 

5. His response, contained ·in IMAGE, is passed to RLIS~ to 

generate the values of LIST. 

PROGRAM 

SUBROUTINE OEFLSTl*t*tCAT,NUMC,MC,LIST) 0000454 

COMMON /FILNAM/ FNAMES,WHICH,PAD 0000455 

INTEGER CAT(8,l ),LIST(l),IMAGE(30),fNAMES(21),WHICH,PAD(4) 0000456 

DATA IYES,NO/'Y', 'N'/ 0000457 

CALL IFILE(20,FNAMES(8+WHICH)) 0000458 

READ (20) NCAT,MC,l(CAT(I,J),I=l,MC),J=l,NCAT) 0000459 

25 TYPE 30 0000460 

CALL KEYBRD(&lOO,I,1) 0000461 

IF(I.EQ.IYESl GO TO 40 0000462 

lf(I.EQ.NO) GO TO 5 0000463 

TYPE 35 0000464 

GO TO 25 0000465 

40 NUMC=NCAT 0000466 

DO 45 I=l,NUMC 0000467 

45 LIST( I )=I 0000468 

GO TO 85 0000469 

5 TYPE 110 0000470 

DO 10 J=1,NCAT 0000471 

CALL LENGTH(CAT(l,J),MC,MCL) 0000472 

10 TYPE 120, J,(CAT(I,JI,I=l,MCL) 0000473 

TYPE 130 0000474 

20 CALL KEYBRD(&lOO, IMAGE,30) 0000475 

CALL RLIST(&20,IMAGE,LIST,NUMC,NCAT) 0000476 

If (NUMC.EQ.O) GO TO 90 0000477 

85 RETURN 0000478 

90 RETURN 1 0000479 

100 RETURN 2 0000480 

30 FORMAT(' SHALL All CATEGORIES BE CONSIDERED? (YES OR NO): •,$) 0000481 

35 FORMAT(' YOUR REPLY WAS NOT UNDERSTOOD.') 0000482 

110 FORMAT ( 1 EACH RECORD HAS BEEN DIVIDED INTO THE FOLLOWING •,•GENER0000483 

1Al CATEGORIES: 1 /8X, 1 CAT. # CAT. NAME 1 /8X,•------ ---------•t 0000484 

120 FORMAT (10X,I2,4X,9A5) 0000~85 

130 FORMAT ( 1 ENTER A LIST Of ASCENDING NUMBERS MATCHING •,•YOUR CATEG0000486 

10RIES OF INTEREST'/' (IE. 1,3,5 OR 2-5)') 0000487 

END 0000488 
GRASP SOFTWARE SPECIFICATIONS 33 

SUBROUTINE NAME: DUMPIT 

Purpose: DUMPIT outputs to the terminal those values for 

all items present in a set of user-selected categories. The 

values are obtained from a user-selected file. 

Calling sequence: CALL DUMPIT 

Arguments: None 

Subroutines called: OPREP, DEFLST, FINDGP, ACCESS, 

GETPUT, PAUSE, LENGTH, UNCODE, BINTYP, 

BLIST 

Common data referenced: 

NFILE in /IOUNIT/ 

NAMES, ITYPE in blank common 

Called by: DRIVER 

Error checking and reporting: None 

Program logic: 

1. Page size (NPAGE), input file name, and file unit are 

set up by a call to OPREP. 

2. A call to DEFLST is made to determine categories to be 

dumped. 

3. Calls to FINDGP are made to determine pointers (KLIST) 

for those items in the selected categories. As DEFLST and 

FINDGP used FORTRAN unit 20, the "definitions" file 

for the current data base, the unit is rewound. 

4. A call to ACCESS is made to initialize character dictionary 

lookups. 

5. Each record 'in the input file is obtained by GETPUT, the 

selected items are tested for nonMank characters, and their 

value is output. 

6. The output algorithm is basically as follows: 

(a) Determine item type and switch to appropriate code 

section via a computed GOTO. 

(b) If type is integer, print under an I format. 

(c) If type is real, print under a G format. 

(d) If type is character, obtain string value by a call to 

ACCESS and print under an A format. 

(e) If type is multiple choice, obtain possible values by a 

call to BINTYP, and select the actual subset via a 

call to BLIST. Print this subset under an A format. 

(f) If type is qualified real, obtain value and qualifier via 

a call to UNCODE. Print under a G and A format. 

(g) After each line is printed, increment and test KOUNT 

against page size. If KOUNT is greater than page 

size, call PAUSE for a programmed pause and reindtialize KOUNT to zero. 

(h) After each record has been processed, print a line of 

asterisks as a record separator. 

G R A S P S 0 U R C E PROGRAM 

SUBROUTINE OUMPIT 

COMMON NAMES,ITYPE,IPTS,IPAD 

COMMON /IOUNIT/ NFILE,IOF 

DIMENSION ITYPE(5001, BITEM(l5,25), IRECC500), IQUALC6), 

1 RECC500), TANK(25), LABEL(25), LIST(25) 

DOUBLE PRECISION LABEL,NAMESI, NAMESC500) 

INTEGER TANK,CAT(8,17),KLISTC17J,SELECTC500t,IPTSC500) 

LOGICAL PNT HOG, NEWCAT, HIT 

EQUIVALENCE (REC,IREC),(IVAL,VAL),(TANK,LIST),(IBLNK,IQUALI 

DATA IQUAL/' •,•G•-, 1 H1 , 1 L1 , 1 N','T'/ 

KOUNT =0 

CALL OPREP(t200,t205,NPAGE) 

CALL DEFLST(t200,&200,CAT,NUMC,MC,KLIST) 

NTOT=O 

DO 20 K=l ,NUMC 

CALL FINDGP(t200,KLIST(K),I,J 1 NG,IREC) 

READ (20) 

DO 10 I=l,NG 

NTOT=NTOT+l 

10 SELECT(NTOT)=2*1REC(I) 

SELECT(NTOT-NG+l)=SELECTINTOT-NG+l)+1 

20 CONTINUE 

REWIND 20 

CALL ACCESSIII,IVAL,TANK,J 1 1) 

40 CALL GETPUTC&200,IREC,l) 

HIT=.FALSE. 

KNT=O 

DO 190 JJ=l,NTOT 

II=SELECT(JJ)/2 

NEWCAT=SELECT(JJ).NE.2*11 

If (NEWCAT) KNT=KNT+1 

PNTHDG=PNTHOG.OR.NEWCAT 

0000489 

0000490 

0000491 

0000492 

0000493 

0000494 

0000495 

0000496 

0000497 

0000498 

0000499 

0000500 

0000501 

0000502 

0000503 

0000504 

0000505 

0000506 

0000507 

0000508 

0000509 

0000510 

oouos11 

0000512 

0000513 

0000514 

0000515 

0000516 

0000517 

0000518 

0000519 

0000520 
34 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

NA M E S I= NAME S ( I I ) 

IVAL=IREC(II) 

If (IVAL.EQ.IBLNK) GO TO 190 

HIT=.TRUE. 

KOUNT=KOUNT +1 

IF (KOUNT.LE.NPAGE) GO TO 50 

KOUNT=O 

CALL PAUSE ( &200) 

50 KIND=ITYPE(II) 

IF(.NOT.PNTHDG) GO TO 55 

KL=KLIST(KNT) 

CALL LENGTH(CAT(1,KL),MC,MCL) 

TYPE 21Q,(CAT(t,KL),I=1,MCL) 

PNTHDG=.FALSE. 

55 GO TO (60, 70,80, 170, 160) ,KIND 

60 TYPE 230, NAMESI,IVAL 

GO TO 1~0 

70 TYPE 240, NAMESI,VAL 

GO TO 190 

80 CALL ACCESS(II,IVAL,TANK,J,2) 

TYPE 250, NAMESI,(TANK(l),l=l,J) 

GO TO 190 

16G 

170 

180 

190 

200 

205 

210 

220 

23C 

240 

250 

260 

VAL=UNCODE(VAL,IQ) 

TYPE 240,NAMESI,VAL,IQUAL(IQ) 

GO TO 190 

CALL BINTYP(II,LABEL,BITEM,K,M) 

K OUNT=KOUNT +l 

TYPE 250, NAMES! 

CALL BLIST(LIST,NUMS,IVAL) 

DO 180 I=l,NUMS 

J=LlSTtll 

TYPE 260, LABEL(J),(BITEM(L,J),L=l,K) 

CONTINUE 

IF (HIT) TYPE 220 

GO TO 40 

REWIND NFILE 

REWIND 20 

RETURN 

FORMAT(' CATEGORY: •,8A5) 

FOR~AT (1X,3(8H********)) 

FORMAT (2X,A8,1X,I9) 

FORMAT (2X,A8,1X,lPG12.5,Al) 

FOR~AT (2X,A8,1X,l2A5/11X,l2A5) 

FORMAT (5X,A8,15A4) 

END 

0000521 

0000522 

OOC0523 

OOC0524 

0000525 

0000526 

0000527 

0000528 

0000529 

0000530 

0000531 

0000532 

0000533 

0000534 

0000535 

00005 36 

0000537 

0000538 

0000539 

0000540 

0000541 

0000542 

0000543 

0000544 

0000545 

0000546 

0000547 

0000548 

0000549 

0000550 

0000551 

0000552 

0000553 

0000554 

0000555 

0000556 

0000557 

0000558 

0000559 

0000560 

0000561 

0000562 

00005&3 

0000564 

0000565 
GRASP SOFTWARE SPECIFICATIONS 35 

FUNCTION NAME: EVAL 

Purpose: By using a particular set of values as operands, 

EVAL evaluates a previously parsed Reverse-Polish-form 

arithmetic expression. 

Calling sequence: VAL=EVAL(VALUES,TYPE,POLISH, 

I,BLNK) 

Arguments: 

VALUES-Set of operand values. 

TYPE, POLISH-Arrays containing the encoded ReversePolish form of the expression to be evaluated. The encoding is as follows: Let ITY be the I'th element of TYPE. 

If ITY =0, the I'th element of POLISH ~s a numeric 

constant. If ITY>O, ITY is an index to the array 

VALUES. If ITY <0, ITY corresponds to an arithmetic 

operator or function. 

1-Gives the length of the arrays TYPE and POLISH. 

BLNK-Logical variable set to TRUE if any operand with 

a blank value is sensed. 

Subroutines called: UNCODE 

Common data referenced: !TYPE in blank common 

Called by: COLPNT, ROWPNT 

Error checking and reporting: 

1. Division by zero attempted. 

2. Log of a nonpos.itive value attempted. 

3. Square root of a negative value attempted. 

Program logic: A push-down stack technique is used to evaluate the Reverse-Polish string contained in TYPE and POLISH. TYPE is scanned, an element at a time, pushing 

operand values down on the stack until an operator is 

sensed. Either the top or topmost two stack elements are 

then used as operands resulting in a new topmost-stack 

element which is the resulting value of the operator. Unary 

operators/functions (absolute value, ABS; square root, 

SQRT; logarithm, LOG; square, SQR; ten exponent, TEN: 

minus, -) operate on the top stack element. Binary operators ( +, -, *, I) operate on the topmost-two stack elements. 

After all elements of TYPE have been processed, the stack 

should have one vaJlue in it. This value, the result, is returned. If a blank operand value is detected, the flag BLNK 

is turned on and zero is returned. 

G R A S P S 0 U R C E PROGRAM 

FUNCTION EVAL(VALUES,TYPE,POLISH,I,BLNK) 

COMMON NAMES,ITYPE,IPTS,IPAD 

DIMENSION NAMES(500), VALUES(!), POLISH(l), STACK(41), TYPE(!), 

1YPE(500J,IPTS(500) 

DOUBLE PRECISION NAMES 

INTEGER TOP,TYPE,VALUES 

LOGICAL BLNK 

E QU IV Al EN C E ( VAl , I VAl ) 

DATA IBLNK/' 'I 

BLNK=.FALSE. 

TOP=O 

DO 190 J=l,I 

INDEX=TYPE(J) 

IF (INDEX) 40,30,10 

10 TOP=TOP+l 

IVAL=VALUES(INDEX) 

If (IVAL.EQ.IBLNK) GO TO 195 

IF (ITYPE(INDEX).EQ.2) GO TO 15 

IF( ITYPE( INDEX) .NE .5) GO TO 20 

VAL=UNCODE(VAL,IQ) 

15 STACK(TOP)=VAL 

GO TO 190 

20 STACK(TOP)=IVAL 

GO TO 190 

30 TOP=TOP+1 

STACK(TOP)=POLISH(JJ 

GO TO 190 

40 IF (INDEX.GE.-4) GO TO 130 

INOEX=INDEX+11 

GO TO (50,6C,80, 100, 110,120), INDEX 

50 STACK(TOPI=ABS(STACK(TOP)J 

GO TO 190 

0000566 

0000567 

IT0000568 

0000569 

0000570 

0000571 

0000572 

0000573 

0000574 

0000575 

0000576 

0000577 

0000578 

0000579 

0000580 

0000581 

0000582 

0000583 

0000584 

0000585 

0000586 

0000587 

0000586 

0000589 

000059C 

0000591 

0000592 

0000593 

0000594 

0000595 

0000596 

0000597 
36 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

60 TV= S T ACK ( TOP ) 

IF (TV.GE.O.) GO TO 70 

TYPE 230 

GO TO 200 

70 STACK(TOP)=SQRT(TV) 

GO TO 190 

80 TV=ST ACK (TOP) 

IF ( TV. G T. 0.) G 0 T 0 90 

TYPE 220 

GO TO 200 

90 STACK(T0Pt=ALOG10(TV) 

GO TO 190 

10C STACK(TOPt=STACK(TOP)**2 

GO TO 190 

110 STACKCTOP)=lO.**STACKCTOP) 

GO TO 190 

120 STACK(TOP)=-STACK(TOP) 

GO TO 190 

130 INDEX=INDEX+5 

V T= STACK ( TOP) 

TOP=TOP-1 

GO TO (150,140,180,170), INDEX 

140 STACKCTOP)=STACK(TOP)*VT 

GO TO 190 

150 If (VT.NE.O.OJ GO TO 160 

TYPE 240 

GO TO 200 

160 STACKCTOPt=STACKCTOP)/VT 

GO TO 190 

170 STACK(TOP)=STACKCTOP)+VT 

GO TO 190 

180 STACK(TOP)=STACKCTOPt-VT 

190 CONTINUE 

IF (TOP .NE. 1) GO TO 200 

EVAL=STACK( 1) 

GO TO 210 

19 5 B L NK = • TRUE. 

200 EVAL=O.O 

210 RETURN 

220 FORMAT ( 1 ATTEMPTED TO TAKE LOG Of A ZERO OR NEG. VALUE.') 

230 FORMAT(' ATTEMPTED TO TAKE SQRT OF A NEGATIVE VALUE.') 

240 FORMAT ( 1 DIVIDE BY ZEPO ATTEMPTED.') 

END 

0000598 

0000599 

ovoo6oo 

0000601 

0000602-

0000603 

0000604 

0000605 

0000606 

0000607 

0000608 

0000609 

0000610 

0000611 

0000612 

0000613 

0000614 

0000615 

0000616 

0000617 

0000618 

0000619 

0000620 

0000621 

0000622 

0000623 

0000624 

0000625 

0000626 

0000627 

0:>00628 

0000629 

0000630 

0000631 

0000632 

0000633 

0000634 

0000635 

0000636 

0000637 

0000638 

0000639 

0000640 
GRASP SOFTWARE SPECIFICATIONS 37 

SUBROUTINE NAME: FDRIVE 

Purpose: FDRIVE provides for the single-pass computation 

of all implemented mathematical or statistical functions. Using this routine to make all calls to the subroutines corresponding to implemented functions simp>lifies the addition 

of new functions. 

eating phase 1, 2, or 3. The phases are initialization, body, 

and postprocessing. 

Subroutines called: MEAN, FIT 

Common data referenced: None 

Called by: FTNC 

Calling Error checking and reporting: None sequence: CALL FDRIVE (ISWTCH) 

Arguments: 

ISWTCH-Integer code passed to called subroutines indiProgram logic: This routine merely makes calls to the functions JSe•lected by the user via computed GOTO. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBROUTINE FDRIVE(ISWTCH) 

COMMON /FTNCOM/ TAGS,IREC,ARGS,NARGS,IFTN,NFTN 

DOUBLE PRECISION TAGS(5,5) 

INTEGER ARGS(6,5),NARGS(5),IFTN(5),1REC(500t 

DO 30 J= 1 ,NFTN 

I= I FTN( J » 

GO TO (10,20,30,30,30,30), I 

10 CALL MEAN(J,ISWTCH) 

GO TO 30 

20 CALL FIT(J,ISWTCH) 

30 CONTINUE 

RETURN 

END 

0000641 

0000642 

0000643 

0000644 

0000645 

0000646 

0000647 

0000648 

0000649 

0000650 

0000651 

0000652 

0000653 
38 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: FILES 

Purpose: FILES prompts for and accepts a data-base name. 

After the name has been provided and verified, the Mask 

file of data-base characteristics associated with that name is 

read. Some preliminary processing is done on these characteristics. 

Calling sequence: CALL FILES(&n) 

Argument: 

n-Statement (in caller) to which a branch is made if the 

nonstandard return from KEYBRD is taken (namely, an 

EOF is sensed). 

Subroutines called: KEYBRD, !FILE, BINIT, DEFINE, 

PACK 

Common data referenced: 

NAMES, !TYPE, IPTS, IDIM in blank common. 

MASTER, MASK, DFILE, BFILE, NUMF, NUMI, !DIMS 

in /FILNAM/. 

I, IDPT in /DACOMM/. 

Called by: DRIVER 

G R A S P S 0 U R C E 

SUAROUTINE FILES(*) 

COMMON NAMES,ITYPE,IPTS,IDIM 

Error checking and reporting: The data-base name entered by 

the user is compared wdth the list (MASTER) of those 

available. If the data-base name is not recognized, an error 

message is typed. 

Program Logic: 

1. A data-base name is prompted for and accepted via KEYBRD, and is then packed into FILEID and compared with 

the list (MASTER) of available names. If not found, an 

error message and the list of available names is typed followed by a prompt for another name. 

2. Once the data base has been established, its corresponding 

Mask file is read to fill the blank common area. 

3. The item names from MASK are sorted via a call to 

BINIT and the array of pointers ( IPTS) to the sorted 

NAMES is returned from BINIT. 

4. NAMES is restored to its unsorted form and DEFINE 

is called to associate the name of the direct-access character 

dictionary with unit 21. !FILE is then called to associate 

the name of the multiple-choice file with unit 22. 

P R 0 G R A M 

COMMON /FILNAM/ MASTER,MASK,OEFTN,OFILE,BFILE,NUMF,NUMI,IDIMS 

COMMON /DACOMM/ I,IOPT 

0000654 

0000655 

0000656 

0000657 

0000658 

0000659 

0000660 

0000661 

0000662 

0000663 

0000664 

0000665 

0000666 

0000667 

0000668 

0000669 

0000670 

0000671 

0000672 

0000673 

0000674 

0000675 

00(,0676 

0000677 

0000678 

0000679 

0000680 

0000681 

0000682 

0000683 

0000684 

0000685 

0000686 

0000687 

0000688 

DIMENSION ITYPE(500t, IPTS(500), IOPT(5COt, IDIMS(4) 

DOUBLE PRECISION NAMES(500),VNAMES(500) 

INTEGER MASTER(4),MASK(4),0EFTN(4),0fllE(4),BfllE(4J,FILEID 

DATA 120,121,122/20,21,22/ 

1 TYPE 11 

CALL KEYBR0(&999,ITYPE,5) 

CALL PACK(ITYPE,FILEID,5,5) 

DO 3 J= 1 , NU Mf 

IF(MASTER(J).EQ.FILEIDI GO TO 5 

3 CONTINUE 

TYPE 4,FILEID,CMASTER(I),I=l,NUMF) 

GO TO 1 

5 NUMI=J 

CALL IFILE(l20,MASK(NUMI)) 

I 0 I M= I D I M S ( N UM I ) 

READ ( I 20 ) ( IT YP E ( I ) , I= 1, I 0 1M ) , ( I D P T (I ) , I= 1, I D 1M I , 

1 CNAMES(I),I=1,IDIM) 

REWIND I 20 

DO 10 1=1,IDIM 

10 VNAMES(l)=NAMES(I) 

CALL RINIT(NAMES,IPTS,IDIM) 

DO 20 I=1,IDIM 

20 NAMES(l)=VNAMES(I) 

CALL DEFINECI21,27,I,OFILE(NUMI),"412,"176) 

CALL IFILECI22,BFILECNUMI)J 

RETURN 

999 RETURN 1 

4 FORMAT(lX,A6, 1 NOT AN AVAILABLE DATA BASE NAME. •, 

1 'USE ONE Of THE FOLLOWING: 1 /(1X,A5)) 

11 FORMAT(' ENTER DATA BASE NAME: 1 9 $) 

END 
GRASP SOFTWARE SPECIFICATIONS 39 

SUBROUTINE NAME: FIND 

Purpose: FIND is used to look up a word in a "hash coded" 

table and return a code associated with its position. The 

"Linear quotient" technique, as described by Bell and Kaman 

( 1970) , is used. 

Calling sequence: CALL FIND (&n,ISYMBL,KODE,CHARS, 

CODES,M) 

Arguments: 

n-Statement (in caller) to which a branch is taken if 

ISYMBL is not in CHARS. 

ISYMBL-Word to be looked up. 

KODE-Integer from the position in CODES corresponding 

to the position of ISYMBL in CHARS. 

CHARS-"Hash coded" table of words to be looked up. 

G R A S P S 0 U R C E 

CODES-Table corresponding to CHARS giving the original 

position of the word to be looked up. 

M-Tabl'e size (a prime number) for CHARS and CODES. 

Subroutines called: None 

Common data referenced: None 

Called by: LOG EXP, PARSE 

Error checking and reporting: If ISYMBL is not in CHARS, 

the nonstandard return is taken. 

Program logic: An initial location I and displacement J is 

determined from the internal machine representation of the 

word stored in ISYMBL. Initial and successive probes to 

CHARS are made until an empty location is probed. If 

ISYMBL is not in CHARS, the nonstandard return is taken. 

If ISYMBL is found in CHARS, the corresponding element 

of CODES is returned in KODE. 

P R 0 G R A M 

SUBROUTINE FIND(*,ISYMBL,KOOE,CHARS,CODES,M) 

INTEGER CHARSClJ,COOES(l),FILLER 

0000689 

0000690 

0000691 

0000692 

0000693 

0000694 

0000695 

0000696 

0000697 

0000698 

0000699 

0000700 

0000701 

0000702 

0000703 

DATA FILLER/ 1 VOI0 1 / 

L=IABS( ISVMBL) 

J=l/M 

I=L-M*J 

IF (MOO(J,M).EQ.O) J=l 

5C ICHAR=CHARS(I+l) 

If (ICHAR.EQ.ISYMBL) GO TO 60 

IF (ICHAR.EQ.FILLERJ RETURN 1 

I =MOO ( I+ J, M) 

GO TO 50 

60 KODE=CODESII+l) 

RETURN 

END 
40 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: FINDGP 

Purpose: FINDGP positions the file associated with FORTRAN 

unit 20 to a particular record paid associated with a category. 

Data concerning that category are returned to the caller. 

Calling sequence: CALL FINDGP (&n,KNUM,NUM,MAXL, 

NG,GROUP) 

Arguments: 

n-Statement number (in caller) to which control is passed 

if an EOF is sensed on unit 20. 

KNUM-The category number to which the file will be 

be positioned. 

NUM-The number of descriptions in this category. 

MAXL-The maximum length (in words) for a description. 

NG-Number of items referred to in this category. 

GROUP-List of item pointers associated with this category. 

Subroutines called: !FILE 

Common data referenced: FNAMES, WHICH in/FILNAM/ 

Called by: NAME, DUMPIT 

Error checking and reporting: None 

Program logic: 

1. The next record on unit 20 is read, giving a category 

number KK and values for the last four arguments. 

2,. KK is tested against KNUM. 

(a) If KK<KNUM, record pairs are .skipped up to the 

one of interest. 

(b) If KK=KNUM, return. 

(c) If KK>KNUM, rewind unit 20 and reassociate it with 

the correct name via a call to !FILE having 

FNAMES and WHICH as arguments. Next, reposition the file to the number pair of interest. 

G R A S P S 0 U R C E PROGRAM 

SUBROUTINE FINOGP( *,KNUfJI,NUM,MAXL,NG,GROUP) 

COMMON /FILNAM/ FNAMES,WHICH,PAD 

INTEGER GROUP(l),FNAMESC2lt,WHICH,PA0(4) 

DATA NOEF/20/ 

30 READ (N0Ef,EN0=90) KK,NUM,MAXL,NG,(GROUP(I),J=l,NGI 

If (KK-KNUM) 40,80,70 

40 J=KNUM-KK-1 

50 REAO(NDEf) 

IF (J.LT.l) GO TO 30 

DO 60 I= l,J 

READ(NOEF) 

60 REAO(NDEFt 

GO TO 30 

70 REWIND NDEF 

CALL IFILECNOEF,FNAMES(8+WHICH)) 

J=KNUM 

GO TO 50 

80 RETURN 

90 RETURN 1 

END 

0000704 

0000705 

0000706 

0000707 

0000708 

0000709 

0000710 

0:> 00711 

0000712 

0000713 

0000714 

0000715 

000071& 

0000717 

0000718 

0000719 

0000720 

0000721 

0000722 

0000723 
GRASP SOFTWARE SPECIFICATIONS 41 

SUBROUTINE NAME: FIT 

Purpose: FIT is used to provide a least-square linear fit between two items within a selected file. 

Calling sequence: CALL FIT(J,ISWTCH) 

Arguments: 

J-Pointer used to retrieve argument values from the common area /FTNCOM/. 

ISWTCH-Switch indicating which of three parts (initialization, body, postprocessing) of the code is to be executed. 

Subroutines called: UN CODE 

Common data referenced: 

!TYPE in blank common 

TAGS, IREC, ARGS, NARGS, in /FTNCOM/ 

Called by: FDRIVE 

Error checking and reporting: If two arguments are not given, 

an appropriate error message is typed and return is immediate. If the computation would yield an infinite slope, that 

message is typed. 

Prograrm logic: The value of ISWTCH determines which of 

three sections of the code is executed. If ISWTCH=l, the 

number of arguments is checked, and various sums are set 

to zero. If ISWTCH=2, the error flag is tested. If not set, 

the appropriate values of the arguments are tested for nonblank. If nonblank, they are added to the appropriate sums. 

If ISWTCH = 3·, the slope, intercept, and correlation coefficient are calculated (if possible), using the sums previously 

determined. They are then printed out using the appropriate 

item names. All summations and least-square determinations 

are done using double-precision arithmetic to minimize the 

round-off effects introduced by performing the computation 

using only one pass on the data. 

Assuming the function FIT X,Y had been issued, the calculations are performed using the following formula: 

D=N ·l:X2 -l:X ·l:X 

B1= (N·l:XY-~X·~Y) !D 

Bo= ( l:Y -B1·l:X) IN 

C=D·Bdv D· (N·l:Y -~Y·l:Y) 

where: 

Bo=intercept, 

B1=slope, 

C =correlation coefficient, and 

N =number of non blank X, Y points. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBROUTINE FIT(J,ISWTCH) 

COMMON NAMES,ITYPE,IPTS,IPAD 

COMMON /FTNCOM/ TAGS,IREC,ARGS,NARGS,IFTN,NFTN 

DOUBLE PRECISION NAMES(500),TAGS(5,5J,SUMX,SUMY,SUMXY, 

1 SUMXS,SUMYS,D,FN,Vl,V2 

INTEGER IPTS(500) 

INTEGER ARGS(6,5),NARGS(5 ), IFTN(5) ,ITYPE( 500), IREC(500) 

LOGICAL ERR 

E QU IV AL EN C E ( IV All , VAL 1 ) , ( I VA l2, VA l2 I 

DATA IBLNK/' 1 / 

I F ( I S W TC H- 2 ) 2 , 4 , (> 

2 ERR=NARGSCJ).NE.2 

IF (ERR) GO TO 20 

N=O 

SUMX=O.OOO 

SUMY=O. 000 

SUMXY=O. ODO 

SUMXS=O .000 

SUMVS=O. 000 

GO TO 30 

4 IF (ERR) GO TO 30 

IVAll=IREC(ARGS(2,Jt) 

IF ( IVALl.EQ.IBLNK) GO TO 30 

IVAL2=1REC(ARGSC3,J)) 

IF (IVAL2.EQ.IBLNK) GO TO 30 

Vl=IVAll 

V2=1VAl2 

IF (ITYPE(ARGSC2,J)).EQ.2) Vl=VAll 

IF (ITYPE(ARGS(3,Jt).E0.2) V2=VAL2 

lF(ITYPElARGS(2,J)).EQ.5) Vl=UNCODE(VALl,IQ) 

If( ITYPE(ARGS(3,J) ).EQ.5) V2=UNCODE(VAL2,IQ) 

N=N+l 

SUM X= SUM X+V 1 

0000724 

0000725 

0000726 

0000727 

0000728 

0000729 

0000730 

0000731 

0000732 

0000733 

0000734 

0000735 

0000736 

0000737 

0000738 

0000739 

0000740 

0000741 

0000742 

0000743 

0000744 

0000745 

0000746 

0000747 

0000748 

0000749 

0000750 

0000751 

0000752 

0000753 

0000754 

0000755 

0000756 
42 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUMXS=SUMXS+Vl*Vl 0000757 

SUMXY=SUMXY+Vl*V2 0000758 

SUMY=SUMY+V2 0000759 

SUMYS=SUMYS+V2*V2 0000760 

GO TO 30 0000761 

6 IF (ERR) GO TO 30 0000762 

FN=N 0000763 

D=FN*SUMXS-SUMX*SUMX 0000764 

If (D.EQ.O.OOO) GO TO 10 0000765 

Bl=(FN*SUMXY-SUMX*SUMY)/0 0000766 

BO=(SUMY-Bl*SUMX)/FN 0000767 

CC=(FN*SUMXY-SUMX*SUMY)/DSQRT((FN*SUMXS-SUMX*SUMX)*(fN*SUMYS-SUMY*0000768 

lSUMY)) 0000769 

TYPE 40, N,TAGS(l,Jt,TAGS(2,Jt,Bl,BO,CC 0000770 

GO TO 30 0000771 

10 TYPE 50, N 0000772 

GO TO 30 0000773 

20 TYPE 60 0000774 

30 RETURN 0000775 

40 FORMAT (/1X,I5,' POINTS USED TO FIT •,A8, 1 TO •,AS/' SLOPE=' ,1PE12.0000776 

15,' INTERCEPT=',il2.5,• CORR. COEFF.=',El2.5) 0000777 

50 FORMAT (' UNABLE TO CALCULATE FIT WITH',I5,' POINTS') 0000778 

60 fORMAT ('THE fiT FUNCTION MUST HAVE 2 ARGUMENTS') 0000779 

END 0000780 
G~SP SOFTWARE SPECIFICATIONS 

SUBROUTINE NAME: FTNC 

Purpose: This routine acts as a driver for the processing of 

the FUNCTION command. It accepts (via KEYBRD) the 

function names and arguments, sets up system-required 

input-file information, and is then used to supply input 

records to the routines that actually calculate the requested 

functions. 

Calling sequence: CALL FTNC(&n) 

Argument: 

n-Statement (in caller) to which a branch is made if the 

nonstandard return (EOF) from KEYBRD is taken. 

Subroutines called: KEYBRD, OBEY, DECOMP, FDRIVE, 

GETPUT, PACK 

Common data referenced: 

FNAMES, WHICH in /FILNAM/ 

TAGS, IREC, ARGS, N ARGS, IFTN, NFTN in /FTNCOM/ 

NFILE in /IOUNIT I 

Called by: DRIVER 

Error checking and reporting: Function names entered by 

G R A S P SOURCE 

SUBROUTINE FTNC(*) 

COMMON /FILNAM/ fNAMES,WHICH,PAO 

the user are checked against a list of those available. If an 

invalid function name is entered, that message is typed. 

Program logic: 

1. A prompted input-file name is obtained via KEYBRD, 

packed via a call to PACK, and associated with the FORTRAN input unit number via OBEY. 

2. A list of the implemented function names is typed along 

with a request to enter the names of desired functions and 

their corresponding arguments. 

3. As each function name is entered (via KEYBRD), it and 

its argument names are identified via DECOMP. 

4. After the names have been entered and identified, a call to 

FDRIVE using an argument of 1 is issued to perfonn 

initialization. 

5. Each record of the selected file is obtained via GETPUT 

and processed via a call to FDRIVE using an argument of 2. 

6. Finally, a call to FDRIVE using an argument of 3 is made 

to accomplish any wrap-up processing associated with the 

selected function, and the input file is rewound. 

PROGRAM 

COMMON /FTNCOM/ TAGS,IREC,ARGS,NARGS,IFTN,NFTN 

COMMON /IOUNIT/ NFILE,IPAO 

0000781 

OOG0782 

OOCOl83 

0000784 

0000785 

0000786 

0000787 

0000788 

0000789 

0000790 

0000791 

0000792 

0000793 

0000794 

0000795 

0:>00796 

0000797 

0000798 

0000799 

0000800 

0000801 

0000802 

0000803 

0000804 

0000805 

0000806 

0000807 

0000808 

0000809 

0000810 

0000811 

0000812 

0000813 

OOC0814 

0000815 

0000816 

DOUBLE PRECISION TAG$(5,5) 

INTEGER DFAULT,FILE,OBLNK,FNAMES(21),WHICH,PA0(4),IFTN(51, 

1EQUATE(4),FTNS(5),ARGS(6,51,IMAGE(80),NARGS(5),1REC(5001, 

2 PROMPT ( 5) 

LOGICAL ANY,GOOO 

DATA DBLNK,EQUATE/ 1 •,•EQUA','TE 1 1 , 1 1 1 , 1 1 / 

DATA IMPLTO,FTNS/2, 1 MEAN 1 , 1 FIT 1 ,3*' 1 / 

DATA PROMPT/ 1 1. 1 , 1 2. 1 , 1 3. 1 , 1 4. 1 , 1 5. 1 / 

E QU IV AL EN CE ( EQ UA T E ( 4 ) , F ILE ) 

TYPE 100 

OFAUL T=FNAMES( WHICH) 

CALL KEYBR0(&90,IMAGE,5) 

CALL PACK(IMAGE,FILE,5,5) 

If (FILE.EQ.OBLNK) FILE=DFAULT 

CALL OBEYI&85,EQUATE,4) 

TYPE 120, (FTNS(I),I=l 1 1MPLTO) 

TYPE 130 

10 NFTN= 1 

20 TYPE 150, PROMPT(NFTNt 

CALL KEYBR0(&90,IMAGE,80) 

CALL DECOMP(&20,&30,1MAGE,TAGSC1,NFTN),ARGS(1,NFTNI,NARGI 

NARGS(NFTN)=NARG-1 

NfTN=NfTN+l 

IF INFTN-IMPLTD-lt 2G,30,30 

30 NFTN=NFTN-1 

IF (NFTN.EQ.O) RETURN 

ANY=. FALSE. 

DO 60 I=l,NFTN 

GOOD=. TRUE. 

INAME=ARGS(1,1t 

DO 40 J=l,IMPLTD 

IF (I~AME.EQ.FTNSCJ)) GO TO 50 
44 

85 

GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

40 CONTINUE 0000817 

0000818 

0000819 

0000820 

0000821 

0000822 

0000823 

0000824 

0000825 

0000826 

0000827 

0000828 

0000829 

0000830 

0000831 

0000832 

50 

60 

70 

80 

90 

100 

120 

130 

150 

160 

TYPE 160, I NAME 

J=6 

GOOD= .FAlSE • 

I FTN ( I) =J 

A NY=A NY. OR. GOOD 

IF (.NOT.ANY) GO TO 10 

CALL fORIVE(l) 

CALL GETPUT(&80,IREC,1) 

CALL FOR I VE ( 2 t 

GO TO 70 

CALL FORI VE I 3) 

REWIND NFILE 

RETURN 

RETURN 1 

FORMAT(' ENTER NAME OF FILE: •,$) 

FORMAT (' FUNCTIONS AVAILABLE AT THIS TIME ARE:'/1X,5A8t 

FORMAT (' fNTER FUNCTION NAMES AND CORRESPONDING ARGUMENTS. 1 ) 

FORMAT (lX,A3,$) 

0000833 

0000834 

0000835 

FORMAT (1X,A5,' IS NOT AN AVAILABLE FUNCTION AND HAS •, 'BEEN 

lED.') 

END 

IGNOR0000836 

0000837 

0000838 
GRASP SOFTWARE SPECIFICATIONS 45 

SUBROUTINE NAME: GETPUT 

Purpose.: GETPUT is used to read and unpack a record from 

the current input file, or to write the last-packed record 

obtained from the current input file on the current output 

file. 

Calling sequence: CALL GETPUT(&n,IREC,ISWTCH) 

Arguments: 

n-Statement (in caller) to which a branch is made if an 

EOF is sensed on the current input file. 

IREC-Contains the expanded record from the current input 

file. 

ISWTCH-Switch indieating whether record is to be read 

or written. 

Subroutines called: None 

Common data referenced: IN, IOUT in /IOUNIT/ 

Called by: COLPNT, DUMPIT, FTNC, RETRVE, ROWPNT 

Error checking and reporting: None 

Program logic: 

1. If ISWTCH=l, the next input record is read into TANK 

G R A S P S 0 U R C E 

SUBROUTINE GETPUT(*,IREC,ISWTCH) 

COMMON /IOUNIT/ IN,IOUT 

on the unit referenced by IN in /IOUNIT I. If an EOF is 

sensed, the nonstandard return is taken. If ISWTCH>l, 

the last-read input record is output on the unit referenced 

by IOUT in /IOUNIT I. 

2. The first word of TANK is assumed to be of type 

INTEGER and corresponds to the first word of IREC. The 

last 2 bits contain the type of the next word in TANK. 

TYPE values are: 

TYPE 

1 

2 

3 

Indicates 

Next word is an integer value. 

Next word is a real value. 

Next word is a blank counter. 

The value part of types 1 and 3 is in the leading bits (that 

is, 2-bit truncation). 

3. If the word is of type REAL, it may be visualized as being 

composed of an integer and a fraction. The type for the 

next word is in the last 2 bits of the integer part and the 

associated real value is obtained by adding the fractional 

part to the leading bits of the integer part. 

P R 0 G R A M 

INTEGER IRECI 1 t, ITANK( 150),8LANK,TYPE 

REAL TANK(l50) 

0000839 

0000840 

0000841 

0000842 

0000843 

0000844 

0000845 

000084b 

0000847 

0000848 

0000849 

0000850 

0000851 

0000852 

0000853 

0000854 

0000855 

0000856 

0000857 

0000858 

0000859 

OOC0860 

0000861 

0000862 

0000863 

0000864 

0000865 

0000866 

0000867 

0000868 

0000869 

0000870 

0000871 

0000872 

0000873 

EQUIVALENCE CFRACT,IVAL), (ITANK(li,TANK(l)) 

OAT A BLANK/' 1 / 

IF(ISWTCH-21 5,70,70 

5 READ (IN,END=llO) NUM,(TANK(ll,l=l,NUM) 

TYPE=l 

I PT= 1 

DO 50 I = 1, N UM 

lf(TYPE.LT.O) TYPE=-TYPE 

IF ( TYPE- 2) 10, 20, 3 0 

10 IVAL=ITANK(l,/4 

TYPE=ITANK(I)-4*IVAL 

GO TO 25 

20 TYPE=TANK( I) 

FRACT=TANKIIt-TYPE 

J=TYPE/4 

TYPE=TYPE-4*J 

FRACT=J+FRACT 

25 IREC(IPT)=IVAL 

I PT=I PT+l 

GO TO 50 

3 0 J = I T A NK ( I ) I 4 

TYPE=ITANK( 1)-4*J 

DO 40 K= 1 ,J 

IR EC( IPT, =BLANK 

4 0 I P T·= I P T + 1 

50 CONTINUE 

60 RETURN 

10 WRITE(IOUT)NUM,(TANK(I),l=l,NUM) 

GO TO 60 

110 RETURN 1 

END 
46 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: HELP 

Purpose: HELP types the names and descriptions of GRASP 

commands available to the user. 

Subroutines called: None 

Common data referenced: None 

Called by: DRIVER 

Error checking and reporting: None 

Calling sequence: CALL HELP(WORDS) 

Argument: 

WORDS-An array containing the command names that 

may be issued by the user. 

G R A S P S 0 U R C E 

Program logic: The text associated with each of the commands 

is initialized in DATA statements. Each command name (in 

WORDS) is typed with its corresponding description in 

TEXT. 

P R 0 G R A M 

SUBROUTINE HELP{WOROS) 0000874 

INTEGER WOROS(l) 0000875 

DOUBLE PRECISION TEXT(ll,ll),MSGl(ll),MSG2(ll),~SG3(llt, 0000876 

1 MSG4(ll),MSG5(11J,MSG6(ll),MSG7(ll),MSG8(11J,MSG9(llt, 0000877 

2 MSGlO(llt,MSGll(llt 0000878 

EQUIVALENCE (MSG1(l),TEXT(l,1)),{MSG2(1),TEXT(l,2)), 0000879 

1 ( MS G 3 ( 1 ) , TEXT ( 1 , 3 ) ) , ( M S G4 ( 1 J, TEXT ( 1, 4) ) , ( M SG 5 ( 1 ) , TEXT I 1, 5) ) , 00008 80 

2 (MSG6(l),TEXT(1,6)),(MSG7(1) 9 TEXT(1,7)),(MSG8(l),TEXTI1,8)J, 0000881 

3 CMSG9( l),TEXT( 1,9) ),(MSGlO( lJ,TEXT( 19 10) I ,(MSGll(l) ,TEXT(l,llt) 0000882 

DATA MSGl/ 1 - INITIA 1 , 1 TES THE 1 , 1 REQUEST 1 , 1 FOR RETR 1 , 1 IEVAL CR', 0000883 

l'ITERIA T1 , 1 0 BE ENT 1 , 1 ERED IN 1 , 1 THE FORM•,•: NAME R1 , 1 EL VALUE'/ 0000884 

DATA MSG2/ 1 - INITIA','TES THE 1 , 1 REQUEST 1 , 1 FOR A L0 1 , 1 GICAL EX', 0000885 

l'PRESSION',' TO BE E','NTERE0 1 , 1 USING LO','GICAL OP','ERATORS.'/ 0000886 

DATA MSG3/ 1 - I~ITIA TES THE 1 , 1 SEARCH 0 1 , 1 F A fiLE',' BASED u•, 0000887 

l'PON PREV','IOUSLY E1 , 1 NTERE0 1 , 1 CONDITI0 1 ,'NS AND L','OGIC. 'I 0000888 

DATA MSG4/'- ALLOWS•,• THE USE','R TO LIS 1 , 1 T SELECT 1 , 1 EO VALUE', 0000889 

l'S CVARIA 1 , 1 BLE NAME','S WILL 1 , 1 BE ASKED',' FOR) IN',' A FILE.'/ 0000890 

DATA MSGS/ 1 - ALLOWS•,• THE USE 1 , 1 R TO SEL 1 , 1 ECT OR C1 , 1 HANGE TH', 0000891 

l 'E DATA B','ASE TO B1 , 1 E USED. 1 ,3*' 1 / 0000892 

DATA MSG6/ 1 - TERMIN 1 , 1 ATES THE•,• SYSTE~.•,• ENTERIN','G IN R', 0000893 

11 ESPONSE 1 , 1 TO A PR0 1 , 1 MPT WILL 1 , 1 ALSO ST0 1 , 1 P THE SY 1 , 1 STEM. 1 / 0000894 

DATA MSG7/ 1 - USED r•,•o PRINT 1 , 1 ITEM NA~ ES, THEI 1 , 1 R TYPES', 0000895 

l'AND DEfi','NITIONS 1 , 1 IN A 1 , 1 SELECTE0 1 , 1 SET OF 1 , 1GROUPS. 1 / 0000896 

DATA MSG8/ 1 - USED T1 ,•o OBTAIN•,• THE AB0 1 , 1 VE COMMA 1 , 1 ND DEFIN 1 , 0000897 

l'ITIONS.',5*' 1 / 0000898 

DATA MSG9/ 1 - LISTS 1 , 1 THE FlLE 1 , 1 S WHICH 1 , 1 HAVE BEE','N USED A', 0000899 

l'S WELL A','S THE C0 1 , 1 NDITIONS 1 , 1 ANO LOGI't'C ENTERE•,•o. 1 / 0000900 

DATA MSGl0/ 1 - PRINTS•,• ALL ITE 1 , 1 MS PRESE 1 , 1 NT FOR E1 , 1 ACH REC0 1 ,0000901 

l'RD IN A•,•SELECTEO•,• FILE.','WAITS AF 1 , 1 TER EACH•,• N LINES'/ 0000902 

DATA MSGll/'- PROVID', 1 ES FOR T1 , 1 HE COMPU1 , 1 TATION O','F FUNCTI 1 ,0000903 

l'ONS ON I','TE~S IN','A DATA 1 , 1 SET COR','FILEJ.•,• 1 / 0000904 

TYPE 10, (WORDS(J),(TEXT(l,J),I=l,ll),J=l,ll) 0000905 

RETURN 0000906 

10 FOR~AT ('OTHE COMMANDS WHICH MAY BE ISSUED •,•(AND THEIR MEANING) 0000907 

lARE LISTED BELOW:'/(' 1 9 A4,8A8/7X,3A8)) 0000908 

END 0000909 
GRASP SOFTWARE SPECIFICATIONS 47 

FUNCTION NAME: ICONV 

Purpose: ICONV is used to convert a number from unpackedcharacter form to numeric fixed-point form. 

Calling sequence: IVAL=ICONV(TANK,LNGTH,EXP, 

ERR) 

Arguments: 

TANK-Contains the number to be converted in unpackedcharacter form. 

LNGTH-The number of elements in TANK. 

EXP-The power of 10 to which the value returned must 

be raised to obtain the floating point value represented. 

ERR-An error flag which is turned on if an error is detected. 

Subroutines called: None 

G R A S P S 0 U R C E 

Common data referenced: None 

Called by: OPREP, PARSE, RELEXP 

Error checking and reporting: Each character is checked. If 

an invalid character is detected, an error message is typed, 

and the error flag is turned on. 

Program logic: If all characters are blank, blank is returned 

as a value. Leading blanks and imbedded commas are 

ignored, and a blank acts as a string deliminator. If a 

decimal point is sensed, the position counter EXP is initialized to 1 and incremented for each subsequent digit. As 

each digit is detected in a left-to-right fashion, the value is 

shifted left one digit, and the detected digit is added to the 

least significant part of the value. If all (LNGTH) characters have been scanned or if a trailing blank is detected, 

the scan is terminated and control is returned to the caller. 

PROGRAM 

INTEGER FUNCTIONICONV(TANK,LNGTH,EXP,ERR) 0000910 

0000911 

0000912 

0000913 

0000914 

0000915 

0000916 

0000917 

0000918 

0000919 

0000920 

0000921 

0000922 

0000923 

0000924 

0000925 

0000926 

0000927 

0000928 

0000929 

0000930 

00009 3.1 

0000932 

0000933 

0000934 

0000935 

000093•6 

0000937 

0000938 

0000939 

0000940 

0000941 

0000942 

0000943 

0000944 

00009't5 

INTEGER TANK( 1 ),D IGITS(10) ,BLANK, COMMA, POINT ,EXP,VALUE 

LOGICAL ERR 

DATA BLANK,COMMA,POINT/4H ,4H, ,4H. /,DIGITS/4HO ,4H1 

14H2 ,4H3 ,4H4 ,4H5 ,4H6 ,4H7 ,4H8 ,4H9 I 

ERR=. FALSE. 

EXP=O 

IF (LNGTH.GT.O) GO TO 10 

ICONV=BLANK 

GO TO 90 

10 VALUE=O 

DO 20 K=1 ,L NGTH 

IF (TANK(K).NE.BLANK) GO TO 30 

20 CONTINUE 

GO TO 80 

30 DO 70 J=K,LNGTH 

NEXT=TANK(J) 

IF (NEXT.EQ.COMMA) GO TO 70 

IF (~EXT. EQ .BLANK) GO TO 80 

IF (NEXT.NE.POINT) GO TO 40 

E XP= 1 

GO TO 70 

40 IF {EXP.GT.O) EXP=EXP+1 

DO 50 l= 1, 10 

IF (NEXT.EO.DIGITS(l)) GO TO 60 

50 CONTINUE 

TYPE 100, VALUE,EXP,(TANK(L),L:::l,LNGTH) 

ERR=. TRUE. 

GO TO 90 

60 VALUE=lO*VALUE+L-1 

70 CONTINUE 

80 EXP=MIN0(0,1-EXP) 

I CONV= VALUE 

90 RETURN 

100 FORMAT (l5H BAD CHARACTER ,lll,I5,3X,64A1) 

END 
48 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: IFILE 

Purpose: This subroutine is used to associate dynamically 

the name of an existing data set with a FORTRAN 

input unit number (that is, logical device number). When 

this subroutine is called, the file is opened and read; statements referencing the unit number given in the argument 

list are directed to the named file. The file may be closed 

by use of a rewind statement. 

Calling sequence: CALL !FILE (I,NAME) 

Arguments: 

I-An integer variable or constant specifying a logical device number. 

NAME-Either a literal (hollerith) constant or a variable 

containing a file name consisting of five or fewer characters. 

Subroutines called: None 

Common data referenced: None 

Called by: BINTYP, DEFLST, FINDGP, OBEY, START, 

FILES 

Error checking and reporting: None 

Program logic: This is a DEC 1070, TOPS-10 system resident routine. It provides the capab.i\lities referred to in the 

Purpose section above. If the GRASP system is to be implemented on some other main frame, a comparable routine 

must be written or acquired. No listing is shown here.. 
GRASP SOFTWARE SPECIFICATIONS 49 

SUBROUTINE NAME: INIT 

Purpose: !NIT initializes a set of words and codes for future 

table lookup. The initialization assumes that the "linear 

quotient hash code" technique willl be used for table lookup. 

See Bell and Kaman ( 1970) for a complete description of 

the technique. 

Calling sequence: CALL INIT(CHARS,CODES,M,SYMBOL, 

N) 

Arguments: 

CHARS-Table which is to contain the symbols in "hashcoded" order. 

CODES-Table giving the index of the symbol as it was 

stored in CHARS. 

M-Table size for CHARS and CODES. Note this must 

be a prime number. 

G R A S P S 0 U R C E 

SYMBOL-Table of words to "hash" into CHARS. 

N-Number of words in SYMBOL. 

Subroutines called: None 

Common data referenced: None 

Called by: LOGEXP, PARSE 

Error checking and reporting: None 

Program logic: 

1. CHARS is filled with "VOID," the flag for an empty location. 

2. Each element of SYMBOL is then inserted into CHARS 

at the "hashed" address. "Collisions" are handled via the 

Linear-quotient method. 

3. As each element of SYMBOL is "hashed" into CHARS, its 

position is stored in CODES. 

4. The initial probe ·address and collision dispiacement are determined from the contents of each element of SYMBOL. 

P R 0 G R A M 

SUBROUTINE INIT(CHARS,CODES,M,SYMBOL,N) 

INTEGER FILLER,CHARS(l),COOEStlJ,SYMBOL(l) 

DATA FILLER/ 1 VOID'/ 

0000946 

0000947 

0000948 

0000949 

0000950 

0000951 

0000952 

0000953 

0000954 

0000955 

0000956 

0000957 

0000958 

0000959 

0000960 

0000961 

0000962 

0000963 

DO 10 I=l,M 

10 CHARS(l)=flLLER 

00 40 I CODE =1 ,N 

ICHAR=SYMBOL(ICOOE) 

L= I ABS (I CHAR) 

J=l/M 

I=l-M*J 

IF (MOO(J,M).EQ.O) J=l 

20 IF (CHARS(I+l).EQ.FILLERJ GO TO 30 

I=MOD(I+J,M) 

GO TO 20 

30 CHARS(I+l)=ICHAR 

40 COOES(l+l,=ICODE 

RETURN 

END 
50 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: KEYBRD 

Purpose: KEYBRD accepts all user input in unpacked character form and returns it to the caller. 

Calling sequence: CALL KEYBRD(&m,IMAGE,N) 

Arguments: 

m-Statement number (in caller) to which a branch is 

made if an EOF is found. 

IMAGE-Contains the user input in unpacked character 

form. 

G R A S P S 0 U R C E 

SUBROUTINE KEYBRD(*,IMAGE,N) 

DATA I XI' ' I 

DIMENSION I~AGE(l) 

REA0(5,20,END=lC) (1MAGE([),I=1,N) 

IF( IMAGE( 1) .EQ.IX) GO TO 10 

RETURN 

10 RETURN 1 

20 FORMAT( BOA l) 

END 

N-Number of characters to be read. 

Subroutines called: None 

Common data referenced: None 

Called by: BDEF, COLPNT, CONDTN, DEFLST, FTNC, 

LIST, LOGEXP, OPREP, QUIT, RETRVE, VLIST, 

FILES, DRIVER, OBEY, PAUSE 

Error checking and reporting: None 

Program logic: KEYBRD accepts input from the user (unit 5,) 

and takes nonstandard return if EOF occurs. 

P R 0 G R A M 

0000964 

0000965 

0000966 

0000967 

0000968 

0000969 

0000970 

0000971 

0000972 
GRASP SOFTWARE SPECIFICATIONS 51 

SUBROUTINE NAME: LENGTH 

Purpose: LENGTH determines the number of leading nonblank words in a character stl'ling. 

Calling sequence: CALL LENGTH (VECT,N,L) 

Arguments: 

VECT-Array containing the character string to be examined. 

10 

20 

G R A S P S 0 U R C E 

SUBROUTINE LENGTHCVECT,N,L) 

INTEGER VECTC 1) 

DATA IBLNK/' 'I 

L=O 

DO 10 l=l,N 

lF(VECT(II.EQ.IBLNK) GO TO 20 

l=l+1 

RETURN 

END 

N-The number of words to check. 

L-The number of nonblank leading words. 

Subroutines called: None 

Common data referenced: None 

Called by: DEFLST, DUMPIT, NAME 

Error checking and reporting: None 

Program logic: The first full-word blank is searched for; its 

position is returned in L. 

P R 0 G R A M 

0000973 

0000974 

0000975 

0000976 

0000977 

0000978 

0000979 

0000980 

0000981 
52 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: LIST 

Purpose: LIST is used as a driver for the listing of items 

from a selected file. LIST performs initialization common 

to both row and column forms of p.rintout, and rewinds the 

input file after returning from the routine which created 

the printout. 

Calling sequence: CALL LIST (&n) 

Argument: 

n-Statement (in caller) that is branched to if an EOF is 

sensed in any of the caHed routines. 

Subroutines called: OPREP, KEYBRD, ROWPNT, COLPNT 

Common data referenced: None 

G R A S P S 0 U R C E 

SUBROUTINE LIST(*) 

COMMON /IOUNIT/ NFILE,IOFILE 

DATA IC,IR/ 1C1 , 1 R1 / 

CALL OPREP(t50,&45,NPAGE) 

10 TYPE 60 

CALL KEYBR0(&50,IM,1) 

IF ( IM.EQ.ICt GO TO 30 

IF (IM.EQ.IR) GO TO 20 

TYPE 70 

GO TO 10 

20 TYPE 80 

CALL ROWPNT(&50,NPAGE) 

GO TO 40 

30 TYPE 80 

CALL COLPNT(&50,NPAGE) 

40 REWIND NFILE 

45 RETURN 

50 REWIND NFILE 

RETURN 1 

Called by: DRIVER 

Erro'i' checking and reporting: The user response returned by 

KEYBRD is checked for validity. If in error, a message is 

typed, and the user is prompted again. 

Program logic: 

1. The input file name and page size are set by a call to 

OPREP. 

2. The user is prompted for "C" (column) or "R'' (row) 

to establish the desired output form. 

3. Either ROWPNT or COLPNT is called depending on the 

user's response to step 2 above. 

4. The input file is rewound prior to the return to DRIVER. 

P R 0 G R A M 

60 FORMAT(' ENTER C FOR COLUMN ORR FOR ROW PRINTING: •,$1 

70 FORMAT (' YOUR REPLY WAS NOT UNOE~STOOO.•) 

0000982 

0000983 

0000984 

0000985 

0000986 

0000987 

0000988 

0000989 

0000990 

0000991 

0000992 

0000993 

0000994 

0000995 

0000996 

0000997 

0000998 

0000999 

0001000 

0001001 

0001002 

80 FORMAT I' AT EACH PAUSE PRESS CR KEY TO CONTINUE. •,•TO ABORT 

1R A •' ) 

END 

ENTE0001003 

0001004 

0001005 
GRASP SOFTWARE SPECIFICATIONS 53 

SUBROUTINE NAME: LOGEXP 

Purpose: This routine accepts a logical expression as user input via a call to KEYBRD and returns the encoded Reverse-Polish form of the expressions. The logical expression 

may be composed of single-letter (A-Z) operands which 

refer to previously entered conditions, the logical operators 

"and," "or," "not," and the grouping symbols (,). Each of 

the logical operators may be denoted in two ways, as follows: .AND. or*, .OR. or +,.NOT. or-. 

Calling sequence: CALL LOGEXP(&n,POLISH,LPS,NCOND) 

Arguments: 

n-Statement number (in calling routine) to which a branch 

will be made if an EOF is sensed by KEYBRD. 

POLISH-Contains the encoded Reverse-Polish form of a 

logical expression. Let n denote the value of some element of POLISH. Then 1~ n~26 implies reference to 

the nth condition entered. If 29~n~31, the logical opperators OR, AND, NOT correspond to these three values. 

No other values will be assumed by elements of POLISH. 

LPS-Gives the number of elements in POLISH. 

NCOND-Gives the number of conditions which have been 

entered by a previous call to CONDTN. 

Subroutines called: INIT, KEYBRD, SCAN, FIND, PACK 

Common data referenced: LOGIC in /INPUT I 

Called by: DRIVER 

Error checking and reporting: The logic expression entered is 

checked for syntactic correctness. Following are eight error 

messages which may be typed: 

1. LOGICAL OPERATOR NOT PRECEDED BY A ) OR 

A LETTER (A-Z). 

2. UNBALANCED PARENTHESIS. 

3. LETTER (A-Z) NOT SEPARATED BY AN OPERATOR. 

4. UNEXPECTED LEFT PARENTHESIS OR .NOT. OPERATOR (-). 

5. INVALID CHARACTER IN EXPRESSION. 

6. UNDETERMINED SYNTAX-ERROR. CONTACT PROGRAMMER. 

7. LOGIC EXPRESSION REFERENCES A CONDITfON 

(A-Z) WHICH WAS NOT ENTERED. 

8. OPERATOR NOT ENCLOSED WITH PERIODS. REENTER LOGIC. 

Program logic: 

1. On the first call to LOGEXP, a call to INIT is made to 

"hash-code" the elements of SYMBOL into CHARS. CODES 

is used to save the original indices. 

2. A prompt message is typed and a call to KEYBRD is 

made to get the input string which is then packed into 

LOGIC. 

3. After initialization of pointers and counters, a call is made 

to SCAN to bracket the nonblank section of STRING. 

4. At this point the actual algorithm begins. Transition matrix parsing is used . with the following transition matrix 

(!MAT): 

A-Z + • (- ) blank 1. f(l)/2 f(7)/1 f(4)/l f(7)/2 f(2)/l f(6.)/l 2. f(7)/3 f(3)/1 f(7)/4 f(5)/2 f(2)/2 f(6)/l 

where f (i) I j means "do the i'th job and set the next row 

value to j." The jobs are: 

f(l)-Insert character code into Reverse-Polish string and 

test to determine if there has been a condition entered 

for it. 

f(2)-Go scan next character. 

f(3)-Pop stack into POLISH until value of topmost element is less than character code. Then do f ( 4) . 

f(4)-Push down character code into stack. 

f (5)-Pop stack into POLISH until the value for ( is 

reached. Remove value for (. 

f ( 6)-Period character sensed, find next matching period 

and determine logical operator. 

f(7)-Type the error message pointed to by the row value, 

then request reentry of .Jogic. 

Each character of STRING is scanned using the subroutine 

FIND to obtain its code !CODE. !CODE is an index to 

ICOLS which then determines the proper column of IMAT. 

This element IFTN is then broken down into a function 

pointer JOB and a next row value STATE. Control is then 

passed to the function indicated by JOB. After the function has been completed, the next character of STRING is 

scanned if an error was not detected. If an error was detected, the appropriate message is typed. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBkOUTlNE LOGEXP(*,POLISH,LPS,NCONO) 

COMMON /INPUT/ EXPR,LOGIC 

DOUBLE PRECISION ERRMSG(7,61,EXPR(4,26),LOGIC(8) 

INTEGER POLISH(lt,ICOLS(33),CHARS(411,TOP,FC,STATE,OR,ANO,STACK(l 

15),IMAT(2,6I,CODES(41),SYMBGL(33),STRING(80),PERIOO,BLANK 

LOGICAL CALLED 

0001006 

0001007 

0001008 

0001009 

0001010 

0001011 

OAT A sv MBOL ,. A' '. B I '. c I' • 0. t IE I' IF I' I G I t 'H.' I 1 '' 'J.' • K. ' • L. ''HI t I NOOO 1012 

1 I ' 'o • ' 'P • '• Q' '• R • ' • s • '' T • '• u• '' v • ' • w I' • x • ' • v • ' • z• ' ' ' I ' • , '' I + • ' I *I 'o o o 10 13 

2 1 - 1 , 1 ., ••• , 0001014 

DATA ICOLS/26*1,3,4,2,2,3,5,6/, CALLED/.FALSE./ 0001015 

DATA IMAT/12,73,71,31,41,74,72,52,21,22,61,61/ 0001016 

DATA ERRMSG/ 1 LOGICAL 1 1 1 0PERATOR',' NOT PRE','CEDED BY•,• A OR', 0001017 

l'A LETTER•,• (A-ZI.', 1 UNBALANC 1 , 1 ED PAREN 1 , 1 THESIS.',4*' •, 0001018 

£'LETTER ( 1 , 1 A-Z) NOT•,• SEPARAT 1 , 1 ED BY AN•,• OPERATO','R. •, 0001019 

3' 1 , 1 UNEXPECT 1 , 1 ED LEFT','PARENTHE 1 1 1 SIS OR .•,•NOT. OPE', 0001020 

4 1 RATOR (- 1 , 1 ). 1 , 1 INVALI0 1 , 1 CHARACTE 1 , 1 R IN EXP 1 , 1 RESSION.•, 0001021 
54 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

53*' •,•UNDETERM 1 , 1 1NEO SYN','TAX ERR0 1 , 1 R. CONTA 1 , 1 CT 

6'AMMER.•,• 1 /,0R,ANO,NOT/ 1 0R 1 , 1 AN0 1 , 1 NOT 1 / 

EQUIVALENCE (SYMBOL(32t,BLANK),(SYMBOL(33),PERI00) 

IF (CALLED) GO TO 20 

CALLED=. TRUE. 

CALL INITCCHARS,CODES,41,SYMBOL,33) 

20 TYPE 250 

CALL KEYBRD(S245,STRING,80) 

CALL PACK(STRING,LOGIC,80,80) 

TOP=l 

STACK{l)=O 

LPS=O 

STAT E=1 

CALL SCAN(&30,STRING,l,IPT,LNGTH,2) 

IPT=IPT-1 

GO TO 40 

30 RETURN 

40 N STATE= STATE 

IPT=IPT+l 

IF ( I P T • G T. LNG TH ) G 0 T 0 2 30 

CALL FIND(S50,STRING(IPT),ICOOE,CHARS,COOES,41t 

GO TO 60 

50 STATE=5 

GO TO 220 

60 IFTN=IMAT(NSTATE,ICOLS(ICOOE)J 

JOB= I FTN/10 

STATE=IFTN-10*JOB 

GO TO (70,40,90,100,110,130,220) ,JOB 

70 LPS=LPS+1 

POLISH{LPSJ=ICODE 

IF ( ICODE.LE.NCONDJ GO TO 40 

TYPE 270 

GO TO 20 

90 IF CSTACKtTOP).LT.ICODE) GO TO 100 

L PS=L PS+ 1 

POLISH(LPS)=STACK(TOP) 

TOP= TOP-1 

IF (TOP.GT.OJ GO TO 90 

STATE=6 

GO TO 220 

100 TOP=TOP+1 

STACK(TOP)=ICODE 

GO TO 40 

110 IF ($TACKITOP).EQ.27) GO TO 120 

LPS=LPS+ 1 

POLISH(LPSJ=STACK(TOP) 

TOP=TOP-1 

IF (TOP.GT.O) GO TO 110 

STATE=2 

GO TO 220 

120 TOP=TOP-1 

IF (TOP.GT.OJ GO TO 40 

STA TE=2 

GO TO 220 

130 FC=IPT+1 

DO 14C I=FC,80 

IF (STRING(IJ.NE.BLANK) GO TO 160 

140 CONTINUE 

150 TYPE 280 

GO TO 20 

PROGR',0001022 

0001023 

0001024 

0001025 

0001026 

0001027 

0001028 

0001029 

0001030 

0001031 

00010 32 

0001J33 

0001034 

0001035 

0001036 

0001037 

00010 38 

0001039 

0001040 

0001041 

0001042 

0001043 

0001044 

0001045 

0001046 

0001047 

0001048 

0001049 

0001050 

0001051 

0001052 

0001053 

0001054 

0001055 

0001056 

00010 57 

0001058 

0001059 

0001060 

0001061 

0001062 

0001063 

0001064 

0001065 

0001066 

0001067 

0001068 

0001069 

0001070 

0001071 

0001072 

0001073 

0001074 

0001075 

0001076 

0001077 

0001078 

0001079 

0001080 

0001081 
GRASP SOFTWARE SPECIFICATIONS 

160 FC=I 

DO 170 IPT=FC,80 

IF tSTRING(IPT).EQ.PERIOOJ GO TO 180 

170 CONTINUE 

GO TO 150 

180 NCHAR=3 

I CODE =0 

190 NCHAR=NCHAR-1 

NCH=FC+NCHAR 

10P=CHARS(21t 

CALL PACK(STRING(FCJ,IOP,NCH-FC+l,4) 

I F ( I 0 P • E Q. AN 0 ) 1 C 0 0 E= 30 

IF (JOP.EQ.NOTt ICODE=3l 

If (lOP .EQ.OR) ICOOE=29 

IF (ICODE.NE.OJ GO TO 200 

IF (NCHAR.GT.l) GO TO 190 

STATE=6 

GO TO 220 

200 IF (ICOOE.LT.31) GO TO 210 

IF (NSTATE.EQ.l) GO TO 100 

STATE=4 

GO TO 220 

210 IF (NSTATE.EQ.2) GO TO 90 

STATE= 1 

220 TYPE 300, (ERRMSG(I,STATE),I=1,7) 

GO TO 20 

230 IF (TOP.EQ.1) GO TO 30 

IF (STACK{T0P).GT.28) GO TO 240 

STATf:=2 

GO TO 220 

240 LPS=LPS+l 

POLISH(LPSJ=STACK(TOPJ 

TOP=TOP-1 

GO TO 230 

245 RETURN 1 

250 FORMAT ( 1 ENTER LOGIC: 1 ,$) 

270 FORMAT ( 1 LOGIC EXPRESSION REFERENCES A CONDITION (A-Z)•,• WHICH 

lAS NOT ENTERED. 1 ) 

280 FORMAT (' OPERATOR NOT ENCLOSED WITH PERIODS. RE-ENTER LOGIC.') 

30C FORMAT (' LOGICAL ERROR:'/1X,7A8) 

END 

55 

0001082 

0001083 

0001084 

0001085 

0001086 

0001087 

0001088 

0001089 

0001090 

0001091 

0001092 

0001093 

0001094 

0001095 

0001096 

0001097 

0001098 

0001099 

0001100 

0001101 

0001102 

0001103 

0001104 

0001105 

0001l06 

0001107 

0001108 

0001109 

0001110 

0001111 

0001112 

0001113 

0001114 

0001115 

OJ01116 

0001117 

wooo 1118 

0001119 

0001120 

0001121 

0001122 
56 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: MEAN 

Purpose: MEAN provides for the computation of range, mean, 

sum, root mean square, and sum of squares for as many as 

five specified items in a specified file. 

Calling sequence: CALL MEAN (J,ISWTCH) 

Arguments: 

J-Pointer used to retrieve argument values from the common area /FTNCOM/. 

ISWTCH-Switch indicating which of three parts (initialization, body, postprocessing) of the code is to be executed. 

Subroutine called: UNCODE 

Common data referenced: 

!TYPE in blank common 

TAGS, IREC, ARGS, NARGS in /FTNCOM/ 

Called by: FDRIVE 

Error checking and reporting: None 

Program logic: The value of ISWTCH determines which of 

three sections of the code is executed. 

If ISWTCH=l, sums and range values are initialized. If 

ISWTCH=2, the type for each argument value is determinted and its value is added to the appropriate sums. 

Range values are updated if required. If ISWTCH = 3, the 

final computations are performed and the results typed out 

to the user. 

The mean is determined using X =~X IN and the root mean 

square is determined using RMS=~X /N, where N is the number of nonblank values of X. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBROUTINE MEAN(J,ISWTCH) 

COMMON NAMES,ITYPE,IPTS,IDIM 

COMMON /FTNCOM/ TAGS,IREC,APGS,NARGS,IFTN,NFTN 

DIMENSION ARG$(6,5), NARG$(5), IFTN(5), ITYPE(500), IREC(500), 

11PTS(500),NSUM(5), SUMX(5), SUMXS(5), VMAX(5), VMIN(5) 

DOUBLE PRECISION NAMESC500),TAGS(5,5) 

INTEGER ARGS 

EQUIVALENCE CIVAL,VAL) 

DATA IBLNK/ 1 1 / 

IF(ISWTCH-2) 5,15,25 

5 K=NARGS(J) 

DO 10 I= 1 ,K 

SUMX (I )=0. 

VM AX (I ) =-1. E30 

NSUM( I )=0 

VMIN(I)=l.E30 

10 SUMXS (I ) =0. 

GO TO 55 

15 K=NARGS(J) 

DO 20 l=l,K 

I V Al = I R E C ( A R G S ( I + 1 , J ) ) 

IF (IVAL.EQ.IBLNK) GO TO 20 

NSUM(I)=NSUM(I)+l 

VALUE=IVAL 

IF(ITYPE(ARGSCI+l,J)).EQ.5) VALUE=UNCOOECVAL,IQ) 

IF (I TYPE(ARGS( 1+1,J)) .EQ.2) VALUE=VAL 

IF (VALUE.LT.VMIN(I)) VMIN(It=VALUE 

IF ( VALUE.GT. VMAX( It I VMAX( I) =VALUE 

SUMX( I )=SUMX( I) +VALUE 

SUMXS(I)=SUMXS( I)+VALUE*VALUE 

20 CONTINUE 

GO TO 55 

25 K=NARGS(J) 

DO 50 1=1,K 

IF (NSUM(l).EQ.O) GO TO 30 

TYPE 60, TAGSCI,J),NSUM(I) 

AMEAN=SUMX(It/NSUM(l) 

RMS=SUMXS(l)/NSUM(I) 

IF (ITYPE(ARGS(l+l,J)).EQ.2) GO TO 40 

If (ITYPE(ARGS( l+l,J)).EQ.5t GO TO 40 

0001123 

0001124 

0001125 

0001126 

0001127 

0001128 

0001129 

0001130 

0001131 

0001132 

0001133 

0001134 

0001135 

0001136 

JJ~1137 

0001138 

0001139 

0001140 

0001141 

0001142 

~J01143 

0001144 

0001145 

0001146 

0001147 

OJ01148 

0001149 

0001150 

0001151 

0001152 

0001153 

0001154 

0001155 

0001156 

0001157 

0001158 

0001159 

0001160 

0001161 

0001162 
M I N= V M IN ( I t 

MAX=VMAX( It 

GRASP SOFTWARE SPECIFICATIONS 

TYPE 80, MIN,MAX,AMEAN,RMS,SUMX(li,SUMXS(l) 

GO TO 50 

30 TYPE 70, TAGS( I ,J) 

GO TO 50 

40 TYPE 80, VMIN(l),VMAX(I),AMEAN,RMS,SUMX(l),SUMXS(ll 

50 CONTINUE 

55 RETURN 

60 FORMAT(/' MEAN STATISTICS FOR •,A8, 1 WITH 1 ,I6, 1 ITEM(S).'I 

70 FORMAT (/' NO VALUES PRESENT FOR 1 ,AB) 

80 FORMAT ( 1 MIN= 1 ,1PG9.2,' MAX= 1 ,G9.2, 1 MEAN= 1 ,G9.2,' ROOT MEAN 

1SQ.=',G9.2/' SUM=',Gl2.5,' SUM OF SQUARES:',G12.5) 

END 

57 

0001163 

0001164 

0001165 

0001166 

0001167 

0001168 

000116q 

0001170 

0001171 

0001172 

0001173 

0001174 

0001175 

0001176 
58 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: NAME Called by: DRIVER 

Purpose: NAME provides the user with the mechanism for 

examining the structure and content of the current data 

base. The user iSI permitted to select categories of interest. 

Item names, types, and descriptions for alii entries in selected 

categories are printed. The user is aliSo permitted to see the 

values which are assumed (in the current data base) by 

character- and multiple-choice-type items. 

Error checking and reporting: None 

Program logic: 

1. DEFLST is caJlled to select those categories of interest 

(LIST). 

2. For each category selected, a call is made to FINDGP 

to obtain the names, types, and descriptions for all items 

within that category. They are then printed under thecategory name. Calling sequence: CALL NAME (&n) 

Argument: 

n-Statement number (in caller) to which a branch is made 

if the .second nonstandard return is taken from DEFLST 

(EOF sensed by KEYBRD), or EOF is sensed in BDEF. 

Subroutines called: DEFLST, PAUSE, FINGDP, LENGTH, 

BDEF 

Common data referenced: None 

G R A S P S 0 U R C E 

3. Programmed pauses after each category or 30 lines of output are provided via calls to PAUSE. 

4. A call to LENGTH is made to determine the number of 

nonblank words in the description. 

5. Unit 20 (used by DEFLST and FINDGP) is rewound 

prior to returning to DRIVER. 

P R 0 G R A M 

SUBROUTINE NAME(*) 0001177 

INTEGER CAT(8,17t,DESC(12,45),TYPE(45),LIST(l7J 0001178 

DOUBLE PRECISION NAMES(45) 0001179 

CALL OEFLST(&50,&60,CAT,NUMC,MC,LIST) 0001180 

TYPE 70 0001181 

CALL PAUSE(&50) 0001182 

DO 30 K=l,NUMC 0001183 

KNUM=liST(K) 0001184 

CALL FINDGP(&50,KNUM,NU~,MAXL,NG,OESC) 0001185 

READ (20) (NAMES(Jt,TYPE(J),(DESC(I,J),l=1,MAXL),J=l,NUMI 0001186 

CAlL LENGTH(CAT(1,KNUM),MC,MCLJ 0001187 

TYPE 90, (CAT(I,KNUM),I=1,MCL) 0001188 

TYPE 91 0001189 

LINE=O 0001190 

10 LINE=LINE+1 0001191 

IF (LINE.GT.NUM) GO TO 30 0001192 

IF (M00(LINE,301.NE.O) GO TO 20 0001193 

CALL PAUSEC&50) 0001194 

TYPE 90, {CAT(l,KNUM),I=l,MCL) 0001195 

TYPE 100 0001196 

TYPE 91 0001197 

20 CALL LENGTHCDESCC1,LINE),MAXL,MXL) 0001198 

TYPE 110, NA~ES(LINE),TYPE(LINE),(DESC(I,LINEJ,I=l,MXL) 0001199 

GO TO 10 0001200 

30 CALL PAUSE(&50) 0001201 

50 REWIND 20 0001202 

CALL RDEF(&60) 0001203 

RETURN 0001204 

60 RFTURN 1 0001205 

7G FORMAT ( 1 IN EACH CATEGORY, THE ITEM NAMES, TYPE CODES,•,• AND DES0001206 

1CRIPTIONS WILL BE'/ 1 LISTED. TYPE CODES: 1 /9X, 1 1 =WHOLE NUMBERS'/90001207 

2X,'R = NUMBERS WITH FRACTIONAL PARTS 1 /9X, 1 A = ALPHANUMERIC STRINGS0001208 

3'/9X,•B =MULTIPLE CHOICE TYPES 1 /9X, 1 Q =QUALIFIED NUMERIC VALUES 1 0001209 

4 /' AT EACH PAUSE STRIKE CR KEY TO CONTINUE (STARTING NOW).•) 0001210 

9C FORMAT(' CATEGORY: 1 ,9A5t 0001211 

91 FORMAT(' NAME TYPE DESCPIPTION'/' ----•, 0001212 

1. ---- -----------·· 0001213 

100 FORMATC 1 + 1 ,T50, 1 (CON 11 T) 1 ) 0001214 

110 FOR~AT (1X,A7,1X,A1,2X,12A5) 0001215 

END 0001216 
GRASP SOFTWARE SPECIFICA'TIONS 59 

SUBROUTINE NAME: OBEY 

Purpose: OBEY associates input or output file names with 

FORTRAN unit numbers and provides a degree of filename checking and protection. 

Calling sequence: CALL OBEY(&m,MSG,N) 

Arguments: 

m-Statement (in caller) to which a branch will be made 

if a protected (output) or unknown (input) file name is 

referenced. 

MSG-Contains (in packed-character form) either of the 

following: 

"EQUATE 11 name," indicating input, 

"EQUATE 12 name," indicating output. 

N-The number of words in MSG. 

Subroutines called: KEYBRD, IFILE, OFILE 

Common data referenced: 

IN, lOUT in /IOUNIT/ 

FNAMES, NUMI, WHICH in /FILNAM/ 

Called by: RETRVE, OPREP, FTNC 

Error checking and reporting: 

1. Input file names are checked for recognition. 

2. Output file names are checked to prevent writing on a 

"protected" file. 

3. The total number of output files is checked against the 

maximum 20. 

Error messages for each of the above three checks are 

provided. 

Program logic: 

l. If the message length N is not 4 or if the first 4 characters in MSG are not EQUA, return is immediate. 

2. MASTER is set to the cur.rent data-base name in 

/FILNAM/ and MSG is moved to IMSG. 

3. If the third word of IMSG is not "2," input is assumed, 

and the file name (last word of IMSG) is checked against 

the names of files created during this session. If no match 

is found, the user is informed and given the opportunity to 

exit and enter a new command. Finally, IFILE is called to 

associate unit 23 with the file name provided. 

4. If the third word of IMSG is "2.," output is assumed, and 

the file name FN AME (last word in IMSG) is checked 

against the Ust of protected file names in /FILNAM/. If a 

match is found, the nonstandard return is taken. Otherwise, 

FNAME is added to the list FILES, and unit 24 is associated with the file FNAME via a call to OFILE. 

G R A S P S 0 U R C f P R 0 G R A M 

SUBROUTINE OBEY{*,MSG,Nl COM~ON /IOUNIT/ IN,IOUT 

COMMON /FILNAM/ FNAMES,NUMI,WHICH,PAD 

INTEGER MASTER,FNAME,FILESC20),MSG{l),IMSG(4),FNAMES(20),WHICH 

1 ,PA0(4) 

EQUIVALENCE (IMSG{4),FNAMEt 

DATA 12,NUMf, IEQ/'2',0, 'EQUA'/,IYES/'Y'/ 

IF{N.NE.4) GO TO 100 

lf(MSG{l).NE.IEQ) GO TO 100 

MASTtR=FNAMES (WHICH) 

DO 2 I= 1, 4 

2 IMSG(l)=MSG(I) 

1F(IMSG(3).EQ.I21 GO TO 10 

I N=23 

IF(f~AME.EQ.MASTER) GO TO 6 

IFCNUMF.GT.OJ GO TO 4 

3 TYPE 5CO 

CALL KEYBRDC&lOO,I,l) 

IF(I.FO.IYESt GO TO 6 

8 RETURN 1 

4 DO 5 I = 1 , NU M F 

IF(FILES(I).EQ.FNAME) GO TO 6 

5 CONTINUE 

GO TO 3 

6 CALL IF I l E ( IN, F NAME I 

GO TJ 1CO 

10 DO 11 J=l,5 

K=4* ( J-1) 

DO . 11 I= 1, N UM I 

IFCFNAMES(K+I).EQ.FNAME) GO TO 14 

11 CONTINUE 

GO TO 12 

JJ01217 

0001218 

0001219 

0001220 

0001221 

0001222 

0001223 

0001224 

0001225 

0001226 

OOC1227 

0001228 

0001229 

0001230 

0001231 

0001232 

0001233 

0001234 

00012.35 

0001236 

0001237 

0001238 

0001239 

0001240 

0001241 

J001242 

0001243 

0001244 

0001245 

0001246 

0001247 

0001248 
60 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

14 TYPE 501,FNAME 

GO TO 8 

12 IF(NU~F.EQ.Ot GO TO 20 

DO 13 I =1 ,NUMF 

IFCFILES(I).EQ.FNAME) GO TO 21 

13 CONTINUE 

20 NUMF=NUMF+1 

IF(NU~F.LE.20) GO TO 22 

NUMF=20 

TYPE 23 

GO TO 8 

22 FILES(NUMF)=FNAME 

21 IOUT=24 

CALL OFILE( IOUT,FNAME) 

100 RETURN 

23 FORMAT(' NO MORE THAN 20 FILES MAY BE CREATED IN ONE RUN.') 

500 FORMAT(' ATTEMPT TO REFERENCE A FILE NOT CREATED THIS RUN.'/ 

1 ' DO YOU STILL WANT IT? (Y OR N): •,$) 

501 FORMAT(lX,A6,'MAY NOT BE USED AS AN OUTPUT FilE NAME') 

END 

0001249 

0001250 

0001251 

0001252 

0001253 

00012~4 

0001255 

00012 56 

0001257 

0001258 

0001259 

0001260 

0001261 

0001262 

0001263 

0001264 

0001265 

0001266 

0001267 

0001268 
GRASP SOFTWARE SPECIFICATIONS 61 

SUBROUTINE NAME: OFILE 

Purpose: This subroutine is used to associate dynamically the 

name of a new data set with a FORTRAN output unit number (that is, logical device number). When this subroutine 

is caHed, the file is opened, and write statements referencing the unit number given in the argument list are directed 

to the named file. The file may be closed by use of a rewind 

statement. 

Calling sequence: CALL OFILE(I,NAME) 

Arguments: 

I-An integer variable or constant specifying a logical device number. 

NAME-Either a literal (hollerith) constant or variable 

containing a file name consisting of five or fewer characters. 

Subroutines called: None 

Common data referenced: None 

Called by: COLPN.T, OBEY 

Error checking and reporting: None 

Program logic: This routine is a DEC 1070, TOPS-10 system resident routine. It provides the capabilities referred to 

in the section "Purpose" above. If the GRASP system is to 

be implemented on some other main frame, a comparable 

routine must be written or acquired. Therefore, a listing 

has not been provided. 
62 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: OPREP 

Purpose: This routine is used to prompt for and accept the 

name of a :file and a page size. 

Calling sequence: CALL OPREP(&n,&m,NPAGE) 

Arguments: 

n-Statement number (in calling routine) to which a branch 

will be made if an EOF is sensed by KEYBRD. 

m-Statement number (in calling routine) to which a branch 

will be made if the nonstandard return from OBEY is 

taken. 

NPAGE-Page size (in lines) as entered by us-er. 

Subroutines called: KEYBRD, OBEY, ICONV, PACK 

Common data referenced: NAMES, WHICH in /FILN AM/ 

G R A S P S 0 U R C E 

SUBROUTINE OPREPl*t*tNPAGEa 

COMMON /FILNAM/ FNAMES,WHICH,PAD 

Called by: DUMPIT, LIST 

Error checking and reporting: An error flag set by ICONV is 

tested. If set, the user is requested to reenter the value. 

Program logic: 

1. A file name is prompted for and accepted (via KEYBRD). 

This name is then packed into FNAME and compared with 

blank. 

2. If blank, FNAME is set to the default file name obtained 

in /FILNAM/. 

3. FNAME is then passed to OBEY via EQUATE. 

4. A page size is then prompted for and accepted in character form. The numeric value is obtained by a reference 

to ICONV. If zero, then NPAGE is set to 10 million. 

P R 0 G R A M 

INTEGER DBLNK,OFAULT,FNAME,EQUATE(4),TANK(5),FNAMES(2l),WHICH 

0001269 

J001270 

0001271 

0001272 

0001273 

0001274 

0001275 

0001276 

0001277 

0001278 

0001279 

0001280 

0001281 

0001282 

0001283 

0001284 

00012 85 

0001286 

0001287 

0001288 

0001289 

0001290 

0001291 

0001292 

1 ,PA0(4) 

LOGICAL BAD 

EQUIVALENCE (EQUATE(4),FNAME) 

0 AT A DB L N K ' E QUA T E I • • ' ' E QlJ A t ' • T E 1 • ' • 1 I ' I • I 

TYPE 20 

DFAULT=FNAMES(WHICH) 

CALL KEYBR0(&15,TANK,5) 

CALL PACK ( T A NK , F N A M E, 5, 5 ) 

IF(FNAME.EQ.OBLNK) FNAME=DFAULT 

CALL OBEY(&l8,EQUATE,4) 

10 TYPE 30 

CALL KEYBRD(&15,TANK,5) 

NPAGE=ICONV(TANK,S,I,BADt 

IF (BAD) GO TO 10 

IF (NPAGE.EQ.O) NPAGE=10000000 

RETURN 

15 RETURN l 

18 RETURN 2 

20 FORMAT ('ENTER NAME OF FILE: 1 1 $) 

30 FORMAT(' ENTER NUMBER OF LINES/PAGE: •,$) 

END 
GRASP SOFTWARE SPECIFICATIONS 63 

SUBROUTINE NAME: PACK 

Purpose: All user input to the GRASP system is in unpacked 

form (in other words, one single left-justified character per 

word). PACK is used to convert from this unpacked form 

to packed form. This is necessary because character data 

in files accessed by GRASP is in packed form to conserve 

space. 

Calling sequence: CALL PACK(SOURCE,DESTN,N,SIZE) 

Arguments: 

SOURCE-The array containing the unpacked character 

string. 

DESTN-The array which is to contain the packed character string. 

G R A S P S 0 U R C E 

N-The number of characters to pack. 

SIZE-The size (in characters) of the area to receive the 

packed data. 

Subroutines called: None 

Common data referenced: None 

Called by: DRIVER, COLPNT, CONDTN, DECOMP, FILES, 

FTNC, LOGEXP, OPREP, PARSE, PNTER, RELEXP, 

RETRVE, VLIST 

Error checking and reporting: None 

Program logic: The ENCODE .statement is used to move the 

characters from the unpacked string (SOURCE) to the 

packed string (DES TN) . 

PROGRAM 

SUBROUTINE PACK(SOURCE,DESTN,N,SIZE) 

I NT E G E R S OUR C E ( 1 ) t 0 E S TN ( 1 J , S I l E 

0001293 

0001294 

0001295 

0001296 

0001297 

0001298 

ENC 00 E ( S I Z E, 1, 0 EST N t (SOURCE ( I) , I= 1, N) 

1 FORMAT(80Al) 

RETURN 

END 
64 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: PARSE 

Purpose: PARSE converts arithmetic expressions to an encoded Reverse-Polish fonn. Extensive syntax checking, conversion, and preliminary addressing are performed to facilitate later evaluation by EV AL. The arithmetic expressions 

may contain the usual arithmetic operators ( +,-,*,/), 

numeric constants, item names, and the following functions: 

ABS ( ) -absolute value; 

SQRT ( ) -square root; 

LOG ( )-log base 10; 

SQR ( ) -square; 

TEN ( ) -power of 10. 

Parentheses may be used for grouping to control the order 

of evaluation. 

Calling sequence: CALL PARSE (EXPR,L,TYPE,POLISH, 

I,ERR) 

Arguments: 

EXPR-Arithmetic expression to be parsed in unpacked 

character form. 

L-The length of EXPR. 

TYPE, POLISH-Arrays which will contain the encoded 

Reverse-Polish form. See s•ection on subroutine EV AL 

for additional encoding information. 

!-Length of TYPE and POLISH. 

ERR-Logical flag set if an error is detected. 

Subroutines called: INIT, FIND, BFIND, INCONV, PACK 

Common data referenced: NAMES, IPNTS, IDIM in blank 

common. 

Called by: PREV AL 

Error checking and reporting: The expression is checked for 

normal FORTRAN-like syntax (such as balanced parentheses, binary operators bracketed by valid names or expressions, and correct spelling of function names) . The message 

"ERROR IN EXPRESSION"is typed if an error is detected. 

If an operand or function name is not recognized, that 

message is typed. 

Program logic: The logical variable CALLED is tested. If it 

has not been set by a previous call, it is set to .TRUE. and 

INIT is called to "hash code" the elements of SYMBOL 

G R A S P S 0 U R C E 

into CHARS and CODES. Next, the variables ERR, ROW, 

TOP, I, and C are initialized. The remainder of the computation involves scanning EXPR, an element at a time. 

As in LOGEXP, a transition-matrix technique is used to 

parse the expression, converting it to reverse-Polish form. 

The transition matr.ix (TM) is given below: 

A-Z + I blank 0-9 

% 

1. f(l)/2 f(S)/1 error error error f(l0)/1 error f(2)/1 f(ll)/3 2. f(3)/2 f(4)/1 f(5)/l f(6)/1 f(7)/l f(12)/l f(9)/2 f(2)/2 f( 3)/2 3. error f(4)/l f(5)/1 f(6)/l f(7)/1 error f(9)/3 f(2)/3 f( 3)/3 

where the f (i) are separate tasks as follows: 

f ( 1) -Start a name. 

f ( 2) -Go scan next character. 

f(3)-Append current character to name. 

f(4-7)-Binary arithmetic operator sensed: Set CODE to 

indicated operator; pop stack until CODE is less than 

the topmost stack element; push CODE down on stack. 

f(8)-Unary minus sensed: set CODE and push down on 

stack. 

f(9)-Right parenthesis sensed: pop stack until topmost 

element is code for left parenthesis (P AREN) ; decrease 

size of stack by one. 

f(l())-Left parenthesis sensed; push down parenthesis 

code PAREN. 

f(ll)-Digit or period sensed: start a constant. NAME is 

used to contain the constant in character form. 

f ( 12)-Left parenthesis sensed in row 2: hence, the contents 

of NAME are assumed to be a function name. Check for 

validity and print an error message if invalid; otherwise, 

set CODE and push down on stack. 

The proper element of TM is selected by the variables ROW 

and COLUMN. The COLUMN value is determined by a lookup 

(via FIND) of the current character and the ROW value is set 

by the last element of TM referenced. Once the proper element 

of TM is selected, the next ROW value is set and a branch 

is made to the current task. 

This process is repeated until all elements of EXPR have 

been processed. See the section on subroutine EV AL for details 

of the encoding of TYPE and POLISH. 

P R 0 G R A M 

SUBROUTINE PARSE(EXPR,L,TYPE,POLISH,I,ERR) OG01299 

COMMON NAMES,ITYPE,IPNTS,IDIM 0001300 

DIMENSION NAMES(500), POLISH( 1), STACK(41), EXPR(l), NAME(8), TM(30001301 

1,9), SYMBOL(45), COLS(45), TYPE(l), ITYPE(500), IPNTS(500), IFNCTS0001302 

2(5), CHARS(47), CODES(47) 0001303 

DOUBLE PRECISION N~MES,VARBLE,OBLNK 0001304 

INTEGER TM,TOP,ROW,COLUMN,ELEMNT,SWITCH,TYPE,C,COLS,SYMBOL,CHARS,C0001305 

10DES,CHAR,EXPR 0001306 

LOGICAL POP,NUM,ERR,CALLED 0001307 

DATA TMI12,32,0,81,2*41,0,2*51,0,2*61,0,2*71,101,121,2*0,92,93,21,0001308 

122,23,113,32,331 0001309 

DATA s y M B OL I • A. t • B • ' I c I ' ' D • ' I E I ' • f ' ' • G ' ' • H • ' I I • ' • J • t • K ' ' ' L • ' ' M • t • N 00 0 13 1 0 

1. t • 0. ' • p. ' • Q I ' I R. 'I s. '. T I 'I u I '. v. ' • w I ' I X. ' • y' ' • Z1 ' • 0. ' • 1. ' • 2. ' I 3. '000 1311 

2 1 4.' • 5.' • 6.' I 7.' • 8.' • 9 I 'I. I 'I • ' 1+ • '·-. '.*I '.I. 'I ( I '. , I '. %1 I 0001312 

DATA COLS/26*1,11*9 9 8,3,2 1 5,41 6 1 7,11 0001313 

DATA IALNK,CALLED,OBLNK/ 1 •,.FALSE.,' 1 / 0001314 

DATA PAREN,PluS,OIFF,PROD,OlV,UNARY/0.,-1.,-2.,-3.,-4.,-5.1 0001315 
GRASP SOFTWARE SPECIFICATIONS 

DATA IFNCTS/'ABS' ,•SQRT' , 1 LOG't'SQR1 , 1 TEN'/ 

If (CALLED) GO TO 20 

C ALL E 0= • T RU E • 

CALL INITCCHARS,CODES,47,SYMBOL,45) 

20 ERR=.FALSE. 

ROW=1 

TOP=O 

1=0 

C=O 

30 C=C+ 1 

I F ( C • L E • L ) GO T 0 50 

If (ROW.EQ.1) GO TO 350 

IF (POP) GO TO 250 

IF (NUM) GO TO 40 

SWITCH=1 

GO TO 300 

40 SWITCH=2 

GO TO 320 

50 CHAR=EXPR(C) 

CALL FIN0(&350,CHAR,COLUMN,CHARS,COOES,47) 

COLUMN=COLSCCOLUMN) 

ELEMNT=TM(ROW,COLUMN) 

JOB=ELEMNT/10 

ROW=ELEMNT-lO*JOB 

GO TO (60,30,70,130,140,150,160,170,180,230,240,270), JOB 

GO TO 350 

60 NAME( !)=CHAR 

NCHAR= 1 

POP=. FALSE. 

NUM=. FALSE. 

GO TO 30 

70 NCHAR=NCHAR+1 

NAME ( N CHAR) =CHAR 

GO T 0 30 

80 IF (POP) GO TO 100 

POP=. TRUE. 

IF (NUM) GO TO 90 

SWITCH= 3 

GO TO 300 

90 SWITCH=4 

GO TO 320 

100 If (TOP.EQ.O) GO TO 120 

IF CCODf.LT.STACK(TOP)) GO TO 120 

SWITCH=5 

VALUE=STACK(TOPt 

INDEX= VALUE 

GO TO 330 

110 TOP=TOP-1 

GO TO 100 

120 TOP=TOP+1 

STACKlTOP)=CODE 

GO TO 30 

130 CODE= D IFF 

GO TO 80 

140 CODE=PLUS 

GO TO 80 

150 CODE=OIV 

GO TO 80 

160 CODE=PROO 

65 

0001316 

0001317 

0001318 

0001319 

0001320 

0001321 

0001322 

0001323 

0001324 

0001325 

0001326 

0001327 

0001328 

0001329 

0001330 

0001331 

0001332 

:>:>01333 

0001334 

0001335 

0001336 

0001337 

0001338 

0001339 

0001340 

0001341 

0001342 

0001343 

0001344 

0001345 

0001346 

0001347 

0:>01348 

0001349 

0001350 

0001351 

0001352 

0001353 

0001354 

0001355 

0001356 

0001357 

0001358 

0001359 

0001360 

0001361 

0001362 

0001363 

0001364 

0001365 

0001366 

0001367 

OOC1368 

0001369 

0001370 

0001371 

0001372 

0001373 

0001374 
66 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

GO TO 80 

1 7C COOt:; UNARY 

GO TO 120 

180 IF (POP) GO TO 200 

POP=. TRUE. 

IF CNUM) GO TO 190 

SWI TCH=6 

GO TO 300 

190 SWITCH=7 

GO TO 320 

200 IF (TOP.EQ.O) GO TO 350 

IF CPAREN.EQ.STACK(TOPt) GO TO 220 

SWt TC H=8 

VALUE=STACK(TOP) 

INOEX=VALUE 

GO TO 330 

210 TOP=TOP-1 

GO TO 200 

220 TOP=TOP-1 

GO TO 30 

230 TOP=TOP+l 

STACKCTOP)=PAREN 

GO TO 30 

240 NAMEC1»=CHAR 

NCHAR= 1 

NUM=.TRUE. 

POP=. FALSE. 

GO TO 30 

250 IF CTOP.EQ.O) GO TO 370 

SW I TC H=9 

VALUE=STACKCTOP) 

IF (VALUE.EQ.PARENt GO TO 350 

INDEX= VALUE 

GO TO 330 

260 TOP:::TOP-1 

GO TO 250 

270 IVAL=IBLNK 

IF (NCHAR.EQ.O) GO TO 350 

CALL PACKCNAME,IVAL,NCHAR,4) 

DO 280 J=1,5 

IF ( I VAL • E Q • IF NC T S ( J) ) G 0 T 0 2 90 

280 CONTINUE 

TYPE 410, IVAL 

GO TO 350 

290 COOE=J-11 

TOP=TOP+l 

STACK (TOP)= CODE 

GO TO 230 

300 VARBLE=DBLNK 

CALL PACKCNAME,VARBLE,NCHAR,8) 

CALL BFIND(&310,VARBLE,INDEX,NAMES,IPNTS,IDIM) 

GO TO 330 

310 TYPE ~90, VARBLE 

GO TO 360 

320 VALUE=ICONV(NAME,NCHAR,J,ERR) 

IF (ERR) GO TO 350 

INDEX :::0 

IF (J.NE.O) VALUE=VALUF*10.**J 

0001375 

OJ01376 

0001377 

0001378 

0001379 

0001380 

0001381 

0001382 

0001383 

0001384 

0001385 

0001386 

0001387 

0001388 

0001389 

0001390 

0001391 

0001392 

0001393 

0001394 

0001395 

0001396 

0001397 

0001398 

OJ01399 

0001400 

0001401 

0001ft.02 

0001403 

0001404 

0001405 

0001406 

0001ft.07 

0001408 

0001409 

OJ01ft10 

0001411 

0001412 

0001413 

0001414 

0001415 

0001416 

OOC1417 

0001418 

0001419 

0001420 

0001421 

0001422 

0001423 

0001424 

0001425 

0001426 

0001427 

0001428 

00(;1429 

0001430 

0001431 

0001432 
GRASP SOFTWARE SPECIFICATIONS 

330 I~I+l 

IF ( I .L E. 15) GO TO 340 

TYPE 420 

GO TO 350 

340 POLISH(I)=VALUE 

TYPE(It=INDEX 

GO TO (250,250,100,100,110,200,200,210,26Ct, SWITCH 

350 TYPE 380, ( EXPR( Jt ,J=l ,L) 

360 ERR=.TRUE. 

370 RETURN 

380 FORMAT(' ERROR IN EXPRESSION: 1 1 50Al/23X,30Al) 

39C FORMAT (' UNDEFINED NAME 1 1 A8) 

410 FORMAT (1X,A5,'IS NOT A PERMISSIBLE FUNCTION. HENCE') 

420 FORMAT(' MORf THAN 15 NAMES AND OPERATCRS USED. HENCE't 

END 

67 

0001433 

0001434 

0001435 

0001436 

0001437 

0001438 

0001439 

J001440 

0001441 

0001442 

0001443 

0001444 

0001445 

0001446 

0001447 
68 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: PAUSE 

Purpose: This routine is used to provide a system-generated 

pause in output. If a nonblank character is entered by the 

user, the nonstandard return is taken. 

Calling sequence: CALL PAUSE (&n) 

Argument: 

n-Statement (in caller) to which a branch will be made 

,if a nonblank character is returned by KEYBRD, or if 

G R A S P S 0 U R C E 

SUBRJUTINE PAUSEC*t 

the nonstandard return is taken from KEYBRD. 

Subroutine called: KEYBRD 

Common data referenced: None 

Called by: BDEF, COLPNT, DUMPIT, NAME, ROWPNT 

Error checking and reporting: None 

Program logic: PAUSE accepts a single (left-justified) character from KEYBRD. If an EOF is sensed or the character 

is nonblank, take the nonstandard return. 

PROGRAM 

DATA IBLNK/' 'I,IBELL/"0340GCOOOOOO/ 

TYPE l,IBELL 

0:>01448 

0001449 

0001450 

0001451 

0001452 

0001453 

JJOllt54 

0001455 

CALL KEYBRO(&lC,I,l) 

IF (l.EQ.IBLNK) RETURN 

10 RETURN 1 

1 FORMAT(lX,A1) 

END 
GRASP SOFTWARE SPECIFICATIONS 69 

FUNCTION NAME: PNTER 

Purpose: PNTER is used to look up user-entered characterstring or multiple-choice-type values in the value part of 

"conditions" statements. Lookup is performed in the appropriate dictionary, and the value returned is a pointer to the 

particular dictionary item. If the value is not found, an 

error flag is set and zero is returned. 

Calling sequence: IPT = PNTER (VALUE,IDIM,NAME, 

ITYPE,ERR) 

Arguments: 

VALUE-Unpacked character-string value to be looked up. 

!DIM-Length of the string in VALUE. 

NAME-Item number for which the character string represents a value. 

ITYPE-Item type of item pointed to by NAME. 

ERR-Error flag which is set if the value is not found in 

the dicitionary pointed to by NAME. 

Subroutines called: ACCESS, BINTYP, PACK 

Common data referenced: None 

Called by: RELEXP 

G R A S P S 0 U R C E 

Error checking and reporting: If the character-string value is 

not found, a message is typed, the error flag is set, and 

zero is returned as the value of PNTER. 

Program logic: If the length of the string is given as zero, 

a value of blank is returned immediately. Otherwise, the 

string is packed into STRING. The value of ITYPE then 

determines whether the character-type dictionarie's should 

be accessed (via ACCESS) or the multiple-choice-type dictionaries should be accessed (via BINTYP). If a charactertype dictionary is indicated, a call to ACCESS is made, 

where the fifth parameter has a value of 31. This returns K 

as the pointer to the first dictionary item. ACCESS is then 

called, using the value 4 as the fifth parameter (which returns the K'th entry and updates K to point to the next 

entry) , until all entries have been returned or until a match 

is found. If a match is found, the entry number is returned 

as a value. Otherwise, zero is returned as a value, and the 

nonstandard return is taken. If a multiple-choice-type dictionary is indicated, a call to BINTYP returns the possible 

values in LABEL. The string (equivalenced to BLABEL) is 

then compared with the items of LABEL. 

P R 0 G R A M 

INTEGER FUNCTIONPNTER(VALUE,IOIM,NAME,ITYPE,ERR) 

DOUBLE PRECISION LAREL(25),BLABEL 

0001456 

0001457 

0001458 

0001459 

OOG1460 

0001461 

0001462 

0001463 

0001464 

0001465 

0001466 

0001467 

0001468 

0001469 

0001470 

0001471 

0001472 

0001473 

0001474 

O:>Olft75 

0001476 

0001477 

0001478 

0001479 

0001480 

0001481 

0001482 

0001483 

0001484 

0001485 

0001486 

0001487 

0001488 

0001489 

INTEGER VALUECl),TANKC25),BlTEM(l5,25),STRING(l2) 

LOGICAL ERR 

EQUIVALENCE (STRING(1),BLABEL) 

DATA IBLNK/ 1 '/ 

ERR=. FALSE. 

N=IBLNK 

IF (I 01~. EQ .0) GO TO 110 

DO 10 1=1,12 

10 STRING(I)=IBLNK 

CALL PACK(VALUE,STRING,IDIM,60) 

00 20 1=1,12 

IF (STRING(13-I).NE.IBLNK) GO TO 30 

20 CONTINUE 

GO TO 110 

30 LENGTH= 13-1 

IF(ITYPE-3) 35,35,80 

35 CALL ACCESS(NAME,K,TANK,NU~,3) 

N=O 

40 IF(K.EQ.Q) GO TO 60 

N=N+l 

CALL ACCESS(NAME,K,TANK,NWORDS,4) 

IF (NWORDS.LT.lENGTHt GO TO 40 

DO 50 1=1 ,LENGTH 

IF (TANK(U.NE.STRING(J)) GO TO 40 

50 CONTINUE 

GO TO 110 

60 ERR=.TRUE. 

TYPE 130, (VALUE(I),I=l,IDI~) 

GO TO 100 

80 CALL BINTYP(NAME,LABEL,BITEM,L,M) 

DO 90 N=1,M 

IF (BLABEL.EQ.LABEL(N)) GO TO 110 
70 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

90 CONTINUE 0001490 

00Cl491 

000lft92 

0001493 

0001494 

000lft95 

100 

110 

130 

140 

T Y P E 14 0 , B LAB E l 

ERR=.TRUE. 

N=O 

PNTER=N 

RETURN 

FORMAT (' 

FORMAT ( 1 

END 

CHARACTER TYPE VARIABLE DOES ~OT ASSUME VALUE: 1 /1X,60Al)0001496 

BINARY TYPE VARIABLE DOES NOT ASSUME VALUE •,AS) 0001497 

0001498 
GRASP SOFTWARE SPECIFICATIONS 71 

SUBROUTINE NAME: PREV AL 

Purpose: PREY AL acts as an interface between the calling 

routine (YLIST) and the arithmetic-expression parsing 

routine PARSE. This interface allows a reduction in the 

number of dimensions for the variables in /EXPRNS/ 

which contain the Reverse-Polish form of the arithmetic 

expressions entered by the usel'. 

Calling sequence: CALL PREY AL ( &n,IEXPR,L,KNT) 

Arguments: 

n-Statement (in calling routine) to which a branch is made 

if the routine PARSE sets an error flag. 

IEXPR-Contains (in unpacked character form) the expression to be parsed. 

L-The length of IEXPR. 

KNT-Arithmetic expression counter. 

Subroutine called: PARSE 

Common data referenced: POLISH, ITYPE, LPS in 

/EXPRNS/ 

Called by: YLIST 

Error checking and reporting: Error flag returned from 

PARSE is tested .. 

Program logic: 

1. The expression counter KNT is incremented. 

2. Call PARSE, passing the input arguments IEXPR, L, and 

the KNT'th columns of ITYPE, POLISH along with the 

KNT'th element of LPS, and an error flag. 

3. Take the nonstandard return if the error flag ERR has been 

set. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBROUTINE PREVAL(*,IEXPR,L,KNT) 

COMMON /EXPRNS/ POLISH,ITYPE 1 LPS 

DIMENSION POLISH(l5,8), ITYPE(l5,8), LPS(8J, IEXPRC1t 

LOGICAL ERR 

KNT=KNT+l 

CALL PARSECI~XPR,L,ITYPE(l,KNT),POLISH(l,KNTt,LPSCKNT),ERR) 

I F ( ERR ) R E TURN 1 

RETURN 

END 

0001499 

0001500 

0001501 

0001502 

0001503 

0001504 

0001505 

0001506 

eoo1so1 
72 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: QUIT 

Purpose: QUIT performs "wrap-up" processing prior to exiting 

from the GRASP system. This involves a typed statement 

regarding the disposition of files created during the current 

session. 

Error checking and reporting: The user's response to prompts 

is checked for validity. 

Program logic: 

1. The list of created file names is typed, and the user is 

asked if he would like to save any of them. 

Calling sequence: CALL QUIT(OFILES,NFILES) 

Arguments: 

2. If so, he is asked to enter a list of numbers corresponding 

to those files he wishes to save. 

OFILES-List of output files created during this session. 

NFILES-The number of items in OFILES. 

Subroutines called: KEYBRD, RLIST 

Common data referenced: None 

Called by: DRIVER 

3. The system then instructs him how to delete the files he 

does not wish to save. This routine is provided primarily for 

bookkeeping. The file-maintenance functions can be performed at the program level on those systems having this 

capability. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBROUTINE QUIT(OFILES,NFILES) 

DIMENSION IMAGE(30),LIST(20), KLIST(201 

INTEGER OFILES(20),FILE,VES,REPLY 

DATA YES,N0/ 1 Y1 , 1 N1 / 

IF (NFILES.EQ.O) GO TO 100 

TYPE 110, (l,OFILES(I),l=1,NFILESJ 

TYPE 120 

10 TYPE 130 

CAll KEYBRD(&100,REPLY,1) 

IF (REPLY.EQ.VES) GO TO 40 

IF (REPLY.EQ.NO) GO TO 20 

TYPE 150 

GO TO 10 

20 NKILL=NFILES 

00 30 1=1,NFILES 

30 KLIST(I)=I 

GO TO 80 

40 IF (NFILES.EQ.1) GO TO 100 

TYPE 160 

50 CALL KEVBR0(&100,IMAGE,30) 

CALL RLIST(&50,1MAGE,LIST,NSAVE,20) 

IF (NSAVE.EQ.O) GO TO 20 

NKILL=O 

DO 70 l=l,NFILES 

DO 60 J= 1,NSAVE 

IF (llST(J).EQ.l) GO TO 70 

60 CONTINUE 

NKILL=NK Ill +1 

KllST(NKILL)=I 

70 CONTINUE 

IF (NKILL) 100,100,80 

BC TYPE 90,(0FILESCKLISTtl)),l=l,NKill) 

100 RETURN 

0001508 

0001509 

0001510 

0001511 

0001512 

0001513 

0001514 

0001515 

0001516 

0001517 

0001518 

0001519 

0001520 

0001521 

0001522 

0001523 

JJ01524 

0001525 

0001526 

0001527 

0001528 

0001529 

0001530 

0001531 

0001532 

C001533 

0001534 

0001535 

0001536 

0001537 

000153B 

0001539 

0001540 

9C FORMAT(' ISSUE .DEL COMMANDS FOR THE 

110 FORMAT (//' THE FOLLOWING FILES HAVE 

FOLLOWING FILES: 1 /(1X,10A6)) 0001541 

BEEN CREATED •,•DURING THIS SOOC1542 

1ESSION: 1 /(15,5X,A6) t 

120 FORMAT (// 1 00 YOU WISH TO SAVE ANY OF THEM?') 

13C FORMAT ( 1 (ENTER YES OR NO): •,$) 

150 FORMAT ('YOUR REPLY WAS NOT UNDERSTOOD.') 

160 FORMAT ( 1 ENTER A LIST OF NUMBERS CORRESPONDING 

1 YOU WI SH TO SAVE ( IE. 1-3,5) • 1 ) 

END 

0001543 

0001544 

0001545 

0001546 

TO 'I' THOSE FILES0001547 

0001548 

0001549 
GRASP SOFTWARE SPECIFICATIONS 73 

SUBROUTINE NAME: RELEXP 

Purpose: This subroutine is used to decode the "condition" 

appearing in IMAGE into the· components NAMEPT, 

RCO DE, and IV AL. If it is unsuccessful, an error message 

is typed and an error flag is set. The "condition"' is in 

unpacked character form and is assumed to be a name 

followed by a relation followed by a value. Name must be 

an item name in the current data base (as established by the 

file command). Relation must be one of the following: EQ, 

equal; LT, less than; GT, greater than; LE, less than or 

equal; GE, greater than or equal; NE, not equal; BE, between. Value must be a number, number pair, character 

string, set of qualifiers, permissible multiple-choice acronym, 

or blank. The following table gives valid constructions for 

"conditions": 

Item type 

Integer or reaL __ 

Character -------

Multiple choice __ 

Qualified real ----

Relation 

EQ, LT, GT, LE, GE, NE __ 

BE ------------ EQ, LT, GT, LE, GE, NE __ 

BE ------------

EQ, NE --------------------

EQ, LT, GT, LE, GE, NE __ 

BE ------------ EQ, NE ------------

Value 

Numeric. 

Numeric pair. 

Any printable string. 

Printable string con- taining comma. Multiple-choice 

acronym. 

Numeric. 

1\lumeric pair. 

Qualifier set 1 in 

parentheses. 

1 Qualifier set is one or more of the following characters, each of 

which occur, at most, once; G, H, L, N, T, or blank. 

Calling sequence: CALL RELEXP(&n,IMAGE,NAMEPT, 

RCODE,IVAL,ERR) 

Arguments: 

n-Statement number (in ca:lling routine) to which a branch 

will be made if an all-blank condition is detected. 

IMAGE-Contains "condition" in unpacked-character form. 

NAMEPT-Returned pointer to item name. 

RCODE-Returned encoding of relation having the following possible values: 

1-7 corresponding to the relations 

EQ,LT,GT,LE,GE,NE,BE. 

11 or 16 corresponding to the relations EQ or NE, 

applied to a set of qualifiers. 

IV AL-Returned as one of the following: 

1. Integer or real value. 

2. Pointer to a particular entry in the character dictionary 

associated with the item pointed to by NAMEPT. 

3. Bit encoding, giving the position of a particular multiplechoice acronym in the file containing possible acronym 

values for the item pointed to by NAMEPT. 

4. Pointer to the number pair in the common block BTWN 

which will be used by this instance of the BE relation. 

5. Bit encoding of a qualifier set. 

ERR-Returned error flag that is set if an error is detected. 

Subroutines called: SCAN, BFIND, ICONV, PNTER, PACK 

Common data referenced: 

G R A S P S 0 U R C E 

NAMES, !TYPE, PNTERS, IDIM in blank common 

IVALS, NBE in /BTWN/ 

Called by: CONDTN 

Error checking and reporting: 

1. All testing is performed to insure conformity to the table 

of valid constructs appearing in the preceding "purpose" 

section. 

2. An error flag that may be set by the routines ICONV or 

PNTER is tested. 

3. A nonstandard return from BFIND indicates an invalid 

name. 

An error meEsag.e is printed reporting any of the following 

errors: 

a. Unable to find relation (that is, EQ, LT, GT, LE, GE, 

NE, BE). 

b. Incorrect qualifier set. 

c. Qualifier codes are .referenced in forms other than EQ 

orNE. 

d. Invalid name as first syntactic unit of condition. 

e. No comma separating a value pair used with the BE 

relation. 

Program logic: 

1. A call to SCAN is made to bracket the name as the first 

syntactic element. If the image is all blank, the nonstandard 

return is taken. 

2. The name ~s packed into NAME via ENCODE, and 

BFIND is used to do the lookup. If the name is not 

found, a message is typed, and the error flag is set. 

3. The next ca:ll to SCAN brackets the relation. It is packed 

into REL and tested against the list of valid relations. Note 

that RCODE is used as the index. If invalid, a message is 

typed, and the error flag is set. 

4. The value part of the condition is then bracketed via the 

next call to SCAN. If the value field is blank, IVAL is set 

to blank. 

5. Otherwise, the type of name is determined using ITYPE 

in blank common. 

6. The logical variable BE (indicating the "between" relation) is determined. If set, the second value is determined 

and stored in the BTWN common area, and IV AL is set 

to point to the BTWN location. The second value determination is logically similar to the first which is described 

in step 8. 

7. If BE was not set, the value element is tested as a qualifier 

set. If it is one, the appropriate tests are made, and IV AL 

is bit encoded to show which codes are present. RCODE is, 

also, incremented by 10 as a flag indicating comparison of 

qualifier cores. 

8. If the value element was not a qualifier set, and the rela .. 

tion was not BE, IVAL is set via a call to ICONV, if type 

was numeric. Note that for real values, VAL (equivalenced 

to IV ALL) is set. IV AL is then set by IV ALL, which shares 

.storage with VAL. For character and multiple-choice types, 

IV AL is set using the external function PNTER. 

PROGRAM 

SUBROUTINE RELEXP(*,IMAGE,NAMEPT,RCOOE,IVAL,ERR) 

COMMON NAMES,ITYPE,PNTERS,IOIM 

0001550 

0001551 

COMMON /BTWN/ IVALS,NBE 0001552 

DIMENSION RELS(7), IVALS(2,10), IMAGE(80), ITVPE(500t, NAMES(500) 0001553 
74 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

DOUBLE PRECISION NAME,NAMES,OBLNK 0001554 

INTEGER FCNAME,FCOP,FCCON,RCOOE,PNTER,BLANK,PNTERS(500),E,REL,RELS0001555 

l,COMMA,RPAREN,IQUAL(6) 

LOGICAL ERR ,BE 

EQUIVALENCE (VAL, I VALL), (I QUAL, BLANK) 

DATA COMMA,RPAREN,LPAREN,OBLNK,IQUALI 1 9 1 , 1 ) 1 , 1 ( 1 ,' 

1' '•'G','H','L','N','T'I, 

1 REL S I' E Q', 'l T' , 'GT ', 'L E 1 , 1 GE 1 , 1 N E 1 , 1 BE' I 

ERR=. FALSE. 

I= 1 

CALL SCANI&295,IMAGE,I,FCNAME,LCNAME,11 

NAME=DBLNK 

CALL PACK(IMAGE(FCNAMEJ,NAME,LCNAME-FCNAME+1,8) 

CALL BFIND(&llO,NAME,NAMEPT,NAMES~PNTERS,IDIM) 

I=LCNAME+l 

CALL SCAN(&20,IMAGE,I,FCOP,J,1) 

IF(J.NE.FCOP+1) GO TO 20 

REL=BLANK 

CALL PACK(IMAGE(FCOPJ,REL,2,4) 

00 10 RCODE=1,7 

lf(RELS(RCOOE).EQ.REL) GO TO 30 

10 CONTINUE 

20 TYPE 320 

GO TO 144 

30 I=J+l 

CALL SCAN(&4Q,IMAGE,I,FCCON,LCCON,2) 

GO TO 140 

40 IVAL=BLANK 

GO TO 210 

295 RETURN 1 

140 J=ITYPE(NAMEPT) 

BE=RCODE. EQ. 7 

IF(BE) GO TO 220 

IF(IMAGE(FCCON).NE.LPAREN) GO TO 150 

lf(J.NE.5) GO TO 150 

IF(IMAGE(LCCONt.EQ.RPAREN) GO TO 142 

1405 TYPE 141 

GO TO 144 

142 IF(RCOOE.EQ.1) GO TO 145 

IF(RCODE.EQ.6) GO TO 145 

TYPE 143 

144 ERR=.TRUE. 

GO TO 210 

145 RCODE=RCODE+10 

I VAL=O 

FC CON= FCCON + 1 

LCCON=LCCON-1 

DO 147 K=FCCON,LCCON 

J= IMAGE(K) 

DO 146 I= 1, 6 

IF(IQUAL(I).EQ.J) GO TO 147 

146 CONTINUE 

GO TO 1405 

147 IVAL=IVAL+2**(1-1) 

GO TO 210 

110 TYPE 310, NAME 

GO TO 144 

150 GO TO (160,170,190,19t,170),J 

160 IVAL=ICONV(IMAGECFCCONt,LCCON-FCCON+1,E,ERR) 

GO TO 200 

'' 

0001556 

0001557 

0001558 

0001559 

0001560 

0001561 

0001562 

0001563 

OOC1564 

0001565 

OOC1566 

0001567 

0001568 

0001569 

0001570 

0001571 

0001572 

0001573 

0001574 

0001575 

0001576 

0001577 

0001578 

0001579 

000158C 

OOC1581 

0001582 

0001583 

0001584 

0001585 

0001586 

0001587 

0001588 

0001589 

0001590 

0001591 

0001592 

0001593 

0001594 

0001595 

0001596 

0001597 

0001598 

0001599 

0001600 

0001601 

0001602 

0001603 

0001604 

0001605 

0001606 

0001607 

0001608 

0001609 

0001610 

0001611 

0001612 

~J01613 
GRASP SOFTWARE SPECIFICATIONS 

170 K=ICONV(IMAGE(FCCON),LCCON-FCCON+1,E,ERR) 

IF (K.NE.BLANK) GO TO 180 

I VAL= K 

GO TO 200 

180 VAL=K*lO.**E 

I VAL= I VALL 

GO TO 200 

l9C IVAL=PNTER(IMAGEtfCCON),LCCON-FCCON+l,NAMEPT,J,ERR) 

200 IF (ERR) GO TO 210 

IF l.NOT.BEJ GO TO 210 

NBE=N BE+ 1 

IVALS(1,NBE)=IVAL 

I VAL=NB E 

210 RETURN 

220 DO 230 J=FCCON,LCCON 

IF (IMAGE(IJ.EQ.COMMA) GO TO 240 

230 CONTINUE 

TYPE 330 

GO TO 144 

240 GO TO (250,260,280,280,260),J 

250 IVAL=ICONV(IMAGE(l+1J,LCCON-I,E,ERR) 

GO TO 290 

2b0 K=ICONV(IMAGE(l+1t,LCCON-I,E,ERR) 

IF (K.NE.BLANK) GO TO 270 

IVAL=K 

GO TO 290 

270 VAL=K*lO.**E 

IVAL=IVALL 

GO TO 290 

280 IVAL=PNTER( IMAGE(I+l),LCCON-I,NAMEPT,J,ERR) 

290 IF (ERR) GO TO 210 

I VALS (2 ,NBE+1 J=IVAL 

LCCON=I-1 

GO TO 150 

141 FORMAT(' QUALIFIER CODES MUST BE ONE OR MORE OF "Lt ,N,T,G,H"', 

1 1 AND ENCLOSED IN PARENTHESIS.') 

143 FORMAT(' ONLY EQ/NE CAN BE USED WITH QUALIFIER CODES.') 

310 FORMAT ( 1 INVALID NAME= •,AS) 

320 FORMAT(' UNABLE TO FIND RELATION (LT,GT,LE,GE,EQ,NE,BE)') 

330 FORMAT ( 1 NO COMMA SEPARATING CONSTANTS FOLLOWING BE OPERATOR') 

END 

75 

0001614 

0001615 

0001616 

0001617 

OOC1618 

0001619 

0001620 

0001621 

0001622 

0001623 

0001624 

0001625 

0001626 

0001627 

0001628 

0001629 

0001630 

0001631 

0001632 

0001633 

0001634 

0001635 

0001636 

0001637 

0001638 

0001639 

OOC1640 

0001641 

ouot642 

0001643 

000164-4 

0001645 

0001646 

0001647 

0001648 

0001649 

0001650 

0001651 

0001652 

0001653 

0001654 
76 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: RETRVE 

Purpose: RETRVE is used to retrieve records from a selected 

file and write them on some other selected file. User-specified 

encoded retrieval criteria are passed to RETRVE via its 

argument list. 

Calling sequence: CALL RETRVE (&n,&m,IFILES,OFILES, 

NFILES,POLISH,LPS,V ARS,CODES,V ALS,NCOND) 

Arguments: 

n-Statement number (in calling routine) to which a branch 

is made if previously undetected (by LOGEXP) errors 

are encountered. 

m-Statement number (in calling routine) to which a branch 

is made if KEYBRD senses an EOF. 

!FILES, OFILES-Arrays of input and output file names, 

respectively. 

NFILES-Number of elements in either !FILES or 

OFILES (!FILES and OFILES are of equal size). 

POLISH-Array containing the Reverse-Polish form of the 

logic expression to be used for data retrieval. 

LPS-The number of elements in POLISH. 

VARS, CODES, VALS-Arrays that give an encoding of 

the conditional expressions entered by the user. 

NCOND-Number of e•lements in V ARS, CODES, and 

VALS. 

Subroutines called: KEYBRD, OBEY, GETPUT, COMP, 

UNCODE, PACK 

Common data referenced: 

FNAMES, SELECT in /FILNAM/ 

!TYPE in blank common 

INPUT, OUTPUT in /IOUNIT/ 

Called by: DRIVER 

Error checking and reporting: 

1. Check to assure entry of retrieval criteria (that is, LPS>O) 

2. Check to assure absence of undetected errors in the retrieval criteria. 

G R A S P S 0 U R C E 

Messages are typed corresponding to the two error situations above. 

Program logic: 

1. LPS is checked to insure that retrieval criteria have been 

entered. 

2. The elements of V ALS are moved to IV AL to allow the 

equivalencing necessary for mixed modes (in particular, 

integer and rea:l) possible in retrieval criteria. 

3. Input- and output-file names are prompted and accepted, 

then associated with FORTRAN unit numbers via calls to 

KEYBRD and OBEY. The new file names are added to 

!FILES and OFILES. 

4. The input file is then read, one record at a time (via 

GETPUT), until the nonstandard (EOF) return is taken. 

After each call to GETPUT, the record (IREC) is tested 

against the retrieval criteria indicated in POLISH, V ARS, 

CODES, and VALS via the logical valued push-down stack 

technique described as follows: Any element of POLISH 

less than 27 points to one of the conditional expressions encoded in VARS, CODES, VALS. That expression is evaluated via a reference to the logical function COMP, and the 

.result is placed in the push-down stack. If POLISH (I) >26, 

it points to one of the logical operators "and," "or," "not" 

(denoted by *, +, -) . If the operator is -, the "not" operation is performed on the topmost stack element. If the 

operator i.s * or +, the operation is performed on the topmost two stack elements, the size of the stack is decremented, 

and the resultant (!logical) value replaces the new topmost 

stack element. After the last element of POLISH has been 

processed, the size of the stack should be 1, and the value 

of this element indicates whether or not the record meets 

the retrieval criteria. If ,so, it is added to the output file 

by a call to GETPUT. Counts of records read and records 

retrieved are kept and typed at the end of retrieval processing. 

P R 0 G R A M 

SUBROUTINE RETRVE(*,*tiFILES,OFILES,NFILES,POLISH,LPS,VARS,CODES, 0001655 

0001656 

0001657 

0001658 

0001659 

0001660 

OOC1661 

0001662 

0001663 

0001664 

0001665 

0001666 

0001667 

0001668 

0001669 

0001670 

0001671 

0001672 

0001673 

0001674 

0001675 

1VALS,NCONDt 

COMMON NAMES,ITYPE,IPTS,IDIM 

COMMON /IOUNITI INPUT,OUTPUT 

COMMON IFILNAMI FNAMES,SELECT,PAD 

DIMENSION VAL(26) 

DOUBLE PRECISION NAMES(500t 

INTEGER IVAL(26),CODES(1),VARS(lt,wHICH,DREC(500),0UTPUT,TOP,POL 

1ISH(l),ITYPE(500J,ONE,TWO,VALS(l),EQUATE(4) 9 IPTS(5001,SELECT 

INTEGER FILEIO,OBLANK,IFILES(1),0fiLES(l),OFAULT,FNAMES(21) 

LOGICAL COMP,VALUE,STACK(20),EVAL,PA0(4) 

EQUIVALENCE (IREC,REC),(IVAL,VAL),(STACK,EVAL),(EQUATE(4),FILEID) 

DATA ONE , T WO , 0 BlANK I ' 1 1 , 1 2 1 , ' 1 I , E QUAT E I 1 E QUA 1 , 1 T E 1 • , 2 * ' • I 

If {LPS.GT.O) GO TO 10 

TYPE 180 

GO TO 170 

10 DO 20 I=1,NCOND 

2 0 I VAL ( I ) =VAL S ( I ) 

DFAULT=FNAMES(SELECTJ 

NRECS=O 

NFOUND=O 
NF IL E S=NF IL ES+ 1 

EQUATE( 3 )=ONE 

TYPE 190 

GRASP SOFTWARE SPECIFICATIONS 

CALL KEYBR0(&175,0REC,5) 

CALL PACK(OREC,FllEI0,5,5) 

IF (FILEIO.EQ.DBLANK) FILEIO=OFAULT 

IFILES(NfllfS)=fiLEIO 

CALL OAEV(&170,EQUATE,4) 

EQUATE( 3)=TWO 

TYPE 210 

CALL KEYBR0(&175,DREC,5) 

CALL PACK(DREC,FILEI0,5,5) 

OFILES ( NF IL ES )=FILE ID 

CALL OBtY(&170,EQUATE,4) 

30 CALL GETPUT(&140,DREC,1) 

NRECS=NRECS+1 

TOP=O 

DO 110 J= 1, LPS 

INDEX=POLISH(Jt 

IF (INDEX.GT.26t GO TO 70 

TOP=TOP+ 1 

WH I CH =VA R S ( I NO E X) 

l=ITYPE(WHICH) 

I REC= OR EC (WHICH) 

GV TO (40,50,40,60,62), I 

40 STACK(TOP)= COMP(IREC ,IVAL(INOEX),01,02,COOES(INDEX),1) 

GO TO 110 

50 STACK(TOP)= COMP(10l,I02,REC ,VAL(INOEX),COOEStiNDEX),2) 

GO TO 110 

6C STACK(TOPt= COMP(IREC ,IVAL(INOEX),Ol,02,COOES(INDEX),3J 

GO TJ 110 

62 IF(IREC.NE.OBLANK) GO TO 63 

IFtCDDES(INDEX).LT.lll GO TO 50 

STACKCTOP)=.FALSE. 

GO TO 110 

63 REC=UNCODE(REC,IQ) 

IF(CODES( INOEX)-11) 50,64,66 

64 STACK(TOP)=M00(1VAL(INDEX)/2**(1Q-1),2).EQ.1 

GO TO 110 

66 STACKtTOP)=MOD(IVAL(INOEX)/2**(IQ-11,2).EQ.O 

GO TO 110 

7u VALUE=STACK(TQP) 

IF (INDEX-30) 80,90,100 

80 TOP=TOP-1 

STACK(TOP)=STACK(TOP).OR.VALUE 

GO TO 110 

90 TOP=TOP-1 

STACK(TOP)=STACK(TOP).AND.VALUE 

GO TO 110 

100 STACK(TOP)=.NOT.STACK(TOP) 

110 CONTINUE 

IF (TOP.EQ.1) GO TO 120 

TYPE 220 

REW I NO INPUT 

RETURN 1 

120 IF (EVAL) GO TO 130 

GO TO 30 

130 CALL GETPUT(&l40,DREC,2) 

NFOU~ 0= NFOU ND+1 

GO TO 30 

77 

0001&76 

0001677 

0001678 

0001&79 

0001680 

0001681 

0001682 

0001683 

0001684 

0001685 

0001686 

0001687 

0001688 

0001689 

0001690 

0001691 

0001692 

0001693 

0001694 

0001695 

0001696 

0001697 

0001698 

0001699 

0001700 

0001701 

0001702 

0001703 

~0~1704 

0001705 

0001706 

0001707 

0001708 

0001709 

000171C 

0001711 

0001712 

0001713 

0001714 

0001715 

0001716 

0001717 

0001718 

0001719 

0001720 

0001721 

0001722 

0001723 

0001724 

0001725 

OJJ1726 

0001727 

0001728 

0001729 

aoo 1130 

0001731 

0001732 

0001733 

0001734 

0001735 
78 GEOLOGIC RETRIEVAL AND SYNPOSIS PROGRAM (GRASP) 

140 TYPE 230, NRECS,IFILES(NfiLES) 

IF (NfOUND.GT.O) GO TO 150 

TYPE 240 

NFI L ES=NF IL ES-1 

GO TO 160 

150 TYPE 250, NFOUND,FILEID 

160 REWIND INPUT 

REWIND OUTPUT 

170 RETURN 

0001736 

0001737 

0001738 

0001739 

0001740 

0001741 

0001742 

0001743 

0001744 

J001745 

(' LOGIC MUST BE SUPPLIED BEFORE 

( ' EN T E R I N P U T f I l E NA ME : 1 , $ ) 

(' ENTER OUTPUT FILE NAME: 1 ,$) 

175 RETURN 2 

180 FORMAT 

190 FORMAT 

210 FORMAT 

220 FORMAT 

230 FORMAT 

240 fORMAT 

250 FORMAT 

A RETRIEVAL CAN BE MADE') 0001746 

0001747 

0001748 

1 E BEEN 

END 

(' ERROR IN LOGIC EXPRESSION') 

( 1 ALL',I6,' RECORDS OF 1 ,A6, 1 SEARCHED. 1 J 

( 1 THERE ARE NO RECORDS WHICH SATISFY THE REQUEST') 

(110, 1 RECORDS FOUND WHICH SATISFY THE REQUEST.'/' THEY 

STORED IN 1 ,A6) 

0001749 

0001750 

0001751 

HAV0001752 

0001753 

0001754 
GRASP SOFTWARE SPECIFICATIONS 79 

SUBROUTINE NAME: RLIST 

Purpose: RLIST is used to convert an unpacked character 

string representing a list of user-entered numbers into a 

correSJPonding numeric list. 

Calling sequence: CALL RLIST(&n,IMAGE,LIST,NUMC, 

MOST) 

Arguments: 

n-Statement number (in caller) to which a branch will be 

made if an uncorrectable error in the entered character 

string is detected. 

IMAGE-The unpacked character-string form of the list 

of numbers. 

LIST-The list of numbe1~s which are returned in numeric 

form. 

NUMC-The number of items in LIST. 

MOST-The maximum number of items that LIST may 

contain. 

Subroutines called: None 

Common data referenced: None 

Called by: DEFLST, QUIT 

Error checking and reporting: If an illegal character (not 

0~9, dash, or comma) is detected, an error message is 

typed and the nonstandard return is taken. If the list isn't 

G R A S P S 0 U R C E 

composed of numbers or number ranges separated by commas, an error message is typed, and the nonstandard return is taken. 

Program logic: Each character of the unpacked string is proc-

·essed via the following transition matrix: 

Q-9 

1. f (1) /2 error 2. f(2)/2 f(3)/1 3. f(l)/4 error 4. f(2)/4 f(4)/1 

f ( i) are defined as : 

f ( 1) -Start a number value. 

error 

f(3)/3 

error 

error 

f(2)-Build number value by adding digit on right. 

f(3)-Number built, add it to list. 

f(4)-Fill LIST with values up to and including current 

value. 

Rows 1 and 2 are used to process a single list element or 

the first of a number-range pair. 

Rows 3 and 4 are used to process the second of a number-range pair. Blanks are completely ignored. 

The columns of the transition matrix are associated with 

the indicated characters, and the rows correspond to individual states. 

P R 0 G R A M 

SUBROUTINE RLIST(*,IMAGE,LIST,NUMC,MCST) 0001755 

0001756 

0001757 

0001758 

0001759 

0001760 

0001761 

0001762 

0001763 

0001764 

0001765 

0001766 

0001767 

0001768 

0001769 

0001770 

0001771 

0001772 

0001773 

0001774 

0001775 

0001776 

0001777 

0001778 

0001779 

0001780 

0001781 

0001782 

0001783 

0001784 

0001785 

INTEGER LIST(l),IMAGE(3Q),CHAR(12),COL(12),1MAT(4,3) 

DATA IMAT/12,22,14,24,C,3l,C,4l,0,33,0,0/,IBLNK/ 1 1 / 

0 AT A cHAR I • 0 ' ' t 1. ' • 2. ' • 3 I ' • 4. ' I 5 ' ' • 6. ' • 1 • ' • 8. ' • 9. ' • ' • '. -. I 

DATA COL/10*1,2,3/ 

NUMC=C 

LAST= 1 

IP=O 

I ROW= 1 

10 IP=IP+l 

IF (IP.GT.30) GO TO 120 

I CHAR= IMAGE ( I P ) 

IF ( I CH A R • E Q • I B l N K ) GO T 0 1 0 

DO 20 1=1,12 

IF (ICHAR.EQ.CHAR( 1)) GO TO 40 

20 CONTINUE 

TYPE 150, ICHAR 

30 RETURN 1 

35 TYPE 145,IVAL 

GO TO 30 

40 IFS=IMAT(IROW,COL(I)) 

IF (lFS.NE.O) GO TO 60 

50 TYPE 160 

GO TO 30 

60 IROW=M00(1FS,10) 

IFS=IfS/10 

GO TO (70,80,90,100), IFS 

70 IVAL=I-1 

GO TO 10 

80 IVAL=10*1VAL+I-l 

GO TO 10 
80 GEOLOGIC RETRIEVAL AND SNYPOSIS PROGRAM (GRASP) 

90 NUMC=NUMC+1 0001786 

IF (NUMC.GT.MOSTI GO TO 110 0001787 

IF(IVAL.GT.MOST) GO TO 35 0001788 

LIST(NUMCt=IVAL OOC1789 

GO TO (10,140), LAST 0001790 

100 LIST(NUMC+l)=LIST(NUMC)+l 0001791 

NUMC=NUMC+l 0001792 

IF (NUMC.GT.MOST) GO TO 110 0001793 

IF(IVAL.GT.MOST) GO TO 35 00u1794 

IF (LIST(NUMC).LT.IVAL) GO TO 100 0001795 

GO TO (10,140), LAST 0001796 

110 TYPE 170, MOST 0001797 

NUMC=MOST 0001798 

GO TO 140 0001799 

120 IF (NUMC.NE.OI GO TO 130 0001800 

IF (IROW.EQ.1) GO TO 140 0001801 

NUMC=1 0001802 

LIST(1)=1VAL 0001803 

GO TO 140 0001804 

130 IF (MQO(IROW,2t.NE.OI GO TO 50 0001805 

LAST=2 0001806 

IROW=IROW/2 0001807 

GO TO (90,100), IROW 0001808 

140 RETURN 0001809 

145 FORMAT(I5,' DOES NOT CORRESPOND TO A CATEGORY. RE-ENTER NUMBERS') 0001810 

150 FORMAT (lX,Al,• IS AN ILLEGAL CHARACTER. RE-ENTER NUMBERS.' t 0001811 

160 FORMAT (' EACH NUMBER OR NUMBER RANGE (IE. 4-7) EXCEPT •,•THE l~ST0001812 

1 MUST BE FJLLOWED BY A COMMA. 1 / 1 RE-ENTER NUMBERS.•) 0001813 

170 FORMAT (' TOO MANY NUMBERS GIVEN. ONLY THE FIRST',I3, 1 WILL BE USE0001814 

10. 1 ) 0001815 

END 0001816 
GRASP SOFTWARE SPECIFICATIONS 

SUBROUTINE NAME: ROWPNT 

Purpose: ROWPNT prints selected items or expressions, one 

to a line, from a selected file. 

Called by: LIST 

Error checking and reporting: None 

Program logic: 

81 

Calling sequence: CALL ROWPNT(&n,NPAGE) 

Arguments: 

n-Statement (in caller) to which VLIST will branch when 

an EOF is encountered by KEYBRD. 

1. The list of items to be printed is obtained via a call to 

VLIST. 

NPAGE-Number of lines per page of printed output. 

2. A caB to ACCESS is made to initialize the lookup of dictionary-type items. 

Subroutines called: VLIST, ACCESS, GETPUT, PAUSE, 

EVAL, UNCODE, BINTYP, BLIST 

Common data referenced: 

3. Each record of the ,selected file is obtained via GETPUT 

and a line counter is incremented and tested. If it exceeds 

the page size, a pause is generated via PAUSE. 

POLISH, !CODE, LPS in /EXPRNS/ 

ITYPE in blank common 

4. After each record is obtained, the selected items are evaluated (if necessary) and printed. 

G R A S P S 0 U R C E 

SUBROUTINE ROWPNT(*,NPAGE) 

COMMON NAMES,ITYPE,IPTS,IPAD 

COMMON /E XPRNS/ POLISH, ICODE, LPS 

P R 0 G R A M 

DOUBLE PRECISION NAMES,LABEL,NAMESI,VNAMES(20) 

INTEGER BlANK,TANK,IPTSC500),1QUALC6J,POLISH(15,8), 

1 ICODE(15,8),LPSC8) 

DIMENSION ITYPEC500), BITEM(l5,25), ITEMS(20), IRECC500J, 

1 REC(500), NAME$(500), TANK(25), LABEL(25), LIST(25) 

LOGICAL ERR 

EQUIVALENCE (REC,IREC),(IVAL,VAL),(LIST,TANK),(BLANK,IQUAL) 

DATA IQUAL/ 1 1 , 1G1 , 1H1 , 1 L1 , 1 N1 , 1 T1 / 

KOUNT=O 

CAll VLIST(&270,VNAMES,ITEMS,NUM) 

IF (NUM.EQ.O) GO TO 260 

TYPE 280 

CALL ACCESSCII,IVAL,TANK,J,1) 

12u CALL GETPUT(&260,IREC,l) 

KOUNT=KOUNT+NUM+1 

If (KOUNT.LE.NPAGEt GO TO 130 

KOUNT=O 

CALL PAUSE ( &260) 

130 DO 240 JJ=l,NUM 

I I= IT EMS ( JJ ) 

IF(II.GT.O) GO TO 135 

I I=- I I 

NAMESI=VNAMES(JJ) 

VAl=EVAL(IPEC,ICOOE(1,IIJ,POLISHl1ell),LPS(II),ERR) 

IF(ERRt GO TO 240 

GO TO 150 

135 IVAL=IREC(Il) 

If (IVAL.EQ.BLANK) GO TO 240 

KIND=ITYPE(II) 

NAMESI=VNAMESCJJ) 

GO TO (140,150,160,220,170), KIND 

140 TYPE 300, NAMESI,IVAL 

GO TO 240 

150 TYPE 310, NAMESI,VAL 

GO TO 240 

160 CALL ACCESSCII,IVAL,TANK,J,2) 

TYPE 320, NAMESI,(TANK(I),I=1 9 J) 

GO TO 240 

0001817 

0001818 

0001819 

0001820 

0001821 

0001822 

0001823 

0001824 

0001825 

0001826 

0001827 

0001828 

0001829 

0001830 

0001831 

0001832 

0001833 

0001834 

0001835 

0001836 

0001837 

0001838 

0001839 

0001840 

0001841 

0001842 

0001843 

0001844 

0001845 

0001846 

0001847 

0001848 

0001849 

0001850 

0001851 

00018 52 

0001853 

0001854 

0001855 

0001856 

0001857 
82 GEOLOGIC RETRIEVAL AND SNYPOSIS PROGRAM (GRASP) 

17C VAl=UNCODECVAL,IQ) 0001858 

TYPE 310,NAMESI,VAL,IQUAL(IQ) 0001859 

GO TO 240 OOC1860 

220 CALL BINTYP(li,LABEL,BITEM,K,M) 0001861 

KOUNT =KOUNT +l 0001862 

TYPE 340, NAMESI 0001863 

CALL BLIST(LIST,NUMS,IVALI 0001864 

DO 230 I=l,NUMS 0001865 

KOUNT=KOUNT+l 0001866 

J =LIST ( I) 0001867 

230 TYPE 330, LABEL(J),(BITEM(L,J),L=1,K) 0001868 

240 CONTINUE 0001869 

TV PE 290 ouo1a7o 

GO TO 120 0001871 

26C RETURN 0001872 

270 RETURN 1 0001873 

280 FORMAT ,,,,, 0001874 

290 FORMAT (1X,3(8H********t) 0001375 

30C FORMAT ( l X , AS , 1 H=, I 9 ) 0001876 

310 FORMAT (1X,A8,lH=,lPG12.5,A1) 0001877 

320 FORMAT (1X,A8,1H=,l2A5/l5X,l2A5) 0001878 

330 FORMAT (5X,A8,15A4) 0001879 

340 FORMAT (1X,A8,1H=) 0001880 

END 0001881 
GRASP SOFTWARE SPECIFICATIONS 83 

SUBROUTINE NAME: SCAN 

Purpose: This subroutine is used to set character-position 

pointers for the syntactic elements of a condition (name, 

relation, value ( s) ) or a logical expression. 

Calling sequence: CALL SCAN(&n,IMAGE,IS,Il,I2,IT) 

Arguments: 

n-Statement number (in calling routine) to which a 

branch will be made if IMAGE is all blanks. 

IMAGE-String of unpacked left-justified characters. 

IS-Starting position of the scan. 

11-Pointer to first character of syntactic element. 

I2-Pointer to last character of syntactic element. 

IT-Embedded blank switch. 

G R A S P S 0 U R C E 

Subroutines called: None 

Common data referenced: None 

Called by: RELEXP, LOGEXP 

Error checking and reporting: None 

Program logic: 

1. The position of the first nonblank character is determined. 

2. If all characters after the IS'th are blank, the nonstandard 

return is taken. 

3. If no embedded blanks are permitted (IT=1), the position 

of the last nonblank character to the right of the position 

found in step 1 is determined, and control passes to the caller. 

4. Otherwise (if, IT=2.), the position of the first nonblank 

character to the left of position 80 is determined and control 

returns to the caller. 

P R 0 G R A M 

SUBROUTINE SCAN(*, IMAGE,IS, 11,12,ITI 

INTEGER IMAGE(lJ 

0001882 

0001883 

0001884 

0001885 

0001886 

0001887 

0001888 

0001889 

0001890 

0001891 

0001892 

0001893 

0001894 

0001895 

0001896 

0001897 

0001898 

0001899 

0001900 

0001901 

0001902 

0001903 

OAT A I B l NK I ' ' I 

DO 1 I=IS,80 

IF(IMAGE(IJ.NE.IBLNKJ GO TO 2 

1 CONTINUE 

RETURN 1 

2 I 1= I 

J=l1+1 

G 0 TO ( 3, 10 ) , IT 

3 DO 4 12=J,80 

IF(I~AGE(l2).EQ.IBLNKJ GO TO 5 

4 CONTINUE 

12= 81 

5 I 2= 12-1 

6 RETURN 

10 DO 11 I=J,80 

12=80-1 +J 

IF(IMAGE(I2).NE.IBLNK) GO TO 6 

11 CONTINUE 

GO TO 6 

END 
84 GEOLOGIC RETRIEVAL AND SNYPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: START 

Purpose: START determines availability of data bases and 

Called by: DRIVER 

Error checking and reporting: None 

Program logic: their associated files. 

Calling sequence: CALL START 

Arguments: None 

1. The name GFILE is associated with FORTRAN input 

unit 20. 

Subroutine called: I FILE 

2. A welcoming message is typed and records of GFILE are 

read to fill the /FILNAM/ common area. 

Common data referenced: 

All variables in /FILN AM/ except NUMF 

3. As each record is read, parts of it are output to the terminal. 

G R A S P S 0 U R C E P R 0 G R A M 

SUBROUTINE START 

COMMON /FILNAM/ MASTER 1 MASK,OEFTN 1 0FILE,BFILE,NUMF,NUHI,IOIMS 

DOUBLE PRECISION CONTNT(4) 

INTEGER MASTER(4J,MASK(41,DEFTN(4J,OFILE(4),8FILE(4),101MS(4) 

CALL IFILE(20, 1 GFILE') 

NUMf= 1 

TYPE 1 

10 REA0(20tl1,END:20) MASTERCNUMFJ,CONTNT,MASK(NUMFJ, 

1 DEFTN(NUMF),OFILE(NUMFJ,BFILE(NUMFJ,IOIMS(NUMFJ 

TYPE 12,MASTERCNUMFt,CONTNT 

NUMF=NUMF+l 

GO TO 10 

20 NUMF=NUMF-1 

REWIND 20 

TYPE 2 

RETURN 

1 FORMAT(/' WELCOME TO THE USGS GRASP RETRIEVAL SYSTEM.'/ 

1 1 AT THE CURRENT TIME THE FOLLOWING DATA BASES ARE AVAILABLE:') 

2 FORMAT(/ 1 BEFORE ANY OF THESE DATA BASES MAY BE ACCESSED,'/ 

1 1 THE 11Fil E" COMMAND SHOULD BE USED TO IDENTIFY THE OAT A', 

2 ' BASE Of INTEREST.' J 

11 FORMAT(A5,1X,4Al0,4(1X,A5),141 

12 FORMAT(/1X,A6, 1 - 1 ,4Al0) 

END 

0001904 

0001905 

0001906 

0001907 

0001908 

0001909 

0001910 

0001911 

J001912 

0001913 

0001914 

0001915 

0001916 

0001917 

0001918 

0001919 

0001920 

0001921 

0001922 

0001923 

0001924 

0001925 

0001926 

0001927 
GRASP SOFTWARE SPECIFICATIONS 85 

FUNCTION NAME: UNCODE 

Purpose: UNCODE breaks down each qualified real value into 

a real value and a qualifier code. 

Calling sequence: VALUE=UNCODE(VAL,ID) 

Arguments: 

VAL-Packed value and qualifier. 

ID-Encoding of qualifier value. 

Subroutines called: None 

Common data referenced: None 

Called by: COLPNT, DUMPIT, FIT, MEAN, RETRVE, 

ROWPNT, EVAL 

Error checking and reporting: None 

Program logic: The type REAL argument VAL may be visualized as composed of both whole and fractional parts. ID is 

set to the 3 low-order bits of the whole part. The whole part 

is then shifted right 3 bits, and the result is added to the 

fractional part to form the value returned by the function. 

G R A S P S 0 U R C E PROGRAM 

FUNCTION UNCOOE(VAL,ID) 

RSIGN=SIGN(l.O,VAL) 

V Al = A B S ( VAL ) 

IPART=VAL 

RE ST=VAL-IPART 

I 0= M 0 0 ( I P ART , 8 ) 

UNCOOE=RSIGN*((JPART/8)+REST) 

RETURN 

END 

0001928 

0001929 

0001930 

0001931 

0001932 

0001933 

0001934 

0001935 

0001936 
86 GEOLOGIC RETRIEVAL AND SNYPOSIS PROGRAM (GRASP) 

SUBROUTINE NAME: VLIST 

Purpose: VLIST prompts for and accepts (via KEYBRD) a 

set of item names or arithmetic expressions that will be 

printed by the caller. The user is provided the ability to reuse 

the list that was last entered. 

names. If not, the values of the arguments as set by a previous call are returned. Otherwise, a new list is processed 

as below. 

2. The routine requests the user to enter a set of item names 

or expressions. Each entry is processed as specified below 

until a blank entry is detected. Control is then returned to 

the caller. Calling sequence: CALL VLIST(&m,VNAMES,LIST,N) 

Arguments: 

m-Statement number (in caller) to which a branch will be 

made if an EOF is sensed by KEYBRD. 

VNAMES-List of item names to be printed. 

LIST-Item numbers corresponding to VNAMES. 

N-Number of elements in VNAMES and LIST. 

Subroutines called: KEYBRD, SCAN, BFIND, PREVAL, 

PACK 

Common data referenced: 

NAMES, PNTS, !DIM in blank common 

Called by: BDEF, COLPNT, ROWPNT 

Error checking and reporting: None 

Program logic: 

1. The user is asked if he wishes to enter a new list of item 

G R A S P S 0 lJ R C E 

3. An entry is accepted via KEYBRD, and leading and/or 

trailing blanks are eliminated via SCAN. 

4. If the entry length is greater than seven characters, an 

expression is assumed. If the entry is not found to be an 

item name (via BFIND), an expression is assumed. 

5. If the entry is determined to be an item name, that name 

is stored in VNAMES, and the corresponding item number 

is stored in LIST. 

6. If the entry is an expression, a call to PREV AL is made 

to parse it into Reverse-Polish form for later evaluation. 

KNT points to the Reverse-Polish form (stored in /EXPNS/ 

by PREV AL), and the negative of KNT is returned in LIST. 

7. The values of the arguments are saved for future calls if 

required. 

P R 0 G R A M 

SUBROUTINE VLISTC*,VNAMES,LIST,Nl 0001937 CO~MON NAMES,TYPE,PNTS,IDIM 0001938 

DOUBLE PRECISION NAMESC500),NAME,BLANK,VNAMES(1),VSAVE(20t 0001939 

INTEGER PNTSC500),TYPEt500),LIST(1),EXPR(80),HALVESC2),EXPHDGC20) OG01940 

1 ,LSAVEC20) 0001941 

EQUIVALENCE (HALVES(1J,NAME) 0001942 

DATA IEQUAL,BLANK/'='•' 'I,NSAVE,NO/O,'N'/ 0001943 

DATA EXPHDG/ 1 1. 1 , 1 2.', 1 3. 1 , 1 4. 1 , 1 5.','6.','7.•,•8.','9.','10.','110001944 

1 •• ' • J. 2 • • ' • 1 3 •• ' • 14. • ' • 1 5 •• ' • 1 6. I ' • 1 1. • ' • 1 8. ' ' • 1 9 •• ~ • 2 0 •• I 0 0 0 19 4 5 

IFCNSAVE.EQ.O) GO TO 5 0001946 

TYPE 4 0001947 

CALL KEYBRDC&110,I,l) J001948 

IF(I.NE.NO) GO TO 5 0001949 

N:NSAVE 0001950 

DO 6 1=1,NSAVE 0001951 

LIST(I)=LSAVE(l) 0001952 

6 V NAME S ( I ) = V SA VE C I ~ 0 0 0 19 53 

GO TO 130 0001954 

5 N=O 0001955 

KNT=O 0001956 

TYPE 120 0001957 

10 N=N+1 0001958 

TYPE 140, EXPHDG(N) 0001959 

CALL KEYBRD(&llO,EXPR,80t 0001~60 

CALL SCAN(&ll5,EXPR,l,Ll,L,2) 0001961 

IFCL-L1.GT.6) GO TO 60 0001962 

L2=L1+6 0001963 

NAME=BLANK 0001964 

CALL PACK(EXPR(ll) ,NAME,L2-Ll+1,8) 0001965 

CALL BFIN0(&60,NAME,I,NAMES,PNTS,JDIM) 0001966 

30 VNAMESlNt=NAME 0001967 

LIST(N)=I 0001968 

IF (N.E0.20) RETURN 0001969 

GO TO 10 0001970 
60 IF (KNT.EQ.8) RETURN 

NAME= BLANK 

DO 70 K=l,10 

GRASP SOFTWARE SPECIFICATIONS 

IF (EXPR(K+ll-1).EQ.IEQUAL) GO TO 80 

70 CONTINUE 

K=l 

HALVES(2)=EXPHOG(N) 

GO TO 90 

80 J=MINO(K-1,7)+L1-1 

CALL PACKCEXPR(ll),NAME,J -L1+1,8) 

K=K+1 

90 CALL PREVAL(&100,EXPR(K+Ll-1),L,KNTI 

1=-KNT 

GO TO 30 

100 N=N-1 

GO TO 10 

110 RETURN 1 

115 N=N-1 

NSAVE=N 

DO 116 I= 1, NSA VE 

LSAVE(I)=LIST( I) 

116 VSAVE(I)=VNAMES(I) 

130 RETURN 

4 fORMAT(' DO YOU WISH TO ENTER A NEW LIST Of NAMES OR', 

1 ' EX PRES SI ONS? (YES OR NO): 1 , $) 

120 FORMAT(' ENTER THE NAMES OF ITEMS OR THE EXPRESSIONS •, 

1'WHICH YOU WANT PRINTED.') 

140 FORMAT (1X,A4,$) 

END 

87 

0001971 

0001972 

0001973 

0001974 

0001975 

0001976 

000197,7 

0001978 

0001979 

0001980 

0001981 

0001982 

0001983 

0001984 

0001985 

0001986 

0001987 

0001988 

0001989 

0001990 

0001991 

0001992 

0001993 

0001994 

0001995 

0001996 

0001997 

0001998 

0001999