CHAPTER 3    CONVENTIONS FOR PROGRAMMING IN MIIPS

                                  





                 The following conventions should be adopted for the  program

            modules of the MIIPS package of programs and related programs.



        1.  Each subroutine for an option should begin with the format  given

            in the following example.



            SUBROUTINE LINEPL

            ENTRY LINEPL_SHARE



        C        This subroutine will plot a cut through a two-dimensional

        C   file.  One can plot a row, a column, or a cut at any angle and

        C   send the output to the graphics package or the Printronix.

        C   Cursor input from the Grinnell is also possible.

        C                  First_Name Last_Name, Month Day, Year

        C                  Version 2, First_Name Last_Name, Month Day, Year

        C                  Added code for Trapix




        2.  Insert comments to explain the variables  in  an  argument  list.

            "C"  and  "R"  stand  for arguments which are given values in the

            call   or   are   given   values    upon    return    from    the

            subroutine.  For the subroutine        PROBABLE2DS(LU,DATA,NX,NY,

            ISX,ISY,IBIN,NBINS,PROBABLEVAL,SIGMA) we therefore have:



        C   LU             (C)  The logical unit

        C   DATA           (C)  The array

        C   NX             (C)  Dimension in the X direction and  the  number

                                of pixels to be read

        C   NY             (C)  Dimension in the Y direction and  the  number

                                of pixels to be read

        C   ISX            (C)  The starting column in the map  (IHED(9)  not

                                subtracted off)

        C   ISY            (C)  The starting row in  the  map  (IHED(11)  not

                                subtracted off)

        C   PROBABLEVAL    (R)  The most probable value of the pixels in  the

                                array

        C   SIGMA          (R)  The mean error



        3.  Use comments liberally in the  source  code.   When  the  comment

            precedes  the  code  referred  to, use the imperative grammatical

            case; when the comment follows  the  code  referred  to  use  the

            present  tense.   Put a C in column one and skip two spaces for a

            preceding comment and skip two spaces and insert a !  followed by

            a space for a following comment.  Use mixed cases, e.g.,



        C   Transfer one file to disk

            DO 28 J = 1,64  ! Starts the loop for reading NOVA records



                 If you are debugging a subroutine which is not one which you

            have  written,  please  add comments as you decipher the mess and

            bring it up  to  the  conventions  described  herein.   Use  good

            english,  do not abbreviate, avoid the use of indefinite articles

            such as "it" which result in ambiguities, and observe the  proper

            typing  conventions  of five spaces when indenting and two spaces


                                                                Page 2





            following a period, colon, and semicolon.



        4.  Use the tab control on the terminal for the  initial  indentation

            for  the  source  code;  keep  it  at  9,  17,  25,  etc.   For a

            continuation use the tab followed by a numeral.



        5.  Use columns 1 through 4 for statement  labels  (right  justified)

            and  then  use  the tab.  FORMAT labels should be 1000 and higher

            and should be positioned in the source code at their first usage.



        6.  Indent an additional 2 spaces for all code within a DO loop or IF

            block.  For example:

            DO I=1,3

              CALL OPENMS (I+10,.TRUE.,'FILE','',0)

              NROWS(I)=I4MHV(I+10,1,'NROWS',0)

              IF  (NROWS.NE.512) THEN

                CALL MESSAGE('WRONG MAP SIZE')

                GO TO 100

              ELSE

                DO J=1,NROWS

                  CALL ROMROW(I+10,1,DATA,320,J)

                  DO II=1,320

                    DATA(II)=DATA(II)*SCALE

                  END DO

                END DO

              END IF

            END DO



        7.  Do  not  proliferate  variable  names.   The  use  of  arithmetic

            expressions  within  the  limits  of  a  DO loop can help in this

            regard.   Do  not  use  short  variable  names  which   give   no

            description of what the variable's purpose is, e.g., use BUFFRLEN

            istead of LB.  Avoid the use of implicitly defined  variables  if

            the  meaning  would  be  obscured.   In order to make the FORTRAN

            commands resemble english as much as possible, use END IF  rather

            than ENDIF and similarly for other commands.



        8.  For all subroutines called as an option, place the  variables  in

            the  COMMON  blocks  SCRATCHBLOCK and CHARSCRATCHBLOCK.  Refer to

            the list of additional COMMON blocks in current usage  in  "MIIPS

            Notes".



        9.  Avoid using dummy variables equated to variables in  an  argument

            list  for those subroutines which are called by one of the option

            subroutines.  Doing so increases the memory requirement.  Put the

            variable in the SCRATCHBLOCK in the option subroutine.



       10.  USRINP  and  associated  routines  should   be   used   for   all

            interaction.   When  using  one  of  the  graphics options direct

            USRINP prompts to the Grinnell via USRINPG and GTEXT  if  it  has

            been assigned and if the prompts number more than one.



       11.  Keywords passed  by  USRINP  should  be  in  upper  case.   Other

            information  messages  may  be in the normal English mixed cases.

            For greater legibility use upper case only for USRINPG.


                                                                Page 3





       12.  Use CALL MESSAGE and GTEXT  to  output  messages  and  text.   If

            outputting numbers, write them to the log file also.



       l3.  The message part of a USRINP or USRINPG  call  which  requires  a

            logical  response  should be phrased as a question and terminated

            with a "?".  Other messages should be phrased as a direction  and

            should be terminated with a colon.



       14.  Use "Enter" instead of "Type" when requesting input from the user

            as they have different meanings.



       15.  When requesting file specifications the order of  request  should

            be read file(s) followed by write file(s).



       16.  The X and Y directions of an  image  should  be  referred  to  as

            columns and rows, respectively, and in that order.



       17.  Under normal circumstances when requesting  boundaries  from  the

            user, the request should be of the form:

            Enter start-column end-column start-row end-row:

            (default = entire map)

            BOUNDARIES=