[R] calling external .EXE file in R macOSX

Sharpie chuck at sharpsteen.net
Mon Mar 22 03:24:54 CET 2010



Alex Anderson wrote:
> 
> Hi All,
> I am currently working on an analysis which requires a call to an 
> external FORTRAN routine contained within a file called MCDS.EXE.  This 
> file is usually called from within a WINDOWS program called DISTANCE.  I 
> have some R script from the developers of the original software which 
> apparently makes a call to this  .EXE file which i need to re-engineer 
> slightly,  but i am having difficulty interpreting how the script makes 
> this call and passes to the EXE file the relevant input command file and 
> data file for processing.  I am also unsure if making such a call will 
> work within the OSX environment for a (windows?) executable file.  Below 
> is an example from the script which is supposed to make the call. Any 
> suggestions would be much appreciated.
> Cheers
> A
> 
> {snip}
> 
> 


Hrm, I really can't tell what that function you posted does-- it seems to be
mostly comments.  But I would imagine MCDS.EXE is being run using something
like a call to the system() function.

The problem with running the program on OS X is that MCDS.EXE is a Windows
binary.  You can't "just run" a binary compiled for Winows on OS X or Linux
more than you could run a binary compiled for OS X or Linux on Windows.

Your options include:

  1. Get the Fortran source code, recompile MCDS on OS X , and run the
program using something like system('mcds')

  2. Get the Fortran source code, refactor and recompile MCDS as a shared
library, load directly into R, and run the routines using .Fortran()

  3. Try using an emulator, such as Wine (www.winehq.ort), and run the
program using something like system('wine MCDS.EXE')

Number three would require the least amount of hassle, but is not guaranteed
to work.  Other people may have better suggestions and you might try asking
on the mac-specific R mailing list:

  https://stat.ethz.ch/mailman/listinfo/r-sig-mac

The people there may be able to give you better answers concerning R and OS
X

Good Luck!

-Charlie

-----
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: http://n4.nabble.com/calling-external-EXE-file-in-R-macOSX-tp1677148p1677162.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list