Introducing the Acorvid Legacy Fortran Compatibility Library

A common problem when revitalizing old scientific software is the need to recreate a working build environment. With standards-conforming code, this is usually straightforward, often a matter of setting a few compiler flags to initialize variables, persistently save local variables, adjust floating point exception-handling, etc. Occasionally one is faced with code that made use of library routines which are not available under the current build environment or which require a software license incompatible with the legacy code’s license. This is especially true of the routines provided with the book Numerical Recipes; back when the book was used as a primary text for numerical analysis, less attention was paid to software licenses and most students (now practicing engineers and developers) were unaware the code from the book was proprietary and could not be redistributed without a commercial license.

The Acorvid Legacy Fortran Compatibility (ALFC) library was created to assist in revitalizing legacy code by providing an open API to a number of proprietary and vendor-specific libraries. At present it contains compatibility interfaces for Numerical Recipes functions (FORTRAN 77 version) and the Sperry-Rand UNIVAC large scale systems libraries, MATH-PACK and STAT-PACK. The ALFC library is licensed under the MIT License which should be permissive enough for almost any application.

Read moreIntroducing the Acorvid Legacy Fortran Compatibility Library

What’s New in Fortran 2018!

Today I saw a reference to The new features of Fortran 2018 float past on Twitter. The WG5 standards committee has renamed the forthcoming language revision to Fortran 2018 from Fortran 2015 to reflect a more accurate release date. Many of the changes focus on coarrays and distributed computing but there were several useful clarifications of existing features. I was very happy to see that COMMON, EQUIVALENCE, DO <label>, FORALL, and arithmetic-IF have finally been marked as obsolescent and are on their way to the dustbin of computing practice. All but FORALL are leftovers from FORTRAN 77 and earlier. Modern Fortran provides much better and clearer facilities for persistence, aliasing, and dynamic memory management than COMMON and EQUIVALENCEand modern control structures make  DO <label> and arithmetic-IF redundant. Numeric line IDs seem to attract spaghetti logic so I see the slow deprecation of these features as a welcome change to the language to improve code quality, reliability, and maintainability. When refactoring code, I tend to refactor away all four of these constructs anyway but it is heartening to see the standards committee recognize these features are problematic enough to (eventually) remove them from the language

In the case of FORALL, the construct never worked up to its potential and has since been replaced with DO CONCURRENTwhich fits more into the DO <iteration style> syntax model. FORALL is rarely used because it never reliably performed any better than a conventional loop. My early experience with modern Fortran led me to experiment with FORALL; finding that it didn’t offer any advantages on any of the compilers I used at the time led me to abandon it, though I really need to look deeper into the coarray model for concurrent execution.

If you have had experience applying coarray features to legacy code, please let me know in the comments or via email (address listed on the contact page). I’m curious what strategies you’ve found to work.

Fortran Library of the Today: FLAP

Today’s Fortran Library of the Today is FLAP (Fortran command Line Arguments Parser for poor people)

From FLAP’s Github page:
A KISS pure Fortran Library for building powerful, easy-to-use, elegant command line interfaces

  • FLAP is a pure Fortran (KISS) library for building easily nice Command Line Interfaces (CLI) for modern Fortran projects;
  • FLAP is Fortran 2003+ standard compliant;
  • FLAP is OOP designed;
  • FLAP is a Free, Open Source Project.

FLAP is inspired by Python’s argparse library which involves instantiating a CLI object, registering options and arguments along with descriptions, optional/required status, argument count and type, etc., then parsing and evaluating the command line arguments. The library also generates help/usage messages, manual pages, and other user documentation and handles any errors in user input.

I have yet to put FLAP through its paces but it looks like a great candidate for the Hypothetical Fortran Standard Library!

What I Miss When Writing Fortran

I work in a number of different languages depending on the project. For rapid prototyping I use Jupyter Notebook with Python 2 or 3 which is then converted to standalone code, documents are written in Markdown or LaTeX and compiled to HTML or PDF, Fortran is used for heavy computation, etc. I also revitalize a lot of legacy FORTRAN IV and FORTRAN77 code so I frequently find myself wishing I had the capabilities found in the standard libraries of more modern languages. I also miss certain language-specific development tools which don’t have a Fortran equivalent.

Read moreWhat I Miss When Writing Fortran

What Should a Fortran Standard Library Contain? Part 2

In the previous post, I lamented the lack of a standard library in Fortran and briefly reviewed the contents of the standard libraries for both C and Python. While these languages serve different roles than Fortran, they are popular and mature and I felt they were worth investigating for inspiration. This post covers two topics: first, I present a brief summary of how a hypothetical Fortran Standard Library could be created and adopted (the “Big Picture“), and second I look at the standard libraries of Julia, R, and Ada.

The Big Picture approach I am taking is to:

  1. describe the problem (lack of a standard library),
  2. show how other languages address it,
  3. set high level policies and goals,
  4. define & implement an achievable initial library,
  5. have people use it and provide feedback, and,
  6. iterate over 4 through 6 until the library is stable, adjusting the policies and goals in 3 to ensure the library is implementable, stable, usable, and meets with community approval.

Following this model, we can define high-level capabilities we want in a standard Fortran library and then get into the details of what functions are necessary. In software engineering terms, that means setting requirements and creating design and functional specifications.

Read moreWhat Should a Fortran Standard Library Contain? Part 2

What Should a Fortran Standard Library Contain? Part 1

One of Fortran’s major drawbacks is its lack of a standard library, a formally defined set of components outside the language core which are supplied along with the compiler. Recent revisions of the Fortran standard have defined several standard modules (ISO_C_BINDING and ISO_FORTRAN_ENV are the two best known) but these do little more than define constants and data types. As of 2017, there are no standard libraries for (say) operating system or filesystem access, string handling, searching and sorting, or networking.

Since Fortran is primarily used for numerical computing, the lack of a standard network library may not be a great disadvantage. However the lack of filesystem tools and text manipulation and parsing tools severely limit the utility of the language.

Before asking what should be in hypothetical Fortran Standard Library, it might be helpful to review what’s in the standard libraries of other languages such as C and Python.

Read moreWhat Should a Fortran Standard Library Contain? Part 1

Acorvid is Go!

I can’t complain too much. TXSoS got back to me with our Certificate of Filing this afternoon so one more major chunk of paperwork has fallen into place. Very proud of this moment; that’ll fade a little as I get bombarded by cold calls and tax nonsense. For the moment though, I’m incredibly happy. Take time to enjoy important moments, even if they’re only automated messages from the Corporations Section of Texas’ Office of the Secretary of State .

Breakout Board: NCP1402 Boost Converter

I’m always on the lookout for interesting breakout boards to simplify hardware development. A recent post from @HybridAR1 showed a tiny breadboard-friendly breakout board for the NCP1402 boost converter:

The Wandering Engineer also has a very nice writeup on the NCP1402 at

Simple Boost / Step-up DC-DC Converter Using the NCP1402

including a board design with JST connectors which is good if you have a LiPo battery upstream. The Usual Suspects (Sparkfun, et al.) also have breakout boards for the NCP1402 but given that it requires two capacitors, an inductor, and a Schottky diode, the reference design is a good toy problem for learning to use KiCad or Eagle to spin up your own boards. Be sure to check your board fabricator for guidelines for your EDA files to reduce fabrication difficulties (here are Oshpark’s guidelines)

Hello world!

All websites are continuously under construction, this one more so.

It’s a big leap into consulting yet not really a big leap at all. Someone still has to balance the books, handle the administrative overhead, find work, do work, ensure staff is trained and engaged and focused, and keep one eye on the future and one on the present. For the past nine years I’ve done some of these tasks; now I get to do all of them.

Truth is, I love the technical work; understanding problems and finding solutions, helping clients make good evidence-based decisions and reducing uncertainty and cost. There’s satisfaction both in solving a one-of-a-kind technical challenge and in automating a complex process, in creating something completely new and in revitalizing systems to extend their capabilities.

Work should be more than punching a clock, chasing TPS reports, or ticking off items on a checklist. It won’t always be easy or fun but overall it should be satisfying. This satisfaction has kept me going for nine years and, with any luck, will keep me going for many more.