parameters.f90 8.82 KB

!_________________________________________________________________________________________

                        !DESCRIPTION: In this routine, the shared parameters for
                        !other subroutines are declared. It also contains the
                        !subroutine read_namelist which read parameters value
                        !from the namelist and the subroutine array_allocation
                        !for memory allocation.

!________________________________________________________________________________________

        !INTERFACE:
        module parameters

        
                        

        implicit none

        !NAME OF OUTPUTS FILES
        character(len=100)            :: root='output/' !output directory
        character(len=100)            :: name_sim='test'!name of the simulation
        character(len=100)            :: namefile
        character(len=100)            :: dirout

        !DUMMIES
        integer                       :: i,ii,n,j,jj,iii,jjj


        !GLOBAL PARAMETERS
        double precision              :: g=9.81         !gravitationnal acceleration
        double precision              :: pi=3.1416      ! Pi


        !SPECTRUM
        double precision, allocatable :: E(:,:,:)       !Energy  spectrum  
        double precision, allocatable :: Ei(:)          !Initial spectrum
        double precision, allocatable :: T(:)           !Period 
        double precision, allocatable :: omega(:)       !Radial frequency
        double precision, allocatable :: freq(:)        !Frequency
        double precision, allocatable :: sigma_s(:)
        integer                       :: nfreq=60       !Number of frequency band
        double precision              :: alpha_s=8.1e-3 !
        double precision              :: beta_s=1.25
        double precision              :: Tmin=2.5       !Minimum period
        double precision              :: Tmax=20        !Maximum period
        double precision              :: Tm=6           !Peak period 
        double precision              :: Hs=1           !Significant Height
        double precision              :: gamma_s=3.3
        double precision              :: freq_s         !Peak frequency
        double precision              :: domega         !frequency increment
        integer                       :: init_spec=1
        double precision              :: swell_T=8
        double precision              :: swell_Hs=1

        !WAVES
        double precision, allocatable :: wl(:)          !wavelength
        double precision, allocatable :: Cp(:)          !Phase speed
        double precision, allocatable :: Cg(:)          !group speed
        double precision, allocatable :: CN(:)          !Courant Number (for each frequency)
        integer                       :: disp=0
        double precision              :: dwl            !wavelength increment


        !GRID PARAMETERS             
        double precision              :: dt             !Time step
        double precision              :: dx=500         !grid resolution
        integer                       :: nsteps         !Duration of the simulation
        double precision              :: Cfl=1          ! Courant
        integer                       :: nbin=10        !Number of grid bin
        double precision, allocatable :: x_axis(:)      !vector of grid width
        double precision, allocatable :: time(:)        !vector of time


        !ICE
        double precision, allocatable :: alpha(:,:)
        double precision, allocatable :: h(:)           !ice thickness
        double precision, allocatable :: C_ice(:)       !ice concentration
        double precision, allocatable :: S_ice(:,:,:)     !ice attenuation source term
        double precision              :: cice=1         !ice concentration (from namelist)
        double precision              :: hice=1         !ice thickness (from namelist)
        double precision, allocatable :: Dave(:)        !Average floe size
        double precision, allocatable :: Dmax(:)        !maximum floe size
        double precision              :: D0=200         !initial floe size
        double precision              :: gam=2          !power law exponent
        double precision              :: Dmin=20        !minimum floe size
        double precision              :: psi=2
        double precision              :: ff=0.5
        double precision              :: Xh=60000
        double precision              :: X_ice=50000
        integer                       :: ice_thick=1
        double precision              :: hmax=4
        double precision              :: stress_crit=0.67e6
        double precision              :: strain_crit=3e-5
        double precision              :: P_c=0.15
        double precision              :: rhoice=960
        double precision, allocatable :: kice(:,:)

        !FSD
        double precision              :: minfloe=5      
        double precision              :: maxfloe=500
        double precision              :: res
        integer                       :: nbcat=40
        integer                       :: nedge
        double precision, allocatable :: FSD(:,:,:,:)
        double precision, allocatable :: floe_cat(:)
        double precision, allocatable :: middle_floe_cat(:)
        integer                       :: FSD_scheme=1

        !IDT
        integer                       :: IDT_scheme=0
        double precision              :: mu_IDT=1.2
        double precision              :: mincat_h=0.1
        double precision              :: maxcat_h=10
        integer                       :: nbcat_h=50
        double precision, allocatable :: IDT(:,:)
        double precision, allocatable :: middle_h_cat(:)
        double precision, allocatable :: h_cat(:)
        integer                       :: nedge_h
        double precision              :: resh

        !STATISTICS
        double precision, allocatable :: h_sign(:,:)
contains

!_____________________________________________________________________________________
        
        !INTERFACE:     
        subroutine read_namelist

        namelist /spectrum_parameters/ nfreq,alpha_s,beta_s,Tmin,Tmax,gamma_s,init_spec, &
                                       swell_T,swell_Hs
        namelist /model_parameter/ nbin,dx,Cfl,name_sim,root
        namelist /waves_parameters/ Tm,Hs,disp
        namelist /ice_parameters/cice,hice,ice_thick,hmax,X_ice, &
                                 Xh,strain_crit,P_c

        namelist /fsd_parameters/FSD_scheme,minfloe,maxfloe,nbcat
        namelist /idt_parameters/IDT_scheme,mu_IDT,mincat_h,maxcat_h,nbcat_h

        open(30,file='nml/parameter.nml',status='old')
        read(30,nml=spectrum_parameters)
        close(30)

        open(30,file='nml/parameter.nml',status='old')
        read(30,nml=model_parameter)
        close(30)

        open(30,file='nml/parameter.nml',status='old')
        read(30,nml=waves_parameters)
        close(30)

        open(30,file='nml/parameter.nml',status='old')
        read(30,nml=ice_parameters)
        close(30)

        open(30,file='nml/parameter.nml',status='old')
        read(30,nml=fsd_parameters)
        close(30)

        open(30,file='nml/parameter.nml',status='old')
        read(30,nml=idt_parameters)
        close(30)


end subroutine read_namelist
!____________________________________________________________________________________

        !INTERFACE:
        subroutine array_allocation



        allocate(Ei(nfreq))
        allocate(T(nfreq))
        allocate(omega(nfreq))
        allocate(freq(nfreq))
        allocate(sigma_s(nfreq))
        allocate(wl(nfreq))
        allocate(Cp(nfreq))
        allocate(Cg(nfreq))
        allocate(CN(nfreq))
        allocate(alpha(nbin,nfreq))
        allocate(h(nbin))
        allocate(C_ice(nbin))
        allocate(x_axis(nbin))

         domega=(2*pi/Tmin-2*pi/Tmax)/(nfreq)
        dwl=(g*Tmax**2/(2*pi)-g*Tmin**2/(2*pi))/(nfreq)
        ii=1
        do i=0,nfreq
        omega(ii)=2*pi/Tmax+i*domega
        ii=ii+1
        end do
        freq=omega/(2*pi)
        T=1d0/freq
        freq_s=1d0/Tm
        wl=g*T**2/(2*pi)
        Cp=sqrt(g*wl/(2*pi))
        Cg=0.5*Cp



        if (disp.eq.0) then
        CN=Cfl
        Cg=maxval(Cg)
        dt=CN(1)*dx/maxval(Cg)
        else
        dt=dx/maxval(Cg)
        CN=Cg*dt/dx
        end if

        nsteps=ceiling(nbin/minval(CN))


        allocate(E(nsteps,nbin,nfreq))
        allocate(Dmax(nbin))
        allocate(Dave(nbin))
        allocate(time(nsteps))
        allocate(S_ice(nsteps,nbin,nfreq))
        allocate(h_sign(nsteps,nbin))

        nedge=nbcat+1

        allocate(floe_cat(nedge))
        allocate(FSD(nsteps,nbin,nbcat,nbcat_h))
        allocate(middle_floe_cat(nbcat))

        nedge_h=nbcat_h+1

        allocate(IDT(nbin,nbcat_h))
        allocate(middle_h_cat(nbcat_h))
        allocate(h_cat(nedge_h))
        allocate(kice(nbcat_h,nfreq))

end subroutine array_allocation




end module parameters