!
!  get_mem.f90
!
    subroutine get_mem(cmem,cname,ctype,location,length,ierr)
    use memory_pointers
    character (len=*) :: cmem,cname
    character (len=*) :: ctype
    integer :: location,length,ierr    
    logical :: found
!
!-----------
    found = .false.   
    if ( cmem(1:7)=='physics' ) then 
     do i=1,nphys
        if ( trim(phys_ptrs(i)%name)==trim(cname) ) then
          ctype = phys_ptrs(i)%type
          location = phys_ptrs(i)%ptr
          length = phys_ptrs(i)%length
          found = .true. 
          exit
        endif
      enddo
!
!-----------            
    else if ( cmem(1:4)=='cell' ) then 
      do i=1,ncell      
        if ( trim(cell_ptrs(i)%name)==trim(cname) ) then
          cname = cell_ptrs(i)%name
          ctype = cell_ptrs(i)%type
          location = cell_ptrs(i)%ptr
          length = cell_ptrs(i)%length
          found = .true. 
          exit
        endif          
      enddo
!
!-----------      
    else if ( cmem(1:4)=='coef' ) then 
      do i=1,ncoef      
        if ( trim(coef_ptrs(i)%name)==trim(cname) ) then
          cname = coef_ptrs(i)%name
          ctype = coef_ptrs(i)%type
          location = coef_ptrs(i)%ptr
          length = coef_ptrs(i)%length
          found = .true. 
          exit
        endif          
      enddo
!
!-----------      
    else if ( cmem(1:9)=='interface' ) then 
      do i=1,nint      
        if ( trim(int_ptrs(i)%name)==trim(cname) ) then
          cname = int_ptrs(i)%name
          ctype = int_ptrs(i)%type
          location = int_ptrs(i)%ptr
          length = int_ptrs(i)%length
          found = .true. 
          exit
        endif          
      enddo   
!    
    endif
!    
    if (.not.found) then
      print *, 'Error in get mem for:'//trim(cname)
      stop
    endif 
!          
    end subroutine get_mem
