Running Fortran programs from Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg115295] Running Fortran programs from Mathematica
- From: john <johnco at idx.com.au>
- Date: Thu, 6 Jan 2011 02:31:00 -0500 (EST)
I am using Mathematica 7 on a WindowsXP machine. I attempted to execute the example given under Help /Run in Mathematica 7. When that attempt failed, I tried to evaluate a Fortran executable file using a Mathematica command. In the following, I have DEFL.EXE and associated input data files in the Mathematica folder. Please tell me how to correct what I have done. Thank you. Basic Examples (1) Run a standalone Mathematica kernel, putting the result of a command in a temporary file: In[21]:= commandstring = First[$CommandLine] <> " -noprompt -run \ \"Put[Factorial[20],ToFileName[$TemporaryPrefix,ToString[temp1]]];Quit[] \"" Out[21]= "MathKernel -noprompt -run \ \"Put[Factorial[20],ToFileName[$TemporaryPrefix,ToString[temp1]]];Quit[] \"" The command exited without an error code: In[22]:= Run[commandstring] Out[22]= 0 Show the contents of the file: In[23]:= FilePrint[ToFileName[$TemporaryPrefix, ToString[temp1]]] During evaluation of In[23]:= General::noopen: Cannot open C: \Documents and Settings\johnc\Local Settings\Temp\m\temp1. >> Delete the file: In[24]:= DeleteFile[ToFileName[$TemporaryPrefix, ToString[temp1]]] During evaluation of In[24]:= DeleteFile::nffil: File not found during DeleteFile[C:\Documents and Settings\johnc\Local Settings\Temp\m \temp1]. >> Out[24]= $Failed In[25]:= commandstring = First[$CommandLine] <> " -noprompt -run \ \"Put[Factorial[20],ToFileName[$TemporaryPrefix,ToString[DEFL.EXE]]];Quit[] \"" Out[25]= "MathKernel -noprompt -run \ \"Put[Factorial[20],ToFileName[$TemporaryPrefix,ToString[DEFL.EXE]]];Quit[] \"" In[26]:= Run[commandstring] Out[26]= 0 In[27]:= FilePrint[ToFileName[$TemporaryPrefix, ToString[DEF.RES]]] During evaluation of In[27]:= General::noopen: Cannot open C: \Documents and Settings\johnc\Local Settings\Temp\m\DEF . RES. >> In[28]:= Run[DEFL.EXE] Out[28]= 1 In[29]:= FilePrint[' DEF.RES'] Basic Examples (1) Run a standalone Mathematica kernel, putting the result of a command in a temporary file: In[29]:= commandstring = First[$CommandLine] <> " -noprompt -run \ \"Put[Factorial[20],ToFileName[$TemporaryPrefix,ToString[temp1]]];Quit[] \"" Out[29]= "MathKernel -noprompt -run \ \"Put[Factorial[20],ToFileName[$TemporaryPrefix,ToString[temp1]]];Quit[] \"" The command exited without an error code: In[30]:= Run[commandstring] Out[30]= 0 Show the contents of the file: In[31]:= FilePrint[ToFileName[$TemporaryPrefix, ToString[temp1]]] During evaluation of In[31]:= General::noopen: Cannot open C: \Documents and Settings\johnc\Local Settings\Temp\m\temp1. >> Delete the file: In[32]:= DeleteFile[ToFileName[$TemporaryPrefix, ToString[temp1]]] During evaluation of In[32]:= DeleteFile::nffil: File not found during DeleteFile[C:\Documents and Settings\johnc\Local Settings\Temp\m \temp1]. >> Out[32]= $Failed