Recipe: Fortran program to read data from downloaded file

From GEOS-5
Revision as of 09:58, 28 October 2014 by Pchakrab (talk | contribs) (Solution)
Jump to navigation Jump to search

Problem

We want to read a downloaded data file using Fortran.

Solution

For the purpose of this example, we assume that we have already downloaded the file c1440_NR.inst01hr_3d_T_Cv.20060918_0900z.nc4 from the ftp server. For more information about file naming conventions, and how to download a file from the ftp server, please follow the links in the #See Also section.

Here we use the NetCDF-4 library to read the downloaded file. Since NetCDF-4 uses HDF-5 as the underlying data format, HDF-5 library can also be used directly.

First, we ensure that out NetCDF-4 library has been built with Fortran and HDF5 support. If both the queries

> nc-config --has-f90
> nc-config --has-hdf5

return "yes", we have a compatible NetCDF-4 library.

Below are two programs to read

  1. global temperature data
  2. temperature data over mainland US

from the downloaded file.

Read global temperature data

Discussions

See Also

  1. Recipe: File naming conventions
  2. Recipe: Retrieve (global) data from FTP server

No Warranty

Copyright