1 ccccccccccccccccccccccccccccccccccccccccccccccccc
2 ccccccccccccccccccccccccccccccccccccccccccccccccc
3 subroutine make_var(n,idum,iter_csa)
4 implicit real*8 (a-h,o-z)
6 include 'COMMON.IOUNITS'
10 include 'COMMON.INTERACT'
11 include 'COMMON.HAIRPIN'
13 include 'COMMON.DISTFIT'
15 include 'COMMON.CONTROL'
16 logical nicht_getan,nicht_getan1,fail,lfound
17 integer nharp,iharp(4,maxres/3),nconf_harp
20 integer nhx_seed(max_seed),ihx_seed(4,maxres/3,max_seed)
21 integer nhx_use(max_seed),ihx_use(0:4,maxres/3,max_seed)
22 integer nlx_seed(max_seed),ilx_seed(2,maxres/3,max_seed),
23 & nlx_use(max_seed),ilx_use(maxres/3,max_seed)
26 write (iout,*) 'make_var : nseed=',nseed,'ntry=',n
29 c-----------------------------------------
30 if (n7.gt.0.or.n8.gt.0.or.n9.gt.0.or.n14.gt.0.or.n15.gt.0
31 & .or.n16.gt.0.or.n17.gt.0.or.n18.gt.0)
32 & call select_frag(n7frag,n8frag,n14frag,
33 & n15frag,nbefrag,iter_csa)
35 c---------------------------------------------------
36 c N18 - random perturbation of one phi(=gamma) angle in a loop
44 if (lvar_frag(i2,1).eq.i1) then
45 nlx_seed(iters)=nlx_seed(iters)+5
46 ilx_seed(1,nlx_seed(iters),iters)=lvar_frag(i2,2)
47 ilx_seed(2,nlx_seed(iters),iters)=lvar_frag(i2,3)
48 ilx_use(nlx_seed(iters),iters)=5
51 nlx_use(iters)=nlx_seed(iters)
52 nlx_tot=nlx_tot+nlx_seed(iters)
55 if (nlx_tot .ge. n18*nseed) then
58 ntot_gen=(nlx_tot/nseed)*nseed
62 do while (ngen.lt.ntot_gen)
65 if (nlx_use(iters).gt.0) then
67 do while (nicht_getan)
68 iih=iran_num(1,nlx_seed(iters))
69 if (ilx_use(iih,iters).gt.0) then
71 ilx_use(iih,iters)=ilx_use(iih,iters)-1
72 nlx_use(iters)=nlx_use(iters)-1
83 nss_in(index)=bvar_nss(iseed)
85 iss_in(ij,index)=bvar_ss(1,ij,iseed)
86 jss_in(ij,index)=bvar_ss(2,ij,iseed)
94 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
99 jr=iran_num(ilx_seed(1,iih,iters),ilx_seed(2,iih,iters))
101 dihang_in(2,jr-2,1,index)=pinorm(dihang_in(2,jr-2,1,index)+d)
104 if (ngen.eq.ntot_gen) goto 145
113 c-----------------------------------------
114 c N17 : zip a beta in a seed by forcing one additional p-p contact
123 if (avar_frag(i2,1).eq.i1) then
124 nhx_seed(iters)=nhx_seed(iters)+1
125 ihx_use(2,nhx_seed(iters),iters)=1
126 if (avar_frag(i2,5)-avar_frag(i2,3).le.3.and.
127 & avar_frag(i2,2).gt.1.and.avar_frag(i2,4).lt.nres) then
128 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,2)-1
129 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,4)+1
130 ihx_use(0,nhx_seed(iters),iters)=1
131 ihx_use(1,nhx_seed(iters),iters)=0
132 nhx_use(iters)=nhx_use(iters)+1
134 if (avar_frag(i2,4).gt.avar_frag(i2,5)) then
135 if (avar_frag(i2,2).gt.1.and.
136 & avar_frag(i2,4).lt.nres) then
137 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,2)-1
138 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,4)+1
139 ihx_use(0,nhx_seed(iters),iters)=1
140 ihx_use(1,nhx_seed(iters),iters)=0
141 nhx_use(iters)=nhx_use(iters)+1
143 if (avar_frag(i2,3).lt.nres.and.
144 & avar_frag(i2,5).gt.1) then
145 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,3)+1
146 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,5)-1
147 ihx_use(0,nhx_seed(iters),iters)=
148 & ihx_use(0,nhx_seed(iters),iters)+1
149 ihx_use(2,nhx_seed(iters),iters)=0
150 nhx_use(iters)=nhx_use(iters)+1
153 if (avar_frag(i2,2).gt.1.and.
154 & avar_frag(i2,4).gt.1) then
155 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,2)-1
156 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,4)-1
157 ihx_use(0,nhx_seed(iters),iters)=1
158 ihx_use(1,nhx_seed(iters),iters)=0
159 nhx_use(iters)=nhx_use(iters)+1
161 if (avar_frag(i2,3).lt.nres.and.
162 & avar_frag(i2,5).lt.nres) then
163 ihx_seed(1,nhx_seed(iters),iters)=avar_frag(i2,3)+1
164 ihx_seed(2,nhx_seed(iters),iters)=avar_frag(i2,5)+1
165 ihx_use(0,nhx_seed(iters),iters)=
166 & ihx_use(0,nhx_seed(iters),iters)+1
167 ihx_use(2,nhx_seed(iters),iters)=0
168 nhx_use(iters)=nhx_use(iters)+1
175 nhx_tot=nhx_tot+nhx_use(iters)
176 cd write (iout,*) "debug N17",iters,nhx_seed(iters),
177 cd & nhx_use(iters),nhx_tot
180 if (nhx_tot .ge. n17*nseed) then
182 else if (nhx_tot .ge. nseed) then
183 ntot_gen=(nhx_tot/nseed)*nseed
187 cd write (iout,*) "debug N17==",ntot_gen,nhx_tot,nseed
190 do while (ngen.lt.ntot_gen)
193 if (nhx_use(iters).gt.0) then
194 cd write (iout,*) "debug N17",nhx_use(iters),ngen,ntot_gen
195 cd write (iout,*) "debugN17^",
196 cd & (ihx_use(0,k,iters),k=1,nhx_use(iters))
198 do while (nicht_getan)
199 iih=iran_num(1,nhx_seed(iters))
200 cd write (iout,*) "debugN17^",iih
201 if (ihx_use(0,iih,iters).gt.0) then
203 cd write (iout,*) "debugN17=",iih,nhx_seed(iters)
204 cd write (iout,*) "debugN17-",iim,'##',
205 cd & (ihx_use(k,iih,iters),k=0,2)
207 do while (ihx_use(iim,iih,iters).eq.1)
209 cd write (iout,*) "debugN17-",iim,'##',
210 cd & (ihx_use(k,iih,iters),k=0,2)
214 ihx_use(iim,iih,iters)=1
215 ihx_use(0,iih,iters)=ihx_use(0,iih,iters)-1
216 nhx_use(iters)=nhx_use(iters)-1
222 parent(1,index)=iseed
226 nss_in(index)=bvar_nss(iseed)
227 do ij=1,nss_in(index)
228 iss_in(ij,index)=bvar_ss(1,ij,iseed)
229 jss_in(ij,index)=bvar_ss(2,ij,iseed)
236 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
242 idata(1,index)=ihx_seed(1,iih,iters)
243 idata(2,index)=ihx_seed(2,iih,iters)
245 idata(1,index)=ihx_seed(3,iih,iters)
246 idata(2,index)=ihx_seed(4,iih,iters)
249 if (ngen.eq.ntot_gen) goto 115
254 write (iout,*) "N17",n17," ngen/nseed",ngen/nseed,
259 c-----------------------------------------
260 c N16 : slide non local beta in a seed by +/- 1 or +/- 2
268 if (bvar_frag(i2,1).eq.i1) then
269 nhx_seed(iters)=nhx_seed(iters)+1
270 ihx_seed(1,nhx_seed(iters),iters)=bvar_frag(i2,3)
271 ihx_seed(2,nhx_seed(iters),iters)=bvar_frag(i2,4)
272 ihx_seed(3,nhx_seed(iters),iters)=bvar_frag(i2,5)
273 ihx_seed(4,nhx_seed(iters),iters)=bvar_frag(i2,6)
274 ihx_use(0,nhx_seed(iters),iters)=4
276 ihx_use(i3,nhx_seed(iters),iters)=0
280 nhx_use(iters)=4*nhx_seed(iters)
281 nhx_tot=nhx_tot+nhx_seed(iters)
282 cd write (iout,*) "debug N16",iters,nhx_seed(iters)
285 if (4*nhx_tot .ge. n16*nseed) then
287 else if (4*nhx_tot .ge. nseed) then
288 ntot_gen=(4*nhx_tot/nseed)*nseed
292 write (iout,*) "debug N16",ntot_gen,4*nhx_tot,nseed
295 do while (ngen.lt.ntot_gen)
298 if (nhx_use(iters).gt.0) then
300 do while (nicht_getan)
301 iih=iran_num(1,nhx_seed(iters))
302 if (ihx_use(0,iih,iters).gt.0) then
304 do while (ihx_use(iim,iih,iters).eq.1)
305 cd write (iout,*) iim,
306 cd & ihx_use(0,iih,iters),ihx_use(iim,iih,iters)
310 ihx_use(iim,iih,iters)=1
311 ihx_use(0,iih,iters)=ihx_use(0,iih,iters)-1
312 nhx_use(iters)=nhx_use(iters)-1
318 parent(1,index)=iseed
322 nss_in(index)=bvar_nss(iseed)
323 do ij=1,nss_in(index)
324 iss_in(ij,index)=bvar_ss(1,ij,iseed)
325 jss_in(ij,index)=bvar_ss(2,ij,iseed)
332 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
338 idata(i,index)=ihx_seed(i,iih,iters)
342 if (ngen.eq.ntot_gen) goto 116
347 write (iout,*) "N16",n16," ngen/nseed",ngen/nseed,
350 c-----------------------------------------
351 c N15 : copy two 2nd structure elements from 1 or 2 conf. in bank to a seed
366 iif=iran_num(1,n15frag)
367 do while( (ifused(iif) .or. svar_frag(iif,1).eq.iseed) .and.
369 iif=iran_num(1,n15frag)
372 if(iran.ge.mxio) goto 811
375 iig=iran_num(1,n15frag)
376 do while( (ifused(iig) .or. svar_frag(iig,1).eq.iseed .or.
377 & .not.(svar_frag(iif,3).lt.svar_frag(iig,2).or.
378 & svar_frag(iig,3).lt.svar_frag(iif,2)) ) .and.
380 iig=iran_num(1,n15frag)
383 if(iran.ge.mxio) goto 811
387 parent(1,index)=iseed
388 parent(2,index)=svar_frag(iif,1)
389 parent(3,index)=svar_frag(iig,1)
393 nss_in(index)=bvar_nss(iseed)
394 do ij=1,nss_in(index)
395 iss_in(ij,index)=bvar_ss(1,ij,iseed)
396 jss_in(ij,index)=bvar_ss(2,ij,iseed)
402 call newconf_copy(idum,dihang_in(1,1,1,index),
403 & svar_frag(iif,1),svar_frag(iif,2),svar_frag(iif,3))
405 do j=svar_frag(iig,2),svar_frag(iig,3)
407 dihang_in(i,j,1,index)=bvar(i,j,1,svar_frag(iig,1))
413 call check_old(icheck,index)
426 c-----------------------------------------
427 c N14 local_move (Maurizio) for loops in a seed
435 if (lvar_frag(i2,1).eq.i1) then
436 nlx_seed(iters)=nlx_seed(iters)+3
437 ilx_seed(1,nlx_seed(iters),iters)=lvar_frag(i2,2)
438 ilx_seed(2,nlx_seed(iters),iters)=lvar_frag(i2,3)
439 ilx_use(nlx_seed(iters),iters)=3
442 nlx_use(iters)=nlx_seed(iters)
443 nlx_tot=nlx_tot+nlx_seed(iters)
444 cd write (iout,*) "debug N14",iters,nlx_seed(iters)
447 if (nlx_tot .ge. n14*nseed) then
450 ntot_gen=(nlx_tot/nseed)*nseed
452 cd write (iout,*) "debug N14",ntot_gen,n14frag,nseed
455 do while (ngen.lt.ntot_gen)
458 if (nlx_use(iters).gt.0) then
460 do while (nicht_getan)
461 iih=iran_num(1,nlx_seed(iters))
462 if (ilx_use(iih,iters).gt.0) then
464 ilx_use(iih,iters)=ilx_use(iih,iters)-1
465 nlx_use(iters)=nlx_use(iters)-1
471 parent(1,index)=iseed
474 idata(1,index)=ilx_seed(1,iih,iters)
475 idata(2,index)=ilx_seed(2,iih,iters)
479 nss_in(index)=bvar_nss(iseed)
480 do ij=1,nss_in(index)
481 iss_in(ij,index)=bvar_ss(1,ij,iseed)
482 jss_in(ij,index)=bvar_ss(2,ij,iseed)
490 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
495 if (ngen.eq.ntot_gen) goto 131
500 cd write (iout,*) "N14",n14," ngen/nseed",ngen/nseed,
504 c-----------------------------------------
505 c N9 : shift a helix in a seed
513 if (hvar_frag(i2,1).eq.i1) then
514 nhx_seed(iters)=nhx_seed(iters)+1
515 ihx_seed(1,nhx_seed(iters),iters)=hvar_frag(i2,2)
516 ihx_seed(2,nhx_seed(iters),iters)=hvar_frag(i2,3)
517 ihx_use(0,nhx_seed(iters),iters)=4
519 ihx_use(i3,nhx_seed(iters),iters)=0
523 nhx_use(iters)=4*nhx_seed(iters)
524 nhx_tot=nhx_tot+nhx_seed(iters)
525 cd write (iout,*) "debug N9",iters,nhx_seed(iters)
528 if (4*nhx_tot .ge. n9*nseed) then
531 ntot_gen=(4*nhx_tot/nseed)*nseed
533 cd write (iout,*) "debug N9",ntot_gen,n8frag,nseed
536 do while (ngen.lt.ntot_gen)
539 if (nhx_use(iters).gt.0) then
541 do while (nicht_getan)
542 iih=iran_num(1,nhx_seed(iters))
543 if (ihx_use(0,iih,iters).gt.0) then
545 do while (ihx_use(iim,iih,iters).eq.1)
546 cd write (iout,*) iim,
547 cd & ihx_use(0,iih,iters),ihx_use(iim,iih,iters)
551 ihx_use(iim,iih,iters)=1
552 ihx_use(0,iih,iters)=ihx_use(0,iih,iters)-1
553 nhx_use(iters)=nhx_use(iters)-1
559 parent(1,index)=iseed
563 nss_in(index)=bvar_nss(iseed)
564 do ij=1,nss_in(index)
565 iss_in(ij,index)=bvar_ss(1,ij,iseed)
566 jss_in(ij,index)=bvar_ss(2,ij,iseed)
573 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
578 jstart=max(nnt,ihx_seed(1,iih,iters)+1)
579 jend=min(nct,ihx_seed(2,iih,iters))
580 cd write (iout,*) "debug N9",iters,iih,jstart,jend
583 else if (iim.eq.2) then
585 else if (iim.eq.3) then
587 else if (iim.eq.4) then
590 write (iout,*) 'CHUJ NASTAPIL: iim=',iim
591 call mpi_abort(mpi_comm_world,ierror,ierrcode)
594 if (itype(j).eq.10) then
600 if (j+ishift.ge.nnt.and.j+ishift.le.nct)
601 & dihang_in(i,j+ishift,1,index)=bvar(i,j,1,iseed)
604 if (ishift.gt.0) then
606 if (itype(jend+j).eq.10) then
612 if (jend+j.ge.nnt.and.jend+j.le.nct)
613 & dihang_in(i,jstart+j,1,index)=bvar(i,jend+j,1,iseed)
618 if (itype(jstart+j).eq.10) then
624 if (jend+j.ge.nnt.and.jend+j.le.nct)
625 & dihang_in(i,jend+j,1,index)=bvar(i,jstart+j,1,iseed)
629 if (ngen.eq.ntot_gen) goto 133
634 cd write (iout,*) "N9",n9," ngen/nseed",ngen/nseed,
638 c-----------------------------------------
639 c N8 : copy a helix from bank to seed
642 if (n8frag.lt.n8) then
643 write (iout,*) "N8: only ",n8frag,'helices'
660 iif=iran_num(1,n8frag)
661 do while( (ifused(iif) .or. hvar_frag(iif,1).eq.iseed) .and.
663 iif=iran_num(1,n8frag)
667 if(iran.ge.mxio) goto 911
671 parent(1,index)=iseed
672 parent(2,index)=hvar_frag(iif,1)
676 nss_in(index)=bvar_nss(iseed)
677 do ij=1,nss_in(index)
678 iss_in(ij,index)=bvar_ss(1,ij,iseed)
679 jss_in(ij,index)=bvar_ss(2,ij,iseed)
684 if (hvar_frag(iif,3)-hvar_frag(iif,2).le.6) then
685 call newconf_copy(idum,dihang_in(1,1,1,index),
686 & hvar_frag(iif,1),hvar_frag(iif,2),hvar_frag(iif,3))
688 ih_start=iran_num(hvar_frag(iif,2),hvar_frag(iif,3)-6)
689 ih_end=iran_num(ih_start,hvar_frag(iif,3))
690 call newconf_copy(idum,dihang_in(1,1,1,index),
691 & hvar_frag(iif,1),ih_start,ih_end)
695 call check_old(icheck,index)
711 c-----------------------------------------
712 c N7 : copy nonlocal beta fragment from bank to seed
715 if (n7frag.lt.n7) then
716 write (iout,*) "N7: only ",n7frag,'nonlocal fragments'
740 iif=iran_num(1,n7frag)
741 do while( (ifused(iif) .or. bvar_frag(iif,1).eq.iseed) .and.
743 iif=iran_num(1,n7frag)
747 cd write (*,'(3i5,l,4i5)'),iters,idummy,iif,ifused(iif),
748 cd & bvar_frag(iif,1),iseed,iran,index2
750 if(iran.ge.mxio) goto 999
751 if(index2.ge.mxio2) goto 999
755 parent(1,index)=iseed
756 parent(2,index)=bvar_frag(iif,1)
762 nss_in(index)=bvar_nss(iseed)
763 do ij=1,nss_in(index)
764 iss_in(ij,index)=bvar_ss(1,ij,iseed)
765 jss_in(ij,index)=bvar_ss(2,ij,iseed)
772 dihang_in2(i,j,k,index2)=bvar(i,j,k,bvar_frag(iif,1))
777 if (bvar_frag(iif,2).eq.4) then
778 do i=bvar_frag(iif,3),bvar_frag(iif,4)
781 if (bvar_frag(iif,5).lt.bvar_frag(iif,6)) then
782 cd print *,'###',bvar_frag(iif,3),bvar_frag(iif,4),
783 cd & bvar_frag(iif,5),bvar_frag(iif,6)
784 do i=bvar_frag(iif,5),bvar_frag(iif,6)
788 cd print *,'###',bvar_frag(iif,3),bvar_frag(iif,4),
789 cd & bvar_frag(iif,6),bvar_frag(iif,5)
790 do i=bvar_frag(iif,6),bvar_frag(iif,5)
799 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
811 c-----------------------------------------------
812 c N6 : copy random continues fragment from bank to seed
817 isize=(is2-is1+1)*ran1(idum)+is1
823 nss_in(index)=bvar_nss(iseed)
824 do ij=1,nss_in(index)
825 iss_in(ij,index)=bvar_ss(1,ij,iseed)
826 jss_in(ij,index)=bvar_ss(2,ij,iseed)
833 i1=nconf* ran1(idum)+1
836 i1=nbank* ran1(idum)+1
838 if(i1.eq.iseed) goto 104
840 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
841 parent(1,index)=iseed
844 call check_old(icheck,index)
845 if(icheck.eq.1) goto 104
849 c-----------------------------------------
850 if (n3.gt.0.or.n4.gt.0) call gen_hairpin
853 if (nharp_seed(iters).gt.0) nconf_harp=nconf_harp+1
855 c-----------------------------------------
856 c N3 : copy hairpin from bank to seed
867 i1=nconf* ran1(idum)+1
870 i1=nbank* ran1(idum)+1
872 if(i1.eq.iseed) goto 124
874 if (i1.eq.iisucc(k).and.nsucc.lt.nconf_harp-1) goto 124
879 call newconf_residue_hairpin(idum,dihang_in(1,1,1,index),
882 if (icycle.le.0 .and. nsucc.eq.nconf .or.
883 & icycle.gt.0 .and. nsucc.eq.nbank) then
891 call check_old(icheck,index)
892 if(icheck.eq.1) goto 124
895 parent(1,index)=iseed
900 nss_in(index)=bvar_nss(iseed)
901 do ij=1,nss_in(index)
902 iss_in(ij,index)=bvar_ss(1,ij,iseed)
903 jss_in(ij,index)=bvar_ss(2,ij,iseed)
909 c if not enough hairpins, supplement with windows
911 cdd if (n3.ne.0) write (iout,*) "N3",n3," nsucc",nsucc," nacc",nacc
913 isize=(is2-is1+1)*ran1(idum)+is1
916 parent(1,index)=iseed
921 nss_in(index)=bvar_nss(iseed)
922 do ij=1,nss_in(index)
923 iss_in(ij,index)=bvar_ss(1,ij,iseed)
924 jss_in(ij,index)=bvar_ss(2,ij,iseed)
931 i1=nconf* ran1(idum)+1
934 i1=nbank* ran1(idum)+1
936 if(i1.eq.iseed) goto 114
938 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
940 call check_old(icheck,index)
941 if(icheck.eq.1) goto 114
945 c-----------------------------------------
946 c N4 : shift a turn in hairpin in seed
949 if (4*nharp_tot .ge. n4*nseed) then
952 ntot_gen=(4*nharp_tot/nseed)*nseed
955 do while (ngen.lt.ntot_gen)
958 c write (iout,*) 'iters',iters,' iseed',iseed,' nharp_seed',
959 c & nharp_seed(iters),' nharp_use',nharp_use(iters),
960 c & ' ntot_gen',ntot_gen
961 c write (iout,*) 'iharp_use(0)',
962 c & (iharp_use(0,k,iters),k=1,nharp_seed(iters))
963 if (nharp_use(iters).gt.0) then
965 do while (nicht_getan)
966 iih=iran_num(1,nharp_seed(iters))
967 c write (iout,*) 'iih',iih,' iharp_use',
968 c & (iharp_use(k,iih,iters),k=1,4)
969 if (iharp_use(0,iih,iters).gt.0) then
971 do while (nicht_getan1)
973 nicht_getan1=iharp_use(iim,iih,iters).eq.1
976 iharp_use(iim,iih,iters)=1
977 iharp_use(0,iih,iters)=iharp_use(0,iih,iters)-1
978 nharp_use(iters)=nharp_use(iters)-1
979 cdd write (iout,'(a16,i3,a5,i2,a10,2i4)')
980 cdd & 'N4 selected hairpin',iih,' move',iim,' iharp_seed',
981 cdd & iharp_seed(1,iih,iters),iharp_seed(2,iih,iters)
987 parent(1,index)=iseed
992 nss_in(index)=bvar_nss(iseed)
993 do ij=1,nss_in(index)
994 iss_in(ij,index)=bvar_ss(1,ij,iseed)
995 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1002 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1006 jstart=iharp_seed(1,iih,iters)+1
1007 jend=iharp_seed(2,iih,iters)
1010 else if (iim.eq.2) then
1012 else if (iim.eq.3) then
1014 else if (iim.eq.4) then
1017 write (iout,*) 'CHUJ NASTAPIL: iim=',iim
1018 call mpi_abort(mpi_comm_world,ierror,ierrcode)
1020 c write (iout,*) 'jstart',jstart,' jend',jend,' ishift',ishift
1021 c write (iout,*) 'Before turn shift'
1023 c theta(j+1)=dihang_in(1,j,1,index)
1024 c phi(j+2)=dihang_in(2,j,1,index)
1025 c alph(j)=dihang_in(3,j,1,index)
1026 c omeg(j)=dihang_in(4,j,1,index)
1030 if (itype(j).eq.10) then
1036 if (j+ishift.ge.nnt.and.j+ishift.le.nct)
1037 & dihang_in(i,j+ishift,1,index)=bvar(i,j,1,iseed)
1040 c write (iout,*) 'After turn shift'
1042 c theta(j+1)=dihang_in(1,j,1,index)
1043 c phi(j+2)=dihang_in(2,j,1,index)
1044 c alph(j)=dihang_in(3,j,1,index)
1045 c omeg(j)=dihang_in(4,j,1,index)
1048 if (ngen.eq.ntot_gen) goto 135
1052 c if not enough hairpins, supplement with windows
1053 c write (iout,*) 'end of enddo'
1055 cdd write (iout,*) "N4",n4," ngen/nseed",ngen/nseed,
1059 do idummy=ngen/nseed+1,n4
1060 isize=(is2-is1+1)*ran1(idum)+is1
1065 nss_in(index)=bvar_nss(iseed)
1066 do ij=1,nss_in(index)
1067 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1068 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1075 if(icycle.le.0) then
1076 i1=nconf* ran1(idum)+1
1079 i1=nbank* ran1(idum)+1
1081 if(i1.eq.iseed) goto 134
1083 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
1084 parent(1,index)=iseed
1087 call check_old(icheck,index)
1088 if(icheck.eq.1) goto 134
1093 c-----------------------------------------
1094 c N5 : copy one residue from bank to seed (normally switched off - use N1)
1104 nss_in(index)=bvar_nss(iseed)
1105 do ij=1,nss_in(index)
1106 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1107 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1114 if(icycle.le.0) then
1115 i1=nconf* ran1(idum)+1
1118 i1=nbank* ran1(idum)+1
1120 if(i1.eq.iseed) goto 105
1122 call newconf_residue(idum,dihang_in(1,1,1,index),i1,isize)
1123 parent(1,index)=iseed
1126 call check_old(icheck,index)
1127 if(icheck.eq.1) goto 105
1131 c-----------------------------------------
1132 c N2 : copy backbone of one residue from bank or first bank to seed
1133 c (normally switched off - use N1)
1138 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1139 iseed=ran1(idum)*nconf+1
1140 iseed=nbank-nconf+iseed
1146 nss_in(index)=bvar_nss(iseed)
1147 do ij=1,nss_in(index)
1148 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1149 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1154 102 i1= ran1(idum)*nbank+1
1155 if(i1.eq.iseed) goto 102
1157 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1158 nran=mod(i-1,nran0)+3
1159 call newconf1arr(idum,dihang_in(1,1,1,index),nran,i1)
1160 parent(1,index)=-iseed
1162 else if(icycle.le.0.and.iters.le.iuse) then
1163 nran=mod(i-1,nran0)+1
1164 call newconf1abr(idum,dihang_in(1,1,1,index),nran,i1)
1165 parent(1,index)=iseed
1168 nran=mod(i-1,nran1)+1
1169 if(ran1(idum).lt.0.5) then
1170 call newconf1abr(idum,dihang_in(1,1,1,index),nran,i1)
1171 parent(1,index)=iseed
1174 call newconf1abb(idum,dihang_in(1,1,1,index),nran,i1)
1175 parent(1,index)=iseed
1180 call check_old(icheck,index)
1181 if(icheck.eq.1) goto 102
1185 c-----------------------------------------
1186 c N1 : copy backbone or sidechain of one residue from bank or
1187 c first bank to seed
1192 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1193 iseed=ran1(idum)*nconf+1
1194 iseed=nbank-nconf+iseed
1200 nss_in(index)=bvar_nss(iseed)
1201 do ij=1,nss_in(index)
1202 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1203 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1208 101 i1= ran1(idum)*nbank+1
1210 if(i1.eq.iseed) goto 101
1212 if(icycle.le.0.and.iuse.gt.nconf-irr) then
1213 nran=mod(i-1,nran0)+3
1214 call newconf1rr(idum,dihang_in(1,1,1,index),nran,i1)
1215 parent(1,index)=-iseed
1217 else if(icycle.le.0.and.iters.le.iuse) then
1218 nran=mod(i-1,nran0)+1
1219 call newconf1br(idum,dihang_in(1,1,1,index),nran,i1)
1220 parent(1,index)=iseed
1223 nran=mod(i-1,nran1)+1
1224 if(ran1(idum).lt.0.5) then
1225 call newconf1br(idum,dihang_in(1,1,1,index),nran,i1)
1226 parent(1,index)=iseed
1229 call newconf1bb(idum,dihang_in(1,1,1,index),nran,i1)
1230 parent(1,index)=iseed
1235 call check_old(icheck,index)
1236 if(icheck.eq.1) goto 101
1240 c-----------------------------------------
1248 parent(1,index)=iseed
1252 nss_in(index)=bvar_nss(iseed)
1253 do ij=1,nss_in(index)
1254 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1255 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1262 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1268 c-----------------------------------------
1275 theta(j+1)=bvar(1,j,k,iseed)
1276 phi(j+2)=bvar(2,j,k,iseed)
1277 alph(j)=bvar(3,j,k,iseed)
1278 omeg(j)=bvar(4,j,k,iseed)
1283 cd write(iout,*) 'makevar DYNSS',iseed,'#',bvar_ns(iseed),
1284 cd & (bvar_s(k,iseed),k=1,bvar_ns(iseed)),
1285 cd & bvar_nss(iseed),
1286 cd & (bvar_ss(1,k,iseed)-nres,'-',
1287 cd & bvar_ss(2,k,iseed)-nres,k=1,bvar_nss(iseed))
1289 do i1=1,bvar_ns(iseed)
1291 c N10 fussion of free halfcysteines in seed
1292 c first select CYS with distance < 7A
1294 do j1=i1+1,bvar_ns(iseed)
1295 if (dist(bvar_s(i1,iseed)+nres,bvar_s(j1,iseed)+nres)
1297 & iabs(bvar_s(i1,iseed)-bvar_s(j1,iseed)).gt.3) then
1301 parent(1,index)=iseed
1303 do ij=1,bvar_nss(iseed)
1304 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1305 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1307 ij=bvar_nss(iseed)+1
1309 iss_in(ij,index)=bvar_s(i1,iseed)+nres
1310 jss_in(ij,index)=bvar_s(j1,iseed)+nres
1312 cd write(iout,*) 'makevar NSS0',index,
1313 cd & dist(bvar_s(i1,iseed)+nres,bvar_s(j1,iseed)+nres),
1314 cd & nss_in(index),iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres
1319 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1327 c N11 type I transdisulfidation
1329 do j1=1,bvar_nss(iseed)
1330 if (dist(bvar_s(i1,iseed)+nres,bvar_ss(1,j1,iseed))
1332 & iabs(bvar_s(i1,iseed)-(bvar_ss(1,j1,iseed)-nres))
1337 parent(1,index)=iseed
1339 do ij=1,bvar_nss(iseed)
1341 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1342 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1345 nss_in(index)=bvar_nss(iseed)
1346 iss_in(j1,index)=bvar_s(i1,iseed)+nres
1347 jss_in(j1,index)=bvar_ss(1,j1,iseed)
1348 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1349 iss_in(j1,index)=bvar_ss(1,j1,iseed)
1350 jss_in(j1,index)=bvar_s(i1,iseed)+nres
1353 cd write(iout,*) 'makevar NSS1 #1',index,
1354 cd & bvar_s(i1,iseed),bvar_ss(1,j1,iseed)-nres,
1355 cd & dist(bvar_s(i1,iseed)+nres,bvar_ss(1,j1,iseed)),
1356 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1357 cd & ij=1,nss_in(index))
1362 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1367 if (dist(bvar_s(i1,iseed)+nres,bvar_ss(2,j1,iseed))
1369 & iabs(bvar_s(i1,iseed)-(bvar_ss(2,j1,iseed)-nres))
1374 parent(1,index)=iseed
1376 do ij=1,bvar_nss(iseed)
1378 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1379 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1382 nss_in(index)=bvar_nss(iseed)
1383 iss_in(j1,index)=bvar_s(i1,iseed)+nres
1384 jss_in(j1,index)=bvar_ss(2,j1,iseed)
1385 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1386 iss_in(j1,index)=bvar_ss(2,j1,iseed)
1387 jss_in(j1,index)=bvar_s(i1,iseed)+nres
1391 cd write(iout,*) 'makevar NSS1 #2',index,
1392 cd & bvar_s(i1,iseed),bvar_ss(2,j1,iseed)-nres,
1393 cd & dist(bvar_s(i1,iseed)+nres,bvar_ss(2,j1,iseed)),
1394 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1395 cd & ij=1,nss_in(index))
1400 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1410 c N12 type II transdisulfidation
1412 do i1=1,bvar_nss(iseed)
1413 do j1=i1+1,bvar_nss(iseed)
1414 if (dist(bvar_ss(1,i1,iseed),bvar_ss(1,j1,iseed))
1416 & dist(bvar_ss(2,i1,iseed),bvar_ss(2,j1,iseed))
1418 & iabs(bvar_ss(1,i1,iseed)-bvar_ss(1,j1,iseed))
1420 & iabs(bvar_ss(2,i1,iseed)-bvar_ss(2,j1,iseed))
1424 parent(1,index)=iseed
1426 do ij=1,bvar_nss(iseed)
1427 if (ij.ne.i1 .and. ij.ne.j1) then
1428 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1429 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1432 nss_in(index)=bvar_nss(iseed)
1433 iss_in(i1,index)=bvar_ss(1,i1,iseed)
1434 jss_in(i1,index)=bvar_ss(1,j1,iseed)
1435 if (iss_in(i1,index).gt.jss_in(i1,index)) then
1436 iss_in(i1,index)=bvar_ss(1,j1,iseed)
1437 jss_in(i1,index)=bvar_ss(1,i1,iseed)
1439 iss_in(j1,index)=bvar_ss(2,i1,iseed)
1440 jss_in(j1,index)=bvar_ss(2,j1,iseed)
1441 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1442 iss_in(j1,index)=bvar_ss(2,j1,iseed)
1443 jss_in(j1,index)=bvar_ss(2,i1,iseed)
1447 cd write(iout,*) 'makevar NSS2 #1',index,
1448 cd & bvar_ss(1,i1,iseed)-nres,bvar_ss(1,j1,iseed)-nres,
1449 cd & dist(bvar_ss(1,i1,iseed),bvar_ss(1,j1,iseed)),
1450 cd & bvar_ss(2,i1,iseed)-nres,bvar_ss(2,j1,iseed)-nres,
1451 cd & dist(bvar_ss(2,i1,iseed),bvar_ss(2,j1,iseed)),
1452 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1453 cd & ij=1,nss_in(index))
1458 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1465 if (dist(bvar_ss(1,i1,iseed),bvar_ss(2,j1,iseed))
1467 & dist(bvar_ss(2,i1,iseed),bvar_ss(1,j1,iseed))
1469 & iabs(bvar_ss(1,i1,iseed)-bvar_ss(2,j1,iseed))
1471 & iabs(bvar_ss(2,i1,iseed)-bvar_ss(1,j1,iseed))
1475 parent(1,index)=iseed
1477 do ij=1,bvar_nss(iseed)
1478 if (ij.ne.i1 .and. ij.ne.j1) then
1479 iss_in(ij,index)=bvar_ss(1,ij,iseed)
1480 jss_in(ij,index)=bvar_ss(2,ij,iseed)
1483 nss_in(index)=bvar_nss(iseed)
1484 iss_in(i1,index)=bvar_ss(1,i1,iseed)
1485 jss_in(i1,index)=bvar_ss(2,j1,iseed)
1486 if (iss_in(i1,index).gt.jss_in(i1,index)) then
1487 iss_in(i1,index)=bvar_ss(2,j1,iseed)
1488 jss_in(i1,index)=bvar_ss(1,i1,iseed)
1490 iss_in(j1,index)=bvar_ss(2,i1,iseed)
1491 jss_in(j1,index)=bvar_ss(1,j1,iseed)
1492 if (iss_in(j1,index).gt.jss_in(j1,index)) then
1493 iss_in(j1,index)=bvar_ss(1,j1,iseed)
1494 jss_in(j1,index)=bvar_ss(2,i1,iseed)
1498 cd write(iout,*) 'makevar NSS2 #2',index,
1499 cd & bvar_ss(1,i1,iseed)-nres,bvar_ss(2,j1,iseed)-nres,
1500 cd & dist(bvar_ss(1,i1,iseed),bvar_ss(2,j1,iseed)),
1501 cd & bvar_ss(2,i1,iseed)-nres,bvar_ss(1,j1,iseed)-nres,
1502 cd & dist(bvar_ss(2,i1,iseed),bvar_ss(1,j1,iseed)),
1503 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1504 cd & ij=1,nss_in(index))
1509 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1520 c N13 removal of disulfide bond
1522 if (bvar_nss(iseed).gt.0) then
1523 i1=bvar_nss(iseed)*ran1(idum)+1
1527 parent(1,index)=iseed
1530 do j1=1,bvar_nss(iseed)
1533 iss_in(ij,index)=bvar_ss(1,j1,iseed)
1534 jss_in(ij,index)=bvar_ss(2,j1,iseed)
1537 nss_in(index)=bvar_nss(iseed)-1
1539 cd write(iout,*) 'NSS3',index,i1,
1540 cd & bvar_ss(1,i1,iseed)-nres,'=',bvar_ss(2,i1,iseed)-nres,'#',
1541 cd & (iss_in(ij,index)-nres,'-',jss_in(ij,index)-nres,
1542 cd & ij=1,nss_in(index))
1547 dihang_in(i,j,k,index)=bvar(i,j,k,iseed)
1556 c-----------------------------------------
1560 if(index.ne.n) write(iout,*)'make_var : ntry=',index
1564 cd write (istat,*) "======== ii=",ii," the dihang array"
1566 cd write (istat,'(i5,4f15.5)') i,(dihang_in(k,i,1,ii)*rad2deg,k=1,4)
1571 ccccccccccccccccccccccccccccccccccccccccccccccccc
1572 ccccccccccccccccccccccccccccccccccccccccccccccccc
1573 subroutine check_old(icheck,n)
1574 implicit real*8 (a-h,o-z)
1575 include 'DIMENSIONS'
1576 include 'COMMON.CSA'
1577 include 'COMMON.BANK'
1578 include 'COMMON.CHAIN'
1579 include 'COMMON.GEO'
1589 dif=rad2deg*dabs(dihang_in(i,j,m,i1)-dihang_in(i,j,m,i2))
1590 if(dif.gt.180.0) dif=360.0-dif
1591 if(dif.gt.ctdif) goto 100
1593 if(diff.gt.ctdiff) goto 100
1606 ccccccccccccccccccccccccccccccccccccccccccccccccc
1607 ccccccccccccccccccccccccccccccccccccccccccccccccc
1608 subroutine newconf1rr(idum,vvar,nran,i1)
1609 implicit real*8 (a-h,o-z)
1610 include 'DIMENSIONS'
1611 include 'COMMON.IOUNITS'
1612 include 'COMMON.CSA'
1613 include 'COMMON.BANK'
1614 include 'COMMON.CHAIN'
1615 include 'COMMON.GEO'
1617 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1623 vvar(i,j,k)=rvar(i,j,k,iseed)
1636 10 iran= ran1(idum)*number+1
1637 if(iter.gt.number) return
1639 if(iter.eq.1) goto 11
1641 if(iran.eq.iold(ind)) goto 10
1645 do ind=1,ngroup(iran)
1646 i=igroup(1,ind,iran)
1647 j=igroup(2,ind,iran)
1648 k=igroup(3,ind,iran)
1649 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1650 if(dif.gt.180.) dif=360.-dif
1651 if(dif.gt.ctdif) goto 20
1653 if(iter.gt.number) goto 20
1656 do ind=1,ngroup(iran)
1657 i=igroup(1,ind,iran)
1658 j=igroup(2,ind,iran)
1659 k=igroup(3,ind,iran)
1660 vvar(i,j,k)=rvar(i,j,k,i1)
1667 ccccccccccccccccccccccccccccccccccccccccccccccccc
1668 ccccccccccccccccccccccccccccccccccccccccccccccccc
1669 subroutine newconf1br(idum,vvar,nran,i1)
1670 implicit real*8 (a-h,o-z)
1671 include 'DIMENSIONS'
1672 include 'COMMON.IOUNITS'
1673 include 'COMMON.CSA'
1674 include 'COMMON.BANK'
1675 include 'COMMON.CHAIN'
1676 include 'COMMON.GEO'
1677 include 'COMMON.TORCNSTR'
1678 include 'COMMON.CONTROL'
1680 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1686 vvar(i,j,k)=bvar(i,j,k,iseed)
1699 10 iran= ran1(idum)*number+1
1700 if(i2ndstr.gt.0) then
1702 if(rtmp.le.rdih_bias) then
1705 if(igroup(2,1,iran).eq.idih_nconstr(j))i=j
1710 iran= ran1(idum)*number+1
1713 if(igroup(2,1,iran).eq.idih_nconstr(j))i=j
1715 if(i.eq.0.or.juhc.lt.1000)goto 4321
1716 if(juhc.eq.1000) then
1717 print *, 'move 6 : failed to find unconstrained group'
1718 write(iout,*) 'move 6 : failed to find unconstrained group'
1723 if(iter.gt.number) return
1725 if(iter.eq.1) goto 11
1727 if(iran.eq.iold(ind)) goto 10
1731 do ind=1,ngroup(iran)
1732 i=igroup(1,ind,iran)
1733 j=igroup(2,ind,iran)
1734 k=igroup(3,ind,iran)
1735 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1736 if(dif.gt.180.) dif=360.-dif
1737 if(dif.gt.ctdif) goto 20
1739 if(iter.gt.number) goto 20
1742 do ind=1,ngroup(iran)
1743 i=igroup(1,ind,iran)
1744 j=igroup(2,ind,iran)
1745 k=igroup(3,ind,iran)
1746 vvar(i,j,k)=rvar(i,j,k,i1)
1753 ccccccccccccccccccccccccccccccccccccccccccccccccc
1754 ccccccccccccccccccccccccccccccccccccccccccccccccc
1755 subroutine newconf1bb(idum,vvar,nran,i1)
1756 implicit real*8 (a-h,o-z)
1757 include 'DIMENSIONS'
1758 include 'COMMON.IOUNITS'
1759 include 'COMMON.CSA'
1760 include 'COMMON.BANK'
1761 include 'COMMON.CHAIN'
1762 include 'COMMON.GEO'
1764 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1770 vvar(i,j,k)=bvar(i,j,k,iseed)
1783 10 iran= ran1(idum)*number+1
1784 if(iter.gt.number) return
1786 if(iter.eq.1) goto 11
1788 if(iran.eq.iold(ind)) goto 10
1792 do ind=1,ngroup(iran)
1793 i=igroup(1,ind,iran)
1794 j=igroup(2,ind,iran)
1795 k=igroup(3,ind,iran)
1796 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
1797 if(dif.gt.180.) dif=360.-dif
1798 if(dif.gt.ctdif) goto 20
1800 if(iter.gt.number) goto 20
1803 do ind=1,ngroup(iran)
1804 i=igroup(1,ind,iran)
1805 j=igroup(2,ind,iran)
1806 k=igroup(3,ind,iran)
1807 vvar(i,j,k)=bvar(i,j,k,i1)
1814 ccccccccccccccccccccccccccccccccccccccccccccccccc
1815 ccccccccccccccccccccccccccccccccccccccccccccccccc
1816 subroutine newconf1arr(idum,vvar,nran,i1)
1817 implicit real*8 (a-h,o-z)
1818 include 'DIMENSIONS'
1819 include 'COMMON.IOUNITS'
1820 include 'COMMON.CSA'
1821 include 'COMMON.BANK'
1822 include 'COMMON.CHAIN'
1823 include 'COMMON.GEO'
1825 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1831 vvar(i,j,k)=rvar(i,j,k,iseed)
1844 10 iran= ran1(idum)*number+1
1845 if(iter.gt.number) return
1847 if(iter.eq.1) goto 11
1849 if(iran.eq.iold(ind)) goto 10
1853 do ind=1,ngroup(iran)
1854 i=igroup(1,ind,iran)
1855 j=igroup(2,ind,iran)
1856 k=igroup(3,ind,iran)
1857 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1858 if(dif.gt.180.) dif=360.-dif
1859 if(dif.gt.ctdif) goto 20
1861 if(iter.gt.number) goto 20
1864 do ind=1,ngroup(iran)
1865 i=igroup(1,ind,iran)
1866 j=igroup(2,ind,iran)
1867 k=igroup(3,ind,iran)
1868 vvar(i,j,k)=rvar(i,j,k,i1)
1875 ccccccccccccccccccccccccccccccccccccccccccccccccc
1876 ccccccccccccccccccccccccccccccccccccccccccccccccc
1877 subroutine newconf1abr(idum,vvar,nran,i1)
1878 implicit real*8 (a-h,o-z)
1879 include 'DIMENSIONS'
1880 include 'COMMON.IOUNITS'
1881 include 'COMMON.CSA'
1882 include 'COMMON.BANK'
1883 include 'COMMON.CHAIN'
1884 include 'COMMON.GEO'
1885 include 'COMMON.TORCNSTR'
1886 include 'COMMON.CONTROL'
1888 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1894 vvar(i,j,k)=bvar(i,j,k,iseed)
1907 10 iran= ran1(idum)*number+1
1908 if(i2ndstr.gt.0) then
1910 if(rtmp.le.rdih_bias) then
1911 iran=ran1(idum)*ndih_nconstr+1
1912 iran=idih_nconstr(iran)
1915 if(iter.gt.number) return
1917 if(iter.eq.1) goto 11
1919 if(iran.eq.iold(ind)) goto 10
1923 do ind=1,ngroup(iran)
1924 i=igroup(1,ind,iran)
1925 j=igroup(2,ind,iran)
1926 k=igroup(3,ind,iran)
1927 dif=rad2deg*dabs(vvar(i,j,k)-rvar(i,j,k,i1))
1928 if(dif.gt.180.) dif=360.-dif
1929 if(dif.gt.ctdif) goto 20
1931 if(iter.gt.number) goto 20
1934 do ind=1,ngroup(iran)
1935 i=igroup(1,ind,iran)
1936 j=igroup(2,ind,iran)
1937 k=igroup(3,ind,iran)
1938 vvar(i,j,k)=rvar(i,j,k,i1)
1945 ccccccccccccccccccccccccccccccccccccccccccccccccc
1946 ccccccccccccccccccccccccccccccccccccccccccccccccc
1947 subroutine newconf1abb(idum,vvar,nran,i1)
1948 implicit real*8 (a-h,o-z)
1949 include 'DIMENSIONS'
1950 include 'COMMON.IOUNITS'
1951 include 'COMMON.CSA'
1952 include 'COMMON.BANK'
1953 include 'COMMON.CHAIN'
1954 include 'COMMON.GEO'
1955 include 'COMMON.TORCNSTR'
1956 include 'COMMON.CONTROL'
1958 dimension vvar(mxang,maxres,mxch),iold(ntotal)
1964 vvar(i,j,k)=bvar(i,j,k,iseed)
1977 10 iran= ran1(idum)*number+1
1978 if(i2ndstr.gt.0) then
1980 if(rtmp.le.rdih_bias) then
1981 iran=ran1(idum)*ndih_nconstr+1
1982 iran=idih_nconstr(iran)
1985 if(iter.gt.number) return
1987 if(iter.eq.1) goto 11
1989 if(iran.eq.iold(ind)) goto 10
1993 do ind=1,ngroup(iran)
1994 i=igroup(1,ind,iran)
1995 j=igroup(2,ind,iran)
1996 k=igroup(3,ind,iran)
1997 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
1998 if(dif.gt.180.) dif=360.-dif
1999 if(dif.gt.ctdif) goto 20
2001 if(iter.gt.number) goto 20
2004 do ind=1,ngroup(iran)
2005 i=igroup(1,ind,iran)
2006 j=igroup(2,ind,iran)
2007 k=igroup(3,ind,iran)
2008 vvar(i,j,k)=bvar(i,j,k,i1)
2015 ccccccccccccccccccccccccccccccccccccccccccccccccc
2016 ccccccccccccccccccccccccccccccccccccccccccccccccc
2017 subroutine newconf_residue(idum,vvar,i1,isize)
2018 implicit real*8 (a-h,o-z)
2019 include 'DIMENSIONS'
2020 include 'COMMON.IOUNITS'
2021 include 'COMMON.CSA'
2022 include 'COMMON.BANK'
2023 include 'COMMON.CHAIN'
2024 include 'COMMON.GEO'
2025 include 'COMMON.TORCNSTR'
2026 include 'COMMON.CONTROL'
2028 dimension vvar(mxang,maxres,mxch),iold(ntotal)
2031 if (iseed.gt.mxio .or. iseed.lt.1) then
2032 write (iout,*) 'Dimension ERROR in NEWCONF: ISEED',iseed
2033 call mpi_abort(mpi_comm_world,ierror,ierrcode)
2038 vvar(i,j,k)=bvar(i,j,k,iseed)
2047 10 iran= ran1(idum)*number+1
2048 if(i2ndstr.gt.0) then
2050 if(rtmp.le.rdih_bias) then
2051 iran=ran1(idum)*ndih_nconstr+1
2052 iran=idih_nconstr(iran)
2057 if(istart.lt.2) istart=2
2058 if(iend.gt.nres-1) iend=nres-1
2060 if(iter.eq.1) goto 11
2062 if(iran.eq.iold(ind)) goto 10
2068 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
2069 if(dif.gt.180.) dif=360.-dif
2070 if(dif.gt.ctdif) goto 20
2075 if(iter.gt.number) goto 20
2081 vvar(i,j,k)=bvar(i,j,k,i1)
2088 ccccccccccccccccccccccccccccccccccccccccccccccccc
2089 ccccccccccccccccccccccccccccccccccccccccccccccccc
2090 subroutine newconf_copy(idum,vvar,i1,istart,iend)
2091 implicit real*8 (a-h,o-z)
2092 include 'DIMENSIONS'
2093 include 'COMMON.IOUNITS'
2094 include 'COMMON.CSA'
2095 include 'COMMON.BANK'
2096 include 'COMMON.CHAIN'
2097 include 'COMMON.GEO'
2098 include 'COMMON.TORCNSTR'
2099 include 'COMMON.CONTROL'
2101 dimension vvar(mxang,maxres,mxch),iold(ntotal)
2104 if (iseed.gt.mxio .or. iseed.lt.1) then
2105 write (iout,*) 'Dimension ERROR in NEWCONF: ISEED',iseed
2106 call mpi_abort(mpi_comm_world,ierror,ierrcode)
2111 vvar(i,j,k)=bvar(i,j,k,iseed)
2119 vvar(i,j,1)=bvar(i,j,1,i1)
2125 ccccccccccccccccccccccccccccccccccccccccccccccccc
2126 ccccccccccccccccccccccccccccccccccccccccccccccccc
2127 subroutine newconf_residue_hairpin(idum,vvar,i1,fail)
2128 implicit real*8 (a-h,o-z)
2129 include 'DIMENSIONS'
2130 include 'COMMON.IOUNITS'
2131 include 'COMMON.CSA'
2132 include 'COMMON.BANK'
2133 include 'COMMON.CHAIN'
2134 include 'COMMON.GEO'
2135 include 'COMMON.VAR'
2137 dimension vvar(mxang,maxres,mxch),iold(ntotal)
2138 integer nharp,iharp(4,maxres/3),icipa(maxres/3)
2139 logical fail,not_done
2143 if (iseed.gt.mxio .or. iseed.lt.1) then
2144 write (iout,*) 'Dimension ERROR in NEWCONF: ISEED',iseed
2145 call mpi_abort(mpi_comm_world,ierror,ierrcode)
2150 vvar(i,j,k)=bvar(i,j,k,iseed)
2156 theta(j+1)=bvar(1,j,k,i1)
2157 phi(j+2)=bvar(2,j,k,i1)
2158 alph(j)=bvar(3,j,k,i1)
2159 omeg(j)=bvar(4,j,k,i1)
2164 call hairpin(.false.,nharp,iharp)
2166 if (nharp.eq.0) then
2179 iih=iran_num(1,nharp)
2181 if (iih.eq.icipa(k)) then
2190 not_done = not_done .and. icount.le.nharp
2194 write (iout,*) "CHUJ NASTAPIL W NEWCONF_RESIDUE_HAIRPIN!!!!"
2199 istart=iharp(1,iih)+1
2202 cdd write (iout,*) "newconf_residue_hairpin: iih",iih,
2203 cdd & " istart",istart," iend",iend
2208 dif=rad2deg*dabs(vvar(i,j,k)-bvar(i,j,k,i1))
2209 if(dif.gt.180.) dif=360.-dif
2210 if(dif.gt.ctdif) goto 20
2219 vvar(i,j,k)=bvar(i,j,k,i1)
2225 c write (iout,'(4f8.3)') (rad2deg*vvar(i,l,j),i=1,4)
2236 ccccccccccccccccccccccccccccccccccccccccccccccccc
2237 ccccccccccccccccccccccccccccccccccccccccccccccccc
2238 subroutine gen_hairpin
2239 implicit real*8 (a-h,o-z)
2240 include 'DIMENSIONS'
2241 include 'COMMON.IOUNITS'
2242 include 'COMMON.CSA'
2243 include 'COMMON.BANK'
2244 include 'COMMON.CHAIN'
2245 include 'COMMON.GEO'
2246 include 'COMMON.VAR'
2247 include 'COMMON.HAIRPIN'
2249 c write (iout,*) 'Entering GEN_HAIRPIN'
2254 theta(j+1)=bvar(1,j,k,i1)
2255 phi(j+2)=bvar(2,j,k,i1)
2256 alph(j)=bvar(3,j,k,i1)
2257 omeg(j)=bvar(4,j,k,i1)
2261 call hairpin(.false.,nharp_seed(iters),iharp_seed(1,1,iters))
2266 nharp_tot=nharp_tot+nharp_seed(iters)
2267 nharp_use(iters)=4*nharp_seed(iters)
2268 do j=1,nharp_seed(iters)
2269 iharp_use(0,j,iters)=4
2271 iharp_use(k,j,iters)=0
2276 write (iout,*) 'GEN_HAIRPIN: nharp_tot',nharp_tot
2278 cdd write (iout,*) 'seed',i
2279 cdd write (iout,*) 'nharp_seed',nharp_seed(i),
2280 cdd & ' nharp_use',nharp_use(i)
2281 cd write (iout,*) 'iharp_seed, iharp_use'
2282 cd do j=1,nharp_seed(i)
2283 cd write (iout,'(7i3)') iharp_seed(1,j,i),iharp_seed(2,j,i),
2284 cd & (iharp_use(k,j,i),k=0,4)
2290 ccccccccccccccccccccccccccccccccccccccccccccccccc
2291 ccccccccccccccccccccccccccccccccccccccccccccccccc
2292 subroutine select_frag(nn,nh,nl,ns,nb,i_csa)
2293 implicit real*8 (a-h,o-z)
2294 include 'DIMENSIONS'
2295 include 'COMMON.IOUNITS'
2296 include 'COMMON.CSA'
2297 include 'COMMON.BANK'
2298 include 'COMMON.CHAIN'
2299 include 'COMMON.GEO'
2300 include 'COMMON.VAR'
2301 include 'COMMON.HAIRPIN'
2302 include 'COMMON.DISTFIT'
2304 integer isec(maxres)
2312 cd write (iout,*) 'Entering select_frag'
2319 theta(j+1)=bvar(1,j,k,i1)
2320 phi(j+2)=bvar(2,j,k,i1)
2321 alph(j)=bvar(3,j,k,i1)
2322 omeg(j)=bvar(4,j,k,i1)
2326 cd write (iout,*) ' -- ',i1,' -- '
2327 call secondary2(.false.)
2329 c bvar_frag nn==pair of nonlocal strands in beta sheet (loop>4)
2330 c strands > 4 residues; used by N7 and N16
2334 Ctest 09/12/02 bfrag(2,j)-bfrag(1,j).gt.3
2336 do i=bfrag(1,j),bfrag(2,j)
2339 do i=bfrag(4,j),bfrag(3,j),sign(1,bfrag(3,j)-bfrag(4,j))
2343 if ( (bfrag(3,j).lt.bfrag(4,j) .or.
2344 & bfrag(4,j)-bfrag(2,j).gt.4) .and.
2345 & bfrag(2,j)-bfrag(1,j).gt.4 ) then
2349 if (bfrag(3,j).lt.bfrag(4,j)) then
2350 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2351 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
2352 & ,",",bfrag(3,j)-1,"-",bfrag(4,j)-1
2354 write(linia,'(a6,i3,a1,i3,a1,i3,a1,i3)')
2355 & "select",bfrag(1,j)-1,"-",bfrag(2,j)-1
2356 & ,",",bfrag(4,j)-1,"-",bfrag(3,j)-1
2359 cd call write_pdb(i_csa*1000+nn+nh,linia,0d0)
2364 bvar_frag(nn,i+2)=bfrag(i,j)
2370 c hvar_frag nh==helices; used by N8 and N9
2374 do i=hfrag(1,j),hfrag(2,j)
2378 if ( hfrag(2,j)-hfrag(1,j).gt.4 ) then
2381 cd write(linia,'(a6,i3,a1,i3)')
2382 cd & "select",hfrag(1,j)-1,"-",hfrag(2,j)-1
2383 cd call write_pdb(i_csa*1000+nn+nh,linia,0d0)
2386 hvar_frag(nh,2)=hfrag(1,j)
2387 hvar_frag(nh,3)=hfrag(2,j)
2392 cv write(iout,'(i4,1pe12.4,1x,1000i1)')
2393 cv & i1,bene(i1),(isec(i),i=1,nres)
2394 cv write(linia,'(i4,1x,1000i1)')
2395 cv & i1,(isec(i),i=1,nres)
2396 cv call write_pdb(i_csa*1000+i1,linia,bene(i1))
2398 c lvar_frag nl==loops; used by N14
2402 do while (i.lt.nres)
2403 if (isec(i).eq.0) then
2408 do while (isec(i).eq.0.and.i.le.nres)
2412 if (lvar_frag(nl,3)-lvar_frag(nl,2).lt.1) nl=nl-1
2416 cd write(iout,'(4i5)') (i,(lvar_frag(i,ii),ii=1,3),i=nl1+1,nl)
2419 c svar_frag ns==an secondary structure element; used by N15
2423 do while (i.lt.nres)
2424 if (isec(i).gt.0) then
2429 do while (isec(i).gt.0.and.isec(i-1).eq.isec(i)
2434 if (svar_frag(ns,3)-svar_frag(ns,2).lt.1) ns=ns-1
2436 if (isec(i).eq.0) i=i+1
2438 cd write(iout,'(4i5)') (i,(svar_frag(i,ii),ii=1,3),i=ns1+1,ns)
2441 c avar_frag nb==any pair of beta strands; used by N17
2447 avar_frag(nb,i+1)=bfrag(i,j)