-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths_filter.f90
174 lines (109 loc) · 4.01 KB
/
s_filter.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
program suave_filter
use funcproc
! Permanecendo com as variaveis para facilitar =======
real, parameter :: pi = 3.141592654
character(len=5), parameter :: version = "2.0.0"
logical :: ex, help, hfilter, lfilter, sfilter, back
character(len=30) :: get(20), signal
integer :: n_index, i, j, ierr
integer :: start, finish, clock_rate, clock_max
real :: aux, aux2, low, lfreq, hfreq, inicial
real :: hour, minu, sec, paramet, dt, dw, t, w
real, dimension(3000000) ::func, re, im, ref, imf
! ====================================================
call startup_filter(back, signal, hfilter, lfilter, sfilter, paramet, &
hfreq, lfreq, low, get, "s_filter ", version)
open(1, file=signal, status='old', iostat=ierr)
if(ierr /= 0) then
write(*, *)
write(*, *) ' Unable to open file ', signal
write(*, *)
stop
endif
if (.not.sfilter) then
call abre('Ftransf ', 2, 'xvg', back)
write(2, '(a7, a7)') "#SuAVE ", version
write(2, '(a14)') '#Command Line:'
write(2, '(a11)', advance='no') '#s_filter '
write(2, *) (trim(get(i))," ", i=1, 20)
write(2, *) '@ title "Discrete Fourier Transform"'
write(2, *) '@ xaxis label "w [rad/(time unity)]"'
write(2, *) '@ yaxis label "|F(w)|"'
call abre('Ffiltered ', 3, 'xvg', back)
write(3, '(a7, a7)') "#SuAVE ", version
write(3, '(a14)') '#Command Line:'
write(3, '(a11)', advance='no') '#s_filter '
write(3, *) (trim(get(i))," ", i=1, 20)
write(3, *) '@ title "Inverse Fourier Transform"'
write(3, *) '@ xaxis label "t"'
write(3, *) '@ yaxis label "f(t)"'
end if
do i=1, 3000000
func(i) = 0
re(i) = 0
im(i) = 0
end do
if (sfilter) then
call abre('Sfiltered ', 4, 'xvg', back)
write(4, '(a7, a7)') "#SuAVE ", version
write(4, '(a14)') '#Command Line:'
write(4, '(a11)', advance='no') '#s_filter '
write(4, *) (trim(get(i))," ", i=1, 20)
write(4, *) '@ title "SuAVE Unidimensional Fitting Curve"'
write(4, *) '@ xaxis label "t"'
write(4, *) '@ yaxis label "f(t)"'
end if
!===================================
n_index = 0
do while (ierr>=0)
read(1, *, iostat=ierr) aux, aux2
if (ierr == 0)then
if(n_index == 0) inicial = aux
n_index = n_index + 1
func(n_index) = aux2
end if
end do
dt = (aux-inicial)/(n_index-1) ! dividindo pelo numero de intervalos
if(n_index>1000000) then
write(*, *)
write(*, *) ' Too many points (>1000000)'
write(*, *)
stop
end if
call system_clock(start, clock_rate, clock_max)
!SuAVE fitting Curve ===============
if (sfilter) then
call filter_suave(n_index, paramet, func, dt, inicial)
close(4)
close(1)
else
!===================================
! calculando a transformada
call filter_ft(n_index, dt, dw, inicial, func, re, im)
close(2)
!==inserindo FILTROS =========================
!$OMP parallel do
do i=1, n_index
if (sqrt(re(i)*re(i) + im(i)*im(i))<=low) then
re(i) = 0
im(i) = 0
end if
if ((hfilter).and.(-pi/dt + (i-1)*dw>hfreq)) then
re(i) = 0
im(i) = 0
end if
if ((lfilter).and.(-pi/dt + (i-1)*dw<lfreq)) then
re(i) = 0
im(i) = 0
end if
end do
!$OMP end parallel do
!=============================================
! calculando a funcao atraves da transformada
call filter_ift(n_index, dt, inicial, func, re, im, ref, imf)
close(1)
close(3)
end if ! if (s_filter) then
call system_clock(finish, clock_rate, clock_max)
call ending(back, finish, start, clock_rate) ! Finaliza programa e mostra tempo de processamento
end program suave_filter