A.3 Verify m4 Macros

The main documentation of the Verify m4 Macros contains additional explanation of this code listing.

dnl
dnl Author: Michael L. Hall
dnl         P.O. Box 1663, MS-D409, LANL
dnl         Los Alamos, NM 87545
dnl         ph: 505-665-4312
dnl         email: hall@lanl.gov
dnl 
dnl Created on: 02/19/98
dnl Date:       09/18/00, 20:45:35
dnl Version:    6.0


dnl Initialize the DEBUG_LEVEL and WARNING_LEVEL to zero if they
dnl are not already defined.

ifdef([DEBUG_LEVEL], [
],[
  define([DEBUG_LEVEL], 0)
])

ifdef([WARNING_LEVEL], [
],[
  define([WARNING_LEVEL], 0)
])


dnl Set the default communication style.

define([VERIFY_COMMUNICATION],[Global])


dnl Define the VERIFY macro.

define([VERIFY], [
  ifelse(m4_eval(DEBUG_LEVEL >= $2), 1, [
    define([HIDE], [])
  ],m4_eval(DEBUG_LEVEL == -1), 1, [
    define([HIDE], [[!]])
  ],[
    define([HIDE], [[!]])
  ])
  define([COMMAND_TEXT],m4_changequote(["],["])$1[]m4_changequote("[","]"))
  ifelse(VERIFY_COMMUNICATION, Global, [
    HIDE if (.not. Global_ALL($1)) then
    HIDE   if (this_is_IO_PE) then
    HIDE     write (6,*) "Verification failed: ", &
    HIDE                 "COMMAND_TEXT, ", &
    HIDE                 "file __file__, ", &
    HIDE                 "line __line__."
    HIDE   end if
    HIDE   call Abort
    HIDE end if
  ],[
    HIDE if (.not. ($1)) then
    HIDE   write (6,*) "Verification failed: ", &
    HIDE               "COMMAND_TEXT, ", &
    HIDE               "file __file__, ", &
    HIDE               "line __line__."
    HIDE   stop
    HIDE end if
  ])
  undefine([COMMAND_TEXT])
  undefine([HIDE])
])


dnl Define the WARN_IF macro.

define([WARN_IF], [
  ifelse(m4_eval(WARNING_LEVEL >= $2), 1, [
    define([HIDE], [])
  ],m4_eval(WARNING_LEVEL == -1), 1, [
    define([HIDE], [[!]])
  ],[
    define([HIDE], [[!]])
  ])
  define([COMMAND_TEXT],m4_changequote(["],["])$1[]m4_changequote("[","]"))
  ifelse(VERIFY_COMMUNICATION, Global, [
    HIDE if (Global_ANY($1)) then
    HIDE   if (this_is_IO_PE) then
    HIDE     write (6,*) "Warning - test failed: ", &
    HIDE                 "COMMAND_TEXT, ", &
    HIDE                 "file __file__, ", &
    HIDE                 "line __line__."
    HIDE   end if
    HIDE end if
  ],[
    HIDE if ($1) then
    HIDE   write (6,*) "Warning - test failed: ", &
    HIDE               "COMMAND_TEXT, ", &
    HIDE               "file __file__, ", &
    HIDE               "line __line__."
    HIDE end if
  ])
  undefine([COMMAND_TEXT])
  undefine([HIDE])
])


Michael L. Hall