Commit 37b993a2 authored by Dany Dumont's avatar Dany Dumont

Nettoyage et resolution du bogue netcdf

parent 31a3ff4d
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
Tm =4.5 Tm =4.5
Hs =1.5 Hs =1.5
disp =0 disp =1
cont =1 cont =1
/ /
...@@ -37,8 +37,8 @@ cont =1 ...@@ -37,8 +37,8 @@ cont =1
!-------------------------------------------------------------------- !--------------------------------------------------------------------
&model_parameter &model_parameter
nx =1000 nx =100
dx =5 dx =10
cfl =1.0 cfl =1.0
name_sim ='test' name_sim ='test'
root = 'output/' root = 'output/'
...@@ -91,7 +91,7 @@ swell_Hs =0.09 ...@@ -91,7 +91,7 @@ swell_Hs =0.09
X_ice =50 X_ice =50
cice =1 cice =1
ice_thick=1 ice_thick=1
hice =0 hice =0.8
hmax =0.8 hmax =0.8
Xh =250 Xh =250
strain_crit=3e-5 strain_crit=3e-5
...@@ -131,7 +131,7 @@ nr =25 ...@@ -131,7 +131,7 @@ nr =25
!-------------------------------------------------------------------- !--------------------------------------------------------------------
&itd_parameters &itd_parameters
itd_scheme =1 itd_scheme =0
mu_itd =0.5 mu_itd =0.5
mincat_h =0.1 mincat_h =0.1
maxcat_h =10 maxcat_h =10
......
!--------------------------------------------------------------------
!____________________________________________________________________
!
!DESCRIPTION: In this routine, the attenuation coefficient is !DESCRIPTION: In this routine, the attenuation coefficient is
! calculated according Kohout and Meylan (2008) and the ! calculated according Kohout and Meylan (2008) and the
! spectrum attenuation is computed. ! spectrum attenuation is computed.
! !--------------------------------------------------------------------
!____________________________________________________________________
!INTERFACE: !INTERFACE:
subroutine attenuation subroutine attenuation
!USES: !USES:
use parameters use parameters
implicit none implicit none
double precision :: q11,q12,q13,q14,q15,q21,q22,q23,q24,q25 double precision :: q11,q12,q13,q14,q15,q21,q22,q23,q24,q25
double precision :: q31,q32,q33,q34,q35 double precision :: q31,q32,q33,q34,q35
double precision, allocatable :: p1(:),p2(:),p3(:) double precision, allocatable :: p1(:),p2(:),p3(:)
double precision, allocatable :: att(:) double precision, allocatable :: att(:)
allocate(p1 (nf)) allocate(p1 (nf))
allocate(p2 (nf)) allocate(p2 (nf))
allocate(p3 (nf)) allocate(p3 (nf))
allocate(att(nf)) allocate(att(nf))
q11 = -0.00000777
q11 = -0.00000777 q12 = 0.00032080
q12 = 0.00032080 q13 = -0.00437542
q13 = -0.00437542 q14 = 0.02047559
q14 = 0.02047559 q15 = -0.01356537
q15 = -0.01356537
q21 = 0.00003635
q21 = 0.00003635 q22 = -0.00153484
q22 = -0.00153484 q23 = 0.02121709
q23 = 0.02121709 q24 = -0.09289399
q24 = -0.09289399 q25 = -0.03693082
q25 = -0.03693082
q31 = -0.00004509
q31 = -0.00004509 q32 = 0.00214484
q32 = 0.00214484 q33 = -0.03663425
q33 = -0.03663425 q34 = 0.26065369
q34 = 0.26065369 q35 = -0.62474085
q35 = -0.62474085
p1 = q11*T**4 + q12*T**3 + q13*T**2 + q14*T + q15
p1 = q11*T**4 + q12*T**3 + q13*T**2 + q14*T + q15 p2 = q21*T**4 + q22*T**3 + q23*T**2 + q24*T + q25
p2 = q21*T**4 + q22*T**3 + q23*T**2 + q24*T + q25 p3 = q31*T**4 + q32*T**3 + q33*T**2 + q34*T + q35
p3 = q31*T**4 + q32*T**3 + q33*T**2 + q34*T + q35
alpha(i,:)=-1*(p1*h(i)**2 + p2*h(i) + p3)
alpha(i,:)=-1*(p1*h(i)**2 + p2*h(i) + p3)
do ii=1,nf
do ii=1,nf if ( alpha(i,ii).lt.0 )then
if ( alpha(i,ii).lt.0 )then alpha(i,ii)=0d0
alpha(i,ii)=0d0 end if
end if end do
end do
att=C_ice(i)*alpha(i,:)/(Dave(i)+3e-14)
att=C_ice(i)*alpha(i,:)/(Dave(i)+3e-14) !S_ice(n,i,1:nf)=-att*E(n,i,1:nf)
!S_ice(n,i,1:nf)=-att*E(n,i,1:nf) S_ice(i,:,n)=-att*E(i,:,n)
S_ice(i,:,n)=-att*E(i,:,n) E(i,:,n)=E(i,:,n)*exp(-att*Cg*dt)
E(i,:,n)=E(i,:,n)*exp(-att*Cg*dt)
end subroutine attenuation end subroutine attenuation
!--------------------------------------------------------------------
!DESCRIPTION: This routine does the wave-induced floe breaking by
! modifying the floe size distribution.
!--------------------------------------------------------------------
! There is a major issue with as the integral of the distribution
! is not consistent with the ice area and the redistribution is not
! performed conservatively.
subroutine ice_fracture subroutine ice_fracture
...@@ -6,20 +15,18 @@ subroutine ice_fracture ...@@ -6,20 +15,18 @@ subroutine ice_fracture
!local parameters !local parameters
implicit none implicit none
integer :: Nband=500 !integer :: Nband=500
integer :: freq1 integer :: freq1
integer :: freq2 integer :: freq2
integer :: ninterp=1 integer :: ninterp=1
double precision :: Y=5.5e9 !double precision :: TT=13
double precision :: TT=13
double precision :: poisson=0.3
double precision :: m_0 double precision :: m_0
double precision :: m_0_stress double precision :: m_0_stress
double precision :: m_0_amp double precision :: m_0_amp
double precision :: m_2_amp double precision :: m_2_amp
double precision :: Tw !double precision :: Tw
double precision :: kw !double precision :: kw
double precision :: Lmin double precision :: Lmin
double precision, allocatable :: P(:) double precision, allocatable :: P(:)
...@@ -70,9 +77,13 @@ subroutine ice_fracture ...@@ -70,9 +77,13 @@ subroutine ice_fracture
do iii=1,nh do iii=1,nh
! Lmin according Mellor 1986 ! Lmin according Mellor 1986
Lmin=pi*0.5*((5e6*middle_h_cat(iii)**3)/(3*10*(1-0.3**2)))**0.25 !Lmin=pi*0.5*((Y*middle_h_cat(iii)**3)/ &
! (3*rhoi*g*(1-nu**2)))**0.25
W=(9.81*kice(iii,:))/omega**2 ! Lmin corrected from Mellor (1986)
Lmin=pi*0.25*((Y*middle_h_cat(iii)**3)/ &
(3*rhoi*g*(1-nu**2)))**0.25
W=(g*kice(iii,:))/omega**2
wavelength=2*pi/kice(iii,:) wavelength=2*pi/kice(iii,:)
strain=middle_h_cat(iii)*0.5*kice(iii,:)**2*W strain=middle_h_cat(iii)*0.5*kice(iii,:)**2*W
...@@ -82,8 +93,8 @@ subroutine ice_fracture ...@@ -82,8 +93,8 @@ subroutine ice_fracture
do ii=1,nr do ii=1,nr
if ( 2d0*floe_cat(ii+1).lt.wavelength(nf) .or. & if ( 2d0*floe_cat(ii+1).lt.wavelength(nf) .or. &
2d0*floe_cat(ii+1).gt.wavelength(1)) then 2d0*floe_cat(ii+1).gt.wavelength( 1) ) then
P_cat(ii)=0d0 P_cat(ii)=0d0
else else
do while ( wavelength(freq1).lt.2d0*floe_cat(ii+1) .or. & do while ( wavelength(freq1).lt.2d0*floe_cat(ii+1) .or. &
......
...@@ -42,6 +42,7 @@ subroutine initialization ...@@ -42,6 +42,7 @@ subroutine initialization
end do end do
write(*,*) ' * dt = ',dt,'s' write(*,*) ' * dt = ',dt,'s'
write(*,*) ' * dx = ',dx,'m'
if ( disp.eq.1 ) then if ( disp.eq.1 ) then
write(*,*) ' * dispersion is on' write(*,*) ' * dispersion is on'
else else
...@@ -49,7 +50,7 @@ subroutine initialization ...@@ -49,7 +50,7 @@ subroutine initialization
end if end if
if ( cont.eq.1 ) then if ( cont.eq.1 ) then
write(*,*) ' * wave energy is continuously injected' write(*,*) ' * wave energy continuously injected'
else else
write(*,*) ' * only a single wave energy pulse' write(*,*) ' * only a single wave energy pulse'
end if end if
...@@ -62,6 +63,8 @@ subroutine initialization ...@@ -62,6 +63,8 @@ subroutine initialization
if ( init_spec.eq.1 ) then if ( init_spec.eq.1 ) then
write(*,*) ' * Jonswap spectrum'
! JONSWAP spectrum ! JONSWAP spectrum
do i=1,nf do i=1,nf
if ( freq(i).le.freq_s ) then if ( freq(i).le.freq_s ) then
...@@ -72,18 +75,22 @@ subroutine initialization ...@@ -72,18 +75,22 @@ subroutine initialization
end do end do
Gf=gamma_s**(exp((-(freq-freq_s)**2)/(2*sigma_s**2*freq_s**2))) Gf=gamma_s**(exp((-(freq-freq_s)**2)/(2*sigma_s**2*freq_s**2)))
PM=alpha_s*Hs**2*(freq_s**4/freq**5)*exp(-beta_s*(freq_s/freq)**4) PM=alpha_s*Hs**2*(freq_s**4/freq**5)* &
exp(-beta_s*(freq_s/freq)**4)
Ei=Gf*PM Ei=Gf*PM
else if ( init_spec.eq.0 ) then else if ( init_spec.eq.0 ) then
write(*,*) ' * Bretschneider spectrum'
! Bretschneider spectrum ! Bretschneider spectrum
Ei=(1.25*Hs**2*(1/freq)**5)/(8*pi*Tm**4)* & Ei=(1.25*Hs**2*(1/freq)**5)/(8*pi*Tm**4)* &
exp(-1.25*((1/freq)/Tm)**4) exp(-1.25*((1/freq)/Tm)**4)
else else
Ei=1/(0.01*sqrt(2*pi))*exp(-(omega-2*pi/swell_T)**2/(2*0.01**2)) Ei=1/(0.01*sqrt(2*pi))* &
exp(-(omega-2*pi/swell_T)**2/(2*0.01**2))
Ei=(swell_Hs/4d0)**2*Ei/(sum(Ei*domega)) Ei=(swell_Hs/4d0)**2*Ei/(sum(Ei*domega))
end if end if
...@@ -94,12 +101,12 @@ subroutine initialization ...@@ -94,12 +101,12 @@ subroutine initialization
S_ice(1,:,1)=0 S_ice(1,:,1)=0
x1=floor(X_ice/dx) !find in which grid bin is the ice edge 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( 1:x1)=0 !ice concentration is 0 before ice edge
C_ice(x1:nx)=cice !ice concentration in the transect C_ice(x1:nx)=cice !ice concentration in the transect
Dave( 1:x1)=0 !initalize mean floe size before ice edge Dave( 1:x1)=0 !initialize mean floe size before ice edge
Dmax( 1:x1)=0 !initialize max floe size before ice edge Dmax( 1:x1)=0 !initialize max floe size before ice edge
Dave(x1:nx)=maxfloe !initalize mean floe size in ice transect Dave(x1:nx)=maxfloe !initialize mean floe size in ice transect
Dmax(x1:nx)=maxfloe !initialize max floe size in ice transect Dmax(x1:nx)=maxfloe !initialize max floe size in ice transect
if ( ice_thick.eq.0 ) then if ( ice_thick.eq.0 ) then
...@@ -118,10 +125,10 @@ subroutine initialization ...@@ -118,10 +125,10 @@ subroutine initialization
!--------------------- FLOE SIZE DISTRIBUTION ----------------------- !--------------------- FLOE SIZE DISTRIBUTION -----------------------
res=abs(minfloe-maxfloe)/nedge dr=abs(minfloe - maxfloe)/nedge
floe_cat(1)=minfloe floe_cat(1)=minfloe
do i=2,nedge do i=2,nedge
floe_cat(i)=floe_cat(1)+i*res floe_cat(i)=floe_cat(1)+i*dr
end do end do
do i=1,nr do i=1,nr
...@@ -134,18 +141,17 @@ subroutine initialization ...@@ -134,18 +141,17 @@ subroutine initialization
end do end do
Dave(x1:nx)=middle_floe_cat(nr) Dave(x1:nx)=middle_floe_cat(nr)
!initialize max floe size in ice transect
!--------------------- ICE THICKNESS DISTRIBUTION ------------------- !--------------------- ICE THICKNESS DISTRIBUTION -------------------
resh=abs(mincat_h-maxcat_h)/(nedge_h) dh=abs(mincat_h - maxcat_h)/nedge_h
h_cat(1)=mincat_h h_cat(1)=mincat_h
do i=2,nedge_h do i=2,nedge_h
h_cat(i)=h_cat(1)+i*resh h_cat(i)=h_cat(1) + i*dh
end do end do
do i=1,nh do i=1,nh
middle_h_cat(i)=(h_cat(i)+h_cat(i+1))*0.5 middle_h_cat(i)=0.5*(h_cat(i) + h_cat(i+1))
end do end do
itd(:,:)=0d0 itd(:,:)=0d0
...@@ -170,7 +176,6 @@ subroutine initialization ...@@ -170,7 +176,6 @@ subroutine initialization
end if end if
!--------------------- STATISTICS ----------------------------------- !--------------------- STATISTICS -----------------------------------
h_sign(1,1)=Hs h_sign(1,1)=Hs
......
! !--------------------------------------------------------------------
!____________________________________________________________________
!
!DESCRIPTION: This is the main program of WIM. This routine merely !DESCRIPTION: This is the main program of WIM. This routine merely
! calls other subroutines and do the main time loop. ! calls other subroutines and do the main time loop.
! It also contains the subroutine progress which display ! It also contains the subroutine progress which display
! a progress bar in the terminal while the model is ! a progress bar in the terminal while the model is
! running. ! running.
!____________________________________________________________________ !--------------------------------------------------------------------
!INTERFACE: !INTERFACE:
program wim2 program wim2
...@@ -113,7 +111,7 @@ subroutine message(info) ...@@ -113,7 +111,7 @@ subroutine message(info)
endif endif
if ( info.eq.3 ) then if ( info.eq.3 ) then
write(*,*)' Allocate memory... ' write(*,*)' Allocate memory ... '
endif endif
if ( info.eq.4 ) then if ( info.eq.4 ) then
...@@ -129,12 +127,9 @@ subroutine message(info) ...@@ -129,12 +127,9 @@ subroutine message(info)
endif endif
if ( info.eq.7 ) then if ( info.eq.7 ) then
write(*,*)' done!' write(*,*)' done!'
endif endif
end subroutine message end subroutine message
!____________________________________________________________________
end program wim2 end program wim2
!--------------------------------------------------------------------
!____________________________________________________________________
!
!DESCRIPTION: In this routine, the shared parameters for other !DESCRIPTION: In this routine, the shared parameters for other
! subroutines are declared. It also contains the ! subroutines are declared. It also contains the
! subroutine read_namelist which read parameters value ! subroutine read_namelist which read parameters value
! from the namelist and the subroutine array_allocation ! from the namelist and the subroutine array_allocation
! for memory allocation. ! for memory allocation.
!____________________________________________________________________ !--------------------------------------------------------------------
!INTERFACE:
module parameters module parameters
implicit none implicit none
!NAME OF OUTPUTS FILES !NAME OF OUTPUTS FILES
character(len=100) :: root='output/' ! Output directory character(len=100) :: root='output/' ! Output directory
character(len=100) :: name_sim='test'! Name of the simulation character(len=100) :: name_sim='test'! Name of the simulation
character(len=100) :: namefile character(len=100) :: namefile
character(len=100) :: dirout character(len=100) :: dirout
!DUMMIES !DUMMIES
integer :: i,ii,iii integer :: i,ii,iii
integer :: j,jj,jjj integer :: j,jj,jjj
integer :: n integer :: n
!GLOBAL PARAMETERS ! physical and useful quantities
double precision :: g=9.81 ! Gravitationnal acceleration real :: g=9.81 ! Gravitationnal acc. [m s-2]
double precision :: pi=3.1416 ! Pi 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 !SPECTRUM
integer :: nf=60 ! Nb of frequency bins integer :: nf=60 ! Nb of frequency bins
integer :: init_spec=1 integer :: init_spec=1
double precision :: alpha_s=8.1e-3 double precision :: alpha_s=8.1e-3 ! Jonswap parameter
double precision :: beta_s=1.25 double precision :: beta_s=1.25 ! Jonswap parameter
double precision :: Tmin=2.5 ! Minimum period double precision :: gamma_s=3.3 ! Jonswap parameter
double precision :: Tmax=20 ! Maximum period double precision :: Tmin=2.5 ! Minimum period
double precision :: Tm=6 ! Peak period double precision :: Tmax=20 ! Maximum period
double precision :: Hs=1 ! Significant Height double precision :: Tm=6 ! Peak period [s]
double precision :: gamma_s=3.3 double precision :: Hs=1 ! Significant wave height [m]
double precision :: freq_s ! Peak frequency double precision :: freq_s ! Peak frequency
double precision :: domega ! Frequency increment double precision :: domega ! Frequency increment
double precision :: swell_T=8 double precision :: swell_T=8
double precision :: swell_Hs=1 double precision :: swell_Hs=1
double precision, allocatable :: E(:,:,:) ! Energy spectrum double precision, allocatable :: E(:,:,:) ! Energy spectrum
double precision, allocatable :: Ei(:) ! Initial spectrum double precision, allocatable :: Ei(:) ! Initial spectrum
...@@ -67,7 +67,7 @@ integer :: nx=10 ! Nb of spatial bins ...@@ -67,7 +67,7 @@ integer :: nx=10 ! Nb of spatial bins
integer :: nt ! Duration of the simulation integer :: nt ! Duration of the simulation
real :: dt ! Time step real :: dt ! Time step
double precision :: dx=500 ! Grid resolution real :: dx=500 ! Grid resolution
double precision :: cfl=1 ! Courant double precision :: cfl=1 ! Courant
double precision, allocatable :: x_axis(:) ! Vector of grid width double precision, allocatable :: x_axis(:) ! Vector of grid width
...@@ -106,7 +106,7 @@ integer :: nedge ...@@ -106,7 +106,7 @@ integer :: nedge
double precision :: minfloe=5 double precision :: minfloe=5
double precision :: maxfloe=500 double precision :: maxfloe=500
double precision :: res double precision :: dr
double precision, allocatable :: fsd(:,:,:,:) double precision, allocatable :: fsd(:,:,:,:)
double precision, allocatable :: floe_cat(:) double precision, allocatable :: floe_cat(:)
...@@ -119,8 +119,8 @@ integer :: nedge_h ...@@ -119,8 +119,8 @@ integer :: nedge_h
double precision :: mu_itd=1.2 double precision :: mu_itd=1.2
double precision :: mincat_h=0.1 double precision :: mincat_h=0.1
double precision :: maxcat_h=10 double precision :: maxcat_h=5.0
double precision :: resh double precision :: dh
double precision, allocatable :: itd(:,:) double precision, allocatable :: itd(:,:)
double precision, allocatable :: middle_h_cat(:) double precision, allocatable :: middle_h_cat(:)
...@@ -135,7 +135,7 @@ contains ...@@ -135,7 +135,7 @@ contains
subroutine read_namelist subroutine read_namelist
namelist /spectrum_parameters/ nf,alpha_s,beta_s, & namelist /spectrum_parameters/ nf,alpha_s,beta_s, &
Tmin,Tmax,gamma_s,init_spec, & Tmin,Tmax,gamma_s,init_spec, &
swell_T,swell_Hs