source: LMDZ6/trunk/tools/netcdf95/docs/usage.md @ 5410

Last change on this file since 5410 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: 1.8 KB
Line 
1# Usage
2
3## In the source code of the consumer program
4
5The name of the module that you must use in your Fortran program is
6`netcdf95`. For example:
7
8```
9use netcdf95, only: nf95_open, nf95_nowrite, nf95_inq_varid, nf95_gw_var, &
10        nf95_close
11```
12
13## Building the consumer program with CMake
14
15If you build your program using NetCDF95 with CMake, then download
16both
17[`FindNetCDF_Fortran.cmake`](https://github.com/lguez/cmake/blob/master/FindNetCDF_Fortran.cmake)
18and
19[`FindnetCDF.cmake`](https://github.com/lguez/cmake/blob/master/FindnetCDF.cmake)
20into the directory of your consumer program and add the following
21lines to the file `CMakeLists.txt` for your program:
22
23```
24find_package(NetCDF_Fortran REQUIRED)
25find_package(NetCDF95 CONFIG REQUIRED)
26target_link_libraries(my_program PRIVATE NetCDF95::netcdf95
27  NetCDF_Fortran::netcdff)
28```
29
30(replace `my_program` by the name of your target).
31
32## Building the consumer program without CMake
33
34If you do not build the consumer program with CMake, take into account
35that your program will require `netcdf95.mod` (and possibly other
36`.mod` files produced by compilation of NetCDF95) at compile time and
37`libnetcdf95.a` at link time. Note that NetCDF95 uses the Fortran 90
38NetCDF interface, so you must keep the options you would use for
39direct access to the Fortran 90 NetCDF interface.
40
41For most compilers, the options you will need to add are:
42
43    -I$netcdf95_inc_dir
44
45at compile time and:
46
47    -L$netcdf95_lib_dir -L$netcdf90_lib_dir -lnetcdf95 -lnetcdff -lnetcdf
48
49at link time, where `$netcdf95_inc_dir` is the directory where you put
50`.mod` files produced by compilation of NetCDF95, `$netcdf95_lib_dir`
51is the directory where you put `libnetcdf95.a` and `$netcdf90_lib_dir`
52is the directory where the Fortran 90 NetCDF interface is
53installed.
Note: See TracBrowser for help on using the repository browser.