Topic: Fortran to Excel

Hi,
I am new to fortran and I would like to ask if someone knows how to connect fortran to excel through simply fortran, or if you have any information about it as I can study this, please.

Currently I am working in a Meshless Method programming for Mechanical Engineering.

I would be grateful with your advices.

Regards,
Emilio

Re: Fortran to Excel

Hi,
Years ago I made an interface between compac visual Fortran. I was very disappointed about the result and possibilities and decided to scratch this routines from my sources! Until now I could not find comparable interface procedures in SF and I am not missing this.
My advice is: forget it, don't try! It is too complicates an takes too may effort and you can start again to develop depending on changes in MS applications.
The question is what do you want to do??:
1) For calculations Fortran is much better than EXEL! Regular i use short and simple Fortran programs in stead of Exel
2) For tabular input you need a special dialog routine. I developed it myself
3) Do you want to get EXEL data in a Fortran program or vise versa? Use a file as interface
But never try to use EXEL from out a Fortran program if you have better work to do
Regards, klaus

Re: Fortran to Excel

cifuentesemilio2010 wrote:

Hi,
I am new to fortran and I would like to ask if someone knows how to connect fortran to excel through simply fortran, or if you have any information about it as I can study this, please.

Emelio,

It is certainly possible to connect Simply Fortran to Excel, but it is not trivial.  In fact, it can be quite frustrating.  You'll need to write some custom VBA code to actually call the Fortran routines.  There is a pretty good thread about the matter at http://forums.approximatrix.com/viewtopic.php?id=366

The Fortran routines themselves must also be declared in such a way that they are callable from C and other languages.  Depending on the version of Windows (32- or 64-bit) and Excel (again, 32- or 64-bit), you'll need to format the Fortran declarations differently.

I would suggest looking into the ISO_C_BINDING module first, which provides guaranteed compatibility between C (and VBA and Excel) and Fortran itself.

Jeff Armstrong
Approximatrix, LLC

Re: Fortran to Excel

Thank you Klaus Asmus, jeff for your replies.

I want this to take advante of the fast calculation of the fortran and the easy to review and plotting capabilities of excel.
I have a complete code in fortran, with up to 2.000 lines and when I make changes to the code it is difficult to trace the changes in results, that is why I formulated a whole spreadsheet with the code formulae as I can "debbug visually" easily the code, but the problem is the limitation in space and speed of calculation of excel.

For the case I am studyin I would need about 1.200.000 columns to analyze a 2D sloshing waves problem for 1.600 particles and over 500.000 iterations which is an utopy in Excel. So I had to analyze 16 particles with up to 2.000 columns and a simulation rate of 500 iterations/hour.

I think I am going to keep on fortran coding and debugging in simply fortran and I will change the code to export values every iteration to review on excel file.

Best,
Emilio

Re: Fortran to Excel

Emilio,

For the quantities of data you're implying, I would consider having your Fortran code generate comma-separated-value, or CSV, files, and importing them into Excel.  Interfacing with Excel, while possible, will be slow from both a development and computational standpoint.  But Excel can quickly read a CSV file, and writing out CSV data is relatively simple in Fortran.

Jeff Armstrong
Approximatrix, LLC