openfast
openfast copied to clipboard
SubDyn stack overflow for structures with large number of members, with Windows/VisualStudio
Bug description "Stack overflow" is issued when running with a jacket. In my case the jacket have 383 members.
To Reproduce Run with a substructure with a lot of joint/members.
Expected behavior
It should work...
However, this is also an easy fix. Just increase the stack size for the linker. I've increased to 512 Mb (from I think 9999999.)
Screenshots, if applicable <Add screenshots to help explain your problem.>
OpenFAST Version <Please provide as much detail as possible including git commit. The best information is a screenshot of the OpenFAST system description that prints when running OpenFAST:>
**************************************************************************************************
OpenFAST
Copyright (C) National Renewable Energy Laboratory
Copyright (C) Envision Energy USA LTD
This program is licensed under Apache License Version 2.0 and comes with ABSOLUTELY NO WARRANTY.
See the "LICENSE" file distributed with this software for details.
**************************************************************************************************
OpenFAST-v2.0.0
Compile Info:
- Architecture: 64 bit
- Precision: double
- Date: Nov 27 2018
- Time: 17:19:38
Execution Info:
- Date: 11/29/2018
- Time: 10:52:28-0700
System Information (please complete the following information):
- OS: <e.g. Ubuntu 14.04 or macOS 10.12>
- Compiler: <e.g. GFortran 4.4>
- Compiler settings: <e.g. CMake flags or other settings>
Additional context <Add any other context about the problem here.>
Hi @Ry8icks, Thank you for your report. Is the system information you listed correct? It seems you are using visual studio on Windows, no? Did you run OpenFAST or the SubDyn driver?
naah , here's the correct info: OpenFAST-v3.0.0-dirty Compile Info:
- Compiler: Intel(R) Fortran Compiler 1910
- Architecture: 64 bit
- Precision: single
- OpenMP: No
- Date: Sep 27 2021
- Time: 16:55:23 Execution Info:
- Date: 10/01/2021
- Time: 16:12:12+0200
and yes, I'm using Visual Studio with the latest Intel Visual Fortran Compiler. And, I was running a recompiled version of Openfast.
We can introduce these changes in our solution, I agree that these should be increased. 512Mb seems a bit excessive, is it the minimum you could use?
I'm a bit rusty on that, but I know some of the old code of SubDyn uses a lot of assumed-shape arrays, which I believe uses the stack. I wonder if that could be the main issue. Do you know the specific lines that lead to stack overflow? Could you maybe share your SubDyn model here?
@bjonkman @rafmudaf @andrew-platt. Do you have any preferences regarding the allowing stack size limit?
@ebranlard , I think increasing the stack size is a short-term solution. I don't think this will be sufficient to solve the issue if someone were to run that model in the FAST S-Function for Simulink, though, so it would probably be better to avoid using the stack for large variables if possible. I got rid of some of those calls that use a lot stack space a while ago--just enough to get the model we were using to run. I'm sure there is more to be done, though. Any equation with transpose()
or matmul()
in SubDyn is suspect. For example, I see one matrix equation that is in the form S = matmul(A,B) + matmul(C,D) + E
, which will be a problem if any of those matrices are allowed to be large.
@bjonkman, thanks for your input. I must admit I have only lazily replaced the matmul calls with lapack calls and introducing intermediate variables, depending on which ones where big matrices, and whenever I ran into stack issues (mostly for win32). I should do another pass through the code to replace those.
@Ry8icks if you can share a dummy model, I could use it to fix these calls (the largest model I've used was the OC4 jacket with a large NDIV and number of modes).
It might take a couple of months before I get to it. I hope you are fine with changing the stack size for now.
I'm not able to recreate the problem. I set the stack size to 8 Mb and it still worked. It's been a bit trial and errors, i.e. update of the input files and update of the code and now I've lost track of it all. In either case the following files work on my version of Openfast. I've made some corrections to the code which I've already reported, e.g. increased number of joints connected to a joint to 10. It should be noted that some of the parameters as given in the files are a bit arbitrary.
Pile_stiff_matrix.txt Openfast__subdyn.txt Openfast__hydrodyn.txt