INITIALIZATION.f90 5.63 KB

!==============================================================================!
!                                                                              !
!				INITIALIZATION                                 !
!                                                                              !
!       Description: Here the particles are released into the domain and       !
!                    the value of variables and arrays  are initialized        !
!                                                                              !
!                                                                              !
!==============================================================================!
        

        subroutine initialization

        USE global_parameter                                    ! shared parameters


!______________________________________________________________________________
!                               LOCAL PARAMETERS
!______________________________________________________________________________

        IMPLICIT NONE
        integer                         :: i
        integer                         :: j
        integer                         :: a
        double precision, allocatable   ::light_level(:),light_bin(:)
        double precision, allocatable   :: dummy1(:)
        

        allocate(light_level(Nlevel))
        allocate(light_bin(Nbin))
        allocate(dummy1(Nlevel))
        
!_____________________________________________________________________________


        day=1                                                   !initialize time for display clock
        hour=0                                                  !
        minute=0                                                !
        rad=0                                                   !




!______________________________________________________________________________
!                               RELEASE PARTICLES
!______________________________________________________________________________



        if (particle_distribution.eq.1) then                    ! release all particles in at a particular depth
        bin=1+floor(z_0*z_res)
        z_cell(1:nbpart)=(levels(bin)+levels(bin+1))/2

        else                                                    !release all particles uniformely in the domain
        do i=1,nbpart                                           !
        z_cell(i)=depth/nbpart/2d0+DBLE(i-1)*(depth/nbpart)     !
        end do                                                  !
        end if                                                  !
        


!______________________________________________________________________________
!                                   BIO
!______________________________________________________________________________



        !S(1:nbpart)=4e6                                         !initial biomass per particle
        !weight_cell(1:nbpart)=m0                                !
        !weight(1:nbpart)=S*weight_cell                          !

        weight(1:nbpart)=m0

        binned_weight(1:Nbin)=0
        binned_pos=0                                                                                        
        euler(1:Nbin)=0
        binned_growth(1:Nbin)=0
        grow(1:Nbin)=0

        do i=1,nbpart  
        bin=1+floor(z_cell(i)*z_res)
        binned_pos(bin)=binned_pos(bin)+1
        binned_weight(bin)=binned_weight(bin)+weight(i)
        end do
        euler=binned_weight/dz


        Ncell(1:Nbin)=q0*euler                                            !initial cell quota
        Ncell_lag=q0*weight
        qlag(1:nbpart)=Ncell_lag/weight                                       !
        binned_Qlag(1:Nbin)=q0                                  !
        q=Ncell/euler                                               !
       
        mu_edge(1)=-2e-6
        q_edge(1)=q0
        do i=2,Ncat+1
        q_edge(i)=q_edge(i-1)+(q_max-q0)/Ncat
        mu_edge(i)=mu_edge(i-1)+(mu_max+2e-6)/Ncat
        end do


        do i=1,Ncat
        q_cat(i)=(q_edge(i)+q_edge(i+1))/2d0
        mu_cat(i)=(mu_edge(i)+mu_edge(i+1))/2d0
        end do
        q_dist=0d0
        q_dist(:,1)=euler(10)
        mu_dist=0

          if (photo_model.eq.2) then
          light_level=rad*0.45*4.16*dexp(-k_bg*levels)                                                   
        a=0
        do i=1,Nlevel
        dummy1(Nlevel-a)=light_level(i)
        a=a+1
        end do                                                                        ! 
        light_level=dummy1


        do i=1,Nbin
        light_bin(i)=(light_level(i)+light_level(i+1))/2
        
        if (light_bin(i)/(rad_max*0.45*4.16).lt.0.01) then
        Clquot_ACC(i)=0.04
        else
        Clquot_ACC(i)=0.01+0.03*log(light_bin(i)/(rad_max*0.45*4.16))/log(0.01)
        end if
        CL=clquot_ACC*euler

        end do

         do i=1,nbpart
        bin=1+floor(z_cell(i)*z_res)
        CL_lag(i)=CL(bin)
        end do
        end if  
!_________________________________________________________________________________
                                !nutrient profile
!_________________________________________________________________________________


        if (nut_profile.eq.1) then
        N_init(1:Nbin)=Nutrient_0                             
        N_init(1:Nbin)=Nutrient_0  
        else
        N_init(1:INT((depth-nut_layer)/dz))=Nutrient_2
        N_init(INT((depth-nut_layer)/dz):Nbin)=Nutrient_1
        end if
        N_lag=N_init
        N_euler=N_init

        Nut_taken(1:Nbin)=0d0                                     


!==============================================================================
        end subroutine initialization