92RECURSIVE SUBROUTINE setmol (this_mol, toglin, stmb, molcount, the_step, the_atom, the_id)
98TYPE (
mol),
POINTER,
INTENT(INOUT) :: this_mol
99INTEGER,
INTENT(INOUT) :: molcount, stmb
100INTEGER,
INTENT(IN) :: the_step, the_atom, the_id
101INTEGER,
DIMENSION(NA),
INTENT(INOUT) :: toglin
104 LOGICAL FUNCTION add_ato(this_mol, ATOM_ID)
106 TYPE (
mol),
POINTER,
INTENT(INOUT) :: this_mol
107 INTEGER,
INTENT(IN) :: atom_id
112toglin(the_atom) = the_id
113this_mol%ATOMES = this_mol%ATOMES + 1
114this_mol%BSP(lot(the_atom)) = this_mol%BSP(lot(the_atom)) + 1
116if (this_mol%ATOMES > 1)
then
117 if (.not.
add_ato(this_mol, the_atom))
then
122 allocate(this_mol%FIRST_AT, stat=err)
130 this_mol%FIRST_AT%IND = the_atom
131 this_mol%ATOM => this_mol%FIRST_AT
133if (stmb .eq. na)
goto 002
134if (molcount.eq.10000)
goto 001
135if (molcount.eq.-1)
goto 001
136do mc=1, contj(the_atom, the_step)
137 md = voisj(mc,the_atom,the_step)
138 if (toglin(md).eq.0 .and. molcount.lt.10000)
then
139 call setmol (this_mol, toglin, stmb, molcount, the_step, voisj(mc,the_atom,the_step), the_id)
141 if (stmb .eq. na)
goto 002
142 if (molcount.eq.10000)
goto 001
143 if (molcount.eq.-1)
goto 001
154INTEGER (KIND=c_int) FUNCTION molecules (frag_and_mol, allbonds) bind (C,NAME='molecules_')
163INTEGER (KIND=c_int),
INTENT(IN) :: frag_and_mol, allbonds
164INTEGER :: totmol, molps, maxmol
165INTEGER,
DIMENSION(:),
ALLOCATABLE :: atmol
166INTEGER,
DIMENSION(:),
ALLOCATABLE :: atvs, mtmbs
171 LOGICAL FUNCTION add_mol(this_mol, MOL_ID, STEP_ID)
173 TYPE (
mol),
POINTER,
INTENT(INOUT) :: this_mol
174 INTEGER,
INTENT(IN) :: mol_id, step_id
176 RECURSIVE SUBROUTINE setmol (this_mol, toglin, stmb, molcount, the_step, the_atom, the_id)
178 TYPE (
mol),
POINTER,
INTENT(INOUT) :: this_mol
179 INTEGER,
INTENT(INOUT) :: molcount, stmb
180 INTEGER,
INTENT(IN) :: the_step, the_atom, the_id
181 INTEGER,
DIMENSION(NA),
INTENT(INOUT) :: toglin
185TYPE (at),
POINTER :: tmpat
186TYPE (mol),
ALLOCATABLE,
TARGET :: themol
187TYPE (mol),
POINTER :: tmpmol
189if (
allocated(fullpos))
deallocate(fullpos)
194 if (contj(j,i) .eq. 0) k = k + 1
197maxmol = k + allbonds/2;
199if (
allocated(themol))
deallocate(themol)
200allocate(themol, stat=err)
207if (
allocated(mtmbs))
deallocate(mtmbs)
208allocate(mtmbs(ns), stat=err)
216if (frag_and_mol .eq. 1)
then
217 call allocate_mol_data ()
222numth = omp_get_max_threads()
223if (ns.lt.numth) numth=ns
229if (
allocated(togl))
deallocate(togl)
230allocate(togl(na), stat=err)
254 nullify(themol%FIRST_AT)
255 allocate(themol%BSP(nsp), stat=err)
279 if (molcounter.eq.0 .and. togl(j).eq.0)
then
282 if (.not.
add_mol(tmpmol, mtmbs(i)+1, i))
then
293 mtmbs(i) = mtmbs(i) + 1
294 call setmol (tmpmol, togl, tmbs, molcounter, i, j, totmol)
295 if (molcounter .lt. 0)
then
304 if (tmbs.eq.na)
goto 003
306 if (molcounter.eq.10000)
goto 002
310 else if (molcounter.gt.0 .and.togl(j).eq.totmol)
then
313 if (togl(m).eq.0)
then
315 call setmol (tmpmol, togl, tmbs, molcounter, i, voisj(l,j,i), totmol)
316 if (molcounter .lt. 0)
then
325 if (tmbs.eq.na)
goto 003
326 if (molcounter.eq.10000)
goto 002
333 if (tmbs .lt. na)
then
340 if (frag_and_mol .eq. 1)
then
343 call allocate_mol_for_step (i, mtmbs(i))
345 if (
allocated(atmol))
deallocate(atmol)
346 allocate(atmol(tmpmol%ATOMES), stat=err)
357 if (
associated(tmpat))
deallocate (tmpat)
358 allocate(tmpat, stat=err)
369 tmpat = tmpmol%FIRST_AT
370 do k=1, tmpmol%ATOMES
372 if (k < tmpmol%ATOMES)
then
374 deallocate (tmpat%PREV)
380 call send_mol_details (tmpmol%STEP, tmpmol%MID, tmpmol%ATOMES, nsp, tmpmol%BSP, atmol)
381 if (tmpmol%ATOMES .gt. 1)
then
382 do l=1, tmpmol%ATOMES
384 n = contj(m,tmpmol%STEP)
385 if (
allocated(atvs))
deallocate(atvs)
386 allocate(atvs(n), stat=err)
398 atvs(o)= voisj(o,m,tmpmol%STEP)
400 call send_mol_neighbors (tmpmol%STEP, tmpmol%MID, m, n, atvs)
403 if (
allocated(atvs))
deallocate(atvs)
404 if (
allocated(atmol))
deallocate(atmol)
405 if (
allocated(tmpmol%BSP))
deallocate (tmpmol%BSP)
407 if (j .lt. mtmbs(i)) tmpmol => tmpmol%NEXT
412 call setup_fragments (i, togl)
413 do while (tmpmol%MID .gt. 1)
414 tmpmol => tmpmol%PREV
415 deallocate (tmpmol%NEXT)
424if (
allocated(togl))
deallocate (togl)
425if (
allocated(themol))
deallocate(themol)
426if (
allocated(atmol))
deallocate(atmol)
427if (
allocated(atvs))
deallocate(atvs)
430if (
allocated(togl))
deallocate (togl)
431if (
allocated(themol))
deallocate(themol)
432if (
allocated(atvs))
deallocate(atvs)
433if (
allocated(atmol))
deallocate(atmol)
439 molps = molps + mtmbs(i)
442call send_coord_opengl (2, 1, 0, 0, j, 1)
443call init_menu_fragmol (2)
445if (frag_and_mol .eq. 1)
then
446 call setup_menu_molecules ()
454 call show_error (
"Impossible to allocate memory !"//char(0), &
455 "Function: molecules"//char(0), char(9)//
"Table: "//alc_tab(1:len_trim(alc_tab))//char(0))
458if (
allocated(mtmbs))
deallocate(mtmbs)
recursive subroutine setmol(this_mol, toglin, stmb, molcount, the_step, the_atom, the_id)