NO

Author Topic: Fortran with Pelles C; f2c  (Read 3974 times)

ofniw

  • Guest
Fortran with Pelles C; f2c
« on: January 08, 2007, 06:22:00 PM »
Hi everybody,

my problem is to use a Fortran subroutine from Pelles c. I have translated the subroutine with the precompiler f2c, which worked well.
Pelles C did not find a syntax error.
The problem comes with the linker. The linker is missing the f2clib called f77.lib. Using a f77.lib which I found in the Internet, generated other references not available in the libraries.

Has anybody experience with Fortran an Pelles C ? Has anybody tried a similar approach?

I searched the forum for "Fortran" and could not find an answer. So I hope, I do not pose a question, that was already answered.

Thanks in advance.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Fortran with Pelles C; f2c
« Reply #1 on: January 09, 2007, 01:48:37 PM »
Sounds like a 'new problem', or a variation of an 'old problem'.

Did you get any warnings when compiling the C code (like "Missing prototype for '...'")?
More specifically what type of linker errors did you get?
Where did you find the f77.lib? (Is the format 'Microsoft compatible' ...)?
/Pelle

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Fortran with Pelles C; f2c
« Reply #2 on: January 09, 2007, 06:47:58 PM »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

ofniw

  • Guest
Fortran with Pelles C; f2c
« Reply #3 on: January 09, 2007, 08:14:23 PM »
Thank you all very much for your response.

I'd like to answer your questions.

I have also added an attachement, which might provide some additional explanation.

The attachement contains five blocks:
Block1: Error messages when compiling and linking
Block2:  Error messages when compiling and linking
Block3: The original Fortran source
Block4: The derived c-file
Block5: the header file

As you can see from looking at block1 and block2, there is no error message or warning from the compiler.
As block1 shows, there are calls to subroutines for handling complex numbers, that are not available from the standard libraries. By adding a link to libf77.lib and libi77.lib, these references are satisfied, however new ones are generated ( see block2 ).

I downloaded the Programs from http://www.weihenstephan.de/~syring/f2c/f2c.html.

It seems that the files are identical to those provided by frankie, however I must admit, that I do not understand what he wants me to do.

Regards to all

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Fortran with Pelles C; f2c
« Reply #4 on: January 10, 2007, 10:57:00 AM »
I'll try to be more clear:
I provided the projects to build the translator (f2c.exe) and the fortran library (that I called libf2c.lib instead of f77.lib).
The errors that you get are due to the fact that the library you are using has been built with M$VC and  use the msvcrt.lib (for advanced readers: the main() function is in the library, the generated source creates an entry point for the fortran PROGRAM token that will be called from the startup code in the library).  :mrgreen:  :mrgreen:  :mrgreen:
So you can:
  Try to check the "omit default libraries" in the switch -Zl (I'm not sure it works)

OR

Simply use the library libf2c.lib that I provided instead of the f77.lib that you got.

OR

  1) compile your fortran sources with the translator that I provided
  2) compile the produced c files and link them with the libf2c.lib that I provided


 :mrgreen:  :mrgreen:  :mrgreen:  :mrgreen:

Anyway coding in FORTRAN with a translator makes programs really slow  #-o , but there is so much math code available in FORTRAN  8)
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Fortran with Pelles C; f2c
« Reply #5 on: January 10, 2007, 05:00:47 PM »
Yet C99 adds a bunch of new math functions - As I understand it to attract some Fortran users...

Complex math is part of C99, but more or less optional. It may be included in the next release....
/Pelle

ofniw

  • Guest
Fortran with Pelles C; f2c
« Reply #6 on: January 10, 2007, 11:13:20 PM »
Hallo Frankie,
I tried your proposal.

The  "Try to check the "omit default libraries" in the switch -Zl (I'm not sure it works)" did not work, indeed.

However the second proposal, using different library, worked fine.

Let me thank all and especially you, for the advice. Maybe some others can also benefit from this discussion.