Standalone geometry program

Open
#265 · Created  · Last updated

Description

I originally did this work about a year ago but it was difficult to review and merge because it was mixed in with a load of other changes and depended on other PRs. Therefore, I have made this new branch from an up-to-date next (and new PR directly into next) and I have re-applied the minimal set of changes that are necessary to implement this feature alone. I have also tried to present the commits in a way that will be easy to review.

This work was reviewed last time and the previous comments are addressed in the commits here. See declined PR #83 for details.

I have tested this by running make tests on each commit (all passed), and running dump_geometry on an input file that is empty apart from nstep = 0 and comparing the output to that from running gs2 on the same input file. The output data is exactly the same to full precision, as expected. dump_grids runs in ~0.1 second on one core of my local machine which is a speedup of ~10, even on a very small case like this. Obviously for larger cases that take many minutes to initialise on many cores, this is a useful little tool if one is only interested in the geometry (which was the case for me at the time of writing).

Automatic description from commit messages:

  • Remove dead code in gs2_io that could never be run

    This was done in anticipation of making changes in this area in order to simplify those changes.

    serial_io, proc_write and netcdf_init are not used in any other module (confirmed with find -type f -exec grep -Hi 'serial_io' {} \; and similar) so we don’t need to worry about breaking code anywhere else.

    serial_io is a parameter set to true and is not within a pre-processor #ifdef block for parallel NetCDF. Therefore, serial_io is always true and the if(serial_io) block will never run the else part, hence that has been deleted.

    Furthermore, the call to netcdf_init does not need serial_io as a parameter since it is always true, so the assignment of proc_write reduces to proc_write = proc0.

    However, proc_write is never used so the call to netcdf_init is completely redundant.

    While this probably only adds a few nanoseconds to the run time, this does negatively impact readability and maintainability of the code. Dead code should always be deleted (so long as it is definitely dead). This code is definitely dead so has been deleted. This will also simplify future changes in this area (including those I plan to make in the next commit).

  • Extract geometry output subroutines

    This was done in advance of re-using this functionality in a standalone geometry program.

  • Extract definition subroutines to remove duplication

  • Add standalone geometry program

    This was done so that one can dump the geometry variables calculated from a given input file without having to initialise the rest of GS2. This reduces the run time because the usual GS2 initialisation does some steps to set up the matrix. In practice, this means we can access the geometry variables in < 1 second on 1 processor, rather than potentially many minutes on many cores.

 

0 attachments

0 comments

Loading commits...