[R-pkg-devel] is Fortran write still strictly forbidden?

Erin Hodgess er|nm@hodge@@ @end|ng |rom gm@||@com
Thu May 9 02:51:46 CEST 2024


Hi Jisca:

I have used the write successfully.  I’m not sure if this matters or not,
but I am using WSL 2 with Ubuntu 22.04 installed.  It works fine with R =>
4.0.

Hope this helps.

Sincerely,
Erin

Erin Hodgess, PhD
mailto: erinm.hodgess using gmail.com


On Wed, May 8, 2024 at 6:49 PM Jisca Huisman <jisca.huisman using gmail.com>
wrote:

> Hello,
>
> I like to use write() in Fortran code to combine text with some integers
> & doubles, to pass runtime information to R in a way that is prettier
> and more legible than with intpr() & dblepr(). In the past any calls to
> write() were strictly forbidden in Fortran code, as apparently it messed
> something up internally (I cannot recall the details). But from 'writing
> R extensions' it seems that there have been quite a few changes with
> respect to support for Fortran code, and it currently reads:
>
>
> 6.5.1 Printing from Fortran
>
> On many systems Fortran|write|and|print|statements can be used, but the
> output may not interleave well with that of C, and may be invisible
> onGUIinterfaces. They are not portable and best avoided.
>
>
> To be more specific, would the subroutine below be allowed? Is it needed
> to declare R >= 4.0 (?) in the package DESCRIPTION (& then use labelpr()
> instead of intpr() ?) Is there an alternative without write() to get the
> same result?
>
>
> subroutine Rprint_pretty(iter, x)
>      integer, intent(IN) :: iter
>      double precision, intent(IN) :: x
>      integer :: date_time_values(8), nchar, IntDummy(0)
>      character(len=8) :: time_now
>      character(len=200) :: msg_to_R
>
>      call date_and_time(VALUES=date_time_values)
>      write(time_now, '(i2.2,":",i2.2,":",i2.2)') date_time_values(5:7)
>      write(msg_to_R, '(a8, " i: ", i5, "  value: ", f8.2)') time_now,
> iter, x
>
>      nchar = len(trim(msg_to_R))
>     call intpr(trim(msg_to_R), nchar, IntDummy, 0)
>
>    end subroutine Rprint_pretty
>
>
> Thanks!
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list