Test fypp to generate templated containers#3
Draft
Manangka wants to merge 1 commit into
Draft
Conversation
This file contains hidden or 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
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 PR is a prototype for testing fypp to generate classes
It occurred more to once to me that i needed a data container that is avaialble in ource code base but with the different kind of type. The solution has always been to just copy that class and replace the type with the type i needed.
This results in code that has a lot of duplication. To prevent this it would be great to have something like c++ templating.
In C++, if you need a vector of a certain type you can specify that in brackets e.g. vector, vector, vec.
Fortran doesn't support that. There is however a package that performs this as a preprossecing step, fypp.
In this PR I tested that with the existing STLVector class in MODFLOW. I moved its content to a template class and then used it to generate a STLVecInt and STLVecDouble class. I'm pretty sure that it can also generate a vector class of a custom type e.g. STLVecParticleTrackRecordType
The way it is implemented in this PR is that the template generation happens as a custom target in the meson project and as a prebuildstep in the visual studio project. That way whenever the template is altered the new classes are automatically generated.
This however does not work for the existing make files because as far as i know they can't call a preprocessin step generate the templated files.
An alternative therefore would be to have the generation of the classes as a manual step and have the developers check in the generated files
Some of the containers that could be made more generic are listed below
Containers in MODFLOW:
It would also be possible to expend these containers with concepts like iterators and have generic algorithms be applied to them
Checklist of items for pull request
ruffon new and modified python scripts in .doc, autotests, doc, distribution, pymake, and utils subdirectories.fprettifyFor additional information see instructions for contributing and instructions for developing.