Latex is something very useful that you only take 30 minute to learn and benefits from it through all your career. Here we hope to use Latex to replace MS word to create docs that need regular modifications, e.g. CV and bio.
\documentclass{article}
\begin{document}
First document. This is a simple example, with no
extra parameters or packages included.
\end{document}
The first line of code declares the type of document, known as the class. The class controls the overall appearance of the document. Different types of documents will require different classes i.e. a CV/resume will require a different class than a scientific paper.
Everything in your .tex file before \begin{document}
point is called the preamble. In the preamble you define the type of document you are writing, the language you are writing in, the packages you would like to use (more on this later) and several other elements.
\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
As for the paper size other possible values are a4paper and legalpaper. Encoding for the document, utf-8 is recommended.
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{Sections and Chapters}
\author{Gubert Farnsworth}
\date{ }
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortisfacilisis sem. Nullam nec mi et
neque pharetra sollicitudin. Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...
\addcontentsline{toc}{section}{Unnumbered Section}
\section*{Unnumbered Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\end{document}
Updated 2020-06-20
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