subroutine ingestion(act,Eb,BeamAtt,Prey_mgdw_per_m3,Larval_m,PauseDuration,PreyMassEnc)
implicit none

!Parameters
real*8, parameter:: PreyRelLength=0.05				!Prey length relative to fish
real*8, parameter:: PreyWidth = 0.5					!Prey diam:length ratio (for mass)
real*8, parameter:: PreyContrast=0.3
real*8, parameter:: VisRtoSDPreyinBL=1.			!=1 BL for a 0.015 mm2 prey (Fiksen & MacKenzie 2002)
real*8, parameter:: Ke = 1.
real*8, parameter:: omega = 0.
real*8, parameter:: PreySwimVel = 0.
real*8,  parameter :: Maxpause = 12.				!seconds pause at minimum activity
real*8,  parameter :: MinPause = 2.					!seconds pause whane maximum active
real*8,  parameter :: Prey_handling_s = 1.			!Prey handling time (s)
real*8,  parameter :: rho = 0.3						!Time to move between search volumes
real*8,  parameter :: Pc = 0.2						!Prey capture probability (Fiksen & MacKenzie 2002: 0.2)
!real*8, parameter:: PauseFrequency = 0.43			!
!real*8, parameter:: PauseDuration = 2.				!Seconds per pause

real*8, parameter:: VisFieldShape = 0.5
real*8, parameter:: zp_mgdw_per_m3 = 1025*0.25*1.d6 !Mauchline..

!Variables
integer	IER
real*8 Eb,BeamAtt,Prey_mgdw_per_m3,Larval_m,PreyMassEnc
real*8 Prey_m,Prey_mgdw,PreyPer_m3,PreyImageArea,Swim_m_per_s
real*8 VisualRange,EyeSens,pi
real*8 act,PauseFrequency,PauseDuration

!Functions
real*8 Weight_Length
real*8 Length_Weight

pi=acos(-1.)

!Prey properties
Prey_m = Larval_m*PreyRelLength	!Prey length (prosome?)
!Prey_mgdw = (4/3.)*pi*((0.5*Prey_m)**3.)*zp_mgdw_per_m3 !Spherical prey
Prey_mgdw = pi*((0.5*PreyWidth*Prey_m)**2.)*Prey_m*zp_mgdw_per_m3 !Cylindric prey (diam=Pw*L)

PreyPer_m3 = Prey_mgdw_per_m3/prey_mgdw					!Prey density
!PreyImageArea = pi*(Prey_m*0.5)**2						!Spherical prey
PreyImageArea = pi*(Prey_m*PreyWidth)*Prey_m*0.75		!Elongate prey 

!Assume larvae detect 0.1x0.2 mm prey (VisRtoSDPreyinBL x Larval_m) away in clear water 
!(from Fiksen&MacKenzie 2002):
EyeSens = ((Larval_m*VisRtoSDPreyinBL)**2.)/(PreyContrast*(0.1*0.2*0.75*1.d-6))

!or alternatively, the eye-sensitivity from Fiksen & al. 1998:
!Eyesens = 5.04/(1. + exp(-((Larval_m*1d3 - 5.33)/0.64)))
!Eyesens = 10**Eyesens

Swim_m_per_s = Larval_m

!Finding the visual range in m (from AU97)
VisualRange = dsqrt(EyeSens*PreyContrast*PreyImageArea*(Eb/(Ke+Eb))) !Approximation
if(VisualRange>0.05)then	!Exact visual range (above ca 5 cm)
 call getr(VisualRange,BeamAtt,PreyContrast,PreyImageArea,EyeSens,Ke,Eb,IER)
endif

!Cruising larvae:
PreyMassEnc = act*VisFieldShape*pi*(VisualRange**2)*Swim_m_per_s

!Behavioural option: Jump frequency or pause duration
!PauseDuration = MaxPause - act*(MaxPause-MinPause)
!PauseFrequency = 1./(PauseDuration + rho) !act*(1./(MinPause + rho)) ..

!Saltatory search:
!PreyMassEnc = 0.667*pi*(VisualRange**3.)*PauseFrequency + & 
!&  pi*(VisualRange**2.)*sqrt(PreySwimVel**2. + 2*omega**2.)*PauseFrequency*PauseDuration
!Holling disk foraging process
PreyMassEnc = (Pc*PreyMassEnc*PreyPer_m3*Prey_mgdw)/(1. + PreyMassEnc*PreyPer_m3*Prey_handling_s)

if(act.lt.1.d-10)PreyMassEnc = 0. !No feeding if not moving

!print('(10E9.1)'),Larval_m,PreyPer_m3,Prey_m,Prey_mgdw,Eyesens,VisualRange/Larval_m,&
!& PreyMassEnc*3600./Weight_Length(Larval_m),Weight_Length(Larval_m)

return
end subroutine ingestion
!******
