Fortran alternative to Matlab 'system' command

Click For Summary
SUMMARY

The discussion focuses on executing a Linux executable from Fortran code, specifically Fortran 77. The user is unable to replicate the Matlab 'system' command functionality in Fortran, where './' is not working. A key insight is that the './' prefix is a Unix convention indicating the current directory, and if the executable is not found, the full pathname must be specified instead, such as '/mnt/hd1/usr/mushi/bin/filename'. The conversation highlights the need for clarity on the correct command to use in Fortran for executing external programs.

PREREQUISITES
  • Understanding of Fortran 77 programming
  • Familiarity with Unix/Linux command line operations
  • Knowledge of executable file paths in Unix
  • Basic understanding of how system calls work in programming languages
NEXT STEPS
  • Research the Fortran 'system' command and its alternatives
  • Learn about executing external commands in Fortran using 'execute_command_line'
  • Explore Unix/Linux file path conventions and how they affect program execution
  • Investigate error handling in Fortran when executing external programs
USEFUL FOR

Fortran developers, programmers transitioning from Matlab to Fortran, and anyone needing to execute external executables within Fortran scripts.

mushi
Messages
23
Reaction score
0
Hi,

I have been trying to run a linux executable (written in fortran77) into my another code (also in fortran77). In Matlab, I did it with "system('./<filename>')". But I am not able to do it in fortran script as './' is not simply working for me.

I will really appreciate if anyone could tell me what alternative command I can use to execute an executable file into fortran code. A quick response will be extremely helpful and highly appreacited.

Thanks in advance.

mushi
 
Physics news on Phys.org
mushi said:
I have been trying to run a linux executable (written in fortran77) into my another code (also in fortran77). In Matlab, I did it with "system('./<filename>')". But I am not able to do it in fortran script as './' is not simply working for me.
The command (if there is one in your Fortran) may not be "system()" but I have no idea of other possibilities. The "./" prefix is nothing to do with the language; it's a shortcut in Unix that says the executable is located in the current directory. So if the executable is not located in what the op sys will see as the current directory, you should specify the full pathname instead, e.g., '/mnt/hd1/usr/mushi/bin/filename'.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
13K