atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
resrings.F90
Go to the documentation of this file.
1! This file is part of the 'atomes' software.
2!
3! 'atomes' is free software: you can redistribute it and/or modify it under the terms
4! of the GNU Affero General Public License as published by the Free Software Foundation,
5! either version 3 of the License, or (at your option) any later version.
6!
7! 'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8! without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9! See the GNU General Public License for more details.
10!
11! You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12! If not, see <https://www.gnu.org/licenses/>
13!
14! Copyright (C) 2022-2024 by CNRS and University of Strasbourg
15!
20
21INTEGER FUNCTION recrings(VID)
22
23USE parameters
24
25IMPLICIT NONE
26
27INTEGER, INTENT(IN) :: vid
28
29DOUBLE PRECISION :: mamp, eamp
30DOUBLE PRECISION :: tamp, etamp
31DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: amp
32DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: ringspna, ectrpna
33DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: emin, emax
34DOUBLE PRECISION, DIMENSION(:,:), ALLOCATABLE :: mpna
35DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: rtab
36
37if (tbr) then
38
39 recrings=2
40 goto 001
41
42else if (alc) then
43
44 recrings=0
45 goto 001
46
47endif
48
49if (allocated(rtab)) deallocate(rtab)
50allocate(rtab(taillr), stat=err)
51if (err .ne. 0) then
52 call show_error ("Impossible to allocate memory"//char(0), &
53 "Function: RECRINGS"//char(0), "Table: RTAB"//char(0))
54 recrings=0
55 goto 001
56endif
57if (allocated(moyred)) deallocate(moyred)
58allocate(moyred(taillr), stat=err)
59if (err .ne. 0) then
60 call show_error ("Impossible to allocate memory"//char(0), &
61 "Function: RECRINGS"//char(0), "Table: MOYRED"//char(0))
62 recrings=0
63 goto 001
64endif
65if (allocated(red)) deallocate(red)
66allocate(red(ns), stat=err)
67if (err .ne. 0) then
68 call show_error ("Impossible to allocate memory"//char(0), &
69 "Function: RECRINGS"//char(0), "Table: RED"//char(0))
70 recrings=0
71 goto 001
72endif
73if (allocated(ectype)) deallocate(ectype)
74allocate(ectype(taillr), stat=err)
75if (err .ne. 0) then
76 call show_error ("Impossible to allocate memory"//char(0), &
77 "Function: RECRINGS"//char(0), "Table: ECTYPE"//char(0))
78 recrings=0
79 goto 001
80endif
81!if (allocated(MOYPUR)) deallocate(MOYPUR)
82!allocate(MOYPUR(TAILLR), STAT=ERR)
83!if (ERR .ne. 0) then
84! call show_error ("Impossible to allocate memory"//CHAR(0), &
85! "Function: RECRINGS"//CHAR(0), "Table: MOYPUR"//CHAR(0))
86! RECRINGS=0
87! goto 001
88!endif
89!if (allocated(IRRED)) deallocate(IRRED)
90!allocate(IRRED(NS), STAT=ERR)
91!if (ERR .ne. 0) then
92! call show_error ("Impossible to allocate memory"//CHAR(0), &
93! "Function: RECRINGS"//CHAR(0), "Table: IRRED"//CHAR(0))
94! RECRINGS=0
95! goto 001
96!endif
97!if (allocated(ECTYP)) deallocate(ECTYP)
98!allocate(ECTYP(TAILLR), STAT=ERR)
99!if (ERR .ne. 0) then
100! call show_error ("Impossible to allocate memory"//CHAR(0), &
101! "Function: RECRINGS"//CHAR(0), "Table: ECTYP"//CHAR(0))
102! RECRINGS=0
103! goto 001
104!endif
105
106ectype(:)=0.0d0
107!ECTYP(:)=0.0d0
108
109do l=3, taillr
110 do i=1, ns
111 red(i)=dble(nring(l,i))/ntlt
112! IRRED(i)=dble(NIRR(l,i))/NTLT
113 enddo
114 if (ns .gt. 1) then
115 moyred(l)=0.0d0
116! MOYPUR(l)=0.0d0
117 ectype(l)=0.0d0
118! ECTYP(l)=0.0d0
119 call moyenne(red, ns, moyred(l))
120! call MOYENNE(IRRED, NS, MOYPUR(l))
121 call ect_type(moyred(l), red, ns, ectype(l))
122! call ECT_TYPE(MOYPUR(l), IRRED, NS, ECTYP(l))
123 else
124 moyred(l)=red(1)
125! MOYPUR(l)=IRRED(1)
126 endif
127enddo
128
129tamp=0.0
130do i=3, taillr
131 rtab(i)=moyred(i)
132 tamp = tamp + rtab(i)
133enddo
134
135if (tamp .eq. 0.0) then
136 recrings=1
137 goto 001
138endif
139
140l=(nsp+1)*4*vid
141if (tlt .ne. nsp+1) l = l + 4*tlt
142call save_curve (taillr, rtab, l, idri)
143
144if (allocated(mpna)) deallocate(mpna)
145allocate(mpna(taillr,taillr), stat=err)
146if (err .ne. 0) then
147 call show_error ("Impossible to allocate memory"//char(0), &
148 "Function: RECRINGS"//char(0), "Table: MPNA"//char(0))
149 recrings=0
150 goto 001
151endif
152if (allocated(epna)) deallocate(epna)
153allocate(epna(taillr,taillr), stat=err)
154if (err .ne. 0) then
155 call show_error ("Impossible to allocate memory"//char(0), &
156 "Function: RECRINGS"//char(0), "Table: EPNA"//char(0))
157 recrings=0
158 goto 001
159endif
160if (allocated(ringspna)) deallocate(ringspna)
161allocate(ringspna(taillr), stat=err)
162if (err .ne. 0) then
163 call show_error ("Impossible to allocate memory"//char(0), &
164 "Function: RECRINGS"//char(0), "Table: RINGSPNA"//char(0))
165 recrings=0
166 goto 001
167endif
168if (allocated(ectrpna)) deallocate(ectrpna)
169allocate(ectrpna(taillr), stat=err)
170if (err .ne. 0) then
171 call show_error ("Impossible to allocate memory"//char(0), &
172 "Function: RECRINGS"//char(0), "Table: ECTPNA"//char(0))
173 recrings=0
174 goto 001
175endif
176if (allocated(rnamax)) deallocate(rnamax)
177allocate(rnamax(taillr), stat=err)
178if (err .ne. 0) then
179 call show_error ("Impossible to allocate memory"//char(0), &
180 "Function: RECRINGS"//char(0), "Table: RNAMAX"//char(0))
181 recrings=0
182 goto 001
183endif
184if (allocated(rnamin)) deallocate(rnamin)
185allocate(rnamin(taillr), stat=err)
186if (err .ne. 0) then
187 call show_error ("Impossible to allocate memory"//char(0), &
188 "Function: RECRINGS"//char(0), "Table: RNAMIN"//char(0))
189 recrings=0
190 goto 001
191endif
192if (allocated(emax)) deallocate(emax)
193allocate(emax(taillr), stat=err)
194if (err .ne. 0) then
195 call show_error ("Impossible to allocate memory"//char(0), &
196 "Function: RECRINGS"//char(0), "Table: EMAX"//char(0))
197 recrings=0
198 goto 001
199endif
200if (allocated(emin)) deallocate(emin)
201allocate(emin(taillr), stat=err)
202if (err .ne. 0) then
203 call show_error ("Impossible to allocate memory"//char(0), &
204 "Function: RECRINGS"//char(0), "Table: EMIN"//char(0))
205 recrings=0
206 goto 001
207endif
208if (allocated(mtabl)) deallocate(mtabl)
209allocate(mtabl(ns), stat=err)
210if (err .ne. 0) then
211 call show_error ("Impossible to allocate memory"//char(0), &
212 "Function: RECRINGS"//char(0), "Table: MTABL"//char(0))
213 recrings=0
214 goto 001
215endif
216
217ringspna(:)=0.0d0
218ectrpna(:)=0.0d0
219rnamax(:)=0.0d0
220rnamin(:)=0.0d0
221emax(:)=0.0d0
222emin(:)=0.0d0
223mpna(:,:)=0.0d0
224epna(:,:)=0.0d0
225
226do i=3, taillr
227 do j=3, taillr
228 if (ns .gt. 1) then
229 do k=1, ns
230 mtabl(k)=pna(i,j,k)
231 enddo
232 call moyenne(mtabl, ns, mpna(i,j))
233 call ect_type(mpna(i,j), mtabl, ns, epna(i,j))
234 if (i.eq.j) then
235 ringspna(i)=mpna(i,j)/ntlt
236 ectrpna(i)=epna(i,j)/ntlt
237 endif
238 else
239 mpna(i,j)=dble(pna(i,j,1))/ntlt
240 if (i.eq.j) ringspna(i)=mpna(i,j)
241 endif
242 enddo
243enddo
244
245do i=1, taillr
246 rtab(i)=ringspna(i)
247enddo
248l=l+1
249call save_curve (taillr, rtab, l, idri)
250
251do i=1, taillr
252 if (ns .gt. 1) then
253 m=0
254 do j=1, ns
255 if (pna(i,i,j) .eq. 0) then
256 mtabl(j)=0.0d0
257 else
258 m=m+1
259 mtabl(j)=dble(maxpna(i,j))/dble(pna(i,i,j))
260 endif
261 enddo
262 if (m.gt.1) then
263 call moyenne(mtabl, ns, rnamax(i))
264 rnamax(i)=rnamax(i)*ns/m
265 call ect_type_rings(rnamax(i), mtabl, ns, m, emax(i))
266 elseif (m.eq.1) then
267 rnamax(i)=rnamax(i)*ns
268 emax(i)=0.0d0
269 else
270 rnamax(i)=0.0d0
271 emax(i)=0.0d0
272 endif
273 m=0
274 do j=1, ns
275 if (pna(i,i,j) .eq. 0) then
276 mtabl(j)=0.0d0
277 else
278 m=m+1
279 mtabl(j)=dble(minpna(i,j))/dble(pna(i,i,j))
280 endif
281 enddo
282 if (m.gt.1) then
283 call moyenne(mtabl, ns, rnamin(i))
284 rnamin(i)=rnamin(i)*ns/m
285 call ect_type_rings(rnamin(i), mtabl, ns, m, emin(i))
286 elseif (m.eq.1) then
287 rnamin(i)=rnamin(i)*ns
288 emin(i)=0.0d0
289 else
290 rnamin(i)=0.0d0
291 emin(i)=0.0d0
292 endif
293 else
294 if (pna(i,i,1).eq.0.0) then
295 rnamax(i)=0.0d0
296 emax(i)=0.0d0
297 rnamin(i)=0.0d0
298 emin(i)=0.0d0
299 else
300 rnamax(i)=dble(maxpna(i,1))/pna(i,i,1)
301 emax(i)=0.0d0
302 rnamin(i)=dble(minpna(i,1))/pna(i,i,1)
303 emin(i)=0.0d0
304 endif
305 endif
306enddo
307
308do i=1, taillr
309 rtab(i)=rnamax(i)
310enddo
311l=l+1
312call save_curve (taillr, rtab, l, idri)
313do i=1, taillr
314 rtab(i)=rnamin(i)
315enddo
316l=l+1
317call save_curve (taillr, rtab, l, idri)
318
319if (allocated(amp)) deallocate(amp)
320allocate(amp(ns), stat=err)
321if (err .ne. 0) then
322 call show_error ("Impossible to allocate memory"//char(0), &
323 "Function: RECRINGS"//char(0), "Table: AMP"//char(0))
324 recrings=0
325 goto 001
326endif
327
328do i=1, ns
329 amp(i)=0.0d0
330 if (doampat) then
331 do j=1, ntlt
332 amp(i)=amp(i)+dble(ampat(j,i))
333 enddo
334 endif
335enddo
336mamp=0.0d0
337eamp=0.0d0
338if (doampat) then
339 if (ns .gt. 1) then
340 call moyenne(amp, ns, mamp)
341 call ect_type(mamp, amp, ns, eamp)
342 else
343 mamp=amp(1)
344 endif
345endif
346
347if (allocated(totpstep)) deallocate(totpstep)
348allocate(totpstep(ns), stat=err)
349if (err .ne. 0) then
350 call show_error ("Impossible to allocate memory"//char(0), &
351 "Function: RECRINGS"//char(0), "Table: TOTPSTEP"//char(0))
352 recrings=0
353 goto 001
354endif
355
356do i=1, ns
357 totpstep(i)=0
358 do j=3, taillr
359 totpstep(i)=totpstep(i)+dble(nring(j,i))
360 enddo
361enddo
362
363tamp=0.0d0
364etamp=0.0d0
365call moyenne(totpstep, ns, tamp)
366call ect_type(tamp, totpstep, ns, etamp)
367call save_rings_data (taillr, ectype, ectrpna, emax, emin, tamp, etamp, mamp, eamp)
368
369recrings=1
370
371001 continue
372
373if (allocated(rtab)) deallocate(rtab)
374if (allocated(ampat)) deallocate(ampat)
375if (allocated(amp)) deallocate(amp)
376if (allocated(totpstep)) deallocate(totpstep)
377if (allocated(moyred)) deallocate(moyred)
378if (allocated(red)) deallocate(red)
379if (allocated(ectype)) deallocate(ectype)
380!if (allocated(MOYPUR)) deallocate(MOYPUR)
381!if (allocated(IRRED)) deallocate(IRRED)
382!if (allocated(ECTYP)) deallocate(ECTYP)
383if (allocated(mpna)) deallocate(mpna)
384if (allocated(epna)) deallocate(epna)
385if (allocated(ringspna)) deallocate(ringspna)
386if (allocated(ectrpna)) deallocate(ectrpna)
387if (allocated(rnamax)) deallocate(rnamax)
388if (allocated(rnamin)) deallocate(rnamin)
389if (allocated(emax)) deallocate(emax)
390if (allocated(emin)) deallocate(emin)
391if (allocated(mtabl)) deallocate(mtabl)
392if (allocated(nring)) deallocate(nring)
393
394END FUNCTION
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
integer ntlt
double precision, dimension(:), allocatable mtabl
double precision, dimension(:), allocatable moyred
double precision, dimension(:), allocatable totpstep
logical tbr
integer, dimension(:,:), allocatable ampat
integer, dimension(:,:), allocatable maxpna
integer, dimension(:,:), allocatable minpna
double precision, dimension(:), allocatable red
double precision, dimension(:), allocatable ectype
integer taillr
integer err
logical alc
integer, dimension(:,:,:), allocatable pna
double precision, dimension(:,:), allocatable epna
integer idri
logical doampat
double precision, dimension(:), allocatable rnamin
double precision, dimension(:), allocatable rnamax
integer tlt
integer, dimension(:,:), allocatable, target nring
integer nsp
integer function recrings(vid)
Definition resrings.F90:22
subroutine moyenne(tableau, longtm, moytab)
Definition utils.F90:526
subroutine ect_type(moyenne, tableau, longte, ec_type)
Definition utils.F90:552
subroutine ect_type_rings(moyenne, tableau, longte, lrepres, ec_type)
Definition utils.F90:394