All Projects → geospace-code → nc4fortran

geospace-code / nc4fortran

Licence: MIT license
Object-oriented Fortran NetCDF4 interface

Programming Languages

CMake
9771 projects
fortran
972 projects
C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to nc4fortran

mo netcdf
Modern fortran netcdf wrapper
Stars: ✭ 15 (-51.61%)
Mutual labels:  netcdf4
netcdf4
NodeJS addon to read and write NetCDF4 files
Stars: ✭ 35 (+12.9%)
Mutual labels:  netcdf4
woss-ns3
WOSS is a multi-threaded C++ framework that permits the integration of any existing underwater channel simulator that expects environmental data as input and provides as output a channel realization. Currently, WOSS integrates the Bellhop ray-tracing program. Thanks to its automation the user only has to specify the location in the world and the…
Stars: ✭ 20 (-35.48%)
Mutual labels:  netcdf4
clisops
Climate Simulation Operations
Stars: ✭ 17 (-45.16%)
Mutual labels:  netcdf4
h5fortran-mpi
HDF5-MPI parallel Fortran object-oriented interface
Stars: ✭ 15 (-51.61%)
Mutual labels:  object-oriented-fortran

Object-oriented Fortran NetCDF4 interface

DOI ci ci_windows ci_fpm

Simple, robust, thin, object-oriented NetCDF4 polymorphic read/write interface. For HDF5 see h5fortran. Designed for easy use as a CMake "ExternalProject" using static or shared linking. Uses Fortran 2008 submodule for clean template structure. nc4fortran abstracts away the messy parts of NetCDF4 so that you can read/write various types/ranks of data with a single command. In distinction from other high-level NetCDF4 interfaces, nc4fortran works to deduplicate code, using polymorphism wherever feasible, with an extensive test suite.

Polymorphic API with read/write for types int32, int64, real32, real64 with rank:

  • scalar (0-D)
  • 1-D .. 7-D

Also:

  • read/write character variables.
  • read/write character, int, float, double attributes

Datatypes are coerced as per standard Fortran rules. For example, reading a float NetCDF4 variable into an integer Fortran variable: 42.3 => 42

Tested on systems with NetCDF4 including:

  • MacOS
  • Linux
  • Windows

See API for usage.

Build

Requirements:

  • modern Fortran compiler: examples: GCC ≥ 7 or Intel oneAPI ≥ 2021
  • NetCDF4 Fortran library
    • Mac / Homebrew: brew install gcc netcdf
    • Linux: apt install gfortran libnetcdf-dev libnetcdff-dev
    • Windows Subsystem for Linux: apt install gfortran libnetcdf-dev libnetcdff-dev
    • Windows Cygwin libnetcdf-fortran-devel

Note that some precompiled NetCDF4 libraries include C / C++ without Fortran.

Build this NetCDF OO Fortran interface. The library libnc4fortran.a is built, link it into your program as usual.

CMake

cmake -B build
cmake --build build

# optional
ctest --test-dir build

To specify a particular NetCDF library, use

cmake -DNetCDF_ROOT=/path/to/netcdff -B build

or set environment variable NetCDF_ROOT=/path/to/netcdff

To use nc4fortran as a CMake ExternalProject do like:

include(FetchContent)

FetchContent_Declare(nc4fortran_proj
GIT_REPOSITORY https://github.com/geospace-code/nc4fortran.git
)

FetchContent_MakeAvailable(nc4fortran_proj)

# ------------------------------------------------------
# whatever your program is
add_executable(myProj main.f90)
target_link_libraries(myProj nc4fortran::nc4fortran)

Fortran Package Manager (fpm)

fpm build
fpm test
fpm install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].