-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathderx_1.f90
executable file
·138 lines (93 loc) · 3.63 KB
/
derx_1.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
subroutine derx_1(q3, q4)
!----------------------------------------------------------- !
! F. Califano, 2006 !
! First x-derivative by FFT (periodic boundary conditions) !
!----------------------------------------------------------- !
!**************************************************
! MPI PARALLEL VERSION: VALENTINI-FAGANELLO 2009
!*************************************************
use parameter_mod
use box_mod
use deriv_mod
IMPLICIT NONE
integer :: i
REAL(dp),DIMENSION (nx) :: q3, q4
!do i = 1, nx
!q3(i) = exp(x(i))
!enddo
! Soluzione del sistema lineare tridiagonale fattorizzato LU
! Differenze finite compatte 3x5
do i = 3, nx2
q4(i) = a_1_3x5 * (q3(i+1) - q3(i-1)) + b_1_3x5 * (q3(i+2) - q3(i-2))
enddo
! Differenze finite compatte 3x3 in i=2, nx-1
q4(2) = a_1_3x3 * (q3(3) - q3(1))
q4(nx1) = a_1_3x3 * (q3(nx) - q3(nx2))
SELECT CASE (ibc) ! *** 1 = free, 2 = fixed ***
CASE (1)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! FREE boundary condition (left and right), I derivative, i=1, i=nx !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
q4(1) = a_1_bc * q3(1) + b_1_bc * q3(2) &
+ c_1_bc * q3(3) + d_1_bc * q3(4)
q4(nx) = - a_1_bc * q3(nx) - b_1_bc * q3(nx1) &
- c_1_bc * q3(nx2) - d_1_bc * q3(nx3)
CALL DGTTRS(TRANS,nx,NRHS,dm_1,dd_1,dp_1,dw_1,ipv_d,q4,ndb,INFO)
if (info > 0 .or. info < 0) then
write(*,*) 'Problemi soluzione, info:', info
stop
endif
CASE (2)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Derivata nulla al bordo (left and right), I derivative, i=1, i=nx !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
q4(1) = 0.0
q4(nx) = 0.0
CALL DGTTRS(TRANS,nx,NRHS,wm_1,wd_1,wp_1,ww_1,ipv_w,q4,ndb,INFO)
if (info > 0 .or. info < 0) then
write(*,*) 'Problemi soluzione, info:', info
stop
endif
CASE (3)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Derivata costante al bordo (left and right), I derivative, i=1, i=nx !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
q4(1) = 0.0
q4(nx) = 0.0
CALL DGTTRS(TRANS,nx,NRHS,qm_1,qd_1,qp_1,qq_1,ipv_q,q4,ndb,INFO)
if (info > 0 .or. info < 0) then
write(*,*) 'Problemi soluzione, info:', info
stop
endif
CASE (4)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Boundary Condition Basate sulle caratteristiche !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! in avanzamento e' attiva subroutine BC, per ora poniamo
! la derivata in 1,nx e' calcolata con i punti interni
! e serve solo per poter calcolare la derivata in 2,nx-1
q4(1) = a_1_bc * q3(1) + b_1_bc * q3(2) &
+ c_1_bc * q3(3) + d_1_bc * q3(4)
q4(nx) = - a_1_bc * q3(nx) - b_1_bc * q3(nx1) &
- c_1_bc * q3(nx2) - d_1_bc * q3(nx3)
CALL DGTTRS(TRANS,nx,NRHS,dm_1,dd_1,dp_1,dw_1,ipv_d,q4,ndb,INFO)
if (info > 0 .or. info < 0) then
write(*,*) 'Problemi soluzione, info:', info
stop
endif
END SELECT
!write(*,*) 'derivata numerica'
!write(*,*) q4(1)
!write(*,*) 'valore analitico'
!write(*,*) exp(x(1))
!write(*,*) 'derivata numerica'
!write(*,*) q4(10)
!write(*,*) 'valore analitico'
!write(*,*) exp(x(10))
!write(*,*) 'derivata numerica'
!write(*,*) q4(nx)
!write(*,*) 'valore analitico'
!write(*,*) exp(x(nx))
!call syncronize()
!stop
end subroutine