Examples of using f2py to get high-speed Fortran integrated with Python easily

Overview

f2py Examples

Actions Status

Simple examples of using f2py to get high-speed Fortran integrated with Python easily. These examples are also useful to troubleshoot problems with f2py.

Build

Fortran compiler is needed:

  • Mac: brew install gcc
  • Linux: apt install gfortran or yum install gfortran
  • Windows

Install

pip install -e .

This will compile the Fortran code (in .f and .f90 files). It creates a file pyprod.* where * depends on operating system and Python version:

  • Linux/Mac: .so
  • Windows: .pyd

Examples

.f2py_f2cmap required

A file .f2py_f2cmap as in this repository must be in the top-level (same as setup.py) of the project directory tree. If this file is missing, all "real" kinds map to float32, which is not in general what is wanted. A missing .f2py_f2cmap will lead float64 values to be completely incorrect.

The names in the .f2py_f2cmap must exactly match the Fortran variable names used for the real kind. If you use dp=>real64 in the Fortran code, then .f2py_f2cmap must map dp as well.

Fortran Intents

python f2py_demo.py

output:

x = 3
y = 2
x * y = 6.0
Your system did this in Python using Fortran-compiled library

Fortran comment syntax

Fortran 77 is officially full-line comments only. Inline comments are not allowed with f2py as a result in Fortran 77 files. Demonstrate this with:

f2py -m badcomment -c badcomment.f

Troubleshooting f2py

f2py normally Just Works on Linux, MacOS and Windows Subsystem for Linux. However, Windows itself can be more challenging due to inconsistencies in Microsoft Visual Studio.

See the Windows f2py installation guide and troubleshooting guide.

You might also like...
Wind Speed Prediction using LSTMs in PyTorch
Wind Speed Prediction using LSTMs in PyTorch

Implementation of Deep-Forecast using PyTorch Deep Forecast: Deep Learning-based Spatio-Temporal Forecasting Adapted from original implementation Setu

Vehicle speed detection with python

Vehicle-speed-detection In the project simulate the tracker.py first then simulate the SpeedDetector.py. Finally, a new window pops up and the output

A Neural Net Training Interface on TensorFlow, with focus on speed + flexibility
A Neural Net Training Interface on TensorFlow, with focus on speed + flexibility

Tensorpack is a neural network training interface based on TensorFlow. Features: It's Yet Another TF high-level API, with speed, and flexibility built

A Neural Net Training Interface on TensorFlow, with focus on speed + flexibility
A Neural Net Training Interface on TensorFlow, with focus on speed + flexibility

Tensorpack is a neural network training interface based on TensorFlow. Features: It's Yet Another TF high-level API, with speed, and flexibility built

Based on Yolo's low-power, ultra-lightweight universal target detection algorithm, the parameter is only 250k, and the speed of the smart phone mobile terminal can reach ~300fps+
Based on Yolo's low-power, ultra-lightweight universal target detection algorithm, the parameter is only 250k, and the speed of the smart phone mobile terminal can reach ~300fps+

Based on Yolo's low-power, ultra-lightweight universal target detection algorithm, the parameter is only 250k, and the speed of the smart phone mobile terminal can reach ~300fps+

The modify PyTorch version of Siam-trackers which are speed-up by TensorRT.

SiamTracker-with-TensorRT The modify PyTorch version of Siam-trackers which are speed-up by TensorRT or ONNX. [Updating...] Examples demonstrating how

This project aim to create multi-label classification annotation tool to boost annotation speed and make it more easier.
This project aim to create multi-label classification annotation tool to boost annotation speed and make it more easier.

This project aim to create multi-label classification annotation tool to boost annotation speed and make it more easier.

It is a simple library to speed up CLIP inference up to 3x (K80 GPU)

CLIP-ONNX It is a simple library to speed up CLIP inference up to 3x (K80 GPU) Usage Install clip-onnx module and requirements first. Use this trick !

Tgbox-bench - Simple TGBOX upload speed benchmark

TGBOX Benchmark This script will benchmark upload speed to TGBOX storage. Build

Comments
  • What does f2py_cmap mean?

    What does f2py_cmap mean?

    https://github.com/scivision/f2py-examples/blob/14329a37fb9c38c8281d05b404d559295dd2a1c7/badprec.f90#L1-L14

    It is not clear what do you mean by unless matching .f2py_cmap. What is .f2py_cmap?

    Thank you

    opened by ghost 1
Owner
Michael
Scientific computing enabling new frontiers in aerospace and geospace discovery. Language expertise includes Fortran, Python, Matlab, CMake.
Michael
E2EC: An End-to-End Contour-based Method for High-Quality High-Speed Instance Segmentation

E2EC: An End-to-End Contour-based Method for High-Quality High-Speed Instance Segmentation E2EC: An End-to-End Contour-based Method for High-Quality H

zhangtao 146 Dec 29, 2022
ColossalAI-Examples - Examples of training models with hybrid parallelism using ColossalAI

ColossalAI-Examples This repository contains examples of training models with Co

HPC-AI Tech 185 Jan 9, 2023
The deployment framework aims to provide a simple, lightweight, fast integrated, pipelined deployment framework that ensures reliability, high concurrency and scalability of services.

savior是一个能够进行快速集成算法模块并支持高性能部署的轻量开发框架。能够帮助将团队进行快速想法验证(PoC),避免重复的去github上找模型然后复现模型;能够帮助团队将功能进行流程拆解,很方便的提高分布式执行效率;能够有效减少代码冗余,减少不必要负担。

Tao Luo 125 Dec 22, 2022
Learning High-Speed Flight in the Wild

Learning High-Speed Flight in the Wild This repo contains the code associated to the paper Learning Agile Flight in the Wild. For more information, pl

Robotics and Perception Group 391 Dec 29, 2022
Official PyTorch implementation of "AASIST: Audio Anti-Spoofing using Integrated Spectro-Temporal Graph Attention Networks"

AASIST This repository provides the overall framework for training and evaluating audio anti-spoofing systems proposed in 'AASIST: Audio Anti-Spoofing

Clova AI Research 56 Jan 2, 2023
ivadomed is an integrated framework for medical image analysis with deep learning.

Repository on the collaborative IVADO medical imaging project between the Mila and NeuroPoly labs.

null 144 Dec 19, 2022
Discretized Integrated Gradients for Explaining Language Models (EMNLP 2021)

Discretized Integrated Gradients for Explaining Language Models (EMNLP 2021) Overview of paths used in DIG and IG. w is the word being attributed. The

INK Lab @ USC 17 Oct 27, 2022
A lane detection integrated Real-time Instance Segmentation based on YOLACT (You Only Look At CoefficienTs)

Real-time Instance Segmentation and Lane Detection This is a lane detection integrated Real-time Instance Segmentation based on YOLACT (You Only Look

Jin 4 Dec 30, 2022
PyDeepFakeDet is an integrated and scalable tool for Deepfake detection.

PyDeepFakeDet An integrated and scalable library for Deepfake detection research. Introduction PyDeepFakeDet is an integrated and scalable Deepfake de

Junke, Wang 49 Dec 11, 2022