NEP 2.7.0
NetCDF Extension Pack
Loading...
Searching...
No Matches
Functions/Subroutines
f_simple_2D.f90 File Reference

Basic example: 2D array creation and reading in NetCDF (Fortran) More...

Functions/Subroutines

program f_simple_2d
 
subroutine handle_err (status)
 

Detailed Description

Basic example: 2D array creation and reading in NetCDF (Fortran)

This is the Fortran equivalent of simple_2D.c, demonstrating the fundamental workflow for working with NetCDF files using the Fortran 90 NetCDF API. The program creates a 2D integer array, writes it to a NetCDF file with a global attribute ("title") and a variable attribute ("units"), then reopens the file to verify metadata, attributes, and data correctness using nf90_inquire(), nf90_inquire_dimension(), and nf90_inquire_variable().

Learning Objectives:

Key Concepts:

Fortran vs C Differences:

Prerequisites:

Related Examples:

Compilation:

gfortran -o f_simple_2d f_simple_2d.f90 -lnetcdff -lnetcdf
program f_simple_2d
Definition f_simple_2D.f90:83

Usage:

Expected Output: Creates f_simple_2D.nc containing:

Note
Companion code for "The NetCDF Developer's Handbook: The Authoritative Guide to Writing High-Performance Programs for Scientific Data Management, Second Edition" (https://www.amazon.com/dp/B0H7Q1Z75L)
Author
Edward Hartnett, Intelligent Data Design, Inc.
Date
May 1, 2026

Function/Subroutine Documentation

◆ f_simple_2d()

program f_simple_2d

◆ handle_err()

subroutine f_simple_2d::handle_err ( integer, intent(in)  status)