atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
allocbonds.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
21LOGICAL FUNCTION allocedco (alloc)
22
23!
24! Memory allocation for Edge and Corner sharing analysis
25!
26
27USE parameters
28
29IMPLICIT NONE
30
31LOGICAL, INTENT(IN) :: alloc
32
33if (allocated(edgeta)) deallocate(edgeta)
34if (allocated(corta)) deallocate(corta)
35if (allocated(defta)) deallocate(defta)
36if (allocated(tda)) deallocate(tda)
37if (allocated(cornera)) deallocate(cornera)
38if (allocated(edgea)) deallocate(edgea)
39if (allocated(defa)) deallocate(defa)
40if (allocated(tdsa)) deallocate(tdsa)
41if (allocated(eabl)) deallocate(eabl)
42if (allocated(cabl)) deallocate(cabl)
43if (allocated(dabl)) deallocate(dabl)
44if (allocated(etabl)) deallocate(etabl)
45if (allocated(ctabl)) deallocate(ctabl)
46if (allocated(dtabl)) deallocate(dtabl)
47if (allocated(ectabl)) deallocate(ectabl)
48if (allocated(tdtabl)) deallocate(tdtabl)
49if (allocated(etypea)) deallocate(etypea)
50if (allocated(ctypea)) deallocate(ctypea)
51if (allocated(detypea)) deallocate(detypea)
52if (allocated(etda)) deallocate(etda)
53if (allocated(mtabl)) deallocate(mtabl)
54
55if (alloc) then
56 allocate(edgeta(nsp,nsp), stat=err)
57 if (err .ne. 0) then
58 call show_error ("Impossible to allocate memory"//char(0), &
59 "Function: ALLOCEDCO"//char(0), "Table: EDGETA"//char(0))
60 allocedco=.false.
61 goto 001
62 endif
63 allocate(corta(nsp,nsp), stat=err)
64 if (err .ne. 0) then
65 call show_error ("Impossible to allocate memory"//char(0), &
66 "Function: ALLOCEDCO"//char(0), "Table: CORTA"//char(0))
67 allocedco=.false.
68 goto 001
69 endif
70 allocate(defta(nsp,nsp), stat=err)
71 if (err .ne. 0) then
72 call show_error ("Impossible to allocate memory"//char(0), &
73 "Function: ALLOCEDCO"//char(0), "Table: DEFTA"//char(0))
74 allocedco=.false.
75 goto 001
76 endif
77 allocate(tda(nsp,nsp), stat=err)
78 if (err .ne. 0) then
79 call show_error ("Impossible to allocate memory"//char(0), &
80 "Function: ALLOCEDCO"//char(0), "Table: TDA"//char(0))
81 allocedco=.false.
82 goto 001
83 endif
84 do m=1, nsp
85 do n=1, nsp
86 edgeta(n,m)=0
87 corta(n,m)=0
88 defta(n,m)=0
89 tda(n,m)=0
90 enddo
91 enddo
92 allocate(cornera(nsp,nsp,ns), stat=err)
93 if (err .ne. 0) then
94 call show_error ("Impossible to allocate memory"//char(0), &
95 "Function: ALLOCEDCO"//char(0), "Table: CORNERA"//char(0))
96 allocedco=.false.
97 goto 001
98 endif
99 allocate(edgea(nsp,nsp,ns), stat=err)
100 if (err .ne. 0) then
101 call show_error ("Impossible to allocate memory"//char(0), &
102 "Function: ALLOCEDCO"//char(0), "Table: EDGEA"//char(0))
103 allocedco=.false.
104 goto 001
105 endif
106 allocate(defa(nsp,nsp,ns), stat=err)
107 if (err .ne. 0) then
108 call show_error ("Impossible to allocate memory"//char(0), &
109 "Function: ALLOCEDCO"//char(0), "Table: DEFA"//char(0))
110 allocedco=.false.
111 goto 001
112 endif
113 allocate(tdsa(nsp,nsp,ns), stat=err)
114 if (err .ne. 0) then
115 call show_error ("Impossible to allocate memory"//char(0), &
116 "Function: ALLOCEDCO"//char(0), "Table: TDSA"//char(0))
117 allocedco=.false.
118 goto 001
119 endif
120 do m=1, nsp
121 do n=1, nsp
122 do o=1, ns
123 cornera(m,n,o)=0
124 edgea(m,n,o)=0
125 defa(m,n,o)=0
126 tdsa(m,n,o)=0
127 enddo
128 enddo
129 enddo
130 allocate(eabl(nsp), stat=err)
131 if (err .ne. 0) then
132 call show_error ("Impossible to allocate memory"//char(0), &
133 "Function: ALLOCEDCO"//char(0), "Table: EABL"//char(0))
134 allocedco=.false.
135 goto 001
136 endif
137 allocate(cabl(nsp), stat=err)
138 if (err .ne. 0) then
139 call show_error ("Impossible to allocate memory"//char(0), &
140 "Function: ALLOCEDCO"//char(0), "Table: CABL"//char(0))
141 allocedco=.false.
142 goto 001
143 endif
144 allocate(dabl(nsp), stat=err)
145 if (err .ne. 0) then
146 call show_error ("Impossible to allocate memory"//char(0), &
147 "Function: ALLOCEDCO"//char(0), "Table: DABL"//char(0))
148 allocedco=.false.
149 goto 001
150 endif
151 allocate(etabl(nsp), stat=err)
152 if (err .ne. 0) then
153 call show_error ("Impossible to allocate memory"//char(0), &
154 "Function: ALLOCEDCO"//char(0), "Table: ETABL"//char(0))
155 allocedco=.false.
156 goto 001
157 endif
158 allocate(ctabl(nsp), stat=err)
159 if (err .ne. 0) then
160 call show_error ("Impossible to allocate memory"//char(0), &
161 "Function: ALLOCEDCO"//char(0), "Table: CTABL"//char(0))
162 allocedco=.false.
163 goto 001
164 endif
165 allocate(dtabl(nsp), stat=err)
166 if (err .ne. 0) then
167 call show_error ("Impossible to allocate memory"//char(0), &
168 "Function: ALLOCEDCO"//char(0), "Table: DTABL"//char(0))
169 allocedco=.false.
170 goto 001
171 endif
172 allocate(ectabl(nsp), stat=err)
173 if (err .ne. 0) then
174 call show_error ("Impossible to allocate memory"//char(0), &
175 "Function: ALLOCEDCO"//char(0), "Table: ECTABL"//char(0))
176 allocedco=.false.
177 goto 001
178 endif
179 allocate(tdtabl(nsp), stat=err)
180 if (err .ne. 0) then
181 call show_error ("Impossible to allocate memory"//char(0), &
182 "Function: ALLOCEDCO"//char(0), "Table: TDTABL"//char(0))
183 allocedco=.false.
184 goto 001
185 endif
186 allocate (etypea(nsp,nsp), stat=err)
187 if (err .ne. 0) then
188 call show_error ("Impossible to allocate memory"//char(0), &
189 "Function: ALLOCEDCO"//char(0), "Table: ETYPEA"//char(0))
190 allocedco=.false.
191 goto 001
192 endif
193 allocate (ctypea(nsp,nsp), stat=err)
194 if (err .ne. 0) then
195 call show_error ("Impossible to allocate memory"//char(0), &
196 "Function: ALLOCEDCO"//char(0), "Table: CTYPEA"//char(0))
197 allocedco=.false.
198 goto 001
199 endif
200 allocate (detypea(nsp,nsp), stat=err)
201 if (err .ne. 0) then
202 call show_error ("Impossible to allocate memory"//char(0), &
203 "Function: ALLOCEDCO"//char(0), "Table: DETYPEA"//char(0))
204 allocedco=.false.
205 goto 001
206 endif
207 allocate (etda(nsp,nsp), stat=err)
208 if (err .ne. 0) then
209 call show_error ("Impossible to allocate memory"//char(0), &
210 "Function: ALLOCEDCO"//char(0), "Table: EDTA"//char(0))
211 allocedco=.false.
212 goto 001
213 endif
214 allocate(mtabl(ns), stat=err)
215 if (err .ne. 0) then
216 call show_error ("Impossible to allocate memory"//char(0), &
217 "Function: ALLOCEDCO"//char(0), "Table: MTABL"//char(0))
218 allocedco=.false.
219 goto 001
220 endif
221 do i=1, nsp
222 do j=1,nsp
223 etypea(j,i)=0.0d0
224 ctypea(j,i)=0.0d0
225 detypea(j,i)=0.0d0
226 etda(j,i)=0.0d0
227 enddo
228 enddo
229endif
230
231allocedco=.true.
232
233001 continue
234
235END FUNCTION
236
237LOGICAL FUNCTION allocbonds (alloc)
238
239!
240! Memory allocation for bond properties
241!
242
243USE parameters
244
245!INTEGER, INTENT(IN) :: adv
246LOGICAL, INTENT(IN) :: alloc
247
248! For neighbors and environments
249
250if (allocated(la_count)) deallocate(la_count)
251if (allocated(sa_count)) deallocate(sa_count)
252if (allocated(ma_count)) deallocate(ma_count)
253if (allocated(togl)) deallocate(togl)
254if (allocated(tigl)) deallocate(tigl)
255if (allocated(num_gsa)) deallocate(num_gsa)
256if (allocated(tot_gsa)) deallocate(tot_gsa)
257if (allocated(cabl)) deallocate(cabl)
258if (allocated(dabl)) deallocate(dabl)
259if (allocated(eabl)) deallocate(eabl)
260if (allocated(lgsa)) deallocate(lgsa)
261if (allocated(ngsa)) deallocate(ngsa)
262if (allocated(lp_geom)) deallocate(lp_geom)
263if (allocated(lt_geom)) deallocate(lt_geom)
264if (allocated(cmoy)) deallocate(cmoy)
265if (allocated(mac)) deallocate(mac)
266
267if (alloc) then
268 allocate(la_count(na,nsp,ns), stat=err)
269 if (err .ne. 0) then
270 call show_error ("Impossible to allocate memory"//char(0), &
271 "Function: ALLOCBONDS"//char(0), "Table: LA_COUNT"//char(0))
272 allocbonds=.false.
273 goto 001
274 endif
275 allocate(sa_count(nsp), stat=err)
276 if (err .ne. 0) then
277 call show_error ("Impossible to allocate memory"//char(0), &
278 "Function: ALLOCBONDS"//char(0), "Table: SA_COUNT"//char(0))
279 allocbonds=.false.
280 goto 001
281 endif
282 allocate(ma_count(nsp,nsp), stat=err)
283 if (err .ne. 0) then
284 call show_error ("Impossible to allocate memory"//char(0), &
285 "Function: ALLOCBONDS"//char(0), "Table: MA_COUNT"//char(0))
286 allocbonds=.false.
287 goto 001
288 endif
289 sa_count(:)=0
290 ma_count(:,:)=0
291 la_count(:,:,:)=0
292 allocate(togl(ns*na), stat=err)
293 if (err .ne. 0) then
294 call show_error ("Impossible to allocate memory"//char(0), &
295 "Function: ALLOCBONDS"//char(0), "Table: TOGL"//char(0))
296 allocbonds=.false.
297 goto 001
298 endif
299 allocate(tigl(ns*na), stat=err)
300 if (err .ne. 0) then
301 call show_error ("Impossible to allocate memory"//char(0), &
302 "Function: ALLOCBONDS"//char(0), "Table: TIGL"//char(0))
303 allocbonds=.false.
304 goto 001
305 endif
306 allocate(num_gsa(nsp,na*10), stat=err)
307 if (err .ne. 0) then
308 call show_error ("Impossible to allocate memory"//char(0), &
309 "Function: ALLOCBONDS"//char(0), "Table: NUM_GSA"//char(0))
310 allocbonds=.false.
311 goto 001
312 endif
313 allocate(tot_gsa(nsp), stat=err)
314 if (err .ne. 0) then
315 call show_error ("Impossible to allocate memory"//char(0), &
316 "Function: ALLOCBONDS"//char(0), "Table: TOT_GSA"//char(0))
317 allocbonds=.false.
318 goto 001
319 endif
320 allocate(mac(nsp), stat=err)
321 if (err .ne. 0) then
322 call show_error ("Impossible to allocate memory"//char(0), &
323 "Function: ALLOCBONDS"//char(0), "Table: MAC"//char(0))
324 allocbonds=.false.
325 goto 001
326 endif
327endif
328
329!if (adv .eq. 1) then
330! ALLOCBONDS = ALLOCEDCO ()
331!else
332 allocbonds=.true.
333!endif
334
335001 continue
336
337END FUNCTION
logical function allocedco(alloc)
logical function allocbonds(alloc)
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
double precision, dimension(:), allocatable cmoy
double precision, dimension(:), allocatable tdtabl
double precision, dimension(:), allocatable mtabl
integer, dimension(:), allocatable lgsa
double precision, dimension(:,:), allocatable ctypea
double precision, dimension(:,:), allocatable ma_count
double precision, dimension(:), allocatable ctabl
integer, dimension(:,:,:), allocatable defa
integer, dimension(:,:,:), allocatable edgea
double precision, dimension(:,:), allocatable etypea
double precision, dimension(:), allocatable eabl
integer, dimension(:,:), allocatable corta
integer, dimension(:), allocatable tot_gsa
integer, dimension(:,:,:), allocatable la_count
integer err
integer, dimension(:,:,:), allocatable tdsa
double precision, dimension(:), allocatable mac
integer, dimension(:), allocatable ngsa
double precision, dimension(:), allocatable cabl
integer, dimension(:,:), allocatable edgeta
integer, dimension(:,:), allocatable tda
double precision, dimension(:,:), allocatable etda
double precision, dimension(:,:), allocatable num_gsa
integer, dimension(:,:,:), allocatable cornera
integer, dimension(:,:), allocatable defta
double precision, dimension(:), allocatable ectabl
integer, dimension(:), allocatable lp_geom
double precision, dimension(:), allocatable etabl
double precision, dimension(:), allocatable dabl
double precision, dimension(:), allocatable sa_count
double precision, dimension(:), allocatable dtabl
double precision, dimension(:,:), allocatable detypea
integer nsp
integer, dimension(:,:), allocatable lt_geom
integer, dimension(:), allocatable tigl
integer, dimension(:), allocatable togl