-
Notifications
You must be signed in to change notification settings - Fork 17
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
Sebastianwolf/error checking #45
Open
sebastianwolf
wants to merge
34
commits into
fastscape-lem:master
Choose a base branch
from
sebastianwolf:sebastianwolf/ErrorChecking
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7b686a3
Added a couple of missing type declaration statements.
47a16b2
* Added first version of error-checking with macros.
sebastianwolf 0c6ed1b
Added list of strings containing error names. Care needs be taken wit…
sebastianwolf 220a1c0
Removed none in err_names. Now array indexing fits with err-codes.
sebastianwolf f85f8a1
Exception handling: Added handlers which are less brutal and allow do…
dmay23 eb30715
Exceptions: Integrating changes into API and demo driver.
dmay23 c26e9b0
Resolved conflict
dmay23 7d4ad8d
Exceptions: Remove old storage of ierr/msg in the error module.
dmay23 56f8b61
Merge remote-tracking branch 'origin/sebastianwolf/ErrorChecking' int…
sebastianwolf 4f6b9f9
Exceptions: Clean up
dmay23 8169c1d
Exceptions: Put error codes in their own module and their own file fo…
dmay23 b142b50
Merge remote-tracking branch 'origin/sebastianwolf/ErrorChecking' int…
sebastianwolf 673054e
* Added ierr error code to all API funcs
sebastianwolf 056bb25
* Added error checking to Diffusion and Flowrouting errors.
sebastianwolf 97e127d
* cleanup
sebastianwolf 5d7420e
* removed debug files and Makefile from src
sebastianwolf 06793f1
cleanup
sebastianwolf 9b0f0a5
Fixed small arg error in api
sebastianwolf e1bd453
Merge remote-tracking branch 'upstream/master' into sebastianwolf/Err…
sebastianwolf 3f4c4f4
Added ErrorCodes to compiled files list
sebastianwolf 4880638
Fixed typo
sebastianwolf 135dd2c
Error macros need line length longer than the standard of 132 chars. …
sebastianwolf ad8a4ce
Merge remote-tracking branch 'upstream/master' into sebastianwolf/Err…
sebastianwolf d9a0a22
wrap all api subroutines in a new module
benbovy dff733b
add FSCAPE_INITERR and FSCAPE_CHKERR_OPT macros
benbovy 7241ec9
insert new macros in API functions
benbovy fd8c433
update examples
benbovy ba65b11
hopefully fix python builds
benbovy fbabf5b
try fix Flang (Python bindings) builds
benbovy 84edb41
reduce expanded macro line lengths (flang compat)
benbovy 8c71965
python bindings: do not print error messages
benbovy 09d9607
Added iso_c bindings for api functions. The function-names when calli…
sebastianwolf bfaba1b
Merge branch 'sebastianwolf/bindC' into sebastianwolf/ErrorChecking
sebastianwolf 5faa737
Updated Cmakelist to conform with standard 2018. That is required for…
sebastianwolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
! Error.fpp | ||
|
||
! | ||
! Macros for error handling. | ||
! Fortran preprocessor must be enabled: -fpp. | ||
! | ||
|
||
! | ||
! Initialize ierr argument in API functions | ||
! | ||
#define FSCAPE_INITERR(ierr, ierr_, fname) \ | ||
ierr_ = 0; \ | ||
if (present(ierr)) then; \ | ||
ierr = ierr_; \ | ||
else; \ | ||
print '(A)', "*** Depreciation warning *** "; \ | ||
print '(A,A,A)', "Calling ", TRIM((fname)), " without 'ierr' argument (integer) is depreciated! Please update your code!"; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @benbovy This should read "deprecated" not "depreciated" |
||
end if; | ||
|
||
! | ||
! Raise an exception by pushing the name of the exception + file name, line number to stdout | ||
! Sets ierr to the error type specified by err_type | ||
! | ||
#define FSCAPE_RAISE(err_type, ierr) \ | ||
ierr = (err_type); \ | ||
print '(A,I4,A)', "*** FastScape exception *** -> " // TRIM(err_names((ierr))) // " (" // __FILE__ // ", line", __LINE__, ")"; | ||
|
||
! | ||
! Raise an exception by pushing custom user provided message to stdout, | ||
! along with the name of the exception + file name, line number to stdout | ||
! Sets ierr to the error type specified by err_type | ||
! | ||
#define FSCAPE_RAISE_MESSAGE(msg, err_type, ierr) \ | ||
print '(A,A)', "*** FastScape exception *** ", TRIM((msg)) // "!"; \ | ||
FSCAPE_RAISE(err_type, ierr); | ||
|
||
! | ||
! Calls return if error code is non-zero. | ||
! | ||
#define FSCAPE_CHKERR(ierr) \ | ||
if (ierr /= 0) then; \ | ||
return; \ | ||
end if; | ||
|
||
! | ||
! Either calls return or stop if error code is non-zero, dependening on whether the | ||
! the ierr argument is present. | ||
! | ||
#define FSCAPE_CHKERR_OPT(ierr, ierr_) \ | ||
if (ierr_ /= 0) then; \ | ||
if (present(ierr)) then; \ | ||
ierr = ierr_; \ | ||
return; \ | ||
else; \ | ||
print '(A)', "*** Execution being halted by calling stop!"; \ | ||
print '(A)', "Call all API routine with 'ierr' argument to avoid this."; \ | ||
stop; \ | ||
end if; \ | ||
end if; | ||
|
||
! | ||
! Force stop if error code is non-zero. | ||
! This should only be called in driver code - never within library code or the API. | ||
! | ||
#define FSCAPE_CHKERR_ABORT(ierr) \ | ||
if (ierr /= 0) then; \ | ||
stop; \ | ||
end if; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
module FastScapeErrorCodes | ||
implicit none | ||
integer, parameter :: ERR_None = 0, & | ||
ERR_Default = 1, & | ||
ERR_FileNotFound = 2, & | ||
ERR_FileOpenFailed = 3, & | ||
ERR_ParameterInvalid = 4, & | ||
ERR_ParameterOutOfRange = 5, & | ||
ERR_TridiagNotSolvable = 6, & | ||
ERR_SetupNotRun = 7, & | ||
ERR_NotConverged = 8 | ||
|
||
character(len=50), dimension(8) :: err_names = [character(len=50) :: "Default run time error", & | ||
"File error: File not found", & | ||
"File error: File open failed", & | ||
"Parameter error: Input invalid", & | ||
"Parameter error: Out of range" , & | ||
"Solver error: Tridiag not solvable", & | ||
"Order invalid: Must call SetUp() first", & | ||
"Solver error: not converged" ] | ||
|
||
end module FastScapeErrorCodes |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benbovy This should read "Deprecation" not "Depreciation"