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

Increase number of unit numbers available for OMP file opening #2339

Closed

Conversation

andrew-platt
Copy link
Collaborator

Needs testing and approval by @rthedin before merging

Feature or improvement description

We were having problems with the !OMP directives around high resolution file reading in AWAE.f90. Since the file reading starts with a call to GetNewUnit before starting the opening, parallel calls to GetNewUnit could result in the same unit number handed out to two processes. The first process would open the file and start reading, but then the second process would open a different file with the same unit number causing read errors for both processes as they attempted to read the same file at the same time.

To resolve this, an optional start unit number is added to GtNewUnit. This optional argument is propagated up through to the calls within the !OMP loop where a N*100 is used as the starting unit number for the search (where N is the turbine number). Theoretically this will solve the parallel file reading issue from AWAE.

Routine changes:

GetNewUnit

  • Increased maximum unit from 1024 to 64k (likely won't be an issue since most times where more than 1024 files are needed will be on supercomputers where the unit number limit is really high)
  • optional argument for starting unit number. Defaults to old behaviour when not present. ReadLowResWindFile
  • optional argument for starting unit number. Defaults to old behaviour when not present. ReadHighResWindFile
  • optional argument for starting unit number. Defaults to old behaviour when not present. AWAE UpdateStates
  • call to ReadHighResWindFile includes nt*100 as the start unit number

Related issue, if one exists
There may be several FAST.Farm issues related to this, but it is unknown at the moment.

Impacted areas of the software
FAST.Farm AWAE module file reading of high-res VTK files inside the !OMP directive in UpdateStates

Additional supporting information

We were having problems with the `!OMP` directives around high resolution file reading in AWAE.f90. Since the file reading starts with a call to `GetNewUnit` before starting the opening, parallel calls to `GetNewUnit` could result in the same unit number handed out to two processes.  The first process would open the file and start reading, but then the second process would open a different file with the same unit number causing read errors for both processes as they attempted to read the same file at the same time.

To resolve this, an optional start unit number is added to `GtNewUnit`.  This optional argument is propagated up through to the calls within the `!OMP` loop where a `N*100` is used as the starting unit number for the search (where `N` is the turbine number).  Theoretically this will solve the parallel file reading issue from AWAE.

Routine changes:

`GetNewUnit`
 - Increased maximum unit from 1024 to 64k (likely won't be an issue since most times where more than 1024 files are needed will be on supercomputers where the unit number limit is really high)
 - optional argument for starting unit number.  Defaults to old behaviour when not present.
`ReadLowResWindFile`
 - optional argument for starting unit number.  Defaults to old behaviour when not present.
`ReadHighResWindFile`
 - optional argument for starting unit number.  Defaults to old behaviour when not present.
AWAE `UpdateStates`
 - call to `ReadHighResWindFile` includes `nt*100` as the start unit number
@andrew-platt
Copy link
Collaborator Author

Closing this in preference of the simpler solution in #2340

@andrew-platt andrew-platt deleted the b/OpenMP_FF_vtk_read branch July 19, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant