cfortran.h with Compaq Fortran/Visual C++ 
Author Message
 cfortran.h with Compaq Fortran/Visual C++

Hi,

I need to integrate fortran routines in c++. I'm forced to do this on Microsoft
with Compaq Fortran and Visual C++. I like to use cfortran.h from
        http://www.*-*-*.com/ ~burow/cfortran/

I can build and link the examples. But when I execute the program I get
the following error:
        File: i386\chkesp.c
        Line: 42

        The value of ESP was not properly saved accros a function
        call. [..]

How can i fix this problem? Does someone has experiences with cfortran.h
on Windows? Are there other solutions to build a c++/fortran library which
can be used by normal VisualC++ programs.

I would like to stick with cfortran.h because it has a uniq way to
integrate fortran on many plattforms (Unix, Linux, Winodws(?))

Regards
Carsten
--
Carsten Ehbrecht

http://www.*-*-*.com/



Sat, 05 Mar 2005 00:22:24 GMT  
 cfortran.h with Compaq Fortran/Visual C++


Quote:
>I need to integrate fortran routines in c++. I'm forced to do this on Microsoft
>with Compaq Fortran and Visual C++. I like to use cfortran.h from
>    http://www-zeus.desy.de/~burow/cfortran/
>I can build and link the examples. But when I execute the program I get
>the following error:
>    File: i386\chkesp.c
>    Line: 42
>    The value of ESP was not properly saved accros a function
>    call. [..]
>How can i fix this problem? Does someone has experiences with cfortran.h
>on Windows? Are there other solutions to build a c++/fortran library which
>can be used by normal VisualC++ programs.

        I think you really need the experts on this one -- you appear to
be using mixed calling standards so that the stack pointer (ESP) is not being
restored.  Thinking back to when I did mixed-language programming,
typically C would clean its own stack after return from a subroutine
(sometimes well after, for efficiency) but Fortran would pop the stack
before (or during, with the 8086 instruction set) return from a
subroutine.

Quote:
>I would like to stick with cfortran.h because it has a uniq way to
>integrate fortran on many plattforms (Unix, Linux, Winodws(?))

        Read the chapters in your manuals on mixed-language programmin,
then look for all occurrences of "Powerstation" in cfortran.h and
undrstand what he's doing and what additions/alterations you might need
to make to your code.

--

        KotPT -- "for stupidity above and beyond the call of duty".



Sat, 05 Mar 2005 14:43:49 GMT  
 cfortran.h with Compaq Fortran/Visual C++

Quote:

> Hi,

> I need to integrate fortran routines in c++. I'm forced to do this on Microsoft
> with Compaq Fortran and Visual C++. I like to use cfortran.h from
>         http://www-zeus.desy.de/~burow/cfortran/

> I can build and link the examples. But when I execute the program I get
> the following error:
>         File: i386\chkesp.c
>         Line: 42

>         The value of ESP was not properly saved accros a function
>         call. [..]

> How can i fix this problem? Does someone has experiences with cfortran.h
> on Windows? Are there other solutions to build a c++/fortran library which
> can be used by normal VisualC++ programs.

> I would like to stick with cfortran.h because it has a uniq way to
> integrate fortran on many plattforms (Unix, Linux, Winodws(?))

> Regards
> Carsten
> --
> Carsten Ehbrecht

> http://www.linacs.org

I have some experience with it on Windows (with the same combination
:-).
But I can not find this example in my version. Can you show me the code?

Regards,

Arjen



Sat, 05 Mar 2005 15:44:09 GMT  
 cfortran.h with Compaq Fortran/Visual C++

| Hi,
|
| I need to integrate fortran routines in c++. I'm forced to do this on
Microsoft
| with Compaq Fortran and Visual C++. I like to use cfortran.h from
| http://www.*-*-*.com/ ~burow/cfortran/
|
| I can build and link the examples. But when I execute the program I get
| the following error:
| File: i386\chkesp.c
| Line: 42
|
| The value of ESP was not properly saved accros a function
| call. [..]
|
|
| How can i fix this problem? Does someone has experiences with cfortran.h
| on Windows? Are there other solutions to build a c++/fortran library which
| can be used by normal VisualC++ programs.

It's hard to tell without seeing the code. It's definitely about
calling conventions -- the default for CVF is __stdcall, while the
default for VC++ is __fastcall (for .cpp files, for .c files it's
__cdecl). I'm not sure which combination is actually used and how
it is mismatched. Also, it's hard to tell how cfortran.h gets in
the way. I see it has FCALLSC_QUALIFIER define for __stdcall.
However, it's hard to *link* a program with mismatched conventions
*unless* it uses arguments which are routines (i.e. EXTERNALs).

Anyway, it would be a good idea to debug the program and use
"Call stack" de{*filter*} button after the crash to (try to) see where
it originates from.

Take a look at "Decorated names" section in MSDN. (VC++ Programmer's Guide).
Among other things, it says:

      Calling Convention Decoration
      __cdecl (the default) Leading underscore (_)

number representing the number of bytes in the parameter list
      __fastcall Same as __stdcall, but prepended by an at sign instead of an
underscore

You can inspect symbols of the functions you find suspicious
in your .obj files by using dumpbin /symbols myfile.obj.
That *might* tell you about the causes.

--
 Jugoslav
___________
www.geocities.com/jdujic



Sat, 05 Mar 2005 15:47:12 GMT  
 cfortran.h with Compaq Fortran/Visual C++
Quote:

> I have some experience with it on Windows (with the same combination
>:-).
> But I can not find this example in my version. Can you show me the code?

Finally I got it running with the settings for VisualC++ described on:
http://scipp.ucsc.edu/groups/silicon/ATLAS/DaqLab/soft/usingFor/

I can now generate a lib for my Fortran/C++ code. It's also possible to
use this library in a VisualC++ console-application.

But I have to integrate it in MFC-Application. Now I have the problem
that the compiler complains about my include-file filter.h:

// ======================================================
//          to initilize cfortran.h
// ======================================================

#ifdef WIN32
#ifndef VISUAL_CPLUSPLUS
#define VISUAL_CPLUSPLUS
#endif
#endif

#include "cfortran.h"

// ========================================================

#include <stdio.h>
#include <stdlib.h>

// firfilter_f.f
PROTOCCALLSFSUB8(BNDFLT,bndflt,FLOATV,FLOAT,FLOAT,FLOAT,FLOAT,FLOAT,FLOAT,FLOATV)
#define bndflt(F,M,T,N,FU,FO,TYP,G)
CCALLSFSUB8(BNDFLT,bndflt,FLOATV,FLOAT,FLOAT,FLOAT,FLOAT,FLOAT,FLOAT,FLOATV,F,M,T,N,FU,FO,TYP,G)

------------------------

The error message is:

[..]\filter.h(25) : error C2065: 'BNDFLT' : nichtdeklarierter Bezeichner

It says that my subroutine name BNDFLT is not declared.

What can I do?

Regards
Carsten

--
Carsten Ehbrecht

http://www.linacs.org



Sat, 05 Mar 2005 21:46:59 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Mixing Compaq Visual Fortran 6 with Microsoft Visual C++ .NET

2. Question on using Compaq Visual FORTRAN with Microsoft Visual C++ 6.0

3. Creating - Fortran 77 dll for use in Visual Basic 6.0 (not using Compaq Visual Fortran)

4. Building DLLs with Compaq Visual Fortran and Intel Visual Fortran

5. C++ Calling Compaq Visual FORTRAN

6. Compaq Visual Fortran or Intel Fortran Compiler?

7. Compaq visual fortran and Watcom fortran

8. using Intel Visual Fortran with Visual C++ 2005 Express

9. Compaq Visual Fortran on WINDOWS Problem

10. Compaq Visual Fortran Code Coverage Analysis

11. F2py and Compaq Visual Fortran 6.6, Win-XP

12. Compaq visual fortran and WIN2000

 

 
Powered by phpBB® Forum Software