hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_file_open (x04ac)

Purpose

nag_file_open (x04ac) opens a Fortran unit number for reading, writing or appending, and associates the unit with a named file.

Syntax

[ifail] = x04ac(iounit, file, mode)
[ifail] = nag_file_open(iounit, file, mode)

Description

nag_file_open (x04ac) is especially useful if the calling language is not Fortran. It opens a Fortran unit number for reading, writing or appending, and associates the unit with a filename specified by the parameter file.

References

None.

Parameters

Compulsory Input Parameters

1:     iounit – int64int32nag_int scalar
The Fortran unit number which identifies the file to be read from, written to or appended to. Note that this may be system dependent. Values in the range 77 to 10001000 should however be safe on most systems.
2:     file – string
The name of the file to be opened.
Constraint: must contain a valid filename for the computer system being used.
3:     mode – int64int32nag_int scalar
Specifies whether the file is to be opened for reading, writing or appending.
mode = 0mode=0
The file is to be opened for reading.
mode = 1mode=1
The file is to be opened for writing.
mode = 2mode=2
The file is to be opened for appending.
Constraint: 0mode20mode2.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry, mode is invalid.
  ifail = 2ifail=2
Failure to open the file for reading.
  ifail = 3ifail=3
Failure to open the file for writing.
  ifail = 4ifail=4
Failure to open the file for appending.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_file_open_example
iounit = int64(4);
file = 'success.res';
mode = int64(1);
% Open file
[ifail] = nag_file_open(iounit, file, mode);
% ...
% Close file
[ifail] = nag_file_close(iounit)
 

ifail =

                    0


function x04ac_example
iounit = int64(4);
file = 'success.res';
mode = int64(1);
% Open File
[ifail] = x04ac(iounit, file, mode);
% ...
% Close File
[ifail] = x04ad(iounit)
 

ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013