This example illustrates how FMS may be used to solve a full real nonsymmetric matrix A(N,N) which is dimensioned in your program. In this example step 3 (write data to FMS files) and step 5 (read data from FMS files) are not required because FMS operates directly on data dimensioned in your program. Note that the array A(N,N) and vector X(N) are placed in blank common for proper data alignment. Subroutine MATGEN is used to generate test data.
C       E X A M P L E   1
C
C	Program name:
	CHARACTER*9 MYNAME
	PARAMETER (MYNAME='EXAMPLE_1')
C
C	Problem size:
	INTEGER     N
	PARAMETER  (N = 100)
C
C	Data type = real:
	PARAMETER (IDTYPE = 1)
C
C	Number of RHS vectors:
	PARAMETER (NUMRHS = 1)
C
C	Number of vectors to reduce during factoring:
	PARAMETER (NUMRED = 0)
C
C	Skip operations during solving (no)
	PARAMETER (ISKIP  = 0)
C
C	Matrix and vector:
	COMMON     A(N,N), X(N)
	REAL*8     A, X
C
C	FMS matrix and vector file attributes:
	
	INTEGER    LUA(25)
	INTEGER    LUX(25)
C
C	Local variables:
	REAL*8     EI, ERROR
C
C (1)   Initialize FMS:
	CALL FMSINI
	CALL FMSPSH(MYNAME)
	CALL FMSIST ('IPRF',1026)
C
C       Populate [A] and {X} with test data:
	CALL MATGEN (A, N, N, X)
C
C (2)   Open FMS files:
C	NOTE: The arrays A(N,N) and X(N) are automatically shared on
C	machines using threads.  On machines using separate processes
C	for parallel, they are not automatically shared.  Therefore we
C	will limit the number of processes accessing these arrays to 1
C	for this example.  Example_2 illustrates how to place these
C	arrays in FMS shared memory so they can be operated on by
C	parallel processes on all machines.
	CALL FMSIST ('MAXCPU',1)
 
	CALL RNDANN (A, N, N, LUA)
	CALL FMSOV2 (N, IDTYPE, NUMRHS, X, N, LUX)
C
C (3)   Write data to FMS files: (Not required).
C
C (4)   Perform matrix algebra:
	CALL RNDF (LUA, LUA, LUX, LUX,    NUMRED)
	CALL RNDS (LUA, LUX, LUX, NUMRHS, ISKIP)
C
C (5)   Read data from FMS files: (Not required).
C
C       Check the answer:
	ERROR = 0.0D0
	DO 50 I = 1,N
	   EI = ABS(X(I) - 1.0D0)
	   IF(EI .GT. ERROR) ERROR = EI
   50   CONTINUE
	WRITE(6,*) 'MAXIMUM ERROR =', ERROR
C
C (6)   Close FMS files:
	CALL FMSCM (LUA)
	CALL FMSCV (LUX)
	CALL FMSPOP(MYNAME)
	CALL FMSEND
	END
C=======================================================================
	SUBROUTINE MATGEN (A, LDA, N, B)
C=======================================================================
	INTEGER    LDA, N
	REAL*8     A(LDA,N), B(N), ZERO, ONE
	CHARACTER*6 MYNAME
	PARAMETER  (ZERO=0.D0)
	PARAMETER  (ONE =1.D0)
	PARAMETER  (MYNAME='MATGEN')
C
C       Populate [A] and {B} with test data:
C              [A]        {X}  =  {B}
C       +-            -+ +   +   +   +
C       | N -1 -1 -1 -1| | 1 |   | 1 |
C       |-1  1  0  0  0| | 1 |   | 0 |
C       |-1  0  1  0  0| | 1 | = | 0 |
C       |-1  0  0  1  0| | 1 |   | 0 |
C       |-1  0  0  0  1| | 1 |   | 0 |
C       +-            -+ +   +   +   +
C
	CALL FMSPSH(MYNAME)
	A(1,1) = DCMPLX(N,N)
	B(1)   = ONE
	DO 20 I = 2,N
	   DO 10 J = 2,N
	      A(I,J) = ZERO
   10      CONTINUE
	   A(1,I) =-ONE
	   A(I,1) =-ONE
	   A(I,I) = ONE
	   B(I)   = ZERO
   20   CONTINUE
	CALL FMSPOP(MYNAME)
	RETURN
	END