Coder Social home page Coder Social logo

fortran-fans / forlab Goto Github PK

View Code? Open in Web Editor NEW
32.0 2.0 4.0 6.42 MB

Forlab is a Fortran module that provides a lot of functions for scientific computing mostly inspired by Matlab and Python's package NumPy.

Home Page: https://fortran-fans.github.io/forlab/

License: Other

Fortran 99.84% Makefile 0.10% Shell 0.06%
fpm functions fortran numerical

forlab's Introduction

FORLAB

Actions Status

FORLAB is a Fortran module that provides some functions for scientific computing. It's more like a small toolbox.
FORLAB uses stdlib as an upstream package. FORLAB hopes to be a small scaffolding tool. Compared with stdlib, FORLAB is less formal.

Version: 1.0.2
Author: FORLAB Contributors
Web site: https://github.com/fortran-fans/forlab
API-Doc Web site: https://zoziha.github.io/forlab-API-doc/
Copyright: This document has been placed in the public domain.
License: FORLAB is released under the MIT License.

Getting Started (中文文档)

Get the code

git clone https://github.com/fortran-fans/forlab.git
cd forlab

Supported Compilers

The following combinations are tested on the default branch of forlab:

Name Vesrion Platform Architecture
GCC Fortran(MSYS2) 10 Windows 10 x86_64
GCC Fortran 10 Ubuntu x86_64
GCC Fortran 10 MacOS x86_64

Build with fortran-lang/fpm

Fortran Package Manager (fpm) is a great package manager and build system for Fortran. You can build using provided fpm.toml:

fpm build
fpm test --list
fpm test <test_name, see `fpm.toml` or list>

To use forlab within your fpm project, add the following to fpm.toml file:

[dependencies] # or [dev-dependencies] for tests.
forlab = { git="https://github.com/fortran-fans/forlab.git", branch="forlab-fpm" }

API-Doc

ford API-doc-FORD-file.md  # todo

see forlab-API-doc.

Some examples are prepared in the ./example folder, and you can use fpm to run them.

fpm run --example --list
fpm run --example <demo_name, see `fpm.toml` or list>

More informations

Links

  1. keurfonluu/Forlab
    Forlab is mainly developed by Keurfon Luu originally.
  2. stdlib
    Fortran standard library.
  3. Fortran Generics

Fypp

The original intention of developing the multi-precision library(forlab) is to facilitate the user to switch the program accuracy requirements in a timely manner, which is challenging. We use fypp to build a multi-precision forlab. I have to say that fypp has helped us a lot. I learned that the use of code to generate code is called meta-programming. I also think that metaprogramming has great potential, especially for some low-level polymorphic functions and improving the dynamics of statically compiled languages, which is very helpful.
I hope that fypp will get better and better, and that fortran will natively support meta-programming technology in the future.

The problems we encountered

  1. The adaptability of fortran metaprogramming ability is not strong;
  2. Modular development module and setting submodule should best be combined effectively to improve development efficiency.
  3. We don't want forlab to increase its volume unlimitedly. We hope that it can be used in areas where it can achieve value, such as rapid development of fortran automation applets. So we will keep the forlab lightweight, and update and repair it from time to time.
  4. Fpm currently has some problems and pain points when compiling the program (But we are very optimistic about the potential of fpm):
    • Slow compilation speed. (Improvements in this PR: optimize file listing)
    • Cannot manage and distribute fpm packages well now.
  5. Fortran Generics: Due to the lack of more complete generics, certain functions such as multiple precision and multiple array dimensions cannot be implemented now.

forlab's People

Contributors

euler-37 avatar keurfonluu avatar st-maxwell avatar zoziha 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

Watchers

 avatar  avatar

forlab's Issues

Return value polymorphic function

For example, x = zeros(dim1, dim2, ...) function.

flag

We add a flag to the function, this flag is consistent with the precision of the return value.

x = zeros(dim1, dim2, ..., flag)

ref from: https://fortran-lang.discourse.group/t/fortran-function-return-value-polymorphism/1350/5

But we found that this method is actually not good for the user experience. We want to find other ways.

function name

We can abandon the idea of a polymorphic function interface and set up the following functions:

szeros / dzeros / qzeros
default: zeros = szeros

real(integer, kind)

Maybe we can imitate the standard function of Fortran, the real function.
ref from:

  1. {"real", {{"a", AnyNumeric, Rank::elementalOrBOZ}, DefaultingKIND}
  2. https://github.com/llvm/llvm-project/blob/d8805574c183484f055552855fa82d2e8932415e/flang/runtime/numeric.h#L22
  3. https://github.com/llvm/llvm-project/blob/d8805574c183484f055552855fa82d2e8932415e/flang/runtime/numeric.cpp
  4. https://github.com/llvm/llvm-project/blob/d480f968ad8b56d3ee4a6b6df5532d485b0ad01e/flang/runtime/type-code.cpp
real(integer, kind)

Final question

Should we implement the second method first. It will be more difficult to implement the third method? May need to use c/c++, so we need to ensure that fpm can build such code.
fortran-lang/fpm#353
https://github.com/fortran-lang/fpm/tree/master/example_packages/with_c

Or do we have a better way?

Unused variable i in a few places

fpm build gives

.\.\src\forlab_stats_var.f90:162:27:

  162 |         integer :: opt_w, i
      |                           1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]
.\.\src\forlab_stats_var.f90:141:27:

  141 |         integer :: opt_w, i
      |                           1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]
.\.\src\forlab_stats_var.f90:120:27:

  120 |         integer :: opt_w, i
      |                           1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]

How to deal with more and more `fypp` files

Every time we compile with make tool, our fypp files generate all the f90 files.

With the increase of fypp files, how do we make the make tool only update the fypp files that we modify?

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.