Last spring Phil Austin had an interesting post in which he
implemented C-style assertions in Fortran 90 using the Fortran
preprocessor fpp. The key component of his implementation
was a macro definition similar to
#define assert(EXPR) if (.not.(EXPR)) call assert_failed(#EXPR)
Here EXPR is a logical expression and #EXPR is supposed to be
its "stringification" -- that is, EXPR enclosed in quotes. Using
# to turn a macro argument into a string is standard for cpp, and
apparently works also for Sun's fpp (according to Phil). However
it doesn't work for the fpp shipped with NAG's f95.
o Is there a standard specification for fpp (ISO tech report?)
o Where can one find complete documentation for fpp? I found a
short 4 page paper on Sun's web site but it's very incomplete.
(Major gripe: although NAG included fpp with its f95, they didn't
bother to include _any_ documentation for it >:-|
o Can anyone think of a trick to get a macro argument enclosed in
quotes? No, "EXPR" in the replacement text won't work -- the
quotes prevent EXPR from being replaced by the value of the argument.
Thanks!
------------------------------------------------------------------------
Neil N. Carlson 505-665-1220 (voice)
T-1, MS B221 505-665-5757 (fax)
Los Alamos National Laboratory [log in to unmask] (work)
Los Alamos, New Mexico 87545 [log in to unmask] (non-work)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|