Hello again,

After several days of investigation, I was able to patch and make NEC
(numerical Electromacnetigs Code) in plain C languaje under OpenBSD.

The trick was making function definitions for those functions that are
"built-in " in gcc compiler:

#define complex _Complex
double creal(complex double z);
double cimag(complex double z);

long double creall(complex long double z);
long double cimagl(complex long double z);
complex double conj(complex double z);



and definitions for the complex functions made by myself:




long double carg(complex long double z);
long double complexabs(complex long double z);
complex long double csqrt(complex long double z);
complex long double clog(complex long double z);
complex long double cexp(complex long double z);

I added a complex.c file with the home made functions:

#include "nec2c.h"


long double carg(complex long double z)
{
return( atan2( cimagl(z) , creall(z) ) );
}
long double complexabs(complex long double z)
{
return( sqrt( pow(creall(z),2) + pow(cimagl(z),2) ) );
}
complex long double csqrt(complex long double z)
{
return( pow(complexabs(z),2) * (  cos(carg(z)/2)  + sin(carg(z)/2) *
CPLX_01));
}
complex long double clog(complex long double z)
{
return( log(complexabs(z))+CPLX_01*carg(z));
}
complex long double cexp(complex long double z)
{
return(exp(creall(z)) * (cos(cimagl(z)) + CPLX_01*sin(cimagl(z))    ));
}


Every cabs() on the program was renamed to complexabs() just to not
conflict cabs() under OpenBSD.



I wrote this just in case someone desire to use this classic antenna
modelling software under OpenBSD in plain C languaje. The Fortran
version that compiles without effort is an interactive one. This one,
written in plain C, is not interactive and can accept command line input
and output files, and thus is more flexible and convenient.
If someone is interested in making a port for OpenBSD, please contact me
and I will send the patch. I am not a programmer and know that this is a
horrible and dirty patch that make the program work.
The original program is  nec2c.rxq-0.2.tar.gz at:

http://sharon.esrac.ele.tue.nl/users/pe1rxq/


Thanks for your time.

Ramiro
EA1ABZ.

Reply via email to