Functions/Subroutines

numeric_diff.F95 File Reference

The numeric_diff program. More...

Functions/Subroutines

program numeric_diff
 Compare two files containing numerical arrays and check whether they are the same as each other, to within the specified tolerance.
real(kind=dp) string_to_real (string)
 Convert a string to a real.
integer string_to_integer (string)
 Convert a string to an integer.
subroutine inout_tabs_to_spaces (line)
 Expand all tabs in a line into single spaces (one tab makes one space).
subroutine read_char_raw (unit, char, eol, eof)
 Read a single character from a file, signaling if we have hit EOL or EOF. If EOL or EOF are true then the character value should be ignored. A file containing a single line with a single character on it will first return the character with EOL and EOF both false, then will return with EOL true but EOF false, and finally will return with EOL false and EOF true.
subroutine read_word_raw (unit, word, eol, eof)
 Read a white-space delimited word from a file, signaling if we have EOL or EOF. If EOL or EOF are true then the word will still be meaningful data. If there was no data to be read then len(word) will be 0.

Detailed Description

The numeric_diff program.


Function Documentation

subroutine numeric_diff::inout_tabs_to_spaces ( character(len=*),intent(inout)  line )

Expand all tabs in a line into single spaces (one tab makes one space).

Parameters:
lineComplete input line.
program numeric_diff (  )

Compare two files containing numerical arrays and check whether they are the same as each other, to within the specified tolerance.

If the arrays in the two files are of different sizes then they are automatically different. Otherwise the are the same if

\[ | A_1 - A_2 |_2 < \verb+abs_tol+ \]

and

\[ \frac{| A_1 - A_2 |_2}{| A_1 |_2 + | A_2 |_2} < \verb+rel_tol+ \]

and are otherwise different. Setting abs_tol or rel_tol to zero skips the corresponding test.

If the files are the same then "<tt>files match within the given tolerances</tt>" is printed on stdout, otherwise "<tt>files are different</tt>" is printed, followed by the absolute and relative differences, as above, or a message describing the difference. The files will be reported as different if they have a different pattern of end-of-lines and end-of-files, or if they have whitespace in different places (amount of whitespace is irrelevant).

The exit status of the program is:

  • 0 if the files are the same
  • 1 if the files are different
  • 2 if an error occurred
subroutine numeric_diff::read_char_raw ( integer,intent(in)  unit,
character,intent(out)  char,
logical,intent(out)  eol,
logical,intent(out)  eof 
)

Read a single character from a file, signaling if we have hit EOL or EOF. If EOL or EOF are true then the character value should be ignored. A file containing a single line with a single character on it will first return the character with EOL and EOF both false, then will return with EOL true but EOF false, and finally will return with EOL false and EOF true.

Parameters:
unitUnit number to read from.
charCharacter read.
eolTrue if at EOL (end of line).
eofTrue if at EOF (end of file).
subroutine numeric_diff::read_word_raw ( integer,intent(in)  unit,
character(len=*),intent(out)  word,
logical,intent(out)  eol,
logical,intent(out)  eof 
)

Read a white-space delimited word from a file, signaling if we have EOL or EOF. If EOL or EOF are true then the word will still be meaningful data. If there was no data to be read then len(word) will be 0.

Parameters:
unitUnit number to read from.
wordWord read.
eolTrue if at EOL (end of line).
eofTrue if at EOF (end of file).
integer numeric_diff::string_to_integer ( character(len=*),intent(in)  string )

Convert a string to an integer.

Parameters:
stringString to convert.
real(kind=dp) numeric_diff::string_to_real ( character(len=*),intent(in)  string )

Convert a string to a real.

Parameters:
stringString to convert.