20#include "../base/base_uses.f90" 
   25   LOGICAL, 
PRIVATE, 
PARAMETER :: debug_this_module = .true.
 
   26   CHARACTER(len=*), 
PARAMETER, 
PRIVATE :: moduleN = 
'input_enumeration_types' 
   40      CHARACTER, 
DIMENSION(:), 
POINTER :: chars => null()
 
   44      INTEGER :: ref_count = 0
 
   45      CHARACTER(len=default_string_length), 
DIMENSION(:), 
POINTER :: c_vals => null()
 
   46      TYPE(char_array), 
DIMENSION(:), 
POINTER :: desc => null()
 
   47      INTEGER, 
DIMENSION(:), 
POINTER :: i_vals => null()
 
   48      LOGICAL :: strict = .false.
 
 
   65      CHARACTER(len=*), 
DIMENSION(:), 
INTENT(in)         :: c_vals
 
   66      INTEGER, 
DIMENSION(:), 
INTENT(in)                  :: i_vals
 
   67      CHARACTER(len=*), 
DIMENSION(:), 
INTENT(in), &
 
   69      LOGICAL, 
INTENT(in), 
OPTIONAL                      :: strict
 
   73      cpassert(.NOT. 
ASSOCIATED(enum))
 
   74      cpassert(
SIZE(c_vals) == 
SIZE(i_vals))
 
   77      ALLOCATE (enum%c_vals(
SIZE(c_vals)))
 
   78      DO i = 1, 
SIZE(enum%c_vals)
 
   79         cpassert(len_trim(c_vals(i)) > 0)
 
   80         enum%c_vals(i) = c_vals(i)
 
   83      ALLOCATE (enum%i_vals(
SIZE(i_vals)))
 
   86      IF (
PRESENT(strict)) enum%strict = strict
 
   87      ALLOCATE (enum%desc(
SIZE(c_vals)))
 
   88      IF (
PRESENT(desc)) 
THEN 
   89         cpassert(
SIZE(enum%desc) == 
SIZE(desc))
 
   90         DO i = 1, 
SIZE(enum%desc)
 
   92            ALLOCATE (enum%desc(i)%chars(n))
 
   94               enum%desc(i)%chars(j) = desc(i) (j:j)
 
   98         DO i = 1, 
SIZE(enum%desc)
 
   99            ALLOCATE (enum%desc(i)%chars(1))
 
  100            enum%desc(i)%chars(1:1) = 
' ' 
 
  113      cpassert(
ASSOCIATED(enum))
 
  114      cpassert(enum%ref_count > 0)
 
  115      enum%ref_count = enum%ref_count + 1
 
 
  128      IF (
ASSOCIATED(enum)) 
THEN 
  129         cpassert(enum%ref_count > 0)
 
  130         enum%ref_count = enum%ref_count - 1
 
  131         IF (enum%ref_count == 0) 
THEN 
  132            DEALLOCATE (enum%c_vals)
 
  133            DEALLOCATE (enum%i_vals)
 
  134            DO i = 1, 
SIZE(enum%desc)
 
  135               DEALLOCATE (enum%desc(i)%chars)
 
  137            DEALLOCATE (enum%desc)
 
 
  153      INTEGER, 
INTENT(in)                                :: i
 
  154      CHARACTER(len=default_string_length)               :: res
 
  159      cpassert(
ASSOCIATED(enum))
 
  160      cpassert(enum%ref_count > 0)
 
  163      DO j = 1, 
SIZE(enum%i_vals)
 
  164         IF (enum%i_vals(j) == i) 
THEN 
  170      IF (.NOT. found) 
THEN 
  171         IF (enum%strict) 
THEN 
  172            DO j = 1, 
SIZE(enum%desc)
 
  173               print *, trim(
a2s(enum%desc(j)%chars))
 
  174               print *, trim(enum%c_vals(j))
 
  179            cpabort(
"invalid value for enumeration:"//
cp_to_string(i))
 
 
  193      CHARACTER(len=*), 
INTENT(in)                       :: c
 
  196      CHARACTER(len=default_string_length)               :: upc
 
  200      cpassert(
ASSOCIATED(enum))
 
  201      cpassert(enum%ref_count > 0)
 
  202      upc = trim(adjustl(c)) 
 
  205      DO j = 1, 
SIZE(enum%c_vals)
 
  206         IF (enum%c_vals(j) == upc) 
THEN 
  213      IF (.NOT. found) 
THEN 
  215            cpabort(
"invalid value for enumeration:"//trim(c))
 
  216         READ (c, 
"(i10)", iostat=iostat) res
 
  218            cpabort(
"invalid value for enumeration2:"//trim(c))
 
 
various routines to log and control the output. The idea is that decisions about where to log should ...
Defines the basic variable types.
integer, parameter, public default_string_length
Utilities for string manipulations.
pure character(len=size(array)) function, public a2s(array)
Converts a character-array into a string.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.