Now we spin-up for the next journey! We try to compile the first C++ program in the linux environment.
First we review the Big Three command line to invoke compilers:
GNU | INTEL | PGI | |
---|---|---|---|
FORTRAN | gfortran | ifort | pgfortran |
C | gcc | icc | pgcc |
C++ | g++ | icpc | pgc++ |
Now we try a very simple program, do a loooong loop and see the CPU lapsed time!
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
for (int i = 0; i < 1000000000; i++)
{
i++;
}
cout << "Totle Time : " << (double)clock() /CLOCKS_PER_SEC<< "s" << endl;
return 0;
}
Interesting! Here you see the optimization of the Intel compilers!
Updated 2020-05-29
Here we archive the process of building cfgrib engine for xarray in python3.7 (Anaconda). Although there still seems to be some problems, the eccodes
and cfgrib
have been installed sucessfully.
First, we found using conda install
cannot install eccodes
due to dependency problems (might comes from python version issue, we did not check then).
Then we install the eccodes
from source. The process was smooth, just install cmake
prior to the eccodes installation.
When install python interface, try both --install-option
and export ECCODES_DIR=/path/to/where/you/install/eccodes
.
After that:
pip install --force-reinstall cfgrib
Note conda does not work in my case.
Set all possible environmental varibales:
export ECCODES_DIR=/home/yhuangci/lee/soft/eccodes-2.17.0
export PATH=$ECCODES_DIR:$PATH
export LIBECCODES=$ECCODES_DIR/lib
export LD_LIBRARY_PATH=$ECCODES_DIR/lib:$LD_LIBRARY_PATH
xr.open_dataset('example.grib', engine='cfgrib')
works with some data-caused errors.
Error things like:
cfgrib.dataset.DatasetBuildError: key present and new value is different
See this post. Add a backend_kwargs
to overwrite the “strict” option will fix the problem:
ds_grib = xr.open_dataset('../../data/era5/sfc202005.grib', engine='cfgrib', backend_kwargs={'errors': 'ignore'})
Updated 2020-05-19
I used the default environment to install metpy
with:
conda install metpy
got errors.
TypeError: find_intersections takes 5 parameters, but 3 units were passed
Following this post. The issue seems to be a specific version dependency issue. In conda, the metpy is version 0.11, while version 0.12 solves the problem.
Here we just create a new conda environment for metpy
.
conda create -n metpy python=3.7
Use pip install
to install the metpy. After that, we found the cartopy
need to be installed. Then, everything goes fine.
Example figure:
CartoPy figure:
Updated 2020-05-11