-1

I am doing an heavy weather simulation in Fortran 90. I would like to call a script in R in order to perform some complicated data analysis. The only way that i found is to write inside a file the data and then calling the system function from Fortan

  call system('R CMD BATCH script.r outcome.out')

and read the outcomes of the analysis from Fortran in outcome.out. This present some problems in order to manage the file outcome.out when the simulation give bogus numbers. Does exists a more elegant way to call R from Fortran?

2
  • What kind of problems exactly? 'Some problems' is a but vague. Sep 16, 2012 at 17:59
  • in case of error i have some difficult on manage the file of output of R.
    – emanuele
    Sep 16, 2012 at 18:40

1 Answer 1

2

I would recommend not calling R from Fortran, but turning this around. I regularly call Fortran models (executables) from R, and then picking up the results in R. Using R as a means to control the model enables one to e.g. run them in parallel.

Most of the time I actually use a system where the models run in Fortran, the model is run using Python, and I use R for the post-processing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.