-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnumerics.f90
94 lines (47 loc) · 1.71 KB
/
numerics.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
MODULE numerics
!-------------------------Parametres------------------------------------
INTEGER, PARAMETER :: rp = 8
REAL(rp), PARAMETER :: un = 1.0_rp
REAL(rp), PARAMETER :: zero = 0.0_rp
REAL(rp), PARAMETER :: grv=9.81_rp
!---------------------------Scalaire------------------------------------
REAL(rp), dimension(:), allocatable :: x, u0,tmp, u_prev, u_next, flux, up, um
REAL(rp), dimension(:,:), allocatable :: uex
REAL(rp) :: d, g, dx, dt, Tmax, t
INTEGER :: n
!-----------------------------------------------------------------------
contains
subroutine init_space()
integer :: i
!-----------------------------------------------------------------------
n=510 ! nombre points en espace
g=-1._rp
d=1._rp
Tmax=2.5_rp !temps maximal
dx=(d-g)/(n-1) ! pas d'espace
t=0._rp
dt=0._rp !pas de temps
!---------------------------Allocation----------------------------------
allocate(x(n))
allocate(u_prev(n))
allocate(u_next(n))
allocate(up(n))
allocate(um(n))
allocate(tmp(n))
allocate(flux(0:n))
!---------------------INITIALISATION ESPACE----------------------------
do i=1, N
x(i)=g+i*dx
end do
end subroutine init_space
SUBROUTINE save_file(x,u, fichier)
real(rp), intent(in), dimension(:) :: u, x
character(len=*), intent(in) :: fichier
! stockage dans un fichier
open(unit=13, file=fichier, status='REPLACE')
DO i=1, SIZE(X)
WRITE(13,*) X(i), u(i)
END DO
close(13)
END SUBROUTINE
END MODULE numerics