source: LMDZ6/trunk/tools/netcdf95/docs/index.md @ 5450

Last change on this file since 5450 was 4918, checked in by Laurent Fairhead, 8 months ago

Reintegrated NetCDF95 in LMDZ so that it is compiled and made available by the makelmdz_fcm script.
The makelmdz_fcm creates the libnetcdf95 library and copies it in the tools/netcdf/lib directory, copying
the mod files in the tools/netcdf/include library.

File size: 3.3 KB
Line 
1# Introduction
2
3## What is it?
4
5NetCDF95 is an alternative Fortran interface to the
6[NetCDF](http://www.unidata.ucar.edu/software/netcdf/index.html)
7library. The official Fortran interface is the [Fortran 90 NetCDF
8interface](https://www.unidata.ucar.edu/software/netcdf/docs-fortran/f90_The-NetCDF-Fortran-90-Interface-Guide.html).
9
10The name NetCDF95 was at first a reference to the Fortran 95 standard
11but NetCDF95 now uses Fortran 2003 features.
12
13Author: [Lionel GUEZ](https://www.lmd.jussieu.fr/~lguez)
14
15## Why an alternative interface?
16
17Compared to the the [Fortran 90 NetCDF
18interface](https://www.unidata.ucar.edu/software/netcdf/docs-fortran/f90_The-NetCDF-Fortran-90-Interface-Guide.html),
19NetCDF95 is meant to be friendlier and more secure. Notably:
20
21- NetCDF95 frees you of the cumbersome task of handling the error
22  status.  NetCDF95 procedures behave like the Fortran input/output
23  statements. That is, the error status is an optional output
24  argument. Consider, for example, the Fortran formatted `read`
25  statement:
26
27                read([unit=]u, [fmt=]fmt [,iostat=ios] [, err=error-label] &
28                   [,end=end-label]) [list]
29
30        If the `err`, `end` and `iostat` keywords are not provided, and
31        there is a problem in the execution of the `read` statement, then
32        execution of the program stops (with an informative error message
33        from the compiler). Similarly, NetCDF95 procedures have an
34        optional argument for error status. If the optional argument is
35        absent and there is an error, then the NetCDF95 procedure produces
36        an error message and stops the program. (The official Fortran 90
37        interface looks like it has been made to mimic the C interface,
38        and this is not optimal in Fortran.)
39
40- NetCDF95 frees you of assumptions on the size of arrays and the size
41  of character strings when you call several inquiry procedures. (It
42  does so by making use of allocatable arguments, a Fortran 2003
43  feature.) See
44  [`nf95_inquire_variable`](Detailed_content/variables.md),
45  [`nf95_inq_grpname`](Detailed_content/groups.md),
46  [`nf95_inq_grps`](Detailed_content/groups.md),
47  [`nf95_inq_grpname_full`](Detailed_content/groups.md).
48 
49- NetCDF95 offers procedures that have no counterpart in the official
50  interface. These combine several calls to other NetCDF95 procedures
51  for common higher-level tasks. See
52  [`nf95_gw_var`](Detailed_content/variables.md),
53  [`nf95_find_coord`](Detailed_content/datasets.md),
54  [`nf95_create_single`](Detailed_content/datasets.md),
55  [`nf95_get_missing`](Detailed_content/attributes.md).
56 
57- NetCDF95 replaces functions by subroutines. Procedures of the
58official Fortran 90 interface are all functions, and they are all with
59side effects. First, they have `intent(out)` arguments. Furthermore,
60there is obviously data transfer inside the procedures. Any data
61transfer inside a function is considered as a side effect. In this
62respect, the Fortran 90 interface mimics the C interface. But Fortran
63has a different programming style than C and frowns upon side-effects
64in functions. See for example Metcalf and Reid (Fortran 90/95
65Explained, 1999, §§ 5.10 and 6.10).
66
67- There are other improvements such as securing the call to
68[`nf95_get_var`](Detailed_content/variables.md) by checking the
69arguments start and `count_nc`, and renaming badly chosen argument
70names len and count to nclen and `count_nc`.
71
72 
Note: See TracBrowser for help on using the repository browser.