Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,39 @@ USHOW_LIBS += $(ZARR_LIBS)
UTERM_LIBS += $(ZARR_LIBS)
endif

# GRIB support (optional) - build with: make WITH_GRIB=1
# Requires: eccodes (brew install eccodes on macOS)
ifdef WITH_GRIB
GRIB_PKG_CFLAGS := $(shell pkg-config --cflags eccodes 2>/dev/null)
GRIB_PKG_LIBS := $(shell pkg-config --libs eccodes 2>/dev/null)

ifneq ($(strip $(GRIB_PKG_CFLAGS)$(GRIB_PKG_LIBS)),)
GRIB_CFLAGS := -DHAVE_GRIB $(GRIB_PKG_CFLAGS)
GRIB_LIBS := $(GRIB_PKG_LIBS)
else
# DKRZ Levante spack path (eccodes uses lib64)
DKRZ_ECCODES := /sw/spack-levante/eccodes-2.44.0-hsksp4

ifneq ($(wildcard $(DKRZ_ECCODES)/include/eccodes.h),)
GRIB_PREFIX ?= $(DKRZ_ECCODES)
GRIB_LIBDIR := $(GRIB_PREFIX)/lib64
GRIB_RPATH := -Wl,-rpath,$(GRIB_LIBDIR)
else
GRIB_PREFIX ?= $(shell brew --prefix eccodes 2>/dev/null || echo "/usr/local")
GRIB_LIBDIR := $(GRIB_PREFIX)/lib
GRIB_RPATH :=
endif

GRIB_CFLAGS := -DHAVE_GRIB -I$(GRIB_PREFIX)/include
GRIB_LIBS := -L$(GRIB_LIBDIR) -leccodes $(GRIB_RPATH)
endif

BASE_CFLAGS += $(GRIB_CFLAGS)
X11_FULL_CFLAGS += $(GRIB_CFLAGS)
USHOW_LIBS += $(GRIB_LIBS)
UTERM_LIBS += $(GRIB_LIBS)
endif

# Directories
SRCDIR = src
OBJDIR = obj
Expand Down Expand Up @@ -146,6 +179,11 @@ USHOW_SRCS += $(SRCDIR)/cJSON/cJSON.c
UTERM_SRCS += $(SRCDIR)/cJSON/cJSON.c
endif

# Add grib sources if enabled
ifdef WITH_GRIB
COMMON_SRCS += $(SRCDIR)/file_grib.c
endif

USHOW_OBJS = $(USHOW_SRCS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
UTERM_OBJS = $(UTERM_SRCS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)

Expand Down Expand Up @@ -231,6 +269,11 @@ $(OBJDIR)/file_zarr.o: $(SRCDIR)/file_zarr.c $(SRCDIR)/file_zarr.h $(SRCDIR)/ush
$(OBJDIR)/cJSON/cJSON.o: $(SRCDIR)/cJSON/cJSON.c $(SRCDIR)/cJSON/cJSON.h
endif

# GRIB dependencies (when WITH_GRIB is set)
ifdef WITH_GRIB
$(OBJDIR)/file_grib.o: $(SRCDIR)/file_grib.c $(SRCDIR)/file_grib.h $(SRCDIR)/ushow.defines.h
endif

# Print configuration
info:
@echo "CC: $(CC)"
Expand Down
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ For optional Zarr support:
brew install c-blosc lz4
```

For optional GRIB support:
```bash
brew install eccodes
```

Install [XQuartz](https://www.xquartz.org/) for X11 support. After installation, the X11 libraries will be in `/opt/X11`.

Build:
```bash
make # Without zarr support
make # Without zarr/grib support
make WITH_ZARR=1 # With zarr support
make WITH_GRIB=1 # With grib support
make uterm # Build terminal viewer only
```

Expand All @@ -54,10 +60,16 @@ For optional Zarr support:
sudo apt-get install libblosc-dev liblz4-dev
```

For optional GRIB support:
```bash
sudo apt-get install libeccodes-dev
```

Build:
```bash
make # Without zarr support
make # Without zarr/grib support
make WITH_ZARR=1 # With zarr support
make WITH_GRIB=1 # With grib support
make uterm # Build terminal viewer only
```

Expand All @@ -69,8 +81,9 @@ On Levante, the Makefile automatically uses the DKRZ spack-installed libraries:

No modules need to be loaded. Simply run:
```bash
make # Without zarr support
make # Without zarr/grib support
make WITH_ZARR=1 # With zarr support (uses system blosc/lz4)
make WITH_GRIB=1 # With grib support (uses system eccodes)
```

The binary will have the library paths embedded (via rpath), so it runs without setting `LD_LIBRARY_PATH`.
Expand Down Expand Up @@ -103,7 +116,7 @@ No libraries should show as "not found".
## Usage

```bash
./ushow [options] <data_file.nc|data.zarr> [file2 ...]
./ushow [options] <data_file.nc|data.zarr|data.grib> [file2 ...]

Options:
-m, --mesh <file> Mesh file with coordinates (for unstructured data)
Expand All @@ -115,7 +128,7 @@ Options:

Terminal quick-look mode:
```bash
./uterm [options] <data_file.nc|data.zarr> [file2 ...]
./uterm [options] <data_file.nc|data.zarr|data.grib> [file2 ...]

Options (uterm):
-m, --mesh <file> Mesh file with coordinates
Expand Down Expand Up @@ -159,6 +172,12 @@ Zarr store (requires `make WITH_ZARR=1`):
./ushow data.zarr -r 0.25 # Higher resolution display
```

GRIB file (requires `make WITH_GRIB=1`):
```bash
./ushow data.grib # Single GRIB file
./uterm data.grib --color
```

Zarr store with consolidated metadata (faster loading):
```bash
# Zarr stores with .zmetadata file are loaded more efficiently
Expand Down
Loading