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.SBRIDGE"
21 character*800 controlcard
22 integer i,j,k,ii,n_ene_found
23 integer ind,itype1,itype2,itypf,itypsc,itypp
30 call card_concat(controlcard,.true.)
31 call readi(controlcard,"N_ENE",n_ene,max_ene)
32 if (n_ene.gt.max_ene) then
33 write (iout,*) "Error: parameter out of range: N_ENE",n_ene,
37 call readi(controlcard,"NPARMSET",nparmset,1)
38 separate_parset = index(controlcard,"SEPARATE_PARSET").gt.0
39 call readi(controlcard,"IPARMPRINT",iparmprint,1)
40 write (iout,*) "PARMPRINT",iparmprint
41 if (nparmset.gt.max_parm) then
42 write (iout,*) "Error: parameter out of range: NPARMSET",
46 call readi(controlcard,"MAXIT",maxit,5000)
47 call reada(controlcard,"FIMIN",fimin,1.0d-3)
48 call readi(controlcard,"ENSEMBLES",ensembles,0)
49 hamil_rep=index(controlcard,"HAMIL_REP").gt.0
50 write (iout,*) "Number of energy parameter sets",nparmset
51 call multreadi(controlcard,"ISAMPL",isampl,nparmset,1)
52 write (iout,*) "MaxSlice",MaxSlice
53 call readi(controlcard,"NSLICE",nslice,1)
55 if (nslice.gt.MaxSlice) then
56 write (iout,*) "Error: parameter out of range: NSLICE",nslice,
60 write (iout,*) "Frequency of storing conformations",
61 & (isampl(i),i=1,nparmset)
62 write (iout,*) "Maxit",maxit," Fimin",fimin
63 call readi(controlcard,"NQ",nQ,1)
65 write (iout,*) "Error: parameter out of range: NQ",nq,
70 if (index(controlcard,"CLASSIFY").gt.0) indpdb=1
71 call reada(controlcard,"DELTA",delta,1.0d-2)
72 call readi(controlcard,"EINICHECK",einicheck,2)
73 call reada(controlcard,"DELTRMS",deltrms,5.0d-2)
74 call readi(controlcard,"NGRIDT",NGridT,400)
75 call reada(controlcard,"STARTGRIDT",StartGridT,200.0d0)
76 call reada(controlcard,"DELTA_T",Delta_T,1.0d0)
77 call reada(controlcard,"DELTRGY",deltrgy,5.0d-2)
78 call readi(controlcard,"RESCALE",rescale_mode,1)
79 check_conf=index(controlcard,"NO_CHECK_CONF").eq.0
80 write (iout,*) "delta",delta
81 write (iout,*) "einicheck",einicheck
82 write (iout,*) "rescale_mode",rescale_mode
84 bxfile=index(controlcard,"BXFILE").gt.0
85 cxfile=index(controlcard,"CXFILE").gt.0
86 if (nslice .eq. 1 .and. .not.bxfile .and. .not.cxfile)
88 histfile=index(controlcard,"HISTFILE").gt.0
89 histout=index(controlcard,"HISTOUT").gt.0
90 entfile=index(controlcard,"ENTFILE").gt.0
91 zscfile=index(controlcard,"ZSCFILE").gt.0
92 with_dihed_constr = index(controlcard,"WITH_DIHED_CONSTR").gt.0
93 call readi(controlcard,'CONSTR_DIST',constr_dist,0)
94 write (iout,*) "with_dihed_constr ",with_dihed_constr,
95 & " CONSTR_DIST",constr_dist
96 call readi(controlcard,'CONSTR_HOMOL',constr_homology,0)
97 write (iout,*) "with_homology_constr ",with_dihed_constr,
98 & " CONSTR_HOMOLOGY",constr_homology
99 refstr = index(controlcard,'REFSTR').gt.0
100 pdbref = index(controlcard,'PDBREF').gt.0
101 dyn_ss=(index(controlcard,'DYN_SS').gt.0)
102 C /06/28/2013 Adasko: dyn_ss is keyword allowing to break and create bond
103 C disulfide bond. Note that in conterary to dynamics this in
104 C CONTROLCARD. The bond are read in molread_zs.F
108 c------------------------------------------------------------------------------
109 subroutine read_efree(*)
111 C Read molecular data
115 include 'DIMENSIONS.ZSCOPT'
116 include 'DIMENSIONS.COMPAR'
117 include 'DIMENSIONS.FREE'
118 include 'COMMON.IOUNITS'
119 include 'COMMON.TIME1'
120 include 'COMMON.SBRIDGE'
121 include 'COMMON.CONTROL'
122 include 'COMMON.CHAIN'
123 include 'COMMON.HEADER'
125 include 'COMMON.FREE'
126 character*320 controlcard,ucase
127 integer iparm,ib,i,j,npars
139 call card_concat(controlcard,.true.)
140 call readi(controlcard,'NT',nT_h(iparm),1)
141 write (iout,*) "iparm",iparm," nt",nT_h(iparm)
143 if (nT_h(iparm).gt.MaxT_h) then
144 write (iout,*) "Error: parameter out of range: NT",nT_h(iparm),
148 replica(iparm)=index(controlcard,"REPLICA").gt.0
149 umbrella(iparm)=index(controlcard,"UMBRELLA").gt.0
150 if (umbrella(iparm) .and. homol_nset.gt.1) then
151 umbrella(iparm) = .false.
153 & "Replica in homology restraints weights UMBRELLA ignored,",iparm
155 read_iset(iparm)=index(controlcard,"READ_ISET").gt.0
156 write (iout,*) "nQ",nQ," nT",nT_h(iparm)," replica ",
157 & replica(iparm)," umbrella ",umbrella(iparm),
158 & " read_iset",read_iset(iparm)
161 call card_concat(controlcard,.true.)
162 call readi(controlcard,'NR',nR(ib,iparm),1)
163 if (umbrella(iparm)) then
166 nRR(ib,iparm)=nR(ib,iparm)
168 if (nR(ib,iparm).gt.MaxR) then
169 write (iout,*) "Error: parameter out of range: NR",
173 call reada(controlcard,'TEMP',beta_h(ib,iparm),298.0d0)
174 beta_h(ib,iparm)=1.0d0/(beta_h(ib,iparm)*1.987D-3)
175 call multreada(controlcard,'FI',f(1,ib,iparm),nR(ib,iparm),
178 call card_concat(controlcard,.true.)
179 call multreada(controlcard,'KH',KH(1,i,ib,iparm),nQ,
181 call multreada(controlcard,'Q0',Q0(1,i,ib,iparm),nQ,
186 write (iout,*) "ib",ib," beta_h",
187 & 1.0d0/(0.001987*beta_h(ib,iparm))
188 write (iout,*) "nR",nR(ib,iparm)
189 write (iout,*) "fi",(f(i,ib,iparm),i=1,nR(ib,iparm))
191 write (iout,*) "i",i," Kh",(Kh(j,i,ib,iparm),j=1,nQ),
192 & "q0",(q0(j,i,ib,iparm),j=1,nQ)
197 write (iout,*) "HOMOL_NSET",homol_nset
198 if (homol_nset.gt.1) then
199 write (iout,*) "HOMOL_NSET: nT_h",nT_h(iparm)
201 nR(ib,iparm)=homol_nset
202 write (iout,*) "iparm",iparm," ib",ib," nR",nR(ib,iparm)
213 nR(ib,iparm)=nR(ib,1)
214 if (umbrella(iparm)) then
217 nRR(ib,iparm)=nR(ib,1)
219 beta_h(ib,iparm)=beta_h(ib,1)
221 f(i,ib,iparm)=f(i,ib,1)
223 KH(j,i,ib,iparm)=KH(j,i,ib,1)
224 Q0(j,i,ib,iparm)=Q0(j,i,ib,1)
227 replica(iparm)=replica(1)
228 umbrella(iparm)=umbrella(1)
229 read_iset(iparm)=read_iset(1)
237 c-----------------------------------------------------------------------------
238 subroutine read_protein_data(*)
241 include "DIMENSIONS.ZSCOPT"
242 include "DIMENSIONS.FREE"
245 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
248 include "COMMON.CHAIN"
249 include "COMMON.IOUNITS"
250 include "COMMON.PROT"
251 include "COMMON.PROTFILES"
252 include "COMMON.NAMES"
253 include "COMMON.FREE"
254 include "COMMON.OBCINKA"
256 character*16000 controlcard
257 integer i,ii,ib,iR,iparm,ilen,iroof,nthr,npars
267 C Read names of files with conformation data.
268 if (replica(iparm)) then
274 do ii=1,nRR(ib,iparm)
275 write (iout,*) "Parameter set",iparm," temperature",ib,
278 call card_concat(controlcard,.true.)
279 write (iout,*) controlcard(:ilen(controlcard))
280 call readi(controlcard,"NFILE_BIN",nfile_bin(ii,ib,iparm),0)
281 call readi(controlcard,"NFILE_ASC",nfile_asc(ii,ib,iparm),0)
282 call readi(controlcard,"NFILE_CX",nfile_cx(ii,ib,iparm),0)
283 call readi(controlcard,"REC_START",rec_start(ii,ib,iparm),1)
284 call readi(controlcard,"REC_END",rec_end(ii,ib,iparm),
285 & maxstr*isampl(iparm)+rec_start(ii,ib,iparm)-1)
286 call reada(controlcard,"TIME_START",
287 & time_start_collect(ii,ib,iparm),0.0d0)
288 call reada(controlcard,"TIME_END",time_end_collect(ii,ib,iparm),
290 write (iout,*) "rec_start",rec_start(ii,ib,iparm),
291 & " rec_end",rec_end(ii,ib,iparm)
292 write (iout,*) "time_start",time_start_collect(ii,ib,iparm),
293 & " time_end",time_end_collect(ii,ib,iparm)
295 if (replica(iparm)) then
296 call readi(controlcard,"TOTRAJ",totraj(ii,iparm),1)
297 write (iout,*) "Number of trajectories",totraj(ii,iparm)
300 if (nfile_bin(ii,ib,iparm).lt.2
301 & .and. nfile_asc(ii,ib,iparm).eq.0
302 & .and. nfile_cx(ii,ib,iparm).eq.0) then
303 write (iout,*) "Error - no action specified!"
306 if (nfile_bin(ii,ib,iparm).gt.0) then
307 call card_concat(controlcard,.false.)
308 call split_string(controlcard,protfiles(1,1,ii,ib,iparm),
309 & maxfile_prot,nfile_bin(ii,ib,iparm))
311 write(iout,*)"nfile_bin",nfile_bin(ii,ib,iparm)
312 write(iout,*) (protfiles(i,1,ii,ib,iparm),
313 & i=1,nfile_bin(ii,ib,iparm))
316 if (nfile_asc(ii,ib,iparm).gt.0) then
317 call card_concat(controlcard,.false.)
318 call split_string(controlcard,protfiles(1,2,ii,ib,iparm),
319 & maxfile_prot,nfile_asc(ii,ib,iparm))
321 write(iout,*) "nfile_asc(ii,ib,iparm)",nfile_asc(ii,ib,iparm)
322 write(iout,*) (protfiles(i,2,ii,ib,iparm),
323 & i=1,nfile_asc(ii,ib,iparm))
325 else if (nfile_cx(ii,ib,iparm).gt.0) then
326 call card_concat(controlcard,.false.)
327 call split_string(controlcard,protfiles(1,2,ii,ib,iparm),
328 & maxfile_prot,nfile_cx(ii,ib,iparm))
330 write(iout,*) "nfile_cx(ii,ib,iparm)",nfile_cx(ii,ib,iparm)
331 write(iout,*) (protfiles(i,2,ii,ib,iparm),
332 & i=1,nfile_cx(ii,ib,iparm))
343 c-------------------------------------------------------------------------------
344 subroutine opentmp(islice,iunit,bprotfile_temp)
347 include "DIMENSIONS.ZSCOPT"
348 include "DIMENSIONS.FREE"
351 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
354 include "COMMON.IOUNITS"
355 include "COMMON.PROTFILES"
356 include "COMMON.PROT"
357 include "COMMON.FREE"
358 character*64 bprotfile_temp
359 character*3 liczba,liczba2
366 write (liczba1,'(bz,i2.2)') islice
367 write (liczba,'(bz,i3.3)') me
369 c write (iout,*) "separate_parset ",separate_parset,
371 if (separate_parset) then
372 write (liczba2,'(bz,i3.3)') myparm
373 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
374 & prefix(:ilen(prefix))//liczba//"_"//liczba2//".xbin.tmp"//liczba1
375 open (iunit,file=bprotfile_temp,status="unknown",
376 & form="unformatted",access="direct",recl=lenrec)
378 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
379 & prefix(:ilen(prefix))//liczba//".xbin.tmp"//liczba1
380 open (iunit,file=bprotfile_temp,status="unknown",
381 & form="unformatted",access="direct",recl=lenrec)
384 bprotfile_temp = scratchdir(:ilen(scratchdir))//
385 & "/"//prefix(:ilen(prefix))//".xbin.tmp"//liczba1
386 open (iunit,file=bprotfile_temp,status="unknown",
387 & form="unformatted",access="direct",recl=lenrec)
389 c write (iout,*) "OpenTmp iunit",iunit," bprotfile_temp",
394 c-------------------------------------------------------------------------------
395 subroutine read_database(*)
398 include "DIMENSIONS.ZSCOPT"
399 include "DIMENSIONS.FREE"
402 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
405 include "COMMON.CHAIN"
406 include "COMMON.IOUNITS"
407 include "COMMON.PROTFILES"
408 include "COMMON.NAMES"
411 include "COMMON.ENEPS"
412 include "COMMON.PROT"
413 include "COMMON.INTERACT"
414 include "COMMON.FREE"
415 include "COMMON.SBRIDGE"
416 include "COMMON.OBCINKA"
417 real*4 csingle(3,maxres2)
418 character*64 nazwa,bprotfile_temp
421 integer i,j,ii,jj(maxslice),k,kk(maxslice),l,
422 & ll(maxslice),mm(maxslice),if
423 integer nrec,nlines,iscor,iunit,islice
424 double precision energ
427 double precision rmsdev,energia(0:max_ene),efree,eini,temp
428 double precision prop(maxQ)
429 integer ntot_all(maxslice,0:maxprocs-1)
430 integer iparm,ib,iib,ir,nprop,nthr,npars
431 double precision etot,time
435 lenrec1=12*(nres+nct-nnt+1)+4*(2*nss+2)+24
436 lenrec2=12*(nres+nct-nnt+1)+4*(2*nss+2)+24+8*nQ
438 write (iout,*) "lenrec",lenrec," lenrec1",lenrec1,
448 write (iout,*) "nparmset",nparmset
456 if (replica(iparm)) then
463 do iR=1,nRR(ib,iparm)
465 write (iout,*) "iparm",iparm," ib",ib," iR",iR," nQ",nQ
471 IF (NFILE_BIN(iR,ib,iparm).GT.0) THEN
472 c Read conformations from binary DA files (one per batch) and write them to
473 c a binary DA scratchfile.
474 write (liczba,'(bz,i3.3)') me
475 do if=1,nfile_bin(iR,ib,iparm)
476 nazwa=protfiles(if,1,iR,ib,iparm)
477 & (:ilen(protfiles(if,1,iR,ib,iparm)))//".bx"
478 open (ientin,file=nazwa,status="old",form="unformatted",
479 & access="direct",recl=lenrec2,err=1111)
482 call opentmp(islice,ientout,bprotfile_temp)
483 call bxread(nazwa,ii,jj(islice),kk(islice),ll(islice),
484 & mm(islice),iR,ib,iparm)
491 IF (NFILE_ASC(iR,ib,iparm).GT.0) THEN
492 c Read conformations from multiple ASCII int files and write them to a binary
494 do if=1,nfile_asc(iR,ib,iparm)
495 nazwa=protfiles(if,2,iR,ib,iparm)
496 & (:ilen(protfiles(if,2,iR,ib,iparm)))//".x"
497 open(unit=ientin,file=nazwa,status='old',err=1111)
498 write(iout,*) "reading ",nazwa(:ilen(nazwa))
500 call xread(nazwa,ii,jj,kk,ll,mm,iR,ib,iparm)
503 IF (NFILE_CX(iR,ib,iparm).gt.0) THEN
504 c Read conformations from cx files and write them to a binary
506 do if=1,nfile_cx(iR,ib,iparm)
507 nazwa=protfiles(if,2,iR,ib,iparm)
508 & (:ilen(protfiles(if,2,iR,ib,iparm)))//".cx"
509 write(iout,*) "reading ",nazwa(:ilen(nazwa))
511 print *,"Calling cxread"
512 call cxread(nazwa,ii,jj,kk,ll,mm,iR,ib,iparm,
515 write (iout,*) "exit cxread"
521 stot(islice)=stot(islice)+jj(islice)
526 write (iout,*) "IPARM",iparm
529 if (nslice.eq.1) then
531 write (liczba,'(bz,i3.3)') me
532 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
533 & prefix(:ilen(prefix))//liczba//".xbin.tmp"
535 bprotfile_temp = scratchdir(:ilen(scratchdir))//
536 & "/"//prefix(:ilen(prefix))//".xbin.tmp"
538 write(iout,*) mm(1)," conformations read",ll(1),
539 & " conformations written to ",
540 & bprotfile_temp(:ilen(bprotfile_temp))
543 write (liczba1,'(bz,i2.2)') islice
545 write (liczba,'(bz,i3.3)') me
546 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
547 & prefix(:ilen(prefix))//liczba//".xbin.tmp"//liczba1
549 bprotfile_temp = scratchdir(:ilen(scratchdir))//
550 & "/"//prefix(:ilen(prefix))//".xbin.tmp"//liczba1
552 write(iout,*) mm(islice)," conformations read",ll(islice),
553 & " conformations written to ",
554 & bprotfile_temp(:ilen(bprotfile_temp))
559 c Check if everyone has the same number of conformations
560 call MPI_Allgather(stot(1),maxslice,MPI_INTEGER,
561 & ntot_all(1,0),maxslice,MPI_INTEGER,MPI_Comm_World,IERROR)
566 if (stot(islice).ne.ntot_all(islice,i)) then
567 write (iout,*) "Number of conformations at processor",i,
568 & " differs from that at processor",me,
569 & stot(islice),ntot_all(islice,i)," slice",islice
577 write (iout,*) "Numbers of conformations read by processors"
580 write (iout,'(8i10)') i,(ntot_all(islice,i),islice=1,nslice)
582 write (iout,*) "Calculation terminated."
587 ntot(islice)=stot(islice)
591 1111 write(iout,*) "Error opening coordinate file ",nazwa(:ilen(nazwa))
595 c------------------------------------------------------------------------------
596 subroutine card_concat(card,to_upper)
598 include 'DIMENSIONS.ZSCOPT'
599 include "COMMON.IOUNITS"
601 character*80 karta,ucase
605 read (inp,'(a)') karta
606 if (to_upper) karta=ucase(karta)
608 do while (karta(80:80).eq.'&')
609 card=card(:ilen(card)+1)//karta(:79)
610 read (inp,'(a)') karta
611 if (to_upper) karta=ucase(karta)
613 card=card(:ilen(card)+1)//karta
616 c------------------------------------------------------------------------------
617 subroutine readi(rekord,lancuch,wartosc,default)
619 character*(*) rekord,lancuch
620 integer wartosc,default
623 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
628 iread=iread+ilen(lancuch)+1
629 read (rekord(iread:),*) wartosc
632 c----------------------------------------------------------------------------
633 subroutine reada(rekord,lancuch,wartosc,default)
635 character*(*) rekord,lancuch
637 double precision wartosc,default
640 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
645 iread=iread+ilen(lancuch)+1
646 read (rekord(iread:),*) wartosc
649 c----------------------------------------------------------------------------
650 subroutine multreadi(rekord,lancuch,tablica,dim,default)
653 integer tablica(dim),default
654 character*(*) rekord,lancuch
661 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
662 if (iread.eq.0) return
663 iread=iread+ilen(lancuch)+1
664 read (rekord(iread:),*,end=10,err=10) (tablica(i),i=1,dim)
667 c----------------------------------------------------------------------------
668 subroutine multreada(rekord,lancuch,tablica,dim,default)
671 double precision tablica(dim),default
672 character*(*) rekord,lancuch
679 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
680 if (iread.eq.0) return
681 iread=iread+ilen(lancuch)+1
682 read (rekord(iread:),*,end=10,err=10) (tablica(i),i=1,dim)
685 c----------------------------------------------------------------------------
686 subroutine reads(rekord,lancuch,wartosc,default)
688 character*(*) rekord,lancuch,wartosc,default
690 integer ilen,lenlan,lenrec,iread,ireade
696 iread=index(rekord,lancuch(:lenlan)//"=")
697 c print *,"rekord",rekord," lancuch",lancuch
698 c print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
704 c print *,"iread",iread
705 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
706 do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
708 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
710 c print *,"iread",iread
711 if (iread.gt.lenrec) then
716 c print *,"ireade",ireade
717 do while (ireade.lt.lenrec .and.
718 & .not.iblnk(rekord(ireade:ireade)))
721 wartosc=rekord(iread:ireade)
724 c----------------------------------------------------------------------------
725 subroutine multreads(rekord,lancuch,tablica,dim,default)
728 character*(*) rekord,lancuch,tablica(dim),default
730 integer ilen,lenlan,lenrec,iread,ireade
739 iread=index(rekord,lancuch(:lenlan)//"=")
740 c print *,"rekord",rekord," lancuch",lancuch
741 c print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
742 if (iread.eq.0) return
745 c print *,"iread",iread
746 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
747 do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
749 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
751 c print *,"iread",iread
752 if (iread.gt.lenrec) return
754 c print *,"ireade",ireade
755 do while (ireade.lt.lenrec .and.
756 & .not.iblnk(rekord(ireade:ireade)))
759 tablica(i)=rekord(iread:ireade)
763 c----------------------------------------------------------------------------
764 subroutine split_string(rekord,tablica,dim,nsub)
766 integer dim,nsub,i,ii,ll,kk
767 character*(*) tablica(dim)
778 C Find the start of term name
780 do while (ii.le.ll .and. rekord(ii:ii).eq." ")
783 C Parse the name into TABLICA(i) until blank found
784 do while (ii.le.ll .and. rekord(ii:ii).ne." ")
786 tablica(i)(kk:kk)=rekord(ii:ii)
789 if (kk.gt.0) nsub=nsub+1
794 c--------------------------------------------------------------------------------
795 integer function iroof(n,m)
797 if (ii*m .lt. n) ii=ii+1