hodgesse1 / rfortran

Automatically exported from code.google.com/p/rfortran
0 stars 0 forks source link

Fortran and R execution order #89

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Dear Mark and other users,

I used RFortran at the end of our HYDR model to pass some variables to R for 
extra calculation and plot many figures. The runs successfully now.

But here comes another problem: the above R Process with plotting usually costs 
a couple of minutes, then our HYDR model show that "Model Run Ends". In fact, 
the R Process doesn't need the Fortran Model at all once it gets the variables. 
So we want our HYDR model show "Model Run Ends" as soon as possible before R 
process ends. This request is useful for our next procedures. 

If I am not clear, please let me know. Any suggestions would be appreciated. 

Thanks,
Rocky

Original issue reported on code.google.com by rocky.y...@gmail.com on 10 Feb 2011 at 5:29

GoogleCodeExporter commented 8 years ago
Rocky,

Glad to here you have had some success using RFortran.

I think I understand your problem. 

Unfortunatly, the RFortran mode of operation is for the Fortran process to wait 
until the R commands executed through RFortran (e.g. Reval or Rcall) are 
completed before returning control to the Fortran process. I am not currently 
aware of how to easily change this. 
This has advantages when you are debugging because you can put browser() 
commands in R scripts called via RFortran and this actually pauses the Fortran 
process. 
In your case however, this has the disadvantage the HYDR model has to wait 
until the R process is finished plotting before continuing.

A suggested workaround is to potentially re-arrange your RFortran commands, so 
that the data transfer (Fortran->R) is undertaken during running of the HYDR 
model (variable transfer is usually quick), and the computationally expensive 
processing of data into the plots is undertaken after the "Model Run Ends" 
command is executed - either through R commands via RFortran or manually 
running R scripts. 

Hope this helps.

Mark

Original comment by mark.th...@gmail.com on 13 Feb 2011 at 1:16