Is it possible to call shell commands from a Fortran program?

  • Context: Fortran 
  • Thread starter Thread starter yo6781
  • Start date Start date
  • Tags Tags
    Fortran Shell
Click For Summary
SUMMARY

It is possible to call shell commands from a Fortran program using the "system" subroutine available in the gfortran compiler. However, this approach introduces compiler dependency, which may lead to portability issues. Users are advised to consider alternatives to maintain compatibility across different environments. The discussion highlights the need for caution when integrating Fortran with MATLAB without using mex-functions or MATLAB engine functions.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with gfortran compiler and its functionalities
  • Basic knowledge of shell command syntax in Linux
  • Awareness of MATLAB integration methods
NEXT STEPS
  • Research the use of Fortran's "system" subroutine in gfortran
  • Explore alternatives to mex-functions for MATLAB integration
  • Learn about compiler dependency issues in Fortran
  • Investigate cross-platform compatibility strategies for Fortran programs
USEFUL FOR

Fortran developers, software engineers integrating Fortran with MATLAB, and anyone interested in enhancing Fortran applications with shell command capabilities.

yo6781
Messages
1
Reaction score
0
Hello!

I'm new here and I was wondering if anyone could help me.

I've a program in fortran which I want to combine with Matlab, both working in Ubunt 7.10 but I don't want to use mex-functions or MATLAB engine functions because it could cause damage to the fortran program I'm using. I was wondering if it would be possible to do it with a calling to the shell. Does anybody know if it is possible and how could I do it??

Thank you
 
Technology news on Phys.org
If you are using the gfortran compiler there is a subroutine called "system" http://gcc.gnu.org/onlinedocs/gfortran/SYSTEM.html" . But be aware about that this makes your code compiler dependent, so if it is possible you should avoid to use it.
 
Last edited by a moderator:

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
16
Views
3K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K