-
Notifications
You must be signed in to change notification settings - Fork 462
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
Consistent use of turbine indexing when coupled to c/c++ #2097
Merged
andrew-platt
merged 6 commits into
OpenFAST:rc-3.5.3
from
andrew-platt:b/FASTlib_TurbineIndex_1
Mar 20, 2024
Merged
Consistent use of turbine indexing when coupled to c/c++ #2097
andrew-platt
merged 6 commits into
OpenFAST:rc-3.5.3
from
andrew-platt:b/FASTlib_TurbineIndex_1
Mar 20, 2024
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
All code in FAST_Subs.f90 and other modules assumes Fortran style indexing (index start at 1) to the Turbine data structure.
This more accurately reflects what it is used for.
- `iTurb_c` is the new variable name for the turbine index passed into a FAST_Library.f90 routine. This is assumed to start at 0 for the first turbine. - `iTurb = iTurb_c + 1` shifts this index to the indexing used internally in OpenFAST.
deslaughter
approved these changes
Mar 18, 2024
@andrew-platt thanks for working on this. I had to rebuild this whole amr-wind stack because they've changed the way we do builds on our end. Running into some snags with this new method and then I will be off the rest of the week. So realistically I won't be testing this until next week. |
I can confirm that the files are closed with these changes and interfacing with amr-wind. Thank you! |
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, pending discussion.
Feature or improvement description
There has been an ambiguous usage of turbine indexing. In C and C++ codes, arrays start with index 0, but Fortran starts with index 1. In coupling OpenFAST to AMR-Wind, an array of
Turbine
data structures was created spanning from index0:NumTurbines-1
. Indexing into this array has been handled by theiTurb
variable passed into all routines inFAST_Library.f90
that include a c-bindings interface. However, inside theFAST_Subs.f90
file, this turbine index is assumed to run from1:NumTurbines
for compatibility with FAST.Farm.This PR corrects the following:
ExternInitData%TurbineID
toExternInitData%TurbIDforName
to more accurately reflect the usage of this variable. This variable is only ever used to set the name of the output file (i.e.SimName.T0.out
). This variable must be 0 or larger (new error handling added).FAST_AllocateTurbines
now allocates theTurbine
data structure to the range(1:NumTurbines)
.FAST_Library.f90
that include a c-bindings interface now take the argumentiTurb_c
instead ofiTurb
. This is the index to the turbine using the c-style array indexing starting at 0. Internally this shifted by 1 and stored asiTurb
, a Fortran index starting at 1.Since the output names are set using the
TurbIDforName
variable, the name is completely independent of the internal numbering.Related issue, if one exists
Exawind/amr-wind#984
#2096
Impacted areas of the software
This will affect any codes calling OpenFAST using the
FAST_Library
interface using 1 as starting index for the first turbine -- these codes will need updating to use 0 as the index to the first turbine. This might affect NALU-Wind, and potentially SOWFA (I'm uncertain what interfaces those codes use, or what assumptions on indexing are made).Additional supporting information
The only place this ambiguity of indexing appeared is when a checkpoint file was written or read. It doesn't appear that anything else was affected.
Test results, if applicable
This will require testing by @marchdf and possibly others.