Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Professional Fortran code development: Log file creation

I have developed a Fortran code which has the following characteristics:

  1. Global variables
  2. 13 Modules with multiple subroutines
  3. Independent subroutines
  4. Using Intel MKL library for LAPACK libraries (Linear Algebra)
  5. Reading and writing text files

The code has become quite big. Even though at this stage I am trying to get the correct answer, speed of execution of the code is desired.

I was writing a text log file with tags such as ERROR: message or INFO: message so far. But writing too much information slows down the code. I know in Java development we use log4j library to efficiently write log files where we can switch on or off various levels of logging. So once the code is clean, we can switch off low level logs and just keep the high level logs.

I would like to know from other programmers what is the best way to handle this in Fortran 90+.

like image 931
Amitava Avatar asked Oct 22 '13 16:10

Amitava


1 Answers

The easiest way would be to create an integer variable verbose and read in its value at execution (from file or through command line). By doing this, you could create different levels:

  • verbose = 0 => no output
  • verbose = 1 => errors only
  • verbose >= 2 => errors & info

It'd be simple to implement:

IF(verbose >= 1) CALL OutputError(message)
IF(verbose >= 2) CALL OutputInfo(message)

and so on.

like image 56
Kyle Kanos Avatar answered Sep 29 '22 01:09

Kyle Kanos