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*128 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)
419 character*128 bprotfile_temp
422 integer i,j,ii,jj(maxslice),k,kk(maxslice),l,
423 & ll(maxslice),mm(maxslice),if
424 integer nrec,nlines,iscor,iunit,islice
425 double precision energ
428 double precision rmsdev,energia(0:max_ene),efree,eini,temp
429 double precision prop(maxQ)
430 integer ntot_all(maxslice,0:maxprocs-1)
431 integer iparm,ib,iib,ir,nprop,nthr,npars
432 double precision etot,time
436 lenrec1=12*(nres+nct-nnt+1)+4*(2*nss+2)+24
437 lenrec2=12*(nres+nct-nnt+1)+4*(2*nss+2)+24+8*nQ
439 write (iout,*) "lenrec",lenrec," lenrec1",lenrec1,
449 write (iout,*) "nparmset",nparmset
457 if (replica(iparm)) then
464 do iR=1,nRR(ib,iparm)
466 write (iout,*) "iparm",iparm," ib",ib," iR",iR," nQ",nQ
472 IF (NFILE_BIN(iR,ib,iparm).GT.0) THEN
473 c Read conformations from binary DA files (one per batch) and write them to
474 c a binary DA scratchfile.
475 write (liczba,'(bz,i3.3)') me
476 do if=1,nfile_bin(iR,ib,iparm)
477 nazwa=protfiles(if,1,iR,ib,iparm)
478 & (:ilen(protfiles(if,1,iR,ib,iparm)))//".bx"
479 open (ientin,file=nazwa,status="old",form="unformatted",
480 & access="direct",recl=lenrec2,err=1111)
483 call opentmp(islice,ientout,bprotfile_temp)
484 call bxread(nazwa,ii,jj(islice),kk(islice),ll(islice),
485 & mm(islice),iR,ib,iparm)
492 IF (NFILE_ASC(iR,ib,iparm).GT.0) THEN
493 c Read conformations from multiple ASCII int files and write them to a binary
495 do if=1,nfile_asc(iR,ib,iparm)
496 nazwa=protfiles(if,2,iR,ib,iparm)
497 & (:ilen(protfiles(if,2,iR,ib,iparm)))//".x"
498 open(unit=ientin,file=nazwa,status='old',err=1111)
499 write(iout,*) "reading ",nazwa(:ilen(nazwa))
501 call xread(nazwa,ii,jj,kk,ll,mm,iR,ib,iparm)
504 IF (NFILE_CX(iR,ib,iparm).gt.0) THEN
505 c Read conformations from cx files and write them to a binary
507 do if=1,nfile_cx(iR,ib,iparm)
508 nazwa=protfiles(if,2,iR,ib,iparm)
509 & (:ilen(protfiles(if,2,iR,ib,iparm)))//".cx"
510 write(iout,*) "reading ",nazwa(:ilen(nazwa))
512 print *,"Calling cxread"
513 call cxread(nazwa,ii,jj,kk,ll,mm,iR,ib,iparm,
516 write (iout,*) "exit cxread"
522 stot(islice)=stot(islice)+jj(islice)
527 write (iout,*) "IPARM",iparm
530 if (nslice.eq.1) then
532 write (liczba,'(bz,i3.3)') me
533 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
534 & prefix(:ilen(prefix))//liczba//".xbin.tmp"
536 bprotfile_temp = scratchdir(:ilen(scratchdir))//
537 & "/"//prefix(:ilen(prefix))//".xbin.tmp"
539 write(iout,*) mm(1)," conformations read",ll(1),
540 & " conformations written to ",
541 & bprotfile_temp(:ilen(bprotfile_temp))
544 write (liczba1,'(bz,i2.2)') islice
546 write (liczba,'(bz,i3.3)') me
547 bprotfile_temp = scratchdir(:ilen(scratchdir))//"/"//
548 & prefix(:ilen(prefix))//liczba//".xbin.tmp"//liczba1
550 bprotfile_temp = scratchdir(:ilen(scratchdir))//
551 & "/"//prefix(:ilen(prefix))//".xbin.tmp"//liczba1
553 write(iout,*) mm(islice)," conformations read",ll(islice),
554 & " conformations written to ",
555 & bprotfile_temp(:ilen(bprotfile_temp))
560 c Check if everyone has the same number of conformations
561 call MPI_Allgather(stot(1),maxslice,MPI_INTEGER,
562 & ntot_all(1,0),maxslice,MPI_INTEGER,MPI_Comm_World,IERROR)
567 if (stot(islice).ne.ntot_all(islice,i)) then
568 write (iout,*) "Number of conformations at processor",i,
569 & " differs from that at processor",me,
570 & stot(islice),ntot_all(islice,i)," slice",islice
578 write (iout,*) "Numbers of conformations read by processors"
581 write (iout,'(8i10)') i,(ntot_all(islice,i),islice=1,nslice)
583 write (iout,*) "Calculation terminated."
588 ntot(islice)=stot(islice)
592 1111 write(iout,*) "Error opening coordinate file ",nazwa(:ilen(nazwa))
596 c------------------------------------------------------------------------------
597 subroutine card_concat(card,to_upper)
599 include 'DIMENSIONS.ZSCOPT'
600 include "COMMON.IOUNITS"
602 character*80 karta,ucase
606 read (inp,'(a)') karta
607 if (to_upper) karta=ucase(karta)
609 do while (karta(80:80).eq.'&')
610 card=card(:ilen(card)+1)//karta(:79)
611 read (inp,'(a)') karta
612 if (to_upper) karta=ucase(karta)
614 card=card(:ilen(card)+1)//karta
617 c------------------------------------------------------------------------------
618 subroutine readi(rekord,lancuch,wartosc,default)
620 character*(*) rekord,lancuch
621 integer wartosc,default
624 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
629 iread=iread+ilen(lancuch)+1
630 read (rekord(iread:),*) wartosc
633 c----------------------------------------------------------------------------
634 subroutine reada(rekord,lancuch,wartosc,default)
636 character*(*) rekord,lancuch
638 double precision wartosc,default
641 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
646 iread=iread+ilen(lancuch)+1
647 read (rekord(iread:),*) wartosc
650 c----------------------------------------------------------------------------
651 subroutine multreadi(rekord,lancuch,tablica,dim,default)
654 integer tablica(dim),default
655 character*(*) rekord,lancuch
662 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
663 if (iread.eq.0) return
664 iread=iread+ilen(lancuch)+1
665 read (rekord(iread:),*,end=10,err=10) (tablica(i),i=1,dim)
668 c----------------------------------------------------------------------------
669 subroutine multreada(rekord,lancuch,tablica,dim,default)
672 double precision tablica(dim),default
673 character*(*) rekord,lancuch
680 iread=index(rekord,lancuch(:ilen(lancuch))//"=")
681 if (iread.eq.0) return
682 iread=iread+ilen(lancuch)+1
683 read (rekord(iread:),*,end=10,err=10) (tablica(i),i=1,dim)
686 c----------------------------------------------------------------------------
687 subroutine reads(rekord,lancuch,wartosc,default)
689 character*(*) rekord,lancuch,wartosc,default
691 integer ilen,lenlan,lenrec,iread,ireade
697 iread=index(rekord,lancuch(:lenlan)//"=")
698 c print *,"rekord",rekord," lancuch",lancuch
699 c print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
705 c print *,"iread",iread
706 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
707 do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
709 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
711 c print *,"iread",iread
712 if (iread.gt.lenrec) then
717 c print *,"ireade",ireade
718 do while (ireade.lt.lenrec .and.
719 & .not.iblnk(rekord(ireade:ireade)))
722 wartosc=rekord(iread:ireade)
725 c----------------------------------------------------------------------------
726 subroutine multreads(rekord,lancuch,tablica,dim,default)
729 character*(*) rekord,lancuch,tablica(dim),default
731 integer ilen,lenlan,lenrec,iread,ireade
740 iread=index(rekord,lancuch(:lenlan)//"=")
741 c print *,"rekord",rekord," lancuch",lancuch
742 c print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
743 if (iread.eq.0) return
746 c print *,"iread",iread
747 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
748 do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
750 c print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
752 c print *,"iread",iread
753 if (iread.gt.lenrec) return
755 c print *,"ireade",ireade
756 do while (ireade.lt.lenrec .and.
757 & .not.iblnk(rekord(ireade:ireade)))
760 tablica(i)=rekord(iread:ireade)
764 c----------------------------------------------------------------------------
765 subroutine split_string(rekord,tablica,dim,nsub)
767 integer dim,nsub,i,ii,ll,kk
768 character*(*) tablica(dim)
779 C Find the start of term name
781 do while (ii.le.ll .and. rekord(ii:ii).eq." ")
784 C Parse the name into TABLICA(i) until blank found
785 do while (ii.le.ll .and. rekord(ii:ii).ne." ")
787 tablica(i)(kk:kk)=rekord(ii:ii)
790 if (kk.gt.0) nsub=nsub+1
795 c--------------------------------------------------------------------------------
796 integer function iroof(n,m)
798 if (ii*m .lt. n) ii=ii+1