Skip to content

Guymer/fortranlib

Repository files navigation

My FORTRAN Library

Documentation Status

Please enjoy using my FORTRAN library. It contains a whole load of random functions and subroutines that I have written over the years. Most of them are overloaded to allow their use by different kinds of arguments. To save repetitive typing you will find some Python scripts dotted around this repository which have been written to create all the different versions of each FORTRAN function or FORTRAN subroutine. The documentation is on Read The Docs.

I find the GFortran Intrinsic Procedures Reference an excellent resource when determining what kind an argument must be. As an aside, it niggles me that a lot of intrinsic procedures, according to the FORTRAN standard, are "of default kind" (to me, these are the sort of problems that ISO_FORTRAN_ENV was supposed to fix).

Ditto, the MPI 3.1 Specification PDF and OpenMP 5.0 Specification PDF are excellent resources too.

FORTRAN Language Conventions

All integers are declared as INT64 (from ISO_FORTRAN_ENV), except:

  • when being saved to disk (depending on the situation); and
  • when interacting with an intrinsic procedure (depending on the procedure's specification).

All reals are declared as REAL64 (from ISO_FORTRAN_ENV), except:

  • when being saved to disk (depending on the situation); and
  • when interacting with an intrinsic procedure (depending on the procedure's specification).

GOTO statements are never used because I do not want to be eaten by a velociraptor.

Library Module/Function/Subroutine List

  • mod_safe is a module that can safely be used (without any extra dependencies) containing:
  • mod_safe_mpi is a module that can safely be used (without any extra dependencies) by a MPI compiler containing:
    • sub_allreduce_array is a subroutine to reduce arrays that are larger than MPI's in-built limits
    • sub_bcast_array is a subroutine to broadcast arrays that are larger than MPI's in-built limits

Additionally, mod_safe contains some other constants, such as const_c and const_kb. A full list can be found in consts.f90.

To Do

  • This library is a consolidation of a whole load of functions and subroutines from a variety of different projects. It will take some time to pull them all in and make sure that they all work well together.

Testing

The directory tests contains some basic tests to (hopefully):

  • find any simple bugs that I might have introduced; and
  • demonstrate some simple programming techniques.

ARM CPUs often do not define a native REAL128 kind. The command touch foo.f90; gfortran -cpp -E -dM foo.f90 | sort will print out all of the predefined macros on your current system. This suite now uses the test __SIZEOF_LONG_DOUBLE__ != __SIZEOF_DOUBLE__ to conditionally compile the REAL128 overloaded parts.

Dependencies

This FORTRAN library requires the following Python modules to be installed and available in your PYTHONPATH.

Bugs

  • There is a bug in Doxygen which results in FORTRAN INCLUDE statements not being parsed. Until this gets fixed then there is little point in providing Doxygen comments in the source code here. The bug was reported on 2009-07-27 and it shows no sign of being fixed (I first commented on the bug report on 2013-01-11 and as of 2022-05-13 it is still open).