How To Run Fortran.exe using Excel

  • Fortran
  • Thread starter khazarhayat
  • Start date
  • Tags
    Excel
In summary, the speaker is having trouble using the Excel shell function to execute a Fortran program. The syntax is correct, but the program ends prematurely without generating the desired output file. They have tried recompiling the program and adjusting Excel's security settings, but have not found a solution. They have also looked for similar posts online, but have not found a clear solution. They mention being able to successfully run a Java program using the same shell function. They also mention not being familiar with Excel or VBA, and not using DLLs to pass data between Excel and Fortran. They provide a link to a forum post that was somewhat helpful, but are still seeking a solution.
  • #1
khazarhayat
2
0
Hello everybody,

I have a fortran.exe (compiled using intel visual fortan comipler 10.1.24 and VS 2005) which takes an input.dat file and generates output.dat.

Currently, I am trying to control fortran.exe execution with excel 2010 shell function. But it is not working properly.

The Shell function syntax is correct, it does run fortran.exe and DOS window can be seen. But fortran.exe ends prematurely without generating output.dat file. However, In case of double-clicking fortran.exe, it runs and reads input.dat and generate output.dat properly.

I have spent several days on this problem. I have recompile program, relaxed excel-marco security setting etc, but in vain.There are similar posts on web describing such problem, but no one clearly described the solution.

Surprisingly, using same shell function i can successfully run a java.exe file.

Any kind of comments, suggestion, advice regarding above problem will be warmly welcomed.
 
Technology news on Phys.org
  • #2
Disclaimer: don't use excel much, don't know VBA, don't do much DOS.

Debugging/testing ideas:
are all the files in the same directory? including the fortran exe?
is the command to start the fortran exe instructed to wait for it to finish?
google returned a few hints about calling fortran DLLs from excel, is this of no use to you?
 
  • #3

1. How do I run a Fortran program in Excel?

To run a Fortran program in Excel, you will need to first compile your Fortran code into an executable file (.exe). Once you have the .exe file, you can create a new Excel workbook and navigate to the "Insert" tab. From there, click on "Object" and select the "Create from File" option. Then, browse for your .exe file and click "OK." This will insert your Fortran program into the Excel workbook and you can run it by double-clicking on the object.

2. Can I use Excel as a front-end for a Fortran program?

Yes, Excel can be used as a front-end for a Fortran program. As mentioned before, you will need to compile your Fortran code into an executable file and then insert it into an Excel workbook. This allows you to use the familiar Excel interface to input data and view results from your Fortran program.

3. How can I pass data between Excel and Fortran?

To pass data between Excel and Fortran, you can use the "Create from File" option in Excel to insert your Fortran program, as mentioned before. This will allow you to input data into the Excel workbook, which can then be read by the Fortran program. Alternatively, you can also use the "Save As" function in Fortran to save your results as a text or CSV file, which can then be opened in Excel.

4. Is it possible to debug a Fortran program in Excel?

No, it is not possible to debug a Fortran program directly in Excel. However, you can use Excel's error checking and formula auditing tools to identify any errors or issues in your Fortran program. Additionally, you can use a Fortran debugger program to debug your code before inserting it into Excel.

5. How can I integrate Excel and Fortran for automation purposes?

To integrate Excel and Fortran for automation purposes, you can use Visual Basic for Applications (VBA) to create macros and scripts that can call and execute your Fortran program. This allows for a seamless integration between the two programs and can automate tasks such as data input, running the Fortran program, and displaying results in Excel.

Similar threads

  • Programming and Computer Science
Replies
7
Views
635
Replies
15
Views
5K
  • Programming and Computer Science
Replies
6
Views
5K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
2K
  • Special and General Relativity
Replies
6
Views
1K
  • Programming and Computer Science
2
Replies
49
Views
10K
Replies
4
Views
3K
Back
Top