

Dear users of R
I have a subroutine in Fortran95, compiled to a DLL with gfortran in Cygwin
4.5.3.
The subroutine is:
subroutine MyPBP( S, p, N )
! Expose subroutine rtest to users of this DLL
!DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
! This function computes the PoissonBinomial distribution
! of size N using p
double precision, intent(inout) :: S(N+1)
double precision, intent(in) :: p(N)
integer, intent(in) :: N
double precision :: X(N+1)
integer i, j
!X=0
!S=0
X(1) = 1  p(1)
X(2) = p(1)
do i = 2, N
S(1) = X(1)*(1p(i))
do j = 2,i
S(j) = X(j1)*p(i) + X(j)*(1p(i))
end do
S(i+1) = X(i)*p(i)
X = S
if (i == N) then
S = X
end if
end do
end subroutine MyPBP
and it is saved into Mango.f95
I compile it from the bash shell using: gfortran4 c Mango.f95 and
gfortran4 shared o Mango.dll Mango.o
I am on a Windows machine running Windows 7 with Intel i7.
I load the dll in a 32bit R by dyn.load("Mango.dll"). Using getLoadedDLLs
I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In addition, R
stop responding when I try .Fortran("MyPBP", as.numeric(S), as.numeric(p),
as.integer(N)),
where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
What am I doing wrong?
Any ideas, thoughts and/or comments are highly appreciated.
Jens
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On 130424 1:36 PM, Jens Olofsson wrote:
> Dear users of R
> I have a subroutine in Fortran95, compiled to a DLL with gfortran in Cygwin
> 4.5.3.
We don't support Cygwin. You should use the gfortran in Rtools, and get
R to set the command line options for you, either by putting the code in
a package, or by using R CMD SHLIB Mango.f95.
Duncan Murdoch
> The subroutine is:
> subroutine MyPBP( S, p, N )
> ! Expose subroutine rtest to users of this DLL
> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
> ! This function computes the PoissonBinomial distribution
> ! of size N using p
> double precision, intent(inout) :: S(N+1)
> double precision, intent(in) :: p(N)
> integer, intent(in) :: N
> double precision :: X(N+1)
> integer i, j
> !X=0
> !S=0
> X(1) = 1  p(1)
> X(2) = p(1)
> do i = 2, N
> S(1) = X(1)*(1p(i))
> do j = 2,i
> S(j) = X(j1)*p(i) + X(j)*(1p(i))
> end do
> S(i+1) = X(i)*p(i)
> X = S
> if (i == N) then
> S = X
> end if
> end do
> end subroutine MyPBP
> and it is saved into Mango.f95
> I compile it from the bash shell using: gfortran4 c Mango.f95 and
> gfortran4 shared o Mango.dll Mango.o
> I am on a Windows machine running Windows 7 with Intel i7.
> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using getLoadedDLLs
> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In addition, R
> stop responding when I try .Fortran("MyPBP", as.numeric(S), as.numeric(p),
> as.integer(N)),
> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>
> What am I doing wrong?
> Any ideas, thoughts and/or comments are highly appreciated.
>
> Jens
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Dear Duncan,
I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob and
also remember I am on Windows. How should I use R CMD SHLIB as if I write
that at the prompt I get the error: unexpected symbol in "R CMD". I have
mango.f95 in the working directory.
//Jens
On 24 April 2013 19:46, Duncan Murdoch < [hidden email]> wrote:
> On 130424 1:36 PM, Jens Olofsson wrote:
>
>> Dear users of R
>> I have a subroutine in Fortran95, compiled to a DLL with gfortran in
>> Cygwin
>> 4.5.3.
>>
>
> We don't support Cygwin. You should use the gfortran in Rtools, and get R
> to set the command line options for you, either by putting the code in a
> package, or by using R CMD SHLIB Mango.f95.
>
> Duncan Murdoch
>
> The subroutine is:
>> subroutine MyPBP( S, p, N )
>> ! Expose subroutine rtest to users of this DLL
>> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
>> ! This function computes the PoissonBinomial distribution
>> ! of size N using p
>> double precision, intent(inout) :: S(N+1)
>> double precision, intent(in) :: p(N)
>> integer, intent(in) :: N
>> double precision :: X(N+1)
>> integer i, j
>> !X=0
>> !S=0
>> X(1) = 1  p(1)
>> X(2) = p(1)
>> do i = 2, N
>> S(1) = X(1)*(1p(i))
>> do j = 2,i
>> S(j) = X(j1)*p(i) + X(j)*(1p(i))
>> end do
>> S(i+1) = X(i)*p(i)
>> X = S
>> if (i == N) then
>> S = X
>> end if
>> end do
>> end subroutine MyPBP
>> and it is saved into Mango.f95
>> I compile it from the bash shell using: gfortran4 c Mango.f95 and
>> gfortran4 shared o Mango.dll Mango.o
>> I am on a Windows machine running Windows 7 with Intel i7.
>> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using getLoadedDLLs
>> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In addition, R
>> stop responding when I try .Fortran("MyPBP", as.numeric(S), as.numeric(p),
>> as.integer(N)),
>> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>>
>> What am I doing wrong?
>> Any ideas, thoughts and/or comments are highly appreciated.
>>
>> Jens
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/**listinfo/rhelp< https://stat.ethz.ch/mailman/listinfo/rhelp>
>> PLEASE do read the posting guide http://www.Rproject.org/**>> postingguide.html < http://www.Rproject.org/postingguide.html>
>> and provide commented, minimal, selfcontained, reproducible code.
>>
>>
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On 130424 1:51 PM, Jens Olofsson wrote:
> Dear Duncan,
> I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob and
> also remember I am on Windows. How should I use R CMD SHLIB as if I write
> that at the prompt I get the error: unexpected symbol in "R CMD". I have
> mango.f95 in the working directory.
That's a commandline command, not something done with R. You can use
it from your bash shell if you have R and the Rtools directories on your
path, or from the Windows CMD shell.
BTW, my comment wasn't trying to tell you to go to a Cygwin forum, it
was telling you that Cygwin's gfortran is unsupported. You need to use
the MinGW64 one that we distribute if you want us to be able to help.
Duncan Murdoch
> //Jens
>
>
>
> On 24 April 2013 19:46, Duncan Murdoch < [hidden email]> wrote:
>
>> On 130424 1:36 PM, Jens Olofsson wrote:
>>
>>> Dear users of R
>>> I have a subroutine in Fortran95, compiled to a DLL with gfortran in
>>> Cygwin
>>> 4.5.3.
>>>
>>
>> We don't support Cygwin. You should use the gfortran in Rtools, and get R
>> to set the command line options for you, either by putting the code in a
>> package, or by using R CMD SHLIB Mango.f95.
>>
>> Duncan Murdoch
>>
>> The subroutine is:
>>> subroutine MyPBP( S, p, N )
>>> ! Expose subroutine rtest to users of this DLL
>>> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
>>> ! This function computes the PoissonBinomial distribution
>>> ! of size N using p
>>> double precision, intent(inout) :: S(N+1)
>>> double precision, intent(in) :: p(N)
>>> integer, intent(in) :: N
>>> double precision :: X(N+1)
>>> integer i, j
>>> !X=0
>>> !S=0
>>> X(1) = 1  p(1)
>>> X(2) = p(1)
>>> do i = 2, N
>>> S(1) = X(1)*(1p(i))
>>> do j = 2,i
>>> S(j) = X(j1)*p(i) + X(j)*(1p(i))
>>> end do
>>> S(i+1) = X(i)*p(i)
>>> X = S
>>> if (i == N) then
>>> S = X
>>> end if
>>> end do
>>> end subroutine MyPBP
>>> and it is saved into Mango.f95
>>> I compile it from the bash shell using: gfortran4 c Mango.f95 and
>>> gfortran4 shared o Mango.dll Mango.o
>>> I am on a Windows machine running Windows 7 with Intel i7.
>>> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using getLoadedDLLs
>>> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In addition, R
>>> stop responding when I try .Fortran("MyPBP", as.numeric(S), as.numeric(p),
>>> as.integer(N)),
>>> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>>>
>>> What am I doing wrong?
>>> Any ideas, thoughts and/or comments are highly appreciated.
>>>
>>> Jens
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________**________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/rhelp< https://stat.ethz.ch/mailman/listinfo/rhelp>
>>> PLEASE do read the posting guide http://www.Rproject.org/**>>> postingguide.html < http://www.Rproject.org/postingguide.html>
>>> and provide commented, minimal, selfcontained, reproducible code.
>>>
>>>
>>
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Ok. I apologise for not understanding. So, I have installed Rtools. It
changed my PATHvariable. I didn't installed Cygwin dlls as stated by
http://cran.rproject.org/doc/manuals/Radmin.html#TheWindowstoolset.
Instead my PATHvariable contains the path to the Cygwin dlls AFTER the
path to R... So, I started RTerm (32bit) and tried > R CMD SHLIB mango.f95
and got the same error as earlier "Error: unexpected symbol in "R CMD"".
The same goes for RTerm (64bit). Can you pls advice me on how to proceed?
Sincerely Jens
On 24 April 2013 20:08, Duncan Murdoch < [hidden email]> wrote:
> On 130424 1:51 PM, Jens Olofsson wrote:
>
>> Dear Duncan,
>> I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob
>> and
>> also remember I am on Windows. How should I use R CMD SHLIB as if I write
>> that at the prompt I get the error: unexpected symbol in "R CMD". I have
>> mango.f95 in the working directory.
>>
>
>
> That's a commandline command, not something done with R. You can use it
> from your bash shell if you have R and the Rtools directories on your path,
> or from the Windows CMD shell.
>
> BTW, my comment wasn't trying to tell you to go to a Cygwin forum, it was
> telling you that Cygwin's gfortran is unsupported. You need to use the
> MinGW64 one that we distribute if you want us to be able to help.
>
> Duncan Murdoch
>
> //Jens
>>
>>
>>
>> On 24 April 2013 19:46, Duncan Murdoch < [hidden email]> wrote:
>>
>> On 130424 1:36 PM, Jens Olofsson wrote:
>>>
>>> Dear users of R
>>>> I have a subroutine in Fortran95, compiled to a DLL with gfortran in
>>>> Cygwin
>>>> 4.5.3.
>>>>
>>>>
>>> We don't support Cygwin. You should use the gfortran in Rtools, and get
>>> R
>>> to set the command line options for you, either by putting the code in a
>>> package, or by using R CMD SHLIB Mango.f95.
>>>
>>> Duncan Murdoch
>>>
>>> The subroutine is:
>>>
>>>> subroutine MyPBP( S, p, N )
>>>> ! Expose subroutine rtest to users of this DLL
>>>> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
>>>> ! This function computes the PoissonBinomial distribution
>>>> ! of size N using p
>>>> double precision, intent(inout) :: S(N+1)
>>>> double precision, intent(in) :: p(N)
>>>> integer, intent(in) :: N
>>>> double precision :: X(N+1)
>>>> integer i, j
>>>> !X=0
>>>> !S=0
>>>> X(1) = 1  p(1)
>>>> X(2) = p(1)
>>>> do i = 2, N
>>>> S(1) = X(1)*(1p(i))
>>>> do j = 2,i
>>>> S(j) = X(j1)*p(i) + X(j)*(1p(i))
>>>> end do
>>>> S(i+1) = X(i)*p(i)
>>>> X = S
>>>> if (i == N) then
>>>> S = X
>>>> end if
>>>> end do
>>>> end subroutine MyPBP
>>>> and it is saved into Mango.f95
>>>> I compile it from the bash shell using: gfortran4 c Mango.f95 and
>>>> gfortran4 shared o Mango.dll Mango.o
>>>> I am on a Windows machine running Windows 7 with Intel i7.
>>>> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using
>>>> getLoadedDLLs
>>>> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In
>>>> addition, R
>>>> stop responding when I try .Fortran("MyPBP", as.numeric(S),
>>>> as.numeric(p),
>>>> as.integer(N)),
>>>> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>>>>
>>>> What am I doing wrong?
>>>> Any ideas, thoughts and/or comments are highly appreciated.
>>>>
>>>> Jens
>>>>
>>>> [[alternative HTML version deleted]]
>>>>
>>>> ______________________________****________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/****listinfo/rhelp< https://stat.ethz.ch/mailman/**listinfo/rhelp>
>>>> < https://stat.**ethz.ch/mailman/listinfo/r**help< https://stat.ethz.ch/mailman/listinfo/rhelp>
>>>> >
>>>> PLEASE do read the posting guide http://www.Rproject.org/**>>>> postingguide.html < http://www.Rproject.org/**postingguide.html< http://www.Rproject.org/postingguide.html>
>>>> >
>>>>
>>>> and provide commented, minimal, selfcontained, reproducible code.
>>>>
>>>>
>>>>
>>>
>>
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On 130424 2:46 PM, Jens Olofsson wrote:
> Ok. I apologise for not understanding. So, I have installed Rtools. It
> changed my PATHvariable. I didn't installed Cygwin dlls as stated by
> http://cran.rproject.org/doc/manuals/Radmin.html#TheWindowstoolset.
> Instead my PATHvariable contains the path to the Cygwin dlls AFTER the
> path to R... So, I started RTerm (32bit) and tried > R CMD SHLIB mango.f95
> and got the same error as earlier "Error: unexpected symbol in "R CMD"".
> The same goes for RTerm (64bit). Can you pls advice me on how to proceed?
See my first paragraph below.
Duncan Murdoch
> Sincerely Jens
>
>
> On 24 April 2013 20:08, Duncan Murdoch < [hidden email]> wrote:
>
>> On 130424 1:51 PM, Jens Olofsson wrote:
>>
>>> Dear Duncan,
>>> I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob
>>> and
>>> also remember I am on Windows. How should I use R CMD SHLIB as if I write
>>> that at the prompt I get the error: unexpected symbol in "R CMD". I have
>>> mango.f95 in the working directory.
>>>
>>
>>
>> That's a commandline command, not something done with R. You can use it
>> from your bash shell if you have R and the Rtools directories on your path,
>> or from the Windows CMD shell.
>>
>> BTW, my comment wasn't trying to tell you to go to a Cygwin forum, it was
>> telling you that Cygwin's gfortran is unsupported. You need to use the
>> MinGW64 one that we distribute if you want us to be able to help.
>>
>> Duncan Murdoch
>>
>> //Jens
>>>
>>>
>>>
>>> On 24 April 2013 19:46, Duncan Murdoch < [hidden email]> wrote:
>>>
>>> On 130424 1:36 PM, Jens Olofsson wrote:
>>>>
>>>> Dear users of R
>>>>> I have a subroutine in Fortran95, compiled to a DLL with gfortran in
>>>>> Cygwin
>>>>> 4.5.3.
>>>>>
>>>>>
>>>> We don't support Cygwin. You should use the gfortran in Rtools, and get
>>>> R
>>>> to set the command line options for you, either by putting the code in a
>>>> package, or by using R CMD SHLIB Mango.f95.
>>>>
>>>> Duncan Murdoch
>>>>
>>>> The subroutine is:
>>>>
>>>>> subroutine MyPBP( S, p, N )
>>>>> ! Expose subroutine rtest to users of this DLL
>>>>> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
>>>>> ! This function computes the PoissonBinomial distribution
>>>>> ! of size N using p
>>>>> double precision, intent(inout) :: S(N+1)
>>>>> double precision, intent(in) :: p(N)
>>>>> integer, intent(in) :: N
>>>>> double precision :: X(N+1)
>>>>> integer i, j
>>>>> !X=0
>>>>> !S=0
>>>>> X(1) = 1  p(1)
>>>>> X(2) = p(1)
>>>>> do i = 2, N
>>>>> S(1) = X(1)*(1p(i))
>>>>> do j = 2,i
>>>>> S(j) = X(j1)*p(i) + X(j)*(1p(i))
>>>>> end do
>>>>> S(i+1) = X(i)*p(i)
>>>>> X = S
>>>>> if (i == N) then
>>>>> S = X
>>>>> end if
>>>>> end do
>>>>> end subroutine MyPBP
>>>>> and it is saved into Mango.f95
>>>>> I compile it from the bash shell using: gfortran4 c Mango.f95 and
>>>>> gfortran4 shared o Mango.dll Mango.o
>>>>> I am on a Windows machine running Windows 7 with Intel i7.
>>>>> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using
>>>>> getLoadedDLLs
>>>>> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In
>>>>> addition, R
>>>>> stop responding when I try .Fortran("MyPBP", as.numeric(S),
>>>>> as.numeric(p),
>>>>> as.integer(N)),
>>>>> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>>>>>
>>>>> What am I doing wrong?
>>>>> Any ideas, thoughts and/or comments are highly appreciated.
>>>>>
>>>>> Jens
>>>>>
>>>>> [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________****________________
>>>>> [hidden email] mailing list
>>>>> https://stat.ethz.ch/mailman/****listinfo/rhelp< https://stat.ethz.ch/mailman/**listinfo/rhelp>
>>>>> < https://stat.**ethz.ch/mailman/listinfo/r**help< https://stat.ethz.ch/mailman/listinfo/rhelp>
>>>>>>
>>>>> PLEASE do read the posting guide http://www.Rproject.org/**>>>>> postingguide.html < http://www.Rproject.org/**postingguide.html< http://www.Rproject.org/postingguide.html>
>>>>>>
>>>>>
>>>>> and provide commented, minimal, selfcontained, reproducible code.
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On Apr 24, 2013, at 7:46 PM, Jens Olofsson < [hidden email]> wrote:
> Ok. I apologise for not understanding. So, I have installed Rtools. It
> changed my PATHvariable. I didn't installed Cygwin dlls as stated by
> http://cran.rproject.org/doc/manuals/Radmin.html#TheWindowstoolset.
> Instead my PATHvariable contains the path to the Cygwin dlls AFTER the
> path to R... So, I started RTerm (32bit) and tried > R CMD SHLIB mango.f95
Repeating what Duncan said  R CMD SHLIB is to be done outside of R, not within R.
Some recent discussion also suggests its perhaps easier to do this with RStudio + devtools as part of a package than as a standalone shared object.
MW
> and got the same error as earlier "Error: unexpected symbol in "R CMD"".
> The same goes for RTerm (64bit). Can you pls advice me on how to proceed?
> Sincerely Jens
>
>
> On 24 April 2013 20:08, Duncan Murdoch < [hidden email]> wrote:
>
>> On 130424 1:51 PM, Jens Olofsson wrote:
>>
>>> Dear Duncan,
>>> I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob
>>> and
>>> also remember I am on Windows. How should I use R CMD SHLIB as if I write
>>> that at the prompt I get the error: unexpected symbol in "R CMD". I have
>>> mango.f95 in the working directory.
>>>
>>
>>
>> That's a commandline command, not something done with R. You can use it
>> from your bash shell if you have R and the Rtools directories on your path,
>> or from the Windows CMD shell.
>>
>> BTW, my comment wasn't trying to tell you to go to a Cygwin forum, it was
>> telling you that Cygwin's gfortran is unsupported. You need to use the
>> MinGW64 one that we distribute if you want us to be able to help.
>>
>> Duncan Murdoch
>>
>> //Jens
>>>
>>>
>>>
>>> On 24 April 2013 19:46, Duncan Murdoch < [hidden email]> wrote:
>>>
>>> On 130424 1:36 PM, Jens Olofsson wrote:
>>>>
>>>> Dear users of R
>>>>> I have a subroutine in Fortran95, compiled to a DLL with gfortran in
>>>>> Cygwin
>>>>> 4.5.3.
>>>>>
>>>>>
>>>> We don't support Cygwin. You should use the gfortran in Rtools, and get
>>>> R
>>>> to set the command line options for you, either by putting the code in a
>>>> package, or by using R CMD SHLIB Mango.f95.
>>>>
>>>> Duncan Murdoch
>>>>
>>>> The subroutine is:
>>>>
>>>>> subroutine MyPBP( S, p, N )
>>>>> ! Expose subroutine rtest to users of this DLL
>>>>> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
>>>>> ! This function computes the PoissonBinomial distribution
>>>>> ! of size N using p
>>>>> double precision, intent(inout) :: S(N+1)
>>>>> double precision, intent(in) :: p(N)
>>>>> integer, intent(in) :: N
>>>>> double precision :: X(N+1)
>>>>> integer i, j
>>>>> !X=0
>>>>> !S=0
>>>>> X(1) = 1  p(1)
>>>>> X(2) = p(1)
>>>>> do i = 2, N
>>>>> S(1) = X(1)*(1p(i))
>>>>> do j = 2,i
>>>>> S(j) = X(j1)*p(i) + X(j)*(1p(i))
>>>>> end do
>>>>> S(i+1) = X(i)*p(i)
>>>>> X = S
>>>>> if (i == N) then
>>>>> S = X
>>>>> end if
>>>>> end do
>>>>> end subroutine MyPBP
>>>>> and it is saved into Mango.f95
>>>>> I compile it from the bash shell using: gfortran4 c Mango.f95 and
>>>>> gfortran4 shared o Mango.dll Mango.o
>>>>> I am on a Windows machine running Windows 7 with Intel i7.
>>>>> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using
>>>>> getLoadedDLLs
>>>>> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In
>>>>> addition, R
>>>>> stop responding when I try .Fortran("MyPBP", as.numeric(S),
>>>>> as.numeric(p),
>>>>> as.integer(N)),
>>>>> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>>>>>
>>>>> What am I doing wrong?
>>>>> Any ideas, thoughts and/or comments are highly appreciated.
>>>>>
>>>>> Jens
>>>>>
>>>>> [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________****________________
>>>>> [hidden email] mailing list
>>>>> https://stat.ethz.ch/mailman/****listinfo/rhelp< https://stat.ethz.ch/mailman/**listinfo/rhelp>
>>>>> < https://stat.**ethz.ch/mailman/listinfo/r**help< https://stat.ethz.ch/mailman/listinfo/rhelp>
>>>>>>
>>>>> PLEASE do read the posting guide http://www.Rproject.org/**>>>>> postingguide.html < http://www.Rproject.org/**postingguide.html< http://www.Rproject.org/postingguide.html>
>>>>>>
>>>>>
>>>>> and provide commented, minimal, selfcontained, reproducible code.
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello again.
I may be a bit slow, but I'm learning. :)
Installed Rtools, added R to the path. Used CMD, moved to the folder of the source and wrote R CMD SHLIB Mango.f95 and voila I got a dll I loaded in R and I could call my current subroutines as intended.
I am very grateful for ur help and ur patience.
Sincerely, Jens
24 apr 2013 kl. 21:33 skrev "R. Michael Weylandt < [hidden email]>" < [hidden email]>:
>
>
> On Apr 24, 2013, at 7:46 PM, Jens Olofsson < [hidden email]> wrote:
>
>> Ok. I apologise for not understanding. So, I have installed Rtools. It
>> changed my PATHvariable. I didn't installed Cygwin dlls as stated by
>> http://cran.rproject.org/doc/manuals/Radmin.html#TheWindowstoolset.
>> Instead my PATHvariable contains the path to the Cygwin dlls AFTER the
>> path to R... So, I started RTerm (32bit) and tried > R CMD SHLIB mango.f95
>
> Repeating what Duncan said  R CMD SHLIB is to be done outside of R, not within R.
>
> Some recent discussion also suggests its perhaps easier to do this with RStudio + devtools as part of a package than as a standalone shared object.
>
> MW
>
>
>> and got the same error as earlier "Error: unexpected symbol in "R CMD"".
>> The same goes for RTerm (64bit). Can you pls advice me on how to proceed?
>> Sincerely Jens
>>
>>
>> On 24 April 2013 20:08, Duncan Murdoch < [hidden email]> wrote:
>>
>>> On 130424 1:51 PM, Jens Olofsson wrote:
>>>
>>>> Dear Duncan,
>>>> I know this isn't a forum for Cygwin, but for R. Pls treat me as a noob
>>>> and
>>>> also remember I am on Windows. How should I use R CMD SHLIB as if I write
>>>> that at the prompt I get the error: unexpected symbol in "R CMD". I have
>>>> mango.f95 in the working directory.
>>>
>>>
>>> That's a commandline command, not something done with R. You can use it
>>> from your bash shell if you have R and the Rtools directories on your path,
>>> or from the Windows CMD shell.
>>>
>>> BTW, my comment wasn't trying to tell you to go to a Cygwin forum, it was
>>> telling you that Cygwin's gfortran is unsupported. You need to use the
>>> MinGW64 one that we distribute if you want us to be able to help.
>>>
>>> Duncan Murdoch
>>>
>>> //Jens
>>>>
>>>>
>>>>
>>>> On 24 April 2013 19:46, Duncan Murdoch < [hidden email]> wrote:
>>>>
>>>> On 130424 1:36 PM, Jens Olofsson wrote:
>>>>>
>>>>> Dear users of R
>>>>>> I have a subroutine in Fortran95, compiled to a DLL with gfortran in
>>>>>> Cygwin
>>>>>> 4.5.3.
>>>>> We don't support Cygwin. You should use the gfortran in Rtools, and get
>>>>> R
>>>>> to set the command line options for you, either by putting the code in a
>>>>> package, or by using R CMD SHLIB Mango.f95.
>>>>>
>>>>> Duncan Murdoch
>>>>>
>>>>> The subroutine is:
>>>>>
>>>>>> subroutine MyPBP( S, p, N )
>>>>>> ! Expose subroutine rtest to users of this DLL
>>>>>> !DEC$ ATTRIBUTES DLLEXPORT, C, REFERENCE, ALIAS: "mypbp_" ::mypbp
>>>>>> ! This function computes the PoissonBinomial distribution
>>>>>> ! of size N using p
>>>>>> double precision, intent(inout) :: S(N+1)
>>>>>> double precision, intent(in) :: p(N)
>>>>>> integer, intent(in) :: N
>>>>>> double precision :: X(N+1)
>>>>>> integer i, j
>>>>>> !X=0
>>>>>> !S=0
>>>>>> X(1) = 1  p(1)
>>>>>> X(2) = p(1)
>>>>>> do i = 2, N
>>>>>> S(1) = X(1)*(1p(i))
>>>>>> do j = 2,i
>>>>>> S(j) = X(j1)*p(i) + X(j)*(1p(i))
>>>>>> end do
>>>>>> S(i+1) = X(i)*p(i)
>>>>>> X = S
>>>>>> if (i == N) then
>>>>>> S = X
>>>>>> end if
>>>>>> end do
>>>>>> end subroutine MyPBP
>>>>>> and it is saved into Mango.f95
>>>>>> I compile it from the bash shell using: gfortran4 c Mango.f95 and
>>>>>> gfortran4 shared o Mango.dll Mango.o
>>>>>> I am on a Windows machine running Windows 7 with Intel i7.
>>>>>> I load the dll in a 32bit R by dyn.load("Mango.dll"). Using
>>>>>> getLoadedDLLs
>>>>>> I can see the DLL. However, is.loaded("Mango.dll") = FALSE. In
>>>>>> addition, R
>>>>>> stop responding when I try .Fortran("MyPBP", as.numeric(S),
>>>>>> as.numeric(p),
>>>>>> as.integer(N)),
>>>>>> where N<5, S<array(0,N+1) and p< c(0.1, 0.2, 0.5, 0.8, 0.9).
>>>>>>
>>>>>> What am I doing wrong?
>>>>>> Any ideas, thoughts and/or comments are highly appreciated.
>>>>>>
>>>>>> Jens
>>>>>>
>>>>>> [[alternative HTML version deleted]]
>>>>>>
>>>>>> ______________________________****________________
>>>>>> [hidden email] mailing list
>>>>>> https://stat.ethz.ch/mailman/****listinfo/rhelp< https://stat.ethz.ch/mailman/**listinfo/rhelp>
>>>>>> < https://stat.**ethz.ch/mailman/listinfo/r**help< https://stat.ethz.ch/mailman/listinfo/rhelp>
>>>>>> PLEASE do read the posting guide http://www.Rproject.org/**>>>>>> postingguide.html < http://www.Rproject.org/**postingguide.html< http://www.Rproject.org/postingguide.html>
>>>>>>
>>>>>> and provide commented, minimal, selfcontained, reproducible code.
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/rhelp>> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html>> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

