Open GoogleCodeExporter opened 8 years ago
See solution below. to use it, rename the old 'Reval' to 'Reval_engine' and
paste the following right after. It resolves the issue in the ticket.
!----------------------------------------------------
function Reval(command)result(err)
! Purpose: Reval that handles multiple R statements within a single argument.
! Programmer: Dmitri Kavetski
! Kreated: 13 June 2011 AD, EMPA Accomo
! Comments:
! 1. Following R conventions, multiple statements must be separated by ";".
use utilities_dmsl_kit,only:parseStringIntoVector
implicit none
! dummies
character(*),intent(in)::command
integer(mik)::err
! locals
integer(mik)::n,i
character(len(command)),pointer::cmdv(:)
character(len_DMSLjmsg)::msg
! Start procedure here
call parseStringIntoVector(string=command,delim=";",&
array=cmdv,err=err,message=msg)
n=size(cmdv)
do i=1,n
err=Reval_eng(trim(cmdv(i)))
if(err/=EXIT_SUCCESS)exit
enddo
! End procedure here
endfunction Reval
Original comment by dmitri.k...@gmail.com
on 13 Jun 2011 at 3:20
Hi Mark,
Since some legitimate R statements use the ";" inside (rather than as a
separator), I modified the code to expect ";;" as a separator. Slightly less
convenient but seems to work fine.
The instructions and new code are below. Also see the related BATEAU_DK ticket
#109 for some further details.
In the file 'RFortran_Rput_Rget_Reval_Rcall.F90', do the following
(i) rename the function 'Reval' to 'Reval_eng'
(ii) paste the following code after the function 'Reval_eng'
!start{\DK}---------------------------------------
!----------------------------------------------------
function Reval(command,forceSingle)result(err)
! Purpose: Reval that handles multiple R statements within a single argument.
! Programmer: Dmitri Kavetski
! Kreated: 13 June 2011 AD, EMPA Accomo
! Comments:
! 1. Following R conventions, multiple statements must be separated by ";",
! However, to avoid spurious parsing, a ";;" is used.
use utilities_dmsl_kit,only:quickif,parseStringIntoVector
implicit none
! dummies
character(*),intent(in)::command
logical(mlk),intent(in),optional::forceSingle
integer(mik)::err
! locals
integer(mik)::n,i
character(len(command)),pointer::cmdv(:)
character(len_DMSLjmsg)::msg
logical(mlk),parameter::forceSingleDef=.false.
character(*),parameter::delim=";;"
! Start procedure here
if(quickif(forceSingle,forceSingleDef))then
err=Reval_eng(command)
else
call parseStringIntoVector(string=command,delim=delim,&
array=cmdv,err=err,message=msg)
if(err/=EXIT_SUCCESS)return
n=size(cmdv)
do i=1,n
err=Reval_eng(trim(cmdv(i)))
if(err/=EXIT_SUCCESS)exit
enddo
endif
! End procedure here
endfunction Reval
!end{\DK}-----------------------------------------
Original comment by dmitri.k...@gmail.com
on 15 Jun 2011 at 11:42
Hi Mark,
In response to your earlier query:
yes, it appears that R allows the delimiter ";" (which normally separates
multiple statements on the same line) within some expressions (ie, outside
strings).
This certainly seems confusing to me, and perhaps error-prone, but thats what R
seems to allow. Eg, see line 671 of RPlotLibrary in BATEA. Unless I misread
something, you can see the ";" inside a single R statement.
cheers,
d
Original comment by dmitri.k...@gmail.com
on 12 Jul 2011 at 11:51
Original issue reported on code.google.com by
dmitri.k...@gmail.com
on 13 Jun 2011 at 12:31