The number of threads
Wgrib2 can be compiled to use multiple threads. By
default, an OpenMP-enabled version of wgrib2 will use the environement
If the environment variable OMP_NUM_THREADS is not
defined, the number of threads created is usually the same as the number
of cores. The -ncpu option controls the number of threads
that will be used by wgrib2. If wgrib2 is not compiled to use OpenMP, this
option is quietly ignored. The -ncpu option overrides
the OMP_NUM_THREADS environment variable.
When you run an OpenMP-enabled wgrib2 version on a shared system, the
performance may be suboptimal. For example, on one of our linux system, we have
a 32 cores. The system is shared by many users and during a busy time, there
may only be a few cores free at any one time.
The main usage of the -ncpu option is to allocate
threads/cpus when you are running multiple copies of wgrib2.
N = number of threads
$ wgrib2 IN.grb -ncpu 3 -new_grid_winds grid -new_grid ncep grid 221 - | wgrib2 - -ncpu 1 -set_grib_type j -ncep_uv OUT.grb
The above line uses 3 threads for regridding and one thread for jpeg2000 compression. The jpeg2000
compression routines can't take advantage of more than one thread.