OOMMF Programming Manual

Chapter 3 OOMMF Variable Types and Macros

The following typedefs are defined in the oommf/pkg/oc/platform/ocport.h header file; this file is created by the pimake build process (see oommf/pkg/oc/procs.tcl), and contains platform and machine specific information.

  • OC_BOOL   Boolean type, unspecified width.

  • OC_BYTE   Unsigned integer type exactly one byte wide.

  • OC_CHAR   Character type, may be signed or unsigned.

  • OC_UCHAR   Unsigned character type.

  • OC_SCHAR   Signed character type. If signed char is not supported by a given compiler, then this falls back to a plain char, so use with caution.

  • OC_INT2, OC_INT4   Signed integer with width of exactly 2, respectively 4, bytes.

  • OC_INT2m, OC_INT4m   Signed integer with width of at least 2, respectively 4, bytes. A type wider than the minimum may be specified if the wider type is handled faster by the particular machine.

  • OC_UINT2, OC_UINT4, OC_UINT2m, OC_UINT4m   Unsigned integer versions of the preceding.

  • OC_REAL4, OC_REAL8   Four byte, respectively eight byte, floating point variable. Typically corresponds to C++ “float” and “double” types.

  • OC_REAL4m, OC_REAL8m   Floating point variable with width of at least 4, respectively 8, bytes. A type wider than the minimum may be specified if the wider type is handled faster by the particular machine.

  • OC_REALWIDE   Widest type natively supported by the underlying hardware. This is usually the C++ “long double” type, but may be overridden by the

    program_compiler_c++_typedef_realwide

    option in the oommf/config/platform/platform.tcl file.

The oommf/pkg/oc/platform/ocport.h header file also defines the following macros for use with the floating point variable types:

  • OC_REAL8m_IS_DOUBLE   True if OC_REAL8m type corresponds to the C++ “double” type.

  • OC_REAL8m_IS_REAL8   True if OC_REAL8m and OC_REAL8 refer to the same type.

  • OC_REAL4_EPSILON   The smallest value that can be added to a OC_REAL4 value of “1.0” and yield a value different from “1.0”. For IEEE 754 compatible floating point, this should be 1.1920929e-007.

  • OC_SQRT_REAL4_EPSILON   Square root of the preceding.

  • OC_REAL8_EPSILON   The smallest value that can be added to a OC_REAL8 value of “1.0” and yield a value different from “1.0”. For IEEE 754 compatible floating point, this should be 2.2204460492503131e-016.

  • OC_SQRT_REAL8_EPSILON, OC_CUBE_ROOT_REAL8_EPSILON   Square and cube roots of the preceding.

  • OC_FP_REGISTER_EXTRA_PRECISION   True if intermediate floating point operations use a wider precision than the floating point variable type; notably, this occurs with some compilers on x86 hardware.

Note that all of the above macros have a leading “OC_” prefix. The prefix is intended to protect against possible name collisions with system header files. Versions of some of these macros are also defined without the prefix; these definitions represent backward support for existing OOMMF extensions. All new code should use the versions with the “OC_” prefix, and old code should be updated where possible. The complete list of deprecated macros is:

BOOL, UINT2m, INT4m, UINT4m, REAL4, REAL4m, REAL8, REAL8m, REALWIDE, REAL4_EPSILON, REAL8_EPSILON, SQRT_REAL8_EPSILON, CUBE_ROOT_REAL8_EPSILON, FP_REGISTER_EXTRA_PRECISION

Macros for system identification:

  • OC_SYSTEM_TYPE   One of OC_UNIX or OC_WINDOWS.

  • OC_SYSTEM_SUBTYPE   For unix systems, this is either OC_VANILLA (general unix) or OC_DARWIN (Mac OS X). For Windows systems, this is generally OC_WINNT, unless one is running out of a Cygwin shell, in which case the value is OC_CYGWIN.

Additional macros and typedefs:

  • OC_POINTERWIDTH   Width of pointer type, in bytes.

  • OC_INDEX   Typedef for signed array index type; typically the width of this (integer) type matches the width of the pointer type, but is in any event at least four bytes wide and not narrower than the pointer type.

  • OC_UINDEX   Typedef for unsigned version of OC_INDEX. It is intended for special-purpose use only. In general, use OC_INDEX where possible.

  • OC_INDEX_WIDTH   Width of OC_INDEX type.

  • OC_BYTEORDER Either “4321” for little endian machines, or “1234” for big endian.

  • OC_THROW(x)   Throws a C++ exception with value “x”.

  • OOMMF_THREADS   True for threaded (multi-processing) builds.

  • OC_USE_NUMA   If true, then NUMA (non-uniform memory access) libraries are available.