<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi Evert,<DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR><DIV><DIV>On Nov 30, 2005, at 1:17 AM, Evert Glebbeek wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Anyway, current result:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">glebbeek@siu024: ~/Program/cfort/cfortran>make</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">[...]</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">ffun_main.o(.text+0x68): In function `ffun_main':</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/kasper/strknd/glebbeek/Program/cfort/cfortran/ffun_main.f:6: undefined<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">reference to `start_'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/lib/libruby-static.a(string.o)(.text+0x4f2e): In<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">function `rb_str_crypt':</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/Program/Ruby/ruby-1.8.3/string.c:4360: undefined<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">reference to `crypt'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/lib/libruby-static.a(dln.o)(.text+0xbc): In function<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">`dln_load':</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/Program/Ruby/ruby-1.8.3/dln.c:1351: undefined reference<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">to `dlopen'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/lib/libruby-static.a(dln.o)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(.text+0xd1):/home/strknd/glebbeek/Program/Ruby/ruby-1.8.3/dln.c:1356:<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">undefined reference to `dlsym'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/lib/libruby-static.a(dln.o)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(.text+0x12d):/home/strknd/glebbeek/Program/Ruby/ruby-1.8.3/dln.c:1359:<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">undefined reference to `dlclose'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/lib/libruby-static.a(dln.o)(.text+0x5): In function<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">`dln_strerror':</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/home/strknd/glebbeek/Program/Ruby/ruby-1.8.3/dln.c:1193: undefined reference<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">to `dlerror'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">make: *** [fun] Error 1</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">glebbeek@siu024: ~/Program/cfort/cfortran></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The Ruby errors maybe can be ignored for now, since it might just be that my<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">installation is broken somehow. I'll read up on embedding Ruby into another<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">programme myself and see if I can fix it.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>The 'crypt' errors from Ruby are a mystery, but the 'dl' errors look like the -ldl was necessary after all (didn't need it on Mac). <DIV><BR class="khtml-block-placeholder"></DIV><DIV>I've changed the makefile line to this:</DIV><DIV>RUBY_LIB = -L$(RUBY_DIR) -lruby -ldl</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>You might try that and see if the 'dl' problems go away (I don't think those were there before).</DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The ffun_main.f error is a bit more serious and the sortof headache I was<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">afraid of: different compilers do different things to function names on<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">different platforms. Apparently, the Intel Fortran compiler adds an<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">underscore to the end of the function name in the object file while GCC does<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">not do the same for C files. Come to think of it, I think GCC does the same<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">for Fortran files, but it's been over a year since I was calling Fortran from<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">C. There has to be a way to figure out what the compiler is doing and<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">compensate for that, but to do it automatically requires a script to detect<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">what's happening at compiletime and some C preprocessor magic, I think.</DIV></BLOCKQUOTE><BLOCKQUOTE type="cite"></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The problems with underscores on function names is exactly the sort of thing that cfortran.h is designed to address. In the makefile, there is the following line:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>CFLAGS = -g -c -DAbsoftProFortran</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The '-DAbsoftProFortran' is to tell cfortran.h which fortran compiler we're using. It then puts the underscores in the right places.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>That's the good news. The bad news is that cfortran's list of compilers doesn't include all the compilers you might hope for (but you are in luck if you are running on VMS or Apollo or VAX or CRAY or NEC!). As I mentioned in my first email about this stuff, I got it to work with the Absoft ProFortran compiler on the mac, but not the IBM xlf compiler.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If you look at cfortran.h starting about line 100, you'll see lots of logic/magic worrying about the differences among fortran compilers. The trick is to find something that it knows about that matches what your compiler does. Check the web page: <A href="http://www-zeus.desy.de/~burow/cfortran/cfortran.html">http://www-zeus.desy.de/~burow/cfortran/cfortran.html</A> for more info (in section II there is a section on "Specifying the FORTRAN compiler").</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If, a big if, you can find a combination of compilers that works with cfortran, it seems to be a very nice solution. It covers the bases:</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>calling Fortran subroutines and functions from C</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>calling C subroutines and functions from Fortran</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>arg types include <FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">[BYTE|DOUBLE|FLOAT|INT|LOGICAL|LONG|SHORT][V|VV|VVV|...]</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>where V means 1 dimension array, VV means 2 dimension, etc.</SPAN></FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>strings and function pointers as arguments </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>C or Fortran routines can be passed either direction, C to Fortran or Fortran to C</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>can use C to directly access Fortran common blocks for communication of data </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>(probably a bad idea in practice, but nice to know it is possible)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BLOCKQUOTE type="cite">Just for kicks, I'll see if I still have the Intel C compiler installed and <DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">see what happens if I use that instead of GCC.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Good idea. At this point, I'm not concerned about making lots of C+Fortran compiler combinations work -- just one would be nice! Although the Intel fortran might be preferred over the Lahey? I seem to remember Onno running into some compiler problems trying to build EZ using the Lahey compiler. Did you experience anything like that? Also, when Mac switches to Intel starting next year, I expect that the ifort compiler may well appear on the Mac before the Lahey one. Perhaps Intel C with Intel fortran will work!</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Cheers,</DIV><DIV>Bill</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR></DIV></DIV></BODY></HTML>