- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have problem in writing my bachelor work. My bachelor work is mostly about taking out some subroutines from fortran code (i think it's Fortran 77 ) .Then rewrite them in to C++ and make DLL which will work with old fortran code. C++ dll will need to take data from common blocks nad other fortran variables.
First of all i have never wrote in Fortran but rewriting most of thing wasn't a problem. I did stuck in some moment and I really need help.
My first problem is that how should i write connection between common block in Fortran and C++.All common blocks are used first in Fortran then in C++. Only one function(hard) is called by Fortran, rest of them is used by this function hard, but all of them are using variables and common block from fortran.
I wroted this :
libmnu.h (part) :
#ifndef LIBMNU_H
#define LIBMNU_H
typedef int INTEGER;
typedef double REAL;
typedef double DOUBLE_PRECISION;
typedef int LOGICAL;
#define SUBROUTINE extern "C" void __declspec(dllexport)
namespace libMNU
{
extern "C" { //////////////// this variables in fortran code are not declarated anywhere ,so i think they should be extern
extern REAL r, t273, rt, z, yield;
extern REAL dsq3,beta,betas,r0,bts,bt,w;
extern REAL sigmainit, sigma_sse,e_c,e_xs,e_s,e_r,e_xr,sigma_ss,sigma_soft;
}
extern "C"
{
extern struct flow_function
{
INTEGER n_function;
};
extern struct flow_function flow_function;
}
SUBROUTINE hard (double&,double&,double&,double&);
void x1 (double&,double&,double&,double&);
void x2 (double&,double&,double&,double&);
void x3 (double&,double&,double&,double&);
void x4 (double&,double&,double&,double&);
void x5 (double&,double&,double&,double&);
void x6 (double&,double&,double&,double&);
...
//// End of file
libmnu.cpp:
SUBROUTINE hard(double& e,double& edot,double& t,double& yield)
{
// double e,edot,t,yield;
switch(flow_function.n_function)
{
...
/// End of file
My explanation:
I was reading that common blocks should be like that:
extern "C"
{
extern struct
{
INTEGER n_function;
} flow_function;
}
, but then i saw "IntelliSense: declaration is incompatible with "libMNU::flow_function libMNU::flow_function" " and i read that it should be like above in code.
Here is sample of fortran code:
subroutine Hard(e,edot,t,yield)
IMPLICIT REAL*8 (A-H,O-Z)
common/flow_function/n_function
GoTo(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)n_function
call x1(t,e,edot,yield)
go to 100
1 call x2(t,e,edot,yield)
go to 100
2 call x3(e,edot,t273,yield)
My first question is does someone know how should it be ?
Does compiling of this dll will be diffrent from normal ?
Since i will need in the future to compile fortran with .lib file i want to ask is it possible to do that all in Visual Studio 2010 with Intel Fortran Composer XE ?
I'm sorry if i my writing is bit chaotic and ask too much in one topic.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page