OpenFAST / openfast

Main repository for the NREL-supported OpenFAST whole-turbine and FAST.Farm wind farm simulation codes.
http://openfast.readthedocs.io
Apache License 2.0
671 stars 453 forks source link

SubDyn stack overflow for structures with large number of members, with Windows/VisualStudio #843

Open Ry8icks opened 2 years ago

Ry8icks commented 2 years ago

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.) image

Screenshots, if applicable

**OpenFAST Version** ``` ************************************************************************************************** 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: - Compiler: - Compiler settings: **Additional context**
ebranlard commented 2 years ago

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?

Ry8icks commented 2 years ago

naah , here's the correct info: OpenFAST-v3.0.0-dirty Compile Info:

and yes, I'm using Visual Studio with the latest Intel Visual Fortran Compiler. And, I was running a recompiled version of Openfast.

ebranlard commented 2 years ago

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?

bjonkman commented 2 years ago

@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.

ebranlard commented 2 years ago

@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.

Ry8icks commented 2 years ago

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