      MODULE MDCOMPONENTS
      
      USE kindef
      USE memory

      IMPLICIT NONE

      SAVE

      INTEGER (INT4), PARAMETER :: LIM_COMPONENTS = 1000;
      INTEGER (INT4) :: NUM_COMPONENTS = 0, NCOMP;
      TYPE COMPONENT
        CHARACTER (LEN=30) :: NAME
        INTEGER (INT4) :: NUM_PART
        REAL (REAL8), DIMENSION(:), POINTER :: PART_LIST
      END TYPE

      TYPE COMPONENT_POINTER 
        TYPE (COMPONENT), POINTER :: P
      END TYPE

      TYPE (COMPONENT), POINTER :: COMP
      TYPE (COMPONENT_POINTER) :: COMP_TMP
      TYPE (COMPONENT_POINTER), DIMENSION(LIM_COMPONENTS) :: COMPONENTS, COMPONENTS_TMP

      INTERFACE MEMDEALLOC
        MODULE PROCEDURE MEMDEALLOC_COMPONENTS_PTR
      END INTERFACE
  
      CONTAINS

      SUBROUTINE ADD_COMPONENTS

      NUM_COMPONENTS = NUM_COMPONENTS + 1
      CALL MEMALLOC (COMPONENTS(NUM_COMPONENTS)%P, IDALL999)

      END SUBROUTINE ADD_COMPONENTS

      END MODULE MDCOMPONENTS
