This chapter contains utility functions concerned with input and output to or from an external file.
Output from NAG Toolbox functions to an external file falls into two categories.
(a) |
Error messages
which are always associated with an error exit from a function, that is, with a nonzero value of ifail as specified in Section 6 of the function document. |
(b) |
Advisory messages which include output of final results, output of intermediate results to monitor the course of a computation, and various warning or informative messages. |
Since the NAG Toolbox is written in Fortran it uses Fortran I/O
features. In particular output is directed to an
output unit
identified by a unique
unit number. To allow output to be
redirected to files from within Matlab, we provide two functions for
connecting and disconnecting a file to and from a Fortran unit:
nag_file_open (x04ac) and
nag_file_close (x04ad).
Fortran unit numbers should be between 1 and 99. The
numbers 5 and 6 are reserved for standard input and
output respectively.
At present only formatted records are output from the Library. All formatted output to an external file from within the Library is performed by
nag_file_line_write (x04ba). Similarly, all formatted input from an external file is performed by
nag_file_line_read (x04bb).
Functions are provided to allow formatted output of
(a) |
general matrices stored in a two-dimensional array (real, complex and integer data types); |
(b) |
triangular matrices stored in a packed one-dimensional array (real and complex data types); |
(c) |
band matrices stored in a packed two-dimensional array (real and complex data types). |
Functions in
(b) and
(c) allow printing of matrices stored in formats used in particular by
Chapter F07 of the Library.
By appropriate choice of arguments you can specify titles, labels, maximum output record length, and the format of individual matrix elements. All output is directed to
the advisory messages unit, which may be altered by a call to
nag_file_set_unit_advisory (x04ab).
Apart from the obvious utility of the matrix printing functions, users of the Library may need to call functions in
Chapter X04 for the following purposes.
If the default error message unit is not satisfactory, it may be changed to a new value
nerr by the statement
[nerr] = x04aa(int32(1),nerr)
Similarly the advisory message unit may be changed to a new value
nadv by the statement
[nadv] = x04ab(int32(1),nadv)
Note that both
nag_file_set_unit_error (x04aa) and
nag_file_set_unit_advisory (x04ab) use a Fortran SAVE statement to retain the value of the unit number and so neither function is safe to use in a multithreaded environment.