Linking Elmer solver with OpenCalphad

Numerical methods and mathematical models of Elmer
serge_13
Posts: 24
Joined: 16 Oct 2015, 17:15
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by serge_13 »

Thank you, I'll try be familar with it. Need some time.

Serge.
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by annier »

Hi Serge,

Code: Select all

$gfortran -o tqex1 TQ1-crfe.F90 liboctq.o liboceq.a 
How can we make TQ1-crfe.F90 equivalent to a shared object library of Elmer so that it can be compiled by elmerf90 compiler?

Yours Sincerely,
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by annier »

Hi Serge,
I replaced TQ1-crfe.F90 with OCWrapper.F90(having the template of User Defined Function of Elmer but contents of TQ1-crfe.F90) and compiled with elmerf90 linker to produce the following error:

Code: Select all

$elmerf90 -o OCwrapper.so OCwrapper.F90 liboctq.o liboceq.a 
/usr/bin/f95 -o OCwrapper.so OCwrapper.F90 liboctq.o liboceq.a -fopenmp -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O2 -g -DNDEBUG -fPIC -shared -I/home/ma-haitao/elmer8/install/share/elmersolver/include -L/home/ma-haitao/elmer8/install/lib/elmersolver -shared -lelmersolver 
/usr/bin/ld: liboceq.a(metlib3.o): relocation R_X86_64_32S against `__metlib_MOD_tophlp' can not be used when making a shared object; recompile with -fPIC
liboceq.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
What has to be done here to solve the error?

Yours Sincerely,
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
serge_13
Posts: 24
Joined: 16 Oct 2015, 17:15
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by serge_13 »

i) Try to compile all sources strightly to OCWrapper.so without intermediate library(s) *.a . It's very interesting, but the library liboceq.a includes the name '__general_thermodynamic_package_MOD_gx'. I have found it by file viewer ...

W.b.r.
Serge.
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by annier »

Hi Serge,
Thank you for your suggestions.
1. I prepared the shared object library of opencalphad (liboceq.so) as following:

Code: Select all

$gfortran -shared -fPIC -o liboceq.so metlib3.F90 lukasnum.F90 gtp3.F90 matsmin.F90 lmdif1lib.F90
.
2. Then i compiled the libraries with OCWrapper.F90 :

Code: Select all

$gfortran -c liboctq.F90

Code: Select all

$elmerf90 -o OCwrapper.so OCwrapper.F90 -loceq -loctq
This produced the following error log:

Code: Select all

 elmerf90 -o OCwrapper.so OCwrapper.F90  -loceq -loctq
/usr/bin/f95 -o OCwrapper.so OCwrapper.F90  -loceq -loctq -fopenmp -DCONTIG=,CONTIGUOUS -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O2 -g -DNDEBUG -fPIC -shared -I/home/username/elmer8/install/share/elmersolver/include -L/home/username/elmer8/install/lib/elmersolver -shared -lelmersolver 
/usr/bin/ld: cannot find  -loceq
/usr/bin/ld: cannot find -loctq
collect2: error: ld returned 1 exit status
Yours Sincerely,
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
serge_13
Posts: 24
Joined: 16 Oct 2015, 17:15
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by serge_13 »

What path for linked liboceq.so ? Here must be two files at least : *.so, and *.a (or *.la) . Control date and time of these.
You need to point to *.a or *.la file path via -L instruction. The -l instruction goes after -L only !!!

For example:
-L/home/username/elmer8/install/lib/elmersolver -shared -lelmersolver . Here -lelmersolver points to small 'import' library file name. Find it to understand the idea of linking for shared.

Serge.
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by annier »

Hi Serge,
I was busy in other things and could not follow this work recently. I need to learn more on this.
Will follow the example from OpenPhase software. Yes the path is very important in this context.
from our discussion, i have learnt that for linking this OpenCalphad software with Elmer, we need to use shared object libraries (dynamic libraries) instead of static libraries.
I need more efforts to learn all these stuffs.
cheers.

Yours Sincerely,
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Linking Elmer solver with OpenCalphad

Post by annier »

Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
Post Reply