# NEC-2 engine (nec2c, WebAssembly build)

`nec2c.wasm` is nec2c — Neoklis Kyriazis' C translation of the NEC-2 Numerical
Electromagnetics Code — compiled to WebAssembly (WASI preview 1).

- License: GNU GPL v3 (see `COPYING.txt`). The rest of Antenna Workbench talks to
  this program only through its input deck and output text, like a command-line tool.
- Source: https://github.com/KJ7LNW/nec2c
  commit 55be1e0e3fe5ee9dad4ce6050711450d19c562fd
- Local change: `nec2c-wasi.patch` (skips POSIX signal handlers, which WASI lacks).

## Build

```bash
pip install ziglang
git clone https://github.com/KJ7LNW/nec2c && cd nec2c
git checkout 55be1e0e3fe5ee9dad4ce6050711450d19c562fd
patch -p0 main.c < nec2c-wasi.patch
python3 -m ziglang cc -target wasm32-wasi -O2 -s \
  -DPACKAGE_STRING='"nec2c 1.3.1 (wasm)"' \
  -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \
  -lwasi-emulated-signal -lwasi-emulated-process-clocks \
  -o nec2c.wasm calculations.c fields.c geometry.c ground.c input.c main.c \
  matrix.c misc.c network.c radiation.c somnec.c shared.c -lm
```
