All Projects → schaefed → mo_netcdf

schaefed / mo_netcdf

Licence: other
Modern fortran netcdf wrapper

Programming Languages

fortran
972 projects
Makefile
30231 projects

Projects that are alternatives of or similar to mo netcdf

netcdf4
NodeJS addon to read and write NetCDF4 files
Stars: ✭ 35 (+133.33%)
Mutual labels:  netcdf, 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 (+33.33%)
Mutual labels:  netcdf, netcdf4
pyscissor
✂️ calculate polygon mask for netCDF/GRIB/raster
Stars: ✭ 14 (-6.67%)
Mutual labels:  netcdf
cftime
Time-handling functionality from netcdf4-python.
Stars: ✭ 53 (+253.33%)
Mutual labels:  netcdf
flowtorch
flowTorch - a Python library for analysis and reduced-order modeling of fluid flows
Stars: ✭ 47 (+213.33%)
Mutual labels:  netcdf
NetCDF.jl
NetCDF support for the julia programming language
Stars: ✭ 102 (+580%)
Mutual labels:  netcdf
aospy
Python package for automated analysis and management of gridded climate data
Stars: ✭ 80 (+433.33%)
Mutual labels:  netcdf
fiona
Fortran IO Netcdf Assembly
Stars: ✭ 17 (+13.33%)
Mutual labels:  netcdf
netcdf-java
The Unidata netcdf-java library
Stars: ✭ 84 (+460%)
Mutual labels:  netcdf
ncdfgeom
NetCDF-CF Geometry and Timeseries Tools for R: https://code.usgs.gov/water/ncdfgeom
Stars: ✭ 13 (-13.33%)
Mutual labels:  netcdf
goes2go
Download and process GOES-16 and GOES-17 data from NOAA's archive on AWS using Python.
Stars: ✭ 77 (+413.33%)
Mutual labels:  netcdf
psyplot
Python package for interactive data visualization
Stars: ✭ 64 (+326.67%)
Mutual labels:  netcdf
clisops
Climate Simulation Operations
Stars: ✭ 17 (+13.33%)
Mutual labels:  netcdf4
Ocean-Data-Map-Project
The Ocean Navigator is an online tool that is used to help visualise scientific research data. a users guide is available at https://dfo-ocean-navigator.github.io/Ocean-Navigator-Manual/ and the tool is live at
Stars: ✭ 41 (+173.33%)
Mutual labels:  netcdf
wxee
A Python interface between Earth Engine and xarray for processing time series data
Stars: ✭ 113 (+653.33%)
Mutual labels:  netcdf
era5 in gee
Functions and Python scripts to ingest ERA5 data into Google Earth Engine
Stars: ✭ 63 (+320%)
Mutual labels:  netcdf
ncdump-json
Modified ncdump to output data in json format
Stars: ✭ 72 (+380%)
Mutual labels:  netcdf
mooda
Module for Ocean Observatory Data Analysis - Python package
Stars: ✭ 17 (+13.33%)
Mutual labels:  netcdf
spacegrids
Analyze spatial Netcdf data: "Numpy on grids" (Python module)
Stars: ✭ 14 (-6.67%)
Mutual labels:  netcdf
cfdm
A Python reference implementation of the CF data model
Stars: ✭ 24 (+60%)
Mutual labels:  netcdf

mo_netcdf

General

A object-oriented wrapper around the NetCDF Fortran 90 interface.

Requirements

  • NetCDF fortran 90 interface
  • A Fortran2003 compatible compiler

Compiler support

The module is tested to work with the following compilers:

  • GNU gfortran 4.8/5.4
  • Intel ifort 15.0.1/17.0.2
  • NAG nagfor 6.0

Older intel compilers

The support of ifort/13.1 was dropped because of this bug.

Usage

The below examples can be found in the examples folder.

Write a netcdf file:

use mo_netcdf, only: NcDataset, NcDimension, NcVariable, NcGroup

type(NcDataset)   :: nc
type(NcDimension) :: dim1, dim2, dim3
type(NcVariable)  :: var, scalar
type(NcGroup)     :: grp

! some data
integer, parameter :: nx=10, ny=20, ntime=8
integer            :: data(nx, ny, ntime), i

data = 42

! open a dataset in write mode
! args:
!     filename
!     mode ("w": write, "r": read-only, "a": read-write)
nc = NcDataset("test.nc", "w") 

! create a group
! args:
!     group name
!     group variable
grp = nc%setGroup("group")

! create dimensions
! args:
!     dimension name 
!     dimension length (optional: skip for an unlimited dimension)
dim1 = grp%setDimension("time")
dim2 = grp%setDimension("y", ny)
dim3 = grp%setDimension("x", nx)

! set a variable
! args:
!     variable name
!     data type (currently available: "i8", "i16", "i32", "f32", "f64")
!     dimensions array (optional: skip for a scalar)
var = grp%setVariable("data", "i32", (/dim3, dim2, dim1/))
scalar = grp%setVariable("scalar", "i32")

! define a fill value
! args:
!     one of the supported datatypes
call var%setFillValue(-9999)

! add variable attributes
! args:
!    name
!    any of the supported datatypes
call var%setAttribute("attr1", "42")
call var%setAttribute("attr2", 42)
call var%setAttribute("attr3", 42.0)

! write data
! args:
!     data: scalar/array of any of the supported datatypes
!     start  (optional): array of indices where the the first/only data value will be written
!     count  (optional): array of integers specifying the number of indices along selected along each dimension
!     stride (optional): array of integers specifying the sampling interval of each dimension 
!     map    (optional): see nf90_put_var 
! write the entire variable
call var%setData(data)
! write one value at position (5,5,1) (indexing: x, y, time)
call var%setData(21, start=(/5,5,1/))
! write on 2D array into the 3D data array at position (1,1,4)
call var%setData(data(:,:,1)/2, start=(/1,1,4/))

! dynamically append some data along the time dimension
do i = ntime+2, ntime+12
    call var%setData(data(:,:,1)+i,start=(/1,1,i/))
end do

! add a group attribute, attributes can be set to any of the data structures
! args:
!    name
!    any of the supported datatypes
call grp%setAttribute("auxiliar author", "Ricardo Torres")
! add a global attribute
! args:
!    name
!    any of the supported datatypes
call nc%setAttribute("author", "Alfred Mustermann")

! close the dataset
call nc%close()

Read data from file:

use mo_netcdf, only: NcDataset, NcDimension, NcVariable, NcGroup

type(NcDataset)   :: nc
type(NcVariable)  :: var
type(NcGroup)     :: grp

integer, allocatable :: data(:,:,:)
integer              :: att_val
character(len=80)    :: author1, author2

! open a dataset in read-only mode
nc = NcDataset("test.nc", "r")

! open the group where the data is
grp = nc%getGroup("group")

! access a variable
! args:
!     variable name
var = grp%getVariable("data")

! read data
! args:
!     data: allocatable array of any of the supported datatypes
!     start  (optional): array of indices of the first value to be read
!     count  (optional): array of integers specifying the number of elements to read along each dimension
!     stride (optional): array of integers specifying the sampling interval of each dimension 
!     map    (optional): see nf90_put_var 
! read the entire variable
call var%getData(data)

! read all but the first 10 time steps
call var%getData(data, start=(/1,1,10/))

! read the first 5 columns and rows of the first 10 timesteps
call var%getData(data, cnt=(/5,5,10/))

! read every second timestep starting from the 3
call var%getData(data, start=(/1,1,3/), stride=(/1,1,2/))

! read attributes
call var%getAttribute('attr2', att_val)
call grp%getAttribute('auxiliar author', author2)
call nc %getAttribute('author', author1)

call nc%close()

Restrictions

The current implementation provides a subset of the NetCDF Fortran 90 interface as described in the User's Guide. Some of the current restrictions:

  • Dataset fill mode settings (nf90_set_fill)
  • Full group names (nf90_inq_grpname_full)
  • Variables are limited to 5 dimensions
  • Accessing variable settings (e.g. nf90_inq_var_chunking, nf90_inq_var_fill, nf90_inq_var_deflate)
  • User defined data types
  • Attributes deletion (nf90_del_att)
  • Attributes of array types
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].