Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable message folding in fatalError #35

Merged
merged 1 commit into from
May 24, 2023

Conversation

Mikolaj-A-Kowalski
Copy link
Collaborator

Changes the fatalError subroutine to something presentable. Resolves #33

  • error messages will be printed to STDERR.
  • the error message will be folded to respect MAX_COL parameter.
  • uses error stop which will produce backtrace on some compilers

For example, a long error message will look as follows:

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Fatal has occurred in:
bestfunction (worstfile.f90)

Because:
This is a very long error message which will contain some number of
detail a person may find interesting and useful for debugging.
Although I have no clue how to build such long strings in a nice way
in Fortran. But sometimes it may be immpossible
sinceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee long strings do happen.
                                                          Also a lot
of whitespace will look weird
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
ERROR STOP

Error termination. Backtrace:
#0  0x7f093ce2cbd0 in ???
#1  0x7f093ce2d685 in ???
#2  0x7f093ce2e9f3 in ???
#3  0x55ad47fd29dd in __errors_mod_MOD_fatalerror
   at /home/<user_path>/SCONE/SharedModules/errors_mod.f90:57
#4  0x55ad47fcb94e in scone
   at /home/<user_path>/SCONE/Apps/scone.f90:24
#5  0x55ad47fcb7be in main
   at /home/<user_path>/SCONE/Apps/scone.f90:3

In the anticipation of the warning log the function was also moved to a new errors_mod module.

@@ -4,6 +4,7 @@ module genericProcedures

use numPrecision
use openmp_func, only : ompGetMaxThreads
use errors_mod, only: fatalError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this enough for compatibility with all the functions that call fatalError and have 'use genericProcedures' rather than 'use errors_mod'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Basically the import makes the fatalError available in genericProcedures scope and use genericProcedures import the entire scope including things that were imported.
Actually this is a feature of Fortran one needs to be careful about since this is how something can sneak into a scope unknowingly.

That being said we should use errors_mod directly. I just wanted to avoid horrible conflicts with other PRs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I also think using 'use errors_mod' directly would be cleaner, even though this means changing a lot of files. Worth creating an issue I assume!

Copy link
Member

@valeriaRaffuzzi valeriaRaffuzzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great, thanks for writing this!

@Mikolaj-A-Kowalski
Copy link
Collaborator Author

Thanks for the review! If it is good to merge for you: please do the honours

@valeriaRaffuzzi valeriaRaffuzzi merged commit be18144 into CambridgeNuclear:main May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal Error format
2 participants