Wednesday, 28 November 2007

More NAG problemos

So, to re-cap, the NAG library wants me to have gfortran 4.2.0 or better. I installed the only ready-built new version of gfortran I could find for linux (since Mandriva doesn't offer a package newer than version 4.1.2), which was 4.3.0. I have the NAG library working fine with this new version of gfortran, and it cries if I try to use the old fortran compiler. To re-cap, I now have two compilers on my computer:
"New"
gcc version 4.3.0 20071121 (experimental)
"Old"
gcc version 4.1.2 20070302 (prerelease)

So all is splendid (when I use the routine S14BAF to find the incomplete gamma function) after a few angry words about data-types. You must use double-precision variables (not real(kind = 10) or anything) or else it just returns junk. This will only work if I compile with the new gfortran version.

However , (and there's always a "however" with me and linux!), now I try to compile a program which uses the random number routines G05MKF and similar. The new compiler now gets angry:
/opt/NAG/fll3a21dfl/lib/libnag_nag.a(g05mkxn.o): In function `g05mkxn_':
g05mkxn.f:(.text+0xde): undefined reference to `_gfortran_pow_r8_i4'
/opt/NAG/fll3a21dfl/lib/libnag_nag.a(g05mkzn.o): In function `g05mkzn_':
g05mkzn.f:(.text+0xb1): undefined reference to `_gfortran_pow_r8_i4'
collect2: ld returned 1 exit status
This subroutine "_gfortran_pow_r8_i4" is apparently supposed to be in libgfortran.a and many people have solved their problems by explicitly telling their compiler where to look for this when linking, eg.
/etc/irun/bin/gfortran -m32 simtest.f90 /opt/NAG/fll3a21dfl/lib/libnag_nag.a -o simtest -L/etc/irun/lib -lgfortran
But this still doesn't work. Anyway, I added this directory to the path before hand, so this probably is not the problem. I look at the contents of the libgfortran library using the command:
nm libgfortran.a |more
where I've piped it through the "more" doo-dah so it doesn't all flash by at once. There are lots of similar routines to "_gfortran_pow_r8_i4", but no actual version of the one I want. So my compiler is not lying! I have not so far found a new version of the library which contains this, but my old compiler library does! So for all my random number programs, I must still use the old compiler, which seems to work just fine. Perhaps I can add the subroutine from the old library into the new one? Or will there be other issues?
This page is quite helpful about libraries, I found...

5 comments:

Michael said...

Well, I now don't remember how I found it! But I still think it is you. And I didn't really just how geeky you are, but I applaud it nonetheless! ;)

Michael said...

*realise, not "really"

Also I meant to comment in reply on previous post. Don't quite know what happened. I am a little teensy bit drunked. :)

Ali said...

How bizarre. I'm not sure I understand what you are trying to say! If it sounds like I'm geeky then I guess that's no surprise- this is my blog about linux battles, after all! Who are you, if it's not too rude to ask?

Michael said...

I'm terribly sorry if I have offended you - from me, "geeky" is a compliment :)
I can't remember how I found this blog, but at the I seemed to be under the impression that you are an Alice whom I know; I can't remember why I thought that, either. Maybe it was the "it's great to go shopping in Stafford" quote.
If it is indeed you, hello from Mr Bannister.
If it is not you (well, obviously you are you, just not the you I thought you were) then please accept my apologies.

Ali said...

Ahhhhhhhhhhhh! Michael!!!!!!!!!!!!!! Hahahaha it is indeed me! Sorry, I had no idea it was you! Of course you didn't offend me with the geek comment (physics- there's no hope!) I now understand your comment "But I still think it is you." Sorry for demanding your identity so rudely! How exciting- how are you? I'm sorry my blog is such a dull read ;-) Hows life in the big city? xxx