Re: Including test "main" programs in modules?



David Simpson wrote:

I would like to have small "main" programs at the end of each module I
write, which basically run just that module for testing and as
examples. At the moment I have to comment these out when applied as
part of larger code which is using these modules, or to make separate
test programs for each module.

The two ways I think of now, are using the C preprocessor,

#ifdef TEST
#endif

You can set environment variables from the command line with most
compilers.

The other is D lines, I believe inherited by most current compilers
from a DEC feature. At least gfortran, g95, and ifort have it.

Instead of using C for a comment, you use D in column one for
debugging (or testing) code, with a compile time option to
treat it as a comment or code.

-- glen

.



Relevant Pages

  • Re: VC++ 2005 beta1 fails with pthreads benchmark tests
    ... >> It is not perror which sets errno ... > preserves errno (which you assume equals EAGAIN) or sets it to EAGAIN ... how do you explain the fact that compilers other than VC++2005 ... there are 122 test programs in total. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: GNU Fortran 95: Opinions?
    ... > F90/95 compilers, for use in the test suite. ... I've got plenty of that. ... that the codes they generate are test programs that should yield errors ...
    (comp.lang.fortran)
  • Re: Compilation problem with gfortran
    ... I'm trying to compile some code of mine with gfortran. ... Argument 'dydx' of pure subroutine 'rkckcontrolstep' at must ... Sun compilers accept this, but I appreciate that that isn't a definitive ...
    (comp.lang.fortran)
  • Re: gfortran/ifort format issues in files
    ... while the gfortran version uses LF only. ... If both compilers can read files with either terminator, ... subroutine read_line (infile, line, ios)! ...
    (comp.lang.fortran)
  • Re: OpenMP "not working" on gfortran
    ... the OpenMP code I wrote works on Mac OS X gfortran 4.5.2. ... and both of these compilers result in no speedup. ...
    (comp.lang.fortran)