Page 127 - Standard Handbook Of Petroleum & Natural Gas Engineering
P. 127

112   Mathematics


                         their subscripts, the number of subscripts being determined by  the dimen-
                         sionality of the array. An element is referred to by  the array name followed
                         by  its  parenthesized  subscripts, e.g.,  TEMP(  IJ)  might  refer  to  the  tem-
                         perature at the Ith time increment  and  at  the Jh  pipe node.
                       3. Record-A  collection  of data items  (fields) of various  types, which may also
                         be records themselves. If  EMPl  is a record in the master  file of employees,
                         EMP1.NAME may  be  a  character  field,  EMPl.ZIP  an  integer  field,  and
                         EMPlSAL a  real  field.
                       4. File-Collection  of records that normally consist  of matching types of fields.
                         Records in a file may be accessed  sequentially (the entire file must be read
                         until  the  needed  record  is  reached)  or randomly  (the record  contains a
                         key  field, which  determines its  physical  location in  storage).
                       5. Linked lists-Data  items linked by  pointers. In the general form, each item,
                         except the first, has one predecessor, and each item, except the last, has
                         one  successor, with  pointers  linking  items  to  their  successors. Doubly  linked
                         lists have  pointers to both  the predecessor and the  successor of  an item and
                         a circular list  has  a pointer  from the final item  to  the initial  item (producing
                         a predecessor  to the initial item and a successor to the final item). Restricted
                         lists also  exist, such  as stacks,  where  items  may  only  be  added  (pushed) or
                         deleted  (popped) at  one  end  (the top), and  queues,  where  items  must  be
                         inserted  at one  end  and  deleted  from  the  other.  Trees  are  linked  lists  in
                         which each item  (node) except the root node has one predecessor, but all
                         nodes may  have any finite number, or zero, successors; graphs contain  both
                         nodes and edges, which  connect the nodes and define their relationships.
                                             Program Statements

                       The  statements of  which  the  program  consists  may  be  either  executable  or
                     nonexecutable. Nonexecutable statements consist  of  comments, which  explain  the
                     data  and  logic  of  the  program,  and  declarations,  which  are  orders  to  the
                     translator  or  to  other  system  programs  and  which  usually  serve  to  allocate
                     memory  space  for data.
                       Executable statements, which are translated into machine code, are instructions
                     by  which  operations  are  performed  on  data  or by  which  the  sequence  of
                     execution is  changed. Statements producing operations on data  are:

                       1. Assignment-Assign  a  value,  either  a  constant  or  a  computed  value,  to  a
                         variable,  an array element, a  node, or a  field.
                       2.  Input-Transfer  data from external devices, such as a keyboard or disk file,
                         to  the program.
                       3.  Output-Transfer  data from the  program  to  an external device,  such  as  a
                         printer,  screen, or a  disk  file.
                       Executable statements affecting  the order in  which  the program  instructions
                     are  executed  include  conditional  (branching) statements,  iterative  (looping)
                     statements, and statements which  call  subprogram units.
                       1. Conditional  statements-Change  the  sequence  in  which  instructions  are
                          executed depending upon the logical relationship(  s) between variables and/
                          or between  variable(s) and  set  value(s).
                       2.  Iterative statements-Force  the repetition of instructions depending on preset
                          conditions.
                       3.  Calling statements-Transfer  control to  a subprogram unit,
   122   123   124   125   126   127   128   129   130   131   132