Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
call writeMatrix(filename, matrix, header, formato)
Where:
filename
: string of any length with the path to the file to write.matrix
: an array of rank 2 of any of the integer or real kinds supported.header
: optional character variable of any length to write in the second line
of the file.formato
: optional character variable with the format to use for the numbers (without
parenthesis.The following example program writes values to a file named matrix.txt:
PROGRAM writeMatrixExample
USE FU_Files, ONLY: writeMatrix
USE FU_Prec, ONLY: dp
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: matrixFileName
REAL(KIND=dp), DIMENSION(2,3) :: matrix
matrixFileName = 'matrix.txt'
matrix(1,1) = 1.1
matrix(1,2) = 1.2
matrix(1,3) = 1.3
matrix(2,1) = 2.1
matrix(2,2) = 2.2
matrix(2,3) = 2.3
CALL writeMatrix(matrixFileName, matrix, formato='F3.1')
END PROGRAM writeMatrixExample
After execution file matrix.txt contains the following information:
2 3 F
1.1 1.2 1.3
2.1 2.2 2.3
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
integer(kind=i8), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: I3 |
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
integer(kind=i16), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: I3 |
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
integer(kind=i32), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: I3 |
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
integer(kind=i64), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: I3 |
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
real(kind=sp), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: F8.3 |
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
real(kind=dp), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: F8.3 |
Writes a matrix to a file. The file will have the following format:
First line includes the number of rows, the number of columns and a logical indicating if the second line is a header line to be skipped. Example: 5 9 T.
The second row can be a header or not.
Then the matrix comes. The different columns are separated using blanks.
The file is then opened, written and closed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Filename of the file to write the matrix to. |
||
real(kind=qp), | intent(in), | DIMENSION(:,:) | :: | matrix |
Values of the matrix to write to the file. |
|
character(len=*), | intent(in), | optional | :: | header |
Header to be writen in the second line. |
|
character(len=*), | intent(in), | optional | :: | formato |
Format to use for the numbers without parenthesis. Example: F8.3 |