Module_Print_Procedures

Copyright 2022 IRD

This file is part of statpack.

statpack is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

statpack is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You can find a copy of the GNU Lesser General Public License in the statpack/doc directory.

Authors: Pascal Terray (LOCEAN/IPSL, Paris, France)


MODULE EXPORTING PRINTING UTILITIES.

LATEST REVISION : 27/03/2022


subroutine enter_proc ( string, level, prt_unit )

Purpose

Upon entering a procedure, this subroutine will be called. It would skips two lines and outputs a message that the routine identified by STRING was entered. If LEVEL is present, the message is prepended by LEVEL blanks.

Arguments

STRING (INPUT) character(len=*)
The string which identifies the routine.
LEVEL (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
The printing unit.

Further Details

Leading and trailing blanks in STRING are removed. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

subroutine leave_proc ( string, level, prt_unit )

Purpose

This is the ‘opposite’ to ENTER_PROC. It should be called just before leaving a routine. An exit message is output on PRT_UNIT and two lines are skipped.

Arguments

STRING (INPUT) character(len=*)
The string which identifies the routine.
LEVEL (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
The printing unit.

Further Details

Leading and trailing blanks in STRING are removed. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

function entering ( string, level, trace, prt_unit )

Purpose

Upon entering a procedure, this function will be called. It will return a prefix string suitable for indenting output lines from the procedure. It takes the given STRING and prepends LEVEL blanks, followed by a ‘[’, and appends the character ‘]’. For example, if STRING were ‘hi’ and LEVEL were 7, it would return ” [hi]”. LEVEL is then also incremented by 2.

If TRACE is true, it also outputs a message that the routine identified by STRING was entered.

Arguments

STRING (INPUT) character(len=*)
The string which identifies the routine.
LEVEL (INPUT/OUTPUT) integer(i4b)
The number of blanks to use for indentation. LEVEL is incremented by 2 on output.
TRACE (INPUT) logical(lgl)
Logical indicator for printing the message.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
The printing unit.

Further Details

Trailing blanks in STRING are removed. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

subroutine leaving ( string, level, trace, prt_unit )

Purpose

This is the ‘opposite’ to ENTERING. It should be called just before leaving a routine. LEVEL is reduced by 2 and if TRACE is true, an exit message is output.

Arguments

STRING (INPUT) character(len=*)
The string which identifies the routine.
LEVEL (INPUT/OUTPUT) integer(i4b)
The number of blanks to use for indentation. LEVEL is reduced by 2 on output.
TRACE (INPUT) logical(lgl)
Logical indicator for printing the message.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
The printing unit.

Further Details

Trailing blanks in STRING are removed. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

subroutine indent ( id, level, prt_unit )

Purpose

This is also used to indent output, albeit in a manner different from ENTERING and LEAVING. It simply writes out LEVEL blanks followed by the string ID in [], and leaves the output file marker where it is. It uses nonadvancing output. If LEVEL is not present, just the ID part is output; i.e. LEVEL is treated as zero.

Arguments

ID (INPUT) character(len=*)
The string to print.
LEVEL (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
The printing unit.

Further Details

Leading and trailing blanks in ID are removed. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

subroutine write_array ( x, f, w, d, s, name, indent, line, prt_unit )

Purpose

Print out a real matrix with given format, as below. The matrix is printed row by row.

Print also a title for the matrix: NAME

Arguments

X (INPUT) real(stnd), dimension(:,:)
The matrix to be output.
F (INPUT, OPTIONAL) character
Selects the edit descriptor: FW.D . F is a character ‘f’, ‘g’, ‘e’ or ‘d’, regardless of case.
W, D (INPUT, OPTIONAL) integer(i4b)
Selects the edit descriptor: fw.d . Print each entry in format FW.D . W and D are integers.
S (INPUT, OPTIONAL) integer(i4b)
The number of spaces between each entry.
NAME (INPUT, OPTIONAL) character(len=*)
Prints the string NAME as a title for the matrix.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the matrix output will be indented (not the TITLE).

Each output line from this subroutine will have at most max(LINE,W+abs(INDENT)) characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is at most max(80,W+abs(INDENT)) characters plus one for carriage control.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine write_array ( x, w, s, name, indent, line, prt_unit )

Purpose

Print out an integer matrix X with given format, as below. The matrix is printed row by row.

Print also a title for the matrix: NAME

Arguments

X (INPUT) integer(i4b), dimension(:,:)
The matrix to be output.
W (INPUT, OPTIONAL) integer(i4b)
Selects the width of each entry. Print each entry in format iW .
S (INPUT, OPTIONAL) integer(i4b)
The number of spaces between each entry.
NAME (INPUT, OPTIONAL) character(len=*)
Prints the string NAME as a title for the matrix.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If W is absent, then the routine determines the best width w needed to edit the array X without excess blanks.

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the matrix output will be indented (not the TITLE).

Each output line from this subroutine will have at most max(LINE,W+abs(INDENT)) characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is at most max(80,W+abs(INDENT)) characters plus one for carriage control.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine write_array ( x, f, w, d, s, name, indent, line, prt_unit )

Purpose

This subroutine prints out a real vector with a given format and a title, as given in the input arguments.

Arguments

X (INPUT) real(stnd), dimension(:)
The vector to be output.
F (INPUT, OPTIONAL) character
Selects the edit descriptor: FW.D . F is a character ‘f’, ‘g’, ‘e’ or ‘d’, regardless of case.
W, D (INPUT, OPTIONAL) integer(i4b)
Selects the edit descriptor: fw.d . Print each entry in format FW.D . W and D are integers.
S (INPUT, OPTIONAL) integer(i4b)
The number of spaces between each entry.
NAME (INPUT, OPTIONAL) character(len=*)
Prints the string NAME as a title for the vector.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the vector output will be indented (not the TITLE).

Each output line from this subroutine will have at most max(LINE,W+abs(INDENT)) characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is at most max(80,W+abs(INDENT)) characters plus one for carriage control.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine write_array ( x, w, s, name, indent, line, prt_unit )

Purpose

This subroutine prints out an integer vector with a given format and a title, as given in the input arguments.

Arguments

X (INPUT) integer(i4b), dimension(:)
The vector to be output.
W (INPUT, OPTIONAL) integer(i4b)
Selects the width of each entry. Print each entry in format iW .
S (INPUT, OPTIONAL) integer(i4b)
The number of spaces between each entry.
NAME (INPUT, OPTIONAL) character(len=*)
Prints the string NAME as a title for the matrix.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If W is absent, then the routine determines the best width w needed to edit the array X without excess blanks.

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the vector output will be indented (not the TITLE).

Each output line from this subroutine will have at most max(line,W+abs(INDENT)) characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is at most max(80,W+abs(INDENT)) characters plus one for carriage control.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_array ( x, f, w, d, sign_ed, s, title, namlig, namcol, indent, line, prt_unit )

Purpose

Routine for labeled real matrix output with given format, as below. The matrix is printed columns block by columns block. Print also a title for the matrix: TITLE

Arguments

X (INPUT) real(stnd), dimension(:,:)
The matrix to be output.
F (INPUT, OPTIONAL) character
Selects the edit descriptor: FW.D . F is a character ‘f’, ‘g’, ‘e’ or ‘d’, regardless of case.
W, D (INPUT, OPTIONAL) integer(i4b)
Selects the edit descriptor: fw.d . Print each entry in format FW.D . W and D are integers.
SIGN_ED (INPUT, OPTIONAL) character(len=2)
Selects the sign edit descriptor. sign_ed is ‘ss’ or ‘sp’, regardless of case.
S (INPUT, OPTIONAL) integer(i4b)
the number of spaces between each entry.
TITLE (INPUT, OPTIONAL) character(len=*)
Prints a title for the matrix.
NAMLIG (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the rows of the matrix. The size of NAMLIG must match the number of ligns of X.
NAMCOL (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the columns of the matrix. The size of NAMCOL must match the number of columns of X.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If NAMLIG is absent, then the rows of X are labeled by row numbers.

If NAMCOL is absent, then the columns of X are labeled by column numbers. Column labels are truncated to W characters.

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the matrix output will be indented (not the TITLE).

Each output line from this subroutine will have at most

max( LINE, W+abs(INDENT)+6+len_trim(NAMLIG) )

characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is at most max( 80, W+abs(INDENT)+6+len_trim(NAMLIG) ) characters plus one for carriage control.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_array (x, w, sign_ed, s, title, namlig, namcol, indent, line, prt_unit)

Purpose

Routine for labeled integer matrix output with given format, as below. The matrix is printed columns block by columns block. Print also a title for the matrix: TITLE

Arguments

X (INPUT) integer(i4b), dimension(:,:)
The matrix to be output.
W (INPUT, OPTIONAL) integer(i4b)
Selects the width of each entry. Print each entry in format iW .
SIGN_ED (INPUT, OPTIONAL) character(len=2)
Selects the sign edit descriptor. sign_ed is ‘ss’ or ‘sp’, regardless of case.
S (INPUT, OPTIONAL) integer(i4b)
The number of spaces between each entry.
TITLE (INPUT, OPTIONAL) character(len=*)
Prints a title for the matrix.
NAMLIG (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the rows of the matrix. The size of NAMLIG must match the number of ligns of X.
NAMCOL (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the columns of the matrix. The size of NAMCOL must match the number of columns of X.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If W is absent, then the routine determines the best width w needed to edit the array X without excess blanks.

If NAMLIG is absent, then the rows of X are labeled by row numbers.

If NAMCOL is absent, then the columns of X are labeled by column numbers. Column labels are truncated to W characters.

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the matrix output will be indented (not the TITLE).

Each output line from this subroutine will have at most

max( LINE, W+abs(INDENT)+6+len_trim(NAMLIG) )

characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is at most max( 80, W+abs(INDENT)+6+len_trim(NAMLIG) ) characters plus one for carriage control.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_array ( x, f, w, d, sign_ed, title, namlig, indent, prt_unit )

Purpose

Routine for labeled real vector output with given format, as below.

Print also a title for the vector: TITLE

Arguments

X (INPUT) real(stnd), dimension(:)
The vector to be output.
F (INPUT, OPTIONAL) character
Selects the edit descriptor: FW.D . F is a character ‘f’, ‘g’, ‘e’ or ‘d’, regardless of case.
W, D (INPUT, OPTIONAL) integer(i4b)
Selects the edit descriptor: fw.d . Print each entry in format FW.D . W and D are integers.
SIGN_ED (INPUT, OPTIONAL) character(len=2)
Selects the sign edit descriptor. sign_ed is ‘ss’ or ‘sp’.
TITLE (INPUT, OPTIONAL) character(len=*)
Prints a title for the vector.
NAMLIG (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the elements of the vector. The size of NAMLIG must match the size of X.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If NAMLIG is absent, then the rows of X are labeled by row numbers.

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the vector output will be indented (not the TITLE).

Each output line from this subroutine will have at most

abs(INDENT) + max( len(TITLE), W+6+len_trim(NAMLIG) )

characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_array ( x, w, sign_ed, title, namlig, indent, prt_unit )

Purpose

Routine for labeled integer vector output with given format, as below.

Print also a title for the vector: TITLE

Arguments

X (INPUT) integer(i4b), dimension(:)
The vector to be output.
W (INPUT, OPTIONAL) integer(i4b)
Selects the width of each entry. Print each entry in format iW .
SIGN_ED (INPUT, OPTIONAL) character(len=2)
Selects the sign edit descriptor. sign_ed is ‘ss’ or ‘sp’, regardless of case.
TITLE (INPUT, OPTIONAL) character(len=*)
Prints a title for the vector.
NAMLIG (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the elements of the vector. The size of NAMLIG must match the size of X.
IDENT (INPUT, OPTIONAL) integer(i4b)
The number of blanks to use for indentation.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If W is absent, then the routine determines the best width w needed to edit the array X without excess blanks.

If NAMLIG is absent, then the rows of X are labeled by row numbers.

If the value of the argument INDENT is positive, then each output line is preceded by INDENT blank characters. If INDENT is negative, then only the vector output will be indented (not the TITLE).

Each output line from this subroutine will have at most

abs(INDENT) + max( len(TITLE), W+6+len_trim(NAMLIG) )

characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

All output is on the unit PRT_UNIT. If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_prinfac ( mode, a, f, names, line, prt_unit )

Purpose

Routine for labeled matrix output after an EOF or SVD analysis.

Print an EOF model (MODE=1) or the associated principal components (MODE=2) and an SVD model (MODE=3) or the associated singular variables (MODE=4)

Arguments

MODE (INPUT) integer(i1b)
integer indicator for printing.
A (INPUT) real(stnd), dimension(:,:)
The matrix to be output.
F (INPUT, OPTIONAL) character
Selects the edit descriptor. F is a character ‘f’, ‘g’, ‘e’ or ‘d’, regardless of case. Print each entry in format f14.6 .
NAMES (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the rows of the matrix. The size of NAMES must match the number of rows of A.
LINE (INPUT, OPTIONAL) integer(i4b)
The number of characters per line.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If F is absent, then the default edit descriptor is DEFF.

If NAMES is absent, then the rows of a are labeled by row numbers.

Each output line from this subroutine will have at least 20+len_trim(NAMES) characters (print at least one column of a) and at most 118+len_trim(NAMES) characters (print at most eight columns of a) plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If LINE is absent, then line width is 80 characters.

If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_prinfac ( mode, a, f, names, prt_unit )

Purpose

Routine for labeled matrix output after an EOF or SVD analysis.

Print an EOF vector (MODE=1) or the associated principal component (MODE=2) and a singular vector (MODE=3) or the associated singular variable (MODE=4)

Arguments

MODE (INPUT) integer(i1b)
integer indicator for printing.
A (INPUT) real(stnd), dimension(:)
The vector to be output.
F (INPUT, OPTIONAL) character
Selects the edit descriptor. F is a character ‘f’, ‘g’, ‘e’ or ‘d’, regardless of case. Print each entry in format F14.6 .
NAMES (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the elements of the vector. The size of NAMES must match the size of A.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

Further Details

If F is absent, then the default edit descriptor is DEFF.

If NAMES is absent, then the elements of A are labeled by element numbers.

Each output line from this subroutine will have 20+len_trim(NAMES) characters plus one additional leading character for Fortran “carriage control”. The carriage control character will always be a blank.

If PRT_UNIT is absent, then all output is on the unit DEFUNIT.

Defaults are defined for all optional arguments. See start of module.

subroutine print_stat ( mode, nomiss, var, inr, qlt, names, prt_unit )

Purpose

Print statistics for an EOF “missing” analysis for

Variables (MODE=1) Observations (MODE=2)

Arguments

MODE (INPUT) integer(i1b)
integer indicator for printing.
NOMISS (INPUT) integer(i4b), dimension(:)
Vector giving the number of non-missing elements for each variable (MODE=1) or observation (MODE=2).
VAR, INR, QLT (INPUT) real(stnd), dimension(:)
The statistics to be output for each variable (MODE=1) or observation (MODE=2). The size of these vectors must match the size of NOMISS.
NAMES (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the variables(MODE=1) or observations (MODE=2). The size of this vector must match the size of NOMISS.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.

subroutine print_stat ( mode, weight, var, inr, qlt, names, prt_unit )

Purpose

Print statistics for an EOF “weighted” analysis for

Variables (MODE=1) Observations (MODE=2)

Arguments

MODE (INPUT) integer(i1b)
integer indicator for printing.
WEIGHT (INPUT) real(stnd), dimension(:)
Vector giving the weights for each variable (MODE=1) or observation (MODE=2).
VAR, INR, QLT (INPUT) real(stnd), dimension(:)
The statistics to be output for each variable (MODE=1) or observation (MODE=2). The size of these vectors must match the size of WEIGHT.
NAMES (INPUT, OPTIONAL) character(len=*), dimension(:)
Labels for the variables(MODE=1) or observations (MODE=2). The size of this vector must match the size of WEIGHT.
PRT_UNIT (INPUT, OPTIONAL) integer(i4b)
Selects the output unit.
Flag Counter