Hi Algiane and Luca,
it would be very nice to have information on the version number inside a dedicated .h file.
This will greatly facilitate the maintenance of our code when the interface of a function changes from one version to the other…
This can be implemented like this this (inspired from PETSC):
#if !defined(MMGVERSION_H)
#define MMGVERSION_H
#define MMG_VERSION_RELEASE 5
#define MMG_VERSION_MAJOR 4
#define MMG_VERSION_MINOR 4
#define MMG_VERSION_SUBMINOR 0
#define MMG_VERSION_PATCH 0
#define MMG_RELEASE_DATE “Oct 1, 2020”
#define MMG_VERSION_EQ(MAJOR,MINOR,SUBMINOR)
((MMG_VERSION_MAJOR == (MAJOR)) &&
(MMG_VERSION_MINOR == (MINOR)) &&
(MMG_VERSION_SUBMINOR == (SUBMINOR)) &&
(MMG_VERSION_RELEASE == 5))
#define MMG_VERSION_ MMG_VERSION_EQ
#define MMG_VERSION_LT(MAJOR,MINOR,SUBMINOR)
(MMG_VERSION_RELEASE == 5 &&
(MMG_VERSION_MAJOR < (MAJOR) ||
(MMG_VERSION_MAJOR == (MAJOR) &&
(MMG_VERSION_MINOR < (MINOR) ||
(MMG_VERSION_MINOR == (MINOR) &&
(MMG_VERSION_SUBMINOR < (SUBMINOR)))))))
#define MMG_VERSION_LE(MAJOR,MINOR,SUBMINOR)
(MMG_VERSION_LT(MAJOR,MINOR,SUBMINOR) ||
MMG_VERSION_EQ(MAJOR,MINOR,SUBMINOR))
#define MMG_VERSION_GT(MAJOR,MINOR,SUBMINOR)
(0 == MMG_VERSION_LE(MAJOR,MINOR,SUBMINOR))
#define MMG_VERSION_GE(MAJOR,MINOR,SUBMINOR)
(0 == MMG_VERSION_LT(MAJOR,MINOR,SUBMINOR))
#endif
which can then be used (in Fortran) as:
#include “mmgversion.h”
#if MMG_VERSION_LE(5,4,3)
call MMG2D_SET_MESHSIZE(mesh,np,nt,na,retval)
#else
call MMG2D_SET_MESHSIZE(mesh,np,nt,nquad,na,retval)
#endif
#endif
Ideally, it could also include information about the git branch (master, develop, …)
In the above example, the interface is different between the last official release (5.4.3) and the development branch: this is not easy to track (maybe the develop branch could be indicated with a patch number >0)…
Thanks!
Ghislain