Finding Fortran code from the command line

fpm-search finds information about registered fpm (Fortran Package Manager) packages. Since my list of Fortran codes is just a Markdown file, it is simple to search it from the command line as well. For example, if the repo is downloaded so that /fullpath/README.md exists,

grep -i hash /fullpath/README.md

gives

fdict: native Fortran 90 dictionary with hash tables for retaining any data-type in a Python-like dictionary, by Nick Papior
fhash: hash table with support for generic keys and values, by Laurence Kedward
ffhash: generic and fast hash table similar to khash in C, by Jannis Teunissen
fh_table: modern Fortran hash functions and hash tables, by dbartilson
M_hashkeys: collection of hash key generator modules, by urbanjost
qContainers: container library for Fortran language. It enables one to store any internal Fortran data type and any derived data type to the container. It implements containers for key/value pairs: tree table and hash table, and containers for objects: list and vector.
Fortran General Library (FGL): code for bitstrings, exception handling, hash tables, lists, logging, queues, strings, sorting, JSON parsing, and other topics, from mobius-eng
fortran_notes: containers and advanced data structures, hash functions, and design patterns
M_hashkeys: collection of hash key generator modules, by urbanjost
libsparse: Fortran 2003 library that provides objects to create and handle rectangular and square sparse matrices using different formats: Linked List, COOrdinate storage (with elements stored using a hashing function), or Compressed Row Storage, by Jeremie Vandenplas. The library relies on different libraries, such as BLAS/LAPACK libraries, PARDISO (at this stage, Intel MKL PARDISO), and METIS 5.

On Windows one can use findstr -i instead of grep -i. Maybe fpm-search could add an option to search the list, although most of the repos in the list are not fpm packages.

1 Like

I use a GNU/Linux script to read HTML pages.
It requires another script (html2txt) and wget and curl if you do not have w3m
or lynx. It could easily use links(1) also, probably.

Anyway, I find it useful to do what you are describing, just with a different
approach that does not require pulling files to local storage.

I think that would be useful. Following your suggestion to mark fpm
repositories with the topic “fortran-package-mananger” to make them easier
to locate, I have been experimenting with using topics like “fpm-tool” and
“fpm-plugin” as well, and using github searches to find the repos:

fpm-tools

So personally, I think it would make fpm-search(1) even more useful to
do something like that and help all the CLI warriors to find things. Wish
more people were submitting packages to the repository as well. I think we
need a more automated method of putting candidates up so you can see those
immediately (still probably need a vetting process for actual acceptance,
probably). Seems to be the way other languages handle plugins and packages.

Capturing accepted packages as tar-balls or clones probably makes a lot of
sense too so things do not get “lost” in the future, more “netlib”-like in
that respect.

So one upvote from me.

url2txt
#!/bin/bash
################################################################################
# @(#) make a text file from an URL using w3m/lynx/wget/curl
################################################################################
export INFILE=$1
export TMPDIR=${TMPDIR:-'/tmp'}
################################################################################
if inpath w3m 
then
   w3m -O ascii -no-graph -cols 132 -dump -T text/html $INFILE 
################################################################################
elif inpath lynx 
then
   lynx -dump $INFILE 
################################################################################
elif inpath wget
then
   wget -O - -q -t 1 $INFILE |html2txt
################################################################################
elif inpath curl
then
   curl -s $INFILE|html2txt
################################################################################
fi
################################################################################
exit
################################################################################
inpath
#!/bin/bash
################################################################################
# @(#)inpath: true if command is in path (John S. Urban)
################################################################################
EXIT=1        # exit code to be returned by command
NAME="$1"
################################################################################
   case "$NAME" in
################################################################################
   */*) # If / in name, assume full pathname
   if [ -x "$NAME" ]
   then
      #echo "FOUND : $NAME" 1>&2
      EXIT=0
   else
      EXIT=2
   fi
   ;;
################################################################################
   *) # search path for command name
   #if [ -x "$(which $NAME 2>/dev/null)" ]

   if hash "$NAME" 2>/dev/null
   then
      #echo "FOUND : $NAME" 1>&2
      EXIT=0
   else
      EXIT=3
   fi
   ;;
################################################################################
   esac
################################################################################
exit $EXIT
################################################################################
# see also: type, command, which, whereis
url2txt https://github.com/Beliavsky/Fortran-code-on-GitHub |grep hash

Also, the full package list from fortran-lang.org is available at https://fortran-lang.org/packages/projects_json.js which, after a little preprocessing, can be parsed with any json library.