Is there a way to set up path for Fortran compiler?

Numerical methods and mathematical models of Elmer
Post Reply
Estiivan
Posts: 25
Joined: 14 Nov 2016, 14:06
Antispam: Yes

Is there a way to set up path for Fortran compiler?

Post by Estiivan » 16 Dec 2016, 11:48

I have a user defined function that I'd like to compile with command

$ elmerf90 -o MyLibrary.so MyLibrary.f90

but it seems that elmersolver does not found Fortran compiler:

/usr/bin/x86_64-linux-gnu-gfortran -o MyLibrary.so MyLibrary.f90 -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O3 -fPIC -shared -I/usr/share/elmersolver/include -L/usr/share/elmersolver/../../lib/elmersolver -shared -lelmersolver
/usr/bin/elmerf90: 25: /usr/bin/elmerf90: /usr/bin/x86_64-linux-gnu-gfortran: not found

$ whereis gfortran-6
gfortran-6: /usr/bin/gfortran-6 /usr/share/man/man1/gfortran-6.1.gz

So right path would be /usr/bin/gfortran-6. How (or where) can I change the path to that?

With regards,
Estiivan

annier
Posts: 1117
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Is there a way to set up path for Fortran compiler?

Post by annier » 16 Dec 2016, 12:57

Hi Estiivan,
If you have installed Elmer using launchpad, then you don't need to care the path of elmerf90 wrapper for converting the F90 files into shared objects. Just jump into the directory where you have your UDF or fortran file and type:

Code: Select all

$ elmerf90 -o myfilename.so myfilename.F90
But in your context, there may be an issue with gfortran compiler.
I don't understand why gfortran-6 library gets into your /usr/bin/ folder instead of gfortran.
In my context, i have no gfortran-6 in /usr/bin/
instead I have only gfortran library.

Code: Select all

$ gfortran --version
GNU Fortran (GCC) 6.2.0
Copyright (C) 2016 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.

Code: Select all

$whereis gfortran
gfortran: /usr/bin/gfortran /opt/moose/gcc-6.2.0/bin/gfortran /usr/share/man/man1/gfortran.1.gz

Code: Select all

whereis gfortran-6
gfortran-6:
I am also using Elmer installed in Ubuntu 16.04 using launchpad.
As gfortran is very essential for Elmer libraries, please check your gfortran libraries.

Code: Select all

$ gfortran --version

Code: Select all

$ whereis gfortran


Yours Sincerely,
Anil Kunwar
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

kataja
Posts: 74
Joined: 09 May 2014, 16:06
Antispam: Yes

Re: Is there a way to set up path for Fortran compiler?

Post by kataja » 19 Dec 2016, 12:06

Hi!

Are you sure you have gfortran installed? The elmerf90 is a wrapper script that calls fortran (in ubuntu it's gfortran) compiler. It reads environment variable ELMER_Fortran_COMPILER and uses its value as compiler command. For example

Code: Select all

$ ELMER_Fortran_COMPILER=gfortran-4.9 elmerf90 --version
gfortran-4.9 --version -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS ....
GNU Fortran (Ubuntu 4.9.3-13ubuntu2) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
However, the compiler variable should be set to the one that ElmerSolver was compiled with.

Cheers,
Juhani

annier
Posts: 1117
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Is there a way to set up path for Fortran compiler?

Post by annier » 20 Dec 2016, 05:32

Hi Juhani and Estiivan,
In my context, it is as such:

Code: Select all

$ elmerf90 --version
/usr/bin/x86_64-linux-gnu-gfortran --version -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O3 -fPIC -shared -I/usr/share/elmersolver/include -L/usr/share/elmersolver/../../lib/elmersolver -shared -lelmersolver 
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
So,Estiivan what does your result come when you type in terminal ?

Yours Sincerely,
Anil Kunwar
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

Estiivan
Posts: 25
Joined: 14 Nov 2016, 14:06
Antispam: Yes

Re: Is there a way to set up path for Fortran compiler?

Post by Estiivan » 20 Dec 2016, 16:47

Hello all,

$elmerf90 --version
/usr/bin/x86_64-linux-gnu-gfortran --version -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O3 -fPIC -shared -I/usr/share/elmersolver/include -L/usr/share/elmersolver/../../lib/elmersolver -shared -lelmersolver
/usr/bin/elmerf90: 25: /usr/bin/elmerf90: /usr/bin/x86_64-linux-gnu-gfortran: not found

I installed Elmer by launch pad to completely clean Ubuntu 16.04 by giving three commands

sudo add-apt-repository ppa:elmer-csc-ubuntu/elmer-csc-ppa
sudo apt-get update
sudo apt-get install elmerfem-csc

As ElmerGUI started ok, I thought everthing was ok. But I guess installation did not go well after all. I have had to re-install Ubuntu for other reasons and maybe I try it just once more.

Estiivan
Posts: 25
Joined: 14 Nov 2016, 14:06
Antispam: Yes

Re: Is there a way to set up path for Fortran compiler?

Post by Estiivan » 20 Dec 2016, 18:27

I have used launcpad for installing Elmer and it seems to work, ElmerGUI starts and seems to work (tried geoslab.grd). So I guess there is nothing wrong with Elmer installation. Or should gfortran have come installed at the same time?

I installed gfortran-6 but I guess it is not right version:

$elmerf90 --version
/usr/bin/x86_64-linux-gnu-gfortran --version -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O3 -fPIC -shared -I/usr/share/elmersolver/include -L/usr/share/elmersolver/../../lib/elmersolver -shared -lelmersolver
/usr/bin/elmerf90: 25: /usr/bin/elmerf90: /usr/bin/x86_64-linux-gnu-gfortran: not found

Which version of gfortran I should install to fix this?

With regards,
Estiivan


kataja wrote:Hi!

Are you sure you have gfortran installed? The elmerf90 is a wrapper script that calls fortran (in ubuntu it's gfortran) compiler. It reads environment variable ELMER_Fortran_COMPILER and uses its value as compiler command. For example

Code: Select all

$ ELMER_Fortran_COMPILER=gfortran-4.9 elmerf90 --version
gfortran-4.9 --version -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS ....
GNU Fortran (Ubuntu 4.9.3-13ubuntu2) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
However, the compiler variable should be set to the one that ElmerSolver was compiled with.

Cheers,
Juhani

kataja
Posts: 74
Joined: 09 May 2014, 16:06
Antispam: Yes

Re: Is there a way to set up path for Fortran compiler?

Post by kataja » 21 Dec 2016, 14:34

Hi,

whichever version

Code: Select all

 $ apt-get install gfortran 
install should do the trick.

-Juhani

Post Reply