[Numpy-discussion] f2py is not recognizing Absoft Fortran Compiler

2019-04-27 Thread Samuel Dupree


I'm attempting to build an interface between a Fortran application I 
have and Python. The problem I'm having is that f2py is not recognizing 
my Absoft Fortran compiler. Details follow.


I'm running on a iMacPro (2017) under Mac OS X Mojave (ver. 10.14.4). 
The version of the Absoft Compiler I'm running is 19.0.0. I'm using the 
Anaconda distribution of Python 3, version 3.6.8, where the version of 
NumPy used is ver. 1.16.3.


The commands I'm using to build the Python interface function and there 
results are:



f2py    -m DIVA_EphGen_f77  -h DIVA_EphGen_f77.pyf DIVA_EphGen_f77.f 
--overwrite-signature


(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$ 
./BuildMe_Part-1.sh

Reading fortran codes...
    Reading file 'DIVA_EphGen_f77.f' (format:fix,strict)
Post-processing...
    Block: DIVA_EphGen_f77
            Block: diva_ephgen_f77
Post-processing (stage 2)...
Saving signatures to file "./DIVA_EphGen_f77.pyf"
(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$


f2py    -c --fcompiler=absoft DIVA_EphGen_f77.pyf DIVA_EphGen_f77.f \
    --f77exec=/Applications/Absoft19.0/bin/af77 \
    -L/Users/user/2nd_ODE_auto_deriv_cleanup_Rev-07/ -lDIVA_EphGen \
-L/Volumes/Development/AstrodynamicsLib/MacOSX.NAIF.Fortran.v65/toolkit-64-bit/lib/ 
-lspicelib \
-L/Volumes/Development/AstrodynamicsLib/MacOSX.NAIF.Fortran.v65/toolkit-64-bit/lib/ 
-lsupport \

    -L/Application/Absoft19.0/lib64/ -lblas \
    -L/Application/Absoft19.0/lib64/ -lAbsoftlapack \
    --verbose

(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$ 
./BuildMe_Part-2.sh

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands 
--compiler options

running config_fc
unifing config_fc, config, build_clib, build_ext, build commands 
--fcompiler options

running build_src
build_src
building extension "DIVA_EphGen_f77" sources
creating 
/var/folders/65/7cxpqns144q6wx5lyb7zcyh8gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6

f2py options: []
f2py: DIVA_EphGen_f77.pyf
Reading fortran codes...
    Reading file 'DIVA_EphGen_f77.pyf' (format:free)
Post-processing...
    Block: DIVA_EphGen_f77
            Block: diva_ephgen_f77
Post-processing (stage 2)...
Building modules...
    Building module "DIVA_EphGen_f77"...
        Constructing wrapper function "diva_ephgen_f77"...
          diva_ephgen_f77(cmdline,scale_factor)
    Wrote C/API module "DIVA_EphGen_f77" to file 
"/var/folders/65/7cxpqns144q6wx5lyb7zcyh8gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6/DIVA_EphGen_f77module.c"
  adding 
'/var/folders/65/7cxpqns144q6wx5lyb7zcyh8gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6/fortranobject.c' 
to sources.
  adding 
'/var/folders/65/7cxpqns144q6wx5lyb7zcyh8gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6' 
to include_dirs.
copying 
/Users/user/anaconda3/lib/python3.6/site-packages/numpy/f2py/src/fortranobject.c 
-> 
/var/folders/65/7cxpqns144q6wx5lyb7zcyh8gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6
copying 
/Users/user/anaconda3/lib/python3.6/site-packages/numpy/f2py/src/fortranobject.h 
-> 
/var/folders/65/7cxpqns144q6wx5lyb7zcyh8gq/T/tmpkv4x9yg7/src.macosx-10.9-x86_64-3.6

build_src: building npy-pkg config files
running build_ext
new_compiler returns 
customize UnixCCompiler
customize UnixCCompiler using build_ext


preprocessor  = ['x86_64-apple-darwin13.4.0-clang', '-E', 
'-D_FORTIFY_SOURCE=2', '-mmacosx-version-min=10.9']
compiler  = ['x86_64-apple-darwin13.4.0-clang', '-DNDEBUG', 
'-fwrapv', '-O2', '-Wall', '-Wstrict-prototypes', '-march=core2', 
'-mtune=haswell', '-mssse3', '-ftree-vectorize', '-fPIC', '-fPIE', 
'-fstack-protector-strong', '-O2', '-pipe', '-D_FORTIFY_SOURCE=2', 
'-mmacosx-version-min=10.9']
compiler_so   = ['x86_64-apple-darwin13.4.0-clang', '-DNDEBUG', 
'-fwrapv', '-O2', '-Wall', '-Wstrict-prototypes', '-march=core2', 
'-mtune=haswell', '-mssse3', '-ftree-vectorize', '-fPIC', '-fPIE', 
'-fstack-protector-strong', '-O2', '-pipe', '-D_FORTIFY_SOURCE=2', 
'-mmacosx-version-min=10.9']

compiler_cxx  = ['x86_64-apple-darwin13.4.0-clang++']
linker_so = ['x86_64-apple-darwin13.4.0-clang', '-bundle', 
'-undefined', 'dynamic_lookup', '-Wl,-pie', 
'-Wl,-headerpad_max_install_names', 
'-Wl,-rpath,/Users/user/anaconda3/lib', '-L/Users/user/anaconda3/lib', 
'-Wl,-pie', '-Wl,-headerpad_max_install_names', 
'-Wl,-rpath,/Users/user/anaconda3/lib', '-L/Users/user/anaconda3/lib', 
'-Wl,-export_dynamic', '-Wl,-pie', '-Wl,-headerpad_max_install_names', 
'-Wl,-dead_strip_dylibs', '-march=core2', '-mtune=haswell', '-mssse3', 
'-ftree-vectorize', '-fPIC', '-fPIE', '-fstack-protector-strong', '-O2', 
'-pipe', '-D_FORTIFY_SOURCE=2', '-mmacosx-version-min=10.9']

linker_exe    = ['x86_64-apple-darwin13.4.0-clang']
archiver  = 
['/Users/user/anaconda3/bin/x86_64-apple-darwin13.4.0-ar', 'rc']

ranlib    = ['ranlib']
libraries = []
library_dirs  = []
inclu

Re: [Numpy-discussion] f2py is not recognizing Absoft Fortran Compiler

2019-04-27 Thread Samuel Dupree


On April/27/2019 21:59:37, Charles R Harris wrote:



On Sat, Apr 27, 2019 at 7:40 PM Samuel Dupree <mailto:sdup...@speakeasy.net>> wrote:



I'm attempting to build an interface between a Fortran application I
have and Python. The problem I'm having is that f2py is not
recognizing
my Absoft Fortran compiler. Details follow.

I'm running on a iMacPro (2017) under Mac OS X Mojave (ver. 10.14.4).
The version of the Absoft Compiler I'm running is 19.0.0. I'm
using the
Anaconda distribution of Python 3, version 3.6.8, where the
version of
NumPy used is ver. 1.16.3.

The commands I'm using to build the Python interface function and
there
results are:


Can you run the compiler in the console and show the `-V` (version) 
output? The distutils absoft compiler code looks really old and many 
things could have changed.




Chuck

___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Chuck,

Thank you for replying to my post. Below is the result of running the 
Absoft Compiler with the -V option:


(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$ f77 -V
Absoft Pro Fortran 19.0.0
ERROR: No input files.
(base) Samuels-Mac-Pro:2nd_ODE_auto_deriv_cleanup_Rev-07 user$

Sam Dupree.


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Attempting to wrap a Fortran-77 subroutine using f2py but I haven't been able to understand what is causing the error

2020-10-14 Thread Samuel Dupree
I'm attempting to wrap a Fortran-77 source member using f2py. I'm 
running he Anaconda distribution for Python 3.7.6 on a Mac Pro (2019) 
under Mac OS X Catalina (ver. 10.15.6). The version of NumPy I'm running 
is 1.18.3.


I've attached a copy of the Fortran source code to this note (see 
rkfn78.for). The command I'm using to wrap this code is


f2py3 -c rkfn78.for --fcompiler=gfortran --f77flags="-c -O -Wall" -m rkfn78

The output I get is captured in the file rkfn78_build_output.txt.

I don't understand the cause behind the error message I get, so any 
advice would be welcomed.


Sam Dupree.
  SUBROUTINE rkfn78( N, FCN, X, Y, YP, XEND, EPS, HMAX, H )
C --
C
C RKFN78 ( N, FCN, X, Y, YP, XEND, EPS, HMAX, H )
C
C Numerical solution of a system of second order
C ordinary differential equations  y"=f(x,y,dy)
C This is an embedded nystroem method of order 7(8)  
C due to Fehlberg with stepsize control
C
C input parameters
C 
C N   dimension of the system (N.LE.51)
C FCN name (external) of subroutine computing the
C second derivative F(X,Y,DY):
CSUBROUTINE FCN(X,Y,DY,F)
CREAL*8 X,Y(N),DY(N),F(N)
CF(1)=...   ETC.
C X   initial x-value
C XENDfinal x-value (XEND.GT.X)
C Y(N)initial values for y
C YP(N)   initial values for y'
C EPS local tolerance
C HMAXmaximal stepsize
C H   initial stepsize guess
C
C output parameters
C -
C Y(N)solution at xend
C YP(N)   derivative of solution at xend
C
C COMMON STAT can be used for statistics
CNFCN  number of function evaluations
CNSTEP number of computed steps
CNACCPTnumber of accepted steps
CNREJCTnumber of rejected steps
C
C  Ref.: Erwin Fehlberg, Computing 14, p.371, 1975
C --
C23456789012345678901234567890123456789012345678901234567890123456789012

  implicit none 

  ! I/O list

  INTEGER*4   N
  REAL*8  X, Y(N), YP(N), XEND, EPS, HMAX, H

  ! method related constants

  INTEGER*4   N_STAGE, P
  PARAMETER ( N_STAGE=13, P=7 )

  ! implementation dependant constants

  INTEGER*4   N_MAX, MAX_STEPS
  REAL*8  UROUND
  PARAMETER ( N_MAX=180, MAX_STEPS=2147483647, UROUND=1.1D-16 )
  ! auxiliary variables 

  REAL*8K ( 1:N_MAX, 0:N_STAGE )
  REAL*8Y1 ( 1:N_MAX ), YP1 ( 1:N_MAX ), TE ( 1:N_MAX )

  REAL*8POSNEG, HNEW, DENOM, ERR, FAC, H2, SUM, SUMP
  INTEGER   I_STAGE, I, J, L 
  LOGICAL   REJECT

  ! coefficients

  REAL*8 ALPHA_(1:13), BETA_(1:13,0:12), GAMMA_(1:13,0:12)
  COMMON /CRKFN78/ ALPHA_, BETA_, GAMMA_ 


  ! statistics 

  INTEGER*4   NFCN,NSTEP,NACCPT,NREJCT
  COMMON/STAT/ NFCN,NSTEP,NACCPT,NREJCT

Cf2py intent(in) N, FCN, X, XEND
Cf2py intent(inout) Y, YP, HMAX, H, EPS
Cf2py depend(in) Y, YP


  ! initial preparations

  IF (ALPHA_(13).NE.1.0D0) THEN
CALL FN78INI
  END IF 

  POSNEG = SIGN ( 1.0D0, XEND-X)

  HMAX   = ABS(HMAX)
  H  = MIN ( MAX(1.0D-8,ABS(H)) , HMAX )
  H  = SIGN ( H, POSNEG )

  EPS= MAX ( EPS, 9.0*UROUND )

  REJECT = .FALSE.

  NFCN   =  NFCN + 1

  CALL FCN ( X, Y, YP, K(1,0) )


  ! basic integration step 


  DO WHILE ( POSNEG*(X-XEND)+UROUND .LE. 0.0 )

! failure exit 

IF ( NSTEP.GT.MAX_STEPS .OR. X+0.05*H.EQ.X ) THEN 
  WRITE (*,*) 'Exit of RKNF78 at x = ', X
  WRITE (*,*) 'NSTEP = ', NSTEP
  WRITE (*,*) 'MAX_STEPS = ', MAX_STEPS
  WRITE (*,*) 'H = ', H
  WRITE (*,*) 'X+0.05*H = ', X+0.05*H
  STOP
END IF

! limit step size

IF ( (X+H-XEND)*POSNEG .GT. 0.0 ) THEN 
  H = XEND-X
END IF
H2= H**2
NSTEP = NSTEP+1

! calculate K(*,1) .. K(*,N_STAGE)

DO I_STAGE = 1,N_STAGE 
  DO L=1,N
SUM  = 0.0
SUMP = 0.0
DO J=0,(I_STAGE-1) 
  SUM  = SUM  + GAMMA_(I_STAGE,J)*K(L,J)
  SUMP = SUMP + BETA_ (I_STAGE,J)*K(L,J)
END DO
Y1(L)  = Y(L) + ALPHA_(I_STAGE)*H*YP(L) + H2*SUM
YP1(L) = YP(L) + H*SUMP
  END DO
  CALL FCN( X + ALPHA_(I_STAGE)*H, Y1, YP1, K(1,I_STAGE) )
END DO  ! end of loop over stages
NFCN = NFCN+N_STAGE

! error term and relative error estimation

DO L=1,N
  TE(L) = GAMMA_(N_STAGE,N_STAGE-1) * H2 
 .  * ( K(L,N_STAGE-1) - K(L,N_STAGE) )
END DO 
ERR = 0.0
DO L=1,N
  DENOM = MAX ( 1.0D-6, ABS(Y(L)), ABS(Y1(L)), 2.0*UROUND/EPS )
  ERR = ERR + ( TE(L) / DE

Re: [Numpy-discussion] Attempting to wrap a Fortran-77 subroutine using f2py but I haven't been able to understand what is causing the error

2020-10-19 Thread Samuel Dupree

Melissa,

Thank you for answering my post. I made the changes you recommended and 
the code compiles successfully. But I do have one question. The arrays 
being passed in the CALL to FCN were treated as assumed shaped arrays in 
the called subroutine. Are assumed shaped arrays a problem for f2py?


Sam Dupree.


On October/19/2020 09:16:02, Melissa Mendonça wrote:

Hello, Sam, sorry for taking so long to answer!

The problem seems to be that you are using

cf2py depend(in) Y, YP

instead of

cf2py depend(n) Y, YP <- (note that there was a spurious i in that 
depend expression)


and that the callback FCN needs the dimension n as an argument. I was 
able to compile your code correctly after making these changes.


If you have any further questions let me know, I hope this helps.

Cheers,

Melissa


On Wed, Oct 14, 2020 at 4:03 AM Samuel Dupree <mailto:sdup...@speakeasy.net>> wrote:


I'm attempting to wrap a Fortran-77 source member using f2py. I'm
running he Anaconda distribution for Python 3.7.6 on a Mac Pro (2019)
under Mac OS X Catalina (ver. 10.15.6). The version of NumPy I'm
running
is 1.18.3.

I've attached a copy of the Fortran source code to this note (see
rkfn78.for). The command I'm using to wrap this code is

f2py3 -c rkfn78.for --fcompiler=gfortran --f77flags="-c -O -Wall"
-m rkfn78

The output I get is captured in the file rkfn78_build_output.txt.

I don't understand the cause behind the error message I get, so any
advice would be welcomed.

Sam Dupree.
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org <mailto:NumPy-Discussion@python.org>
https://mail.python.org/mailman/listinfo/numpy-discussion
<https://mail.python.org/mailman/listinfo/numpy-discussion>


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

--
mail-signature



   Samuel H. Dupree, jr.sdup...@speakeasy.net
   10501 Rising Ridge Road
   Apartment 201 http://users.speakeasy.net/~sdupree/
   Fredericksburg, VA 22407, USA

    HOME: 540-693-1240            iPhone: 215-530-8753         FAX: 
866-514-9629


/  "The Greatest Show on Earth" is not on Earth. It's in Space!/


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Attempting to wrap a Fortran-77 subroutine using f2py but I haven't been able to understand what is causing the error

2020-10-19 Thread Samuel Dupree
One more question. Where can I find a documentation on f2py that covers 
issues like assumed shaped arrays, and issues such as the one discussed 
in this post?


Sam Dupree.


On October/19/2020 13:01:13, Melissa Mendonça wrote:
Sure, you can use assume-shape arrays, but if you generate a signature 
file using


$ f2py rkfn78.for -m rkfn78 -h rkfn78.pyf

you can see that f2py correctly determines n to be the length of the 
array Y, but since YP also depends on n, that's what generated the 
error you saw the first time.


If you change the .pyf signature file to the one attached to this 
message, delete your original cf2py lines in the .for file and compile 
it all using


$ f2py -c rkfn78.pyf rkfn78.for --fcompiler=gfortran --f77flags="-c -O 
-Wall" -m rkfn78


then you'll have no trouble with assumed-shape arrays.

Cheers,

Melissa

On Mon, Oct 19, 2020 at 1:03 PM Samuel Dupree <mailto:sdup...@speakeasy.net>> wrote:

>
> Melissa,
>
> Thank you for answering my post. I made the changes you recommended 
and the code compiles successfully. But I do have one question. The 
arrays being passed in the CALL to FCN were treated as assumed shaped 
arrays in the called subroutine. Are assumed shaped arrays a problem 
for f2py?

>
> Sam Dupree.
>
>
> On October/19/2020 09:16:02, Melissa Mendonça wrote:
>
> Hello, Sam, sorry for taking so long to answer!
>
> The problem seems to be that you are using
>
> cf2py depend(in) Y, YP
>
> instead of
>
> cf2py depend(n) Y, YP <- (note that there was a spurious i in that 
depend expression)

>
> and that the callback FCN needs the dimension n as an argument. I 
was able to compile your code correctly after making these changes.

>
> If you have any further questions let me know, I hope this helps.
>
> Cheers,
>
> Melissa
>
>
> On Wed, Oct 14, 2020 at 4:03 AM Samuel Dupree <mailto:sdup...@speakeasy.net>> wrote:

>>
>> I'm attempting to wrap a Fortran-77 source member using f2py. I'm
>> running he Anaconda distribution for Python 3.7.6 on a Mac Pro (2019)
>> under Mac OS X Catalina (ver. 10.15.6). The version of NumPy I'm 
running

>> is 1.18.3.
>>
>> I've attached a copy of the Fortran source code to this note (see
>> rkfn78.for). The command I'm using to wrap this code is
>>
>> f2py3 -c rkfn78.for --fcompiler=gfortran --f77flags="-c -O -Wall" 
-m rkfn78

>>
>> The output I get is captured in the file rkfn78_build_output.txt.
>>
>> I don't understand the cause behind the error message I get, so any
>> advice would be welcomed.
>>
>> Sam Dupree.
>> ___
>> NumPy-Discussion mailing list
>> NumPy-Discussion@python.org <mailto:NumPy-Discussion@python.org>
>> https://mail.python.org/mailman/listinfo/numpy-discussion 
<https://mail.python.org/mailman/listinfo/numpy-discussion>

>
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org <mailto:NumPy-Discussion@python.org>
> https://mail.python.org/mailman/listinfo/numpy-discussion 
<https://mail.python.org/mailman/listinfo/numpy-discussion>

>


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Attempting to wrap a Fortran-77 subroutine using f2py but I haven't been able to understand what is causing the error

2020-10-19 Thread Samuel Dupree

Melissa,

I've tried working with the documentation hosted at 
https://numpy.org/doc/stable/f2py/ <https://numpy.org/doc/stable/f2py/> 
and you're right, it is not very complete ;-). So on that front I wish 
you the best. Once again, thank you very much for answering my post.


All the best.

Sam Dupree.


On October/19/2020 13:53:03, Melissa Mendonça wrote:
The documentation for f2py is not very complete, I'm afraid. I'll try 
to work on that front in the next few months. For now, you can find it 
here: https://numpy.org/doc/stable/f2py 
<https://numpy.org/doc/stable/f2py>


Cheers,

Melissa

On Mon, Oct 19, 2020 at 2:35 PM Samuel Dupree <mailto:sdup...@speakeasy.net>> wrote:


One more question. Where can I find a documentation on f2py that
covers issues like assumed shaped arrays, and issues such as the
one discussed in this post?

Sam Dupree.


On October/19/2020 13:01:13, Melissa Mendonça wrote:

Sure, you can use assume-shape arrays, but if you generate a
signature file using

$ f2py rkfn78.for -m rkfn78 -h rkfn78.pyf

you can see that f2py correctly determines n to be the length of
the array Y, but since YP also depends on n, that's what
generated the error you saw the first time.

If you change the .pyf signature file to the one attached to this
message, delete your original cf2py lines in the .for file and
compile it all using

$ f2py -c rkfn78.pyf rkfn78.for --fcompiler=gfortran
--f77flags="-c -O -Wall" -m rkfn78

then you'll have no trouble with assumed-shape arrays.

    Cheers,

    Melissa

On Mon, Oct 19, 2020 at 1:03 PM Samuel Dupree
mailto:sdup...@speakeasy.net>> wrote:
>
> Melissa,
>
> Thank you for answering my post. I made the changes you
recommended and the code compiles successfully. But I do have one
question. The arrays being passed in the CALL to FCN were treated
as assumed shaped arrays in the called subroutine. Are assumed
shaped arrays a problem for f2py?
>
> Sam Dupree.
>
>
> On October/19/2020 09:16:02, Melissa Mendonça wrote:
>
> Hello, Sam, sorry for taking so long to answer!
>
> The problem seems to be that you are using
>
> cf2py depend(in) Y, YP
>
> instead of
>
> cf2py depend(n) Y, YP <- (note that there was a spurious i in
that depend expression)
>
> and that the callback FCN needs the dimension n as an argument.
I was able to compile your code correctly after making these changes.
>
> If you have any further questions let me know, I hope this helps.
>
> Cheers,
>
> Melissa
>
>
> On Wed, Oct 14, 2020 at 4:03 AM Samuel Dupree
mailto:sdup...@speakeasy.net>> wrote:
>>
>> I'm attempting to wrap a Fortran-77 source member using f2py. I'm
>> running he Anaconda distribution for Python 3.7.6 on a Mac Pro
(2019)
>> under Mac OS X Catalina (ver. 10.15.6). The version of NumPy
I'm running
>> is 1.18.3.
>>
>> I've attached a copy of the Fortran source code to this note (see
>> rkfn78.for). The command I'm using to wrap this code is
>>
>> f2py3 -c rkfn78.for --fcompiler=gfortran --f77flags="-c -O
-Wall" -m rkfn78
>>
>> The output I get is captured in the file rkfn78_build_output.txt.
>>
>> I don't understand the cause behind the error message I get,
so any
>> advice would be welcomed.
>>
>> Sam Dupree.
>> ___
>> NumPy-Discussion mailing list
>> NumPy-Discussion@python.org <mailto:NumPy-Discussion@python.org>
>> https://mail.python.org/mailman/listinfo/numpy-discussion
<https://mail.python.org/mailman/listinfo/numpy-discussion>
>
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org <mailto:NumPy-Discussion@python.org>
> https://mail.python.org/mailman/listinfo/numpy-discussion
<https://mail.python.org/mailman/listinfo/numpy-discussion>
>



___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Do not understand what f2py is reporting

2020-11-02 Thread Samuel Dupree

Andras,

Thank you for respond to my post. I sincerely appreciate it.

Following your advice, I replaced "integer * 4" with "integer" and I was 
able to generate the signature files for gravity_derivs.f. The problem 
now is generating the signature file for auto_deriv.f90.


I agree that f2py has a problem with

In: :auto_deriv:auto_deriv.f90:ad_auxiliary
get_parameters: got "invalid syntax (, line 1)" on 
'(/((i,i=j,n), j=1,n)/)'


I'm not sure I understand why f2py has a problem with this syntax. Is 
there documentation that talks to what Fortran77, Fortran 90/95 syntax 
f2py will and will not accept?


Sam Dupree.



On November/02/2020 07:22:06, Andras Deak wrote:

On Sun, Nov 1, 2020 at 2:33 AM Samuel Dupree  wrote:

I'm attempting to build wrappers around two Fortran routines. One is a
Fortran 77 subroutine (see file gravity_derivs.f) that calls a Fortran
90 package that performs automatic differentiation (see file
auto_deriv.f90).

I'm running he Anaconda distribution for Python 3.7.6 on a Mac Pro
(2019) under Mac OS X Catalina (ver. 10.15.6). The version of NumPy I'm
running is 1.18.3. The commands I used to attempt the build are
contained in the file auto_deriv_build. The messages output by f2py are
captured in the file auto_derivs_build_report.txt.

I don't understand the cause behind the error messages I got, so any
advice would be welcomed.

Sam Dupree.

Hi Sam,

I've got a partial solution.
I haven't used f2py yet but at least the error from your first `f2py`
call seems straightforward. Near the top:

 Line #119 in gravity_derivs.f:"  integer * 4degree"
 updatevars: no name pattern found for entity='*4degree'. Skipping.

This shows that the fortran code gets parsed as `(integer)
(*4degree)`. That can't be right. There might be a way to tell f2py to
do this right, but anyway I could make your code compile by replacing
every such declaration with `integer * 4 :: degree` etc (i.e. adding
double colons everywhere).
Once that's fixed your first f2py call raises another error:

 Fatal Error: Cannot open module file ‘deriv_class.mod’ for reading
at (1): No such file or directory

I could generate these mod files by manually running `gfortran -c
auto_deriv.f90`. After that the .mod files appear and your first
`f2py` call will succed.
You can now `import gravity_derivs`, but of course this will lead to
an error because `auto_deriv` is not available in python.
Unfortunately your _second_` f2py` call also dies on `auto_deriv.f90`,
with such offending lines:

 In: :auto_deriv:auto_deriv.f90:ad_auxiliary
 get_parameters: got "invalid syntax (, line 1)" on '(/((i,
i=j,n), j=1,n)/)'

I'm guessing that again f2py can't parse that syntax.
My hunch is that if you can get f2py to work with `auto_deriv.f90` you
should first run that. This should hopefully generate the .mod files
after which the second call to `f2py` with `gravity_derivs.f` should
work. If `f2py` doesn't generate the .mod files you could at worst run
your fortran compiler yourself between the two calls to `f2py`.
Cheers,

András


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion



___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Compilation failures in f2py

2021-01-23 Thread Samuel Dupree

Chris,

Thank you for responding to my post. I uninstalled and then reinstalled 
CommandLineTools per your suggestion. I'm still getting the same error. 
It appears that gcc is not seeing any of the CommandLineTools 
directories. When I ran the command


find /Library/Developer/CommandLineTools/ -name _stdio.h

I got:

(base) user@Mac-Pro ~ % find /Library/Developer/CommandLineTools/ -name 
_stdio.h

/Library/Developer/CommandLineTools//SDKs/MacOSX11.1.sdk/usr/include/_stdio.h
/Library/Developer/CommandLineTools//SDKs/MacOSX11.1.sdk/usr/include/xlocale/_stdio.h
/Library/Developer/CommandLineTools//SDKs/MacOSX11.1.sdk/usr/include/secure/_stdio.h
/Library/Developer/CommandLineTools//SDKs/MacOSX10.15.sdk/usr/include/_stdio.h
/Library/Developer/CommandLineTools//SDKs/MacOSX10.15.sdk/usr/include/xlocale/_stdio.h
/Library/Developer/CommandLineTools//SDKs/MacOSX10.15.sdk/usr/include/secure/_stdio.h

Any suggestions?

Sam Dupree.




On January/12/2021 05:11:50, Christopher Albert wrote:

Hi Sam,

looks like the XCode command line tools containing standard headers 
are either not installed or updated. Try xcode-select --install or 
manually download them from https://developer.apple.com/download/more/ 
<https://developer.apple.com/download/more/> and maybe 
uninstall/reinstall them in case updates don't work. Check with


find /Library/Developer/CommandLineTools/ -name _stdio.h

which should 
give /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_stdio.h 
(besides possible older versions of MacOSX)


Best,

Chris




Am Sa., 9. Jan. 2021 um 03:02 Uhr schrieb Samuel Dupree 
mailto:sdup...@speakeasy.net>>:


I'm attempting to wrap a Fortran-77 source member library using f2py.
I'm running he Anaconda distribution for Python 3.7.6 on a Mac Pro
(2019) under Mac OS X Big Sur (ver. 11.1). The version of
Xcode.app I'm
running is 12.3. The version of NumPy I'm running is 1.18.3.

The errors I'm getting are from header files the compiler can't
find as
captured in the attached log file. A sample of the kind of errors I'm
seeing are captured below.

compile options:

'-I/var/folders/2r/4bw6nw0x58z0_ybx632_h14mgq/T/tmp5uemdb2k/src.macosx-10.9-x86_64-3.7

-I/Users/user/opt/anaconda3/lib/python3.7/site-packages/numpy/core/include

-I/Users/user/opt/anaconda3/include/python3.7m -c'
gcc:

/var/folders/2r/4bw6nw0x58z0_ybx632_h14mgq/T/tmp5uemdb2k/src.macosx-10.9-x86_64-3.7/sofapymodule.c
gcc:

/var/folders/2r/4bw6nw0x58z0_ybx632_h14mgq/T/tmp5uemdb2k/src.macosx-10.9-x86_64-3.7/fortranobject.c
In file included from

/opt/local/lib/gcc10/gcc/x86_64-apple-darwin20/10.2.0/include-fixed/syslimits.h:7,
  from

/opt/local/lib/gcc10/gcc/x86_64-apple-darwin20/10.2.0/include-fixed/limits.h:34,
  from
/Users/user/opt/anaconda3/include/python3.7m/Python.h:11,
  from

/var/folders/2r/4bw6nw0x58z0_ybx632_h14mgq/T/tmp5uemdb2k/src.macosx-10.9-x86_64-3.7/sofapymodule.c:14:

/opt/local/lib/gcc10/gcc/x86_64-apple-darwin20/10.2.0/include-fixed/limits.h:195:61:

error: no include path in which to search for limits.h
   195 | #include_next   /* recurse down to the real one */
| ^
In file included from
/Users/user/opt/anaconda3/include/python3.7m/Python.h:25,
  from

/var/folders/2r/4bw6nw0x58z0_ybx632_h14mgq/T/tmp5uemdb2k/src.macosx-10.9-x86_64-3.7/sofapymodule.c:14:

/opt/local/lib/gcc10/gcc/x86_64-apple-darwin20/10.2.0/include-fixed/stdio.h:78:10:

fatal error: _stdio.h: No such file or directory
    78 | #include <_stdio.h>
   |  ^~
compilation terminated.

Any suggestions?

Sam Dupree.


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org <mailto:NumPy-Discussion@python.org>
https://mail.python.org/mailman/listinfo/numpy-discussion
<https://mail.python.org/mailman/listinfo/numpy-discussion>


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Getting scipy.interpolate.pchip_interpolate to return the first derivative of a pchip interpolation

2023-01-21 Thread Samuel Dupree
I'm running SciPy ver. 1.9.3 under Python ver. 3.9.15  on a Mac Pro 
(2019) desktop running Mac OSX ver. 13.1 Ventura. The problem I'm having 
is getting scipy.interpolate.pchip_interpolate to return the first 
derivative of a pchip interpolation.


The test program I'm using is given below (and attached to this note).


import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import pchip_interpolate

x_observed  = np.linspace(0.0, 360.0, 51)
y_observed  = np.sin(np.pi*x_observed/180)
dydx_observed = np.cos(np.pi*x_observed/180)

x    = np.linspace(min(x_observed), max(x_observed), num=100)
y    = pchip_interpolate(x_observed, y_observed, x, der=0, axis=0)
dydx = pchip_interpolate(x_observed, y_observed, x, der=1, axis=0)

plt.plot(x_observed,    y_observed, "bo" , label="observation funct")
plt.plot(x_observed, dydx_observed, "rx" , label="observation deriv")
plt.plot(x , y    , "c-", label="pchip interpolation funct")
plt.plot(x , dydx , "k-", label="pchip interpolation deriv")
plt.legend()
plt.savefig("pchip_example_01.png")
plt.show()


The program generates values of the sine function (y_observed) over the 
range of 0 to 360 degrees. (x_observed). In a similar fashion, the 
cosine function (first derivative of the sine function) is generated 
over the same range (dydx_observed). pchip_interpolate is used to 
perform the interpolation over a specified range for the function and 
its first derivative. A composite plot is generated showing the points 
for the function (the sine) and its first derivative (cosine). The 
interpolated points overlay the function (sine) as expected. However, 
the first derivative returned fails to overlay the cosine function. The 
plot is attached to this note.


Any thoughts or suggestions?

Sam Dupree
#!/Users/user/opt/anaconda3/bin/python3

import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import pchip_interpolate

x_observed  = np.linspace(0.0, 360.0, 51)
y_observed  = np.sin(np.pi*x_observed/180)
dydx_observed = np.cos(np.pi*x_observed/180)

x= np.linspace(min(x_observed), max(x_observed), num=100)
y= pchip_interpolate(x_observed, y_observed, x, der=0, axis=0)
dydx = pchip_interpolate(x_observed, y_observed, x, der=1, axis=0)

plt.plot(x_observed,y_observed, "bo" , label="observation funct")
plt.plot(x_observed, dydx_observed, "rx" , label="observation deriv")
plt.plot(x , y, "c-", label="pchip interpolation funct")
plt.plot(x , dydx , "k-", label="pchip interpolation deriv")
plt.legend()
plt.savefig("pchip_example_01.png")
plt.show()
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: Getting scipy.interpolate.pchip_interpolate to return the first derivative of a pchip interpolation

2023-01-22 Thread Samuel Dupree

I believe I know what is going on, but I don't understand why.

The line for the first derivative that failed to coincide with the 
points in the plot for the cosine is actually the interpolated first 
derivative scaled by the factor pi/180. When I multiply the interpolated 
values for the first derivative by 180/pi,  the interpolated first 
derivative coincides with the points for the cosine as expected.


What I don't understand is how the interpolator came up with the scale 
factor it did and applied it using pure numbers.


Any thoughts?

Sam Dupree.


On 1/21/23 18:04, Samuel Dupree wrote:


I'm running SciPy ver. 1.9.3 under Python ver. 3.9.15  on a Mac Pro 
(2019) desktop running Mac OSX ver. 13.1 Ventura. The problem I'm 
having is getting scipy.interpolate.pchip_interpolate to return the 
first derivative of a pchip interpolation.


The test program I'm using is given below (and attached to this note).


import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import pchip_interpolate

x_observed  = np.linspace(0.0, 360.0, 51)
y_observed  = np.sin(np.pi*x_observed/180)
dydx_observed = np.cos(np.pi*x_observed/180)

x    = np.linspace(min(x_observed), max(x_observed), num=100)
y    = pchip_interpolate(x_observed, y_observed, x, der=0, axis=0)
dydx = pchip_interpolate(x_observed, y_observed, x, der=1, axis=0)

plt.plot(x_observed,    y_observed, "bo" , label="observation funct")
plt.plot(x_observed, dydx_observed, "rx" , label="observation deriv")
plt.plot(x , y    , "c-", label="pchip interpolation 
funct")
plt.plot(x , dydx , "k-", label="pchip interpolation 
deriv")

plt.legend()
plt.savefig("pchip_example_01.png")
plt.show()


The program generates values of the sine function (y_observed) over 
the range of 0 to 360 degrees. (x_observed). In a similar fashion, the 
cosine function (first derivative of the sine function) is generated 
over the same range (dydx_observed). pchip_interpolate is used to 
perform the interpolation over a specified range for the function and 
its first derivative. A composite plot is generated showing the points 
for the function (the sine) and its first derivative (cosine). The 
interpolated points overlay the function (sine) as expected. However, 
the first derivative returned fails to overlay the cosine function. 
The plot is attached to this note.


Any thoughts or suggestions?

Sam Dupree


___
NumPy-Discussion mailing list --numpy-discussion@python.org
To unsubscribe send an email tonumpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address:sdup...@speakeasy.net
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com