# NETCDF-C installation with environmental modules

**URL:** <https://forum.cmascenter.org/t/netcdf-c-installation-with-environmental-modules/2325>\
**Category:** I/O API\
**Created:** [May 9, 2021, 11:01am UTC](https://forum.cmascenter.org/t/netcdf-c-installation-with-environmental-modules/2325 "2021-05-09T11:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nadia](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@Nadia](https://forum.cmascenter.org/u/Nadia)\
**Post date:** [May 9, 2021, 11:01am UTC](https://forum.cmascenter.org/t/netcdf-c-installation-with-environmental-modules/2325/1 "2021-05-09T11:01:52Z")

</div>

I try to install netcdf-c in UBUNTU 20.4 based in the “[CMAQ/CMAQ\_UG\_tutorial\_build\_library\_intel.md at master · USEPA/CMAQ · GitHub](https://github.com/USEPA/CMAQ/blob/master/DOCS/Users_Guide/Tutorials/CMAQ_UG_tutorial_build_library_intel.md)” guideline. However, I do not have environmental modules. How can I install that on my system? I want to compile IOAPI and SMOKE with GNU compiler. in that case, should I use GNU compile instead of intel in this guideline?

---

<div class="post-metadata">

**Author:** ![cjcoats](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cjcoats](https://forum.cmascenter.org/u/cjcoats)\
**Post date:** [May 9, 2021, 11:56am UTC](https://forum.cmascenter.org/t/netcdf-c-installation-with-environmental-modules/2325/2 "2021-05-09T11:56:43Z")

</div>

A few notes:

- You should use the same compilers and compile-flags for the entire system: netCDF, I/O API, M3Tools, CMAQ, SMOKE

- The official I/O API build instructions can be found here [https://cjcoats.github.io/ioapi/AVAIL.html#build](https://cjcoats.github.io/ioapi/AVAIL.html#build); they include notes on netCDF as item 8 and also at https://cjcoats.github.io/ioapi/AVAIL.html#ncf4

- The CMAQ-website document you reference has a number of specifics for the UNC supercomuter-clusters, so don’t worry about them. In particular, ignore _module_ commands.

- All of these documents assume the use of _csh_ or _tcsh_; to adapt for _bash_, replace commands of the form _setenv foo bar_ by the equivalent _export foo = bar._

The build-system for netCDF (note that you need both netCDF-C and netCDF-Fortran) already assumes that you are using the Gnu compilers _gcc_ and _gfortran_ unless you override it with environment variables `CC` and `FC`, making your particular installation a little easier.

On the other hand, if your Ubuntu is using _gfortran_ version 10 or later (run the command _gfortran -v_ to find out) you will need either to add  
` -fallow_argument_mismatch`  
to the Fortran compile-flags (and also to the compile-flags for CMAQ) or use netCDF-Fortran version 4.5.4 or later, due to _gfortran_’s idiosyncratic interpretation of the latest version of the Fortran Standard; however, **its build system is very different** , and also requires that you have installed _cmake_. For the I/O API and SMOKE, you will need to use compile-type `Linux2_x86_64gfort10` – in your case, do the command  
_export BIN = Linux2\_x86\_64gfort10_.

You **do not need** the MPI compilers _mpicc_ and _mpif90_ for netCDF, I/O API, nor SMOKE; however, you do need them for the CMAQ CCTM; you’ll probably want to do the appropriate Ubuntu _app get_ commands for either OpenMPI or MPICH (both of which are available versions of MPI).

---

<div class="post-metadata">

**Author:** ![Nadia](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@Nadia](https://forum.cmascenter.org/u/Nadia)\
**Post date:** [May 10, 2021, 6:31am UTC](https://forum.cmascenter.org/t/netcdf-c-installation-with-environmental-modules/2325/3 "2021-05-10T06:31:25Z")

</div>

Thank you for your help. my gfortran version is 9.3 and my Shell is csh.  
Based on your explanation I set my cshrc as follows:  
setenv CC gcc  
setenv CXX g++  
setenv FC gfortran  
setenv FCFLAGS -m64  
setenv F77 gfortran  
setenv FFLAGS -m64  
according to install.md file in netcdf-c I should install zlib and HDF5 before installing netcdf-c. However, I did not see this instruction in the guidelines. Should I install these libraries as well? Is the version of these libraries important?  
Moreover, I have started to configure netcdf-fortran and although I set CPPFLAGS as it is recommended in [CMAQ/CMAQ\_UG\_tutorial\_build\_library\_intel.md at master · USEPA/CMAQ · GitHub](https://github.com/USEPA/CMAQ/blob/master/DOCS/Users_Guide/Tutorials/CMAQ_UG_tutorial_build_library_intel.md)  
I faced an error which mentioned “netcdf.h could not be found. Please set CPPFLAGS”

---

<div class="post-metadata">

**Author:** ![cjcoats](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cjcoats](https://forum.cmascenter.org/u/cjcoats)\
**Post date:** [May 10, 2021, 11:14am UTC](https://forum.cmascenter.org/t/netcdf-c-installation-with-environmental-modules/2325/4 "2021-05-10T11:14:49Z")

</div>

See [https://cjcoats.github.io/ioapi/AVAIL.html#ncf4](https://cjcoats.github.io/ioapi/AVAIL.html#ncf4)

Life is a lot simpler if you do netCDF’s _configure_ with flags  
`--disable-netcdf4 --disable-dap`  
Otherwise you are going to have to modify all the _Makefile_s for I/O API, SMOKE, CMAQ, etc., to fit the extra libraries you need.
