[4918] | 1 | # Usage |
---|
| 2 | |
---|
| 3 | ## In the source code of the consumer program |
---|
| 4 | |
---|
| 5 | The name of the module that you must use in your Fortran program is |
---|
| 6 | `netcdf95`. For example: |
---|
| 7 | |
---|
| 8 | ``` |
---|
| 9 | use 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 | |
---|
| 15 | If you build your program using NetCDF95 with CMake, then download |
---|
| 16 | both |
---|
| 17 | [`FindNetCDF_Fortran.cmake`](https://github.com/lguez/cmake/blob/master/FindNetCDF_Fortran.cmake) |
---|
| 18 | and |
---|
| 19 | [`FindnetCDF.cmake`](https://github.com/lguez/cmake/blob/master/FindnetCDF.cmake) |
---|
| 20 | into the directory of your consumer program and add the following |
---|
| 21 | lines to the file `CMakeLists.txt` for your program: |
---|
| 22 | |
---|
| 23 | ``` |
---|
| 24 | find_package(NetCDF_Fortran REQUIRED) |
---|
| 25 | find_package(NetCDF95 CONFIG REQUIRED) |
---|
| 26 | target_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 | |
---|
| 34 | If you do not build the consumer program with CMake, take into account |
---|
| 35 | that 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 |
---|
| 38 | NetCDF interface, so you must keep the options you would use for |
---|
| 39 | direct access to the Fortran 90 NetCDF interface. |
---|
| 40 | |
---|
| 41 | For most compilers, the options you will need to add are: |
---|
| 42 | |
---|
| 43 | -I$netcdf95_inc_dir |
---|
| 44 | |
---|
| 45 | at compile time and: |
---|
| 46 | |
---|
| 47 | -L$netcdf95_lib_dir -L$netcdf90_lib_dir -lnetcdf95 -lnetcdff -lnetcdf |
---|
| 48 | |
---|
| 49 | at link time, where `$netcdf95_inc_dir` is the directory where you put |
---|
| 50 | `.mod` files produced by compilation of NetCDF95, `$netcdf95_lib_dir` |
---|
| 51 | is the directory where you put `libnetcdf95.a` and `$netcdf90_lib_dir` |
---|
| 52 | is the directory where the Fortran 90 NetCDF interface is |
---|
| 53 | installed. |
---|