SHOW
Prints rank-1 or rank-2 arrays of numbers in a readable format.
Required Arguments
X — Rank-1 or rank-2 array containing the numbers to be printed. (Input)
Optional Arguments
text = CHARACTER (Input)
CHARACTER(LEN=*) string used for labeling the array.
image = buffer (Output)
CHARACTER(LEN=*) string used for an internal write buffer. With this argument present the output is converted to characters and packed. The lines are separated by an end-of-line sequence. The length of buffer is estimated by the line width in effect, time the number of lines for the array.
iopt = iopt(:) (Input)
Derived type array with the same precision as the input array; used for passing optional data to the routine. Use the REAL(KIND(1E0)) precision for output of INTEGER arrays. The options are as follows:
Packaged Options for SHOW
Prefix is blank
Option Name
Option Value
 
show_significant_digits_is_4
1
 
show_significant_digits_is_7
2
 
show_significant_digits_is_16
3
 
show_line_width_is_44
4
 
show_line_width_is_72
5
 
show_line_width_is_128
6
 
show_end_of_line_sequence_is
7
 
show_starting_index_is
8
 
show_starting_row_index_is
9
 
show_starting_col_index_is
10
iopt(IO) = show_significant_digits_is_4
iopt(IO) = show_significant_digits_is_7
iopt(IO) = show_significant_digits_is_16
These options allow more precision to be displayed. The default is 4D for each value. The other possible choices display 7D or 16D.
iopt(IO) = show_line_width_is_44
iopt(IO) = show_line_width_is_72
iopt(IO) = show_line_width_is_128
These options allow varying the output line width. The default is 72 characters per line. This allows output on many work stations or terminals to be read without wrapping of lines.
iopt(IO) = show_end-of_line_sequence_is
The sequence of characters ending a line when it is placed into the internal character buffer corresponding to the optional argument ‘IMAGE = buffer‘. The value of iopt(IO+1)%idummy is the number of characters. These are followed, starting at iopt(IO+2)%idummy, by the ASCII codes of the characters themselves. The default is the single character, ASCII value 10 or New Line.
iopt(IO) = show_starting_index_is
This are used to reset the starting index for a rank-1 array to a value different from the default value, which is 1.
iopt(IO) = show_starting_row_index_is
iopt(IO) = show_starting_col_index_is
These are used to reset the starting row and column indices to values different from their defaults, each 1.
FORTRAN 90 Interface
Generic: CALL SHOW (X [])
Specific: The specific interface names are S_SHOW and D_SHOW.
Description
The show routine is a generic subroutine interface to separate low-level subroutines for each data type and array shape. Output is directed to the unit number IUNIT. That number is obtained with the subroutine UMACH. Thus the user must open this unit in the calling program if it desired to be different from the standard output unit. If the optional argument ‘IMAGE = buffer‘ is present, the output is not sent to a file but to a character string within buffer. These characters are available to output or be used in the application.
Fatal and Terminal Error Messages
See the messages.gls file for error messages for SHOW. These error messages are numbered 601606; 611617; 621627; 631636; 641646.
Examples
Example1: Printing an Array
Array of random numbers for all the intrinsic data types are printed. For REAL(KIND(1E0)) rank-1 arrays, the number of displayed digits is reset from the default value of 4 to the value 7 and the subscripts for the array are reset so they match their declared extent when printed. The output is not shown.
 
use show_int
use rand_int
implicit none
! This is Example 1 for SHOW.
integer, parameter :: n=7, m=3
real(kind(1e0)) s_x(-1:n), s_m(m,n)
real(kind(1d0)) d_x(n), d_m(m,n)
complex(kind(1e0)) c_x(n), c_m(m,n)
complex(kind(1d0)) z_x(n),z_m(m,n)
integer i_x(n), i_m(m,n)
type (s_options) options(3)
! The data types printed are real(kind(1e0)), real(kind(1d0)),
! complex(kind(1e0)), complex(kind(1d0)), and INTEGER.
! Fill with randsom numbers and then print the contents,
! in each case with a label.
s_x=rand(s_x); s_m=rand(s_m)
d_x=rand(d_x); d_m=rand(d_m)
c_x=rand(c_x); c_m=rand(c_m)
z_x=rand(z_x); z_m=rand(z_m)
i_x=100*rand(s_x(1:n)); i_m=100*rand(s_m)
call show (s_x, 'Rank-1, REAL')
call show (s_m, 'Rank-2, REAL')
call show (d_x, 'Rank-1, DOUBLE')
call show (d_m, 'Rank-2, DOUBLE')
call show (c_x, 'Rank-1, COMPLEX')
call show (c_m, 'Rank-2, COMPLEX')
call show (z_x, 'Rank-1, DOUBLE COMPLEX')
call show (z_m, 'Rank-2, DOUBLE COMPLEX')
call show (i_x, 'Rank-1, INTEGER')
call show (i_m, 'Rank-2, INTEGER')
! Show 7 digits per number and according to the
! natural or declared size of the array.
options(1)=show_significant_digits_is_7
options(2)=show_starting_index_is
options(3)= -1 ! The starting value.
call show (s_x, &
'Rank-1, REAL with 7 digits, natural indexing', IOPT=options)
end
Output
Example 1 for SHOW is correct.
Example 2: Writing an Array to a Character Variable
This example prepares a rank-1 array for further processing, in this case delayed writing to the standard output unit. The indices and the amount of precision are reset from their defaults, as in Example 1. An end-of-line sequence of the characters CR-NL (ASCII 10,13) is used in place of the standard ASCII 10. This is not required for writing this array, but is included for an illustration of the option.
 
use show_int
use rand_int
implicit none
! This is Example 2 for SHOW.
integer, parameter :: n=7
real(kind(1e0)) s_x(-1:n)
type (s_options) options(7)
CHARACTER (LEN=(72+2)*4) BUFFER
! The data types printed are real(kind(1e0)) random numbers.
s_x=rand(s_x)
! Show 7 digits per number and according to the
! natural or declared size of the array.
! Prepare the output lines in array BUFFER.
! End each line with ASCII sequence CR-NL.
options(1)=show_significant_digits_is_7
options(2)=show_starting_index_is
options(3)= -1 ! The starting value.
options(4)=show_end_of_line_sequence_is
options(5)= 2 ! Use 2 EOL characters.
options(6)= 10 ! The ASCII code for CR.
options(7)= 13 ! The ASCII code for NL.
BUFFER= ' ' ! Blank out the buffer.
! Prepare the output in BUFFER.
call show (s_x, &
'Rank-1, REAL with 7 digits, natural indexing '//&
'internal BUFFER, CR-NL EOLs.',&
IMAGE=BUFFER, IOPT=options)
! Display BUFFER as a CHARACTER array. Discard blanks
! on the ends.
WRITE(*,'(1x,A)') TRIM(BUFFER)
end
Output
 
Example 2 for SHOW is correct.
Published date: 03/19/2020
Last modified date: 03/19/2020