Changeset bd2278d for partem_p.f


Ignore:
Timestamp:
09/05/08 11:49:42 (16 years ago)
Author:
baerbaer <baerbaer@…>
Branches:
master
Children:
fafe4d6
Parents:
2ebb8b6
Message:

Reformatting comments and continuation marks.

Fortran 90 and higher use ! to mark comments no matter where they are in the
code. The only valid continuation marker is &.
I also added the SMMP.kdevelop.filelist to the repository to make it easier
to use kdevelop.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@12 26dc1dd8-5c4e-0410-9ffe-d298b4865968

File:
1 edited

Legend:

Unmodified
Added
Removed
  • partem_p.f

    r2ebb8b6 rbd2278d  
    1 c**************************************************************
    2 c     
    3 c This file contains the subroutines: partem_p
    4 C USE WITH main_p, NOT WITH main!!!!!!
    5 c     
    6 c Copyright 2003-2005  Frank Eisenmenger, U.H.E. Hansmann,
    7 c                      Shura Hayryan, Chin-Ku
    8 c Copyright 2007       Frank Eisenmenger, U.H.E. Hansmann,
    9 c                      Jan H. Meinke, Sandipan Mohanty
    10 c     
    11 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!     **************************************************************
    1212
    1313      subroutine  partem_p(num_rep, nequi, nswp, nmes, nsave, newsta,
    1414     &                     switch, rep_id, partem_comm)
    15 C     
    16 C     PURPOSE: SIMULATION OF PROTEINS BY PARALLEL TEMPERING ALGORITHM
    17 C     ON PARALLEL COMPUTERS USING MPI
    18 C     
    19 C     switch: Choses the starting configuration:
    20 C     -1 - stretched configuration
    21 C     0 - don't change anything
    22 C     1 - random start configuration
    23 C     
    24 c     CALLS:  addang,contacts,energy,hbond,helix,iendst,metropolis,
    25 c     outvar,(rand),rgyr
    26 C     
     15!     
     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!     
    2727      include 'INCL.H'
    2828      include 'INCP.H'
     
    3131      logical newsta
    3232      integer switch, partem_comm, rep_id, nsave
    33 c     external rand
     33!     external rand
    3434      external can_weight
    3535
    36 C     nequi:  number of Monte Carlo sweeps for thermalization
    37 C     nswp:   number of Monte Carlo sweeps
    38 C     nmes:   number of Monte Carlo sweeps between measurments
    39 C     newsta: .true. for new simulations, .false. for re-start
     36!     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
    4040
    4141      dimension  eavm(MAX_PROC),sph(MAX_PROC),intem(MAX_PROC),
     
    4747      double precision    e_min, e_minp(MAX_PROC), e_minpt(MAX_PROC)
    4848      integer   h_max, h_maxp(MAX_PROC)
    49 c     Order of replica exchange
     49!     Order of replica exchange
    5050      integer   odd
    5151!     Counter to keep random number generators in sync
    5252      integer randomCount
    5353     
    54 c     Collect partial energies. Only the root writes to disk. We have to
    55 c     collect the information from the different replicas and provide
    56 c     arrays to store them.
    57 c     eyslr    storage array for solvent energy
    58 c     eyelp     -      "        - coulomb energy
    59 c     eyvwp     -      "        - van-der-Waals energy
    60 c     eyhbp     -      "        - hydrogen bonding energy
    61 c     eysmi    -      "        - intermolecular interaction energy
    62 c     eyabp     -      "        - Abagyan correction term
     54!     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
    6363      double precision eyslr(MAX_PROC)
    6464      double precision eyelp(MAX_PROC),eyvwp(MAX_PROC),eyhbp(MAX_PROC),
    6565     &     eyvrp(MAX_PROC),eysmip(MAX_PROC), eyabp(MAX_PROC)
    66 c     Collect information about accessible surface and van-der-Waals volume
    67 c     asap      storage array for solvent accessible surface
    68 c     vdvolp     storage array for van-der-Waals volume
     66!     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
    6969      double precision asap(MAX_PROC), vdvolp(MAX_PROC)
    7070
     
    7373      integer imhbp(MAX_PROC)
    7474      character*80 filebase, fileNameMP, tbase0,tbase1
    75 c     frame     frame number for writing configurations
    76 c     trackID   configuration that should be tracked and written out
    77 c     dir          direction in random walk
    78 c     -1 - visited highest temperature last
    79 c     1 - visited lowest temperature last
    80 c     0 - haven't visited the boundaries yet.
    81 c     dirp      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.
    8282      integer frame, trackID, dir
    8383      integer dirp(MAX_PROC)
     
    9090     &            rep_id, num_rep, partem_comm, myrank
    9191      call flush(6)
    92 C     
    93 c     
    94 C     File with temperatures
     92!     
     93!     
     94!     File with temperatures
    9595      open(11,file='temperatures',status='old')
    96 C     File with reference conformation
     96!     File with reference conformation
    9797      tbase0='trj_00000'
    9898      open(18,file=fileNameMP(tbase0,5,9,rep_id),status='unknown')
    9999      if (rep_id.eq.0.and.myrank.eq.0) then
    100 c     File with time series of simulation
     100!     File with time series of simulation
    101101         open(14,file='ts.d',status='unknown')
    102 c     Track weights
    103 c      open(16, file='weights.dat', status='unknown')
     102!     Track weights
     103!      open(16, file='weights.dat', status='unknown')
    104104      endif
    105105     
    106 C     READ IN TEMPERATURES
     106!     READ IN TEMPERATURES
    107107      do i=1,num_rep
    108108         read(11,*) j,temp
     
    111111      close(11)
    112112
    113 c     nresi:  number of residues
     113!     nresi:  number of residues
    114114      nresi=irsml2(1)-irsml1(1)+1
    115 C     
    116 C     Initialize variables
     115!     
     116!     Initialize variables
    117117      do i=1,num_rep     
    118118         acx1(i) = 0.0d0
     
    132132      dir = dirp(rep_id + 1)
    133133
    134 c     _________________________________ Initialize Variables
     134!     _________________________________ Initialize Variables
    135135      if(newsta) then
    136136         iold=0
     
    139139            intem(i) = i
    140140         end do
    141 c     _________________________________ initialize starting configuration
     141!     _________________________________ initialize starting configuration
    142142         if (switch.ne.0) then
    143143            do i=1,nvr
     
    178178         CALL MPI_BCAST(INODE,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD,IERR)
    179179         CALL MPI_BCAST(YOL,num_rep,MPI_DOUBLE_PRECISION,0,
    180      #        MPI_COMM_WORLD,IERR)
     180     &        MPI_COMM_WORLD,IERR)
    181181         CALL MPI_BCAST(E_MINP, num_rep, MPI_DOUBLE_PRECISION, 0,
    182      #        MPI_COMM_WORLD, IERR)
     182     &        MPI_COMM_WORLD, IERR)
    183183         CALL MPI_BCAST(h_maxp,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD,
    184      $        IERR)
     184     &        IERR)
    185185      end if
    186186     
     
    194194         write(*,*) rep_id, yol(rep_id + 1), eol
    195195      endif
    196 C     Start of simulation
     196!     Start of simulation
    197197      write (*,*) '[',rep_id, myrank, beta, partem_comm,
    198198     &            '] Energy before equilibration:', eol
    199 c     =====================Equilibration by canonical Metropolis
     199!     =====================Equilibration by canonical Metropolis
    200200      do nsw=1,nequi
    201201         call metropolis(eol,acz,can_weight)
     
    204204      write (*,*) '[',rep_id,'] Energy after equilibration:', eol
    205205      call flush(6)
    206 C     
    207 C======================Multiple Markov Chains
     206!     
     207!======================Multiple Markov Chains
    208208      acz = 0
    209209      do nsw=1,nswp
    210 c------------First ordinary Metropolis
     210!------------First ordinary Metropolis
    211211         call metropolis(eol,acz,can_weight)
    212212         iold = iold + 1       
     
    223223            endif
    224224            acz0 = acz
    225 c     Evaluate RMSD
     225!     Evaluate RMSD
    226226            nml = 1
    227227            rmsv = rmsdfun(nml,irsml1(nml),irsml2(nml),ixatp,xatp,yatp, &
    228228     &             zatp,0)
    229 c            print *,myrank,'received RMSD,energy ',rmsv,eyab,beta
    230 C     Measure global radius of gyration
     229!            print *,myrank,'received RMSD,energy ',rmsv,eyab,beta
     230!     Measure global radius of gyration
    231231            call rgyr(0,rgy,ee) 
    232232            rgyp = rgy
    233 C     Measure Helicity and Sheetness
     233!     Measure Helicity and Sheetness
    234234            call helix(nhel,mhel,nbet,mbet)
    235 C     Measure Number of hydrogen bonds
     235!     Measure Number of hydrogen bonds
    236236            mhb = 0
    237237            do i = 1, ntlml
     
    240240            enddo
    241241            call interhbond(imhb)
    242 C     Measure total number of contacts (NCTOT) and number of
    243 C     native contacts (NCNAT)
     242!     Measure total number of contacts (NCTOT) and number of
     243!     native contacts (NCNAT)
    244244            call contacts(nctot,ncnat,dham)
    245 c     Add tracking of lowest energy configuration
     245!     Add tracking of lowest energy configuration
    246246            if (eol.lt.e_min) then
    247 c     Write out configuration
     247!     Write out configuration
    248248               i=rep_id+1
    249249               j=inode(i)
     
    262262               close(15)
    263263            endif
    264 c     Add tracking of configuration with larges hydrogen contents.
     264!     Add tracking of configuration with larges hydrogen contents.
    265265            if ((mhb + imhb).gt.h_max) then
    266 c     Write out configuration
     266!     Write out configuration
    267267               i = rep_id + 1
    268268               j = inode(i)
     
    282282            endif
    283283
    284 C     
    285 C--------------------Gather measurement data
     284!     
     285!--------------------Gather measurement data
    286286! I only use the master node of each replica for data collection. The
    287287! variable partem_comm provides the appropriate communicator.
    288288            if (partem_comm.ne.MPI_COMM_NULL) then
    289289               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)
    291291               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)
    293293               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)
    295295               CALL MPI_GATHER(NHEL,1,MPI_INTEGER,NHELP,1,MPI_INTEGER,
    296296     &              0,partem_comm,IERR)
     
    335335!     &                0,MPI_COMM_WORLD, IERR)               
    336336
    337 c     Write trajectory
     337!     Write trajectory
    338338               write (18,*) '@@@',iold,inode(rep_id+1)
    339339               call outvbs(0,18)
    340340               write (18,*) '###'
    341341!                call flush(18)
    342 c     Write current configuration
     342!     Write current configuration
    343343               if ((mod(iold, nsave).eq.0)) then
    344344                  filebase = "conf_0000.var"
     
    349349            if(rep_id.eq.0.and.myrank.eq.0) then
    350350               randomCount = 0
    351 c  Update acceptance, temperature wise average of E and E^2 used to calculate
    352 c  specific heat.
     351!  Update acceptance, temperature wise average of E and E^2 used to calculate
     352!  specific heat.
    353353               do i=1,num_rep
    354354                  j=intem(i)
    355355                  acy(i)=0.0
    356 c  Above: contents of acy1 are added to acy(i) a few lines down.
    357 c  acy1(intem(i)) contains information received from the node at temperature
    358 c  i, on how many updates have been accepted in node intem(i). Since acz
    359 c  is not reset to 0 every cycle, acy(i) must be set to 0 here. Else, there
    360 c  will be serious double counting and the values of acceptance printed
    361 c  will 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.
    362362                  e_minpt(i)=e_minp(intem(i))
    363363               end do
     
    371371
    372372
    373 C     Write measurements to the time series file ts.d
     373!     Write measurements to the time series file ts.d
    374374               do i=1,num_rep
    375375                  j=intem(i)
     
    382382!                      call flush(14)
    383383               end do
    384 c     Write the current parallel tempering information into par_R.in
     384!     Write the current parallel tempering information into par_R.in
    385385!               timeLeft = llwrem(2) ! Time left till hard limit
    386386!               if ((mod(iold, nsave).eq.0).or.(timeLeft.lt.minTimeLeft)
     
    393393     &                    h_maxp(i)
    394394                  end do
    395 C     -------------------------- Various statistics of current run
    396 c               swp=nswp-nequi
     395!     -------------------------- Various statistics of current run
     396!               swp=nswp-nequi
    397397                  swp=nsw
    398398                  write(13,*) 'Acceptance rate for change of chains:'
     
    400400                     temp=1.0d0/pbe(k1)/0.00198773
    401401                     write(13,*) temp, acx1(k1)*2.0d0*nmes/swp
    402 c  Above: it's the acceptance rate of exchange of replicas. Since a
    403 c  replica exchange is attempted only once every nmes sweeps, the
    404 c  rate 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).
    405405                  end do
    406406                  write(13,*)
     
    411411                     geavm(k1) = nmes*eavm(k1)/swp
    412412                     gsph(k1)  = (nmes*sph(k1)/swp-geavm(k1)**2)
    413      #                    *beta*beta/nresi
     413     &                    *beta*beta/nresi
    414414                     write(13,'(a,2f9.2,i4,f12.3)')
    415415     &                    'Temperature, Node,local acceptance rate:',
    416416     &                    beta,temp,k,acy(k1)/dble(nsw*nvr)
    417 c  Above: Changed (nswp-nequi) in the denominator of acceptance as
    418 c  acceptance values are initialized to 0 after equilibration cycles are
    419 c  finished. Note also that since this is being written in the middle of
    420 c  the 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.
    421421                     write(13,'(a,3f12.2)')
    422422     &                    'Last Energy, Average Energy, Spec. Heat:',
     
    431431               end if
    432432
    433 C--------------------Parallel Tempering  update
    434 c     Swap with right neighbor (odd, even)           
     433!--------------------Parallel Tempering  update
     434!     Swap with right neighbor (odd, even)           
    435435               if(odd.eq.1) then
    436436                  nu=1
    437437                  no1 = num_rep-1
    438 c     Swap with left neighbor (even, odd)
     438!     Swap with left neighbor (even, odd)
    439439               else
    440440                  nu = 2
     
    443443               do i=nu,no1,2
    444444                  j=i+1
    445 c     Periodic bc for swaps
     445!     Periodic bc for swaps
    446446                  if(i.eq.num_rep) j=1
    447447                  in=intem(i)
     
    449449                  wij=exp(-pbe(i)*yol(jn)-pbe(j)*yol(in)
    450450     &                 +pbe(i)*yol(in)+pbe(j)*yol(jn))
    451 c The random number generator is getting out of sync here, because
    452 c        the 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!
    453453! Keep track of number of random numbers used.
    454454                  rd=grnd()
    455455                  randomCount = randomCount + 1
    456 c                  write (16,*) '>', iold, i,j
    457 c     &            ,pbe(i),yol(in), pbe(j), yol(jn), wij, rd
     456!                  write (16,*) '>', iold, i,j
     457!     &            ,pbe(i),yol(in), pbe(j), yol(jn), wij, rd
    458458                  if(wij.ge.rd) then
    459 c Next line: Replica exchange only happens after equilibration,
    460 c which takes place outside this loop over nsw. So, I think nsw.gt.nequi
    461 c is irrelevant for the calculation of acceptance of replica exchanges.
    462 c /Sandipan
    463 c                     if(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)
    464464                     acx1(i) = acx1(i)+1
    465465                     intem(i) = jn
     
    469469                  end if
    470470               end do
    471 c     ---------------- End Loop over nodes which creates a new temperature
    472 c     map for all nodes, at the node with rank 0.
    473 c     
     471!     ---------------- End Loop over nodes which creates a new temperature
     472!     map for all nodes, at the node with rank 0.
     473!     
    474474               odd = 1 - odd
    475475            end if
    476 c     End of "if (myrank.eq.0) ...". The block above includes PT update and
    477 c     writing 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.
    478478           
    479 c     Below: Communicate new temperature-node map to all nodes
     479!     Below: Communicate new temperature-node map to all nodes
    480480            CALL MPI_BCAST(INTEM,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD,
    481481     &           IERR)
     
    486486            CALL MPI_BCAST(H_MAXP,num_rep,MPI_INTEGER,0,MPI_COMM_WORLD,
    487487     &           IERR)
    488 c Synchronize random number generators for replica 0
     488! Synchronize random number generators for replica 0
    489489            if (rep_id.eq.0) then
    490490               CALL MPI_BCAST(randomCount,1,MPI_INTEGER,0,my_mpi_comm,
     
    507507
    508508         endif
    509 c        End of "if (mod(iold,nmes).eq.0) ..."
     509!        End of "if (mod(iold,nmes).eq.0) ..."
    510510      end do
    511 c-----------End Loop over sweeps
    512 c     
    513 C     OUTPUT:
    514 C--------------------For Re-starts:
     511!-----------End Loop over sweeps
     512!     
     513!     OUTPUT:
     514!--------------------For Re-starts:
    515515      nu = rep_id + 1
    516516      filebase = "conf_0000.var"
     
    524524      if (partem_comm.ne.MPI_COMM_NULL) then
    525525         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)
    527527         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)
    529529      endif
    530530     
     
    536536            write(13,*) i,inode(i),intem(i),yol(i),e_minp(i),h_maxp(i)
    537537         end do
    538 C     -------------------------- Various statistics of current run
     538!     -------------------------- Various statistics of current run
    539539         swp=nswp
    540540         write(13,*) 'Acceptance rate for change of chains:'
     
    559559         end do
    560560         close(13)
    561 c         close(16)
     561!         close(16)
    562562      end if
    563563      close(18)
    564564
    565 c     =====================
     565!     =====================
    566566      CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)
    567567
Note: See TracChangeset for help on using the changeset viewer.