Coder Social home page Coder Social logo

fortran2018-examples's Introduction

Fortran 2018 Examples

cmake oneapi-linux fpm

Standalone examples of Fortran 2018 and 2023 standard features. Popular, free-to-use Fortran compilers (GCC, Intel oneAPI, NVIDIA, Cray, IBM OpenXL, AOCC, Flang) and paid compilers such as NAG support all or many Fortran 2008 and 2018 standards.

Some standard Fortran features are so distinctive that we've put examples in separate repos:

The examples are built with CMake:

cmake --workflow --preset default

or to do each step manually:

cmake -B build
cmake --build build
ctest --test-dir build -V

Programs

The standalone examples are organized under test/ directory, including:

  • array: Array math in modern CMake and Fortran
  • Git traceability
  • namelist: Fortran 90 / 2003 Namelist parsing -- native text config files for Fortran
  • io: modern Fortran File I/O including resolving absolute path
  • real: Numerous examples dealing with practical features of real floating point numbers, including sentinel NaN and polymorphism.
  • character: String handling is easy and performant in modern Fortran.
  • standard: advanced features that can be done with Fortran standard coding
  • submodule: Fortran 2008 and CMake โ‰ฅ 3.12 enable even better large program architecture with submodule
  • system: system (hardware) functionality accessible via Fortran

Companion libraries and examples

Resources

Fortran standards

Books

Compiler User Guides

Surveys

fortran2018-examples's People

Contributors

scivision 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  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  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

fortran2018-examples's Issues

add fortran-tutorial tag

Could you add the tag fortran-tutorial to your project? If all relevant repos add this tag it will make such material easier to find on GitHub. Currently topics such javascript-tutorial and python-tutorial have many entries.

cmake errors

ian@ian-Aspire-One-753:$ cd fortran2018*
ian@ian-Aspire-One-753:
/fortran2018examples$ ls
abi_check CMakeCache.txt _deps namelist real
array CMakeFiles fortran2018-examples openmp standard
benchmarks compile git overloading submodule
block contiguous io pointer system
character debug maximum random
ian@ian-Aspire-One-753:~/fortran2018examples$ cmake fortran2018-examples
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/share/cmake-3.16
CMake Error: Error executing cmake::LoadCache(). Aborting.

ian@ian-Aspire-One-753:~/fortran2018examples$ sudo cmake fortran2018-examples
fatal: not a git repository (or any of the parent directories): .git
CMake Error at git/CMakeLists.txt:14 (string):
string sub-command SUBSTRING requires four arguments.

fatal: not a git repository (or any of the parent directories): .git
CMake Error at git/CMakeLists.txt:18 (string):
string sub-command SUBSTRING requires four arguments.

fatal: not a git repository (or any of the parent directories): .git
-- Fortran2018Examples git revision: git_branch: git_porcelain: .true.
-- CMake at least through 3.20.1 and Make have a bug with this Fortran Syntax. CMake + Ninja works OK.

  • Openmp, tests using OpenMP

-- Configuring incomplete, errors occurred!
See also "/home/ian/fortran2018examples/CMakeFiles/CMakeOutput.log".
See also "/home/ian/fortran2018examples/CMakeFiles/CMakeError.log".

fortran program svd_example ! Declare variables integer, parameter :: m = 4, n = 3, lda = 4, ldu = 4, ldvt = 3 integer :: i, j, info real(kind=8) :: a(lda,n), s(n), u(ldu,m), vt(ldvt,n), superb(min(m,n)-1) ! Initialize matrix A with some random values do j=1,n do i=1,m a(i,j) = dble((i-1) + (j-1)*m) end do end do ! Compute the SVD of matrix A using LAPACK routine DGESVD call dgesvd('A', 'A', m, n, a, lda, s, u, ldu, vt, ldvt, superb, info) ! Print the results: matrices U and Vt and vector S. write(*,'(a)') 'Matrix U:' do i=1,m write(*,'(4f8.2)') (u(i,j),j=1,min(m,n)) end do write(*,*) write(*,'(a)') 'Vector S:' write(*,'(3f8.2)') (s(j),j=1,min(m,n)) write(*,*) write(*,'(a)') 'Matrix Vt:' do i=1,min(m,n) write(*,'(3f8.2,a,f8.2)') (vt(i,j),' ',char(10),superb(i)) end do end program svd_example

libISO

I do use Ubuntu 18.10. I was only successful with cmake and 'make test' when I changed
/usr/lib/x86_64-linux-gnu/cmake/opencoarrays/OpenCoarraysTargets-none.cmake
at line 42 and 46 from 'libcISO_Fortran_binding.a' to 'libISO_Fortran_binding.so.2.1.0'
Thank you for the stuff!

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.