FNLMath : Utilities : WRIRL
WRIRL
Print an integer rectangular matrix with a given format and labels.
Required Arguments
TITLE — Character string specifying the title. (Input)
TITLE set equal to a blank character(s) suppresses printing of the title.
MATNRMAT by NCMAT matrix to be printed. (Input)
RLABELCHARACTER * (*) vector of labels for rows of MAT. (Input)
If rows are to be numbered consecutively 1, 2, …, NRMAT, use
RLABEL(1) = ’NUMBER’. If no row labels are desired, use RLABEL(1) = ’NONE’. Otherwise, RLABEL is a vector of length NRMAT containing the labels.
CLABELCHARACTER * (*) vector of labels for columns of MAT. (Input)
If columns are to be numbered consecutively 1, 2, …, NCMAT, use CLABEL(1) = ’NUMBER’. If no column labels are desired, use CLABEL(1) = ’NONE’. Otherwise, CLABEL(1) is the heading for the row labels, and either CLABEL(2) must be ’NUMBER’ or ’NONE’, or CLABEL must be a vector of length
NCMAT + 1 with CLABEL(1 + j) containing the column heading for the j-th column.
Optional Arguments
NRMAT — Number of rows. (Input)
Default: NRMAT = size (MAT,1).
NCMAT — Number of columns. (Input)
Default: NCMAT = size (MAT,2).
LDMAT — Leading dimension of MAT exactly as specified in the dimension statement in the calling program. (Input)
Default: LDMAT = size (MAT,1).
ITRING — Triangle option. (Input)
Default: ITRING = 0.
ITRING
Action
0
Full matrix is printed.
1
Upper triangle of MAT is printed, including the diagonal.
2
Upper triangle of MAT excluding the diagonal of MAT is printed.
-1
Lower triangle of MAT is printed, including the diagonal.
-2
Lower triangle of MAT excluding the diagonal of MAT is printed.
FMT — Character string containing formats. (Input)
If FMT is set to a blank character(s), the format used is a single I format with field width determined by the largest absolute entry. Otherwise, FMT must contain exactly one set of parentheses and one or more I edit descriptors. For example, FMT = ’(I10)’ specifies this I format for the entire matrix. FMT = ’(2I10, 3I5)’ specifies an I10 format for columns 1 and 2 and an I5 format for columns 3, 4 and 5. If the end of FMT is encountered and if some columns of the matrix remain, format control continues with the first format in FMT. FMT may only contain the I edit descriptor, e.g., the X edit descriptor is not allowed.
Default: FMT = ‘ ‘.
FORTRAN 90 Interface
Generic: CALL WRIRL (TITLE, MAT, RLABEL, CLABEL [])
Specific: The specific interface name is S_WRIRL.
FORTRAN 77 Interface
Single: CALL WRIRL (TITLE, NRMAT, NCMAT, MAT, LDMAT, ITRING, FMT, RLABEL, CLABEL)
Description
Routine WRIRL prints an integer rectangular matrix (stored in MAT) with row and column labels (specified by RLABEL and CLABEL, respectively), according to a given format (stored in FMT). WRIRL can restrict printing to the elements of upper or lower triangles of matrices via the ITRING option. Generally, ITRING  0 is used with symmetric matrices. In addition, one-dimensional arrays can be printed as column or row vectors. For a column vector, set NRMAT to the length of the array and set NCMAT = 1. For a row vector, set NRMAT = 1 and set NCMAT to the length of the array. In both cases, set LDMAT = NRMAT, and set ITRING = 0.
1. The output appears in the following form:
TITLE
CLABEL(1)
CLABEL(2)
CLABEL(3)
CLABEL 4)
RLABEL(1)
Xxxxx
xxxxx
xxxxx
RLABEL(2)
Xxxxx
xxxxx
xxxxx
2. Use “% /” within titles or labels to create a new line. Long titles or labels are automatically wrapped.
3. A page width of 78 characters is used. Page width and page length can be reset by invoking PGOPT.
4. Horizontal centering, a method for printing large matrices, paging, printing a title on each page, and many other options can be selected by invoking WROPT.
5. Output is written to the unit specified by UMACH (see the Reference Material).
Example
The following example prints all of a 3 × 4 matrix A = MAT where aij= 10i + j.

USE WRIRL_INT

IMPLICIT NONE
INTEGER ITRING, LDMAT, NCMAT, NRMAT

PARAMETER (ITRING=0, LDMAT=10, NCMAT=4, NRMAT=3)
!
INTEGER I, J, MAT(LDMAT,NCMAT)
CHARACTER CLABEL(5)*5, FMT*8, RLABEL(3)*5
!
DATA FMT/'(I2)'/
DATA CLABEL/' ', 'Col 1', 'Col 2', 'Col 3', 'Col 4'/
DATA RLABEL/'Row 1', 'Row 2', 'Row 3'/
!
DO 20 I=1, NRMAT
DO 10 J=1, NCMAT
MAT(I,J) = I*10 + J
10 CONTINUE
20 CONTINUE
! Write MAT matrix.
CALL WRIRL ('MAT', MAT, RLABEL, CLABEL, NRMAT=NRMAT)
END
Output

MAT
Col 1 Col 2 Col 3 Col 4
Row 1 11 12 13 14
Row 2 21 22 23 24
Row 3 31 32 33 34