<p>Actually, you probably shouldn't install it. If you're comfortable using Linux, then you would be better advised to use the docker container instead, with it already installed. That way your system stays clean and you can have someone else maintain it for you.</p>

<p>Check docker hub for different versions and find the one you like (<a href="https://hub.docker.com/search?q=esmf&amp;type=image" rel="nofollow noreferrer">here</a>).</p>

<p>Install docker using: </p>

<pre><code>curl -LSs get.docker.com | sh
</code></pre>

<p>There are plenty of simple docker tutorials that will help you work out how to use it.</p>

CC BY-SA 4.0
2020-05-06T13:51:31.320Z
Thanks for the suggestion. I will try to use docker for esmf.
Manmeet Singh
CC BY-SA 4.0
2020-05-06T21:10:09.227Z
I'm trying to get an image ready myself. It's not quite there yet, and I'm short of time so I don't know when it'll be ready. https://github.com/BryanDollery/esmf-docker
Software Engineer
CC BY-SA 4.0
2020-05-06T21:35:08.577Z
Also, https://hub.docker.com/repository/docker/bryandollery/esmf
Software Engineer
CC BY-SA 4.0
2020-05-01T17:27:53.187Z
2020-05-01T17:27:53.187Z
Software Engineer
<p>First download the esmf tar file from <a href="http://www.earthsystemmodeling.org/esmf_releases/public/ESMF_7_1_0r/reg/ESMF_Framework_Down.html" rel="nofollow noreferrer">http://www.earthsystemmodeling.org/esmf_releases/public/ESMF_7_1_0r/reg/ESMF_Framework_Down.html</a></p>

<p>Then install netcdf library and gfortran compiler using</p>

<pre><code>sudo apt-get install git tcsh pkg-config
sudo apt-get install gfortran
sudo apt-get install netcdf-bin libnetcdf-dev libnetcdff-dev
sudo apt-get install openmpi-bin libopenmpi-dev
sudo apt-get install libnetcdff-dev
</code></pre>

<p>Once you have the netcdf library and gfortran compiler in your /usr/local/lib and /usr/local/include You can check this also, login as root using</p>

<pre><code>sudo -i
</code></pre>

<p>Then define the following environment variables</p>

<pre><code>cd path_of_esmf_dir
export ESMF_DIR=path_of_esmf_dir
export ESMF_INSTALL_PREFIX=/usr/local/esmf
export ESMF_OS=Linux
export ESMF_NETCDF="local"
export ESMF_COMM=mpiuni
export ESMF_F90COMPILER=gfortran
export ESMF_CXXCOMPILER=g++
export ESMF_TESTEXHAUSTIVE=on
export ESMF_TESTSHAREDOBJ=on
export ESMF_NETCDF_INCLUDE=/usr/local/include
export ESMF_NETCDF_LIBS="-lnetcdf -lnetcdff"
export ESMF_NETCDF_LIBPATH=/usr/local/lib
export ESMF_BOPT=O3
</code></pre>

<p>Then run the following syntax to make the library ESMF</p>

<pre><code>make all
make install
make installcheck
</code></pre>

<p>Now to install the ESMF python library</p>

<pre><code>cd path_to_esmf_dir/addon/ESMpy/
python setup.py build --ESMFMKFILE=/usr/local/esmf/lib/libO3/Linux.gfortran.64.mpiuni.default/esmf.mk
python setup.py install
</code></pre>

<p>You can check the installation by </p>

<pre><code>$ python 
&gt;&gt;&gt; import ESMF
</code></pre>

<p>ESMF python library has got limited features as compared to the ESMF library. Hence it is better to use ESMF directly.</p>

CC BY-SA 4.0
2020-05-01T19:35:28.620Z
I get this: `Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory`
Software Engineer
CC BY-SA 4.0
2020-05-02T08:03:01.997Z
either you have not installed netcdf library or your environment variables  ESMF_NETCDF_INCLUDE and ESMF_NETCDF_LIBPATH are not pointing to the path where netcdf library is installed
Manmeet Singh
CC BY-SA 4.0
2020-05-02T08:03:27.103Z
can you check the paths by doing which ncdump or wherein netcdf.mod
Manmeet Singh
CC BY-SA 4.0
2020-05-02T16:48:31.587Z
I'm following all of your instructions so it installed ok. The problem seems to be the include directory. The path you have above is empty on my Ubuntu 18.04 installation (WSL2). Changing it to /usr/include seems to have fixed the build. Thanks for the pointer. – Software Engineer 39 mins ago   Delete
Software Engineer
CC BY-SA 4.0
2024-01-15T15:21:24.553Z
For netcdf paths, you can use `nc-config --fflags` which gives you the path to your includes (bit after the `-I`)and `nc-config --flibs` which gives you the path to your libs (bit after the `-L`).
Klimaat
CC BY-SA 4.0
2019-12-22T08:02:10.867Z
2020-04-21T19:34:14.283Z
2020-04-21T19:34:14.283Z
Manmeet Singh
<p>I am trying to regrid some of my latitude-longitude grid files to tripolar ocean grid and found that ESMF can be useful. However, I am finding it hard to install the same. </p>

<meteorology><numerical-modelling><atmospheric-circulation><ocean-models>
How to install ESMF and ESMFPy in Ubuntu using gfortran, gcc, python?
tech_climate
# How to install ESMF and ESMFPy in Ubuntu using gfortran, gcc, python?

(Asked by: username_0 on 2019-12-22)

I am trying to regrid some of my latitude-longitude grid files to tripolar ocean grid and found that ESMF can be useful. However, I am finding it hard to install the same.

**Tags:** meteorology, numerical-modelling, atmospheric-circulation, ocean-models


---

## 2 answers

### Answer by username_2 on 2019-12-22. Score: 7 | Accepted answer

First download the esmf tar file from <http://www.earthsystemmodeling.org/esmf_releases/public/ESMF_7_1_0r/reg/ESMF_Framework_Down.html>

Then install netcdf library and gfortran compiler using

```
sudo apt-get install git tcsh pkg-config
sudo apt-get install gfortran
sudo apt-get install netcdf-bin libnetcdf-dev libnetcdff-dev
sudo apt-get install openmpi-bin libopenmpi-dev
sudo apt-get install libnetcdff-dev

```

Once you have the netcdf library and gfortran compiler in your /usr/local/lib and /usr/local/include You can check this also, login as root using

```
sudo -i

```

Then define the following environment variables

```
cd path_of_esmf_dir
export ESMF_DIR=path_of_esmf_dir
export ESMF_INSTALL_PREFIX=/usr/local/esmf
export ESMF_OS=Linux
export ESMF_NETCDF="local"
export ESMF_COMM=mpiuni
export ESMF_F90COMPILER=gfortran
export ESMF_CXXCOMPILER=g++
export ESMF_TESTEXHAUSTIVE=on
export ESMF_TESTSHAREDOBJ=on
export ESMF_NETCDF_INCLUDE=/usr/local/include
export ESMF_NETCDF_LIBS="-lnetcdf -lnetcdff"
export ESMF_NETCDF_LIBPATH=/usr/local/lib
export ESMF_BOPT=O3

```

Then run the following syntax to make the library ESMF

```
make all
make install
make installcheck

```

Now to install the ESMF python library

```
cd path_to_esmf_dir/addon/ESMpy/
python setup.py build --ESMFMKFILE=/usr/local/esmf/lib/libO3/Linux.gfortran.64.mpiuni.default/esmf.mk
python setup.py install

```

You can check the installation by

```
$ python 
>>> import ESMF

```

ESMF python library has got limited features as compared to the ESMF library. Hence it is better to use ESMF directly.

> **Comments:**
> **username_1**: I get this: `Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory`  
> **username_2**: either you have not installed netcdf library or your environment variables  ESMF_NETCDF_INCLUDE and ESMF_NETCDF_LIBPATH are not pointing to the path where netcdf library is installed  
> **username_2**: can you check the paths by doing which ncdump or wherein netcdf.mod  
> **username_1**: I'm following all of your instructions so it installed ok. The problem seems to be the include directory. The path you have above is empty on my Ubuntu 18.04 installation (WSL2). Changing it to /usr/include seems to have fixed the build. Thanks for the pointer. – username_1 username_1 39 mins ago   Delete  
> **username_3**: For netcdf paths, you can use `nc-config --fflags` which gives you the path to your includes (bit after the `-I`)and `nc-config --flibs` which gives you the path to your libs (bit after the `-L`).  

---

### Answer by username_1 on 2020-05-01. Score: 2

Actually, you probably shouldn't install it. If you're comfortable using Linux, then you would be better advised to use the docker container instead, with it already installed. That way your system stays clean and you can have someone else maintain it for you.

Check docker hub for different versions and find the one you like ([here](https://hub.docker.com/search?q=esmf&type=image)).

Install docker using:

```
curl -LSs get.docker.com | sh

```

There are plenty of simple docker tutorials that will help you work out how to use it.

> **Comments:**
> **username_2**: Thanks for the suggestion. I will try to use docker for esmf.  
> **username_1**: I'm trying to get an image ready myself. It's not quite there yet, and I'm short of time so I don't know when it'll be ready. https://github.com/BryanDollery/esmf-docker  
> **username_1**: Also, https://hub.docker.com/repository/docker/bryandollery/esmf  

---

