forked from libAtoms/GAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescriptors_wrapper.f95
587 lines (442 loc) · 21.7 KB
/
descriptors_wrapper.f95
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
! HND X
! HND X GAP (Gaussian Approximation Potental)
! HND X
! HND X
! HND X Portions of GAP were written by Albert Bartok-Partay, Gabor Csanyi,
! HND X Copyright 2006-2021.
! HND X
! HND X Portions of GAP were written by Noam Bernstein as part of
! HND X his employment for the U.S. Government, and are not subject
! HND X to copyright in the USA.
! HND X
! HND X GAP is published and distributed under the
! HND X Academic Software License v1.0 (ASL)
! HND X
! HND X GAP is distributed in the hope that it will be useful for non-commercial
! HND X academic research, but WITHOUT ANY WARRANTY; without even the implied
! HND X warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! HND X ASL for more details.
! HND X
! HND X You should have received a copy of the ASL along with this program
! HND X (e.g. in a LICENSE.md file); if not, you can write to the original licensors,
! HND X Gabor Csanyi or Albert Bartok-Partay. The ASL is also published at
! HND X http://github.com/gabor1/ASL
! HND X
! HND X When using this software, please cite the following reference:
! HND X
! HND X A. P. Bartok et al Physical Review Letters vol 104 p136403 (2010)
! HND X
! HND X When using the SOAP kernel or its variants, please additionally cite:
! HND X
! HND X A. P. Bartok et al Physical Review B vol 87 p184115 (2013)
! HND X
! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!X
!X descriptors_wrapper subroutine
!X
!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
subroutine descriptors_wrapper_distances(N,lattice,symbol,coord,descriptor_str,descriptor_str_len, &
calc_args_str,calc_args_str_len,i,fractional,previous_accepted,distances)
use system_module
use linearalgebra_module
use dictionary_module
use periodictable_module
use atoms_types_module
use connection_module
use atoms_module
use descriptors_module
implicit none
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
integer, intent(in) :: descriptor_str_len
character(len=descriptor_str_len) :: descriptor_str
integer, intent(in) :: calc_args_str_len
character(len=calc_args_str_len) :: calc_args_str
real(dp), dimension(3,N), intent(in) :: coord
integer, intent(in) :: i
logical, intent(in) :: fractional, previous_accepted
real(dp), dimension(N,N), intent(out) :: distances
type(atoms), save :: at
type(Connection), save :: at_connect_last_accepted, at_connect_previous
type(descriptor), save :: desc
type(descriptor_data) :: desc_data
real(dp), dimension(:,:), allocatable, save :: desc_array_last_accepted, distances_in_last_accepted, desc_array_previous, distances_in_previous
logical, dimension(:), pointer :: desc_mask
integer, save :: d
integer :: j, k, l, n_i
logical, save :: first_run = .true.
logical :: recalculate
recalculate = .false.
if( first_run ) then
call system_initialise(verbosity=PRINT_SILENT)
call initialise(desc,trim(descriptor_str))
call initialise(at,N,lattice)
call add_property(at,'desc_mask',.true.,ptr=desc_mask)
d = descriptor_dimensions(desc)
allocate(desc_array_previous(d,N), desc_array_last_accepted(d,N))
allocate(distances_in_previous(N,N), distances_in_last_accepted(N,N))
recalculate = .true.
endif
if( .not. first_run .and. (N /= at%N) ) then
call finalise(at)
call initialise(at,N,lattice)
call add_property(at,'desc_mask',.true.,ptr=desc_mask)
if(allocated(desc_array_previous)) deallocate(desc_array_previous)
allocate(desc_array_previous(d,N))
if(allocated(desc_array_last_accepted)) deallocate(desc_array_last_accepted)
allocate(desc_array_last_accepted(d,N))
if(allocated(distances_in_previous)) deallocate(distances_in_previous)
allocate(distances_in_previous(N,N))
if(allocated(distances_in_last_accepted)) deallocate(distances_in_last_accepted)
allocate(distances_in_last_accepted(N,N))
recalculate = .true.
endif
if( .not. first_run ) then
if( previous_accepted ) then
at_connect_last_accepted = at_connect_previous
desc_array_last_accepted = desc_array_previous
distances_in_last_accepted = distances_in_previous
else
at_connect_previous = at_connect_last_accepted
desc_array_previous = desc_array_last_accepted
distances_in_previous = distances_in_last_accepted
endif
endif
if( at%lattice .fne. lattice ) then
call set_lattice(at,lattice, scale_positions=.false.)
recalculate = .true.
endif
do k = 1, at%N
at%Z(k) = atomic_number_from_symbol(symbol(k))
enddo
if( i > 0 .and. previous_accepted .and. .not. recalculate ) then
if( fractional ) then
at%pos(:,i) = matmul(at%lattice,coord(:,i))
else
at%pos(:,i) = coord(:,i)
endif
else
if( fractional ) then
at%pos = matmul(at%lattice,coord)
else
at%pos = coord
endif
endif
call set_cutoff(at,cutoff(desc)+0.5_dp)
call calc_connect(at)
if( .not. assign_pointer(at,'desc_mask',desc_mask) ) call system_abort("descriptors_wrapper: could not assign pointer desc_mask")
if( i > 0 .and. .not. recalculate ) then
if( i > at%N ) call system_abort("descriptors_wrapper: argument i = "//i//" greater than number of atoms "//at%N)
desc_mask = .false.
desc_mask(i) = .true.
if( at_connect_previous%initialised ) then
do n_i = 1, n_neighbours(at,i,alt_connect=at_connect_previous)
desc_mask(neighbour(at,i,n_i,alt_connect=at_connect_previous)) = .true.
enddo
endif
do n_i = 1, n_neighbours(at,i)
desc_mask(neighbour(at,i,n_i)) = .true.
enddo
call calc(desc,at,desc_data,do_descriptor=.true.,do_grad_descriptor=.false.,args_str="atom_mask_name=desc_mask "//trim(calc_args_str))
do k = 1, count(desc_mask)
j = desc_data%x(k)%ci(1)
desc_array_previous(:,j) = desc_data%x(k)%data(:)
enddo
do k = 1, count(desc_mask)
j = desc_data%x(k)%ci(1)
do l = 1, at%N
distances_in_previous(l,j) = sum( desc_array_previous(:,l) * desc_array_previous(:,j) )
distances_in_previous(j,l) = distances_in_previous(l,j)
enddo
enddo
desc_mask = .true.
at_connect_previous = at%connect
else
call calc(desc,at,desc_data,do_descriptor=.true.,do_grad_descriptor=.false.,args_str=trim(calc_args_str))
do j = 1, at%N
desc_array_previous(:,j) = desc_data%x(j)%data
enddo
distances_in_previous = matmul(transpose(desc_array_previous),desc_array_previous)
at_connect_previous = at%connect
endif
distances = -log(distances_in_previous)
call finalise(desc_data)
if( first_run ) then
at_connect_last_accepted = at_connect_previous
desc_array_last_accepted = desc_array_previous
distances_in_last_accepted = distances_in_previous
endif
first_run = .false.
endsubroutine descriptors_wrapper_distances
module descriptors_wrapper_module
use system_module
use periodictable_module, only : atomic_number_from_symbol
use atoms_module
use linearalgebra_module
use descriptors_module, only : descriptor, initialise, finalise, cutoff, calc, descriptor_sizes, descriptor_dimensions
implicit none
#ifdef HAVE_GAP
type(descriptor), save :: desc
#endif
logical :: first_run = .true.
contains
subroutine descriptors_wrapper_initialise(descriptor_str)
character(len=*) :: descriptor_str
#ifdef HAVE_GAP
if( first_run ) then
call system_initialise(verbosity=PRINT_SILENT)
call initialise(desc,trim(descriptor_str))
else
call finalise(desc)
call initialise(desc,trim(descriptor_str))
endif
first_run = .false.
#endif
endsubroutine descriptors_wrapper_initialise
subroutine descriptors_wrapper_initialise_C(descriptor_str,n_descriptor_str) bind(c)
use iso_c_binding, only: c_int, c_char
character(kind=c_char), intent(in) :: descriptor_str(n_descriptor_str)
integer(kind=c_int), intent(in) :: n_descriptor_str
call descriptors_wrapper_initialise(trim(a2s(descriptor_str)))
endsubroutine descriptors_wrapper_initialise_C
function descriptors_wrapper_dimensions()
integer :: descriptors_wrapper_dimensions
if(.not. first_run) then
descriptors_wrapper_dimensions = descriptor_dimensions(desc)
else
call system_abort("descriptors_wrapper_dimensions: initialise with calling descriptors_wrapper_initialise() first.")
endif
endfunction descriptors_wrapper_dimensions
function descriptors_wrapper_dimensions_C() bind(c)
use iso_c_binding, only: c_int
integer(kind=c_int) :: descriptors_wrapper_dimensions_C
descriptors_wrapper_dimensions_C = descriptors_wrapper_dimensions()
endfunction descriptors_wrapper_dimensions_C
function descriptors_wrapper_size(N,lattice,symbol,coord,fractional)
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer :: descriptors_wrapper_size
type(atoms), save :: at
integer :: n_descriptors,n_cross
call copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
call descriptor_sizes(desc,at,n_descriptors,n_cross)
descriptors_wrapper_size = n_descriptors
endfunction descriptors_wrapper_size
function descriptors_wrapper_size_C(N,lattice,symbol,coord,fractional) bind(c)
use iso_c_binding, only: c_double, c_int, c_bool, c_char
integer(kind=c_int), intent(in) :: N
real(kind=c_double), dimension(3,3), intent(inout) :: lattice
character(kind=c_char), dimension(3,N), intent(in) :: symbol
real(kind=c_double), dimension(3,N), intent(in) :: coord
logical(kind=c_bool), intent(in) :: fractional
integer(kind=c_int) :: descriptors_wrapper_size_C
character(len=3), dimension(N) :: my_symbol
integer :: i
logical :: my_fractional
do i = 1, N
my_symbol(i) = a2s(symbol(:,i))
enddo
my_fractional = logical(fractional,kind=kind(my_fractional))
descriptors_wrapper_size_C = descriptors_wrapper_size(N,lattice,my_symbol,coord,my_fractional)
endfunction descriptors_wrapper_size_C
function descriptors_wrapper_gradient_size(N,lattice,symbol,coord,fractional)
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer :: descriptors_wrapper_gradient_size
type(atoms), save :: at
integer :: n_descriptors,n_cross
call copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
call descriptor_sizes(desc,at,n_descriptors,n_cross)
descriptors_wrapper_gradient_size = n_cross
endfunction descriptors_wrapper_gradient_size
function descriptors_wrapper_gradient_size_C(N,lattice,symbol,coord,fractional) bind(c)
use iso_c_binding, only: c_double, c_int, c_bool, c_char
integer(kind=c_int), intent(in) :: N
real(kind=c_double), dimension(3,3), intent(inout) :: lattice
character(kind=c_char), dimension(3,N), intent(in) :: symbol
real(kind=c_double), dimension(3,N), intent(in) :: coord
logical(kind=c_bool), intent(in) :: fractional
integer(kind=c_int) :: descriptors_wrapper_gradient_size_C
character(len=3), dimension(N) :: my_symbol
integer :: i
logical :: my_fractional
do i = 1, N
my_symbol(i) = a2s(symbol(:,i))
enddo
my_fractional = logical(fractional,kind=kind(my_fractional))
descriptors_wrapper_gradient_size_C = descriptors_wrapper_gradient_size(N,lattice,my_symbol,coord,my_fractional)
endfunction descriptors_wrapper_gradient_size_C
subroutine descriptors_wrapper_both_sizes(N,lattice,symbol,coord,fractional,n_descriptors,n_cross)
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer, intent(out) :: n_descriptors, n_cross
type(atoms), save :: at
call copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
call descriptor_sizes(desc,at,n_descriptors,n_cross)
endsubroutine descriptors_wrapper_both_sizes
subroutine descriptors_wrapper_both_sizes_C(N,lattice,symbol,coord,fractional,n_descriptors,n_cross) bind(c)
use iso_c_binding, only: c_double, c_int, c_bool, c_char
integer(kind=c_int), intent(in) :: N
real(kind=c_double), dimension(3,3), intent(inout) :: lattice
character(kind=c_char), dimension(3,N), intent(in) :: symbol
real(kind=c_double), dimension(3,N), intent(in) :: coord
logical(kind=c_bool), intent(in) :: fractional
integer(kind=c_int), intent(out) :: n_descriptors, n_cross
character(len=3), dimension(N) :: my_symbol
integer :: i
logical :: my_fractional
do i = 1, N
my_symbol(i) = a2s(symbol(:,i))
enddo
my_fractional = logical(fractional,kind=kind(my_fractional))
call descriptors_wrapper_both_sizes(N,lattice,my_symbol,coord,my_fractional,n_descriptors,n_cross)
endsubroutine descriptors_wrapper_both_sizes_C
subroutine descriptors_wrapper_array(N,lattice,symbol,coord,fractional,descriptor_array,d_descriptor, n_descriptor)
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer, intent(in) :: d_descriptor, n_descriptor
real(dp), dimension(d_descriptor,n_descriptor), intent(out):: descriptor_array
type(atoms), save :: at
if( first_run ) then
call system_abort("descriptors_wrapper_array: initialise with calling descriptors_wrapper_initialise() first.")
endif
call copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
call calc(desc,at,descriptor_array)
endsubroutine descriptors_wrapper_array
subroutine descriptors_wrapper_array_C(N,lattice,symbol,coord,fractional,descriptor_array,d_descriptor, n_descriptor) bind(c)
use iso_c_binding, only: c_double, c_int, c_bool, c_char
integer(kind=c_int), intent(in) :: N
real(kind=c_double), dimension(3,3), intent(inout) :: lattice
character(kind=c_char), dimension(3,N), intent(in) :: symbol
real(kind=c_double), dimension(3,N), intent(in) :: coord
logical(kind=c_bool), intent(in) :: fractional
integer(kind=c_int), intent(in) :: d_descriptor, n_descriptor
real(kind=c_double), dimension(d_descriptor,n_descriptor), intent(out):: descriptor_array
character(len=3), dimension(N) :: my_symbol
integer :: i
logical :: my_fractional
do i = 1, N
my_symbol(i) = a2s(symbol(:,i))
enddo
my_fractional = logical(fractional,kind=kind(my_fractional))
call descriptors_wrapper_array(N,lattice,my_symbol,coord,my_fractional,descriptor_array,d_descriptor,n_descriptor)
endsubroutine descriptors_wrapper_array_C
subroutine descriptors_wrapper_gradient_array(N,lattice,symbol,coord,fractional,grad_descriptor_array,grad_descriptor_index,grad_descriptor_pos,d_descriptor,n_cross)
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer, intent(in) :: d_descriptor, n_cross
real(dp), dimension(d_descriptor,3,n_cross), intent(out):: grad_descriptor_array
integer, dimension(2,n_cross), intent(out):: grad_descriptor_index
real(dp), dimension(3,n_cross), intent(out):: grad_descriptor_pos
type(atoms), save :: at
if( first_run ) then
call system_abort("descriptors_wrapper_gradient_array: initialise with calling descriptors_wrapper_initialise() first.")
endif
call copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
call calc(desc,at,grad_descriptor_out=grad_descriptor_array,grad_descriptor_index=grad_descriptor_index,grad_descriptor_pos=grad_descriptor_pos)
endsubroutine descriptors_wrapper_gradient_array
subroutine descriptors_wrapper_gradient_array_C(N,lattice,symbol,coord,fractional,grad_descriptor_array,grad_descriptor_index,grad_descriptor_pos,d_descriptor,n_cross) bind(c)
use iso_c_binding, only: c_double, c_int, c_bool, c_char
integer(kind=c_int), intent(in) :: N
real(kind=c_double), dimension(3,3), intent(inout) :: lattice
character(kind=c_char), dimension(3,N), intent(in) :: symbol
real(kind=c_double), dimension(3,N), intent(in) :: coord
logical(kind=c_bool), intent(in) :: fractional
integer(kind=c_int), intent(in) :: d_descriptor, n_cross
real(kind=c_double), dimension(d_descriptor,3,n_cross), intent(out):: grad_descriptor_array
integer(kind=c_int), dimension(2,n_cross), intent(out):: grad_descriptor_index
real(kind=c_double), dimension(3,n_cross), intent(out):: grad_descriptor_pos
character(len=3), dimension(N) :: my_symbol
integer :: i
logical :: my_fractional
do i = 1, N
my_symbol(i) = a2s(symbol(:,i))
enddo
my_fractional = logical(fractional,kind=kind(my_fractional))
call descriptors_wrapper_gradient_array(N,lattice,my_symbol,coord,my_fractional,grad_descriptor_array,grad_descriptor_index,grad_descriptor_pos,d_descriptor,n_cross)
endsubroutine descriptors_wrapper_gradient_array_C
subroutine descriptors_wrapper_both_arrays(N,lattice,symbol,coord,fractional,descriptor_array,grad_descriptor_array,grad_descriptor_index,grad_descriptor_pos,d_descriptor,n_descriptor,n_cross)
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer, intent(in) :: d_descriptor, n_descriptor, n_cross
real(dp), dimension(d_descriptor,n_descriptor), intent(out):: descriptor_array
real(dp), dimension(d_descriptor,3,n_cross), intent(out):: grad_descriptor_array
integer, dimension(2,n_cross), intent(out):: grad_descriptor_index
real(dp), dimension(3,n_cross), intent(out):: grad_descriptor_pos
type(atoms), save :: at
if( first_run ) then
call system_abort("descriptors_wrapper_both_arrays: initialise with calling descriptors_wrapper_initialise() first.")
endif
call copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
call calc(desc,at,descriptor_out=descriptor_array,grad_descriptor_out=grad_descriptor_array,grad_descriptor_index=grad_descriptor_index,grad_descriptor_pos=grad_descriptor_pos)
endsubroutine descriptors_wrapper_both_arrays
subroutine descriptors_wrapper_both_arrays_C(N,lattice,symbol,coord,fractional,descriptor_array,grad_descriptor_array,grad_descriptor_index,grad_descriptor_pos,d_descriptor,n_descriptor,n_cross) bind(c)
use iso_c_binding, only: c_double, c_int, c_bool, c_char
integer(kind=c_int), intent(in) :: N
real(kind=c_double), dimension(3,3), intent(inout) :: lattice
character(kind=c_char), dimension(3,N), intent(in) :: symbol
real(kind=c_double), dimension(3,N), intent(in) :: coord
logical(kind=c_bool), intent(in) :: fractional
integer(kind=c_int), intent(in) :: d_descriptor, n_descriptor, n_cross
real(kind=c_double), dimension(d_descriptor,n_descriptor), intent(out):: descriptor_array
real(kind=c_double), dimension(d_descriptor,3,n_cross), intent(out):: grad_descriptor_array
integer(kind=c_int), dimension(2,n_cross), intent(out):: grad_descriptor_index
real(kind=c_double), dimension(3,n_cross), intent(out):: grad_descriptor_pos
character(len=3), dimension(N) :: my_symbol
integer :: i
logical :: my_fractional
do i = 1, N
my_symbol(i) = a2s(symbol(:,i))
enddo
my_fractional = logical(fractional,kind=kind(my_fractional))
call descriptors_wrapper_both_arrays(N,lattice,my_symbol,coord,my_fractional,descriptor_array,grad_descriptor_array,grad_descriptor_index,grad_descriptor_pos,d_descriptor,n_descriptor,n_cross)
endsubroutine descriptors_wrapper_both_arrays_C
subroutine copy_data_to_atoms(at,N,lattice,symbol,coord,fractional)
type(atoms), intent(inout) :: at
integer, intent(in) :: N
real(dp), dimension(3,3), intent(inout) :: lattice
character(len=3), dimension(N), intent(in) :: symbol
real(dp), dimension(3,N), intent(in) :: coord
logical, intent(in) :: fractional
integer :: k
if( N /= at%N ) then
call finalise(at)
call initialise(at,N,lattice)
endif
if( at%lattice .fne. lattice ) then
call set_lattice(at,lattice, scale_positions=.false.)
endif
do k = 1, at%N
at%Z(k) = atomic_number_from_symbol(symbol(k))
enddo
if( fractional ) then
at%pos = matmul(at%lattice,coord)
else
at%pos = coord
endif
call set_cutoff(at,cutoff(desc)+0.5_dp)
call calc_connect(at)
endsubroutine copy_data_to_atoms
endmodule descriptors_wrapper_module