Skip to content

AeroDyn/UnsteadyAero_Driver: Fix for bug #1346#1347

Merged
ebranlard merged 4 commits intoOpenFAST:mainfrom
RiekeJ:UA_driver_bug
Nov 24, 2022
Merged

AeroDyn/UnsteadyAero_Driver: Fix for bug #1346#1347
ebranlard merged 4 commits intoOpenFAST:mainfrom
RiekeJ:UA_driver_bug

Conversation

@RiekeJ
Copy link
Contributor

@RiekeJ RiekeJ commented Nov 23, 2022

This pull request fixes a bug in AeroDyn/UnsteadyAero_Driver:

bug #1346: If SimMod==1 (reduced frequency model) is used, non-allocated variables are handed over to subroutines with intent(in), which causes a runtime error.

Feature or improvement description
Fix for bug #1346, added some if clauses and making some arrays 'optional'.

Related issue, if one exists
none

Impacted areas of the software
AeroDyn -> UnsteadyAero_Driver.f90

Additional supporting information
UnsteadyAero_Driver is only used for stand-alone run of a single airfoil unsteady aerodynamics tests.

…ency model) is used. Un-allocated variables are handed over to subroutines with intent(in), which causes a runtime error.
@andrew-platt
Copy link
Collaborator

There may be some additional logic required for the optional inputs. I don't know this code very well. @bjonkman could you take a look at it?

Copy link
Contributor

@ebranlard ebranlard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks great, thanks for doing that!
I have minor comments below.

@ebranlard
Copy link
Contributor

As a side note, we currently don't have r-tests for unsteady aerodynamics. I think it's because it requires a recompile of OpenFAST with -DUA_OUTS=ON. Now that we have a split compilation/testing process on github action, we could do that!

@ebranlard
Copy link
Contributor

Thank you for doing the changes and fixing this bug!

(we indeed use 3 spaces for indentation. As for indenting the comments and the "error checks" 3 extra spaces, that's not my favorite style, but it is present elsewhere in the code and has been adopted by other developers.).

@ebranlard ebranlard merged commit 1cf9d26 into OpenFAST:main Nov 24, 2022
ebranlard added a commit that referenced this pull request Nov 24, 2022
@RiekeJ RiekeJ deleted the UA_driver_bug branch November 25, 2022 07:44
u%v_ac(1) = sin(u%alpha)*u%U
u%v_ac(2) = cos(u%alpha)*u%U
else
errStat = -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrStat should be set to ErrID_Fatal here. All of the error handling in OpenFAST assumes that errors are values > 0, and it's best practice to use the error level parameters.

Also, ErrStat and ErrMsg are not initialized in the other branches of the nested IF statement. So, this will result in unpredictable results on some compilers.

indx = min(n,size(timeArr))
indx = max(1, indx) ! use constant data at initialization
! check optional variables and allocation status
if (any( (/ allocated(timeArr),allocated(AOAarr),allocated(OmegaArr),allocated(Uarr) /) )) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the error message below, I think you want to use all() instead of any() here.

@RiekeJ
Copy link
Contributor Author

RiekeJ commented Nov 28, 2022

Hi,
Bonnie, you're right. The fix is not complete nor fully correct.

We need to add:

@@ -304,7 +305,20 @@ subroutine setUAinputs(n,u,t,dt,dvrInitInp,timeArr,AOAarr,Uarr,OmegaArr)
304 +   ErrStat   = ErrID_None           ! no error has occurred
305 +   ErrMsg    = ""

And further correct:

@@ -341,10 +341,104 @@ subroutine setUAinputs(n,u,t,dt,dvrInitInp,timeArr,AOAarr,Uarr,OmegaArr)
341 -   if (any( (/ allocated(timeArr),allocated(AOAarr),allocated(OmegaArr),allocated(Uarr) /) )) then
341 +   if (all( (/ allocated(timeArr),allocated(AOAarr),allocated(OmegaArr),allocated(Uarr) /) )) then

And also:

@@ -359,13 +359,33 @@ subroutine setUAinputs(n,u,t,dt,dvrInitInp,timeArr,AOAarr,Uarr,OmegaArr)
359 -   errStat = -1
359 +   errStat = ErrID_Fatal

BR,
Johannes

@ebranlard
Copy link
Contributor

We have now reverted this pull request.

@RiekeJ can you redo your pull request? If possible, chose "dev" as the target branch for your pull request (I didn't notice, but I've merged this pull request into main. I should have spotted that.).

@andrew-platt
Copy link
Collaborator

@RiekeJ, our apologies for the mixup on our end with merging.

The corrections you posted above look good!

@RiekeJ
Copy link
Contributor Author

RiekeJ commented Nov 29, 2022

Hi,
now I'm a little bit confused. How can I help now. Should I create a new pull request? Unfortunately, I had already deleted my fork of OpenFAST, but I can fork it again and can create a new branch + pull request. Let me know, please, how to proceed.

@andrew-platt
Copy link
Collaborator

@RiekJ, I'm sorry about all the confusion here. We had a mixup on our end with the merge. I recreated the PR using your commit, and added the modifications from your comment above. See #1356

Again, my apologies for the issues on our end. And many thanks for contributing your code improvements!

@RiekeJ
Copy link
Contributor Author

RiekeJ commented Nov 29, 2022

@andrew-platt no worries. I'm happy, that I could contribute here a tiny bit. Thanks for having OpenFAST, which is really a great tool.

@rafmudaf rafmudaf mentioned this pull request Dec 19, 2022
10 tasks
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.

4 participants

Comments