Improving the Fortran API
- Removes non-standard DEC$ directives
- Changes comments to F90 (!) from F77 (C)
- Adds semver major, minor, patch variables
- Changes semver version to a larger string
- Changes docstrings to be Doxygen abiding
- Changes module name from
gmsh_fortran
togmsh
- Changes file extension from
.h
to.f90
- Changes indentation to 4-space (fixed for now)
- Fixes & being erroneously placed at the start of newlines vs EOL
- Reformats variable commas, spacings, etc. to be consistent
- Removes hardlimit for procedures names> 45 to be excluded from the API
- Makes Fortran API more user friendly by:
- Allowing for Fortran arrays to be input
- Allowing for Fortran arrays to be output
- Allowing for Jagged arrays to be represented by a 1D array and a an array with the individual dimensions e.g.
array=[1, 2, 3, 4, 5]
anddims=[2, 3]
instead of what previously was ac_ptr
to thearray
ac_ptr
for thedims
array and ac_size_t
integer for the length ofdims
- Pairs are represented by arrays that are (2,n) in dimensions in Fortran, when passed to C the array gets unwrapped to a single 1D array where the first and second pair values i.e. (1,x) and (2,x) are contiguous in memory (Fortran is column major)
- Allowing Fortran strings to be input as names, they are then internally cast to C strings and a C null character is appended to all.
- Introduces the public integer variables,
GMSH_API_VERSION_MAJOR
,GMSH_API_VERSION_MINOR
,GMSH_API_VERSION_PATCH
andGMSH_API_MAX_STR_LEN
Requirements
The API uses optional arguments with the C interop so a Fortran 2018
or Fortran 2008+TS29113
compiler is required.
TODO List:
-
Abide by indent
, currently spacing manually set to 4spaces -
Add optional arguments for things such as gmshModelAddPhysicalGroup
Change names _n _nn to more descriptive names-
Simplify spacing between procedure types -
Convert API names to be user friendly get, set, etc. -
Convert Python strings to fstrings -
Free allocated memory in C -
Wrap lines to 132 chars; break bind(C,...) to next line, break arg list to next line, break C_API call to next line -
Change indentation to 2-spaces from 4
Additional
-
I would like to find a way to provide the Gmsh Fortran API via the Fortran Package Manager (fpm). We would only have to provide the single Fortran file (and possibly the tutorials as examples). I think the easiest way to do this would be from outside the main Gmsh repo. I use mostly GitHub so I will ping you there if I get it working.
-
I have added all the existing 21 tutorials for Fortran. I have tested all of them and they work as expected. Maybe we can add some CMake targets to build the examples.
-
I have not added anything about
flog
in the Fortran section of the Python GenApi.py script. I would be keen to leave this for another PR. -
File paths in tutorials are hardcoded e.g.
'../../input_file.stl'
so the tutorials will only work when run from UNIX shells