Commit 4e5b4414 authored by Jérémy Baudry's avatar Jérémy Baudry
Browse files

ajout commentaires dans le code

parent a081b91c
......@@ -17,7 +17,7 @@
&waves_parameters
Tm =6
Hs =1.5
Hs =1
disp =0
/
......@@ -31,14 +31,14 @@ disp =0
! is needed to calculate the time step.
! name_sim -> name of the output file
! root -> destination folder for the output file
! FSD_sheme -> method for ice floe breaking parametrization
! 0: Williams et al. 2013
! 1: Horvat 2015
! FSD_sheme -> method for compute <D>
! 0: dumont et al (2011)
! 1: power law
!------------------------------------------------------------------------------
&model_parameter
nbin =100
dx =1000
nbin =50
dx =5000
Cfl =1
name_sim ='simulation1'
root = 'output/'
......@@ -86,9 +86,9 @@ gamma_s =3.3
! Dmin -> Minimum floe size (if FSD_sheme=1) [m]
!------------------------------------------------------------------------------
&ice_parameters
X_ice =5000
X_ice =50000
cice =0.8
ice_thick =0
ice_thick =1
hice =2
hmax =4
Xh =100000
......
subroutine advection
use parameters
!_______________________________________________________________________________
implicit none
!DESCRIPTION: Here, the wave spectrum is advected through the
!domain. The advection equation is solved using a Lax-wendroff
!discretization sheme with a superbee flux limiter.
double precision, allocatable :: diffF(:),diffl(:),diffr(:),phi(:),theta(:)
double precision, allocatable :: F(:),diff1(:)
!_______________________________________________________________________________
!INTERFACE:
subroutine advection
!MODULE USES:
use parameters
!LOCAL PARAMETERS:
implicit none
double precision, allocatable :: diffF(:)
double precision, allocatable :: diffl(:)
double precision, allocatable :: diffr(:)
double precision, allocatable :: phi(:)
double precision, allocatable :: theta(:)
double precision, allocatable :: F(:)
double precision, allocatable :: diff1(:)
allocate(diffl(nbin))
......@@ -16,6 +34,7 @@ implicit none
allocate(F(nbin))
allocate(diff1(nbin-1))
!________________________________________________________________________________
do i=2,nbin
diffl(i)=E(n-1,i,ii)-E(n-1,i-1,ii)
......@@ -24,16 +43,18 @@ implicit none
do i=1,nbin-1
diffr(i)=E(n-1,i+1,ii)-E(n-1,i,ii)
end do
diffr(nbin)=-E(n-1,nbin,ii)
diffr(nbin)=-E(n-1,nbin,ii) !set dE=0 at boundaries
diffl(1)=E(n-1,1,ii)
do i=1,nbin
do i=1,nbin !Superbee flux limiter
theta(i)=diffl(i)/(diffr(i)+3e-14)
phi(i)=max(0d0,min(theta(i)*2,1d0),min(theta(i),2d0))
end do
!Lax-Wendroff sheme:
F=E(n-1,1:nbin,ii)+0.5*(1-CN(ii))*diffr*phi
do i=2,nbin
diffF(i)=F(i)-F(i-1)
......@@ -42,7 +63,7 @@ implicit none
E(n,1:nbin,ii)=E(n-1,1:nbin,ii)-CN(ii)*diffF
!________________________________________________________________________________
end subroutine advection
......
subroutine attenuation
use parameters
implicit none
!____________________________________________________________________________
!DESCRIPTION: In this routine, the attenuation
!coefficient is calculated according Kohout and
!Meylan (2008) and the spectrum attenuation is
!computed.
!____________________________________________________________________________
!INTERFACE:
subroutine attenuation
!USES:
use parameters
implicit none
double precision :: q11,q12,q13,q14,q15,q21,q22,q23,q24,q25
double precision :: q31,q32,q33,q34,q35
double precision, allocatable ::p1(:),p2(:),p3(:),att(:)
double precision, allocatable :: p1(:),p2(:),p3(:)
double precision, allocatable :: att(:)
allocate(p1(nfreq))
allocate(p2(nfreq))
allocate(p3(nfreq))
allocate(att(nfreq))
!____________________________________________________________________________
q11 = -0.00000777
q12 = 0.00032080
......@@ -42,13 +60,14 @@ alpha(i,j)=0d0
end if
end do
att=C_ice(i)*alpha(i,1:nfreq)/(Dave(i)+3e-14)
S_ice(i,1:nfreq)=-att*E(n,i,1:nfreq)
S_ice(n,i,1:nfreq)=-att*E(n,i,1:nfreq)
E(n,i,1:nfreq)=E(n,i,1:nfreq)*exp(-att*Cg*dt)
!_____________________________________________________________________________
end subroutine attenuation
subroutine floe_breaking
use parameters
!_______________________________________________________________________________
implicit none
double precision, allocatable :: WN_ice(:),fnt(:),k(:)
double precision ::rho=1025,d,F,Y=5.5,v=0.3
!DESCRIPTION: Here is the parametrization proposed by
!Williams et al. (2013) for wave induced
!floe breaking. In this routine, the maximum floe size
!is computed using the significant strain imposed by
!passing waves in ice.
!_______________________________________________________________________________
!INTERFACE:
subroutine floe_breaking
!USES:
use parameters
!LOCAL PARAMETERS:
implicit none
double precision, allocatable :: WN_ice(:)
double precision, allocatable :: fnt(:)
double precision, allocatable :: k(:)
double precision :: rho=1025
double precision :: d
double precision :: F
double precision :: Y=5.5
double precision :: v=0.3
integer :: acc=10000
double precision, allocatable :: W(:)
double precision, allocatable :: fnt_d(:)
......@@ -27,11 +52,13 @@ implicit none
allocate(fnt_d(acc+1))
allocate(S(nfreq))
!_______________________________________________________________________________
F=Y*h(i)**3/12d0*(1-v**2)
d=0.9*h(i)
jj=1
jj=1 !create a wavelength vector (this is used to
!find the root of the polynom fnt
do ii=0,acc
k(jj)=real(ii)*10d0/real(acc)
jj=jj+1
......@@ -40,15 +67,15 @@ implicit none
do j=1,nfreq
fnt=F*k**5+rho*(g-d*omega(j)**2)*k-rho*omega(j)**2
WN_ice(j)=k(minloc(abs(fnt),DIM=1))
WN_ice(j)=k(minloc(abs(fnt),DIM=1))!calculate wavelength in ice
end do
W=g*WN_ice/omega**2
S=(0.5*h(i))*WN_ice**2*W
m0_s=sum(E(n,i,1:nfreq)*S**2)*domega
SS=2*sqrt(m0_s)
m0_s=sum(E(n,i,1:nfreq)*S**2)*domega !0th moment of the strain spectrum
SS=2*sqrt(m0_s) !significant strain
if (SS.gt.RS) then
......@@ -61,7 +88,6 @@ implicit none
WN_ice_d=k(minloc(abs(fnt_d),DIM=1))
wl_w=2*pi/WN_ice_d
Dmax(i)=max(Dmin,min(0.5*wl_w,Dmax(i)))
......@@ -69,5 +95,5 @@ implicit none
!_________________________________________________________________________________
end subroutine floe_breaking
subroutine fsd_build
use parameters
!________________________________________________________________________________
!DESCRIPTION: In this routine the average floe size
!Dave is computed using the value of Dmax calculated in
!the subroutine 'floe_breaking'.
!________________________________________________________________________________
!INTERFACE:
subroutine fsd_build
!MODULE USES:
use parameters
!LOCAL PARAMETERS:
implicit none
double precision :: coeff
double precision, allocatable :: ND(:),NN(:)
integer :: M,mm
double precision, allocatable :: ND(:)
double precision, allocatable :: NN(:)
integer :: M
integer :: mm
!_________________________________________________________________________________
if(C_ice(i).eq.0)then
Dave(i)=0
......@@ -13,10 +33,11 @@ use parameters
elseif (Dmax(i).eq.Dmin) then
Dave(i)=Dmin
elseif (FSD_scheme.eq.1) then
elseif (FSD_scheme.eq.1) then !use a power law to compute <D>
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
else !use the method from Dumont et al.(2011) to compute <D>
M=floor(log(Dmax(i)/Dmin)/log(psi))
......@@ -40,6 +61,6 @@ use parameters
!_________________________________________________________________________________
end subroutine fsd_build
......@@ -23,6 +23,22 @@
!construct time array
time(1)=0
do ii=2,nsteps
time(ii)=time(ii-1)+dt/60
end do
!construct space array
x_axis(1)=0
do ii=2,nbin
x_axis(ii)=x_axis(ii-1)+dx/1000
end do
!_________________________INITIAL SPECTRUM_____________________________
E(1:nsteps,1:nbin,1:nfreq)=0d0 !INITIALIZE SPECTRUM ARRAY
......@@ -54,7 +70,7 @@
!_______________________________________________________________________
!_______________________ICE_TRANSECT____________________________________
S_ice(1,1,1:nfreq)=0
X1=floor(X_ice/dx) !find in which grid bin is the ice edge
C_ice(1:X1)=0 !ice concentration is 0 before ice edge!
C_ice(X1:nbin)=cice !ice concentration in the transect
......@@ -81,6 +97,17 @@ h(1:X1)=0d0
end if
!_____________________FSD_____________________________________________
res=abs(minfloe-maxfloe)/nedge
floe_cat(1)=maxfloe
do i=2,nedge
floe_cat(i)=floe_cat(1)-i*res
end do
do i=1,nedge-1
middle_floe_cat(i)=(floe_cat(i)+floe_cat(i+1))*0.5
end do
FSD(1,1:nbin,1)=1d0
......
......@@ -20,18 +20,6 @@
!________________________________________________________________________________
spectrum=trim(root)//'Energy_spectrum.dat'
floe_size=trim(root)//'floe_size.dat'
namefile=trim(root)//trim(name_sim)//'.nc'
open(10,file=spectrum)
open(11,file=floe_size)
!________________________________________________________________________________
! DO THE TIME LOOP
......@@ -46,17 +34,16 @@
do i=1,nbin !spatial calculations
call attenuation ! compute spectrum attenuation
call break_horvat ! compute floe breaking
!call floe_breaking
!call fsd_build
! compute floe breaking
call floe_breaking
call fsd_build
end do
end do
!______________________OUTPUTS_________________________________________________
namefile=trim(root)//trim(name_sim)//'.nc'
call write_output ! Write outputs in NETCDF
!call graph_dislin
close(10)
close(11)
......
......@@ -5,7 +5,7 @@ OPTION= -O3
NETCDFinc=-I/usr/include
NETCDFLIB=-L/usr/lib64 -lnetcdff
NETCDFMOD=-I/usr/lib64/gfortran/modules
DISLIN=-I/usr/local/dislin/gf -ldislin
OBJ= *.o
SRC= *.f90
......@@ -17,7 +17,7 @@ EXEC= WIM2
WIM2: $(OBJ)
$(COMPILER) $(OPTION) $(NETCDFinc) $(NETCDFMOD) -o $(EXEC) $(OBJ) $(NETCDFLIB) $(DISLIN)
$(COMPILER) $(OPTION) $(NETCDFinc) $(NETCDFMOD) -o $(EXEC) $(OBJ) $(NETCDFLIB)
mv WIM2 ../
......
module parameters
implicit none
!_________________________________________________________________________________________
!__________________name of files__________________
character(len=100) ::root='output/',spectrum,floe_size,name_sim='test'
character(len=100) ::namefile
!______________dummys_____________________________
!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
!DUMMIES
integer :: i,ii,n,j,jj
!______________global parameters__________________
double precision :: g=9.81,pi=3.1416
!____________Spectrum_____________________________
double precision, allocatable :: E(:,:,:),Ei(:),T(:)
double precision, allocatable :: omega(:),freq(:),sigma_s(:)
integer :: nbin=10,nfreq=60
double precision :: alpha_s=8.1e-3,beta_s=1.25
double precision :: Tmin=2.5,Tmax=20,Tm=6,Hs=1
double precision :: gamma_s=3.3,freq_s,domega
double precision, allocatable :: x_axis(:),time(:)
!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
!____________waves_________________________________
double precision, allocatable ::wl(:),Cp(:),Cg(:),CN(:)
integer ::disp=0
double precision ::dwl
!____________grid parameters________________________
double precision :: dt,dx=500
integer :: nsteps
double precision :: Cfl=1
!_____________ICE_____________________________________
!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(:)
double precision, allocatable :: C_ice(:)
double precision, allocatable :: S_ice(:,:)
double precision :: cice=1
double precision :: hice=1
double precision, allocatable :: Dave(:)
double precision, allocatable :: Dmax(:)
double precision :: D0=200
double precision :: gam=2
double precision :: Dmin=20
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
!_________________FSD______________________________
double precision :: minfloe
double precision :: maxfloe
!FSD
double precision :: minfloe=1
double precision :: maxfloe=500
double precision :: res
integer :: nbcat
integer :: nbcat=100
integer :: nedge
double precision, allocatable :: FSD(:,:,:)
double precision, allocatable :: floe_cat(:)
double precision, allocatable :: middle_floe_cat(:)
!_________model parameters____________________________
integer :: FSD_scheme=1
contains
!_____________________________________________________________________________________
subroutine read_namelist
!INTERFACE:
subroutine read_namelist
namelist /spectrum_parameters/ nfreq,alpha_s,beta_s,Tmin,Tmax,gamma_s,init_spec
namelist /model_parameter/ nbin,dx,Cfl,name_sim,root,FSD_scheme
......@@ -88,48 +134,40 @@ subroutine read_namelist
end subroutine read_namelist
!____________________________________________________________________________________
subroutine array_allocation
nfreq=nfreq+1
!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))
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))