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

Save registry structures to file without using a buffer #1986

Merged

Conversation

deslaughter
Copy link
Collaborator

This pull request is ready to be merged.

Feature or improvement description

This pull request changes the Registry and types files to pack/unpack data directly to/from a file without using temporary buffers; thereby reducing the memory used when generating a checkpoint file. This PR also updates the NWTC_Library so that the registry subroutines used by ModMeshMapping are automatically updated.

This PR also adds the ModVar module upon which the tight coupling changes are based.

Impacted areas of the software

NWTC_Library
*_Types.f90

Additional supporting information

The existing code generated by the OpenFAST registry to pack/unpack data structures to/from files used buffer arrays to temporarily store the data in memory before it was written. For models which require a large amount of data (InflowWind/SeaState); or which have a long runtime and use binary output; this could cause a significant amount of memory to be used. As these buffers grow, there is also the potential to overflow the indexing variable (typically an IntKi) which is only capable of representing a number up to 2,147,483,647. So if an array has more than 2 billion elements (which could happen when packing all the data into an array), the program will crash with a strange error.

Test results, if applicable

No test results changed. 5MW_OC3Mnpl_DLL_WTurb_WavesIrr_Restart, which checks the restart functionality, passed successfully.

The CMakeLists.txt now automatically generates modules based on the Registry_NWTC_Library_mesh.txt and Registry_NWTC_Library_base.txt files. It also concatenates these files to create the full Registry_NWTC_Library.txt which is included by other modules. The changes to Generate_NWTC_Library_types.bat replicate this behavior.
@andrew-platt
Copy link
Collaborator

andrew-platt commented Jan 16, 2024

I noticed that the file Registry_NWTC_Library_mesh.txt is used to generate NWTC_Library_Subs.f90. I'm wondering if we should consider changing the filename NWTC_Library_Subs.f90. I think all the other registry generated files currently end in _Types.f90, which kind of doesn't make sense for this file given it's contents.

Of course, if we do start auto-generating the params for each module through the registry (or similar) from csv files instead of the OutListParameters.xlsx, we'll have another set of auto-generated files using a file name other than *_Types.f90.

I don't have a solution here, just an observation.

Copy link
Collaborator

@andrew-platt andrew-platt left a comment

Choose a reason for hiding this comment

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

the help menu for the registry might have a typo

@@ -13,6 +13,7 @@ Usage: openfast_registry registryfile [options] -or-
-h this summary
-I <dir> look for usefrom files in directory "dir"
-O <dir> generate types files in directory "dir"
-inc generate types file to be included in another file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be subs for the new flag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to incsubs and updated documentation in new commit

@deslaughter
Copy link
Collaborator Author

I'd be fine with changing the name since this solution is a bit of a hack. The existing process requires two steps: 1) generate NWTC_Library_Types.f90 from Registry_NWTC_Library_mesh.txt and copy just the subroutines to ModMesh_Mapping.f90 2) generate the actual NWTC_Library_Types.f90 from Registry_NWTC_Library_base.txt. The new code generates just the subroutines from Registry_NWTC_Library_mesh.txt and stores it in NWTC_Library_Subs.f90 which is includeed in ModMesh_Mapping.f90

@andrew-platt
Copy link
Collaborator

andrew-platt commented Jan 16, 2024

I definitely like the new solution!

For the name, could we do something like _RegSubs.f90? Maybe not the best name, but it makes it a bit more distinct.

@deslaughter deslaughter merged commit 05aabd7 into OpenFAST:dev-unstable-pointers Jan 16, 2024
21 checks passed
@deslaughter deslaughter deleted the f/regpack-nobuf branch January 16, 2024 21:33
@andrew-platt andrew-platt mentioned this pull request Dec 24, 2024
38 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.

2 participants