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

37 fortran interface null terminated strings #41

Merged
merged 9 commits into from
Aug 10, 2022

Conversation

mo-mglover
Copy link
Collaborator

Wraps the profiler_start interface with a subroutine that concatenates c_null_char onto the end of the region name. It also changes the name argument to region_name so as to not clash with a piece of Fortran syntax. (It shouldn't cause an issue, but just to be on the safe side.)

There is also a change to the Doxygen configuration. These changes are a tad tangential, but I thought I'd include them while I was making changes to the comment blocks in profiler_mod. I noticed that later versions of Doxygen (installed on site) don't recognise .F90 as being Fortran files; hence they didn't appear in the output documentation. The Doxygen configuration changes represent a patch for that.

Reason I was trying later Doxygen versions: there doesn't seem to be away of getting comment blocks for Fortran interfaces to appear in the Doxygen output. Not even with @fn. There's a wider issue open already (#38) covering Doxygen stuff as a whole. Getting that to work is beyond the scope of the present changes.

@mo-mglover mo-mglover linked an issue Aug 8, 2022 that may be closed by this pull request
@mo-mglover mo-mglover self-assigned this Aug 8, 2022
@mo-mglover mo-mglover added the ready for review ready for review label Aug 9, 2022
Copy link

@bencopl bencopl left a comment

Choose a reason for hiding this comment

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

image

Changes were tested with my fortran test case which times a main program plus three subroutines, and it works absolutely fine (see attached image above). It just 'magically works' without me having to make any changes to how the profiler is called which is nice.

The code itself makes sense and formatting is kept consistent, I only left a couple of comments which are more queries from me rather than huge issues - it clearly works OK as is.

src/f/profiler_mod.F90 Show resolved Hide resolved
src/f/profiler_mod.F90 Outdated Show resolved Hide resolved
Copy link
Collaborator

@andrewcoughtrie andrewcoughtrie left a comment

Choose a reason for hiding this comment

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

Looks good on the whole, just a couple of points to address. Returning to @mo-mglover.

@@ -21,6 +21,8 @@ function(enable_doxygen)
set(DOXYGEN_JAVADOC_BLOCK NO)
set(DOXYGEN_FULL_PATH_NAMES NO)
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
set(DOXYGEN_FILE_PATTERNS *.c *.cpp *.h *.f90 *.F90 )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because you're now defining the specific file extensions Doxygen no longer picks up the .md file used for the front page, adding *.md to this list should fix this though it will add the directory to the list of files shown in the Doxygen pages even if here isn't anything there.

!-----------------------------------------------------------------------------
contains

!> @brief Start a profiled region, taking care to add a C null character to
Copy link
Collaborator

Choose a reason for hiding this comment

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

The @brief here should be for the user, describing that the subroutine is adding a null character doesn't seem right for the API documentation. A normal comment inside the subroutine would probably be better i think.

Copy link
Collaborator Author

@mo-mglover mo-mglover Aug 9, 2022

Choose a reason for hiding this comment

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

I'll move it into a @note. I think it's important that it mentions the null character on the tin: it tells the Fortran programmer that they need not add one explicitly in higher-level code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me.

@andrewcoughtrie andrewcoughtrie added under review Pull request being reviewed and removed ready for review ready for review labels Aug 10, 2022
Copy link
Collaborator

@andrewcoughtrie andrewcoughtrie left a comment

Choose a reason for hiding this comment

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

The requested changes have been done so I'm happy this passes review.

@andrewcoughtrie andrewcoughtrie added ready to be merged and removed under review Pull request being reviewed labels Aug 10, 2022
Copy link
Collaborator

@andrewcoughtrie andrewcoughtrie left a comment

Choose a reason for hiding this comment

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

Updated Changelog

@andrewcoughtrie andrewcoughtrie merged commit 7c07c76 into main Aug 10, 2022
@andrewcoughtrie andrewcoughtrie deleted the 37-fortran-interface-null-terminated-strings branch August 10, 2022 13:57
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.

Fortran interface: null terminated strings
3 participants