1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5 ! Program to carry out conformational search of proteins in an united-residue !
8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13 use control, only:tcpu
14 use io_base, only:ilen
15 use geometry, only:chainbuild
16 use control, only:dajczas
19 use compare, only: test
25 ! implicit real*8 (a-h,o-z)
26 ! include 'DIMENSIONS'
28 use MPI_data ! include 'COMMON.SETUP'
33 use MPI_data, only: me,king
36 ! include 'COMMON.TIME1'
37 ! include 'COMMON.INTERACT'
38 ! include 'COMMON.NAMES'
39 ! include 'COMMON.GEO'
40 ! include 'COMMON.HEADER'
41 ! include 'COMMON.CONTROL'
42 ! include 'COMMON.CONTACTS'
43 ! include 'COMMON.CHAIN'
44 ! include 'COMMON.VAR'
45 ! include 'COMMON.IOUNITS'
46 ! include 'COMMON.FFIELD'
47 ! include 'COMMON.REMD'
49 ! include 'COMMON.SBRIDGE'
51 real(kind=8) :: hrtime,mintime,sectime
52 character(len=64) :: text_mode_calc(-2:14)
53 text_mode_calc(-2) = 'test'
54 text_mode_calc(-1) = 'cos'
55 text_mode_calc(0) = 'Energy evaluation or minimization'
56 text_mode_calc(1) = 'Regularization of PDB structure'
57 text_mode_calc(2) = 'Threading of a sequence on PDB structures'
58 text_mode_calc(3) = 'Monte Carlo (with minimization) '
59 text_mode_calc(4) = 'Energy minimization of multiple conformations'
60 text_mode_calc(5) = 'Checking energy gradient'
61 text_mode_calc(6) = 'Entropic sampling Monte Carlo (with minimization)'
62 text_mode_calc(7) = 'Energy map'
63 text_mode_calc(8) = 'CSA calculations'
64 text_mode_calc(9) = 'Not used 9'
65 text_mode_calc(10) = 'Not used 10'
66 text_mode_calc(11) = 'Soft regularization of PDB structure'
67 text_mode_calc(12) = 'Mesoscopic molecular dynamics (MD) '
68 text_mode_calc(13) = 'Not used 13'
69 text_mode_calc(14) = 'Replica exchange molecular dynamics (REMD)'
71 ! call memmon_print_usage()
75 write(iout,*)'### LAST MODIFIED 09/03/15 15:32PM by EL'
76 if (me.eq.king) call cinfo
77 ! Read force field parameters and job setup data
81 if (me.eq.king .or. .not. out1file) then
82 write (iout,'(2a/)') &
83 text_mode_calc(modecalc)(:ilen(text_mode_calc(modecalc))), &
85 if (minim) write (iout,'(a)') &
86 'Conformations will be energy-minimized.'
87 write (iout,'(80(1h*)/)')
91 if (modecalc.eq.-2) then
94 else if (modecalc.eq.-1) then
95 write(iout,*) "call check_sc_map next"
99 !elwrite(iout,*)"!!!!!!!!!!!!!!!!! in unres"
102 if (fg_rank.gt.0) then
103 ! Fine-grain slaves just do energy and gradient components.
104 call ergastulum ! slave workhouse in Latin
107 if (modecalc.eq.0) then
108 call exec_eeval_or_minim
109 else if (modecalc.eq.1) then
111 else if (modecalc.eq.2) then
113 else if (modecalc.eq.3 .or. modecalc .eq.6) then
115 else if (modecalc.eq.4) then
116 call exec_mult_eeval_or_minim
117 else if (modecalc.eq.5) then
119 else if (ModeCalc.eq.7) then
121 else if (ModeCalc.eq.8) then
123 else if (modecalc.eq.11) then
125 else if (modecalc.eq.12) then
127 else if (modecalc.eq.14) then
130 write (iout,'(a)') 'This calculation type is not supported',&
137 if (fg_rank.eq.0) call finish_task
138 ! call memmon_print_usage()
140 call print_detailed_timing
142 call MPI_Finalize(ierr)
145 call dajczas(tcpu(),hrtime,mintime,sectime)
146 stop '********** Program terminated normally.'
150 !-----------------------------------------------------------------------------
152 !-----------------------------------------------------------------------------
154 use MPI_data !include 'COMMON.SETUP'
155 use control_data !include 'COMMON.CONTROL'
156 use geometry, only:chainbuild
158 use io_units !include 'COMMON.IOUNITS'
161 ! include 'DIMENSIONS'
166 if (me.eq.king .or. .not. out1file) &
167 write (iout,*) "Calling chainbuild"
171 end subroutine exec_MD
172 !---------------------------------------------------------------------------
173 subroutine exec_MREMD
174 use MPI_data !include 'COMMON.SETUP'
175 use control_data !include 'COMMON.CONTROL'
176 use io_units !include 'COMMON.IOUNITS'
178 use REMD_data !include 'COMMON.REMD'
179 use geometry, only:chainbuild
183 ! include 'DIMENSIONS'
190 call alloc_MREMD_arrays
192 if (me.eq.king .or. .not. out1file) &
193 write (iout,*) "Calling chainbuild"
195 if (me.eq.king .or. .not. out1file) &
196 write (iout,*) "Calling REMD"
206 end subroutine exec_MREMD
207 !-----------------------------------------------------------------------------
208 subroutine exec_eeval_or_minim
209 use MPI_data !include 'COMMON.SETUP'
210 use control_data !include 'COMMON.CONTROL''COMMON.TIME1''COMMON.NAMES''COMMON.HEADER'
211 use io_units !include 'COMMON.IOUNITS'
213 ! use energy !include 'COMMON.INTERACT''COMMON.CONTACTS''COMMON.VAR''COMMON.FFIELD' 'COMMON.SBRIDGE'
214 use geometry_data !include 'COMMON.GEO''COMMON.CHAIN'
215 ! use REMD !include 'COMMON.REMD'
216 ! use MD !include 'COMMON.MD'
221 use geometry, only:chainbuild
223 use compare, only:alloc_compare_arrays,hairpin,secondary2,rms_nac_nnc
224 use minimm, only:minimize,minim_dc,sc_move
228 ! implicit real*8 (a-h,o-z)
229 ! include 'DIMENSIONS'
234 !el common /srutu/ icall
235 real(kind=8) :: energy_(0:n_ene)
236 real(kind=8) :: energy_long(0:n_ene),energy_short(0:n_ene)
237 real(kind=8) :: varia(6*nres) !(maxvar) (maxvar=6*maxres)
238 real(kind=8) :: time00, evals, etota, etot, time_ene, time1
239 integer :: nharp,nft_sc,iretcode,nfun
240 integer,dimension(4,nres/3) :: iharp !(4,nres/3)(4,maxres/3)
242 real(kind=8) :: rms,frac,frac_nn,co
245 call alloc_compare_arrays
246 if (indpdb.eq.0) call chainbuild
251 ! write(iout,*)"in exec_eeval or minimim",split_ene
253 ! write(iout,*)"cccccc",j,(c(i,j),i=1,3)
254 ! write(iout,*)"dcccccc",j,(dc(i,j),i=1,3)
257 ! write(iout,*)"in exec_eeval or minimim"
259 print *,"Processor",myrank," after chainbuild"
262 call etotal_long(energy_long)
263 write (iout,*) "Printing long range energy"
264 call enerprint(energy_long)
266 call etotal_short(energy_short)
267 write (iout,*) "Printing short range energy"
268 call enerprint(energy_short)
270 energy_(i)=energy_long(i)+energy_short(i)
271 write (iout,*) i,energy_long(i),energy_short(i),energy_(i)
273 write (iout,*) "Printing long+short range energy"
274 call enerprint(energy_)
279 time_ene=MPI_Wtime()-time00
281 write (iout,*) "Time for energy evaluation",time_ene
282 print *,"after etotal"
285 call enerprint(energy_)
286 call hairpin(.true.,nharp,iharp)
287 call secondary2(.true.)
291 print *, 'Calling OVERLAP_SC'
292 call overlap_sc(fail)
296 call sc_move(2,nres-1,10,1d10,nft_sc,etot)
297 print *,'SC_move',nft_sc,etot
298 write(iout,*) 'SC_move',nft_sc,etot
302 print *, 'Calling MINIM_DC'
306 ! call check_ecartint !el
307 call minim_dc(etot,iretcode,nfun)
308 ! call check_ecartint !el
310 if (indpdb.ne.0) then
314 call geom_to_var(nvar,varia)
315 print *,'Calling MINIMIZE.'
320 ! call exec_checkgrad !el
321 call minimize(etot,varia,iretcode,nfun)
323 ! call exec_checkgrad !el
325 print *,'SUMSL return code is',iretcode,' eval ',nfun
327 evals=nfun/(MPI_WTIME()-time1)
329 print *,'# eval/s',evals
330 print *,'refstr=',refstr
331 call hairpin(.true.,nharp,iharp)
332 call secondary2(.true.)
335 call enerprint(energy_)
338 call briefout(0,etot)
339 if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
340 write (iout,'(a,i3)') 'SUMSL return code:',iretcode
341 write (iout,'(a,i20)') '# of energy evaluations:',nfun+1
342 write (iout,'(a,f16.3)')'# of energy evaluations/sec:',evals
344 print *,'refstr=',refstr
345 if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
346 call briefout(0,etot)
348 if (outpdb) call pdbout(etot,titel(:32),ipdb)
349 if (outmol2) call mol2out(etot,titel(:32))
350 !elwrite(iout,*) "after exec_eeval_or_minim"
352 end subroutine exec_eeval_or_minim
353 !-----------------------------------------------------------------------------
354 subroutine exec_regularize
355 ! use MPI_data !include 'COMMON.SETUP'
356 use control_data !include 'COMMON.CONTROL''COMMON.TIME1''COMMON.NAMES''COMMON.HEADER'
357 use io_units !include 'COMMON.IOUNITS'
359 use energy_data !include 'COMMON.INTERACT''COMMON.CONTACTS''COMMON.VAR''COMMON.FFIELD' 'COMMON.SBRIDGE'
360 use geometry_data !include 'COMMON.GEO''COMMON.CHAIN'
361 ! use REMD !include 'COMMON.REMD'
362 ! use MD !include 'COMMON.MD'
366 ! implicit real*8 (a-h,o-z)
367 ! include 'DIMENSIONS'
371 real(kind=8) :: energy_(0:n_ene)
373 real(kind=8) :: rms,frac,frac_nn,co
376 call alloc_compare_arrays
380 call regularize(nct-nnt+1,etot,rms,cref(1,nnt,1),iretcode)
382 energy_(0)=energy_(0)-energy_(14)
384 call enerprint(energy_)
386 call briefout(0,etot)
387 if (outpdb) call pdbout(etot,titel(:32),ipdb)
388 if (outmol2) call mol2out(etot,titel(:32))
389 if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
390 write (iout,'(a,i3)') 'SUMSL return code:',iretcode
392 end subroutine exec_regularize
393 !-----------------------------------------------------------------------------
394 subroutine exec_thread
395 ! use MPI_data !include 'COMMON.SETUP'
398 ! include 'DIMENSIONS'
402 call alloc_compare_arrays
405 end subroutine exec_thread
406 !-----------------------------------------------------------------------------
408 ! use MPI_data !include 'COMMON.SETUP'
409 use control_data !include 'COMMON.CONTROL'
414 ! implicit real*8 (a-h,o-z)
415 ! include 'DIMENSIONS'
416 character(len=10) :: nodeinfo
417 real(kind=8) :: varia(6*nres) !(maxvar) (maxvar=6*maxres)
422 call alloc_MCM_arrays
426 if (modecalc.eq.3) then
432 if (modecalc.eq.3) then
442 end subroutine exec_MC
443 !-----------------------------------------------------------------------------
444 subroutine exec_mult_eeval_or_minim
445 use MPI_data !include 'COMMON.SETUP'
446 use control_data !include 'COMMON.CONTROL''COMMON.TIME1''COMMON.NAMES''COMMON.HEADER'
447 use io_units !include 'COMMON.IOUNITS'
449 use energy_data !include 'COMMON.INTERACT''COMMON.CONTACTS''COMMON.VAR''COMMON.FFIELD' 'COMMON.SBRIDGE'
450 use geometry_data !include 'COMMON.GEO''COMMON.CHAIN'
451 ! use REMD !include 'COMMON.REMD'
452 ! use MD !include 'COMMON.MD'
454 use geometry, only:chainbuild,geom_to_var,int_from_cart1,var_to_geom
455 use energy, only:etotal,enerprint
456 use compare, only:rms_nac_nnc
457 use minimm, only:minimize!,minim_mcmf
458 ! implicit real*8 (a-h,o-z)
459 ! include 'DIMENSIONS'
461 use minimm, only:minim_mcmf
464 integer :: ierror,ierr
466 real(kind=8),dimension(mpi_status_size) :: muster
470 real(kind=8) :: varia(6*nres) !(maxvar) (maxvar=6*maxres)
471 integer,dimension(6) :: ind
472 real(kind=8) :: energy_(0:n_ene)
474 real(kind=8) :: etot,ene0
475 integer :: mm,imm,nft,n,iconf,nmin,i,iretcode,nfun,it,&
477 real(kind=8) :: rms,frac,frac_nn,co,time,ene
487 open(intin,file=intinname,status='old')
488 write (istat,'(a5,20a12)')"# ",&
489 (wname(print_order(i)),i=1,nprint_ene)
491 write (istat,'(a5,20a12)')"# ",&
492 (ename(print_order(i)),i=1,nprint_ene),&
493 "ETOT total","RMSD","nat.contact","nnt.contact"
495 write (istat,'(a5,20a12)')"# ",&
496 (ename(print_order(i)),i=1,nprint_ene),"ETOT total"
502 read (intin,'(e15.10,e15.5)',end=1100,err=1100) time,ene
503 call read_x(intin,*11)
505 ! Broadcast the order to compute internal coordinates to the slaves.
507 call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
509 call int_from_cart1(.false.)
511 read (intin,'(i5)',end=1100,err=1100) iconf
512 call read_angles(intin,*11)
513 call geom_to_var(nvar,varia)
516 write (iout,'(a,i7)') 'Conformation #',iconf
518 call briefout(iconf,energy_(0))
519 call enerprint(energy_)
522 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
523 write (istat,'(i5,20(f12.3))') iconf,&
524 (energy_(print_order(i)),i=1,nprint_ene),etot,&
528 write (istat,'(i5,16(f12.3))') iconf,&
529 (energy_(print_order(i)),i=1,nprint_ene),etot
545 if (mm.lt.nodes) then
547 read (intin,'(e15.10,e15.5)',end=11,err=11) time,ene
548 call read_x(intin,*11)
550 ! Broadcast the order to compute internal coordinates to the slaves.
552 call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
554 call int_from_cart1(.false.)
556 read (intin,'(i5)',end=11,err=11) iconf
557 call read_angles(intin,*11)
558 call geom_to_var(nvar,varia)
561 write (iout,'(a,i7)') 'Conformation #',iconf
571 call mpi_send(ind,6,mpi_integer,mm,idint,CG_COMM,&
573 call mpi_send(varia,nvar,mpi_double_precision,mm,&
575 call mpi_send(ene0,1,mpi_double_precision,mm,&
577 ! print *,'task ',n,' sent to worker ',mm,nvar
579 call mpi_recv(ind,6,mpi_integer,mpi_any_source,idint,&
581 man=muster(mpi_source)
582 ! print *,'receiving result from worker ',man,' (',iii1,iii,')'
583 call mpi_recv(varia,nvar,mpi_double_precision,&
584 man,idreal,CG_COMM,muster,ierr)
585 call mpi_recv(ene,1,&
586 mpi_double_precision,man,idreal,&
588 call mpi_recv(ene0,1,&
589 mpi_double_precision,man,idreal,&
591 ! print *,'result received from worker ',man,' sending now'
593 call var_to_geom(nvar,varia)
599 write (iout,'(a,2i7)') 'Conformation #',iconf,ind(5)
602 call enerprint(energy_)
603 call briefout(it,etot)
604 ! if (minim) call briefout(it,etot)
606 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
607 write (istat,'(i5,19(f12.3))') iconf,&
608 (energy_(print_order(i)),i=1,nprint_ene),etot,&
611 write (istat,'(i5,15(f12.3))') iconf,&
612 (energy_(print_order(i)),i=1,nprint_ene),etot
617 read (intin,'(e15.10,e15.5)',end=1101,err=1101) time,ene
618 call read_x(intin,*11)
620 ! Broadcast the order to compute internal coordinates to the slaves.
622 call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
624 call int_from_cart1(.false.)
626 read (intin,'(i5)',end=1101,err=1101) iconf
627 call read_angles(intin,*11)
628 call geom_to_var(nvar,varia)
639 call mpi_send(ind,6,mpi_integer,man,idint,CG_COMM,&
641 call mpi_send(varia,nvar,mpi_double_precision,man,&
643 call mpi_send(ene0,1,mpi_double_precision,man,&
645 nf_mcmf=nf_mcmf+ind(4)
651 call mpi_recv(ind,6,mpi_integer,mpi_any_source,idint,&
653 man=muster(mpi_source)
654 call mpi_recv(varia,nvar,mpi_double_precision,&
655 man,idreal,CG_COMM,muster,ierr)
656 call mpi_recv(ene,1,&
657 mpi_double_precision,man,idreal,&
659 call mpi_recv(ene0,1,&
660 mpi_double_precision,man,idreal,&
663 call var_to_geom(nvar,varia)
669 write (iout,'(a,2i7)') 'Conformation #',iconf,ind(5)
672 call enerprint(energy_)
673 call briefout(it,etot)
675 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
676 write (istat,'(i5,19(f12.3))') iconf,&
677 (energy_(print_order(i)),i=1,nprint_ene),etot,&
680 write (istat,'(i5,15(f12.3))') iconf,&
681 (energy_(print_order(i)),i=1,nprint_ene),etot
693 call mpi_send(ind,6,mpi_integer,i,idint,CG_COMM,&
698 open(intin,file=intinname,status='old')
699 write (istat,'(a5,20a12)')"# ",&
700 (wname(print_order(i)),i=1,nprint_ene)
701 write (istat,'("# ",20(1pe12.4))') &
702 (weights(print_order(i)),i=1,nprint_ene)
704 write (istat,'(a5,20a12)')"# ",&
705 (ename(print_order(i)),i=1,nprint_ene),&
706 "ETOT total","RMSD","nat.contact","nnt.contact"
708 write (istat,'(a5,14a12)')"# ",&
709 (ename(print_order(i)),i=1,nprint_ene),"ETOT total"
713 read (intin,'(e15.10,e15.5)',end=11,err=11) time,ene
714 call read_x(intin,*11)
716 ! Broadcast the order to compute internal coordinates to the slaves.
718 call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
720 call int_from_cart1(.false.)
722 read (intin,'(i5)',end=11,err=11) iconf
723 call read_angles(intin,*11)
724 call geom_to_var(nvar,varia)
727 write (iout,'(a,i7)') 'Conformation #',iconf
728 if (minim) call minimize(etot,varia,iretcode,nfun)
732 call enerprint(energy_)
733 if (minim) call briefout(it,etot)
735 call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
736 write (istat,'(i5,18(f12.3))') iconf,&
737 (energy_(print_order(i)),i=1,nprint_ene),&
738 etot,rms,frac,frac_nn,co
741 write (istat,'(i5,14(f12.3))') iconf,&
742 (energy_(print_order(i)),i=1,nprint_ene),etot
748 end subroutine exec_mult_eeval_or_minim
749 !-----------------------------------------------------------------------------
750 subroutine exec_checkgrad
751 ! use MPI_data !include 'COMMON.SETUP'
752 use control_data !include 'COMMON.CONTROL''COMMON.TIME1''COMMON.NAMES''COMMON.HEADER'
753 use io_units !include 'COMMON.IOUNITS'
754 !el use energy_data, only:icall !include 'COMMON.INTERACT''COMMON.CONTACTS''COMMON.VAR''COMMON.FFIELD' 'COMMON.SBRIDGE'
755 use geometry_data !include 'COMMON.GEO''COMMON.CHAIN'
756 ! use REMD !include 'COMMON.REMD'
757 use MD_data !include 'COMMON.MD'
758 use io_base, only:intout
759 use io_config, only:read_fragments
764 ! implicit real*8 (a-h,o-z)
765 ! include 'DIMENSIONS'
770 !el common /srutu/ icall
771 real(kind=8) :: energy_(0:max_ene)
775 ! vbld(i)=vbld(i)+ran_number(-0.1d0,0.1d0)
776 ! if (itype(i).ne.10)
777 ! & vbld(i+nres)=vbld(i+nres)+ran_number(-0.001d0,0.001d0)
779 if (indpdb.eq.0) call chainbuild
782 ! dc(j,i)=dc(j,i)+ran_number(-0.2d0,0.2d0)
786 ! if (itype(i).ne.10) then
788 ! dc(j,i+nres)=dc(j,i+nres)+ran_number(-0.2d0,0.2d0)
793 ! dc(j,0)=ran_number(-0.2d0,0.2d0)
803 call etotal(energy_(0))
805 call enerprint(energy_(0))
806 write (iout,*) "Uconst",Uconst," Uconst_back",uconst_back
807 print *,'icheckgrad=',icheckgrad
808 goto (10,20,30) icheckgrad
809 10 call check_ecartint
811 20 call check_cartgrad
815 end subroutine exec_checkgrad
816 !-----------------------------------------------------------------------------
820 use io_config, only:map_read
823 call alloc_map_arrays
827 end subroutine exec_map
828 !-----------------------------------------------------------------------------
831 use io_units !include 'COMMON.IOUNITS'
837 ! include 'DIMENSIONS'
838 ! Conformational Space Annealling programmed by Jooyoung Lee.
839 ! This method works only with parallel machines!
841 call alloc_CSA_arrays
844 write (iout,*) "CSA works on parallel machines only"
847 end subroutine exec_CSA
848 !-----------------------------------------------------------------------------
849 subroutine exec_softreg
850 use io_units !include 'COMMON.IOUNITS'
851 use control_data !include 'COMMON.CONTROL'
853 use io_base, only:intout,briefout
854 use geometry, only:chainbuild
858 ! include 'DIMENSIONS'
859 real(kind=8) :: energy_(0:n_ene)
861 real(kind=8) :: rms,frac,frac_nn,co,etot
864 call alloc_compare_arrays
867 call enerprint(energy_)
868 if (.not.lsecondary) then
869 write(iout,*) 'Calling secondary structure recognition'
870 call secondary2(debug)
872 write(iout,*) 'Using secondary structure supplied in pdb'
879 call enerprint(energy_)
881 call briefout(0,etot)
882 call secondary2(.true.)
883 if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
885 end subroutine exec_softreg
886 !-----------------------------------------------------------------------------
888 !-----------------------------------------------------------------------------
890 subroutine ergastulum
892 ! implicit real*8 (a-h,o-z)
893 ! include 'DIMENSIONS'
896 use MDyn, only:setup_fricmat
897 use REMD, only:fricmat_mult,ginv_mult
901 ! include 'COMMON.SETUP'
902 ! include 'COMMON.DERIV'
903 ! include 'COMMON.VAR'
904 ! include 'COMMON.IOUNITS'
905 ! include 'COMMON.FFIELD'
906 ! include 'COMMON.INTERACT'
907 ! include 'COMMON.MD'
908 ! include 'COMMON.TIME1'
909 real(kind=8),dimension(6*nres) :: z,d_a_tmp !(maxres6) maxres6=6*maxres
910 real(kind=8) :: edum(0:n_ene),time_order(0:10)
911 !el real(kind=8),dimension(2*nres,2*nres) :: Gcopy !(maxres2,maxres2) maxres2=2*maxres
912 !el common /przechowalnia/ Gcopy
916 real(kind=8) :: time00
917 integer :: iorder,i,j,nres2,ierr,ierror
920 if(.not.allocated(Gcopy)) allocate(Gcopy(nres2,nres2))
922 if(.not.allocated(Ginv)) allocate(Ginv(nres2,nres2)) !(maxres2,maxres2)
925 if(.not.allocated(ng_start)) allocate(ng_start(0:nfgtasks-1))
926 if(.not.allocated(ng_counts)) allocate(ng_counts(0:nfgtasks-1))
927 if(.not.allocated(nginv_counts)) allocate(nginv_counts(0:nfgtasks-1)) !(0:MaxProcs-1)
928 if(.not.allocated(nginv_start)) allocate(nginv_start(0:nfgtasks)) !(0:MaxProcs)
930 if(.not.allocated(fricmat)) allocate(fricmat(nres2,nres2)) !maxres2=2*maxres
932 ! Workers wait for variables and NF, and NFL from the boss
934 do while (iorder.ge.0)
935 ! write (*,*) 'Processor',fg_rank,' CG group',kolor,
936 ! & ' receives order from Master'
938 call MPI_Bcast(iorder,1,MPI_INTEGER,king,FG_COMM,IERR)
939 time_Bcast=time_Bcast+MPI_Wtime()-time00
940 if (icall.gt.4 .and. iorder.ge.0) &
941 time_order(iorder)=time_order(iorder)+MPI_Wtime()-time00
944 ! & 'Processor',fg_rank,' completed receive MPI_BCAST order',iorder
945 if (iorder.eq.0) then
948 ! write (2,*) "After etotal"
949 ! write (2,*) "dimen",dimen," dimen3",dimen3
951 else if (iorder.eq.2) then
953 call etotal_short(edum)
954 ! write (2,*) "After etotal_short"
955 ! write (2,*) "dimen",dimen," dimen3",dimen3
957 else if (iorder.eq.3) then
959 call etotal_long(edum)
960 ! write (2,*) "After etotal_long"
961 ! write (2,*) "dimen",dimen," dimen3",dimen3
963 else if (iorder.eq.1) then
965 ! write (2,*) "After sum_gradient"
966 ! write (2,*) "dimen",dimen," dimen3",dimen3
968 else if (iorder.eq.4) then
969 call ginv_mult(z,d_a_tmp)
970 else if (iorder.eq.5) then
971 ! Setup MD things for a slave
972 dimen=(nct-nnt+1)+nside
973 dimen1=(nct-nnt)+(nct-nnt+1)
975 ! write (2,*) "dimen",dimen," dimen3",dimen3
977 call int_bounds(dimen,igmult_start,igmult_end)
978 igmult_start=igmult_start-1
979 call MPI_Allgather(3*igmult_start,1,MPI_INTEGER,&
980 ng_start(0),1,MPI_INTEGER,FG_COMM,IERROR)
981 my_ng_count=igmult_end-igmult_start
982 call MPI_Allgather(3*my_ng_count,1,MPI_INTEGER,ng_counts(0),1,&
983 MPI_INTEGER,FG_COMM,IERROR)
984 write (2,*) "ng_start",(ng_start(i),i=0,nfgtasks-1) !sp
985 ! write (2,*) "ng_counts",(ng_counts(i),i=0,nfgtasks-1)
986 myginv_ng_count=nres2*my_ng_count !el maxres2
987 ! write (2,*) "igmult_start",igmult_start," igmult_end",
988 ! & igmult_end," my_ng_count",my_ng_count
990 call MPI_Allgather(nres2*igmult_start,1,MPI_INTEGER,& !el maxres2
991 nginv_start(0),1,MPI_INTEGER,FG_COMM,IERROR)
992 call MPI_Allgather(myginv_ng_count,1,MPI_INTEGER,&
993 nginv_counts(0),1,MPI_INTEGER,FG_COMM,IERROR)
994 ! write (2,*) "nginv_start",(nginv_start(i),i=0,nfgtasks-1)
995 ! write (2,*) "nginv_counts",(nginv_counts(i),i=0,nfgtasks-1)
997 ! call MPI_Barrier(FG_COMM,IERROR)
999 call MPI_Scatterv(ginv(1,1),nginv_counts(0),&
1000 nginv_start(0),MPI_DOUBLE_PRECISION,gcopy(1,1),&
1001 myginv_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
1003 time_scatter_ginv=time_scatter_ginv+MPI_Wtime()-time00
1006 do j=1,2*my_ng_count
1007 ginv(j,i)=gcopy(i,j)
1010 ! write (2,*) "dimen",dimen," dimen3",dimen3
1011 ! write (2,*) "End MD setup"
1013 ! write (iout,*) "My chunk of ginv_block"
1014 ! call MATOUT2(my_ng_count,dimen3,maxres2,maxers2,ginv_block)
1015 else if (iorder.eq.6) then
1016 call int_from_cart1(.false.)
1017 else if (iorder.eq.7) then
1018 call chainbuild_cart
1019 else if (iorder.eq.8) then
1021 else if (iorder.eq.9) then
1022 call fricmat_mult(z,d_a_tmp)
1023 else if (iorder.eq.10) then
1027 write (*,*) 'Processor',fg_rank,' CG group',kolor,&
1028 ' absolute rank',myrank,' leves ERGASTULUM.'
1029 write(*,*)'Processor',fg_rank,' wait times for respective orders',&
1030 (' order[',i,']',time_order(i),i=0,10)
1032 end subroutine ergastulum