EZNEC Source Code


I've been asked why not encourage and make possible an open source version of EZNEC after I retire. The reason is that there are some serious problems.

Before I go into the details I need to explain that EZNEC consists of two distinct parts, written in different languages and compiled into separate executable files, and with different histories. The main part of EZNEC is the user interface. Actual antenna calculations are done by the separately written and compiled "calculating engines". First I'll talk about the main part, and "EZNEC" will refer below just to the main part of the program, exclusive of the calculating engines.

The first problem is the language.

EZNEC began in 1990 as ELNEC, a MININEC-based program written in GWBASIC. The first Windows version of EZNEC (EZNEC v. 3.0) was written beginning in about 1998 when Visual Basic was the current and logical choice for a Windows language, and three major versions of EZNEC (v. 4.0, 5.0, and 6.0) were subsequently developed using that language and released. By the time Microsoft discontinued support for Visual Basic 6.0 in 2008, EZNEC/EZNEC+ had undergone two major upgrades and consisted of more than 71,000 lines of code and EZNEC Pro more than 76,000 lines -- not counting blank and comment lines. This is just the main program, not including the calculating engines. Translation from Visual Basic 6.0 (VB6) to its successor Visual Basic Net (VB.Net) or any other language, open source or not, would require almost a complete re-write of the program. (Although VB.Net has a similar name and some commonality to VB6, it's different enough to prevent any kind of even semi-automated translation let alone direct copying.)

v. 6.0.34 of EZNEC/EZNEC+ now consists of more than 78,000 lines of code and EZNEC Pro more than 84,000. Worse yet, the program has evolved over three decades and contains some code from the days when memory and computing time were precious, so there are portions which aren't nearly as modular and compartmentalized as more recent tools and systems allow us to be.

Of course I've thought a number of times about updating EZNEC to another language but estimate that it would take at least two years of full time work, at the end of which would be a program which the user couldn't distinguish from the original -- except for the massive number of bugs which would inevitably result from the translation and the poor support I'd be able to provide while spending the time programming instead.

If it was attempted, the logical way to go about a project like this would be to identify blocks of code which could be independently translated and put into external libraries where the re-written functions could be called and tested as they're developed. As far as I've been able to tell, compatible libraries can't be created with Visual Basic Net, at least not easily, although they can be made with some other languages. (EZNEC uses a number of libraries I wrote in Fortran for calculation speed.) After creating a library, EZNEC would have to be modified to call its functions and then be recompiled -- but the VB6 compiler hasn't been available for many years now. (Those of us who have it can still coax it to run under Windows up to and including 10 but with a few quirks. I won't be testing it under Windows 11.)

Then there are the third party components.

The grid structure used for many of the EZNEC windows is contained in a third party component (ssdw3b32.ocx) which has been unavailble for many years. Incidentally, I found over 20 bugs in the component. Some of these were fixed by the developer but EZNEC contains quite a bit of code to work around the others. I'm sure there isn't a drop-in replacement, so the basic grid operations would have to be re-written pretty much from scratch. That comprises a substantial portion of EZNEC.

Several other third party components are used but would probably be unnecessary (such as a printer management component needed because of VB6's limited ability) or could be more directly replaced.

And some components written in Fortran.

A number of dlls (dynamic linked libraries) used by EZNEC such as Catenary.dll, Csi.dll, EZWf16, EZWf36.dll, and others contain functions I wrote in Fortran for higher speed. An example is a routine that compares the end coordinates of every wire to those of every other wire to determine which are connected. It doesn't look for an exact match but rather determines whether the distance is within some fraction of the segment lengths. This runs completely every time any wire coordinate is changed and might have to process as many as 90,000 wire ends for the largest permissible models. Another is the elaborate geometry check which looks for wires which are touching (anywhere from the centers to the outsides of the wires), overlapping, etc. Or the catenary wire calculation which can't be done in closed form so uses an iterative process. These could be left as is but a good Fortran compiler would be needed if any changes were made.

Then there are the calculating engines.

The calculating engines are extensively modified NEC-2 and, for EZNEC Pro/4 which won't be made available under any circumstances, NEC-4.2. NEC-2 was incorporated to replace ELNEC's MININEC calculating engine, so it's extensively integrated and doesn't use the native NEC-2 input and output format. Memory management and dynamic dimensioning of arrays were added, and the most intensive matrix math calculations were replaced by very fast optimized math libraries which speed the program immensely. Many other features have been added such as current sources, lossy transmission lines, transformers, and MININEC-type ground. They're written in Fortran, and directly recompiling requires the Intel Visual Fortran compiler which I believe now costs about $1000 -- I pay $299 per year just for support and access to updates. And anyone wanting to work with any remaining original NEC-2 (or for that matter NEC-4) code should be warned that it's extremely obtuse and difficult to follow, being written in 1970s style.

Finally, and not least, there's me.

Anybody attempting to work with EZNEC code will have a great many questions, a lot of which I might be able to quickly answer. But I won't, and would probably feel guilty for not helping. But I'm bound and determined to really retire, and that means cutting the cord. Sorry.

Roy Lewallen, W7EL
July 16, 2021