1 subroutine read_general_data(*)
4 include "DIMENSIONS.ZSCOPT"
5 include "DIMENSIONS.FREE"
6 include "COMMON.TORSION"
7 include "COMMON.INTERACT"
8 include "COMMON.IOUNITS"
11 include "COMMON.PROTFILES"
12 include "COMMON.CHAIN"
13 include "COMMON.NAMES"
14 include "COMMON.FFIELD"
15 include "COMMON.ENEPS"
16 include "COMMON.WEIGHTS"
18 include "COMMON.CONTROL"
19 include "COMMON.ENERGIES"
20 include "COMMON.SPLITELE"
21 include "COMMON.SBRIDGE"
22 include "COMMON.SHIELD"
23 character*800 controlcard
24 integer i,j,k,ii,n_ene_found
25 integer ind,itype1,itype2,itypf,itypsc,itypp
32 call card_concat(controlcard,.true.)
33 call readi(controlcard,"N_ENE",n_ene,max_ene)
34 if (n_ene.gt.max_ene) then
35 write (iout,*) "Error: parameter out of range: N_ENE",n_ene,
39 call readi(controlcard,"NPARMSET",nparmset,1)
40 separate_parset = index(controlcard,"SEPARATE_PARSET").gt.0
41 call readi(controlcard,"IPARMPRINT",iparmprint,1)
42 write (iout,*) "PARMPRINT",iparmprint
43 if (nparmset.gt.max_parm) then
44 write (iout,*) "Error: parameter out of range: NPARMSET",
48 call readi(controlcard,"MAXIT",maxit,5000)
49 call reada(controlcard,"FIMIN",fimin,1.0d-3)
50 call readi(controlcard,"ENSEMBLES",ensembles,0)
51 hamil_rep=index(controlcard,"HAMIL_REP").gt.0
52 write (iout,*) "Number of energy parameter sets",nparmset
53 call multreadi(controlcard,"ISAMPL",isampl,nparmset,1)
55 if (isampl(i).eq.0) then
56 write (iout,*) "ERROR: isampl is 0 for parmset",i
61 write (iout,*) "MaxSlice",MaxSlice
62 call readi(controlcard,"NSLICE",nslice,1)
64 if (nslice.gt.MaxSlice) then
65 write (iout,*) "Error: parameter out of range: NSLICE",nslice,
69 write (iout,*) "Frequency of storing conformations",
70 & (isampl(i),i=1,nparmset)
71 write (iout,*) "Maxit",maxit," Fimin",fimin
72 call readi(controlcard,"NQ",nQ,1)
74 write (iout,*) "Error: parameter out of range: NQ",nq,
79 energy_dec=(index(controlcard,'ENERGY_DEC').gt.0)
80 if (index(controlcard,"CLASSIFY").gt.0) indpdb=1
81 call reada(controlcard,"DELTA",delta,1.0d-2)
82 call readi(controlcard,"EINICHECK",einicheck,2)
83 call reada(controlcard,"DELTRMS",deltrms,5.0d-2)
84 call reada(controlcard,"DELTRGY",deltrgy,5.0d-2)
85 call readi(controlcard,"RESCALE",rescale_mode,1)
86 check_conf=index(controlcard,"NO_CHECK_CONF").eq.0
87 call readi(controlcard,'TORMODE',tor_mode,0)
88 write(iout,*) "torsional and valence angle mode",tor_mode
89 call reada(controlcard,'DISTCHAINMAX',distchainmax,50.0d0)
90 call reada(controlcard,'BOXX',boxxsize,100.0d0)
91 call reada(controlcard,'BOXY',boxysize,100.0d0)
92 call reada(controlcard,'BOXZ',boxzsize,100.0d0)
93 c Cutoff range for interactions
94 call reada(controlcard,"R_CUT",r_cut,15.0d0)
95 call reada(controlcard,"LAMBDA",rlamb,0.3d0)
96 call reada(controlcard,"LIPTHICK",lipthick,0.0d0)
97 call reada(controlcard,"LIPAQBUF",lipbufthick,0.0d0)
98 if (lipthick.gt.0.0d0) then
99 bordliptop=(boxzsize+lipthick)/2.0
100 bordlipbot=bordliptop-lipthick
102 if ((bordliptop.gt.boxzsize).or.(bordlipbot.lt.0.0))
103 & write(iout,*) "WARNING WRONG SIZE OF LIPIDIC PHASE"
104 buflipbot=bordlipbot+lipbufthick
105 bufliptop=bordliptop-lipbufthick
106 if ((lipbufthick*2.0d0).gt.lipthick)
107 &write(iout,*) "WARNING WRONG SIZE OF LIP AQ BUF"
109 write(iout,*) "bordliptop=",bordliptop
110 write(iout,*) "bordlipbot=",bordlipbot
111 write(iout,*) "bufliptop=",bufliptop
112 write(iout,*) "buflipbot=",buflipbot
113 call readi(controlcard,'SYM',symetr,1)
114 write (iout,*) "DISTCHAINMAX",distchainmax
115 write (iout,*) "delta",delta
116 write (iout,*) "einicheck",einicheck
117 write (iout,*) "rescale_mode",rescale_mode
119 bxfile=index(controlcard,"BXFILE").gt.0
120 cxfile=index(controlcard,"CXFILE").gt.0
121 if (nslice .eq. 1 .and. .not.bxfile .and. .not.cxfile)
123 histfile=index(controlcard,"HISTFILE").gt.0
124 histout=index(controlcard,"HISTOUT").gt.0
125 entfile=index(controlcard,"ENTFILE").gt.0
126 zscfile=index(controlcard,"ZSCFILE").gt.0
127 with_dihed_constr = index(controlcard,"WITH_DIHED_CONSTR").gt.0
128 write (iout,*) "with_dihed_constr ",with_dihed_constr
129 with_theta_constr = index(controlcard,"WITH_THETA_CONSTR").gt.0
130 write (iout,*) "with_theta_constr ",with_theta_constr
131 call readi(controlcard,'SHIELD',shield_mode,0)
132 write(iout,*) "shield_mode",shield_mode
134 call readi(controlcard,'TORMODE',tor_mode,0)
135 write(iout,*) "torsional and valence angle mode",tor_mode
136 if (shield_mode.gt.0) then
138 C VSolvSphere the volume of solving sphere
140 C rpp(1,1) is the energy r0 for peptide group contact and will be used for it
141 C there will be no distinction between proline peptide group and normal peptide
142 C group in case of shielding parameters
143 VSolvSphere=4.0/3.0*pi*rpp(1,1)**3
144 VSolvSphere_div=VSolvSphere-4.0/3.0*pi*(rpp(1,1)/2.0)**3
145 write (iout,*) VSolvSphere,VSolvSphere_div
146 C long axis of side chain
148 C long_r_sidechain(i)=vbldsc0(1,i)
149 C short_r_sidechain(i)=sigma0(i)
154 call readi(controlcard,'CONSTR_DIST',constr_dist,0)
155 dyn_ss=index(controlcard,"DYN_SS").gt.0
156 adaptive = index(controlcard,"ADAPTIVE").gt.0
157 call readi(controlcard,'NSAXS',nsaxs,0)
158 call readi(controlcard,'SAXS_MODE',saxs_mode,0)
159 call reada(controlcard,'SCAL_RAD',scal_rad,1.0d0)
160 call reada(controlcard,'SAXS_CUTOFF',saxs_cutoff,1.0d0)
161 write (iout,*) "Number of SAXS restraints",NSAXS," SAXS_MODE",
162 & SAXS_MODE," SCAL_RAD",scal_rad,"SAXS_CUTOFF",saxs_cutoff
165 c------------------------------------------------------------------------------
166 subroutine read_efree(*)
168 C Read molecular data
172 include 'DIMENSIONS.ZSCOPT'
173 include 'DIMENSIONS.COMPAR'
174 include 'DIMENSIONS.FREE'
175 include 'COMMON.IOUNITS'
176 include 'COMMON.TIME1'
177 include 'COMMON.SBRIDGE'
178 include 'COMMON.CONTROL'
179 include 'COMMON.CHAIN'
180 include 'COMMON.HEADER'
182 include 'COMMON.FREE'
183 character*320 controlcard,ucase
184 integer iparm,ib,i,j,npars
196 call card_concat(controlcard,.true.)
197 call readi(controlcard,'NT',nT_h(iparm),1)
198 write (iout,*) "iparm",iparm," nt",nT_h(iparm)
200 if (nT_h(iparm).gt.MaxT_h) then
201 write (iout,*) "Error: parameter out of range: NT",nT_h(iparm),
205 replica(iparm)=index(controlcard,"REPLICA").gt.0
206 umbrella(iparm)=index(controlcard,"UMBRELLA").gt.0
207 read_iset(iparm)=index(controlcard,"READ_ISET").gt.0
208 write (iout,*) "nQ",nQ," nT",nT_h(iparm)," replica ",
209 & replica(iparm)," umbrella ",umbrella(iparm),
210 & " read_iset",read_iset(iparm)
213 call card_concat(controlcard,.true.)
214 call readi(controlcard,'NR',nR(ib,iparm),1)
215 if (umbrella(iparm)) then
218 nRR(ib,iparm)=nR(ib,iparm)
220 if (nR(ib,iparm).gt.MaxR) then
221 write (iout,*) "Error: parameter out of range: NR",
225 call reada(controlcard,'TEMP',beta_h(ib,iparm),298.0d0)
226 beta_h(ib,iparm)=1.0d0/(beta_h(ib,iparm)*1.987D-3)
227 call multreada(controlcard,'FI',f(1,ib,iparm),nR(ib,iparm),
230 call card_concat(controlcard,.true.)
231 call multreada(controlcard,'KH',KH(1,i,ib,iparm),nQ,
233 call multreada(controlcard,'Q0',Q0(1,i,ib,iparm),nQ,
238 write (iout,*) "ib",ib," beta_h",
239 & 1.0d0/(0.001987*beta_h(ib,iparm))
240 write (iout,*) "nR",nR(ib,iparm)
241 write (iout,*) "fi",(f(i,ib,iparm),i=1,nR(ib,iparm))
243 write (iout,*) "i",i," Kh",(Kh(j,i,ib,iparm),j=1,nQ),
244 & "q0",(q0(j,i,ib,iparm),j=1,nQ)
256 nR(ib,iparm)=nR(ib,1)
257 if (umbrella(iparm)) then
260 nRR(ib,iparm)=nR(ib,1)
262 beta_h(ib,iparm)=beta_h(ib,1)
264 f(i,ib,iparm)=f(i,ib,1)
266 KH(j,i,ib,iparm)=KH(j,i,ib,1)
267 Q0(j,i,ib,iparm)=Q0(j,i,ib,1)
270 replica(iparm)=replica(1)
271 umbrella(iparm)=umbrella(1)
272 read_iset(iparm)=read_iset(1)
280 c-----------------------------------------------------------------------------
281 subroutine read_protein_data(*)
284 include "DIMENSIONS.ZSCOPT"
285 include "DIMENSIONS.FREE"
288 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
291 include "COMMON.CHAIN"
292 include "COMMON.IOUNITS"
293 include "COMMON.PROT"
294 include "COMMON.PROTFILES"
295 include "COMMON.NAMES"
296 include "COMMON.FREE"
297 include "COMMON.OBCINKA"
299 character*16000 controlcard
300 integer i,ii,ib,iR,iparm,ilen,iroof,nthr,npars
310 C Read names of files with conformation data.
311 if (replica(iparm)) then
317 do ii=1,nRR(ib,iparm)
318 write (iout,*) "Parameter set",iparm," temperature",ib,
321 call card_concat(controlcard,.true.)
322 write (iout,*) controlcard(:ilen(controlcard))
323 call readi(controlcard,"NFILE_BIN",nfile_bin(ii,ib,iparm),0)
324 call readi(controlcard,"NFILE_ASC",nfile_asc(ii,ib,iparm),0)
325 call readi(controlcard,"NFILE_CX",nfile_cx(ii,ib,iparm),0)
326 call readi(controlcard,"REC_START",rec_start(ii,ib,iparm),1)
327 call readi(controlcard,"REC_END",rec_end(ii,ib,iparm),
328 & maxstr*isampl(iparm)+rec_start(ii,ib,iparm)-1)
329 call reada(controlcard,"TIME_START",
330 & time_start_collect(ii,ib,iparm),0.0d0)
331 call reada(controlcard,"TIME_END",time_end_collect(ii,ib,iparm),
333 write (iout,*) "rec_start",rec_start(ii,ib,iparm),
334 & " rec_end",rec_end(ii,ib,iparm)
335 write (iout,*) "time_start",time_start_collect(ii,ib,iparm),
336 & " time_end",time_end_collect(ii,ib,iparm)
338 if (replica(iparm)) then
339 call readi(controlcard,"TOTRAJ",totraj(ii,iparm),1)
340 write (iout,*) "Number of trajectories",totraj(ii,iparm)
343 if (nfile_bin(ii,ib,iparm).lt.2
344 & .and. nfile_asc(ii,ib,iparm).eq.0
345 & .and. nfile_cx(ii,ib,iparm).eq.0) then
346 write (iout,*) "Error - no action specified!"
349 if (nfile_bin(ii,ib,iparm).gt.0) then
350 call card_concat(controlcard,.false.)
351 call split_string(controlcard,protfiles(1,1,ii,ib,iparm),
352 & maxfile_prot,nfile_bin(ii,ib,iparm))
354 write(iout,*)"nfile_bin",nfile_bin(ii,ib,iparm)
355 write(iout,*) (protfiles(i,1,ii,ib,iparm),
356 & i=1,nfile_bin(ii,ib,iparm))
359 if (nfile_asc(ii,ib,iparm).gt.0) then
360 call card_concat(controlcard,.false.)
361 call split_string(controlcard,protfiles(1,2,ii,ib,iparm),
362 & maxfile_prot,nfile_asc(ii,ib,iparm))
364 write(iout,*) "nfile_asc(ii,ib,iparm)",nfile_asc(ii,ib,iparm)
365 write(iout,*) (protfiles(i,2,ii,ib,iparm),
366 & i=1,nfile_asc(ii,ib,iparm))
368 else if (nfile_cx(ii,ib,iparm).gt.0) then
369 call card_concat(controlcard,.false.)
370 call split_string(controlcard,protfiles(1,2,ii,ib,iparm),
371 & maxfile_prot,nfile_cx(ii,ib,iparm))
373 write(iout,*) "nfile_cx(ii,ib,iparm)",nfile_cx(ii,ib,iparm)
374 write(iout,*) (protfiles(i,2,ii,ib,iparm),
375 & i=1,nfile_cx(ii,ib,iparm))
386 c-------------------------------------------------------------------------------
387 subroutine opentmp(islice,iunit,bprotfile_temp)
390 include "DIMENSIONS.ZSCOPT"
391 include "DIMENSIONS.FREE"
394 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
397 include "COMMON.IOUNITS"
398 include "COMMON.PROTFILES"
399 include "COMMON.PROT"
400 include "COMMON.FREE"
401 character*64 bprotfile_temp
402 character*3 liczba,liczba2
409 write (liczba1,'(bz,i2.2)') islice
410 write (liczba,'(bz,i3.3)') me
412 c write (iout,*) "separate_parset ",separate_parset,
414 if (separate_parset) then
415 write (liczba2,'(bz,i3.3)') myparm
416 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
417 & prefix(:ilen(prefix))//liczba//"_"//liczba2//".xbin.tmp"//liczba1
418 open (iunit,file=bprotfile_temp,status="unknown",
419 & form="unformatted",access="direct",recl=lenrec)
421 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
422 & prefix(:ilen(prefix))//liczba//".xbin.tmp"//liczba1
423 open (iunit,file=bprotfile_temp,status="unknown",
424 & form="unformatted",access="direct",recl=lenrec)
427 bprotfile_temp = scratchdir(:ilen(scratchdir))//
428 & "/"//prefix(:ilen(prefix))//".xbin.tmp"//liczba1
429 open (iunit,file=bprotfile_temp,status="unknown",
430 & form="unformatted",access="direct",recl=lenrec)
432 c write (iout,*) "OpenTmp iunit",iunit," bprotfile_temp",
437 c-------------------------------------------------------------------------------
438 subroutine read_database(*)
441 include "DIMENSIONS.ZSCOPT"
442 include "DIMENSIONS.FREE"
445 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
448 include "COMMON.CHAIN"
449 include "COMMON.IOUNITS"
450 include "COMMON.PROTFILES"
451 include "COMMON.NAMES"
454 include "COMMON.ENEPS"
455 include "COMMON.PROT"
456 include "COMMON.INTERACT"
457 include "COMMON.FREE"
458 include "COMMON.SBRIDGE"
459 include "COMMON.OBCINKA"
460 real*4 csingle(3,maxres2)
461 character*64 nazwa,bprotfile_temp
464 integer i,j,ii,jj(maxslice),k,kk(maxslice),l,
465 & ll(maxslice),mm(maxslice),if
466 integer nrec,nlines,iscor,iunit,islice
467 double precision energ
470 double precision rmsdev,energia(0:max_ene),efree,eini,temp
471 double precision prop(maxQ)
472 integer ntot_all(maxslice,0:maxprocs-1), maxslice_buff
473 integer iparm,ib,iib,ir,nprop,nthr,npars
474 double precision etot,time
478 lenrec1=12*(nres+nct-nnt+1)+4*(2*nss+2)+24
479 lenrec2=12*(nres+nct-nnt+1)+4*(2*nss+2)+24+8*nQ
481 write (iout,*) "lenrec",lenrec," lenrec1",lenrec1,
491 write (iout,*) "nparmset",nparmset
499 if (replica(iparm)) then
506 do iR=1,nRR(ib,iparm)
508 write (iout,*) "iparm",iparm," ib",ib," iR",iR," nQ",nQ
514 IF (NFILE_BIN(iR,ib,iparm).GT.0) THEN
515 c Read conformations from binary DA files (one per batch) and write them to
516 c a binary DA scratchfile.
517 write (liczba,'(bz,i3.3)') me
518 do if=1,nfile_bin(iR,ib,iparm)
519 nazwa=protfiles(if,1,iR,ib,iparm)
520 & (:ilen(protfiles(if,1,iR,ib,iparm)))//".bx"
521 open (ientin,file=nazwa,status="old",form="unformatted",
522 & access="direct",recl=lenrec2,err=1111)
525 call opentmp(islice,ientout,bprotfile_temp)
526 call bxread(nazwa,ii,jj(islice),kk(islice),ll(islice),
527 & mm(islice),iR,ib,iparm)
534 IF (NFILE_ASC(iR,ib,iparm).GT.0) THEN
535 c Read conformations from multiple ASCII int files and write them to a binary
537 do if=1,nfile_asc(iR,ib,iparm)
538 nazwa=protfiles(if,2,iR,ib,iparm)
539 & (:ilen(protfiles(if,2,iR,ib,iparm)))//".x"
540 open(unit=ientin,file=nazwa,status='old',err=1111)
541 write(iout,*) "reading ",nazwa(:ilen(nazwa))
543 call xread(nazwa,ii,jj,kk,ll,mm,iR,ib,iparm)
546 IF (NFILE_CX(iR,ib,iparm).gt.0) THEN
547 c Read conformations from cx files and write them to a binary
549 do if=1,nfile_cx(iR,ib,iparm)
550 nazwa=protfiles(if,2,iR,ib,iparm)
551 & (:ilen(protfiles(if,2,iR,ib,iparm)))//".cx"
552 write(iout,*) "reading ",nazwa(:ilen(nazwa))
554 print *,"Calling cxread"
555 call cxread(nazwa,ii,jj,kk,ll,mm,iR,ib,iparm,
558 write (iout,*) "exit cxread"
564 stot(islice)=stot(islice)+jj(islice)
569 write (iout,*) "IPARM",iparm
572 if (nslice.eq.1) then
574 write (liczba,'(bz,i3.3)') me
575 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
576 & prefix(:ilen(prefix))//liczba//".xbin.tmp"
578 bprotfile_temp = scratchdir(:ilen(scratchdir))//
579 & "/"//prefix(:ilen(prefix))//".xbin.tmp"
581 write(iout,*) mm(1)," conformations read",ll(1),
582 & " conformations written to ",
583 & bprotfile_temp(:ilen(bprotfile_temp))
586 write (liczba1,'(bz,i2.2)') islice
588 write (liczba,'(bz,i3.3)') me
589 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
590 & prefix(:ilen(prefix))//liczba//".xbin.tmp"//liczba1
592 bprotfile_temp = scratchdir(:ilen(scratchdir))//
593 & "/"//prefix(:ilen(prefix))//".xbin.tmp"//liczba1
595 write(iout,*) mm(islice)," conformations read",ll(islice),
596 & " conformations written to ",
597 & bprotfile_temp(:ilen(bprotfile_temp))
602 c Check if everyone has the same number of conformations
604 c call MPI_ALLgather(MPI_IN_PLACE,stot(1),MPI_DATATYPE_NULL,
605 c & ntot_all(1,0),maxslice,MPI_INTEGER,MPI_Comm_World,IERROR)
607 maxslice_buff=maxslice
609 call MPI_Allgather(stot(1),maxslice_buff,MPI_INTEGER,
610 & ntot_all(1,0),maxslice,MPI_INTEGER,MPI_Comm_World,IERROR)
615 if (stot(islice).ne.ntot_all(islice,i)) then
616 write (iout,*) "Number of conformations at processor",i,
617 & " differs from that at processor",me,
618 & stot(islice),ntot_all(islice,i)," slice",islice
626 write (iout,*) "Numbers of conformations read by processors"
629 write (iout,'(8i10)') i,(ntot_all(islice,i),islice=1,nslice)
631 write (iout,*) "Calculation terminated."
636 ntot(islice)=stot(islice)
640 1111 write(iout,*) "Error opening coordinate file ",nazwa(:ilen(nazwa))
644 c------------------------------------------------------------------------------
645 subroutine card_concat(card,to_upper)
647 include 'DIMENSIONS.ZSCOPT'
648 include "COMMON.IOUNITS"
650 character*80 karta,ucase
654 read (inp,'(a)') karta
655 if (to_upper) karta=ucase(karta)
657 do while (karta(80:80).eq.'&')
658 card=card(:ilen(card)+1)//karta(:79)
659 read (inp,'(a)') karta
660 if (to_upper) karta=ucase(karta)
662 card=card(:ilen(card)+1)//karta
665 c------------------------------------------------------------------------------
666 subroutine readi(rekord,lancuch,wartosc,default)
668 character*(*) rekord,lancuch
669 integer wartosc,default
672 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
677 iread=iread+ilen(lancuch)+1
678 read (rekord(iread:),*) wartosc
681 c----------------------------------------------------------------------------
682 subroutine reada(rekord,lancuch,wartosc,default)
684 character*(*) rekord,lancuch
686 double precision wartosc,default
689 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
694 iread=iread+ilen(lancuch)+1
695 read (rekord(iread:),*) wartosc
698 c----------------------------------------------------------------------------
699 subroutine multreadi(rekord,lancuch,tablica,dim,default)
702 integer tablica(dim),default
703 character*(*) rekord,lancuch
710 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
711 if (iread.eq.0) return
712 iread=iread+ilen(lancuch)+1
713 read (rekord(iread:),*,end=10,err=10) (tablica(i),i=1,dim)
716 c----------------------------------------------------------------------------
717 subroutine multreada(rekord,lancuch,tablica,dim,default)
720 double precision tablica(dim),default
721 character*(*) rekord,lancuch
728 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
729 if (iread.eq.0) return
730 iread=iread+ilen(lancuch)+1
731 read (rekord(iread:),*,end=10,err=10) (tablica(i),i=1,dim)
734 c----------------------------------------------------------------------------
735 subroutine reads(rekord,lancuch,wartosc,default)
737 character*(*) rekord,lancuch,wartosc,default
739 integer ilen,lenlan,lenrec,iread,ireade
745 iread=index(rekord,lancuch(:lenlan)//"=")
746 c print *,"rekord",rekord," lancuch",lancuch
747 c print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
753 c print *,"iread",iread
754 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
755 do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
757 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
759 c print *,"iread",iread
760 if (iread.gt.lenrec) then
765 c print *,"ireade",ireade
766 do while (ireade.lt.lenrec .and.
767 & .not.iblnk(rekord(ireade:ireade)))
770 wartosc=rekord(iread:ireade)
773 c----------------------------------------------------------------------------
774 subroutine multreads(rekord,lancuch,tablica,dim,default)
777 character*(*) rekord,lancuch,tablica(dim),default
779 integer ilen,lenlan,lenrec,iread,ireade
788 iread=index(rekord,lancuch(:lenlan)//"=")
789 c print *,"rekord",rekord," lancuch",lancuch
790 c print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
791 if (iread.eq.0) return
794 c print *,"iread",iread
795 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
796 do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
798 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
800 c print *,"iread",iread
801 if (iread.gt.lenrec) return
803 c print *,"ireade",ireade
804 do while (ireade.lt.lenrec .and.
805 & .not.iblnk(rekord(ireade:ireade)))
808 tablica(i)=rekord(iread:ireade)
812 c----------------------------------------------------------------------------
813 subroutine split_string(rekord,tablica,dim,nsub)
815 integer dim,nsub,i,ii,ll,kk
816 character*(*) tablica(dim)
827 C Find the start of term name
829 do while (ii.le.ll .and. rekord(ii:ii).eq." ")
832 C Parse the name into TABLICA(i) until blank found
833 do while (ii.le.ll .and. rekord(ii:ii).ne." ")
835 tablica(i)(kk:kk)=rekord(ii:ii)
838 if (kk.gt.0) nsub=nsub+1
843 c--------------------------------------------------------------------------------
844 integer function iroof(n,m)
846 if (ii*m .lt. n) ii=ii+1
850 c-------------------------------------------------------------------------------
851 subroutine read_dist_constr
852 implicit real*8 (a-h,o-z)
854 include 'COMMON.CONTROL'
855 include 'COMMON.CHAIN'
856 include 'COMMON.IOUNITS'
857 include 'COMMON.SBRIDGE'
858 include 'COMMON.INTERACT'
859 integer ifrag_(2,100),ipair_(2,100)
860 double precision wfrag_(100),wpair_(100)
861 character*500 controlcard
862 logical normalize,next
864 double precision xlink(4,0:4) /
866 & 0.0d0,0.0d0,0.0d0,0.0d0, ! default, no xlink potential
867 & 0.00305218d0,9.46638d0,4.68901d0,4.74347d0, ! ZL
868 & 0.00214928d0,12.7517d0,0.00375009d0,6.13477d0, ! ADH
869 & 0.00184547d0,11.2678d0,0.00140292d0,7.00868d0, ! PDH
870 & 0.000161786d0,6.29273d0,4.40993d0,7.13956d0 / ! DSS
871 write (iout,*) "Calling read_dist_constr"
872 c write (iout,*) "nres",nres," nstart_sup",nstart_sup," nsup",nsup
874 restr_on_coord=.false.
879 call card_concat(controlcard,.true.)
880 next = index(controlcard,"NEXT").gt.0
881 call readi(controlcard,"RESTR_TYPE",restr_type,constr_dist)
882 write (iout,*) "restr_type",restr_type
883 call readi(controlcard,"NFRAG",nfrag_,0)
884 call readi(controlcard,"NFRAG",nfrag_,0)
885 call readi(controlcard,"NPAIR",npair_,0)
886 call readi(controlcard,"NDIST",ndist_,0)
887 call reada(controlcard,'DIST_CUT',dist_cut,5.0d0)
888 call reada(controlcard,'SCAL_BFAC',scal_bfac,1.0d0)
889 if (restr_type.eq.10)
890 & call reada(controlcard,'WBOLTZD',wboltzd,0.591d0)
891 if (restr_type.eq.12)
892 & call reada(controlcard,'SCAL_PEAK',scal_peak,5.0d0)
893 call multreadi(controlcard,"IFRAG",ifrag_(1,1),2*nfrag_,0)
894 call multreadi(controlcard,"IPAIR",ipair_(1,1),2*npair_,0)
895 call multreada(controlcard,"WFRAG",wfrag_(1),nfrag_,0.0d0)
896 call multreada(controlcard,"WPAIR",wpair_(1),npair_,0.0d0)
897 normalize = index(controlcard,"NORMALIZE").gt.0
898 write (iout,*) "WBOLTZD",wboltzd
899 write (iout,*) "SCAL_PEAK",scal_peak
900 write (iout,*) "NFRAG",nfrag_," NPAIR",npair_," NDIST",ndist_
901 write (iout,*) "IFRAG"
903 write (iout,*) i,ifrag_(1,i),ifrag_(2,i),wfrag_(i)
905 write (iout,*) "IPAIR"
907 write (iout,*) i,ipair_(1,i),ipair_(2,i),wpair_(i)
909 if (nfrag_.gt.0 .or. restr_type.eq.4 .or. restr_type.eq.5) then
911 read(inp,'(a)') pdbfile
913 & "Distance restraints will be constructed from structure ",pdbfile
914 open(ipdbin,file=pdbfile,status='old',err=11)
920 if (ifrag_(1,i).lt.nstart_sup) ifrag_(1,i)=nstart_sup
921 if (ifrag_(2,i).gt.nstart_sup+nsup-1)
922 & ifrag_(2,i)=nstart_sup+nsup-1
923 c write (iout,*) i,ifrag_(1,i),ifrag_(2,i),wfrag_(i)
925 if (wfrag_(i).eq.0.0d0) cycle
926 do j=ifrag_(1,i),ifrag_(2,i)-1
928 c write (iout,*) "j",j," k",k
930 if (restr_type.eq.1) then
936 forcon(nhpb)=wfrag_(i)
937 else if (constr_dist.eq.2) then
938 if (ddjk.le.dist_cut) then
944 forcon(nhpb)=wfrag_(i)
946 else if (restr_type.eq.3) then
952 forcon(nhpb)=wfrag_(i)*dexp(-0.5d0*(ddjk/dist_cut)**2)
954 write (iout,'(a,3i5,f8.2,1pe12.2)') "+dist.restr ",
955 & nhpb,ihpb(nhpb),jhpb(nhpb),dhpb(nhpb),forcon(nhpb)
960 if (wpair_(i).eq.0.0d0) cycle
968 do j=ifrag_(1,ii),ifrag_(2,ii)
969 do k=ifrag_(1,jj),ifrag_(2,jj)
971 if (restr_type.eq.1) then
977 forcon(nhpb)=wpair_(i)
978 else if (constr_dist.eq.2) then
979 if (ddjk.le.dist_cut) then
985 forcon(nhpb)=wpair_(i)
987 else if (restr_type.eq.3) then
993 forcon(nhpb)=wpair_(i)*dexp(-0.5d0*(ddjk/dist_cut)**2)
995 write (iout,'(a,3i5,f8.2,f10.1)') "+dist.restr ",
996 & nhpb,ihpb(nhpb),jhpb(nhpb),dhpb(nhpb),forcon(nhpb)
1002 write (iout,*) "Distance restraints as read from input"
1004 if (restr_type.eq.12) then
1005 read (inp,*) ihpb_peak(nhpb_peak+1),jhpb_peak(nhpb_peak+1),
1006 & dhpb_peak(nhpb_peak+1),dhpb1_peak(nhpb_peak+1),
1007 & ibecarb_peak(nhpb_peak+1),forcon_peak(nhpb_peak+1),
1008 & fordepth_peak(nhpb_peak+1),npeak
1009 c write(iout,*) ihpb_peak(nhpb_peak+1),jhpb_peak(nhpb_peak+1),
1010 c & dhpb_peak(nhpb_peak+1),dhpb1_peak(nhpb_peak+1),
1011 c & ibecarb_peak(nhpb_peak+1),forcon_peak(nhpb_peak+1),
1012 c & fordepth_peak(nhpb_peak+1),npeak
1013 if (forcon_peak(nhpb_peak+1).le.0.0d0.or.
1014 & fordepth_peak(nhpb_peak+1).le.0.0d0)cycle
1015 nhpb_peak=nhpb_peak+1
1016 irestr_type_peak(nhpb_peak)=12
1017 if (ipeak(1,npeak).eq.0) ipeak(1,npeak)=i
1019 write (iout,'(a,5i5,2f8.2,2f10.5,i5)') "+dist.restr ",
1020 & nhpb_peak,ihpb_peak(nhpb_peak),jhpb_peak(nhpb_peak),
1021 & ibecarb_peak(nhpb_peak),npeak,dhpb_peak(nhpb_peak),
1022 & dhpb1_peak(nhpb_peak),forcon_peak(nhpb_peak),
1023 & fordepth_peak(nhpb_peak),irestr_type_peak(nhpb_peak)
1024 if (ibecarb_peak(nhpb_peak).eq.3) then
1025 jhpb_peak(nhpb_peak)=jhpb_peak(nhpb_peak)+nres
1026 else if (ibecarb_peak(nhpb_peak).eq.2) then
1027 ihpb_peak(nhpb_peak)=ihpb_peak(nhpb_peak)+nres
1028 else if (ibecarb_peak(nhpb_peak).eq.1) then
1029 ihpb_peak(nhpb_peak)=ihpb_peak(nhpb_peak)+nres
1030 jhpb_peak(nhpb_peak)=jhpb_peak(nhpb_peak)+nres
1032 else if (restr_type.eq.11) then
1033 read (inp,*) ihpb(nhpb+1),jhpb(nhpb+1),dhpb(nhpb+1),
1034 & dhpb1(nhpb+1),ibecarb(i),forcon(nhpb+1),fordepth(nhpb+1)
1035 c fordepth(nhpb+1)=fordepth(nhpb+1)/forcon(nhpb+1)
1036 if (forcon(nhpb+1).le.0.0d0.or.fordepth(nhpb+1).le.0.0d0)cycle
1038 irestr_type(nhpb)=11
1039 write (iout,'(a,4i5,2f8.2,2f10.5,i5)') "+dist.restr ",
1040 & nhpb,ihpb(nhpb),jhpb(nhpb),ibecarb(nhpb),dhpb(nhpb),
1041 & dhpb1(nhpb),forcon(nhpb),fordepth(nhpb),irestr_type(nhpb)
1042 c if (ibecarb(nhpb).gt.0) then
1043 c ihpb(nhpb)=ihpb(nhpb)+nres
1044 c jhpb(nhpb)=jhpb(nhpb)+nres
1046 if (ibecarb(nhpb).eq.3) then
1047 ihpb(nhpb)=ihpb(nhpb)+nres
1048 else if (ibecarb(nhpb).eq.2) then
1049 ihpb(nhpb)=ihpb(nhpb)+nres
1050 else if (ibecarb(nhpb).eq.1) then
1051 ihpb(nhpb)=ihpb(nhpb)+nres
1052 jhpb(nhpb)=jhpb(nhpb)+nres
1054 else if (restr_type.eq.10) then
1055 c Cross-lonk Markov-like potential
1056 call card_concat(controlcard,.true.)
1057 call readi(controlcard,"ILINK",ihpb(nhpb+1),0)
1058 call readi(controlcard,"JLINK",jhpb(nhpb+1),0)
1060 if (index(controlcard,"BETA").gt.0) ibecarb(nhpb+1)=1
1061 if (ihpb(nhpb+1).eq.0 .or. jhpb(nhpb+1).eq.0) cycle
1062 if (index(controlcard,"ZL").gt.0) then
1064 else if (index(controlcard,"ADH").gt.0) then
1066 else if (index(controlcard,"PDH").gt.0) then
1068 else if (index(controlcard,"DSS").gt.0) then
1073 call reada(controlcard,"AXLINK",dhpb(nhpb+1),
1074 & xlink(1,link_type))
1075 call reada(controlcard,"BXLINK",dhpb1(nhpb+1),
1076 & xlink(2,link_type))
1077 call reada(controlcard,"CXLINK",fordepth(nhpb+1),
1078 & xlink(3,link_type))
1079 call reada(controlcard,"SIGMA",forcon(nhpb+1),
1080 & xlink(4,link_type))
1081 call reada(controlcard,"SCORE",xlscore(nhpb+1),1.0d0)
1082 c read (inp,*) ihpb(nhpb+1),jhpb(nhpb+1),ibecarb(nhpb+1),
1083 c & dhpb(nhpb+1),dhpb1(nhpb+1),forcon(nhpb+1),fordepth(nhpb+1)
1084 if (forcon(nhpb+1).le.0.0d0 .or.
1085 & (dhpb(nhpb+1).eq.0 .and. dhpb1(nhpb+1).eq.0)) cycle
1087 irestr_type(nhpb)=10
1088 c if (ibecarb(nhpb).gt.0) then
1089 c ihpb(nhpb)=ihpb(nhpb)+nres
1090 c jhpb(nhpb)=jhpb(nhpb)+nres
1092 if (ibecarb(nhpb).eq.3) then
1093 jhpb(nhpb)=jhpb(nhpb)+nres
1094 else if (ibecarb(nhpb).eq.2) then
1095 ihpb(nhpb)=ihpb(nhpb)+nres
1096 else if (ibecarb(nhpb).eq.1) then
1097 ihpb(nhpb)=ihpb(nhpb)+nres
1098 jhpb(nhpb)=jhpb(nhpb)+nres
1100 write (iout,'(a,4i5,2f8.2,3f10.5,i5)') "+dist.restr ",
1101 & nhpb,ihpb(nhpb),jhpb(nhpb),ibecarb(nhpb),dhpb(nhpb),
1102 & dhpb1(nhpb),forcon(nhpb),fordepth(nhpb),xlscore(nhpb),
1106 read (inp,*) ihpb(nhpb+1),jhpb(nhpb+1),dhpb(nhpb+1),
1107 & dhpb1(nhpb+1),ibecarb(nhpb+1),forcon(nhpb+1)
1108 if (forcon(nhpb+1).gt.0.0d0) then
1110 if (dhpb1(nhpb).eq.0.0d0) then
1115 c if (ibecarb(nhpb).gt.0) then
1116 c ihpb(nhpb)=ihpb(nhpb)+nres
1117 c jhpb(nhpb)=jhpb(nhpb)+nres
1119 if (ibecarb(nhpb).eq.3) then
1120 ihpb(nhpb)=ihpb(nhpb)+nres
1121 else if (ibecarb(nhpb).eq.2) then
1122 ihpb(nhpb)=ihpb(nhpb)+nres
1123 else if (ibecarb(nhpb).eq.1) then
1124 ihpb(nhpb)=ihpb(nhpb)+nres
1125 jhpb(nhpb)=jhpb(nhpb)+nres
1127 if (dhpb(nhpb).eq.0.0d0)
1128 & dhpb(nhpb)=dist(ihpb(nhpb),jhpb(nhpb))
1130 write (iout,'(a,4i5,f8.2,f10.1)') "+dist.restr ",
1131 & nhpb,ihpb(nhpb),jhpb(nhpb),ibecarb(i),dhpb(nhpb),forcon(nhpb)
1133 C read (inp,*) ihpb(nhpb+1),jhpb(nhpb+1),forcon(nhpb+1)
1134 C if (forcon(nhpb+1).gt.0.0d0) then
1136 C dhpb(nhpb)=dist(ihpb(nhpb),jhpb(nhpb))
1139 if (restr_type.eq.4) then
1140 write (iout,*) "The BFAC array"
1142 write (iout,'(i5,f10.5)') i,bfac(i)
1145 if (itype(i).eq.ntyp1) cycle
1147 if (itype(j).eq.ntyp1) cycle
1148 if (itype(i).eq.10) then
1153 if (itype(j).eq.10) then
1163 forcon(nhpb)=scal_bfac**2/(bfac(i)**2+bfac(j)**2)
1166 if (ibecarb(nhpb).gt.0) ibecarb(nhpb)=4-ibecarb(nhpb)
1167 ihpb(nhpb)=i+nres*ii
1168 jhpb(nhpb)=j+nres*jj
1169 dhpb(nhpb)=dist(i+nres*ii,j+nres*jj)
1170 write (iout,'(a,4i5,2f8.2,3f10.5,i5)') "+dist.restr ",
1171 & nhpb,ihpb(nhpb),jhpb(nhpb),ibecarb(nhpb),dhpb(nhpb),
1172 & dhpb1(nhpb),forcon(nhpb),fordepth(nhpb),xlscore(nhpb),
1181 if (restr_type.eq.5) then
1182 restr_on_coord=.true.
1184 if (itype(i).eq.ntyp1) cycle
1185 bfac(i)=(scal_bfac/bfac(i))**2
1194 if (irestr_type(i).eq.11.and.fordepth(i).gt.fordepthmax)
1195 & fordepthmax=fordepth(i)
1198 if (irestr_type(i).eq.11) fordepth(i)=fordepth(i)/fordepthmax
1201 if (nhpb.gt.nss) then
1202 write (iout,'(/a,i5,a/4a5,2a8,3a10,a5)')
1203 & "The following",nhpb-nss,
1204 & " distance restraints have been imposed:",
1205 & " Nr"," res1"," res2"," beta"," d1"," d2"," k"," V",
1208 write (iout,'(4i5,2f8.2,3f10.5,i5)')i-nss,ihpb(i),jhpb(i),
1209 & ibecarb(i),dhpb(i),dhpb1(i),forcon(i),fordepth(i),xlscore(i),
1217 11 write (iout,*)"read_dist_restr: error reading reference structure"