PHYS-4007/5007 Useful Fortran 77 Subroutine and Functions Web Page

This web page contains the links of the various files that contain useful Fortran 77 subroutines and functions needed for PHYS-4007/5007 Computational Physics. There are two sets of files below. The first to solve ordinary differential equations and the second to carry out linear least squares fitting of data. All of the files here are in standard ASCII (text) format so that when you click on the link, the code will appear in your web browser. Follow these steps to save these files on your Linux machine.


Numerical Ordinary Differential Equations (ODE) Files

The following is a list of useful Fortran 77 subroutines and functions use to numerically solve ordinary differential equations. Feel free to use them if you need them in your work.

  rk4.f     Fortran 77 subroutines using the 4th-order Runge-Kutta technique for ODEs.  
  ode.f     Fortran 77 subroutines using the Adams method for ODEs. Note that this  
  file also contains the DE, STEP, and INTRP subroutines.
 
  de.f     Fortran 77 subroutine of Adams method for ODEs.  
  intrp.f     Fortran 77 subroutine called by de.f.  
  step.f     Fortran 77 subroutine called by de.f.  
  machin.f     Fortran 77 program to calculate data for ode.f and de.f.  
  f.f     Sample Fortran 77 subroutine containing the differential equations that  
  ode.f and de.f are asked to solve.
 


Numerical Linear Least-Squares Fitting Files

The following is a list of useful Fortran 77 subroutines and functions use to numerically solve ordinary differential equations. Feel free to use them if you need them in your work.

  fit.f     Fortran 77 subroutine to fit data to a straight line using the linear least-squares  
  fitting technique.
 
  gammq.f     Fortran 77 function to calculate the complement of the incomplete gamma  
  function, Q(a, x) = 1 - P(a, x), where P(a, x) is the incomplete gamma function.
 
  gser.f     Fortran 77 subroutine to calculate the incomplete gamma function using a  
  series solution.
 
  gcf.f     Fortran 77 subroutine to calculate the incomplete gamma function using a  
  continued fraction technique.
 
  gammln.f     Fortran 77 function to calculate the natural log of the gamma function.  

Let say we have a Fortran 77 program that contains data representative of a linear function called mylinfit.f and we wish to carry out a linear least-squares fit to this data and print out the parameters of this straight line fit. Once we are in an appropriate subdirectory of a Linux computer, we then issue the following command to compile and link our files into an executable file using

      gfortran   -o mylinfit.exe   mylinfit.f   fit.f   gammq.f   gser.f   gcf.f   gammln.f

We then run this program using

      ./mylinfit.exe


Click here to go back to the Computational Physics home page.


Last modified: October 7, 2013 by D.G. Luttermoser