Commit 4e5b441447b49d06de12372d18cc6c2b3fef7409

Authored by Jérémy Baudry
1 parent a081b91c
Exists in master

ajout commentaires dans le code

nml/parameter.nml
... ... @@ -17,7 +17,7 @@
17 17 &waves_parameters
18 18  
19 19 Tm =6
20   -Hs =1.5
  20 +Hs =1
21 21 disp =0
22 22  
23 23 /
... ... @@ -31,14 +31,14 @@ disp =0
31 31 ! is needed to calculate the time step.
32 32 ! name_sim -> name of the output file
33 33 ! root -> destination folder for the output file
34   -! FSD_sheme -> method for ice floe breaking parametrization
35   -! 0: Williams et al. 2013
36   -! 1: Horvat 2015
  34 +! FSD_sheme -> method for compute <D>
  35 +! 0: dumont et al (2011)
  36 +! 1: power law
37 37 !------------------------------------------------------------------------------
38 38 &model_parameter
39 39  
40   -nbin =100
41   -dx =1000
  40 +nbin =50
  41 +dx =5000
42 42 Cfl =1
43 43 name_sim ='simulation1'
44 44 root = 'output/'
... ... @@ -86,9 +86,9 @@ gamma_s =3.3
86 86 ! Dmin -> Minimum floe size (if FSD_sheme=1) [m]
87 87 !------------------------------------------------------------------------------
88 88 &ice_parameters
89   -X_ice =5000
  89 +X_ice =50000
90 90 cice =0.8
91   -ice_thick =0
  91 +ice_thick =1
92 92 hice =2
93 93 hmax =4
94 94 Xh =100000
... ...
src/advection.f90
1   -subroutine advection
2 1  
3   -use parameters
  2 +!_______________________________________________________________________________
4 3  
5   -implicit none
  4 + !DESCRIPTION: Here, the wave spectrum is advected through the
  5 + !domain. The advection equation is solved using a Lax-wendroff
  6 + !discretization sheme with a superbee flux limiter.
6 7  
7   - double precision, allocatable :: diffF(:),diffl(:),diffr(:),phi(:),theta(:)
8   - double precision, allocatable :: F(:),diff1(:)
  8 +!_______________________________________________________________________________
  9 +
  10 +
  11 + !INTERFACE:
  12 + subroutine advection
  13 +
  14 + !MODULE USES:
  15 + use parameters
  16 +
  17 + !LOCAL PARAMETERS:
  18 + implicit none
  19 +
  20 + double precision, allocatable :: diffF(:)
  21 + double precision, allocatable :: diffl(:)
  22 + double precision, allocatable :: diffr(:)
  23 + double precision, allocatable :: phi(:)
  24 + double precision, allocatable :: theta(:)
  25 + double precision, allocatable :: F(:)
  26 + double precision, allocatable :: diff1(:)
9 27  
10 28  
11   - allocate(diffl(nbin))
12   - allocate(diffr(nbin))
13   - allocate(diffF(nbin))
14   - allocate(theta(nbin))
15   - allocate(phi(nbin))
16   - allocate(F(nbin))
17   - allocate(diff1(nbin-1))
18   -
  29 + allocate(diffl(nbin))
  30 + allocate(diffr(nbin))
  31 + allocate(diffF(nbin))
  32 + allocate(theta(nbin))
  33 + allocate(phi(nbin))
  34 + allocate(F(nbin))
  35 + allocate(diff1(nbin-1))
  36 +
  37 +!________________________________________________________________________________
19 38  
20 39 do i=2,nbin
21   - diffl(i)=E(n-1,i,ii)-E(n-1,i-1,ii)
  40 + diffl(i)=E(n-1,i,ii)-E(n-1,i-1,ii)
22 41 end do
23 42  
24 43 do i=1,nbin-1
25 44 diffr(i)=E(n-1,i+1,ii)-E(n-1,i,ii)
26 45 end do
27   - diffr(nbin)=-E(n-1,nbin,ii)
  46 +
  47 + diffr(nbin)=-E(n-1,nbin,ii) !set dE=0 at boundaries
28 48 diffl(1)=E(n-1,1,ii)
29 49  
30 50  
31   - do i=1,nbin
  51 + do i=1,nbin !Superbee flux limiter
32 52 theta(i)=diffl(i)/(diffr(i)+3e-14)
33 53 phi(i)=max(0d0,min(theta(i)*2,1d0),min(theta(i),2d0))
34 54 end do
35 55  
36   -
  56 +
  57 + !Lax-Wendroff sheme:
37 58 F=E(n-1,1:nbin,ii)+0.5*(1-CN(ii))*diffr*phi
38 59 do i=2,nbin
39 60 diffF(i)=F(i)-F(i-1)
... ... @@ -42,7 +63,7 @@ implicit none
42 63 E(n,1:nbin,ii)=E(n-1,1:nbin,ii)-CN(ii)*diffF
43 64  
44 65  
45   -
  66 +!________________________________________________________________________________
46 67 end subroutine advection
47 68  
48 69  
... ...
src/attenuation.f90
1   -subroutine attenuation
2   -use parameters
3 1  
4   -implicit none
  2 +!____________________________________________________________________________
5 3  
6   - double precision :: q11,q12,q13,q14,q15,q21,q22,q23,q24,q25
7   - double precision :: q31,q32,q33,q34,q35
8   - double precision, allocatable ::p1(:),p2(:),p3(:),att(:)
9 4  
10   - allocate(p1(nfreq))
11   - allocate(p2(nfreq))
12   - allocate(p3(nfreq))
13   - allocate(att(nfreq))
  5 + !DESCRIPTION: In this routine, the attenuation
  6 + !coefficient is calculated according Kohout and
  7 + !Meylan (2008) and the spectrum attenuation is
  8 + !computed.
14 9  
  10 +!____________________________________________________________________________
  11 +
  12 +
  13 +
  14 + !INTERFACE:
  15 + subroutine attenuation
  16 +
  17 + !USES:
  18 + use parameters
  19 +
  20 + implicit none
  21 +
  22 + double precision :: q11,q12,q13,q14,q15,q21,q22,q23,q24,q25
  23 + double precision :: q31,q32,q33,q34,q35
  24 + double precision, allocatable :: p1(:),p2(:),p3(:)
  25 + double precision, allocatable :: att(:)
  26 +
  27 + allocate(p1(nfreq))
  28 + allocate(p2(nfreq))
  29 + allocate(p3(nfreq))
  30 + allocate(att(nfreq))
  31 +
  32 +!____________________________________________________________________________
15 33  
16 34 q11 = -0.00000777
17 35 q12 = 0.00032080
... ... @@ -42,13 +60,14 @@ alpha(i,j)=0d0
42 60 end if
43 61 end do
44 62  
  63 +
45 64 att=C_ice(i)*alpha(i,1:nfreq)/(Dave(i)+3e-14)
46 65  
47   -S_ice(i,1:nfreq)=-att*E(n,i,1:nfreq)
  66 +S_ice(n,i,1:nfreq)=-att*E(n,i,1:nfreq)
48 67  
49 68 E(n,i,1:nfreq)=E(n,i,1:nfreq)*exp(-att*Cg*dt)
50 69  
51 70  
52   -
  71 +!_____________________________________________________________________________
53 72  
54 73 end subroutine attenuation
... ...
src/floe_breaking.f90
1   -subroutine floe_breaking
2   -
3   -use parameters
4   -
5   -implicit none
6   - double precision, allocatable :: WN_ice(:),fnt(:),k(:)
7   - double precision ::rho=1025,d,F,Y=5.5,v=0.3
8   - integer :: acc=10000
9   - double precision, allocatable :: W(:)
10   - double precision, allocatable :: fnt_d(:)
11   -
12   - double precision, allocatable :: S(:)
13   - double precision :: SS
14   - double precision :: WN_ice_d
15   - double precision :: RS=7.05e-05
16   - double precision :: m0_s
17   - double precision :: m0_a
18   - double precision :: m2_a
19   - double precision :: Tw
20   - double precision :: om_d
21   - double precision :: wl_w
22   -
23   - allocate(fnt(acc+1))
24   - allocate(k(acc+1))
25   - allocate(WN_ice(nfreq))
26   - allocate(W(nfreq))
27   - allocate(fnt_d(acc+1))
28   - allocate(S(nfreq))
29   -
30   -
31   - F=Y*h(i)**3/12d0*(1-v**2)
32   - d=0.9*h(i)
33   -
34   - jj=1
35   - do ii=0,acc
36   - k(jj)=real(ii)*10d0/real(acc)
37   - jj=jj+1
38   - end do
39   -
40   -
41   - do j=1,nfreq
42   - fnt=F*k**5+rho*(g-d*omega(j)**2)*k-rho*omega(j)**2
43   - WN_ice(j)=k(minloc(abs(fnt),DIM=1))
44   -
45   - end do
46 1  
47   -
48   - W=g*WN_ice/omega**2
49   - S=(0.5*h(i))*WN_ice**2*W
50   - m0_s=sum(E(n,i,1:nfreq)*S**2)*domega
51   - SS=2*sqrt(m0_s)
52   - if (SS.gt.RS) then
  2 +!_______________________________________________________________________________
  3 +
  4 + !DESCRIPTION: Here is the parametrization proposed by
  5 + !Williams et al. (2013) for wave induced
  6 + !floe breaking. In this routine, the maximum floe size
  7 + !is computed using the significant strain imposed by
  8 + !passing waves in ice.
  9 +
  10 +
  11 +!_______________________________________________________________________________
  12 +
  13 +
  14 +
  15 + !INTERFACE:
  16 + subroutine floe_breaking
  17 +
  18 + !USES:
  19 + use parameters
  20 +
  21 + !LOCAL PARAMETERS:
53 22  
  23 + implicit none
54 24  
55   - m0_a=sum(E(n,i,1:nfreq)*W**2)*domega
56   - m2_a=sum(omega**2*E(n,i,1:nfreq)*W**2)*domega
57   - Tw=2*pi*sqrt(m0_a/m2_a)
58   - om_d=2*pi/Tw
  25 + double precision, allocatable :: WN_ice(:)
  26 + double precision, allocatable :: fnt(:)
  27 + double precision, allocatable :: k(:)
  28 + double precision :: rho=1025
  29 + double precision :: d
  30 + double precision :: F
  31 + double precision :: Y=5.5
  32 + double precision :: v=0.3
  33 + integer :: acc=10000
  34 + double precision, allocatable :: W(:)
  35 + double precision, allocatable :: fnt_d(:)
  36 +
  37 + double precision, allocatable :: S(:)
  38 + double precision :: SS
  39 + double precision :: WN_ice_d
  40 + double precision :: RS=7.05e-05
  41 + double precision :: m0_s
  42 + double precision :: m0_a
  43 + double precision :: m2_a
  44 + double precision :: Tw
  45 + double precision :: om_d
  46 + double precision :: wl_w
  47 +
  48 + allocate(fnt(acc+1))
  49 + allocate(k(acc+1))
  50 + allocate(WN_ice(nfreq))
  51 + allocate(W(nfreq))
  52 + allocate(fnt_d(acc+1))
  53 + allocate(S(nfreq))
  54 +
  55 +!_______________________________________________________________________________
  56 +
  57 + F=Y*h(i)**3/12d0*(1-v**2)
  58 + d=0.9*h(i)
  59 +
  60 + jj=1 !create a wavelength vector (this is used to
  61 + !find the root of the polynom fnt
  62 + do ii=0,acc
  63 + k(jj)=real(ii)*10d0/real(acc)
  64 + jj=jj+1
  65 + end do
  66 +
  67 +
  68 + do j=1,nfreq
  69 + fnt=F*k**5+rho*(g-d*omega(j)**2)*k-rho*omega(j)**2
  70 + WN_ice(j)=k(minloc(abs(fnt),DIM=1))!calculate wavelength in ice
  71 +
  72 + end do
  73 +
  74 +
  75 + W=g*WN_ice/omega**2
  76 + S=(0.5*h(i))*WN_ice**2*W
  77 + m0_s=sum(E(n,i,1:nfreq)*S**2)*domega !0th moment of the strain spectrum
  78 + SS=2*sqrt(m0_s) !significant strain
  79 + if (SS.gt.RS) then
59 80  
60   - fnt_d=F*k**5+rho*(g-d*om_d**2)*k-rho*om_d**2
61   - WN_ice_d=k(minloc(abs(fnt_d),DIM=1))
62 81  
63   - wl_w=2*pi/WN_ice_d
  82 + m0_a=sum(E(n,i,1:nfreq)*W**2)*domega
  83 + m2_a=sum(omega**2*E(n,i,1:nfreq)*W**2)*domega
  84 + Tw=2*pi*sqrt(m0_a/m2_a)
  85 + om_d=2*pi/Tw
64 86  
65   - Dmax(i)=max(Dmin,min(0.5*wl_w,Dmax(i)))
  87 + fnt_d=F*k**5+rho*(g-d*om_d**2)*k-rho*om_d**2
  88 + WN_ice_d=k(minloc(abs(fnt_d),DIM=1))
66 89  
  90 + wl_w=2*pi/WN_ice_d
  91 + Dmax(i)=max(Dmin,min(0.5*wl_w,Dmax(i)))
67 92  
68   - end if
69 93  
  94 + end if
70 95  
71 96  
72 97  
  98 +!_________________________________________________________________________________
73 99 end subroutine floe_breaking
... ...
src/fsd_build.f90
1   -subroutine fsd_build
2   -use parameters
3 1  
4   - implicit none
5   - double precision :: coeff
6   - double precision, allocatable :: ND(:),NN(:)
7   - integer :: M,mm
  2 +!________________________________________________________________________________
  3 +
  4 + !DESCRIPTION: In this routine the average floe size
  5 + !Dave is computed using the value of Dmax calculated in
  6 + !the subroutine 'floe_breaking'.
  7 +
  8 +!________________________________________________________________________________
  9 +
  10 +
  11 +
  12 + !INTERFACE:
  13 + subroutine fsd_build
  14 +
  15 + !MODULE USES:
  16 + use parameters
  17 +
  18 + !LOCAL PARAMETERS:
  19 + implicit none
  20 +
  21 + double precision :: coeff
  22 + double precision, allocatable :: ND(:)
  23 + double precision, allocatable :: NN(:)
  24 + integer :: M
  25 + integer :: mm
  26 +
  27 +!_________________________________________________________________________________
8 28  
9 29 if(C_ice(i).eq.0)then
10 30 Dave(i)=0
... ... @@ -13,11 +33,12 @@ use parameters
13 33 elseif (Dmax(i).eq.Dmin) then
14 34 Dave(i)=Dmin
15 35  
16   - elseif (FSD_scheme.eq.1) then
17   - coeff=1/((1/(1-gam))*(Dmax(i)**(1-gam)-Dmin**(1-gam)))
18   - Dave(i)=coeff*(1/(2-gam))*(Dmax(i)**(2-gam)-Dmin**(2-gam))
19   - else
  36 + elseif (FSD_scheme.eq.1) then !use a power law to compute <D>
  37 + coeff=1/((1/(1-gam))*(Dmax(i)**(1-gam)-Dmin**(1-gam)))
  38 + Dave(i)=coeff*(1/(2-gam))*(Dmax(i)**(2-gam)-Dmin**(2-gam))
20 39  
  40 + else !use the method from Dumont et al.(2011) to compute <D>
  41 +
21 42 M=floor(log(Dmax(i)/Dmin)/log(psi))
22 43  
23 44 allocate(ND(M+1))
... ... @@ -40,6 +61,6 @@ use parameters
40 61  
41 62  
42 63  
43   -
  64 +!_________________________________________________________________________________
44 65  
45 66 end subroutine fsd_build
... ...
src/initialization.f90
... ... @@ -23,6 +23,22 @@
23 23  
24 24  
25 25  
  26 +
  27 +
  28 + !construct time array
  29 + time(1)=0
  30 + do ii=2,nsteps
  31 + time(ii)=time(ii-1)+dt/60
  32 + end do
  33 +
  34 + !construct space array
  35 + x_axis(1)=0
  36 + do ii=2,nbin
  37 + x_axis(ii)=x_axis(ii-1)+dx/1000
  38 + end do
  39 +
  40 +
  41 +
26 42 !_________________________INITIAL SPECTRUM_____________________________
27 43  
28 44 E(1:nsteps,1:nbin,1:nfreq)=0d0 !INITIALIZE SPECTRUM ARRAY
... ... @@ -54,7 +70,7 @@
54 70 !_______________________________________________________________________
55 71  
56 72 !_______________________ICE_TRANSECT____________________________________
57   -
  73 +S_ice(1,1,1:nfreq)=0
58 74 X1=floor(X_ice/dx) !find in which grid bin is the ice edge
59 75 C_ice(1:X1)=0 !ice concentration is 0 before ice edge!
60 76 C_ice(X1:nbin)=cice !ice concentration in the transect
... ... @@ -81,6 +97,17 @@ h(1:X1)=0d0
81 97 end if
82 98  
83 99 !_____________________FSD_____________________________________________
  100 + res=abs(minfloe-maxfloe)/nedge
  101 +
  102 +floe_cat(1)=maxfloe
  103 +do i=2,nedge
  104 +floe_cat(i)=floe_cat(1)-i*res
  105 +end do
  106 +
  107 +do i=1,nedge-1
  108 +middle_floe_cat(i)=(floe_cat(i)+floe_cat(i+1))*0.5
  109 +end do
  110 +
84 111  
85 112 FSD(1,1:nbin,1)=1d0
86 113  
... ...
src/main.f90
... ... @@ -19,18 +19,6 @@
19 19 call initialization ! initialize the model
20 20  
21 21  
22   -
23   -
24   -!________________________________________________________________________________
25   -
26   -
27   - spectrum=trim(root)//'Energy_spectrum.dat'
28   - floe_size=trim(root)//'floe_size.dat'
29   - namefile=trim(root)//trim(name_sim)//'.nc'
30   -
31   - open(10,file=spectrum)
32   - open(11,file=floe_size)
33   -
34 22  
35 23 !________________________________________________________________________________
36 24 ! DO THE TIME LOOP
... ... @@ -46,18 +34,17 @@
46 34 do i=1,nbin !spatial calculations
47 35  
48 36 call attenuation ! compute spectrum attenuation
49   - call break_horvat ! compute floe breaking
50   - !call floe_breaking
51   - !call fsd_build
  37 + ! compute floe breaking
  38 + call floe_breaking
  39 + call fsd_build
52 40 end do
53 41 end do
54 42 !______________________OUTPUTS_________________________________________________
55 43  
  44 + namefile=trim(root)//trim(name_sim)//'.nc'
56 45 call write_output ! Write outputs in NETCDF
57   - !call graph_dislin
58   - close(10)
59   - close(11)
60   -
  46 +
  47 +
61 48  
62 49  
63 50 contains
... ...
src/makefile
... ... @@ -5,7 +5,7 @@ OPTION= -O3
5 5 NETCDFinc=-I/usr/include
6 6 NETCDFLIB=-L/usr/lib64 -lnetcdff
7 7 NETCDFMOD=-I/usr/lib64/gfortran/modules
8   -DISLIN=-I/usr/local/dislin/gf -ldislin
  8 +
9 9 OBJ= *.o
10 10  
11 11 SRC= *.f90
... ... @@ -17,7 +17,7 @@ EXEC= WIM2
17 17  
18 18  
19 19 WIM2: $(OBJ)
20   - $(COMPILER) $(OPTION) $(NETCDFinc) $(NETCDFMOD) -o $(EXEC) $(OBJ) $(NETCDFLIB) $(DISLIN)
  20 + $(COMPILER) $(OPTION) $(NETCDFinc) $(NETCDFMOD) -o $(EXEC) $(OBJ) $(NETCDFLIB)
21 21 mv WIM2 ../
22 22  
23 23  
... ...
src/parameters.f90
1   -module parameters
2   -
3   -implicit none
4   -
5   -!__________________name of files__________________
6   - character(len=100) ::root='output/',spectrum,floe_size,name_sim='test'
7   - character(len=100) ::namefile
8   -!______________dummys_____________________________
9   - integer :: i,ii,n,j,jj
10   -!______________global parameters__________________
11   -
12   - double precision :: g=9.81,pi=3.1416
13   -!____________Spectrum_____________________________
14   - double precision, allocatable :: E(:,:,:),Ei(:),T(:)
15   - double precision, allocatable :: omega(:),freq(:),sigma_s(:)
16   - integer :: nbin=10,nfreq=60
17   - double precision :: alpha_s=8.1e-3,beta_s=1.25
18   - double precision :: Tmin=2.5,Tmax=20,Tm=6,Hs=1
19   - double precision :: gamma_s=3.3,freq_s,domega
20   - double precision, allocatable :: x_axis(:),time(:)
21   - integer :: init_spec=1
22   -!____________waves_________________________________
23   - double precision, allocatable ::wl(:),Cp(:),Cg(:),CN(:)
24   - integer ::disp=0
25   - double precision ::dwl
26   -!____________grid parameters________________________
27   - double precision :: dt,dx=500
28   - integer :: nsteps
29   - double precision :: Cfl=1
30   -!_____________ICE_____________________________________
31   - double precision, allocatable :: alpha(:,:)
32   - double precision, allocatable :: h(:)
33   - double precision, allocatable :: C_ice(:)
34   - double precision, allocatable :: S_ice(:,:)
35   - double precision :: cice=1
36   - double precision :: hice=1
37   - double precision, allocatable :: Dave(:)
38   - double precision, allocatable :: Dmax(:)
39   - double precision :: D0=200
40   - double precision :: gam=2
41   - double precision :: Dmin=20
42   - double precision :: psi=2
43   - double precision :: ff=0.5
44   - double precision :: Xh=60000
45   - double precision :: X_ice=50000
46   - integer :: ice_thick=1
47   - double precision :: hmax=4
48   -!_________________FSD______________________________
49   - double precision :: minfloe
50   - double precision :: maxfloe
51   - double precision :: res
52   - integer :: nbcat
53   - integer :: nedge
  1 +
  2 +!_________________________________________________________________________________________
  3 +
  4 + !DESCRIPTION: In this routine, the shared parameters for
  5 + !other subroutines are declared. It also contains the
  6 + !subroutine read_namelist which read parameters value
  7 + !from the namelist and the subroutine array_allocation
  8 + !for memory allocation.
  9 +
  10 +!________________________________________________________________________________________
  11 +
  12 + !INTERFACE:
  13 + module parameters
  14 +
  15 +
  16 +
  17 +
  18 + implicit none
  19 +
  20 + !NAME OF OUTPUTS FILES
  21 + character(len=100) :: root='output/' !output directory
  22 + character(len=100) :: name_sim='test'!name of the simulation
  23 + character(len=100) :: namefile
  24 +
  25 +
  26 + !DUMMIES
  27 + integer :: i,ii,n,j,jj
  28 +
  29 +
  30 + !GLOBAL PARAMETERS
  31 + double precision :: g=9.81 !gravitationnal acceleration
  32 + double precision :: pi=3.1416 ! Pi
  33 +
  34 +
  35 + !SPECTRUM
  36 + double precision, allocatable :: E(:,:,:) !Energy spectrum
  37 + double precision, allocatable :: Ei(:) !Initial spectrum
  38 + double precision, allocatable :: T(:) !Period
  39 + double precision, allocatable :: omega(:) !Radial frequency
  40 + double precision, allocatable :: freq(:) !Frequency
  41 + double precision, allocatable :: sigma_s(:)
  42 + integer :: nfreq=60 !Number of frequency band
  43 + double precision :: alpha_s=8.1e-3 !
  44 + double precision :: beta_s=1.25
  45 + double precision :: Tmin=2.5 !Minimum period
  46 + double precision :: Tmax=20 !Maximum period
  47 + double precision :: Tm=6 !Peak period
  48 + double precision :: Hs=1 !Significant Height
  49 + double precision :: gamma_s=3.3
  50 + double precision :: freq_s !Peak frequency
  51 + double precision :: domega !frequency increment
  52 + integer :: init_spec=1
  53 +
  54 +
  55 + !WAVES
  56 + double precision, allocatable :: wl(:) !wavelength
  57 + double precision, allocatable :: Cp(:) !Phase speed
  58 + double precision, allocatable :: Cg(:) !group speed
  59 + double precision, allocatable :: CN(:) !Courant Number (for each frequency)
  60 + integer :: disp=0
  61 + double precision :: dwl !wavelength increment
  62 +
  63 +
  64 + !GRID PARAMETERS
  65 + double precision :: dt !Time step
  66 + double precision :: dx=500 !grid resolution
  67 + integer :: nsteps !Duration of the simulation
  68 + double precision :: Cfl=1 ! Courant
  69 + integer :: nbin=10 !Number of grid bin
  70 + double precision, allocatable :: x_axis(:) !vector of grid width
  71 + double precision, allocatable :: time(:) !vector of time
  72 +
  73 +
  74 + !ICE
  75 + double precision, allocatable :: alpha(:,:)
  76 + double precision, allocatable :: h(:) !ice thickness
  77 + double precision, allocatable :: C_ice(:) !ice concentration
  78 + double precision, allocatable :: S_ice(:,:,:) !ice attenuation source term
  79 + double precision :: cice=1 !ice concentration (from namelist)
  80 + double precision :: hice=1 !ice thickness (from namelist)
  81 + double precision, allocatable :: Dave(:) !Average floe size
  82 + double precision, allocatable :: Dmax(:) !maximum floe size
  83 + double precision :: D0=200 !initial floe size
  84 + double precision :: gam=2 !power law exponent
  85 + double precision :: Dmin=20 !minimum floe size
  86 + double precision :: psi=2
  87 + double precision :: ff=0.5
  88 + double precision :: Xh=60000
  89 + double precision :: X_ice=50000
  90 + integer :: ice_thick=1
  91 + double precision :: hmax=4
  92 +
  93 +
  94 + !FSD
  95 + double precision :: minfloe=1
  96 + double precision :: maxfloe=500
  97 + double precision :: res
  98 + integer :: nbcat=100
  99 + integer :: nedge
54 100 double precision, allocatable :: FSD(:,:,:)
55 101 double precision, allocatable :: floe_cat(:)
56 102 double precision, allocatable :: middle_floe_cat(:)
57   -
58   -!_________model parameters____________________________
59   - integer :: FSD_scheme=1
60   -
  103 + integer :: FSD_scheme=1
  104 +
61 105  
62 106  
63 107 contains
64 108  
  109 +!_____________________________________________________________________________________
  110 +
  111 + !INTERFACE:
  112 + subroutine read_namelist
65 113  
66   -subroutine read_namelist
  114 + namelist /spectrum_parameters/ nfreq,alpha_s,beta_s,Tmin,Tmax,gamma_s,init_spec
  115 + namelist /model_parameter/ nbin,dx,Cfl,name_sim,root,FSD_scheme
  116 + namelist /waves_parameters/ Tm,Hs,disp
  117 + namelist /ice_parameters/ cice,hice,D0,gam,Dmin,ice_thick,hmax,X_ice,Xh
67 118  
68   - namelist /spectrum_parameters/ nfreq,alpha_s,beta_s,Tmin,Tmax,gamma_s,init_spec
69   - namelist /model_parameter/ nbin,dx,Cfl,name_sim,root,FSD_scheme
70   - namelist /waves_parameters/ Tm,Hs,disp
71   - namelist /ice_parameters/ cice,hice,D0,gam,Dmin,ice_thick,hmax,X_ice,Xh
  119 + open(30,file='nml/parameter.nml',status='old')
  120 + read(30,nml=spectrum_parameters)
  121 + close(30)
72 122  
73   - open(30,file='nml/parameter.nml',status='old')
74   - read(30,nml=spectrum_parameters)
75   - close(30)
  123 + open(30,file='nml/parameter.nml',status='old')
  124 + read(30,nml=model_parameter)
  125 + close(30)
76 126  
77   - open(30,file='nml/parameter.nml',status='old')
78   - read(30,nml=model_parameter)
79   - close(30)
  127 + open(30,file='nml/parameter.nml',status='old')
  128 + read(30,nml=waves_parameters)
  129 + close(30)
80 130  
81   - open(30,file='nml/parameter.nml',status='old')
82   - read(30,nml=waves_parameters)
83   - close(30)
  131 + open(30,file='nml/parameter.nml',status='old')
  132 + read(30,nml=ice_parameters)
  133 + close(30)
84 134  
85   - open(30,file='nml/parameter.nml',status='old')
86   - read(30,nml=ice_parameters)
87   - close(30)
88   -
89 135  
90 136 end subroutine read_namelist
  137 +!____________________________________________________________________________________
  138 +
  139 + !INTERFACE:
  140 + subroutine array_allocation
  141 +
  142 +
  143 +
  144 + allocate(Ei(nfreq))
  145 + allocate(T(nfreq))
  146 + allocate(omega(nfreq))
  147 + allocate(freq(nfreq))
  148 + allocate(sigma_s(nfreq))
  149 + allocate(wl(nfreq))
  150 + allocate(Cp(nfreq))
  151 + allocate(Cg(nfreq))
  152 + allocate(CN(nfreq))
  153 + allocate(alpha(nbin,nfreq))
  154 + allocate(h(nbin))
  155 + allocate(C_ice(nbin))
  156 + allocate(x_axis(nbin))
  157 +
  158 + domega=(2*pi/Tmin-2*pi/Tmax)/(nfreq)
  159 + dwl=(g*Tmax**2/(2*pi)-g*Tmin**2/(2*pi))/(nfreq)
  160 + ii=1
  161 + do i=0,nfreq
  162 + omega(ii)=2*pi/Tmax+i*domega
  163 + ii=ii+1
  164 + end do
  165 + freq=omega/(2*pi)
  166 + T=1d0/freq
  167 + freq_s=1d0/Tm
  168 + wl=g*T**2/(2*pi)
  169 + Cp=sqrt(g*wl/(2*pi))
  170 + Cg=0.5*Cp
91 171  
92 172  
93 173  
94   -subroutine array_allocation
95   -
96   -nfreq=nfreq+1
97   -
98   -
99   -
100   -
101   -allocate(Ei(nfreq))
102   -allocate(T(nfreq))
103   -allocate(omega(nfreq))
104   -allocate(freq(nfreq))
105   -allocate(sigma_s(nfreq))
106   -allocate(wl(nfreq))
107   -allocate(Cp(nfreq))
108   -allocate(Cg(nfreq))
109   -allocate(CN(nfreq))
110   -allocate(alpha(nbin,nfreq))
111   -allocate(h(nbin))
112   -allocate(C_ice(nbin))
113   -allocate(S_ice(nbin,nfreq))
114   -allocate(x_axis(nbin))
115   -
116   -
117   -
118   -
119   -
120   - domega=(2*pi/Tmin-2*pi/Tmax)/(nfreq-1)
121   - dwl=(g*Tmax**2/(2*pi)-g*Tmin**2/(2*pi))/(nfreq-1)
122   - ii=1
123   - do i=0,nfreq-1
124   - omega(ii)=2*pi/Tmax+i*domega
125   - freq(ii)=1/Tmax+i*(1/Tmin-1/Tmax)/(nfreq-1)
126   - ii=ii+1
127   - end do
128   - T=1/freq
129   - freq_s=1/Tm
130   - wl=g*T**2/(2*pi)
131   - Cp=sqrt(g*wl/(2*pi))
132   - Cg=Cp/2
133   -
134   -
135   -
136   - if (disp.eq.0) then
137   - CN=Cfl
138   - Cg=maxval(Cg)
139   - dt=CN(1)*dx/maxval(Cg)
  174 + if (disp.eq.0) then
  175 + CN=Cfl
  176 + Cg=maxval(Cg)
  177 + dt=CN(1)*dx/maxval(Cg)
140 178 else
141 179 dt=dx/maxval(Cg)
142 180 CN=Cg*dt/dx
143   - end if
144   -
145   -
  181 + end if
146 182  
147   - nsteps=ceiling(nbin/minval(CN))
  183 + nsteps=ceiling(nbin/minval(CN))
148 184  
149 185  
  186 + allocate(E(nsteps,nbin,nfreq))
  187 + allocate(Dmax(nbin))
  188 + allocate(Dave(nbin))
  189 + allocate(time(nsteps))
  190 + allocate(S_ice(nsteps,nbin,nfreq))
150 191  
151 192  
  193 + nedge=nbcat+1
152 194  
153   -allocate(E(nsteps,nbin,nfreq))
154   -allocate(Dmax(nbin))
155   -allocate(Dave(nbin))
156   -allocate(time(nsteps))
157   -
158   - time(1)=0
159   - do ii=2,nsteps
160   - time(ii)=time(ii-1)+dt/60
161   - end do
162   - x_axis(1)=0
163   - do ii=2,nbin
164   - x_axis(ii)=x_axis(ii-1)+dx/1000
165   - end do
166   -
167   -
168   -
169   -
170   -minfloe=1
171   -maxfloe=500
172   -nbcat=100
173   -nedge=nbcat+1
174   -res=abs(minfloe-maxfloe)/nedge
175   -
176   -allocate(floe_cat(nedge))
177   -allocate(FSD(nsteps,nbin,nbcat))
178   -allocate(middle_floe_cat(nbcat))
179   -
180   -floe_cat(1)=maxfloe
181   -do i=2,nedge
182   -floe_cat(i)=floe_cat(1)-i*res
183   -end do
184   -
185   -do i=1,nedge-1
186   -middle_floe_cat(i)=(floe_cat(i)+floe_cat(i+1))*0.5
187   -end do
188   -
189   -write(*,*)wl
190   -
  195 + allocate(floe_cat(nedge))
  196 + allocate(FSD(nsteps,nbin,nbcat))
  197 + allocate(middle_floe_cat(nbcat))
191 198  
192 199  
193 200 end subroutine array_allocation
194 201  
195 202  
196   -
197   -
198   -
199 203  
200 204  
201 205 end module parameters
... ...
src/write_output.f90
1   -subroutine write_output
2   -
3   -use netcdf
4   -use parameters
5   -implicit none
6   -include 'netcdf.inc'
7   - integer :: ncid,omID,xID,tID,SpectreID
8   - integer :: om_varID,x_varID,t_varID,stat
9   - integer :: Dmax_varID,Dave_varID,c_varID,h_varID
10   - integer :: floeID,fsdID,floe_varID
  1 +
  2 +!________________________________________________________________________________
  3 +
  4 + !DESCRIPTION: This routine create the NETCDF output
  5 + !file. You must have the FORTRAN NETCDF libraries
  6 + !installed on your computer to use this routine.
  7 +
  8 +
  9 +!________________________________________________________________________________
  10 +
  11 + !INTERFACE:
  12 + subroutine write_output
  13 +
  14 + !MODULE USES:
  15 + use netcdf
  16 + use parameters
  17 +
  18 +
  19 +
  20 + !LOCAL PARAMETERS:
  21 +
  22 + implicit none
  23 +
  24 + !INCLUDES:
  25 + include 'netcdf.inc'
  26 +
  27 + integer :: ncid
  28 + integer :: omID
  29 + integer :: xID
  30 + integer :: tID
  31 + integer :: SpectreID
  32 + integer :: om_varID
  33 + integer :: x_varID
  34 + integer :: t_varID
  35 + integer :: stat
  36 + integer :: Dmax_varID
  37 + integer :: Dave_varID
  38 + integer :: c_varID
  39 + integer :: h_varID
  40 + integer :: floeID
  41 + integer :: fsdID
  42 + integer :: floe_varID
  43 + integer :: SrcID
  44 +
  45 +
  46 +!_________________________________________________________________________________
11 47 stat=nf90_create(namefile,nf90_clobber,ncid)
12 48 call handle_err(stat)
13 49 !__________________dimensions_______________________________
... ... @@ -36,6 +72,10 @@ call handle_err(stat)
36 72  
37 73 stat=nf90_def_var(ncid,"Spectrum",nf90_double,(/ tID, xID, omID /),SpectreID)
38 74 call handle_err(stat)
  75 +
  76 + stat=nf90_def_var(ncid,"att src term",nf90_double,(/ tID, xID, omID /),SrcID)
  77 + call handle_err(stat)
  78 +
39 79 stat=nf90_def_var(ncid,"Dave",nf90_double,xID,Dave_varID)
40 80 call handle_err(stat)
41 81 stat=nf90_def_var(ncid,"Dmax",nf90_double,xID,Dmax_varID)
... ... @@ -47,14 +87,14 @@ call handle_err(stat)
47 87 stat=nf90_def_var(ncid,"Floe size distribution",nf90_double,(/ tID, xID,floeID /),fsdID)
48 88 call handle_err(stat)
49 89  
50   -
51   - !stat=nf90_put_att(ncid,ID,"units", values)
52 90 stat=nf90_enddef(ncid)
53 91 call handle_err(stat)
54 92 stat=nf90_put_var(ncid,om_varID,omega)
55 93 call handle_err(stat)
56 94 stat=nf90_put_var(ncid,spectreID,E)
57 95 call handle_err(stat)
  96 + stat=nf90_put_var(ncid,SrcID,S_ice)
  97 + call handle_err(stat)
58 98 stat=nf90_put_var(ncid,Dmax_varID,Dmax)
59 99 call handle_err(stat)
60 100 stat=nf90_put_var(ncid,Dave_varID,Dave)
... ... @@ -76,11 +116,12 @@ call handle_err(stat)
76 116  
77 117  
78 118  
79   -stat=nf90_close(ncid)
80   -call handle_err(stat)
  119 + stat=nf90_close(ncid)
  120 + call handle_err(stat)
81 121  
82 122 contains
83 123  
  124 +!____________________________________________________________________________________
84 125 subroutine handle_err(stat)
85 126 integer, intent(in) :: stat
86