Академический Документы
Профессиональный Документы
Культура Документы
Fortran77
Why Fortran77?
Insert Mac OS X Installation DVD. Navigate to the Optional Installs: Xcode Tools
folder.
Uncheck all the components and check only Unix Development Support. In
particular, Developer Tools Essentials should be unchecked (saving you 2.5GB of
disk space)!
http://prdownloads.sourceforge.net/hpc/g77-intel-bin.tar.gz?download
http://prdownloads.sourceforge.net/hpc/g77-bin.tar.gz?download
The fortran77 compiler g77 does not apparently work well for the
Mavericks OS on Macs.
http://prdownloads.sourceforge.net/hpc/gfortran-4.8-bin.tar.gz?download
Advantages of FORCE
Install Force209GFortranSetup.exe
http://force.lepsch.com/2009/05/
downloads.html
Compile the program using the g77 command if you fortran77 compiler and the
gfortan command if you have gfortran compiler, i.e., if the program is named
nano.f and it uses a subroutine named sub.f, then type g77 nano.f sub.f at
the command prompt, which should produce an executable called a.out within the
same directory
To visualize the program, you can use any text editor. I personally prefer to use
the text editor that comes with Xcode, which colors the text according to the
fortran program commands
"
"
"
"SUBROUTINE TOTALENERGY(RX,RY,RZ,EPOT)!
"IMPLICIT NONE!
C
RXIJ=RXI-RX(J)!
RYIJ=RYI-RY(J)!
RZIJ=RZI-RZ(J)!
"INCLUDE 'param.h'!
"REAL*8
"REAL*8
EPOT, ELRC!
"REAL*8
"REAL*8
"REAL*8
"REAL*8
"INTEGER
R6I,R12I, PI!
RXIJ,RYIJ,RZIJ,RIJSQ!
RXI, RYI, RZI!
LSIMBOX, LJCUTSQ!
I,J!
"PI = 3.14159265d0
C
"
RXIJ=RXIJ-LSIMBOX*ANINT(RXIJ/LSIMBOX)
"
"
RYIJ=RYIJ-LSIMBOX*ANINT(RYIJ/LSIMBOX)!
RZIJ=RZIJ-LSIMBOX*ANINT(RZIJ/LSIMBOX)!
"
RIJSQ=RXIJ**2+RYIJ**2+RZIJ**2!
"
IF (RIJSQ.LE.LJCUTSQ) THEN!
"
"
"
"
"! Pi!
R6I= SIGMA**6/(RIJSQ*RIJSQ*RIJSQ) !
R12I= R6I*R6I!
"!
EPOT=EPOT+(-R6I+R12I)!
ENDIF!
"LSIMBOX=(NATOM/DENS)**(1.0D0/3.0D0)!
"LJCUTSQ=LJCUT*LJCUT!
"
"ENDDO!
"EPOT=0.0!
"EPOT=4.0D0*EPSILON*EPOT!
RXI=RX(I)!
RYI=RY(I)!
RZI=RZ(I)!
"
DO J=I+1, NATOM!
ENDDO!
"RETURN!
"END
An excellent website for quickly learning basic Fortran77 that will allow you to
understand the provided codes and even modify them slightly
http://maeresearch.ucsd.edu/arya/FortranGuide.pdf
Fortran77 tutorial
http://www.idris.fr/data/cours/lang/fortran/f90/F77.html
http://www.geo.utexas.edu/courses/387h/Lectures/fortran
%2077%20tutorial.pdf
http://www.obliquity.com/computer/fortran/
Lets say we want to calculate the vdW energy of a 3-particle cluster of Argon
atoms such that the three atoms are arranged as an equilateral triangle of side
length 3.5 Angstroms.
The vdW energy of interaction between 2 Argon atoms is given by the LennardJones potential ULJ = 4 [(/r)12 (/r)6], with = 3.41 and = 1.6510-21 J.
"Define all
"REAL*8
"REAL*8
"REAL*8
"INTEGER
variables!
"
"
"
"I, J
Example continued
C
"Specify
"RX(1) =
"RY(1) =
"RZ(1) =
"Specify
"RX(2) =
"RY(2) =
"RZ(2) =
"Specify
"RX(3) =
"RY(3) =
"RZ(3) =
"
"
"
"R6I = SIGMA**6/(RIJSQ*RIJSQ*RIJSQ) !
"
"
"R12I = R6I*R6I!
"
"!
"
"
"POTE = POTE + (R12I - R6I)
"!
"
"ENDDO!
"ENDDO!
"POTE = 4.0*EPSILON*POTE!
C