{"id":18854429,"url":"https://github.com/urbanjost/general-purpose-fortran","last_synced_at":"2026-02-06T02:03:25.244Z","repository":{"id":117557559,"uuid":"96054730","full_name":"urbanjost/general-purpose-fortran","owner":"urbanjost","description":"General Purpose Fortran Cooperative","archived":false,"fork":false,"pushed_at":"2025-07-11T02:23:24.000Z","size":202124,"stargazers_count":45,"open_issues_count":1,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-17T07:46:22.254Z","etag":null,"topics":["fortran","fortran-package-manager","fpm","library","repository"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbanjost.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-07-02T23:39:54.000Z","updated_at":"2025-07-11T00:04:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd6d2303-fb78-4784-921e-0ffa4472cd78","html_url":"https://github.com/urbanjost/general-purpose-fortran","commit_stats":{"total_commits":80,"total_committers":1,"mean_commits":80.0,"dds":0.0,"last_synced_commit":"b5437d205bdacc44d666c82ea67bba8066ce35ba"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/urbanjost/general-purpose-fortran","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2Fgeneral-purpose-fortran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2Fgeneral-purpose-fortran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2Fgeneral-purpose-fortran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2Fgeneral-purpose-fortran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbanjost","download_url":"https://codeload.github.com/urbanjost/general-purpose-fortran/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2Fgeneral-purpose-fortran/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29145565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T01:13:33.096Z","status":"online","status_checked_at":"2026-02-06T02:00:08.092Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fortran","fortran-package-manager","fpm","library","repository"],"created_at":"2024-11-08T03:48:12.394Z","updated_at":"2026-02-06T02:03:25.195Z","avatar_url":"https://github.com/urbanjost.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GPF](docs/images/GPF.gif)](https://urbanjost.github.io/general-purpose-fortran/docs/index.html)\n# [General-Purpose Fortran Repository](https://urbanjost.github.io/general-purpose-fortran/docs/man3.html)\n\n## Shortcut\n\nThe majority of the documentation is in HTML at the \n[Documentation](https://urbanjost.github.io/general-purpose-fortran/docs/index.html)\npage.\n\n## Intro\nThis repository concentrates on those \"other\" Fortran procedures that\nsolve the day-to-day non-numeric(mostly) issues in programming. Large\nrepositories of numeric algorithms written in Fortran exist at such\nsites as the [ netlib ](http://www.netlib.org) repository.\n\nModern Fortran is quite capable of accessing many commonly available\nC libraries or expressing many commonly desired utility procedures\ndirectly, but the standard language does not define many of these\nbasic interfaces. Because of Fortran's expressiveness and power in\nHPC environments ( Coarrays, MPI, OpenMP, matrix operators and the\nmany numeric libraries available in Fortran) I prefer we bring these\ngeneral-purpose utilities to Fortran instead of bringing Fortran to other\nlanguages. With that in mind I placed some such modules I have here.\nI hope others will find them useful (and expand upon them).\n\n### Alternate stand-alone modules\n\nGPF(General Purpose Fortran) is the main repository that contains man(1)\npages, utility programs, extended examples and unit tests.  As generally\nuseful modules mature simpler stand-alone versions are created from\nthis base. That is because the full GPF (General Purpose Fortran\nrepository) has many interdependencies. The extracated stand-alone\n[individual modules](https://github.com/urbanjost?tab=repositories)\nare more appropriate if only a specific module is required, and can be\nfound as additional repositories at the GPF site.\n\nBut if you want to work with the entire repository this is where new\ndevelopment (and a lot more functionality) is concentrated!\n\n### Cloning the repository\n```bash\n    git clone https://github.com/urbanjost/general-purpose-fortran\n    cd general_purpose-fortran/src\n    # you might have to change \"-lncurses\" to \"-lncurses -ltinit\"\n    # depending on how ncurses(3c) was built on your machine, and\n    # have ncurses(3c), readline(3c), sqlite3(3c), X11(3c) and lua(3c) \n    # installed for all the interfaces to build, but the most \n    # commonly used interfaces should build without problems.\n\n    make -k\n```\n### for building optional GPF\nTo build some of the optional components you may have to install several\npackages. Starting from a base MINT 20.1 platform (2021-03-07), for example:\n```\n   sudo apt-get install gfortran\n   sudo apt-get install libx11-dev\n   sudo apt-get install sqlite3 libsqlite3-dev\n   sudo apt-get install libcurl4-gnutls-dev \n   sudo apt-get install libreadline libreadline-dev\n```\n\n### If interested in the graphics routines ...\n\nyou might want to edit hershey.sh to select where hershey\nfont files will be installed (default is /usr/share/hershey), \nand then enter ...\n\n    bash hershey.sh\n\nif you do not have bash(1) or a Posix shell you will have to build and \nrun the h2v program for each font, as illustrated by the simple\nhershey.sh script.\n\n## Dependencies\n\nBy default, the graphics routines require X11, the ncurses interface\nassumes libncurses is installed, the SQLite3 interface needs the\nlibsqlite3 library, and the readline interface needs libreadline.\nThese libraries are commonly available on many platforms but you may\nhave to remove some of the files from Makefile \nif you do not want to build those interfaces.\n\n## Overview\n\nThe GPF (General-Purpose Fortran) repository consists of  Fortran modules\nand libraries (and in some cases their associated C support routines)\nproviding\n\n*  __command line parsing__\n*  __string operations__\n*  a __date and time__ module\n*  a module that supports basic integrated __unit testing__ \n*  simple __numeric expression parsing__\n*  __command line history__ editing\n*  The low-level __M_draw__ graphics library, and the beginnings of a\n   __pixel graphics module__ -- both similar to the VOGLE graphics library interface\n*  libraries for __message handling__ and __debugging__\n*  a growing number of Fortran interfaces to common C routines, including\n   +  many __POSIX system routines__\n   +  a module for reading and writing lines to a process (a __popen(3c)__ interface)\n   +  an interface to the __ncurses(3c)__ terminal screen handling library\n   +  an interface to the __sqlite3(3c)__ SQL file library\n   +  an interface to the __regex(3c)__ Regular Expression library\n   +  routines for controlling the X11 Windows attributes of an xterm(1) terminal emulator,\n      including the program __setxt__(1)\n\nThe majority of these routines come with a man(1) page in *roff and HTML format.\nAn index into the documentation is contained in this distribution and available on the home page\n   + [[overview]](https://urbanjost.github.io/general-purpose-fortran/docs/index.html)\n   + A [collection of programs](https://urbanjost.github.io/general-purpose-fortran/docs/man1.html) that use the\n     repository code are included. These range from useful utilities (a __pre-processor__, an\n     __SCCS-style meta-data reader__, __regression testing utilities__, ...) to simple\n     example programs that exercise the modules.\n\nCode additions are strongly encouraged (This is intended to be a development of\nthe Fortran community).\n\n\nThe Fortran Wiki [fortranwiki.org ](http://fortranwiki.org) contains information on many Fortran\nresources (If you do not see a link there to your favorites please add them.)\n\nA modern Fortran compiler is assumed. This code has been tested using\ngfortran GNU Fortran (GCC) 8.3.1 .\n\n## Routine Categories and Descriptions\n\n### command line arguments\n\n[M\\_KRACKEN(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_ARGUMENTS.html): command line\narguments\n\nThe M\\_KRACKEN(3f) module makes cracking Unix-like arguments off the command\nline easy. This version is expanded to allow use in configuration files and\ninteractive input as well, and incorporates additional modules. It requires\nmany other components from the GPF collection, and is used to generate\nprograms that use shell-like input as well as crack command lines.\n\n[M\\_ARGS(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_args.3m_args.html) \n\nThe M_args(3fm) module supports cracking Unix-like arguments off the\ncommand line as a string that can be read as a NAMELIST, eliminating\nthe typical additional steps needed to convert the strings found on the\ncommand line to other types.\n\n[M\\_GETOPT(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_getopt.3.html): command line arguments\n\nThe M\\_GETOPT(3fm) module by Mark Gates supports cracking Unix-like arguments\noff the command line in much the same way as the C getopt(3c) procedure.\n\n[M\\_GETOPT\\_LONG(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_getopt_long.3.html): command line\narguments\n\nThe M\\_GETOPT\\_LONG(3fm) module by Joe Krahn supports cracking Unix-like\narguments off the command line in much the same way as the SunOS\ngetopt_long(3c) procedure.\n\n### strings\n\n[M\\_STRINGS(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_strings.html)\n\nconvert case, change numbers to strings, strings to numbers, parse on\ndelimiters,edit strings, ... .\n\n### date and time\n\n[M\\_TIME(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_time.html)\n\nCalculate and display date and time values\n\n### expression parsers\n\n[M\\_CALCULATOR(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_calculator.3.html),\n\nM\\_calculator(3fm) is a module for evaluating expressions. The primary routine\nis JUCALC(3f). JUCALC(3f) evaluates simple numeric and string expressions.\nThis allows your input to use expressions and variable names instead of simple\nvalues. You will have to comment out or supply some of the functions called,\ndepending on how f2003-compliant your compiler is.\n\n### command line recall and editing\n\n[M\\_HISTORY(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/redo.3.html): An interactive input editor\nmodule\n\nActing much like a line-mode editor, the REDO(3f) procedure lets you list,\nedit, save, and modify your interactively entered program input. Built-in help\nand no dependence on terminal control sequences makes this a simple-to-master\nand portable input history editor.\n\n[ M\\_READLINE(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_readline.3.html): calling readline(3c)\nfrom Fortran\n\nThe readline(3c) routine lets you edit and then execute previously entered\ncommands. An interface using a small C routine and the standard ISO_C_BINDING\nmodule lets the commonly available C routine be called from Fortran. The\nreadline(3c) library is required.\n\n### messages\n\n[M\\_JOURNAL(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_journal.3.html),\n[M\\_MESSAGES(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_messages.3.html)\n\njournaling, logging, and general messaging routines that let you have a single\nroutine filter output to journal files; display attention-grabbing messages or\nreformat messages.\n\n### unit testing and debugging\n\n[M\\_DEBUG(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_debug.html)\n\nThese routines are useful for constructing unit tests for code and for adding\ndebug modes to routines and applications.\n\n[Paranoid Compiler Test](https://urbanjost.github.io/general-purpose-fortran/docs/paranoid.1.html)\n\nThe PARANOID program converted into subroutines that can be called from your\nprograms to verify compiler behavior.\n\n### flow control\n\n[M\\_LOGIC(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_logic.3.html): conditionally select input\n\nThe M\\_LOGIC(3f) module allows you to use if/else/elseif/endif directives in\nyour input; allowing conditional selection of input lines. Requires an\nexpression parser. It uses JUCALC(3f) by default.\n\n### I/O\n\n[ M\\_IO(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_io.3m_io.html)\n\nInput/Output\n\n### hot keys\n\n[GETKEY(3f)](https://urbanjost.github.io/general-purpose-fortran/docs/system_getkey.3.html): read a character from the\nkeyboard in \"immediate mode\"\n\nA simple C routine for most Unix and GNU/Linux systems that immediately reads\na single character keystroke from the keyboard without waiting for a carriage\nreturn. An interface using the ISO_C_BINDING interface allows the routine to\nbe called from Fortran.\n\n### Fortran/C calls\n\n##### Read or Write from a system process\n\n[M\\_PROCESS(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_process.3.html)\n\nRead and write from a process using popen(3c)\n\n##### Many POSIX interface routines\n\n[M\\_SYSTEM(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_system.html)\n\n  * Environment\n  * Directories\n  * File status and attributes\n  * Error code\n  * Process management\n\nAnd other commonly called C system routines interfaced to Fortran. Makes heavy\nuse of the ISO_C_BINDING module introduced as part of Fortran 2003.\n\n##### Call the POSIX Regular Expression library\n\n[M\\_REGEX(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_regex.3.html)\n\nCall the POSIX regular expression library.\n\n#### Fortran(2008) interface to the SQLite3 library\n\n[M\\_SQLITE(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_sqlite.3.html)\n\nA basic interface to the SQLite3 library using the ISO_C_BINDING module and C/Fortran interoperability\nmodeled iniitially on the FLIB interface.\n\n#### Fortran(2003) interface to the ncurses(3c) library\n\n[M\\_NCURSES(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_ncurses.html),\n[M\\_FIXEDFORM(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_fixedform.3.html)\n\nA Fortran module and a few related files create an interface from Fortran to\nthe C ncurses(3c) library; allowing Fortran programs to read function keys and\ncharacters one at a time and to control the characters on the screen on a\ncharacter-cell by character-cell basis.\n\nFile characteristics\n\nInput/Output\n\nSignal management\n\nSockets\n\ndatabase\n\nencryption\n\ninternet\n\nruntime\n\nopengl\n\nparallel\n\noverloading\n\nstructures\n\nAdditional Utilities\n\nRoutine Categories  Descriptions\n\n### numeric utilities that are aware of their accuracy\n\n[M\\_COMPARE_FLOAT\\_NUMBERS(3fm)](math/Compare_Float_Numbers/M_Compare_Float_Numbers.HTML)\n\nA Fortran module containing routines to perform equality and relational\ncomparisons on floating point numbers. That is, you can more safely compare\nreal numeric values.\n\n[Types and Kinds](types/Type_Kinds.HTML)\n\nFortran KIND definitions used by other parts of the basic utilities\n\n[ACCDIG(3f)](https://urbanjost.github.io/general-purpose-fortran/docs/accdig.3.html)\n\ncompare two real numbers only up to a specified number of digits\n\n### Graphics\n[M\\_DRAW(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_draw.html)\n\nThe M\\_draw module is an interface to a C library based on the VOGLE graphics library. It is supplemented\nby higher level modules.\n\n[M\\_PIXEL(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_pixel.html)\n\nThe M\\_pixel module is a _PRELIMINARY_ collection of routines that use 2D-\nvector routines to create or modify a pixel array, which can then be written\nas a GIF file.\n\n### Color\n\n[M\\_COLOR(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_color.3.html)\n\nThe M\\_color module is a collection of color-related procedures. Routines to\nconvert between different color models, return RGB values given common X11\ncolor names, and other simple color-related operations.\n\n### xterm(1) attributes\n\n[M\\_XTERM(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_xterm.html)\n\nThe M\\_xterm module is a collection of routines that use escape sequences to set and query\nxterm(1) X11 Windows attributes such as window size, background and foreground color, font,\nand cursor color. The program setxt(1), included in the GPF distribution, allows for easily\nusing the module capabilities from the command line.\n\n### Sort\n\n[ M\\_SORT(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/M_sort.3.html)\n\nsorting routines encapsulated in a module\n\n[ sort_shell(3f)](https://urbanjost.github.io/general-purpose-fortran/docs/sort_shell.3.html)\n\nsimple generic sort procedure\n\n[ M\\_SWAP(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/swap.3.html)\n\nswap two variables\n\n### General Mathematics\n\n[ M\\_MATH(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_math.html)\n\nA collection of routines for basic geometry, curve fitting and interpolation,\nbasic statistics, ...\n\n### Unit Conversions\n\n[ M\\_UNITS(3fm)](https://urbanjost.github.io/general-purpose-fortran/docs/BOOK_M_units.html)\n\nA collection of unit conversions and constants. Allow degrees instead of\nradians in trig functions; convert between Celcius and Fahrenheit, ...\n\nAn example program that combines many of the components into a simple\ncalculator-like utility that parses command line arguments, evaluates Fortran-\nlike expressions, draws in pixel arrays, allows calls to ncurses, has\ninteractive command history recall and editing, and supports\nif/else/elseif/endif directives can be found in\n[shell.ff](EXE/SHELL/shell.ff).\n\n---\n![fpm](docs/images/fpm_logo.gif)\n---\n\n## Build with fpm(1)\n \nGPF is bundled as an `fpm` package.\nDownload the github repository and build it with \nfpm ( as described at [Fortran Package Manager](https://github.com/fortran-lang/fpm) )\n\n```bash\n     git clone https://github.com/urbanjost/general-purpose-fortran.git\n     cd general-purpose-fortran\n     fpm test  # build and then run unit tests\n```\n\nor just list it as a dependency in your fpm.toml project file.\n\n```toml\n     [dependencies]\n     general-purpose-fortran = { git = \"https://github.com/urbanjost/general-purpose-fortran.git\" }\n```\n + A `ford` configuration file is available to build documentation\n + A `doxygen` configuration file is available to build documentation\n\n\u003c!--\n==================================================================================================\nAt least recently, Fortran has centered around solving large\nnumerically-intensive problems in STEM-related fields; often in parallel,\nparticularly on large HPC platforms.  And this work was done almost\nexclusively with commercial compilers. Where once Fortran was available\non nearly every platform (usually with many extensions provided on a\nper-platform basis) it became something primarily available in these\nsomewhat elite environments.\n\nThen came the open-source compilers G95 and subsequently gfortran, and\nmore recently several previously commerical-only compilers from Intel,\nNAG, Nvidia and new open-source projects. And newer standards standardized\nC interfaces and added back a few of the common features once found in\nalmost all compilers via extensions.\n\nSo Fortran is once again available almost everywhere. But as critical as\nit is for many fields it is rarely taught, as instructors generally prefer\nteaching the most general programming tools, as they can be useful in many\ndifferent disciplines.\n\nBut Fortran is just as capable at its core of doing general functions as\nany language now, given it's standarized C interface and new modern features.\n\nBut, largely due to historical reasons, there still is no standard library\nfor such tasks as command-line parsing, string functions, date-and-time\nmanipulation and display, interfacing to the C POSIX system routines, ...\n==================================================================================================\n --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fgeneral-purpose-fortran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbanjost%2Fgeneral-purpose-fortran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fgeneral-purpose-fortran/lists"}