I am writing to seek your assistance regarding an issue I encountered with Gfortran. I am using Ubuntu 22.04.3 LTS, with the GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 is 11. I need to updated to Gfortran v13 to compile CNS. Therefore, I run the command below
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
Then I run
gfortran --version
but I see that I still have gfortran-11 installed.
Please does anyone know how to upgrade gfortran-11 to gfortran-13?
Also how can I remove Gfortran -11 from my system?
My operating system is: intel-x86_64bit-linux
I am using bash shell
The other versions must be called with their major version: gfortran-??
It is generally useful to have several versions installed. Your program may sometimes run faster with an older version. And older versions are more debugged (higher minor version). For example I have the 13.2, 12.3, 11.4 and 10.5.
Nothing per-se. The software you are trying to install expects the compiler to be named gfortran, otherwise the provided build system doesn’t work.
You could try to create a copy of the Makefile templates and rename them to have gfortran-13 at the end. Actually this is what the CNS authors recommend: CNS Installation — haddock3 3.0.0 documentation
Makefile headers for each supported system-compiler combination are provided in instlib/machine/supported/ (for unsupported systems, see instlib/machine/unsupported/). If you already tried make install, the appropriate directory for your system (eg. mac-intel-darwin) will have been copied to the main cns_solve_1.3 directory. If this directory does not contain the desired file (eg. Makefile.header.2.gfortran), you can create one manually.
For example, for gfortran, create a new file named Makefile.header.6.gfortran inside the directory containing Makefile headers for your system. […continued…]
This alias would work during the execution of the current shell. You can also set this in your bashrc such that every time you open a shell it would automatically create the alias and always point to this version. I have created a small function in my bashrc in order to switch between different version of gnu or sourcing different versions of intel compilers as well.
That is useful shortcut, especially for a piece of software which only needs to be built once.
On Linux there is also the update-alternatives tool. I’ve used it a few times, but it is a bit involved to setup, and if you don’t use it often, you forgot how to switch between alternatives. This blog post explains its use.
Thank you so much for prompt reply. I will try ivanpribec solution which is the CNS authors recommend. Does a number “6 “in the command Makefile.header.6.gfortran is a way to name the new file and it does not represent any version or resources.
A solution is to modify the symbolic link. For example, here I replace gfortran-13 (default in my distribution) by gfortran-10:
$ ls -o /usr/bin/gfortran
lrwxrwxrwx 1 root 20 août 25 12:18 /usr/bin/gfortran -> /usr/bin/gfortran-13
$ sudo ln -s -f /usr/bin/gfortran-10 /usr/bin/gfortran
$ gfortran --version
GNU Fortran (Ubuntu 10.5.0-4ubuntu2) 10.5.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ls -o /usr/bin/gfortran
lrwxrwxrwx 1 root 20 août 25 12:17 /usr/bin/gfortran -> /usr/bin/gfortran-10
You need the -f option (--force) of the ln command because the link already exists.
Note that I don’t know what will happen to that link if an upgrade of your system modifies the gfortran files.