Changeset bd2278d for partem_p.f
- Timestamp:
- 09/05/08 11:49:42 (16 years ago)
- Branches:
- master
- Children:
- fafe4d6
- Parents:
- 2ebb8b6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
partem_p.f
r2ebb8b6 rbd2278d 1 c**************************************************************2 c3 cThis file contains the subroutines: partem_p4 CUSE WITH main_p, NOT WITH main!!!!!!5 c6 cCopyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,7 cShura Hayryan, Chin-Ku8 cCopyright 2007 Frank Eisenmenger, U.H.E. Hansmann,9 cJan H. Meinke, Sandipan Mohanty10 c11 c**************************************************************1 !************************************************************** 2 ! 3 ! This file contains the subroutines: partem_p 4 ! USE WITH main_p, NOT WITH main!!!!!! 5 ! 6 ! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann, 7 ! Shura Hayryan, Chin-Ku 8 ! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann, 9 ! Jan H. Meinke, Sandipan Mohanty 10 ! 11 ! ************************************************************** 12 12 13 13 subroutine partem_p(num_rep, nequi, nswp, nmes, nsave, newsta, 14 14 & switch, rep_id, partem_comm) 15 C16 CPURPOSE: SIMULATION OF PROTEINS BY PARALLEL TEMPERING ALGORITHM17 CON PARALLEL COMPUTERS USING MPI18 C19 Cswitch: Choses the starting configuration:20 C-1 - stretched configuration21 C0 - don't change anything22 C1 - random start configuration23 C24 cCALLS: addang,contacts,energy,hbond,helix,iendst,metropolis,25 coutvar,(rand),rgyr26 C15 ! 16 ! PURPOSE: SIMULATION OF PROTEINS BY PARALLEL TEMPERING ALGORITHM 17 ! ON PARALLEL COMPUTERS USING MPI 18 ! 19 ! switch: Choses the starting configuration: 20 ! -1 - stretched configuration 21 ! 0 - don't change anything 22 ! 1 - random start configuration 23 ! 24 ! CALLS: addang,contacts,energy,hbond,helix,iendst,metropolis, 25 ! outvar,(rand),rgyr 26 ! 27 27 include 'INCL.H' 28 28 include 'INCP.H' … … 31 31 logical newsta 32 32 integer switch, partem_comm, rep_id, nsave 33 cexternal rand33 ! external rand 34 34 external can_weight 35 35 36 Cnequi: number of Monte Carlo sweeps for thermalization37 Cnswp: number of Monte Carlo sweeps38 Cnmes: number of Monte Carlo sweeps between measurments39 Cnewsta: .true. for new simulations, .false. for re-start36 ! nequi: number of Monte Carlo sweeps for thermalization 37 ! nswp: number of Monte Carlo sweeps 38 ! nmes: number of Monte Carlo sweeps between measurments 39 ! newsta: .true. for new simulations, .false. for re-start 40 40 41 41 dimension eavm(MAX_PROC),sph(MAX_PROC),intem(MAX_PROC), … … 47 47 double precision e_min, e_minp(MAX_PROC), e_minpt(MAX_PROC) 48 48 integer h_max, h_maxp(MAX_PROC) 49 cOrder of replica exchange49 ! Order of replica exchange 50 50 integer odd 51 51 ! Counter to keep random number generators in sync 52 52 integer randomCount 53 53 54 cCollect partial energies. Only the root writes to disk. We have to55 ccollect the information from the different replicas and provide56 carrays to store them.57 ceyslr storage array for solvent energy58 ceyelp - " - coulomb energy59 ceyvwp - " - van-der-Waals energy60 ceyhbp - " - hydrogen bonding energy61 ceysmi - " - intermolecular interaction energy62 ceyabp - " - Abagyan correction term54 ! Collect partial energies. Only the root writes to disk. We have to 55 ! collect the information from the different replicas and provide 56 ! arrays to store them. 57 ! eyslr storage array for solvent energy 58 ! eyelp - " - coulomb energy 59 ! eyvwp - " - van-der-Waals energy 60 ! eyhbp - " - hydrogen bonding energy 61 ! eysmi - " - intermolecular interaction energy 62 ! eyabp - " - Abagyan correction term 63 63 double precision eyslr(MAX_PROC) 64 64 double precision eyelp(MAX_PROC),eyvwp(MAX_PROC),eyhbp(MAX_PROC), 65 65 & eyvrp(MAX_PROC),eysmip(MAX_PROC), eyabp(MAX_PROC) 66 cCollect information about accessible surface and van-der-Waals volume67 casap storage array for solvent accessible surface68 cvdvolp storage array for van-der-Waals volume66 ! Collect information about accessible surface and van-der-Waals volume 67 ! asap storage array for solvent accessible surface 68 ! vdvolp storage array for van-der-Waals volume 69 69 double precision asap(MAX_PROC), vdvolp(MAX_PROC) 70 70 … … 73 73 integer imhbp(MAX_PROC) 74 74 character*80 filebase, fileNameMP, tbase0,tbase1 75 cframe frame number for writing configurations76 ctrackID configuration that should be tracked and written out77 cdir direction in random walk78 c-1 - visited highest temperature last79 c1 - visited lowest temperature last80 c0 - haven't visited the boundaries yet.81 cdirp storage array for directions.75 ! frame frame number for writing configurations 76 ! trackID configuration that should be tracked and written out 77 ! dir direction in random walk 78 ! -1 - visited highest temperature last 79 ! 1 - visited lowest temperature last 80 ! 0 - haven't visited the boundaries yet. 81 ! dirp storage array for directions. 82 82 integer frame, trackID, dir 83 83 integer dirp(MAX_PROC) … … 90 90 & rep_id, num_rep, partem_comm, myrank 91 91 call flush(6) 92 C93 c94 CFile with temperatures92 ! 93 ! 94 ! File with temperatures 95 95 open(11,file='temperatures',status='old') 96 CFile with reference conformation96 ! File with reference conformation 97 97 tbase0='trj_00000' 98 98 open(18,file=fileNameMP(tbase0,5,9,rep_id),status='unknown') 99 99 if (rep_id.eq.0.and.myrank.eq.0) then 100 cFile with time series of simulation100 ! File with time series of simulation 101 101 open(14,file='ts.d',status='unknown') 102 cTrack weights103 copen(16, file='weights.dat', status='unknown')102 ! Track weights 103 ! open(16, file='weights.dat', status='unknown') 104 104 endif 105 105 106 CREAD IN TEMPERATURES106 ! READ IN TEMPERATURES 107 107 do i=1,num_rep 108 108 read(11,*) j,temp … … 111 111 close(11) 112 112 113 cnresi: number of residues113 ! nresi: number of residues 114 114 nresi=irsml2(1)-irsml1(1)+1 115 C116 CInitialize variables115 ! 116 ! Initialize variables 117 117 do i=1,num_rep 118 118 acx1(i) = 0.0d0 … … 132 132 dir = dirp(rep_id + 1) 133 133 134 c_________________________________ Initialize Variables134 ! _________________________________ Initialize Variables 135 135 if(newsta) then 136 136 iold=0 … … 139 139 intem(i) = i 140 140 end do 141 c_________________________________ initialize starting configuration141 ! _________________________________ initialize starting configuration 142 142 if (switch.ne.0) then 143 143 do i=1,nvr … … 178 178 CALL MPI_BCAST(INODE,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD,IERR) 179 179 CALL MPI_BCAST(YOL,num_rep,MPI_DOUBLE_PRECISION,0, 180 #MPI_COMM_WORLD,IERR)180 & MPI_COMM_WORLD,IERR) 181 181 CALL MPI_BCAST(E_MINP, num_rep, MPI_DOUBLE_PRECISION, 0, 182 #MPI_COMM_WORLD, IERR)182 & MPI_COMM_WORLD, IERR) 183 183 CALL MPI_BCAST(h_maxp,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD, 184 $IERR)184 & IERR) 185 185 end if 186 186 … … 194 194 write(*,*) rep_id, yol(rep_id + 1), eol 195 195 endif 196 CStart of simulation196 ! Start of simulation 197 197 write (*,*) '[',rep_id, myrank, beta, partem_comm, 198 198 & '] Energy before equilibration:', eol 199 c=====================Equilibration by canonical Metropolis199 ! =====================Equilibration by canonical Metropolis 200 200 do nsw=1,nequi 201 201 call metropolis(eol,acz,can_weight) … … 204 204 write (*,*) '[',rep_id,'] Energy after equilibration:', eol 205 205 call flush(6) 206 C207 C======================Multiple Markov Chains206 ! 207 !======================Multiple Markov Chains 208 208 acz = 0 209 209 do nsw=1,nswp 210 c------------First ordinary Metropolis210 !------------First ordinary Metropolis 211 211 call metropolis(eol,acz,can_weight) 212 212 iold = iold + 1 … … 223 223 endif 224 224 acz0 = acz 225 cEvaluate RMSD225 ! Evaluate RMSD 226 226 nml = 1 227 227 rmsv = rmsdfun(nml,irsml1(nml),irsml2(nml),ixatp,xatp,yatp, & 228 228 & zatp,0) 229 cprint *,myrank,'received RMSD,energy ',rmsv,eyab,beta230 CMeasure global radius of gyration229 ! print *,myrank,'received RMSD,energy ',rmsv,eyab,beta 230 ! Measure global radius of gyration 231 231 call rgyr(0,rgy,ee) 232 232 rgyp = rgy 233 CMeasure Helicity and Sheetness233 ! Measure Helicity and Sheetness 234 234 call helix(nhel,mhel,nbet,mbet) 235 CMeasure Number of hydrogen bonds235 ! Measure Number of hydrogen bonds 236 236 mhb = 0 237 237 do i = 1, ntlml … … 240 240 enddo 241 241 call interhbond(imhb) 242 CMeasure total number of contacts (NCTOT) and number of243 Cnative contacts (NCNAT)242 ! Measure total number of contacts (NCTOT) and number of 243 ! native contacts (NCNAT) 244 244 call contacts(nctot,ncnat,dham) 245 cAdd tracking of lowest energy configuration245 ! Add tracking of lowest energy configuration 246 246 if (eol.lt.e_min) then 247 cWrite out configuration247 ! Write out configuration 248 248 i=rep_id+1 249 249 j=inode(i) … … 262 262 close(15) 263 263 endif 264 cAdd tracking of configuration with larges hydrogen contents.264 ! Add tracking of configuration with larges hydrogen contents. 265 265 if ((mhb + imhb).gt.h_max) then 266 cWrite out configuration266 ! Write out configuration 267 267 i = rep_id + 1 268 268 j = inode(i) … … 282 282 endif 283 283 284 C285 C--------------------Gather measurement data284 ! 285 !--------------------Gather measurement data 286 286 ! I only use the master node of each replica for data collection. The 287 287 ! variable partem_comm provides the appropriate communicator. 288 288 if (partem_comm.ne.MPI_COMM_NULL) then 289 289 CALL MPI_GATHER(rmsv,1,MPI_DOUBLE_PRECISION,rmsdp,1, 290 #MPI_DOUBLE_PRECISION, 0,partem_comm,IERR)290 & MPI_DOUBLE_PRECISION, 0,partem_comm,IERR) 291 291 CALL MPI_GATHER(eyab,1,MPI_DOUBLE_PRECISION,eyabp,1, 292 #MPI_DOUBLE_PRECISION, 0,partem_comm,IERR)292 & MPI_DOUBLE_PRECISION, 0,partem_comm,IERR) 293 293 CALL MPI_GATHER(RGYP,1,MPI_DOUBLE_PRECISION,RGYRP,1, 294 #MPI_DOUBLE_PRECISION, 0,partem_comm,IERR)294 & MPI_DOUBLE_PRECISION, 0,partem_comm,IERR) 295 295 CALL MPI_GATHER(NHEL,1,MPI_INTEGER,NHELP,1,MPI_INTEGER, 296 296 & 0,partem_comm,IERR) … … 335 335 ! & 0,MPI_COMM_WORLD, IERR) 336 336 337 cWrite trajectory337 ! Write trajectory 338 338 write (18,*) '@@@',iold,inode(rep_id+1) 339 339 call outvbs(0,18) 340 340 write (18,*) '###' 341 341 ! call flush(18) 342 cWrite current configuration342 ! Write current configuration 343 343 if ((mod(iold, nsave).eq.0)) then 344 344 filebase = "conf_0000.var" … … 349 349 if(rep_id.eq.0.and.myrank.eq.0) then 350 350 randomCount = 0 351 cUpdate acceptance, temperature wise average of E and E^2 used to calculate352 cspecific heat.351 ! Update acceptance, temperature wise average of E and E^2 used to calculate 352 ! specific heat. 353 353 do i=1,num_rep 354 354 j=intem(i) 355 355 acy(i)=0.0 356 cAbove: contents of acy1 are added to acy(i) a few lines down.357 cacy1(intem(i)) contains information received from the node at temperature358 ci, on how many updates have been accepted in node intem(i). Since acz359 cis not reset to 0 every cycle, acy(i) must be set to 0 here. Else, there360 cwill be serious double counting and the values of acceptance printed361 cwill be simply wrong.356 ! Above: contents of acy1 are added to acy(i) a few lines down. 357 ! acy1(intem(i)) contains information received from the node at temperature 358 ! i, on how many updates have been accepted in node intem(i). Since acz 359 ! is not reset to 0 every cycle, acy(i) must be set to 0 here. Else, there 360 ! will be serious double counting and the values of acceptance printed 361 ! will be simply wrong. 362 362 e_minpt(i)=e_minp(intem(i)) 363 363 end do … … 371 371 372 372 373 CWrite measurements to the time series file ts.d373 ! Write measurements to the time series file ts.d 374 374 do i=1,num_rep 375 375 j=intem(i) … … 382 382 ! call flush(14) 383 383 end do 384 cWrite the current parallel tempering information into par_R.in384 ! Write the current parallel tempering information into par_R.in 385 385 ! timeLeft = llwrem(2) ! Time left till hard limit 386 386 ! if ((mod(iold, nsave).eq.0).or.(timeLeft.lt.minTimeLeft) … … 393 393 & h_maxp(i) 394 394 end do 395 C-------------------------- Various statistics of current run396 cswp=nswp-nequi395 ! -------------------------- Various statistics of current run 396 ! swp=nswp-nequi 397 397 swp=nsw 398 398 write(13,*) 'Acceptance rate for change of chains:' … … 400 400 temp=1.0d0/pbe(k1)/0.00198773 401 401 write(13,*) temp, acx1(k1)*2.0d0*nmes/swp 402 cAbove: it's the acceptance rate of exchange of replicas. Since a403 creplica exchange is attempted only once every nmes sweeps, the404 crate should be normalized with (nmes/swp).402 ! Above: it's the acceptance rate of exchange of replicas. Since a 403 ! replica exchange is attempted only once every nmes sweeps, the 404 ! rate should be normalized with (nmes/swp). 405 405 end do 406 406 write(13,*) … … 411 411 geavm(k1) = nmes*eavm(k1)/swp 412 412 gsph(k1) = (nmes*sph(k1)/swp-geavm(k1)**2) 413 #*beta*beta/nresi413 & *beta*beta/nresi 414 414 write(13,'(a,2f9.2,i4,f12.3)') 415 415 & 'Temperature, Node,local acceptance rate:', 416 416 & beta,temp,k,acy(k1)/dble(nsw*nvr) 417 cAbove: Changed (nswp-nequi) in the denominator of acceptance as418 cacceptance values are initialized to 0 after equilibration cycles are419 cfinished. Note also that since this is being written in the middle of420 cthe simulation, it is normalized to nsw instead of nswp.417 ! Above: Changed (nswp-nequi) in the denominator of acceptance as 418 ! acceptance values are initialized to 0 after equilibration cycles are 419 ! finished. Note also that since this is being written in the middle of 420 ! the simulation, it is normalized to nsw instead of nswp. 421 421 write(13,'(a,3f12.2)') 422 422 & 'Last Energy, Average Energy, Spec. Heat:', … … 431 431 end if 432 432 433 C--------------------Parallel Tempering update434 cSwap with right neighbor (odd, even)433 !--------------------Parallel Tempering update 434 ! Swap with right neighbor (odd, even) 435 435 if(odd.eq.1) then 436 436 nu=1 437 437 no1 = num_rep-1 438 cSwap with left neighbor (even, odd)438 ! Swap with left neighbor (even, odd) 439 439 else 440 440 nu = 2 … … 443 443 do i=nu,no1,2 444 444 j=i+1 445 cPeriodic bc for swaps445 ! Periodic bc for swaps 446 446 if(i.eq.num_rep) j=1 447 447 in=intem(i) … … 449 449 wij=exp(-pbe(i)*yol(jn)-pbe(j)*yol(in) 450 450 & +pbe(i)*yol(in)+pbe(j)*yol(jn)) 451 cThe random number generator is getting out of sync here, because452 cthe swap is only done on node 0!451 ! The random number generator is getting out of sync here, because 452 ! the swap is only done on node 0! 453 453 ! Keep track of number of random numbers used. 454 454 rd=grnd() 455 455 randomCount = randomCount + 1 456 cwrite (16,*) '>', iold, i,j457 c& ,pbe(i),yol(in), pbe(j), yol(jn), wij, rd456 ! write (16,*) '>', iold, i,j 457 ! & ,pbe(i),yol(in), pbe(j), yol(jn), wij, rd 458 458 if(wij.ge.rd) then 459 cNext line: Replica exchange only happens after equilibration,460 cwhich takes place outside this loop over nsw. So, I think nsw.gt.nequi461 cis irrelevant for the calculation of acceptance of replica exchanges.462 c/Sandipan463 cif(nsw.gt.nequi)459 ! Next line: Replica exchange only happens after equilibration, 460 ! which takes place outside this loop over nsw. So, I think nsw.gt.nequi 461 ! is irrelevant for the calculation of acceptance of replica exchanges. 462 ! /Sandipan 463 ! if(nsw.gt.nequi) 464 464 acx1(i) = acx1(i)+1 465 465 intem(i) = jn … … 469 469 end if 470 470 end do 471 c---------------- End Loop over nodes which creates a new temperature472 cmap for all nodes, at the node with rank 0.473 c471 ! ---------------- End Loop over nodes which creates a new temperature 472 ! map for all nodes, at the node with rank 0. 473 ! 474 474 odd = 1 - odd 475 475 end if 476 cEnd of "if (myrank.eq.0) ...". The block above includes PT update and477 cwriting of observables into the time series file etc.476 ! End of "if (myrank.eq.0) ...". The block above includes PT update and 477 ! writing of observables into the time series file etc. 478 478 479 cBelow: Communicate new temperature-node map to all nodes479 ! Below: Communicate new temperature-node map to all nodes 480 480 CALL MPI_BCAST(INTEM,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD, 481 481 & IERR) … … 486 486 CALL MPI_BCAST(H_MAXP,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD, 487 487 & IERR) 488 cSynchronize random number generators for replica 0488 ! Synchronize random number generators for replica 0 489 489 if (rep_id.eq.0) then 490 490 CALL MPI_BCAST(randomCount,1,MPI_INTEGER,0,my_mpi_comm, … … 507 507 508 508 endif 509 cEnd of "if (mod(iold,nmes).eq.0) ..."509 ! End of "if (mod(iold,nmes).eq.0) ..." 510 510 end do 511 c-----------End Loop over sweeps512 c513 COUTPUT:514 C--------------------For Re-starts:511 !-----------End Loop over sweeps 512 ! 513 ! OUTPUT: 514 !--------------------For Re-starts: 515 515 nu = rep_id + 1 516 516 filebase = "conf_0000.var" … … 524 524 if (partem_comm.ne.MPI_COMM_NULL) then 525 525 CALL MPI_GATHER(EOL0,1,MPI_DOUBLE_PRECISION,YOL,1, 526 #MPI_DOUBLE_PRECISION,0,partem_comm,IERR)526 & MPI_DOUBLE_PRECISION,0,partem_comm,IERR) 527 527 CALL MPI_GATHER(acz0,1,MPI_DOUBLE_PRECISION,acy1,1, 528 #MPI_DOUBLE_PRECISION,0,partem_comm,IERR)528 & MPI_DOUBLE_PRECISION,0,partem_comm,IERR) 529 529 endif 530 530 … … 536 536 write(13,*) i,inode(i),intem(i),yol(i),e_minp(i),h_maxp(i) 537 537 end do 538 C-------------------------- Various statistics of current run538 ! -------------------------- Various statistics of current run 539 539 swp=nswp 540 540 write(13,*) 'Acceptance rate for change of chains:' … … 559 559 end do 560 560 close(13) 561 cclose(16)561 ! close(16) 562 562 end if 563 563 close(18) 564 564 565 c=====================565 ! ===================== 566 566 CALL MPI_BARRIER(MPI_COMM_WORLD,IERR) 567 567
Note:
See TracChangeset
for help on using the changeset viewer.