C                                                            <HTML><PRE>
C Program GRDRAN to compute the pseudorandom numbers distributed
C uniformly between -0.5 and 0.5 on the input grid.
C
C Version: 5.40
C Date: 2002, May 20
C
C Coded by Petr Bulant
C     Department of Geophysics, Charles University Prague,
C     Ke Karlovu 3, 121 16 Praha 2, Czech Republic,
C     E-mail: bulant@seis.karlov.mff.cuni.cz
C
C.......................................................................
C                                                    <A NAME="data"></A>
C Description of data files:
C
C Input data read from the standard input device (*):
C     The data are read by the list directed input (free format) and
C     consist of a single string 'SEP':
C     'SEP'...String in apostrophes containing the name of the input
C             SEP parameter or history file with the input data.
C     No default, 'SEP' must be specified and cannot be blank.
C
C                                                     <A NAME="SEP"></A>
C Input data file 'SEP':
C     File 'SEP' has the form of the <A HREF="../forms/sep.htm">SEP</A>
C     parameter file.  The parameters, which do not differ from their
C     defaults, need not be specified in file 'SEP'.
C Data specifying the parameters of the grid:
C     N1=positive integer... Number of gridpoints along the X1 axis.
C             Default: N1=1
C     N2=positive integer... Number of gridpoints along the X2 axis.
C             Default: N2=1
C     N3=positive integer... Number of gridpoints along the X3 axis.
C             Default: N3=1
C Selection of a particular pseudorandom representation:
C     ISEED=integer ... Nonzero integer seed for the generation of
C             pseudorandom numbers.  Its sign is ignored.
C     Default: ISEED=-1.
C Name of output formatted file with the computed values:
C     RANOUT='string'
C             Default: RANOUT='grdran.out'
C     For general description of the files with gridded data refer to
C     file <A HREF="../forms/forms.htm#GRD">forms.htm</A>.
C Optional parameters specifying the form of the real quantities
C written in the output formatted files:
C     MINDIG,MAXDIG=positive integers ... See the description in file
C             <A HREF="forms.for#MAXDIG">forms.for</A>.
C
C-----------------------------------------------------------------------
C Subroutines and external functions required:
      EXTERNAL ERROR,RSEP1,RSEP3T,RSEP3I,WARRAY,RAN3
      REAL RAN3
C     ERROR ... File <A HREF="../forms/error.for">error.for</A>.
C     RSEP1,RSEP3T,RSEP3I ...
C             File <A HREF="../forms/sep.for">sep.for</A>.
C     WARRAY ... File <A HREF="../forms/forms.for">forms.for</A>.
C     RAN3 ... File <A HREF="../nr/ran3.for">ran3.for</A>.
C
C
C Common block /RAMC/:
      INCLUDE 'ram.inc'
C     <A HREF="ram.inc">ram.inc</A>
C
      CHARACTER*80 FILSEP,FILOUT
      INTEGER LU1
      PARAMETER (LU1=1)
      INTEGER N1,N2,N3,ISEED,I1,N1N2N3
C-----------------------------------------------------------------------
C
C     Reading a name of the file with the input data:
      WRITE(*,'(A)') '+GRDRAN: Enter input filename: '
      FILSEP=' '
      READ(*,*) FILSEP
C
C     Reading all the data from the SEP file into the memory:
      IF (FILSEP.NE.' ') THEN
        CALL RSEP1(LU1,FILSEP)
      ELSE
C       <A NAME="error01"></A><FONT COLOR="RED">GRDRAN-01</FONT>
        CALL ERROR('GRDRAN-01: SEP file not given')
      ENDIF
C
      WRITE(*,'(A)') '+GRDRAN: Working ...           '
C
C     Filename of the output file:
      CALL RSEP3T('RANOUT',FILOUT,'grdran.out')
C     The values describing the grid:
      CALL RSEP3I('N1',N1,1)
      CALL RSEP3I('N2',N2,1)
      CALL RSEP3I('N3',N3,1)
      N1N2N3=N1*N2*N3
      IF (N1N2N3.GT.MRAM) THEN
C       <A NAME="error02"></A><FONT COLOR="RED">GRDRAN-02</FONT>
        CALL ERROR('GRDRAN-02: Small array RAM.')
      ENDIF
C     Reading numerical constant ISEED:
      CALL RSEP3I('ISEED',ISEED,-1)
C
C
C     Random numbers:
      DO 10, I1=1,N1N2N3
        RAM(I1)=RAN3(ISEED)-0.5
  10  CONTINUE
C
      IF (FILOUT.NE.' ') THEN
        CALL WARRAY(LU1,FILOUT,'FORMATTED',.FALSE.,0.,.FALSE.,0.,
     *              N1N2N3,RAM)
      ENDIF
      WRITE(*,'(A)') '+GRDRAN: Done.                 '
      STOP
      END
C
C=======================================================================
C
      INCLUDE 'error.for'
C     <A HREF="../forms/error.for">error.for</A>
      INCLUDE 'sep.for'
C     <A HREF="../forms/sep.for">sep.for</A>
      INCLUDE 'forms.for'
C     <A HREF="../forms/forms.for">forms.for</A>
      INCLUDE 'length.for'
C     <A HREF="../forms/length.for">length.for</A>
      INCLUDE 'ran3.for'
C     <A HREF="../general.htm#NR">ran3.for of Numerical Recipes</A>
C
C=======================================================================
C                                                                 </PRE>
