Coder Social home page Coder Social logo

tchlux / fmodpy Goto Github PK

View Code? Open in Web Editor NEW
62.0 4.0 3.0 1.11 MB

A lightweight, efficient, highly automated, fortran wrapper for python.

License: MIT License

Python 80.86% Fortran 18.58% Cython 0.56%
python3 fortran fortran2008 fortran95 fortran90 fortran77 wrapper python

fmodpy's Introduction

fmodpy

An easy-to-use Fortran wrapper for Python.
No source code changes, no manual specification files, just import like it's native.

# Automatically generate a wrapper, compile, link, and import into Python.
fortran_module = fmodpy.fimport('MODULE.f08', dependencies=['LIB.f90', 'BLAS.f'])
#   - handles any Fortran source, modern, or fixed format F77
#   - reads the source to determine the interface specification
#   - includes Fortran documentation in the wrapped code
#   - produces a stand-alone and distrutable Python module with only numpy as dependency

Modern Fortran is capable of being integrated with Python near seamlessly allowing for rapid transition between prototype and optimized production-ready code. This packages aims to make Fortran code as easy to import and use as native Python. This combines the performance of Fortran with the convenience and accessibility of Python, allowing for a productive and exciting development pipeline.

This package is compiler independent. The generated wrappers are self contained, written purely in Python, and are immediately sharable to any other POSIX platform with a Fortran compiler installed. The only python dependency is numpy (no need to hassle with installing cython). After generating the python wrapper module, even fmodpy itself is no longer a dependency! This makes fmodpy particularly suitable to writing and sharing performant mathematical software with a broader audience, since complex dependencies can often be difficult to configure on cutting edge high performance computing platforms.

INSTALLATION:

python3 -m pip install fmodpy

This code expects that you already have a Fortran compiler installed. By default most machines do not have a Fortran compiler installed, but most package managers support installation of gfortran (a GNU compiler). In addition, there are popular commercial Fortran compilers such as pgifortran (the PGI compiler that uniquely supports OpenACC), ifort (the Intel compiler), and f90 (the Oracle Sun compiler).

The easiest setup is to install gfortran with your preferred package manager, then the default behaviors of fmodpy will work correctly.

USAGE:

PYTHON:

import fmodpy

# Compile and import the Fortran code. (This will automatically
#  recompile the module if the Fortran source has been saved 
#  more recently than the last time the module was imported.)
module = fmodpy.fimport("<path to fortran source file>")

For more details, see the help(fmodpy.fimport) documentation. Notably, global configurations (i.e., the default Fortran compiler) can be viewed and edited with fmodpy.configure.

COMMAND LINE:

Run fmodpy from the command line with:

python3 -m fmodpy "<fortran-source-file>" [setting1="<value1>"] [setting2="<value2>"] ...

The result will be a directory containing a Python package that wraps and calls the underlying Fortran code.

Execute with no arguments to get help documentation. For a list of the different configuration options, run the command:

python3 -c "import fmodpy; fmodpy.configure()"

SUPPORTED FORTRAN:

  • INTEGER 32 and 64 bit, (allocatable / assumed shape) arrays, optionals, pointers
  • REAL 32 and 64 bit, (allocatable / assumed shape) arrays, optionals, pointers
  • CHARACTER singletons and assumed-shape arrays, but no support for LEN behaviors
  • COMPLEX 64 and 128 bit, (allocatable / assumed shape) arrays, optionals, pointers
  • LOGICAL singletons, (allocatable / assumed shape) arrays, optionals, pointers
  • TYPE singletons, (allocatable / assumed shape) arrays, optionals, and pointers (type must have BIND(C) attribute)
  • SUBROUTINE standard behaviors (automatically drops PURE and RECURSIVE prefixes)
  • FUNCTION standard behaviors (wrapped with a standard subroutine call)
  • MODULE wrapper that behaves like an instantiated Python class with property-based accessors for internal attributes

It is a goal to eventually allow for the following:

  • passing a PROCEDURE as an argument to Fortran code

This code base is entirely driven by concrete examples and use-cases. If you want to see something supported that is not currently, please consider posting a minimum example of the Fortran code you'd like to wrap under the Issues page.

HOW IT WORKS:

Reads the fortran file, abstracting out the modules, subroutines, functions. Identifies the type-description of each argument for module variables, subroutines, and functions. Uses type-descriptors to generate a Fortran wrapper with BIND(C) enabled, as well as a matching Python wrapper using ctypes to pass data from Python into the Fortran wrapper. The constructed Python wrapper contains compilation settings that will automatically recompile a shared object file containing the underlying original Fortran source code. Overall, the call sequence at runtime looks like:

   Python code
-> Python wrapper converting to C types
-> Fortran wrapper bound to C (transferring characters, implicit shapes, etc.)
-> Original Fortran code

This uses the specifications from the fortran file to determine how the interface for each subroutine / function should behave. (I.e., INTENT(IN) does not return, INTENT(OUT) is optional as input.)

EXAMPLE CODE

Here is a simple python code that compares a fmodpy-wrapped Fortran code with standard NumPy. This example performs a matrix multiply operation using Fortran.

# This is a Python file named whatever you like. It demonstrates
#   automatic `fmodpy` wrapping.

import fmodpy
import numpy as np

code = fmodpy.fimport("code.f03")

a = np.array([
    [1,2,3,4,5],
    [1,2,3,4,5]
], dtype=float, order='F')

b = np.array([
    [1,2],
    [3,4],
    [5,6],
    [7,8],
    [9,10]
], dtype=float, order='F')

print()
print("a:")
print(a)

print()
print("b:")
print(b)

print()
print("Numpy result")
print(np.matmul(a,b))

print()
print("Fortran result")
print(code.matrix_multiply(a,b))


print()
help(code.matrix_multiply)

Here is the associated Fortran file code.f03 (no specific reason for the name, any of .f95, .f03, and .f08 extensions could be used).

! This module provides various testbed routines for demonstrating
! the simplicity of Fortran code usage with `fmodpy`.
! 
! Contains:
! 
!   MATRIX_MULTIPLY  --  A routine for multiplying two matrices of floats.
! 

SUBROUTINE MATRIX_MULTIPLY(A,B,OUT)
  ! This subroutine multiplies the matrices A and B.
  ! 
  ! INPUT:
  !   A(M,N)  --  A 2D matrix of 64 bit floats.
  !   B(N,P)  --  A 2D matrix of 64 bit floats,
  ! 
  ! OUTPUT:
  !   OUT(M,P)  --  The matrix that is the result of (AB).
  ! 
  USE ISO_FORTRAN_ENV, ONLY: REAL64 ! <- Get a float64 type.
  IMPLICIT NONE  ! <- Make undefined variable usage raise errors.
  REAL(KIND=REAL64), INTENT(IN),  DIMENSION(:,:) :: A, B
  REAL(KIND=REAL64), INTENT(OUT), DIMENSION(SIZE(A,1),SIZE(B,2)) :: OUT

  ! Compute the matrix multiplication of A and B.
  OUT(:,:) = MATMUL(A,B)

END SUBROUTINE MATRIX_MULTIPLY

Now run the python program and see the output!

fmodpy's People

Contributors

tchlux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fmodpy's Issues

ValueError: invalid literal for int() with base 10: '1)'

Hi,

Currently I am getting the following error:

Traceback (most recent call last):
  File "/home/johannes/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/johannes/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/__main__.py", line 33, in <module>
    fimport(file_path, **command_line_args)
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/fmodpy.py", line 178, in fimport
    fortran_wrapper, python_wrapper = make_wrapper(
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/fmodpy.py", line 277, in make_wrapper
    python_file = abstraction.generate_python()
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/parsing/file.py", line 97, in generate_python
    lines += super().generate_python()
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/parsing/code.py", line 154, in generate_python
    lines += instance.generate_python(*args) + ['']
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/parsing/module.py", line 126, in generate_python
    lines += ['    '+l for l in code.generate_python(*args)]
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/parsing/subroutine.py", line 306, in generate_python
    arg_declare = arg.py_declare()
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/parsing/argument.py", line 205, in py_declare
    default_shape = ', '.join(self._default_size()).lower()
  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/parsing/argument.py", line 586, in _default_size
    dim = str(int(dim) - 1)
ValueError: invalid literal for int() with base 10: '1)'

when running python3 -m fmodpy test.f90.

test.f90 has the following code:

module tmm

	use iso_fortran_env, only: int32, real64
	implicit none
	
	contains

	pure function calc_angle(incidence_angle,n) result(angle)

		real(real64), intent(in) 	:: incidence_angle
		real(real64), intent(in) 	:: n(:,:)
		real(real64)			:: angle(size(n(:,1)),size(n(1,:)))

	end function calc_angle

end module tmm

This piece of code compiles just fine using gfortran -c test.f90.
I suspect it has to do with the dimensions in the definition of the array angle.
Currently, I am using fmodpy version 1.3.3. Do you know what causes this behaviour?

koshMer

Undefined Symbol Error

I managed to uninstall and reinstall fmodpy. Now, all examples from last time work great -- via command line and my python editor.

However, when I try to run the following piece of code tmm.txt
with this python file:

import fmodpy 
import numpy as np

code = fmodpy.fimport("tmm.f90")

n = np.array([1,2,1,2,1,2],dtype = float, order  = "F")
print(code.calc_k(630e-9,n,n))

i get the following error message:

Traceback (most recent call last):

  File "/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/python_test_f90.py", line 38, in <module>
    print(code.calc_k(630e-9,n,n))

  File "/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/tmm/__init__.py", line 85, in calc_k
    clib.c_calc_k(ctypes.byref(wavelength), ctypes.byref(n_dim_1), ctypes.c_void_p(n.ctypes.data), ctypes.byref(angle_dim_1), ctypes.c_void_p(angle.ctypes.data), ctypes.byref(k_dim_1), ctypes.c_void_p(k.ctypes.data))

  File "/home/johannes/anaconda3/lib/python3.8/ctypes/__init__.py", line 394, in __getattr__
    func = self.__getitem__(name)

  File "/home/johannes/anaconda3/lib/python3.8/ctypes/__init__.py", line 399, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))

AttributeError: /home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/tmm/tmm.so: undefined symbol: c_calc_k

Do you have a clue what's going on?

Building conda package from source code on pypi

Hi :)

I am currently trying to build an anaconda package from the source code you uploaded on pypi.org. Since it is on pypi it is supposedly quite easy to do so ^^.

For reference, i followed this official guide: conda-build skeleton.

During testing the build scripts expects the following path in the folder og.fmodpy: /about/version.txt
What is the purpose of og.fmodpy? You mentioned somewhere that this folder contains old code. Is it necessary to make your module work?

Linking to OpenBLAS for BLAS and LAPACK on Windows

Hi! thank you for this great tool. After wrestling with f2py for way too long this is indeed great to have.

For simple tasks I've managed to make it working so far and then I wanted to step up my game with linking to OpenBLAS on windows. It has its own complications obviously but what I am trying to do can be described as;

1- Let's say I downloaded OpenBLAS from Anaconda https://anaconda.org/conda-forge/libopenblas/files
2- My target is to wrap the FORTRAN library https://github.com/SLICOT/SLICOT-Reference but in it let's pick a very simple file /src/MB01OE.f that has only BLAS dependencies but the rest is standalone; a good candidate for a linking exercise.
3- Now I know somehow I have to use fmodpy.config.{something} to arrive at the command
gfortran -shared .\MB01OE.f -o .\MB01OE.o -L"C:\opt\64\lib" -lopenblas
(or I completely misunderstood the configuration mechanism).

I have not been able to do this step go forward yet. Could you point me to any direction ? Or is this even possible with openblas both having blas and lapack symbols.

If you want a slightly more complicated example https://github.com/SLICOT/SLICOT-Reference/blob/main/src/MB01OD.f depends on both BLAS and MB01OE.f mentioned above which is my second mini-goal if I can get this working.

Support for OpenMP or Co-array Fortran

Hi,
I was wondering whether your wrapper has support for openMP or co-array fortran?

i tried running the .f90 program:

module hello_images

	implicit none
	
	contains
	
	subroutine hello()
	
		print *, "I am iamge", this_image(), "of", num_images()
	
	end subroutine hello
	
  	
end module hello_images

with the following python program

import fmodpy 

code = fmodpy.fimport("hello_images.f90",f_compiler = "caf")

code.hello_images.hello()

This gives me an output of I am iamge 0 of 0

Usually, when using co-array fortran, one would supply the number of images when running the program.
For Example: cafrun -n program

Is something like this possible with your wrapper?

Encountered unrecognized line while parsing Module

Hi,
I am not familiar with github, so I don't know whether this is the right place to ask:

  • I am currently trying to compile Fortran code using fmodpy and ran into the following error:

Encountered unrecognized line while parsing Module:

'PURE FUNCTION MATINV2 ( A ) RESULT ( B )'

are pure functions not supported by your module?

  • When I delete the attribute pure i run into the following exception - could you tell me why?:

fmodpy.exceptions.ParseError: Finished parsing FUNCTION MATINV2, but never declared A, B.

Attached you can find the minimum working example which i ran with python3 fmodpy minimum_working_example.f90 name=mwe:
minimum_working_example.txt

  • Also: I accidentally forgot the end module tmm statement the first time i ran python3 fmodpy minimum_working_example.f90 name=mwe and i had to CTRL-C the terminal because it wouldn't stop ^^ :)

I really like this project of yours, keep it going! 🥇

Compilation of fortran file fails: cannot open shared object file

Hi, its me again :)

I tried to put several functions in one file test2.f90 and use it in python. However, the compilation of this small program fails.
The code in question:

pure function add(val1, val2) result(val3)
	
	use iso_fortran_env, only: real32
	implicit none
	
	real(real32), intent(in)	:: val1,val2
	real(real32)			:: val3
	
	val3 = val1+val2
	

end function add

pure function triple_add(val1,val2) result(val3)


	use iso_fortran_env, only: real32
	implicit none
	
	real(real32), intent(in)	:: val1,val2
	real(real32)			:: val3
	
	val3 = add(val1,val2)*3.0


end function triple_add 

The python code i use to run it:

import fmodpy 
import numpy as np
code = fmodpy.fimport("test.f90",verbose = True)


val1 = np.float32(1)
val2 = np.float32(2)

code.add(1,2)

code.triple_add(1,2)

And the error output:

______________________________________________________________________
fimport

fmodpy configuration:
  autocompile = True
  blas = False
  config_file = '.fmodpy.py'
  debug_line_numbers = False
  end_is_named = True
  f_compiler = 'gfortran'
  f_compiler_args = ['-fPIC', '-shared', '-O3']
  home_directory = '/home/johannes'
  implicit_typing = False
  lapack = False
  link_blas = ['-lblas']
  link_lapack = ['-lblas', '-llapack']
  link_omp = ['-fopenmp']
  log_file = <ipykernel.iostream.OutStream object at 0x7f6acd706bb0>
  omp = False
  rebuild = False
  show_warnings = True
  verbose = True
  wrap = True

=================================================================================
Input file directory:  /home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test
Input file name:       test2.f90
Base module name:      test2
Using build dir:       temporary directory
  fortran wrapper:     test2_c_wrapper.f90
  python wrapper:      test2_python_wrapper.py
Output module path:    /home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test
=================================================================================

Using temporary build directory at '/tmp/tmp2t6pmdpk'.
Build directory is different from source directory..
 sym-linking '/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test2.f90' to '/tmp/tmp2t6pmdpk/test2.f90'
 sym-linking '/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test.txt' to '/tmp/tmp2t6pmdpk/test.txt'
 sym-linking '/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test' to '/tmp/tmp2t6pmdpk/test'

Attempting to autocompile..

 reading 'test2.f90' to check if it can be autocompiled.. yes.
 skipping '/tmp/tmp2t6pmdpk/test.txt'
 skipping '/tmp/tmp2t6pmdpk/test'

Compiling 'test2.f90'.. 
 gfortran -fPIC -shared -O3 -o ./fmodpy_get_size test2.f90
  failed.
----------------------------------------------------------------------
STANDARD ERROR:
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Return type mismatch of functionaddat (1) (UNKNOWN/REAL(4))
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Functionaddat (1) has no IMPLICIT type
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Reference to impure functionaddat (1) within a PURE procedure

----------------------------------------------------------------------
Compiling 'test2.f90'.. 
 gfortran -fPIC -shared -O3 -o ./fmodpy_get_size test2.f90
  failed.
----------------------------------------------------------------------
STANDARD ERROR:
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Return type mismatch of functionaddat (1) (UNKNOWN/REAL(4))
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Functionaddat (1) has no IMPLICIT type
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Reference to impure functionaddat (1) within a PURE procedure

----------------------------------------------------------------------
Failed to compile 'test2.f90'.
Failed to compile 'test2.f90'.

File.parse 
Function.parse ADD
 Function.parse done.
Function.parse TRIPLE_ADD
 Function.parse done.
 File.parse done.
----------------------------------------------------------------------
FILE 
  FUNCTION ADD(VAL1, VAL2) RESULT(VAL3)
    USE ISO_FORTRAN_ENV , ONLY : REAL32
    IMPLICIT NONE
    REAL(KIND=REAL32), INTENT(IN) :: VAL1
    REAL(KIND=REAL32), INTENT(IN) :: VAL2
    REAL(KIND=REAL32) :: VAL3
  END FUNCTION ADD
  FUNCTION TRIPLE_ADD(VAL1, VAL2) RESULT(VAL3)
    USE ISO_FORTRAN_ENV , ONLY : REAL32
    IMPLICIT NONE
    REAL(KIND=REAL32), INTENT(IN) :: VAL1
    REAL(KIND=REAL32), INTENT(IN) :: VAL2
    REAL(KIND=REAL32) :: VAL3
  END FUNCTION TRIPLE_ADD

----------------------------------------------------------------------

Making symlink from '__init__.py' to 'test2_python_wrapper.py'

Moving from:
  /tmp/tmp2t6pmdpk
to
  /home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test2

Finished making module 'test2'.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Running system command with arguments
   gfortran -fPIC -shared -O3 -o test2.so test2.f90 test2_c_wrapper.f90
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Return type mismatch of functionaddat (1) (UNKNOWN/REAL(4))
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Functionaddat (1) has no IMPLICIT type
test2.f90:26:11:

   26 |  val3 = add(val1,val2)*3.0
      |           1
Error: Reference to impure functionaddat (1) within a PURE procedure
Traceback (most recent call last):

  File "/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test2/__init__.py", line 28, in <module>
    clib = ctypes.CDLL(_path_to_lib)

  File "/home/johannes/anaconda3/lib/python3.8/ctypes/__init__.py", line 381, in __init__
    self._handle = _dlopen(self._name, mode)

OSError: /home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test2/test2.so: cannot open shared object file: No such file or directory


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/python_test_f90.py", line 11, in <module>
    code = fmodpy.fimport("test2.f90",verbose = True)

  File "/home/johannes/anaconda3/lib/python3.8/site-packages/fmodpy/fmodpy.py", line 240, in fimport
    module = importlib.import_module(name)

  File "/home/johannes/anaconda3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import

  File "<frozen importlib._bootstrap>", line 991, in _find_and_load

  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 783, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "/home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test2/__init__.py", line 42, in <module>
    clib = ctypes.CDLL(_path_to_lib)

  File "/home/johannes/anaconda3/lib/python3.8/ctypes/__init__.py", line 381, in __init__
    self._handle = _dlopen(self._name, mode)

OSError: /home/johannes/Dokumente/Masterarbeit/Fortran/TMM/tmm_test/test2/test2.so: cannot open shared object file: No such file or directory

I am not really sure why I am getting any of those errors when compiling the fortran code. It seems to me that both functions are pure and i state the type for all variables and only use real32....

It works well if I use only the function add(val1,val2).
Do I have to structure programs differently? Should I define functions in a fortran module?

Question about wrong type of return value(in python) for allocatable real64 arrays(fortran).

Hi.
when i write fortran file like this

subroutine some(array_real64)
    ! use iso_c_binding
    implicit none
    INTEGER :: i
    REAL(kind=8), DIMENSION(:), ALLOCATABLE, INTENT(OUT) :: array_real64
    ALLOCATE (array_real64(4))
    do i = 1, size(array_real64)
        array_real64(i) = 3.14*i
    end do
end subroutine some

and python file like this:

import os
dir_name = os.path.dirname(os.path.abspath(__file__))
test_name = os.path.basename(dir_name)
fort_file = os.path.join(dir_name, "real64.f90")
build_dir = os.path.join(dir_name, "fmodpy_real64")
import fmodpy
import numpy as np
RWD = fmodpy.fimport(fort_file, build_dir=build_dir,
                      output_dir=dir_name, rebuild=True)
# input = np.zeros((4),dtype=np.float64,order='F')
out = RWD.some()
print(out)
print(out.dtype)

the results is wrong and its type is float32
image

If I remove the ALLOCATABLE attribute from the real64 array.

REAL(kind=8), DIMENSION(:), INTENT(OUT) :: array_real64

and python like this

input = np.zeros((4),dtype=np.float64,order='F')
out = RWD.some(input)

The result is correct
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.