mctc_env Module

Environment module providing common utilities and error handling.

This module exports fundamental types and constants used throughout mctc-lib:

  • error_type: Allocatable error type for error propagation
  • fatal_error: Subroutine to create error messages
  • wp: Working precision for real numbers (double precision)
  • sp, dp: Single and double precision kind parameters
  • i1, i2, i4, i8: Integer kind parameters (1, 2, 4, 8 bytes)

Error handling follows a simple pattern: pass an allocatable error_type to library routines, then check if it is allocated to detect errors.

Example usage:

 use mctc_env
 type(error_type), allocatable :: error

 call some_routine(result, error)
 if (allocated(error)) then
    print '(a)', error%message
    error stop
 end if