A collection of Fortran modules and routines for math, science and engineering calculations.
A collection of sub-routines and functions for operating with and on arrays. The sub-routines and functions are listed below.
linspace(x, xMin, xMax, xLength)
This subroutine will create a linearly spaced array.x
is the array,xMin
is the start value,xMax
is the end value andxLength
is the length of the array.
A collection of types, sub-routines and functions for operating with and on vectors. The types, sub-routines and functions are listed below.
vec2d
is the type that defines a 2d vector, it is defined as follows.
type vec2d
real(8) :: x, y
end type vec2d
vec3d
is the type that defines a 3d vector, it is defined as follows.
type vec3d
real(8) :: x, y, z
end type vec3d
dotProduct2d(vec1, vec2)
This function will return the dot product of two, 2-dimensional vectors. It takes the argumentsvec1
andvec2
, these are both of the typevec2d
.dotProduct3d(vec1, vec2)
This function will return the dot product of two, 3-dimensional vectors. It takes the argumentsvec1
andvec2
, these are both of the typevec3d
.dotProductNd(vec1, vec2)
This function will return the dot product of two, n-dimensional vectors. It takes the argumentsvec1
andvec2
, these are both arrays.crossProduct(vec1, vec2)
This function will return the cross product of two vectors as the type ofvec3d
. It taks the arguments ofvec1
andvec2
, these are both of the type ofvec3d
.crossProductArray(vec1, vec2)
This function will return the cross product of two vectors as an array. It takes the arguments ofvec1
andvec2
, these are both arrays.vecAdd2d(vec1, vec2)
This function will return the addition of two 2-dimensional vectors. It takes the arguments ofvec1
andvec2
, these are both of the typevec2d
.vecAdd3d(vec1, vec2)
This function will return the addition of two 3-dimensional vectors. It takes the arguments ofvec1
andvec2
, these are both of the typevec3d
.vecAddArray
This function will return the additon of two n-dimensional vectors. It takes the arguments ofvec1
andvec2
, these are both arrays.
A collection of sub-routines and functions for calculus based operations. The sub-routines and functions are listed below.
trapezoidalIntegrate(x, y)
This function will return the integral using the trapezoidal method. It takes the argumentsx
andy
that are in the form of arrays.simpsonIntegrate(x, y)
This function will return the integral using Simpson's method. It takes the argumentsx
andy
that are in the form of arrays.trapezoid_integrate(f, a, b, n)
This function will return the integral using the trapezoidal method. It takes the arguments,f
the function to be integrated,a
andb
the bounds andn
for the number of sub intervals.simpson_integrate(f, a, b, n)
This function will return the integral using Simpson's method. It takes the arguments,f
the function to be integrated,a
andb
the bounds andn
for the number of sub intervals.
A module where users define their own mathematical functions.
A collection of sub-routines and functions for plotting operations. The sub-routines and functions are listed below.
plot2d(x, y)
This sub-routine will save a file named data.dat to the working directory, so that it can be plotted in gnuplot or other visualisation software. It accepts to argumentsx
andy
, these are both arrays of the same length.
A collection of sub-routines and functions for statistical operations. The sub-routines and functions are lised below.
mean(x)
This function will return the mean value of an input arrayx
median(x)
This function will return the median value of an input arrayx
. Note that currently the sorting method is extremley inefficient.normalDistrubtions(x, sigma, mu)
This function will return a normal distribution. It takes argumentsx
an input array to operate on,sigma
the standard deviation of the normal distribution andmu
the mean of the normal distribution.
A collection of sub-routines and functions for geographical operations. The sub-routines and functions are listed below.
pointInCircle(px, py, cx, cy, r)
This function will return a boolean value, true or false, for if the point lies within the circle, this function assumes standard rectangular coordinates and is not recommended to be used for spheres or ellipsoids. It takes the argumentspx
andpy
for the x and y coordinates of the point,cx
andcy
for the coordinates of the circle centre andr
for the radius of the circle.pointInCircleHaversine(px, py, cx, cy, r)
This function will return a boolean value, true or false, for if a point lies within a circle. This function utilises the haversine method to find the distance and thus is suitable for use on spheres. It takes the arguments ofpx
andpy
for the x and y coordinates of the point,cx
andcy
for the coordinates of the circle centre andr
for the radius of the circle.pointInCircleVincenty(px, py, cx, cy, r)
This function will return a boolean value, true or false, for if a point lies within a circle. This function utilises the vincenty method to find the distance and thus is suitable for use on ellipsoids. It takes the arguments ofpx
andpy
for the x and y coordinates of the point,cx
andcy
for the coordinates of the circle centre andr
for the radius of the circle.haversineDistance(lon1, lat1, lon2, lat2)
This function will return the distance between two points on the surface of the earth, assuming it is a sphere. It takes the arguments,lon1
andlat1
for the coordinates of the first point andlon2
andlat2
for the coordinates of the second point.haversineDistanceArray(lon, lat)
This function will return the distance between successive points in an array, using the abovehaversineDistance
function.vincentyDistance(lon1, lat1, lon2, lat2)
This function will return the distance between two points on the surface of the earth, assuming it is the WGS-84 ellipsoid. It takes the arguments,lon1
andlat1
for the coordinates of the first point andlon2
andlat2
for the coordinates of the second point.vincentyDistanceArray(lon, lat)
This function will return the distance between successive points in an array, using the abovevincentyDistance
function.