A KISS pure Fortran OOD class for computing Vectorial (3D) algebra
VecFor is a user-friendly and Object-Oriented designed API for handling vectors in a (3D) three dimensional frame of reference. It exposes (among others) the object Vector that posses a far complete set of overloaded operators for performing vectorial calculus algebra.
VecFor adheres to the KISS concept: it is a pure Fortran (2003+) library coded into a single module file, vecfor.F90
.
Go to Top
select_real_kind
intrinsic function), but it can be easily changed at compile time;Any feature request is welcome.
Go to Top
VecFor is an open source project, it is distributed under a multi-licensing system:
Anyone is interest to use, to develop or to contribute to VecFor is welcome, feel free to select the license that best matches your soul!
More details can be found on wiki.
Go to Top
Besides this README file the VecFor documentation is contained into its own wiki. Detailed documentation of the API is contained into the GitHub Pages that can also be created locally by means of ford tool.
VecFor allows a very simple, high-level implementation of vectorial calculus algebra.
use vecfor ! load vector type and all helpers
type(vector) :: point1
type(vector) :: point2
type(vector) :: distance
point1 = 1 * ex ! ex is the versor along x direction exposed by VecFor
point2 = 1 * ex + 2 * ey ! ey is the versor along y direction exposed by VecFor
Note that ex, ey and ez are the Cartesian versors exposed by VecFor.
distance = point2 - point1
print "(A)", " Vectorial distance"
call distance%printf
print "(A)", " Distance module"
print*, distance%normL2()
! expected output
! Vectorial distance
! Component x 0.000000000000000E+000
! Component y +0.200000000000000E+001
! Component z 0.000000000000000E+000
! Distance module
! +0.200000000000000E+001
As you can see from the above example, defining and using a vector become very close to the mathematical formulation. Note that, using the dynamic dispatching resolved at compile time, there is no performance penalty on using a type(vector)
variable instead of an hard-coded real, dimension(3)
array variable (or even more verbose and less clear real :: x, y, z
variables for each vector…).