1

I would like to run an external code, written in Fortran, C++, or Python, within Wolfram Mathematica 12 on my MAC OS. I looked up on Internet and I tried to read the WSTP documentation on Wolfram Mathematica, but I still was not able to solve my issue. Could you please provide me some examples explained step by step in order that I can understand the strategy and I can then implement to there external codes? Thanks for your help.

VDF
  • 453
  • 2
  • 7
  • 2
    Python is going to be the easiest by far through ExternalEvaluate. C++ and Fortran will be easiest to do with LibraryLink unless you need to call into Mathematica from either of them. – b3m2a1 Mar 10 '21 at 18:46
  • 6
    Read this and then try to ask a more focused question. This is far too broad I think. – Jason B. Mar 10 '21 at 18:47
  • 1
    This is a bit too broad. Please focus the question to a single language, and check these C++ (read this before you attempt Fortran) https://mathematica.stackexchange.com/q/8438/12 Fortran: https://mathematica.stackexchange.com/q/38018/12 https://mathematica.stackexchange.com/q/5706/12 https://mathematica.stackexchange.com/q/5675/12 Python: http://reference.wolfram.com/language/workflow/ConfigurePythonForExternalEvaluate.html – Szabolcs Mar 11 '21 at 12:29

1 Answers1

0

You must first configure MMA to use Python. Here is how to proceed, from the help (version 12.1):

workflow/ConfigurePythonForExternalEvaluate

If you have done the setup, you can execute Python code inside a Notebook. You may e.g. type ">" (Greater) at the beginning of a line. This gives you a Python code cell, where you can type and execute Python code. E.g.:

enter image description here

Or you may create a Python session, using ExternalEvaluate as described in the help:

ref/ExternalValue

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57