Board index » delphi » FORTRAN code in DELPHI?

FORTRAN code in DELPHI?

Is this possible? If YES, how? Where can I get the info of how to do it?

Thank you very much. I am desperate to know this....please help

Aldeenor-

 

Re:FORTRAN code in DELPHI?


nxn...@psu.edu (Aldeenor Tristan) spake unto us:

Quote
>Is this possible? If YES, how? Where can I get the info of how to do it?

>Thank you very much. I am desperate to know this....please help

>Aldeenor-

You are going to have to be a bit more specific on this one. Most
FORTRAN functionality is available in Pascal; what exactly are you
looking for??

  -Greg

--------------------------------------
Greg Strauss, gstra...@islandnet.com
Victoria, BC, Canada

"...You can see the World from here!"
--------------------------------------

Re:FORTRAN code in DELPHI?


Quote
In article <nxn101.73.30BA8...@psu.edu> nxn...@psu.edu "Aldeenor Tristan" writes:
> Is this possible? If YES, how? Where can I get the info of how to do it?

> Thank you very much. I am desperate to know this....please help

> Aldeenor-

What you can do (assuming you have MS Fortran 5.1) is to make a Fortran DLL
and call it from a Delphi executable. Your MSF manual will tell you how to
make the DLL, and I use the syntax in the CALLDLL demo example to call it
(this is simpler, though less dynamic, than LoadLibrary etc.).

Catherine.
--
Catherine Rees-Lay                 Cathe...@polyhdrn.demon.co.uk

Polyhedron Software Ltd.        
Programs for Programmers - QA, Compilers, Graphics

************ Visit our Web site on http://www.polyhedron.co.uk/ ************

Re:FORTRAN code in DELPHI?


Quote
>Is this possible? If YES, how? Where can I get the info of how to do it?
>Thank you very much. I am desperate to know this....please help

The MS Fortran compiler (as well as the Lahey Fortran compiler)
can generate DLLs, so theoretically, it should be possible to call
Fortran generated code from a Delphi application.
See http://www.lahey.com and http://www.microsoft.com for more
information.

David

--
David Brabant,             | E-mail: David.Brab...@csl.sni.be
Siemens Nixdorf (SNI),     | CIS:    100337,1733
Centre Software de Lige,  | X-400:  C=BE;A=RTT;P=SCN;O=SNI;OU1=LGG1;OU2=S1
2, rue des Fories,         |         S=BRABANT;G=DAVID
4020 Lige (BELGIUM)       | HTTP:   www.sni.de       www.csl.sni.be/~david

Re:FORTRAN code in DELPHI?


Quote
In article <nxn101.75.30BBE...@psu.edu> nxn...@psu.edu "Aldeenor Tristan" writes:

> Ok..let say that if I have a FORTRAN code. A simple one like shown below

> implicit real*8 (a-h,o-z)
> open(unit=10, file='input',status='unknown')
> open(unit=20, file='output',status='unknown')
> read(10,*) xxx, yyy
> bbb=xxx+yyy
> write(20,*) bbb
> stop
> end

> I want to create a nice GUI (using Delphi) to input the xxx and yyy, and
> write it in another Window. I don't want to rewrite the above code in Pascal.

> So how am I going to incorporate this simple program into Delphi. If I compiled
> the above program in FORTRAN and run it with the INPUT file, I will surely
> get the output file with value of bbb. But it is UGLY :) I want to make it
> look nice (the bottom line)...using Delphi.

> I hope this is enuff for what I am looking for. I hope somebody can provide
> the details of how to do this coz I have a lot of FORTRAN code..now what I need
> is to make it user-friendly using Visual tool for the GUI part (just for the
> data input and output).

> Note: I am still learning Delphi so please don't use big words in the
> explanation.

> Thanks you...

> Aldeenor-

What you need to do is turn your program into a subroutine which you compile
into a DLL rather than an executable. (I've had problems with function
return values, but none with subroutine arguments). Say

      subroutine sum(xxx,yyy,bbb)
      implicit real*8 (a-h,o-z)
      bbb=xxx+yyy
      return
      end

Export this subroutine from your DLL. The MSF 5.1 Advanced Topics chapter on
Programming for Windows describes how to do this.

Now you can import it exactly as you would a procedure in a DLL written in
Delphi (see the calldll demo for an example) and you can now call sum just
as if it was written in Pascal. You need to be careful of data types, and
of passing by value / passing by reference (I pass everything by reference).

Now set up your nice Delphi window with 3 boxes, let the user type values in
the first 2 and press a button when he's ready, call sum with the values he
typed in the first 2 boxes, and then put the value you get back for bbb in
the 3rd box. No files, no kludges, no problems! (and no need to s{*word*99} all
that work you put into your legacy Fortran code :-)

Hope this helps,

Catherine.
--
Catherine Rees-Lay                 Cathe...@polyhdrn.demon.co.uk

Polyhedron Software Ltd.        
Programs for Programmers - QA, Compilers, Graphics

************ Visit our Web site on http://www.polyhedron.co.uk/ ************

Re:FORTRAN code in DELPHI?


Quote
Greg wrote:
>You are going to have to be a bit more specific on this one. Most
>FORTRAN functionality is available in Pascal; what exactly are you
>looking for??

Excellent. This is a good sign :)

Ok..let say that if I have a FORTRAN code. A simple one like shown below

implicit real*8 (a-h,o-z)
open(unit=10, file='input',status='unknown')
open(unit=20, file='output',status='unknown')
read(10,*) xxx, yyy
bbb=xxx+yyy
write(20,*) bbb
stop
end

I want to create a nice GUI (using Delphi) to input the xxx and yyy, and
write it in another Window. I don't want to rewrite the above code in Pascal.

So how am I going to incorporate this simple program into Delphi. If I compiled
the above program in FORTRAN and run it with the INPUT file, I will surely
get the output file with value of bbb. But it is UGLY :) I want to make it
look nice (the bottom line)...using Delphi.

I hope this is enuff for what I am looking for. I hope somebody can provide
the details of how to do this coz I have a lot of FORTRAN code..now what I need
is to make it user-friendly using Visual tool for the GUI part (just for the
data input and output).

Note: I am still learning Delphi so please don't use big words in the
explanation.

Thanks you...

Aldeenor-

Quote
>  -Greg
>--------------------------------------
>Greg Strauss, gstra...@islandnet.com
>Victoria, BC, Canada
>"...You can see the World from here!"
>--------------------------------------

Re:FORTRAN code in DELPHI?


In article <817556992...@polyhdrn.demon.co.uk>, Cather...@polyhdrn.demon.co.uk
says...
Quote

>In article <nxn101.73.30BA8...@psu.edu> nxn...@psu.edu "Aldeenor Tristan"
writes:

>> Is this possible? If YES, how? Where can I get the info of how to do it?

>> Thank you very much. I am desperate to know this....please help

>> Aldeenor-

I made an interface with Delphi to a Fortran program. I solved it
so that I compiled the Fortran code as a separate program. This was
because the only way I got it to multitask (with Windows 3.1 and 95) was
to make it Quick-Windows program and the parameters was transferred by
files anyway. The Fortran program runs quite a log time so yielding
was very important.

I start the program without a window (window-parameter 0), so no-one
notices there is an extra program running. I get also a feedback using
a file. This is not very clever way of doing things, but for me it
was too much work to learn program Windows with Fortran.

I would like to add a possibility to kill that Fortran program, but
so far it has not been successful.

Kimmo
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Kimmo Lahtinen =-=-=-=-=-=-=-=-=
tel: +358-0-7581 322                    Finnish Meteorological Institute
fax: +358-0-7581 396                    Sahaajankatu 20 E
email: Kimmo.Lahti...@fmi.fi            00810 HELSINKI, FINLAND

Other Threads