Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
call system ("convert image.jpg image.bmp")
[COLOR=#0000ff]/*[/color][COLOR=#0000ff] Compile:[/color]
[COLOR=#0000ff] * gcc -c functions.c [/color][COLOR=#0000ff]*/[/color]
[COLOR=#a020f0]#include [/color][COLOR=#ff00ff]<stdio.h>[/color]
[COLOR=#a020f0]#include [/color][COLOR=#ff00ff]<stdlib.h>[/color]
[COLOR=#2e8b57][b]int[/b][/color] sys_call__()
[COLOR=#0000ff]/*[/color][COLOR=#0000ff] When Compiling & Linking the Fortran Caller with g95, [/color]
[COLOR=#0000ff] * the name of the function should be[/color]
[COLOR=#0000ff] * sys_call__[/color]
[COLOR=#0000ff] *[/color]
[COLOR=#0000ff] * When Compiling & Linking with gfortran[/color]
[COLOR=#0000ff] * the name of the function should be[/color]
[COLOR=#0000ff] * sys_call_[/color]
[COLOR=#0000ff] [/color][COLOR=#0000ff]*/[/color]
{
[COLOR=#2e8b57][b]int[/b][/color] i;
[COLOR=#0000ff]// Executing program/command[/color]
i=system ([COLOR=#ff00ff]"ls -la *.f*"[/color]);
printf ([COLOR=#ff00ff]"[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]Returned Value = [/color][COLOR=#6a5acd]%d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color],i);
[COLOR=#804040][b]return[/b][/color] [COLOR=#ff00ff]0[/color];
}
[COLOR=#0000ff]! Compile the C functions:[/color]
[COLOR=#0000ff]! gcc -c functions.c[/color]
[COLOR=#0000ff]![/color]
[COLOR=#0000ff]! Compile & Link Fortran:[/color]
[COLOR=#0000ff]! gfortran c_call.f90 functions.o -o c_call[/color]
[COLOR=#0000ff]! or[/color]
[COLOR=#0000ff]! g95 c_call.f90 functions.o -o c_call[/color]
[COLOR=#a020f0]program[/color] c_call
[COLOR=#2e8b57][b]integer[/b][/color] :: res
[COLOR=#804040][b]print[/b][/color] [COLOR=#804040][b]*[/b][/color],[COLOR=#ff00ff]"* Calling C function from Fortran..."[/color]
[COLOR=#a020f0]call[/color] sys_call()
[COLOR=#804040][b]print[/b][/color] [COLOR=#804040][b]*[/b][/color],[COLOR=#ff00ff]"* Back in Fortran..."[/color]
[COLOR=#a020f0]end program[/color] c_call
$ gcc -c functions.c
$ g95 c_call.f90 functions.o -o c_call
$ c_call
* Calling C function from Fortran...
-rw-r--r-- 1 Roman Administ 338 Jan 24 05:53 c_call.f90
-rw-r--r-- 1 Roman Administ 1456 Jan 24 05:53 c_call.f90.html
-rw-r--r-- 1 Roman Administ 338 Jan 24 05:52 c_call.f90~
-rw-r--r-- 1 Roman Administ 201 Nov 30 11:41 f01.f
-rw-r--r-- 1 Roman Administ 201 Nov 30 11:41 f01.f90
-rw-r--r-- 1 Roman Administ 201 Nov 27 00:06 f01.f90~
-rw-r--r-- 1 Roman Administ 252 Nov 26 23:44 myfunctions.f
-rw-r--r-- 1 Roman Administ 345 Nov 26 23:38 myfunctions.f90
-rw-r--r-- 1 Roman Administ 394 Nov 26 23:16 test_myfunctions.f90
* Back in Fortran...
Returned Value = 0