659
edits
(Example of writing F2003 Code linking to Octave) |
Carandraug (talk | contribs) (fix name of fortran file) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
In the example we will load an Octave array from a file in Octave's native ASCII format, | In the example we will load an Octave array from a file in Octave's native ASCII format, | ||
it consists of two steps: | it consists of two steps: | ||
* write a C++ function with a C compatible interface and C linkage that reads a variable from an Octave ASCII file | |||
* write Fortran code using the "iso_c_binding" intrinsic module to call the C++ function | |||
=== C++ function === | === C++ function === | ||
Line 78: | Line 78: | ||
=== Fortran Code === | === Fortran Code === | ||
{{Code| | {{Code|octave_file_io_example.f90|<syntaxhighlight lang="fortran" style="font-size:13px"> | ||
program octave_file_io_example | program octave_file_io_example | ||
Line 123: | Line 123: | ||
mkoctfile -I. octave_file_io.cc | mkoctfile -I. octave_file_io.cc | ||
mkoctfile -I. --mkoctfile --link-stand-alone octave_file_io_example.f90 octave_file_io.o -o octave_file_io_example | mkoctfile -I. --mkoctfile --link-stand-alone octave_file_io_example.f90 octave_file_io.o -o octave_file_io_example | ||
[[Category:Examples]] |