fsd_build.f90 987 Bytes
subroutine fsd_build
use parameters

	implicit none
	double precision :: coeff
        double precision, allocatable :: ND(:),NN(:)
        integer :: M,mm

        if(C_ice(i).eq.0)then
        Dave(i)=0
        elseif (Dmax(i).eq.D0) then
        Dave(i)=Dmax(i)
        elseif (Dmax(i).eq.Dmin) then
        Dave(i)=Dmin
                
	elseif (FSD_scheme.eq.1) then
	coeff=1/((1/(1-gam))*(Dmax(i)**(1-gam)-Dmin**(1-gam)))
	Dave(i)=coeff*(1/(2-gam))*(Dmax(i)**(2-gam)-Dmin**(2-gam))
        else

        M=floor(log(Dmax(i)/Dmin)/log(psi))
 
        allocate(ND(M+1))
        allocate(NN(M+1))
        jj=1
        do mm=0,M-1

        NN(jj)=((1-ff)*(psi**2*ff)**mm)*(Dmax(i)/psi**mm)
        ND(jj)=(1-ff)*(psi**2*ff)**mm
        jj=jj+1
                
        end do
        
        Dave(i)=(sum(NN)+((psi**2*ff)**M)*(Dmax(i)/psi**M))/(sum(ND)+(psi**2*ff)**M)

        deallocate(ND)
        deallocate(NN)
        
        end if

        
      


end subroutine fsd_build