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

Jisca Huisman j|@c@@hu|@m@n @end|ng |rom gm@||@com
Thu May 9 13:40:00 CEST 2024


Hello Berend,

Fantastic, thank you! I'm fairly sure I'll be able to figure something 
out with your code as a guide.

best,

Jisca


On Thu, 09/05/2024 13:08, Berend Hasselman wrote:
> Hi,
>
> Have a look at package nleqslv to see how you can avoid Fortran write completely.
> Look at the file src/nwout.c and the calls of various functions therein in the other fortran files.
>
> regards,
>
> Berend Hasselman
>
>> On 08-05-2024, at 10:37, 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



More information about the R-package-devel mailing list