-
Notifications
You must be signed in to change notification settings - Fork 459
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
Move calls to GetNewUnit into file opening routines and wrap with !$OMP critical #2538
Open
andrew-platt
wants to merge
23
commits into
OpenFAST:rc-3.5.5
Choose a base branch
from
andrew-platt:f/GetNewUnit_in_fileOpening
base: rc-3.5.5
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
Move calls to GetNewUnit into file opening routines and wrap with !$OMP critical #2538
andrew-platt
wants to merge
23
commits into
OpenFAST:rc-3.5.5
from
andrew-platt:f/GetNewUnit_in_fileOpening
Conversation
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 `!$OMP critical` around all `GetNewUnit` + `open(*)` call pairs
Also fix some hard coded file numbers
I'm not positive this is necessary without more advanced OMP directives that the `!$OMP critical`. With my luck though, some obscure compiler will be unhappy about it if I don't.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is ready to merge
Feature or improvement description
We have had issues with unit numbers when opening files for many years when OpenMP is used. The root issue was that the
GetNewUnit
call was separate from the actual file opening. This could lead to race conditions when multiple threads hit aGetNewUnit
before the retrieved unit numbers were used to open the corresponding files.To solve this, we moved all the
GetNewUnit
calls into theOpen*File
subroutines inNWTC_IO.f90
. Inside those routines we wrap theGetNewUnit
andopen(*)
command pairs in a!$OMP critical
block. This should prevent the same unit number from being given out to two different OpenMP threads at once.We debated if this should go into 3.5.5 or 4.0.0. In the end we decided this would be better to address in 3.5.5, mostly so that I don't have to field any more questions or bug reports about it when users stay on the 3.5.x series longer.
Related issue, if one exists
#2510
There were many others over the years that we suspect may be related.
Impacted areas of the software
This change should be completely transparent to the end users, but should fix issues with conflicting unit numbers when OpenMP is used.
Additional supporting information
We originally thought about wrapping the original
GetNewUnit
calls and the followingOpen*File
calls, but decided that would complicate the code considerably. Instead we decided it was simpler to move theGetNewUnit
calls and handle the!$OMP critical
block in the library so future programmers would not need to think about it.Test results, if applicable
No test results should change.