Skip to content

[R-pkg-devel] compute pnorm in Fortran subroutine in R package

3 messages · Wang, Zhu, Duncan Murdoch

#
Hello,

In my R package I would like a Fortran subroutine to compute the same value as pnorm does in R. I didn't find out an existing Fortran pnorm subroutine. Perhaps a Fortran subroutine can somehow call R function pnorm, but I would like advice on how to do this correctly.

Many thanks!

Zhu Wang
#
On 08/03/2019 12:55 p.m., Wang, Zhu wrote:
This is described in the Writing R Extensions manual, Ch 6, The R API: 
entry points for C code.  As the title suggests, it's mainly written for 
calling things like pnorm() from C, but section 6.6 talks about calling 
C functions from Fortran.

You probably also have the erf() function available in Fortran; it's a 
linear transformation of pnorm().  That is,

   erf(x) = 2*pnorm(x*sqrt(2)) - 1

Duncan Murdoch
#
Thanks for the useful tips!

-----Original Message-----
From: Duncan Murdoch <murdoch.duncan at gmail.com> 
Sent: Friday, March 8, 2019 1:32 PM
To: Wang, Zhu <wangz1 at uthscsa.edu>; R-package-devel at r-project.org
Subject: Re: [R-pkg-devel] compute pnorm in Fortran subroutine in R package
On 08/03/2019 12:55 p.m., Wang, Zhu wrote:
This is described in the Writing R Extensions manual, Ch 6, The R API: 
entry points for C code.  As the title suggests, it's mainly written for calling things like pnorm() from C, but section 6.6 talks about calling C functions from Fortran.

You probably also have the erf() function available in Fortran; it's a linear transformation of pnorm().  That is,

   erf(x) = 2*pnorm(x*sqrt(2)) - 1

Duncan Murdoch