RFortran

The open source RFortran library for accessing R from Fortran, with applications in environmental modelling. The open source RFortran library is introduced as a convenient tool for accessing the functionality and packages of the R programming language from Fortran programs. It significantly enhances Fortran programming by providing a set of easy-to-use functions that enable access to R′s very rapidly growing statistical, numerical and visualization capabilities, and support a richer and more interactive model development, debugging and analysis setup. RFortran differs from current approaches that require calling Fortran Dynamic link libraries (DLL) from R, and instead enables the Fortran program to transfer data to/from R and invoke R-based procedures via the R command interpreter. More generally, RFortran obviates the need to re-organize Fortran code into DLLs callable from R, or to re-write existing R packages in Fortran, or to jointly compile their Fortran code with the R language itself. Code snippets illustrate the basic transfer of data and commmands to and from R using RFortran, while two case studies discuss its advantages and limitations in realistic environmental modelling applications. These case studies include the generation of automated and interactive inference diagnostics in hydrological model calibration, and the integration of R statistical packages into a Fortran-based numerical quadrature code for joint probability analysis of coastal flooding using numerical hydraulic models. Currently, RFortran uses the Component Object Model (COM) interface for data/command transfer and is supported on the Microsoft Windows operating system and the Intel and Compaq Visual Fortran compilers. Extending its support to other operating systems and compilers is planned for the future. We hope that RFortran expedites method and software development for scientists and engineers with primary programming expertise in Fortran, but who wish to take advantage of R′s extensive statistical, mathematical and visualization packages by calling them from their Fortran code. Further information can be found at www.rfortran.org.