-
Notifications
You must be signed in to change notification settings - Fork 92
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
Create FatesConstantMod to hold global constants #136
Merged
+27
−9
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module FatesConstantsMod | ||
! This module is used to define global _immutable_ data. Everything in | ||
! this module must have the parameter attribute. | ||
|
||
implicit none | ||
|
||
public | ||
|
||
! kinds | ||
integer, parameter :: fates_r8 = selected_real_kind(12) ! 8 byte real | ||
|
||
! string lengths | ||
integer, parameter :: fates_avg_flag_length = 3 | ||
integer, parameter :: fates_short_string_length = 32 | ||
integer, parameter :: fates_long_string_length = 199 | ||
|
||
end module FatesConstantsMod |
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
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.
can we strip this down to something shorter like "f_r8" or "fr8"? I feel like this will be used so often that we can reduce total letter count with an abbreviation.
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.
When you use it, you can still alias it to r8 with something like 'use FatesConstantsMod, only : r8 => fates_r8'. See how it is used in the history module. The actual declaration should have a meaningful, unambiguous name.
There are no bonus points in software engineering for 'reducing the total letter count'. The compiler doesn't care. Code is written once, refactored a few times, and read many, many, many times by human beings. Meaningful names without cryptic abbreviations optimize for the most common use case. In science, it is often humans with little to no training and interest in software as an end. The more clear the code is, the less time it takes to ramp up, and the fewer mistakes they will make. Plus, all modern editors have some form of autocompletion.
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.
I like the solution of
use FatesConstantsMod, only : r8 => fates_r8
since it only requires changing one line per module...
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.
Not seeing the alias was an over-site on my part. Try to relax a little bit @bandre-ucar. I have arguments that I can go into that validate why I made the suggestion I did, but I'm not. The way your are proposing to go forward is fine. The important thing is that we create a culture on these forums where people feel welcomed to interact and know that their input will be valued.