parameters.f90 7.3 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.
!--------------------------------------------------------------------

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,iii
integer            :: j,jj,jjj
integer            :: n

! physical and useful quantities
real               :: g=9.81         ! Gravitationnal acc. [m s-2]
real               :: Y=5.5e9        ! Young's modulus     [Pa]
real               :: nu=0.3         ! Poisson's ratio     [-]
real               :: rhoi=925.0     ! Sea ice density     [kg m-3]
double precision   :: pi=3.141592653 ! Pi

!SPECTRUM
integer            :: nf=60          ! Nb of frequency bins
integer            :: init_spec=1

double precision   :: alpha_s=8.1e-3 ! Jonswap parameter
double precision   :: beta_s=1.25    ! Jonswap parameter
double precision   :: gamma_s=3.3    ! Jonswap parameter
double precision   :: Tmin=2.5       ! Minimum period
double precision   :: Tmax=20        ! Maximum period
double precision   :: Tm=6           ! Peak period             [s]
double precision   :: Hs=1           ! Significant wave height [m]
double precision   :: freq_s         ! Peak frequency
double precision   :: domega         ! Frequency increment
double precision   :: swell_T=8
double precision   :: swell_Hs=1

double precision, allocatable :: E(:,:,:)  ! Energy spectrum  
double precision, allocatable :: Ei(:)     ! Initial spectrum
double precision, allocatable :: T(:)      ! Period 
double precision, allocatable :: omega(:)  ! Angular frequency
double precision, allocatable :: freq(:)   ! Frequency
double precision, allocatable :: sigma_s(:)

!WAVES
integer              :: disp=0
integer              :: cont=0

double precision     :: dwl            ! Wavelength increment

double precision, allocatable :: wl(:) ! Wavelength
double precision, allocatable :: Cp(:) ! Phase speed
double precision, allocatable :: Cg(:) ! Group speed
double precision, allocatable :: CN(:) ! Courant Number

!GRID PARAMETERS             
integer              :: nx=10        ! Nb of spatial bins
integer              :: nt         ! Duration of the simulation

real                 :: dt             ! Time step
real                 :: dx=500         ! Grid resolution
double precision     :: cfl=1          ! Courant

double precision, allocatable :: x_axis(:) ! Vector of grid width
double precision, allocatable :: time(:)   ! Vector of time

!ICE
integer              :: ice_thick=1

double precision     :: cice=1       ! Ice concentration
double precision     :: hice=1       ! Ice thickness
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
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 :: alpha(:,:)
double precision, allocatable :: h(:)         ! Ice thickness
double precision, allocatable :: C_ice(:)     ! Ice concentration
double precision, allocatable :: S_ice(:,:,:) ! Ice source term
double precision, allocatable :: Dave(:)      ! Average floe size
double precision, allocatable :: Dmax(:)      ! Maximum floe size
double precision, allocatable :: kice(:,:)

!FSD
integer              :: fsd_scheme=1
integer              :: nr=40
integer              :: nedge

double precision     :: minfloe=5      
double precision     :: maxfloe=500
double precision     :: dr

double precision, allocatable :: fsd(:,:,:,:)
double precision, allocatable :: floe_cat(:)
double precision, allocatable :: middle_floe_cat(:)

!itd
integer              :: itd_scheme=0
integer              :: nh=50
integer              :: nedge_h

double precision     :: mu_itd=1.2
double precision     :: mincat_h=0.1
double precision     :: maxcat_h=5.0
double precision     :: dh

double precision, allocatable :: itd(:,:)
double precision, allocatable :: middle_h_cat(:)
double precision, allocatable :: h_cat(:)

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

contains

!____________________________________________________________________

subroutine read_namelist

   namelist /spectrum_parameters/ nf,alpha_s,beta_s,             &
                                  Tmin,Tmax,gamma_s,init_spec,   &
                                  swell_T,swell_Hs

   namelist /model_parameter/     nx,dx,cfl,name_sim,root

   namelist /waves_parameters/    Tm,Hs,disp,cont

   namelist /ice_parameters/      cice,hice,ice_thick,hmax,      &
                                  X_ice,Xh,strain_crit,P_c

   namelist /fsd_parameters/      fsd_scheme,minfloe,maxfloe,    &
                                  nr

   namelist /itd_parameters/      itd_scheme,mu_itd,mincat_h,    &
                                  maxcat_h,nh

   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=itd_parameters)
   close(30)

end subroutine read_namelist


subroutine array_allocation

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

   domega=(2*pi/Tmin - 2*pi/Tmax)/nf
   dwl=(g*Tmax**2/(2*pi)-g*Tmin**2/(2*pi))/(nf)
   ii=1
   do i=0,nf
      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

   nt=ceiling(nx/minval(CN))

   allocate(E     (nx,nf,nt))
   allocate(Dmax  (nx      ))
   allocate(Dave  (nx      ))
   allocate(time  (nt      ))
   allocate(S_ice (nx,nf,nt))
   allocate(h_sign(nx,nt   ))

   nedge=nr+1

   allocate(floe_cat       (nedge))
   allocate(fsd            (nx,nr,nh,nt))
   allocate(middle_floe_cat(nr))

   nedge_h=nh+1

   allocate(itd         (nx,nh))
   allocate(middle_h_cat(nh))
   allocate(h_cat       (nedge_h))
   allocate(kice        (nh,nf))

end subroutine array_allocation

end module parameters