source: LMDZ6/trunk/tools/netcdf95/docs/installation.md @ 5054

Last change on this file since 5054 was 4918, checked in by Laurent Fairhead, 7 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.8 KB
Line 
1# Installation
2
3## Dependencies
4
5- [CMake](https://cmake.org/download) (version ≥ 3.16)[^1].
6
7- The [NetCDF-C
8  library](https://docs.unidata.ucar.edu/nug/current/getting_and_building_netcdf.html)
9  (version ≥ 4.6).
10
11- The [NetCDF-Fortran
12  library](https://www.unidata.ucar.edu/downloads/netcdf/index.jsp)
13  (version ≥ 4.5).
14
15- The Fortran compiler that was used to compile your installed
16  NetCDF-Fortran library.
17- Git (optional, the easiest way to download NetCDF95).
18
19Under Ubuntu ≥ 20.04 or Linux Mint ≥ 20, you can install all these
20dependencies with the following command:
21
22        sudo apt install libnetcdff-dev gfortran cmake git
23
24
25## Instructions
26
271. Get [NetCDF95 from Github](https://github.com/lguez/NetCDF95). As
28   the Git repository contains a submodule, the easiest way is to
29   type:
30
31                git clone --recurse-submodules https://github.com/lguez/NetCDF95.git
32
33        If you prefer to download a ZIP file then you will also have to
34    download the [cmake subdirectory](https://github.com/lguez/cmake).
35
362.  Create a build subdirectory in the NetCDF95 directory you have
37    just downloaded:
38
39        cd NetCDF95
40        mkdir build
41        cd build
42
433.  Decide in which directory you want to install NetCDF95 after
44    compilation and type the command below with your choice after
45    `-DCMAKE_INSTALL_PREFIX=` (enter an absolute path). For example:
46
47        cmake .. -DCMAKE_INSTALL_PREFIX=~/.local
48
494.  Type:
50
51        make install
52
53You do not need to keep the downloaded directory NetCDF95 (nor the
54build directory) after installation.
55
56## Advanced instructions
57
58Most users should not need these advanded instructions.
59
60- You can choose any name and any location for the build
61  directory. You have to refer to the source directory when you run
62  cmake from the build directory:
63
64                mkdir /wherever/any/name
65                cd /wherever/any/name
66                cmake /where/I/downloaded/NetCDF95 -DCMAKE_INSTALL_PREFIX=~/.local
67
68- NetCDF95 assumes that the Fortran default character kind is the same
69  as the C character kind (the official NetCDF-Fortran interface makes
70  the same assumption). You can test this by running the command
71  `ctest` in the build directory. If this test fails then the
72  procedures `nf95_inq_grpname`, `nf95_inq_grpname_full` and
73  `nf95_inq_grp_full_ncid` are not reliable.
74
75- You do not have to install. You can just use the compiled library in
76  the build directory. So you do not have to specify the option
77  `-DCMAKE_INSTALL_PREFIX=` and you can just type `make` instead of
78  `make install`.
79
80- You can compile with debugging options by adding the option
81  `-DCMAKE_BUILD_TYPE=Debug` to the command cmake.
82
83## Troubleshooting
84
85- If your installation of NetCDF or NetCDF-Fortran is in a
86  non-standard location, and CMake does not find it, then re-run cmake
87  setting the variable `CMAKE_PREFIX_PATH` to the directory containing
88  it. CMake will then search `${CMAKE_PREFIX_PATH}/lib`,
89  `${CMAKE_PREFIX_PATH}/include`, etc. For example, if you want to use
90  the parallel-enabled version of NetCDF-C on Ubuntu or Linux Mint:
91
92                cmake . -DCMAKE_PREFIX_PATH:PATH=/usr/lib/x86_64-linux-gnu/netcdf/mpi
93
94- If you have several Fortran or C compilers on your machine, it is
95  possible that CMake does not choose the ones you want. Note that when
96  you run cmake, it prints lines telling which compilers it is going
97  to use. For example :
98
99                -- The Fortran compiler identification is GNU 11.3.0
100                -- The C compiler identification is GNU 11.3.0
101
102        So if you want other compilers, remove everything in the build
103        directory and run cmake again setting the variables FC and CC to the
104        compilers you want. For example:
105
106                rm -r * # in the build directory!
107                FC=ifort CC=icc cmake .. -DCMAKE_INSTALL_PREFIX=~/.local
108
109[^1]: On Mac OS, after downloading the application from the CMake web
110    site, run it, then click on "How to Install For Command Line Use"
111    in the Tools menu.
Note: See TracBrowser for help on using the repository browser.