Running FORTRAN executable from Linux SHELL

Click For Summary
SUMMARY

The issue discussed revolves around executing a FORTRAN program from a Linux shell and the discrepancies encountered when running it from a file manager. The user, Jim, discovered that the current working directory (curdir) defaults to the home directory, regardless of the executable's location. This led to input/output file access issues when attempting to run the program outside its directory. The command line execution works correctly, while the GAMBAS3 environment does not recognize the curdir concept, causing further complications.

PREREQUISITES
  • Understanding of FORTRAN programming and execution in Linux
  • Familiarity with Linux command line operations
  • Basic knowledge of GAMBAS3 programming environment
  • Experience with file management in Linux systems
NEXT STEPS
  • Research how to set the current working directory in GAMBAS3
  • Learn about file path handling in Linux for executables
  • Explore debugging techniques for FORTRAN programs in Linux
  • Investigate alternatives to GAMBAS3 for GUI development with FORTRAN
USEFUL FOR

Developers working with FORTRAN on Linux, particularly those integrating GUI elements with GAMBAS3, and anyone troubleshooting file access issues in Linux environments.

jelanier
Messages
67
Reaction score
1
I have noticed an issue I must resolve before writing a GUI for my FORTRAN program in Linux.

If I move into the directory (cmd line) and type ./myprogram it works fine. It reads the input file from that directory and creates an output file.

If I run it from the file manager it gives me 2 options 'execute' or 'execute from terminal'. Neither one works. I don't see anything happening and a new output file is not created.

In GAMBAS3 I tried a shell command which gave me a hint. I got an EOF error. So it could not find the input file. It is as if it is running the FORTRAN program in oblivion instead of from the directory using the directory resources. I tried complete path in the shell as well as cd in the shell.

I also tried compiling the GAMBAS program and moving it into the directory of the FORTRAN program. No Luck.

What am I missing? (using Debian for Raspberry pi)
Jim
 
Technology news on Phys.org
I figured it out. It turns out that no matter where you have the executable, the curdir is always whatever your home directory is. I don't like it but there it is.

So if I run my program from it's directory (in file manager), the input and output files must be in that home directory.

Command line works fine always.

In the case of Gambas, it does not matter where the Gambas executable resides...the home directory is where it looks. Gambas does not even understand the concept of curdir.

Oh well :)

Thanks anyway,

Jim
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
3
Views
2K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 34 ·
2
Replies
34
Views
5K