Skip to content

Coding conventions

lcirrott edited this page Dec 5, 2019 · 1 revision

File indentation and white spaces

  • No tabs: Use spaces instead of tabs;
  • 2 spaces indentation;
  • Remove trailing whitespaces from lines;
  • Line length is limited to 80 characters.

Coding style

  • Add the PMMG_ prefix to all functions, macros and global variables
void PMMG_init(void);
  • Suffix all file names by _pmmg
grpsplit_pmmg.c
  • Struct type names starting with "p" after the PMMG_ prefix are pointers to the type without the "p"
PMMG_pGrp is a PMMG_Grp*

Minimal documentation

Internal function

Please, use Doxygen to document your functions. Each function must at least contain the following information using the following style:

/**
 * \param parmesh pointer toward the parmesh sturcture
 * \param param1 blabla
 * \param param2 blabla
 *
 * \return Possible return values and explanation
 *
 * My function does blablabla.
 *
 */
int PMMG_myFunction( PMMG_pParMesh parmesh, double param1, int param2 ) {...}

API function

The fortran header file is automatically generated from a C/Perl script and the libparmmg.h header file. To be able to do that, the libparmmg.h file must contain the Doxygen documentation related to the API functions and this documentation must contain a remark section with the fortran interface denoted by ** * > **. Please, look at the following example and use the same formalism (note that each space and special character is important, thus, change only what is mandatory):

/**
 * \param parmesh pointer toward the parmesh structure
 * \param param1 blabla
 * \param param2 blabla
 *
 * \return Possible return values and explanation
 *
 * My function does blablabla.
 *
 * \remark Fortran interface:
 * >   SUBROUTINE MMG3D_MMG3DCHECK(parmesh,param1,param2,retval)\n
 * >     PMMG_DATA_PTR_T, INTENT(INOUT)      :: parmesh\n
 * >     REAL(KIND=8), INTENT(IN)            :: param1\n
 * >     INTEGER, INTENT(IN)                     :: param2\n
 * >     INTEGER, INTENT(OUT)                 :: retval\n
 * >   END SUBROUTINE\n
 *
 */
int PMMG_myFunction( PMMG_pParMesh parmesh,double param1, int param2 ) {...}