MODULE GWFCHDMODULE
  INTEGER,SAVE,POINTER  ::NCHDS,MXCHD,NCHDVL,IPRCHD
  INTEGER,SAVE,POINTER  ::NPCHD,ICHDPB,NNPCHD
  CHARACTER(LEN=16),SAVE, DIMENSION(:),   POINTER     ::CHDAUX
  double precision, SAVE, DIMENSION(:,:), POINTER     ::CHDS
  
  TYPE GWFCHDTYPE
    INTEGER,POINTER  ::NCHDS,MXCHD,NCHDVL,IPRCHD
    INTEGER,POINTER  ::NPCHD,ICHDPB,NNPCHD
    CHARACTER(LEN=16), DIMENSION(:),   POINTER     ::CHDAUX
    double precision,  DIMENSION(:,:), POINTER     ::CHDS
  END TYPE

  TYPE(GWFCHDTYPE),SAVE   ::GWFCHDDAT(10)

contains

  SUBROUTINE GWF2CHD7DA(IGRID)
    !  Deallocate CHD data for a grid
    !
    DEALLOCATE(GWFCHDDAT(IGRID)%NCHDS)
    DEALLOCATE(GWFCHDDAT(IGRID)%MXCHD)
    DEALLOCATE(GWFCHDDAT(IGRID)%NCHDVL)
    DEALLOCATE(GWFCHDDAT(IGRID)%IPRCHD)
    DEALLOCATE(GWFCHDDAT(IGRID)%NPCHD)
    DEALLOCATE(GWFCHDDAT(IGRID)%ICHDPB)
    DEALLOCATE(GWFCHDDAT(IGRID)%NNPCHD)
    DEALLOCATE(GWFCHDDAT(IGRID)%CHDAUX)
    DEALLOCATE(GWFCHDDAT(IGRID)%CHDS)
    !
    RETURN
  END SUBROUTINE GWF2CHD7DA

  SUBROUTINE SGWF2CHD7PNT(IGRID)
    !  Set pointers to CHD data for a grid
    !
    NCHDS=>GWFCHDDAT(IGRID)%NCHDS
    MXCHD=>GWFCHDDAT(IGRID)%MXCHD
    NCHDVL=>GWFCHDDAT(IGRID)%NCHDVL
    IPRCHD=>GWFCHDDAT(IGRID)%IPRCHD
    NPCHD=>GWFCHDDAT(IGRID)%NPCHD
    ICHDPB=>GWFCHDDAT(IGRID)%ICHDPB
    NNPCHD=>GWFCHDDAT(IGRID)%NNPCHD
    CHDAUX=>GWFCHDDAT(IGRID)%CHDAUX
    CHDS=>GWFCHDDAT(IGRID)%CHDS
    !
    RETURN
  END SUBROUTINE SGWF2CHD7PNT

  SUBROUTINE SGWF2CHD7PSV(IGRID)
    !  Save pointers to CHD data for a grid
    !
    GWFCHDDAT(IGRID)%NCHDS=>NCHDS
    GWFCHDDAT(IGRID)%MXCHD=>MXCHD
    GWFCHDDAT(IGRID)%NCHDVL=>NCHDVL
    GWFCHDDAT(IGRID)%IPRCHD=>IPRCHD
    GWFCHDDAT(IGRID)%NPCHD=>NPCHD
    GWFCHDDAT(IGRID)%ICHDPB=>ICHDPB
    GWFCHDDAT(IGRID)%NNPCHD=>NNPCHD
    GWFCHDDAT(IGRID)%CHDAUX=>CHDAUX
    GWFCHDDAT(IGRID)%CHDS=>CHDS
    !
    RETURN
  END SUBROUTINE SGWF2CHD7PSV


END MODULE

