Every time when I try to install the fortran stdlib in MacOS with
brew tap fortran-lang/stdlib
brew install fortran-lang/stdlib/stdlib
and it shows me with the error
Cloning into '/opt/homebrew/Library/Taps/fortran-lang/homebrew-stdlib'...
Username for 'https://github.com': shiqsh
Password for 'https://xxxx@github.com':
remote: Repository not found.
fatal: repository 'https://github.com/fortran-lang/homebrew-stdlib/' not found
Error: Failure while executing; `git clone https://github.com/fortran-lang/homebrew-stdlib /opt/homebrew/Library/Taps/fortran-lang/homebrew-stdlib --origin=origin --template= --config core.fsmonitor=false` exited with 128.
So how to fix the error? and if there is a easy way to install the fortran-stdlib in MacOS?
Unless there is some magic I’m not aware of in the MacOS world (not a mac user), stdlib is not a package installable through any OS package manager. It is a source-code based library that you have to download, build and install, for instance using CMake or FPM. The instructions are here GitHub - fortran-lang/stdlib: Fortran Standard Library
As far as I’m aware, stdlib isn’t a package installable through brew any more than it is through aptitude, pacman, etc.. If you are using the Fortran Package Manager for your project, the easiest way is to simply include the stdlib metapackage by adding to following to your project’s toml file:
[dependencies]
stdlib = "*"
Simple and hassle-free. More info and alternatives are in the README in stdlib’s repository that @hkvzjal pointed to.
Hello! stdlib is a collection of modules and there is no such module as fortran_stdlib which you seem to be using in your in source file test_stdlib.f90
Instead a minimal testing source file could be this
program demo
use stdlib_ascii, only: is_lower
implicit none
print *, is_lower('a')
end program demo
Compile it with the following command (Don’t forget to link with the static library as below!)
This should produce an executable with the desired output.
of course the compile command can turn real messy real fast, you could try to shorten it by making use of pkgconfig, the pkgconfig file for stdlib is located at /opt/homebrew/Cellar/fortran-stdlib/0.7.0/lib/pkgconfig/fortran_stdlib.pc
If one does a google search on “homebrew fortran-stdlib”, then the AI Overview does indeed indicate that the command “brew install fortran-stdlib” is supported within the homebrew package manager.
I think this is the problem. Namely, what is the USE statement in your fortran code? That is what tells the compiler which module file to search for. Module files are created by the fortran compiler during the build of stdlib, and to use them afterwards, both the object file (somename.o) and the module file (modulename.mod) are used. I don’t know the details beyond that for stdlib, but it is likely that the *.o files are moved into an archive library so that only that one library needs to be searched during the load step (either ld, or by the fortran compiler itself). However, the *.mod files must usually be available themselves, not from a library of merged files.
Note the module name that is referenced in the USE statement.
Right now, and for the foreseeable future, each fortran compiler has its own *.mod file format, so individual compilers need to create their own files, and one compiler cannot access another compiler’s *.mod files.
I am not a fortran-stdlib user, so the above comments are just based on what the google search says.