Subversion Repositories Nec2c

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/*** Translated to the C language by N. Kyriazis  20 Aug 2003 ***
2
 
3
Program NEC(input,tape5=input,output,tape11,tape12,tape13,tape14,
4
tape15,tape16,tape20,tape21)
5
 
6
Numerical Electromagnetics Code (NEC2)  developed at Lawrence
7
Livermore lab., Livermore, CA.  (contact G. Burke at 415-422-8414
8
for problems with the NEC code. For problems with the vax implem-
9
entation, contact J. Breakall at 415-422-8196 or E. Domning at 415
10
422-5936)
11
file created 4/11/80.
12
 
13
               ***********Notice**********
14
This computer code material was prepared as an account of work
15
sponsored by the United States government.  Neither the United
16
States nor the United States Department Of Energy, nor any of
17
their employees, nor any of their contractors, subcontractors,
18
or their employees, makes any warranty, express or implied, or
19
assumes any legal liability or responsibility for the accuracy,
20
completeness or usefulness of any information, apparatus, product
21
or process disclosed, or represents that its use would not infringe
22
privately-owned rights.
23
 
24
*******************************************************************/
25
 
26
#include "nec2c.h"
27
 
28
/* common  /cmb/ */
29
complex double *cm;
30
 
31
/* common  /crnt/ */
32
crnt_t crnt;
33
 
34
/* common  /data/ */
35
data_t data;
36
 
37
/*common  /ggrid/ */
38
extern ggrid_t ggrid;
39
 
40
/* common  /gnd/ */
41
gnd_t gnd;
42
 
43
/* common  /matpar/ */
44
matpar_t matpar;
45
 
46
/* common  /netcx/ */
47
netcx_t netcx;
48
 
49
/* common  /save/ */
50
save_t save;
51
 
52
/* common  /segj/ */
53
segj_t segj;
54
 
55
/* common  /yparm/ */
56
yparm_t yparm;
57
 
58
/* common  /zload/ */
59
zload_t zload;
60
 
61
/* common  /vsorc/ */
62
vsorc_t vsorc;
63
 
64
/* common  /fpat/ */
65
fpat_t fpat;
66
 
67
/* common  /gwav/ */
68
gwav_t gwav;
69
 
70
/* common  /plot/ */
71
plot_t plot;
72
 
73
/* common  /smat/ */
74
smat_t smat;
75
 
76
/* pointers to input/output files */
77
FILE *input_fp = NULL, *output_fp = NULL, *plot_fp = NULL;
78
 
79
#if defined USE_SIGHANDLER_CODE
80
/* signal handler */
81
static void sig_handler(int signal);
82
#endif
83
 
84
/*-------------------------------------------------------------------*/
85
 
86
int main(int argc, char **argv)
87
{
88
        char infile[81] = "", otfile[81] = "";
89
        char ain[3], line_buf[81];
90
 
91
        /* input card mnemonic list */
92
#define NUM_CMNDS 20
93
        char *atst[NUM_CMNDS] = {"FR", "LD", "GN", "EX", "NT", "TL", "XQ", "GD", "RP", "NX",
94
                                 "PT", "KH", "NE", "NH", "PQ", "EK", "CP", "PL", "EN", "WG"};
95
 
96
        char *hpol[3] = {"LINEAR", "RIGHT", "LEFT"};
97
        char *pnet[3] = {"        ", "STRAIGHT", " CROSSED"};
98
 
99
        int *ldtyp, *ldtag, *ldtagf, *ldtagt;
100
        int ifrtmw, ifrtmp, mpcnt, igo, nfrq;
101
        int iexk, iptflg, iptflq, iped, iflow, itmp1, iresrv;
102
        int itmp3, itmp2, itmp4, nthi = 0, nphi = 0, iptag = 0, iptagf = 0, iptagt = 0;
103
        int iptaq = 0, iptaqf = 0, iptaqt = 0, nphic = 0, inc = 0;
104
        int i, j, itmp5, nthic = 0, mhz = 0, ifrq = 0, isave = 0;
105
 
106
        int igox,          /* used in place of "igo" in freq loop */
107
            next_job,      /* start next job (next sructure) flag */
108
            idx,           /* general purpose index    */
109
            ain_num,       /* ain mnemonic as a number */
110
            jmp_iloop,     /* jump to input loop flag  */
111
            jmp_floop = 0, /* jump to freq. loop flag  */
112
            mreq;          /* Size req. for malloc's   */
113
 
114
        double *zlr, *zli, *zlc, *fnorm;
115
        double *xtemp, *ytemp, *ztemp, *sitemp, *bitemp;
116
        double rkh, tmp1, delfrq = 0., tmp2, tmp3, tmp4, tmp5, tmp6;
117
        double xpr1 = 0., xpr2 = 0., xpr3 = 0., xpr4 = 0., xpr5 = 0.;
118
        double zpnorm = 0., thetis = 0., phiss = 0., extim;
119
        double tim1, tim, tim2, etha, fr, fr2, cmag, ph, ethm, ephm, epha;
120
        complex double eth, eph, curi, ex, ey, ez, epsc;
121
 
122
        /* getopt() variables */
123
        extern char *optarg;
124
        extern int optind, opterr, optopt;
125
        int option;
126
#if defined USE_SIGHANDLER_CODE
127
        /*** signal handler related code ***/
128
        /* new and old actions for sigaction() */
129
        struct sigaction sa_new, sa_old;
130
 
131
        /* initialize new actions */
132
        sa_new.sa_handler = sig_handler;
133
        sigemptyset(&sa_new.sa_mask);
134
        sa_new.sa_flags = 0;
135
 
136
        /* register function to handle signals */
137
        sigaction(SIGINT, &sa_new, &sa_old);
138
        sigaction(SIGSEGV, &sa_new, 0);
139
        sigaction(SIGFPE, &sa_new, 0);
140
        sigaction(SIGTERM, &sa_new, 0);
141
        sigaction(SIGABRT, &sa_new, 0);
142
#endif
143
 
144
        /*** here we have code to read interactively input/output ***/
145
        /*** file names for compatibility with 4nec2.  ***/
146
        /*** this is done non-interactively below if the user ***/
147
        /*** provides one or more arguments   ***/
148
 
149
        if (argc == 1)
150
        {
151
                fgets(infile, 75, stdin);
152
                int i = strlen(infile);
153
                while (i > 0)
154
                {
155
                        --i;
156
                        if (infile[i] <= ' ')
157
                                infile[i] = 0;
158
                        else
159
                                break;
160
                }
161
                fgets(otfile, 75, stdin);
162
                i = strlen(otfile);
163
                while (i > 0)
164
                {
165
                        --i;
166
                        if (otfile[i] <= ' ')
167
                                otfile[i] = 0;
168
                        else
169
                                break;
170
                }
171
                printf("%s -i %s -o %s\n", argv[0], infile, otfile);
172
        }
173
 
174
        /* process command line options */
175
        while ((option = getopt(argc, argv, "i:o:hv")) != -1)
176
        {
177
                switch (option)
178
                {
179
                case 'i': /* specify input file name */
180
                        if (strlen(optarg) > 75)
181
                                abort_on_error(-1);
182
                        strcpy(infile, optarg);
183
                        break;
184
 
185
                case 'o': /* specify output file name */
186
                        if (strlen(optarg) > 75)
187
                                abort_on_error(-2);
188
                        strcpy(otfile, optarg);
189
                        break;
190
 
191
                case 'h': /* print usage and exit */
192
                        usage();
193
                        exit(0);
194
 
195
                case 'v': /* print nec2c version */
196
                        puts(version);
197
                        exit(0);
198
 
199
                default: /* print usage and exit */
200
                        usage();
201
                        exit(-1);
202
 
203
                } /* end of switch( option ) */
204
 
205
        } /* while( (option = getopt(argc, argv, "i:o:hv") ) != -1 ) */
206
 
207
        /*** open input file ***/
208
        if ((input_fp = fopen(infile, "r")) == NULL)
209
        {
210
                char mesg[88] = "nec2c: ";
211
 
212
                strcat(mesg, infile);
213
                perror(mesg);
214
                exit(-1);
215
        }
216
 
217
        /* make an output file name if not */
218
        /* specified by user on invocation */
219
        if (strlen(otfile) == 0)
220
        {
221
                /* strip file name extension if there is one */
222
                idx = 0;
223
                while ((infile[++idx] != '.') && (infile[idx] != '\0'))
224
                        ;
225
                infile[idx] = '\0';
226
 
227
                /* make the output file name from input file */
228
                strcpy(otfile, infile);
229
                strcat(otfile, ".out"); /* add extension */
230
        }
231
 
232
        /* open output file */
233
        if ((output_fp = fopen(otfile, "w")) == NULL)
234
        {
235
                char mesg[88] = "nec2c: ";
236
 
237
                strcat(mesg, otfile);
238
                perror(mesg);
239
                exit(-1);
240
        }
241
 
242
        /* force the printing of 2 digit exponents in the C library. To enable this  */
243
        /* compile with -posix flag in makefile : e.g. "./configure CFLAGS=-posix" */
244
        setenv("PRINTF_EXPONENT_DIGITS", "2", 1);
245
 
246
        secnds(&extim);
247
 
248
        /* Null local buffer pointers */
249
        /* type int */
250
        ldtyp = ldtag = ldtagf = ldtagt = NULL;
251
        /* type double */
252
        zlr = zli = zlc = fnorm = NULL;
253
        xtemp = ytemp = ztemp = sitemp = bitemp = NULL;
254
        /* type complex double */
255
        cm = NULL;
256
 
257
        /* Null global pointers */
258
        Null_Pointers();
259
 
260
        /* Allocate some buffers */
261
        mem_alloc((void *)&ggrid.ar1, sizeof(complex double) * 11 * 10 * 4);
262
        mem_alloc((void *)&ggrid.ar2, sizeof(complex double) * 17 * 5 * 4);
263
        mem_alloc((void *)&ggrid.ar3, sizeof(complex double) * 9 * 8 * 4);
264
 
265
        /* Initialize ground grid parameters for somnec */
266
        ggrid.nxa[0] = 11;
267
        ggrid.nxa[1] = 17;
268
        ggrid.nxa[2] = 9;
269
 
270
        ggrid.nya[0] = 10;
271
        ggrid.nya[1] = 5;
272
        ggrid.nya[2] = 8;
273
 
274
        ggrid.dxa[0] = .02;
275
        ggrid.dxa[1] = .05;
276
        ggrid.dxa[2] = .1;
277
 
278
        ggrid.dya[0] = .1745329252;
279
        ggrid.dya[1] = .0872664626;
280
        ggrid.dya[2] = .1745329252;
281
 
282
        ggrid.xsa[0] = 0.;
283
        ggrid.xsa[1] = .2;
284
        ggrid.xsa[2] = .2;
285
 
286
        ggrid.ysa[0] = 0.;
287
        ggrid.ysa[1] = 0.;
288
        ggrid.ysa[2] = .3490658504;
289
 
290
        /* l_1: */
291
        /* main execution loop, exits at various points */
292
        /* depending on error conditions or end of jobs */
293
        while (TRUE)
294
        {
295
                ifrtmw = 0;
296
                ifrtmp = 0;
297
 
298
                /* print the nec2c header to output file */
299
                fprintf(output_fp, "1\n");
300
                fprintf(
301
                    output_fp,
302
                    "\n\n\n"
303
                    "                                 "
304
                    "*********************************************\n\n"
305
                    "                                 "
306
                    "   NUMERICAL ELECTROMAGNETICS CODE (nec2c)\n\n"
307
                    "                                 "
308
                    "*********************************************\n");
309
 
310
                /* read a line from input file */
311
                if (load_line(line_buf, input_fp) == EOF)
312
                        abort_on_error(-3);
313
 
314
                /* separate card's id mnemonic */
315
                strncpy(ain, line_buf, 2);
316
                ain[2] = '\0';
317
 
318
                /* if its a "cm" or "ce" card start reading comments */
319
                if ((strcmp(ain, "CM") == 0) || (strcmp(ain, "CE") == 0))
320
                {
321
                        fprintf(
322
                            output_fp,
323
                            "\n\n\n\n"
324
                            "                                     "
325
                            "- - - - COMMENTS - - - -\n\n\n");
326
                        char *s = &line_buf[2];
327
                        int i = strlen(s);
328
                        while (i && s[i] == ' ')
329
                                s[i--] = 0;
330
 
331
                        /* write comment to output file */
332
                        if (i > 0)
333
                                fprintf(output_fp, "                              %s\n", s);
334
 
335
                        /* Keep reading till a non "CM" card */
336
                        while (strcmp(ain, "CM") == 0)
337
                        {
338
                                /* read a line from input file */
339
                                if (load_line(line_buf, input_fp) == EOF)
340
                                        abort_on_error(-3);
341
 
342
                                /* separate card's id mnemonic */
343
                                strncpy(ain, line_buf, 2);
344
                                ain[2] = '\0';
345
                                s = &line_buf[2];
346
                                int i = strlen(s);
347
                                while (i && s[i] == ' ')
348
                                        s[i--] = 0;
349
 
350
                                /* write comment to output file */
351
                                if (i > 0)
352
                                        fprintf(
353
                                            output_fp,
354
                                            "                              %s\n",
355
                                            s);
356
 
357
                        } /* while( strcmp(ain, "CM") == 0 ) */
358
 
359
                        /* no "ce" card at end of comments */
360
                        if (strcmp(ain, "CE") != 0)
361
                        {
362
                                fprintf(
363
                                    output_fp,
364
                                    "\n\n          INCORRECT LABEL FOR A COMMENT CARD");
365
                                abort_on_error(-4);
366
                        }
367
 
368
                } /* if( strcmp(ain, "CM") == 0 ... */
369
                else
370
                        rewind(input_fp);
371
 
372
                /* initializations etc from original fortran code */
373
                mpcnt = 0;
374
                matpar.imat = 0;
375
 
376
                /* set up geometry data in subroutine datagn */
377
                datagn();
378
                iflow = 1;
379
 
380
                /* Allocate some buffers */
381
                mreq = data.npm * sizeof(double);
382
                mem_realloc((void *)&crnt.air, mreq);
383
                mem_realloc((void *)&crnt.aii, mreq);
384
                mem_realloc((void *)&crnt.bir, mreq);
385
                mem_realloc((void *)&crnt.bii, mreq);
386
                mem_realloc((void *)&crnt.cir, mreq);
387
                mem_realloc((void *)&crnt.cii, mreq);
388
                mem_realloc((void *)&xtemp, mreq);
389
                mem_realloc((void *)&ytemp, mreq);
390
                mem_realloc((void *)&ztemp, mreq);
391
                mem_realloc((void *)&sitemp, mreq);
392
                mem_realloc((void *)&bitemp, mreq);
393
 
394
                mreq = data.np2m * sizeof(int);
395
                mem_realloc((void *)&save.ip, mreq);
396
 
397
                mreq = data.np3m * sizeof(complex double);
398
                mem_realloc((void *)&crnt.cur, mreq);
399
 
400
                /* Matrix parameters */
401
                if (matpar.imat == 0)
402
                {
403
                        netcx.neq = data.n + 2 * data.m;
404
                        netcx.neq2 = 0;
405
                }
406
 
407
                fprintf(output_fp, "\n\n\n");
408
 
409
                /* default values for input parameters and flags */
410
                netcx.npeq = data.np + 2 * data.mp;
411
                plot.iplp1 = 0;
412
                plot.iplp2 = 0;
413
                plot.iplp3 = 0;
414
                plot.iplp4 = 0;
415
                igo = 1;
416
                nfrq = 1;
417
                rkh = 1.;
418
                iexk = 0;
419
                fpat.ixtyp = 0;
420
                zload.nload = 0;
421
                netcx.nonet = 0;
422
                fpat.near = -1;
423
                iptflg = -2;
424
                iptflq = -1;
425
                gnd.ifar = -1;
426
                gnd.zrati = CPLX_10;
427
                iped = 0;
428
                yparm.ncoup = 0;
429
                yparm.icoup = 0;
430
                save.fmhz = CVEL;
431
                gnd.ksymp = 1;
432
                gnd.nradl = 0;
433
                gnd.iperf = 0;
434
 
435
                /* l_14: */
436
 
437
                /* main input section, exits at various points */
438
                /* depending on error conditions or end of job */
439
                next_job = FALSE;
440
                while (!next_job)
441
                {
442
                        jmp_iloop = FALSE;
443
 
444
                        if (feof(input_fp))
445
                        {
446
                                next_job = TRUE;
447
                                stop(0);
448
                        }
449
 
450
                        /* main input section - standard read statement - jumps */
451
                        /* to appropriate section for specific parameter set up */
452
                        readmn(
453
                            ain,
454
                            &itmp1,
455
                            &itmp2,
456
                            &itmp3,
457
                            &itmp4,
458
                            &tmp1,
459
                            &tmp2,
460
                            &tmp3,
461
                            &tmp4,
462
                            &tmp5,
463
                            &tmp6);
464
 
465
                        /* If its an "XT" card, exit */
466
                        if (strcmp(ain, "XT") == 0)
467
                        {
468
                                fprintf(
469
                                    stderr,
470
                                    "\nnec2c: Exiting after an \"XT\" command in main()\n");
471
                                fprintf(
472
                                    output_fp,
473
                                    "\n\n  nec2c: Exiting after an \"XT\" command in main()");
474
                                stop(0);
475
                        }
476
 
477
                        mpcnt++;
478
                        fprintf(
479
                            output_fp,
480
                            "\n ***** DATA CARD NO.%3d   "
481
                            "%2s%4d %5d %5d %5d %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E",
482
                            mpcnt,
483
                            ain,
484
                            itmp1,
485
                            itmp2,
486
                            itmp3,
487
                            itmp4,
488
                            tmp1,
489
                            tmp2,
490
                            tmp3,
491
                            tmp4,
492
                            tmp5,
493
                            tmp6);
494
 
495
                        /* identify card id mnemonic (except "ce" and "cm") */
496
                        for (ain_num = 0; ain_num < NUM_CMNDS; ain_num++)
497
                                if (strncmp(ain, atst[ain_num], 2) == 0)
498
                                        break;
499
 
500
                        /* take action according to card id mnemonic */
501
                        switch (ain_num)
502
                        {
503
                        case 0: /* "fr" card, frequency parameters */
504
 
505
                                ifrq = itmp1;
506
                                nfrq = itmp2;
507
                                if (nfrq == 0)
508
                                        nfrq = 1;
509
                                save.fmhz = tmp1;
510
                                delfrq = tmp2;
511
                                if (iped == 1)
512
                                        zpnorm = 0.;
513
                                igo = 1;
514
                                iflow = 1;
515
 
516
                                continue; /* continue card input loop */
517
 
518
                        case 1: /* "ld" card, loading parameters */
519
                        {
520
                                int idx;
521
 
522
                                if (iflow != 3)
523
                                {
524
                                        iflow = 3;
525
                                        /* Free loading buffers */
526
                                        zload.nload = 0;
527
                                        free_ptr((void *)&ldtyp);
528
                                        free_ptr((void *)&ldtag);
529
                                        free_ptr((void *)&ldtagf);
530
                                        free_ptr((void *)&ldtagt);
531
                                        free_ptr((void *)&zlr);
532
                                        free_ptr((void *)&zli);
533
                                        free_ptr((void *)&zlc);
534
 
535
                                        if (igo > 2)
536
                                                igo = 2;
537
                                        if (itmp1 == -1)
538
                                                continue; /* continue card input loop */
539
                                }
540
 
541
                                /* Reallocate loading buffers */
542
                                zload.nload++;
543
                                idx = zload.nload * sizeof(int);
544
                                mem_realloc((void *)&ldtyp, idx);
545
                                mem_realloc((void *)&ldtag, idx);
546
                                mem_realloc((void *)&ldtagf, idx);
547
                                mem_realloc((void *)&ldtagt, idx);
548
                                idx = zload.nload * sizeof(double);
549
                                mem_realloc((void *)&zlr, idx);
550
                                mem_realloc((void *)&zli, idx);
551
                                mem_realloc((void *)&zlc, idx);
552
 
553
                                idx = zload.nload - 1;
554
                                ldtyp[idx] = itmp1;
555
                                ldtag[idx] = itmp2;
556
                                if (itmp4 == 0)
557
                                        itmp4 = itmp3;
558
                                ldtagf[idx] = itmp3;
559
                                ldtagt[idx] = itmp4;
560
 
561
                                if (itmp4 < itmp3)
562
                                {
563
                                        fprintf(
564
                                            output_fp,
565
                                            "\n\n  DATA FAULT ON LOADING CARD No: %d: ITAG "
566
                                            "STEP1: %d IS GREATER THAN ITAG STEP2: %d",
567
                                            zload.nload,
568
                                            itmp3,
569
                                            itmp4);
570
                                        stop(-1);
571
                                }
572
 
573
                                zlr[idx] = tmp1;
574
                                zli[idx] = tmp2;
575
                                zlc[idx] = tmp3;
576
                        }
577
 
578
                                continue; /* continue card input loop */
579
 
580
                        case 2: /* "gn" card, ground parameters under the antenna */
581
 
582
                                iflow = 4;
583
 
584
                                if (igo > 2)
585
                                        igo = 2;
586
 
587
                                if (itmp1 == -1)
588
                                {
589
                                        gnd.ksymp = 1;
590
                                        gnd.nradl = 0;
591
                                        gnd.iperf = 0;
592
                                        continue; /* continue card input loop */
593
                                }
594
 
595
                                gnd.iperf = itmp1;
596
                                gnd.nradl = itmp2;
597
                                gnd.ksymp = 2;
598
                                save.epsr = tmp1;
599
                                save.sig = tmp2;
600
 
601
                                if (gnd.nradl != 0)
602
                                {
603
                                        if (gnd.iperf == 2)
604
                                        {
605
                                                fprintf(
606
                                                    output_fp,
607
                                                    "\n\n  RADIAL WIRE G.S. APPROXIMATION MAY "
608
                                                    "NOT BE USED WITH SOMMERFELD GROUND "
609
                                                    "OPTION");
610
                                                stop(-1);
611
                                        }
612
 
613
                                        save.scrwlt = tmp3;
614
                                        save.scrwrt = tmp4;
615
                                        continue; /* continue card input loop */
616
                                }
617
 
618
                                fpat.epsr2 = tmp3;
619
                                fpat.sig2 = tmp4;
620
                                fpat.clt = tmp5;
621
                                fpat.cht = tmp6;
622
 
623
                                continue; /* continue card input loop */
624
 
625
                        case 3: /* "ex" card, excitation parameters */
626
 
627
                                if (iflow != 5)
628
                                {
629
                                        /* Free vsource buffers */
630
                                        free_ptr((void *)&vsorc.ivqd);
631
                                        free_ptr((void *)&vsorc.iqds);
632
                                        free_ptr((void *)&vsorc.vqd);
633
                                        free_ptr((void *)&vsorc.vqds);
634
                                        free_ptr((void *)&vsorc.isant);
635
                                        free_ptr((void *)&vsorc.vsant);
636
 
637
                                        vsorc.nsant = 0;
638
                                        vsorc.nvqd = 0;
639
                                        iped = 0;
640
                                        iflow = 5;
641
                                        if (igo > 3)
642
                                                igo = 3;
643
                                }
644
 
645
                                fpat.ixtyp = itmp1;
646
                                netcx.masym = itmp4 / 10;
647
                                if ((itmp1 == 0) || (itmp1 == 5))
648
                                {
649
                                        netcx.ntsol = 0;
650
 
651
                                        if (fpat.ixtyp == 5)
652
                                        {
653
                                                vsorc.nvqd++;
654
                                                mem_realloc(
655
                                                    (void *)&vsorc.ivqd,
656
                                                    vsorc.nvqd * sizeof(int));
657
                                                mem_realloc(
658
                                                    (void *)&vsorc.iqds,
659
                                                    vsorc.nvqd * sizeof(int));
660
                                                mem_realloc(
661
                                                    (void *)&vsorc.vqd,
662
                                                    vsorc.nvqd * sizeof(complex double));
663
                                                mem_realloc(
664
                                                    (void *)&vsorc.vqds,
665
                                                    vsorc.nvqd * sizeof(complex double));
666
 
667
                                                {
668
                                                        int indx = vsorc.nvqd - 1;
669
 
670
                                                        vsorc.ivqd[indx] =
671
                                                            isegno(itmp2, itmp3);
672
                                                        vsorc.vqd[indx] = cmplx(tmp1, tmp2);
673
                                                        if (cabsl(vsorc.vqd[indx]) < 1.e-20)
674
                                                                vsorc.vqd[indx] = CPLX_10;
675
 
676
                                                        iped = itmp4 - netcx.masym * 10;
677
                                                        zpnorm = tmp3;
678
                                                        if ((iped == 1) && (zpnorm > 0.0))
679
                                                                iped = 2;
680
                                                        continue; /* continue card input loop
681
                                                                   */
682
                                                }
683
 
684
                                        } /* if( fpat.ixtyp == 5) */
685
 
686
                                        vsorc.nsant++;
687
                                        mem_realloc(
688
                                            (void *)&vsorc.isant, vsorc.nsant * sizeof(int));
689
                                        mem_realloc(
690
                                            (void *)&vsorc.vsant,
691
                                            vsorc.nsant * sizeof(complex double));
692
 
693
                                        {
694
                                                int indx = vsorc.nsant - 1;
695
 
696
                                                vsorc.isant[indx] = isegno(itmp2, itmp3);
697
                                                vsorc.vsant[indx] = cmplx(tmp1, tmp2);
698
                                                if (cabsl(vsorc.vsant[indx]) < 1.e-20)
699
                                                        vsorc.vsant[indx] = CPLX_10;
700
 
701
                                                iped = itmp4 - netcx.masym * 10;
702
                                                zpnorm = tmp3;
703
                                                if ((iped == 1) && (zpnorm > 0.0))
704
                                                        iped = 2;
705
                                                continue; /* continue card input loop */
706
                                        }
707
 
708
                                } /* if( (itmp1 <= 0) || (itmp1 == 5) ) */
709
 
710
                                nthi = itmp2;
711
                                nphi = itmp3;
712
                                xpr1 = tmp1;
713
                                xpr2 = tmp2;
714
                                xpr3 = tmp3;
715
                                xpr4 = tmp4;
716
                                xpr5 = tmp5;
717
                                fpat.xpr6 = tmp6;
718
                                vsorc.nsant = 0;
719
                                vsorc.nvqd = 0;
720
                                thetis = xpr1;
721
                                phiss = xpr2;
722
 
723
                                continue; /* continue card input loop */
724
 
725
                        case 4:
726
                        case 5: /* "nt" & "tl" cards, network parameters */
727
                        {
728
                                int idx;
729
 
730
                                if (iflow != 6)
731
                                {
732
                                        netcx.nonet = 0;
733
                                        netcx.ntsol = 0;
734
                                        iflow = 6;
735
 
736
                                        /* Free network buffers */
737
                                        free_ptr((void *)&netcx.ntyp);
738
                                        free_ptr((void *)&netcx.iseg1);
739
                                        free_ptr((void *)&netcx.iseg2);
740
                                        free_ptr((void *)&netcx.x11r);
741
                                        free_ptr((void *)&netcx.x11i);
742
                                        free_ptr((void *)&netcx.x12r);
743
                                        free_ptr((void *)&netcx.x12i);
744
                                        free_ptr((void *)&netcx.x22r);
745
                                        free_ptr((void *)&netcx.x22i);
746
 
747
                                        if (igo > 3)
748
                                                igo = 3;
749
 
750
                                        if (itmp2 == -1)
751
                                                continue; /* continue card input loop */
752
                                }
753
 
754
                                /* Re-allocate network buffers */
755
                                netcx.nonet++;
756
                                idx = netcx.nonet * sizeof(int);
757
                                mem_realloc((void *)&netcx.ntyp, idx);
758
                                mem_realloc((void *)&netcx.iseg1, idx);
759
                                mem_realloc((void *)&netcx.iseg2, idx);
760
                                idx = netcx.nonet * sizeof(double);
761
                                mem_realloc((void *)&netcx.x11r, idx);
762
                                mem_realloc((void *)&netcx.x11i, idx);
763
                                mem_realloc((void *)&netcx.x12r, idx);
764
                                mem_realloc((void *)&netcx.x12i, idx);
765
                                mem_realloc((void *)&netcx.x22r, idx);
766
                                mem_realloc((void *)&netcx.x22i, idx);
767
 
768
                                idx = netcx.nonet - 1;
769
                                if (ain_num == 4)
770
                                        netcx.ntyp[idx] = 1;
771
                                else
772
                                        netcx.ntyp[idx] = 2;
773
 
774
                                netcx.iseg1[idx] = isegno(itmp1, itmp2);
775
                                netcx.iseg2[idx] = isegno(itmp3, itmp4);
776
                                netcx.x11r[idx] = tmp1;
777
                                netcx.x11i[idx] = tmp2;
778
                                netcx.x12r[idx] = tmp3;
779
                                netcx.x12i[idx] = tmp4;
780
                                netcx.x22r[idx] = tmp5;
781
                                netcx.x22i[idx] = tmp6;
782
 
783
                                if ((netcx.ntyp[idx] == 1) || (tmp1 > 0.))
784
                                        continue; /* continue card input loop */
785
 
786
                                netcx.ntyp[idx] = 3;
787
                                netcx.x11r[idx] = -tmp1;
788
 
789
                                continue; /* continue card input loop */
790
                        }
791
 
792
                        case 6: /* "xq" execute card - calc. including radiated fields */
793
 
794
                                if (((iflow == 10) && (itmp1 == 0)) ||
795
                                    ((nfrq == 1) && (itmp1 == 0) && (iflow > 7)))
796
                                        continue; /* continue card input loop */
797
 
798
                                if (itmp1 == 0)
799
                                {
800
                                        if (iflow > 7)
801
                                                iflow = 11;
802
                                        else
803
                                                iflow = 7;
804
                                }
805
                                else
806
                                {
807
                                        gnd.ifar = 0;
808
                                        fpat.rfld = 0.;
809
                                        fpat.ipd = 0;
810
                                        fpat.iavp = 0;
811
                                        fpat.inor = 0;
812
                                        fpat.iax = 0;
813
                                        fpat.nth = 91;
814
                                        fpat.nph = 1;
815
                                        fpat.thets = 0.;
816
                                        fpat.phis = 0.;
817
                                        fpat.dth = 1.0;
818
                                        fpat.dph = 0.;
819
 
820
                                        if (itmp1 == 2)
821
                                                fpat.phis = 90.;
822
 
823
                                        if (itmp1 == 3)
824
                                        {
825
                                                fpat.nph = 2;
826
                                                fpat.dph = 90.;
827
                                        }
828
 
829
                                } /* if( itmp1 == 0) */
830
 
831
                                break;
832
 
833
                        case 7: /* "gd" card, ground representation */
834
 
835
                                fpat.epsr2 = tmp1;
836
                                fpat.sig2 = tmp2;
837
                                fpat.clt = tmp3;
838
                                fpat.cht = tmp4;
839
                                iflow = 9;
840
 
841
                                continue; /* continue card input loop */
842
 
843
                        case 8: /* "rp" card, standard observation angle parameters */
844
 
845
                                gnd.ifar = itmp1;
846
                                fpat.nth = itmp2;
847
                                fpat.nph = itmp3;
848
 
849
                                if (fpat.nth == 0)
850
                                        fpat.nth = 1;
851
                                if (fpat.nph == 0)
852
                                        fpat.nph = 1;
853
 
854
                                fpat.ipd = itmp4 / 10;
855
                                fpat.iavp = itmp4 - fpat.ipd * 10;
856
                                fpat.inor = fpat.ipd / 10;
857
                                fpat.ipd = fpat.ipd - fpat.inor * 10;
858
                                fpat.iax = fpat.inor / 10;
859
                                fpat.inor = fpat.inor - fpat.iax * 10;
860
 
861
                                if (fpat.iax != 0)
862
                                        fpat.iax = 1;
863
                                if (fpat.ipd != 0)
864
                                        fpat.ipd = 1;
865
                                if ((fpat.nth < 2) || (fpat.nph < 2) || (gnd.ifar == 1))
866
                                        fpat.iavp = 0;
867
 
868
                                fpat.thets = tmp1;
869
                                fpat.phis = tmp2;
870
                                fpat.dth = tmp3;
871
                                fpat.dph = tmp4;
872
                                fpat.rfld = tmp5;
873
                                fpat.gnor = tmp6;
874
                                iflow = 10;
875
 
876
                                break;
877
 
878
                        case 9: /* "nx" card, do next job */
879
                                next_job = TRUE;
880
                                continue; /* continue card input loop */
881
 
882
                        case 10: /* "pt" card, print control for current */
883
 
884
                                iptflg = itmp1;
885
                                iptag = itmp2;
886
                                iptagf = itmp3;
887
                                iptagt = itmp4;
888
 
889
                                if ((itmp3 == 0) && (iptflg != -1))
890
                                        iptflg = -2;
891
                                if (itmp4 == 0)
892
                                        iptagt = iptagf;
893
 
894
                                continue; /* continue card input loop */
895
 
896
                        case 11: /* "kh" card, matrix integration limit */
897
 
898
                                rkh = tmp1;
899
                                if (igo > 2)
900
                                        igo = 2;
901
                                iflow = 1;
902
 
903
                                continue; /* continue card input loop */
904
 
905
                        case 12:
906
                        case 13: /* "ne"/"nh" cards, near field calculation parameters */
907
 
908
                                if (ain_num == 13)
909
                                        fpat.nfeh = 1;
910
                                else
911
                                        fpat.nfeh = 0;
912
 
913
                                if ((iflow == 8) && (nfrq != 1))
914
                                {
915
                                        fprintf(
916
                                            output_fp,
917
                                            "\n\n  WHEN MULTIPLE FREQUENCIES ARE REQUESTED, "
918
                                            "ONLY ONE NEAR FIELD CARD CAN BE USED -"
919
                                            "\n  LAST CARD READ WILL BE USED");
920
                                }
921
 
922
                                fpat.near = itmp1;
923
                                fpat.nrx = itmp2;
924
                                fpat.nry = itmp3;
925
                                fpat.nrz = itmp4;
926
                                fpat.xnr = tmp1;
927
                                fpat.ynr = tmp2;
928
                                fpat.znr = tmp3;
929
                                fpat.dxnr = tmp4;
930
                                fpat.dynr = tmp5;
931
                                fpat.dznr = tmp6;
932
                                iflow = 8;
933
 
934
                                if (nfrq != 1)
935
                                        continue; /* continue card input loop */
936
 
937
                                break;
938
 
939
                        case 14: /* "pq" card, write control for charge */
940
 
941
                                iptflq = itmp1;
942
                                iptaq = itmp2;
943
                                iptaqf = itmp3;
944
                                iptaqt = itmp4;
945
 
946
                                if ((itmp3 == 0) && (iptflq != -1))
947
                                        iptflq = -2;
948
                                if (itmp4 == 0)
949
                                        iptaqt = iptaqf;
950
 
951
                                continue; /* continue card input loop */
952
 
953
                        case 15: /* "ek" card,  extended thin wire kernel option */
954
 
955
                                iexk = 1;
956
                                if (itmp1 == -1)
957
                                        iexk = 0;
958
                                if (igo > 2)
959
                                        igo = 2;
960
                                iflow = 1;
961
 
962
                                continue; /* continue card input loop */
963
                                break;
964
 
965
                        case 16: /* "cp" card, maximum coupling between antennas */
966
 
967
                                if (iflow != 2)
968
                                {
969
                                        yparm.ncoup = 0;
970
                                        free_ptr((void *)&yparm.nctag);
971
                                        free_ptr((void *)&yparm.ncseg);
972
                                        free_ptr((void *)&yparm.y11a);
973
                                        free_ptr((void *)&yparm.y12a);
974
                                }
975
 
976
                                yparm.icoup = 0;
977
                                iflow = 2;
978
 
979
                                if (itmp2 == 0)
980
                                        continue; /* continue card input loop */
981
 
982
                                yparm.ncoup++;
983
                                mem_realloc(
984
                                    (void *)&yparm.nctag, (yparm.ncoup) * sizeof(int));
985
                                mem_realloc(
986
                                    (void *)&yparm.ncseg, (yparm.ncoup) * sizeof(int));
987
                                yparm.nctag[yparm.ncoup - 1] = itmp1;
988
                                yparm.ncseg[yparm.ncoup - 1] = itmp2;
989
 
990
                                if (itmp4 == 0)
991
                                        continue; /* continue card input loop */
992
 
993
                                yparm.ncoup++;
994
                                mem_realloc(
995
                                    (void *)&yparm.nctag, (yparm.ncoup) * sizeof(int));
996
                                mem_realloc(
997
                                    (void *)&yparm.ncseg, (yparm.ncoup) * sizeof(int));
998
                                yparm.nctag[yparm.ncoup - 1] = itmp3;
999
                                yparm.ncseg[yparm.ncoup - 1] = itmp4;
1000
 
1001
                                continue; /* continue card input loop */
1002
 
1003
                        case 17: /* "pl" card, plot flags */
1004
 
1005
                                plot.iplp1 = itmp1;
1006
                                plot.iplp2 = itmp2;
1007
                                plot.iplp3 = itmp3;
1008
                                plot.iplp4 = itmp4;
1009
 
1010
                                if (plot_fp == NULL)
1011
                                {
1012
                                        char plotfile[81];
1013
 
1014
                                        /* Make a plot file name */
1015
                                        strcpy(plotfile, infile);
1016
                                        strcat(plotfile, ".plt");
1017
                                        /* Open plot file */
1018
                                        if ((plot_fp = fopen(plotfile, "w")) == NULL)
1019
                                        {
1020
                                                char mesg[88] = "nec2c: ";
1021
 
1022
                                                strcat(mesg, plotfile);
1023
                                                perror(mesg);
1024
                                                exit(-1);
1025
                                        }
1026
                                }
1027
 
1028
                                continue; /* continue card input loop */
1029
 
1030
                        case 19: /* "wg" card, not supported */
1031
                                abort_on_error(-5);
1032
                                break;
1033
                        default:
1034
                                if (ain_num != 18 && ain_num != 20)
1035
                                {
1036
                                        fprintf(
1037
                                            output_fp,
1038
                                            "\n\n          FAULTY DATA CARD LABEL %d   AFTER "
1039
                                            "GEOMETRY SECTION",
1040
                                            ain_num);
1041
                                        stop(-1);
1042
                                }
1043
 
1044
                                /******************************************************
1045
                                 *** normal exit of nec2c when all jobs complete ok ***
1046
                                 ******************************************************/
1047
 
1048
                                /* time the process */
1049
                                secnds(&tmp1);
1050
                                tmp1 -= extim;
1051
                                fprintf(
1052
                                    output_fp,
1053
                                    "\n\n RUN TIME =     %.3f\n",
1054
                                    (int)tmp1 / 1000.0);
1055
                                stop(0);
1056
                                break;
1057
 
1058
                        } /* switch( ain_num ) */
1059
 
1060
                        /**************************************
1061
                         *** end of the main input section. ***
1062
                         *** beginning of frequency do loop ***
1063
                         **************************************/
1064
 
1065
                        /* Allocate to normalization buffer */
1066
                        {
1067
                                int mreq1, mreq2;
1068
 
1069
                                mreq1 = mreq2 = 0;
1070
                                if (iped)
1071
                                        mreq1 = 4 * nfrq * sizeof(double);
1072
                                if (iptflg >= 2)
1073
                                        mreq2 = nthi * nphi * sizeof(double);
1074
 
1075
                                if ((mreq1 > 0) || (mreq2 > 0))
1076
                                {
1077
                                        if (mreq1 > mreq2)
1078
                                                mem_realloc((void *)&fnorm, mreq1);
1079
                                        else
1080
                                                mem_realloc((void *)&fnorm, mreq2);
1081
                                }
1082
                        }
1083
 
1084
                        /* igox is used in place of "igo" in the   */
1085
                        /* freq loop. below is a special igox case */
1086
                        if (((ain_num == 6) || (ain_num == 8)) && (igo == 5))
1087
                                igox = 6;
1088
                        else
1089
                                igox = igo;
1090
 
1091
                        switch (igox)
1092
                        {
1093
                        case 1: /* label 41 */
1094
                                /* Memory allocation for primary interacton matrix. */
1095
                                iresrv = data.np2m * (data.np + 2 * data.mp);
1096
                                mem_realloc((void *)&cm, iresrv * sizeof(complex double));
1097
 
1098
                                /* Memory allocation for symmetry array */
1099
                                smat.nop = netcx.neq / netcx.npeq;
1100
                                mem_realloc(
1101
                                    (void *)&smat.ssx,
1102
                                    smat.nop * smat.nop * sizeof(complex double));
1103
 
1104
                                mhz = 1;
1105
 
1106
                                if ((data.n != 0) && (ifrtmw != 1))
1107
                                {
1108
                                        ifrtmw = 1;
1109
                                        for (i = 0; i < data.n; i++)
1110
                                        {
1111
                                                xtemp[i] = data.x[i];
1112
                                                ytemp[i] = data.y[i];
1113
                                                ztemp[i] = data.z[i];
1114
                                                sitemp[i] = data.si[i];
1115
                                                bitemp[i] = data.bi[i];
1116
                                        }
1117
                                }
1118
 
1119
                                if ((data.m != 0) && (ifrtmp != 1))
1120
                                {
1121
                                        ifrtmp = 1;
1122
                                        for (i = 0; i < data.m; i++)
1123
                                        {
1124
                                                j = i + data.n;
1125
                                                xtemp[j] = data.px[i];
1126
                                                ytemp[j] = data.py[i];
1127
                                                ztemp[j] = data.pz[i];
1128
                                                bitemp[j] = data.pbi[i];
1129
                                        }
1130
                                }
1131
 
1132
                                /* irngf is not used (NGF function not implemented) */
1133
                                if (matpar.imat == 0)
1134
                                        fblock(netcx.npeq, netcx.neq, iresrv, data.ipsym);
1135
 
1136
                                /* label 42 */
1137
                                /* frequency do loop */
1138
                                do
1139
                                {
1140
                                        jmp_floop = FALSE;
1141
 
1142
                                        if (mhz != 1)
1143
                                        {
1144
                                                if (ifrq == 1)
1145
                                                        save.fmhz *= delfrq;
1146
                                                else
1147
                                                        save.fmhz += delfrq;
1148
                                        }
1149
 
1150
                                        fr = save.fmhz / CVEL;
1151
                                        data.wlam = CVEL / save.fmhz;
1152
                                        fprintf(
1153
                                            output_fp,
1154
                                            "\n\n\n\n\n"
1155
                                            "                                 "
1156
                                            "- - - - - - FREQUENCY - - - - - -\n\n"
1157
                                            "                                 "
1158
                                            "   FREQUENCY= %10.4E MHZ\n"
1159
                                            "                                 "
1160
                                            "   WAVELENGTH= %10.4E METERS\n\n\n",
1161
                                            save.fmhz,
1162
                                            data.wlam);
1163
 
1164
                                        fprintf(
1165
                                            output_fp,
1166
                                            "\n\n"
1167
                                            "                    "
1168
                                            "APPROXIMATE INTEGRATION EMPLOYED FOR SEGMENTS "
1169
                                            "MORE THAN   %.3lf WAVELENGTHS APART\n",
1170
                                            rkh);
1171
 
1172
                                        /*                      if( iexk == 1)
1173
                                                                  fprintf( output_fp, "\n"
1174
                                                                          " " "THE EXTENDED
1175
                                           THIN WIRE KERNEL WILL BE USED\n" );
1176
                                        */
1177
                                        /* frequency scaling of geometric parameters */
1178
                                        if (data.n != 0)
1179
                                        {
1180
                                                for (i = 0; i < data.n; i++)
1181
                                                {
1182
                                                        data.x[i] = xtemp[i] * fr;
1183
                                                        data.y[i] = ytemp[i] * fr;
1184
                                                        data.z[i] = ztemp[i] * fr;
1185
                                                        data.si[i] = sitemp[i] * fr;
1186
                                                        data.bi[i] = bitemp[i] * fr;
1187
                                                }
1188
                                        }
1189
 
1190
                                        if (data.m != 0)
1191
                                        {
1192
                                                fr2 = fr * fr;
1193
                                                for (i = 0; i < data.m; i++)
1194
                                                {
1195
                                                        j = i + data.n;
1196
                                                        data.px[i] = xtemp[j] * fr;
1197
                                                        data.py[i] = ytemp[j] * fr;
1198
                                                        data.pz[i] = ztemp[j] * fr;
1199
                                                        data.pbi[i] = bitemp[j] * fr2;
1200
                                                }
1201
                                        }
1202
 
1203
                                        igo = 2;
1204
                                        /* fall through */
1205
                                /* label 46 */
1206
                                case 2: /* structure segment loading */
1207
                                        fprintf(
1208
                                            output_fp,
1209
                                            "\n\n\n"
1210
                                            "                               "
1211
                                            "- - - STRUCTURE IMPEDANCE LOADING - - -\n");
1212
 
1213
                                        if (zload.nload != 0)
1214
                                                load(
1215
                                                    ldtyp,
1216
                                                    ldtag,
1217
                                                    ldtagf,
1218
                                                    ldtagt,
1219
                                                    zlr,
1220
                                                    zli,
1221
                                                    zlc);
1222
 
1223
                                        if (zload.nload == 0)
1224
                                                fprintf(
1225
                                                    output_fp,
1226
                                                    "\n"
1227
                                                    "                                   "
1228
                                                    "THIS STRUCTURE IS NOT LOADED\n");
1229
 
1230
                                        fprintf(
1231
                                            output_fp,
1232
                                            "\n\n\n"
1233
                                            "                                  "
1234
                                            "- - - ANTENNA ENVIRONMENT - - -\n");
1235
 
1236
                                        if (gnd.ksymp != 1)
1237
                                        {
1238
                                                gnd.frati = CPLX_10;
1239
 
1240
                                                if (gnd.iperf != 1)
1241
                                                {
1242
                                                        if (save.sig < 0.)
1243
                                                                save.sig = -save.sig /
1244
                                                                           (59.96 * data.wlam);
1245
 
1246
                                                        epsc = cmplx(
1247
                                                            save.epsr,
1248
                                                            -save.sig * data.wlam * 59.96);
1249
                                                        gnd.zrati = 1. / csqrtl(epsc);
1250
                                                        gwav.u = gnd.zrati;
1251
                                                        gwav.u2 = gwav.u * gwav.u;
1252
 
1253
                                                        if (gnd.nradl != 0)
1254
                                                        {
1255
                                                                gnd.scrwl =
1256
                                                                    save.scrwlt / data.wlam;
1257
                                                                gnd.scrwr =
1258
                                                                    save.scrwrt / data.wlam;
1259
                                                                gnd.t1 = CPLX_01 * 2367.067 /
1260
                                                                         (double)gnd.nradl;
1261
                                                                gnd.t2 = gnd.scrwr *
1262
                                                                         (double)gnd.nradl;
1263
 
1264
                                                                fprintf(
1265
                                                                    output_fp,
1266
                                                                    "\n"
1267
                                                                    "                         "
1268
                                                                    "   "
1269
                                                                    "RADIAL WIRE GROUND "
1270
                                                                    "SCREEN\n"
1271
                                                                    "                         "
1272
                                                                    "   "
1273
                                                                    "%d WIRES\n"
1274
                                                                    "                         "
1275
                                                                    "   "
1276
                                                                    "WIRE LENGTH: %8.2f "
1277
                                                                    "METERS\n"
1278
                                                                    "                         "
1279
                                                                    "   "
1280
                                                                    "WIRE RADIUS: %10.3E "
1281
                                                                    "METERS",
1282
                                                                    gnd.nradl,
1283
                                                                    save.scrwlt,
1284
                                                                    save.scrwrt);
1285
 
1286
                                                                fprintf(
1287
                                                                    output_fp,
1288
                                                                    "\n"
1289
                                                                    "                         "
1290
                                                                    "   "
1291
                                                                    "MEDIUM UNDER SCREEN -");
1292
 
1293
                                                        } /* if( gnd.nradl != 0) */
1294
 
1295
                                                        if (gnd.iperf != 2)
1296
                                                                fprintf(
1297
                                                                    output_fp,
1298
                                                                    "\n"
1299
                                                                    "                         "
1300
                                                                    "   "
1301
                                                                    "FINITE GROUND.  "
1302
                                                                    "REFLECTION COEFFICIENT "
1303
                                                                    "APPROXIMATION");
1304
                                                        else
1305
                                                        {
1306
                                                                somnec(
1307
                                                                    save.epsr,
1308
                                                                    save.sig,
1309
                                                                    save.fmhz);
1310
                                                                gnd.frati =
1311
                                                                    (epsc - 1.) / (epsc + 1.);
1312
                                                                if (cabsl(
1313
                                                                        (ggrid.epscf - epsc) /
1314
                                                                        epsc) >= 1.0e-3)
1315
                                                                {
1316
                                                                        fprintf(
1317
                                                                            output_fp,
1318
                                                                            "\n ERROR IN "
1319
                                                                            "GROUND "
1320
                                                                            "PARAMETERS -"
1321
                                                                            "\n COMPLEX "
1322
                                                                            "DIELECTRIC "
1323
                                                                            "CONSTANT FROM "
1324
                                                                            "FILE IS: "
1325
                                                                            "%12.5E%+12.5Ej"
1326
                                                                            "\n               "
1327
                                                                            "                 "
1328
                                                                            "REQUESTED: "
1329
                                                                            "%12.5E%+12.5Ej",
1330
                                                                            print_creall(
1331
                                                                                ggrid.epscf),
1332
                                                                            print_cimagl(
1333
                                                                                ggrid.epscf),
1334
                                                                            print_creall(
1335
                                                                                epsc),
1336
                                                                            print_cimagl(
1337
                                                                                epsc));
1338
                                                                        stop(-1);
1339
                                                                }
1340
 
1341
                                                                fprintf(
1342
                                                                    output_fp,
1343
                                                                    "\n"
1344
                                                                    "                         "
1345
                                                                    "   "
1346
                                                                    "FINITE GROUND.  "
1347
                                                                    "SOMMERFELD SOLUTION");
1348
 
1349
                                                        } /* if( gnd.iperf != 2) */
1350
 
1351
                                                        fprintf(
1352
                                                            output_fp,
1353
                                                            "\n"
1354
                                                            "                            "
1355
                                                            "RELATIVE DIELECTRIC CONST.= "
1356
                                                            "%7.3f\n"
1357
                                                            "                            "
1358
                                                            "CONDUCTIVITY= %10.3E MHOS/METER\n"
1359
                                                            "                            "
1360
                                                            "COMPLEX DIELECTRIC CONSTANT= "
1361
                                                            "%11.4E%+11.4Ej",
1362
                                                            save.epsr,
1363
                                                            save.sig,
1364
                                                            print_creall(epsc),
1365
                                                            print_cimagl(epsc));
1366
 
1367
                                                } /* if( gnd.iperf != 1) */
1368
                                                else
1369
                                                        fprintf(
1370
                                                            output_fp,
1371
                                                            "\n"
1372
                                                            "                                 "
1373
                                                            "           "
1374
                                                            "PERFECT GROUND");
1375
 
1376
                                        } /* if( gnd.ksymp != 1) */
1377
                                        else
1378
                                                fprintf(
1379
                                                    output_fp,
1380
                                                    "\n"
1381
                                                    "                                         "
1382
                                                    "   "
1383
                                                    "FREE SPACE");
1384
 
1385
                                        /* label 50 */
1386
                                        /* fill and factor primary interaction matrix */
1387
                                        secnds(&tim1);
1388
                                        cmset(netcx.neq, cm, rkh, iexk);
1389
                                        secnds(&tim2);
1390
                                        tim = tim2 - tim1;
1391
                                        factrs(netcx.npeq, netcx.neq, cm, save.ip);
1392
                                        secnds(&tim1);
1393
                                        tim2 = tim1 - tim2;
1394
                                        fprintf(
1395
                                            output_fp,
1396
                                            "\n\n\n\n"
1397
                                            "                                - - - MATRIX "
1398
                                            "TIMING - - -\n\n"
1399
 
1400
                                            "                        FILL= %8.3f SEC.,  "
1401
                                            "FACTOR= %8.3f SEC.\n",
1402
                                            tim / 1000.0,
1403
                                            tim2 / 1000.0);
1404
 
1405
                                        igo = 3;
1406
                                        netcx.ntsol = 0;
1407
                                        /* fall through */
1408
                                /* label 53 */
1409
                                case 3: /* excitation set up (right hand side, -e inc.) */
1410
 
1411
                                        nthic = 1;
1412
                                        nphic = 1;
1413
                                        inc = 1;
1414
                                        netcx.nprint = 0;
1415
 
1416
                                        /* l_54 */
1417
                                        do
1418
                                        {
1419
                                                if ((fpat.ixtyp != 0) && (fpat.ixtyp != 5))
1420
                                                {
1421
                                                        if ((iptflg <= 0) || (fpat.ixtyp == 4))
1422
                                                                fprintf(
1423
                                                                    output_fp,
1424
                                                                    "\n\n\n"
1425
                                                                    "                         "
1426
                                                                    "    "
1427
                                                                    "- - - EXCITATION - - -");
1428
 
1429
                                                        tmp5 = TA * xpr5;
1430
                                                        tmp4 = TA * xpr4;
1431
 
1432
                                                        if (fpat.ixtyp == 4)
1433
                                                        {
1434
                                                                tmp1 = xpr1 / data.wlam;
1435
                                                                tmp2 = xpr2 / data.wlam;
1436
                                                                tmp3 = xpr3 / data.wlam;
1437
                                                                tmp6 = fpat.xpr6 /
1438
                                                                       (data.wlam * data.wlam);
1439
 
1440
                                                                fprintf(
1441
                                                                    output_fp,
1442
                                                                    "\n"
1443
                                                                    "                         "
1444
                                                                    "         "
1445
                                                                    "    CURRENT SOURCE\n"
1446
                                                                    "                     -- "
1447
                                                                    "POSITION (METERS) -- "
1448
                                                                    "      ORIENTATION (DEG)\n"
1449
                                                                    "                     X   "
1450
                                                                    "       Y          Z "
1451
                                                                    "      ALPHA        BETA  "
1452
                                                                    " DIPOLE MOMENT\n"
1453
                                                                    "               %10.5f "
1454
                                                                    "%10.5f %10.5f "
1455
                                                                    " %7.2f     %7.2f    "
1456
                                                                    "%8.3f",
1457
                                                                    xpr1,
1458
                                                                    xpr2,
1459
                                                                    xpr3,
1460
                                                                    xpr4,
1461
                                                                    xpr5,
1462
                                                                    fpat.xpr6);
1463
                                                        }
1464
                                                        else
1465
                                                        {
1466
                                                                tmp1 = TA * xpr1;
1467
                                                                tmp2 = TA * xpr2;
1468
                                                                tmp3 = TA * xpr3;
1469
                                                                tmp6 = fpat.xpr6;
1470
 
1471
                                                                if (iptflg <= 0)
1472
                                                                        fprintf(
1473
                                                                            output_fp,
1474
                                                                            "\n  PLANE WAVE - "
1475
                                                                            "THETA: %7.2f "
1476
                                                                            "deg, PHI: %7.2f "
1477
                                                                            "deg,"
1478
                                                                            " ETA=%7.2f DEG, "
1479
                                                                            "TYPE - %s  AXIAL "
1480
                                                                            "RATIO: %6.3f",
1481
                                                                            xpr1,
1482
                                                                            xpr2,
1483
                                                                            xpr3,
1484
                                                                            hpol
1485
                                                                                [fpat.ixtyp -
1486
                                                                                 1],
1487
                                                                            fpat.xpr6);
1488
 
1489
                                                        } /* if( fpat.ixtyp == 4) */
1490
 
1491
                                                } /* if( (fpat.ixtyp  != 0) && (fpat.ixtyp <=
1492
                                                     4) ) */
1493
 
1494
                                                /* fills e field right-hand matrix */
1495
                                                etmns(
1496
                                                    tmp1,
1497
                                                    tmp2,
1498
                                                    tmp3,
1499
                                                    tmp4,
1500
                                                    tmp5,
1501
                                                    tmp6,
1502
                                                    fpat.ixtyp,
1503
                                                    crnt.cur);
1504
 
1505
                                                /* matrix solving  (netwk calls solves) */
1506
                                                if ((netcx.nonet != 0) && (inc <= 1))
1507
                                                {
1508
                                                        fprintf(
1509
                                                            output_fp,
1510
                                                            "\n\n\n"
1511
                                                            "                                 "
1512
                                                            "           "
1513
                                                            "- - - NETWORK DATA - - -");
1514
 
1515
                                                        itmp3 = 0;
1516
                                                        itmp1 = netcx.ntyp[0];
1517
 
1518
                                                        for (i = 0; i < 2; i++)
1519
                                                        {
1520
                                                                if (itmp1 == 3)
1521
                                                                        itmp1 = 2;
1522
 
1523
                                                                if (itmp1 == 2)
1524
                                                                        fprintf(
1525
                                                                            output_fp,
1526
                                                                            "\n"
1527
                                                                            "  -- FROM -  --- "
1528
                                                                            "TO --      "
1529
                                                                            "TRANSMISSION "
1530
                                                                            "LINE       "
1531
                                                                            " --------- SHUNT "
1532
                                                                            "ADMITTANCES "
1533
                                                                            "(MHOS) --------- "
1534
                                                                            "  LINE\n"
1535
                                                                            "  TAG   SEG  TAG "
1536
                                                                            "  SEG    "
1537
                                                                            "IMPEDANCE      "
1538
                                                                            "LENGTH    "
1539
                                                                            " ----- END ONE "
1540
                                                                            "-----      ----- "
1541
                                                                            "END TWO -----   "
1542
                                                                            "TYPE\n"
1543
                                                                            "  NO:   NO:  NO: "
1544
                                                                            "  NO:         "
1545
                                                                            "OHMS      METERS "
1546
                                                                            "    "
1547
                                                                            " REAL      "
1548
                                                                            "IMAGINARY      "
1549
                                                                            "REAL      "
1550
                                                                            "IMAGINARY");
1551
                                                                else if (itmp1 == 1)
1552
                                                                        fprintf(
1553
                                                                            output_fp,
1554
                                                                            "\n"
1555
                                                                            "  -- FROM -  --- "
1556
                                                                            "TO --            "
1557
                                                                            "--------"
1558
                                                                            " ADMITTANCE "
1559
                                                                            "MATRIX ELEMENTS "
1560
                                                                            "(MHOS) "
1561
                                                                            "---------\n"
1562
                                                                            "  TAG   SEG  TAG "
1563
                                                                            "  SEG   ----- "
1564
                                                                            "(ONE,ONE) ------ "
1565
                                                                            " "
1566
                                                                            " ----- (ONE,TWO) "
1567
                                                                            "-----   ----- "
1568
                                                                            "(TWO,TWO) "
1569
                                                                            "-------\n"
1570
                                                                            "  NO:   NO:  NO: "
1571
                                                                            "  NO:      REAL  "
1572
                                                                            "    IMAGINARY    "
1573
                                                                            " "
1574
                                                                            " REAL     "
1575
                                                                            "IMAGINARY       "
1576
                                                                            "REAL      "
1577
                                                                            "IMAGINARY");
1578
 
1579
                                                                for (j = 0; j < netcx.nonet;
1580
                                                                     j++)
1581
                                                                {
1582
                                                                        itmp2 = netcx.ntyp[j];
1583
 
1584
                                                                        if ((itmp2 / itmp1) !=
1585
                                                                            1)
1586
                                                                                itmp3 = itmp2;
1587
                                                                        else
1588
                                                                        {
1589
                                                                                int idx4, idx5;
1590
 
1591
                                                                                itmp4 =
1592
                                                                                    netcx.iseg1
1593
                                                                                        [j];
1594
                                                                                itmp5 =
1595
                                                                                    netcx.iseg2
1596
                                                                                        [j];
1597
                                                                                idx4 =
1598
                                                                                    itmp4 - 1;
1599
                                                                                idx5 =
1600
                                                                                    itmp5 - 1;
1601
 
1602
                                                                                if ((itmp2 >=
1603
                                                                                     2) &&
1604
                                                                                    (netcx.x11i
1605
                                                                                         [j] <=
1606
                                                                                     0.))
1607
                                                                                {
1608
                                                                                        double
1609
                                                                                            xx,
1610
                                                                                            yy,
1611
                                                                                            zz;
1612
 
1613
                                                                                        xx =
1614
                                                                                            data.x
1615
                                                                                                [idx5] -
1616
                                                                                            data.x
1617
                                                                                                [idx4];
1618
                                                                                        yy =
1619
                                                                                            data.y
1620
                                                                                                [idx5] -
1621
                                                                                            data.y
1622
                                                                                                [idx4];
1623
                                                                                        zz =
1624
                                                                                            data.z
1625
                                                                                                [idx5] -
1626
                                                                                            data.z
1627
                                                                                                [idx4];
1628
                                                                                        netcx.x11i
1629
                                                                                            [j] =
1630
                                                                                            data.wlam *
1631
                                                                                            sqrtl(
1632
                                                                                                xx *
1633
                                                                                                    xx +
1634
                                                                                                yy *
1635
                                                                                                    yy +
1636
                                                                                                zz *
1637
                                                                                                    zz);
1638
                                                                                }
1639
 
1640
                                                                                fprintf(
1641
                                                                                    output_fp,
1642
                                                                                    "\n"
1643
                                                                                    " %4d %5d "
1644
                                                                                    "%4d %5d  "
1645
                                                                                    "%11.4E "
1646
                                                                                    "%11.4E  "
1647
                                                                                    "%11.4E "
1648
                                                                                    "%11.4E  "
1649
                                                                                    "%11.4E "
1650
                                                                                    "%11.4E "
1651
                                                                                    "%s",
1652
                                                                                    data.itag
1653
                                                                                        [idx4],
1654
                                                                                    itmp4,
1655
                                                                                    data.itag
1656
                                                                                        [idx5],
1657
                                                                                    itmp5,
1658
                                                                                    netcx.x11r
1659
                                                                                        [j],
1660
                                                                                    netcx.x11i
1661
                                                                                        [j],
1662
                                                                                    netcx.x12r
1663
                                                                                        [j],
1664
                                                                                    netcx.x12i
1665
                                                                                        [j],
1666
                                                                                    netcx.x22r
1667
                                                                                        [j],
1668
                                                                                    netcx.x22i
1669
                                                                                        [j],
1670
                                                                                    pnet
1671
                                                                                        [itmp2 -
1672
                                                                                         1]);
1673
 
1674
                                                                        } /* if(( itmp2/ itmp1)
1675
                                                                             == 1) */
1676
 
1677
                                                                } /* for( j = 0; j <
1678
                                                                     netcx.nonet; j++) */
1679
 
1680
                                                                if (itmp3 == 0)
1681
                                                                        break;
1682
 
1683
                                                                itmp1 = itmp3;
1684
 
1685
                                                        } /* for( j = 0; j < netcx.nonet; j++)
1686
                                                           */
1687
 
1688
                                                } /* if( (netcx.nonet != 0) && (inc <= 1) ) */
1689
 
1690
                                                if ((inc > 1) && (iptflg > 0))
1691
                                                        netcx.nprint = 1;
1692
 
1693
                                                netwk(cm, save.ip, crnt.cur);
1694
                                                netcx.ntsol = 1;
1695
 
1696
                                                if (iped != 0)
1697
                                                {
1698
                                                        itmp1 = 4 * (mhz - 1);
1699
 
1700
                                                        fnorm[itmp1] = creall(netcx.zped);
1701
                                                        fnorm[itmp1 + 1] = cimagl(netcx.zped);
1702
                                                        fnorm[itmp1 + 2] = cabsl(netcx.zped);
1703
                                                        fnorm[itmp1 + 3] = cang(netcx.zped);
1704
 
1705
                                                        if (iped != 2)
1706
                                                        {
1707
                                                                if (fnorm[itmp1 + 2] > zpnorm)
1708
                                                                        zpnorm =
1709
                                                                            fnorm[itmp1 + 2];
1710
                                                        }
1711
 
1712
                                                } /* if( iped != 0) */
1713
 
1714
                                                /* printing structure currents */
1715
                                                if (data.n != 0)
1716
                                                {
1717
                                                        if (iptflg != -1)
1718
                                                        {
1719
                                                                if (iptflg <= 0)
1720
                                                                {
1721
                                                                        fprintf(
1722
                                                                            output_fp,
1723
                                                                            "\n\n\n\n"
1724
                                                                            "                 "
1725
                                                                            "            "
1726
                                                                            "- - - CURRENTS "
1727
                                                                            "AND LOCATION - - "
1728
                                                                            "-\n\n"
1729
                                                                            "                 "
1730
                                                                            "                "
1731
                                                                            "DISTANCES IN "
1732
                                                                            "WAVELENGTHS\n");
1733
 
1734
                                                                        fprintf(
1735
                                                                            output_fp,
1736
                                                                            "\n\n"
1737
                                                                            "  SEG.  TAG    "
1738
                                                                            "COORD. OF SEG. "
1739
                                                                            "CENTER     SEG.  "
1740
                                                                            "     "
1741
                                                                            "     - - - "
1742
                                                                            "CURRENT (AMPS) - "
1743
                                                                            "- -\n"
1744
                                                                            "  NO.   NO.     "
1745
                                                                            "X        Y       "
1746
                                                                            " Z      LENGTH   "
1747
                                                                            "  "
1748
                                                                            "REAL        "
1749
                                                                            "IMAG.       MAG. "
1750
                                                                            "       PHASE");
1751
                                                                }
1752
                                                                else
1753
                                                                {
1754
                                                                        if ((iptflg != 3) &&
1755
                                                                            (inc <= 1))
1756
                                                                                fprintf(
1757
                                                                                    output_fp,
1758
                                                                                    "\n\n\n"
1759
                                                                                    "         "
1760
                                                                                    "         "
1761
                                                                                    "      "
1762
                                                                                    "- - - "
1763
                                                                                    "RECEIVING"
1764
                                                                                    " PATTERN "
1765
                                                                                    "PARAMETER"
1766
                                                                                    "S - - -\n"
1767
                                                                                    "         "
1768
                                                                                    "         "
1769
                                                                                    "      "
1770
                                                                                    "         "
1771
                                                                                    "ETA= "
1772
                                                                                    "%7.2f "
1773
                                                                                    "DEGREES\n"
1774
                                                                                    "         "
1775
                                                                                    "         "
1776
                                                                                    "      "
1777
                                                                                    "         "
1778
                                                                                    "TYPE= "
1779
                                                                                    "%s\n"
1780
                                                                                    "         "
1781
                                                                                    "         "
1782
                                                                                    "      "
1783
                                                                                    "         "
1784
                                                                                    "AXIAL "
1785
                                                                                    "RATIO: "
1786
                                                                                    "%6.3f\n\n"
1787
                                                                                    "         "
1788
                                                                                    "         "
1789
                                                                                    "      "
1790
                                                                                    "THETA    "
1791
                                                                                    " PHI     "
1792
                                                                                    " - "
1793
                                                                                    "CURRENT "
1794
                                                                                    "-    "
1795
                                                                                    "SEG\n"
1796
                                                                                    "         "
1797
                                                                                    "         "
1798
                                                                                    "      "
1799
                                                                                    "(DEG)    "
1800
                                                                                    "(DEG)    "
1801
                                                                                    " MAGNITUD"
1802
                                                                                    "E    "
1803
                                                                                    "PHASE    "
1804
                                                                                    "NO.",
1805
                                                                                    xpr3,
1806
                                                                                    hpol
1807
                                                                                        [fpat.ixtyp -
1808
                                                                                         1],
1809
                                                                                    fpat.xpr6);
1810
 
1811
                                                                } /* if( iptflg <= 0) */
1812
 
1813
                                                        } /* if( iptflg != -1) */
1814
 
1815
                                                        fpat.ploss = 0.;
1816
                                                        itmp1 = 0;
1817
 
1818
                                                        for (i = 0; i < data.n; i++)
1819
                                                        {
1820
                                                                curi = crnt.cur[i] * data.wlam;
1821
                                                                cmag = cabsl(curi);
1822
                                                                ph = cang(curi);
1823
 
1824
                                                                if ((zload.nload != 0) &&
1825
                                                                    (fabsl(creall(
1826
                                                                         zload.zarray[i])) >=
1827
                                                                     1.e-20))
1828
                                                                        fpat.ploss +=
1829
                                                                            0.5 * cmag * cmag *
1830
                                                                            creall(
1831
                                                                                zload.zarray
1832
                                                                                    [i]) *
1833
                                                                            data.si[i];
1834
 
1835
                                                                if (iptflg == -1)
1836
                                                                        continue;
1837
 
1838
                                                                if (iptflg >= 0)
1839
                                                                {
1840
                                                                        if ((iptag != 0) &&
1841
                                                                            (data.itag[i] !=
1842
                                                                             iptag))
1843
                                                                                continue;
1844
 
1845
                                                                        itmp1++;
1846
                                                                        if ((itmp1 < iptagf) ||
1847
                                                                            (itmp1 > iptagt))
1848
                                                                                continue;
1849
 
1850
                                                                        if (iptflg != 0)
1851
                                                                        {
1852
                                                                                if (iptflg >=
1853
                                                                                    2)
1854
                                                                                {
1855
                                                                                        fnorm
1856
                                                                                            [inc -
1857
                                                                                             1] =
1858
                                                                                                cmag;
1859
                                                                                        isave =
1860
                                                                                            (i +
1861
                                                                                             1);
1862
                                                                                }
1863
 
1864
                                                                                if (iptflg !=
1865
                                                                                    3)
1866
                                                                                {
1867
                                                                                        fprintf(
1868
                                                                                            output_fp,
1869
                                                                                            "\n"
1870
                                                                                            " "
1871
                                                                                            " "
1872
                                                                                            " "
1873
                                                                                            " "
1874
                                                                                            " "
1875
                                                                                            " "
1876
                                                                                            " "
1877
                                                                                            " "
1878
                                                                                            " "
1879
                                                                                            " "
1880
                                                                                            " "
1881
                                                                                            " "
1882
                                                                                            " "
1883
                                                                                            " "
1884
                                                                                            " "
1885
                                                                                            " "
1886
                                                                                            " "
1887
                                                                                            " "
1888
                                                                                            " "
1889
                                                                                            " "
1890
                                                                                            " "
1891
                                                                                            " "
1892
                                                                                            "%"
1893
                                                                                            "7"
1894
                                                                                            "."
1895
                                                                                            "2"
1896
                                                                                            "f"
1897
                                                                                            " "
1898
                                                                                            "%"
1899
                                                                                            "7"
1900
                                                                                            "."
1901
                                                                                            "2"
1902
                                                                                            "f"
1903
                                                                                            " "
1904
                                                                                            " "
1905
                                                                                            "%"
1906
                                                                                            "1"
1907
                                                                                            "1"
1908
                                                                                            "."
1909
                                                                                            "4"
1910
                                                                                            "E"
1911
                                                                                            " "
1912
                                                                                            " "
1913
                                                                                            "%"
1914
                                                                                            "7"
1915
                                                                                            "."
1916
                                                                                            "2"
1917
                                                                                            "f"
1918
                                                                                            " "
1919
                                                                                            " "
1920
                                                                                            "%"
1921
                                                                                            "5"
1922
                                                                                            "d",
1923
                                                                                            xpr1,
1924
                                                                                            xpr2,
1925
                                                                                            cmag,
1926
                                                                                            ph,
1927
                                                                                            i + 1);
1928
                                                                                        continue;
1929
                                                                                }
1930
 
1931
                                                                        } /* if( iptflg != 0)
1932
                                                                           */
1933
                                                                        else
1934
                                                                                fprintf(
1935
                                                                                    output_fp,
1936
                                                                                    "\n"
1937
                                                                                    " %5d %4d "
1938
                                                                                    "%8.4f "
1939
                                                                                    "%8.4f "
1940
                                                                                    "%8.4f "
1941
                                                                                    "%8.5f"
1942
                                                                                    "  %11.4E "
1943
                                                                                    "%11.4E "
1944
                                                                                    "%11.4E "
1945
                                                                                    "%8.3f",
1946
                                                                                    i + 1,
1947
                                                                                    data.itag
1948
                                                                                        [i],
1949
                                                                                    data.x[i],
1950
                                                                                    data.y[i],
1951
                                                                                    data.z[i],
1952
                                                                                    data.si[i],
1953
                                                                                    print_creall(
1954
                                                                                        curi),
1955
                                                                                    print_cimagl(
1956
                                                                                        curi),
1957
                                                                                    cmag,
1958
                                                                                    ph);
1959
 
1960
                                                                } /* if( iptflg >= 0 ) */
1961
                                                                else
1962
                                                                {
1963
                                                                        fprintf(
1964
                                                                            output_fp,
1965
                                                                            "\n"
1966
                                                                            " %5d %4d %8.4f "
1967
                                                                            "%8.4f %8.4f %8.5f"
1968
                                                                            "  %11.4E %11.4E "
1969
                                                                            "%11.4E %8.3f",
1970
                                                                            i + 1,
1971
                                                                            data.itag[i],
1972
                                                                            data.x[i],
1973
                                                                            data.y[i],
1974
                                                                            data.z[i],
1975
                                                                            data.si[i],
1976
                                                                            print_creall(
1977
                                                                                curi),
1978
                                                                            print_cimagl(
1979
                                                                                curi),
1980
                                                                            cmag,
1981
                                                                            ph);
1982
 
1983
                                                                        if (plot.iplp1 != 1)
1984
                                                                                continue;
1985
 
1986
                                                                        if (plot.iplp2 == 1)
1987
                                                                                fprintf(
1988
                                                                                    plot_fp,
1989
                                                                                    "%12.4E "
1990
                                                                                    "%12.4E\n",
1991
                                                                                    print_creall(
1992
                                                                                        curi),
1993
                                                                                    print_cimagl(
1994
                                                                                        curi));
1995
                                                                        else if (
1996
                                                                            plot.iplp2 == 2)
1997
                                                                                fprintf(
1998
                                                                                    plot_fp,
1999
                                                                                    "%12.4E "
2000
                                                                                    "%12.4E\n",
2001
                                                                                    cmag,
2002
                                                                                    ph);
2003
                                                                }
2004
 
2005
                                                        } /* for( i = 0; i < n; i++ ) */
2006
 
2007
                                                        if (iptflq != -1)
2008
                                                        {
2009
                                                                fprintf(
2010
                                                                    output_fp,
2011
                                                                    "\n\n\n"
2012
                                                                    "                         "
2013
                                                                    "         "
2014
                                                                    "- - - CHARGE DENSITIES - "
2015
                                                                    "- -\n"
2016
                                                                    "                         "
2017
                                                                    "         "
2018
                                                                    "   DISTANCES IN "
2019
                                                                    "WAVELENGTHS\n\n"
2020
                                                                    "   SEG   TAG    "
2021
                                                                    "COORDINATES OF SEG "
2022
                                                                    "CENTER     SEG        "
2023
                                                                    "  CHARGE DENSITY "
2024
                                                                    "(COULOMBS/METER)\n"
2025
                                                                    "   NO.   NO.     X       "
2026
                                                                    "  Y         Z       "
2027
                                                                    "LENGTH   "
2028
                                                                    "  REAL      IMAGINARY    "
2029
                                                                    " MAGN       PHASE");
2030
 
2031
                                                                itmp1 = 0;
2032
                                                                fr = 1.e-6 / save.fmhz;
2033
 
2034
                                                                for (i = 0; i < data.n; i++)
2035
                                                                {
2036
                                                                        if (iptflq != -2)
2037
                                                                        {
2038
                                                                                if ((iptaq !=
2039
                                                                                     0) &&
2040
                                                                                    (data.itag
2041
                                                                                         [i] !=
2042
                                                                                     iptaq))
2043
                                                                                        continue;
2044
 
2045
                                                                                itmp1++;
2046
                                                                                if ((itmp1 <
2047
                                                                                     iptaqf) ||
2048
                                                                                    (itmp1 >
2049
                                                                                     iptaqt))
2050
                                                                                        continue;
2051
 
2052
                                                                        } /* if( iptflq == -2)
2053
                                                                           */
2054
 
2055
                                                                        curi =
2056
                                                                            fr *
2057
                                                                            cmplx(
2058
                                                                                -crnt.bii[i],
2059
                                                                                crnt.bir[i]);
2060
                                                                        cmag = cabsl(curi);
2061
                                                                        ph = cang(curi);
2062
 
2063
                                                                        fprintf(
2064
                                                                            output_fp,
2065
                                                                            "\n"
2066
                                                                            " %5d %4d %9.4f "
2067
                                                                            "%9.4f %9.4f %9.5f"
2068
                                                                            " %11.4E %11.4E "
2069
                                                                            "%11.4E %8.3f",
2070
                                                                            i + 1,
2071
                                                                            data.itag[i],
2072
                                                                            data.x[i],
2073
                                                                            data.y[i],
2074
                                                                            data.z[i],
2075
                                                                            data.si[i],
2076
                                                                            print_creall(
2077
                                                                                curi),
2078
                                                                            print_cimagl(
2079
                                                                                curi),
2080
                                                                            cmag,
2081
                                                                            ph);
2082
 
2083
                                                                } /* for( i = 0; i < n; i++ )
2084
                                                                   */
2085
 
2086
                                                        } /* if( iptflq != -1) */
2087
 
2088
                                                } /* if( n != 0) */
2089
 
2090
                                                if (data.m != 0)
2091
                                                {
2092
                                                        fprintf(
2093
                                                            output_fp,
2094
                                                            "\n\n\n"
2095
                                                            "                                 "
2096
                                                            "     "
2097
                                                            " - - - - SURFACE PATCH CURRENTS "
2098
                                                            "- - - -\n"
2099
                                                            "                                 "
2100
                                                            "               "
2101
                                                            " DISTANCE IN WAVELENGTHS\n"
2102
                                                            "                                 "
2103
                                                            "               "
2104
                                                            " CURRENT IN AMPS/METER\n\n"
2105
                                                            "                                 "
2106
                                                            "- - SURFACE COMPONENTS - "
2107
                                                            " - - - RECTANGULAR COMPONENTS - "
2108
                                                            "- -\n"
2109
                                                            "  PCH   --- PATCH CENTER ---     "
2110
                                                            "TANGENT VECTOR 1    "
2111
                                                            " TANGENT VECTOR 2    ------- X "
2112
                                                            "------    ------- Y ------   "
2113
                                                            " ------- Z ------\n  NO.    X    "
2114
                                                            "   Y       Z       MAG.    "
2115
                                                            "   PHASE     MAG.       PHASE    "
2116
                                                            "REAL   IMAGINARY    REAL  "
2117
                                                            " IMAGINARY    REAL   IMAGINARY");
2118
 
2119
                                                        j = data.n - 3;
2120
                                                        itmp1 = -1;
2121
 
2122
                                                        for (i = 0; i < data.m; i++)
2123
                                                        {
2124
                                                                j += 3;
2125
                                                                itmp1++;
2126
                                                                ex = crnt.cur[j];
2127
                                                                ey = crnt.cur[j + 1];
2128
                                                                ez = crnt.cur[j + 2];
2129
                                                                eth = ex * data.t1x[itmp1] +
2130
                                                                      ey * data.t1y[itmp1] +
2131
                                                                      ez * data.t1z[itmp1];
2132
                                                                eph = ex * data.t2x[itmp1] +
2133
                                                                      ey * data.t2y[itmp1] +
2134
                                                                      ez * data.t2z[itmp1];
2135
                                                                ethm = cabsl(eth);
2136
                                                                etha = cang(eth);
2137
                                                                ephm = cabsl(eph);
2138
                                                                epha = cang(eph);
2139
 
2140
                                                                fprintf(
2141
                                                                    output_fp,
2142
                                                                    "\n"
2143
                                                                    " %4d %7.3f %7.3f %7.3f "
2144
                                                                    "%9.2E %8.2f %9.2E %8.2f"
2145
                                                                    " %9.2E %9.2E %9.2E %9.2E "
2146
                                                                    "%9.2E %9.2E",
2147
                                                                    i + 1,
2148
                                                                    data.px[itmp1],
2149
                                                                    data.py[itmp1],
2150
                                                                    data.pz[itmp1],
2151
                                                                    ethm,
2152
                                                                    etha,
2153
                                                                    ephm,
2154
                                                                    epha,
2155
                                                                    print_creall(ex),
2156
                                                                    print_cimagl(ex),
2157
                                                                    print_creall(ey),
2158
                                                                    print_cimagl(ey),
2159
                                                                    print_creall(ez),
2160
                                                                    print_cimagl(ez));
2161
 
2162
                                                                if (plot.iplp1 != 1)
2163
                                                                        continue;
2164
 
2165
                                                                if (plot.iplp3 == 1)
2166
                                                                        fprintf(
2167
                                                                            plot_fp,
2168
                                                                            "%12.4E %12.4E\n",
2169
                                                                            print_creall(ex),
2170
                                                                            print_cimagl(ex));
2171
                                                                if (plot.iplp3 == 2)
2172
                                                                        fprintf(
2173
                                                                            plot_fp,
2174
                                                                            "%12.4E %12.4E\n",
2175
                                                                            print_creall(ey),
2176
                                                                            print_cimagl(ey));
2177
                                                                if (plot.iplp3 == 3)
2178
                                                                        fprintf(
2179
                                                                            plot_fp,
2180
                                                                            "%12.4E %12.4E\n",
2181
                                                                            print_creall(ez),
2182
                                                                            print_cimagl(ez));
2183
                                                                if (plot.iplp3 == 4)
2184
                                                                        fprintf(
2185
                                                                            plot_fp,
2186
                                                                            "%12.4E %12.4E "
2187
                                                                            "%12.4E %12.4E "
2188
                                                                            "%12.4E %12.4E\n",
2189
                                                                            print_creall(ex),
2190
                                                                            print_cimagl(ex),
2191
                                                                            print_creall(ey),
2192
                                                                            print_cimagl(ey),
2193
                                                                            print_creall(ez),
2194
                                                                            print_cimagl(ez));
2195
 
2196
                                                        } /* for( i=0; i<m; i++ ) */
2197
 
2198
                                                } /* if( m != 0) */
2199
 
2200
                                                if ((fpat.ixtyp == 0) || (fpat.ixtyp == 5))
2201
                                                {
2202
                                                        tmp1 = netcx.pin - netcx.pnls -
2203
                                                               fpat.ploss;
2204
                                                        tmp2 = 100. * tmp1 / netcx.pin;
2205
 
2206
                                                        fprintf(
2207
                                                            output_fp,
2208
                                                            "\n\n\n\n"
2209
                                                            "                                 "
2210
                                                            "       "
2211
                                                            "- - - POWER BUDGET - - -\n\n"
2212
                                                            "                                 "
2213
                                                            "          "
2214
                                                            "INPUT POWER   = %5.4E WATTS\n"
2215
                                                            "                                 "
2216
                                                            "          "
2217
                                                            "RADIATED POWER= %5.4E WATTS\n"
2218
                                                            "                                 "
2219
                                                            "          "
2220
                                                            "STRUCTURE LOSS= %5.4E WATTS\n"
2221
                                                            "                                 "
2222
                                                            "          "
2223
                                                            "NETWORK LOSS  = %5.4E WATTS\n"
2224
                                                            "                                 "
2225
                                                            "          "
2226
                                                            "EFFICIENCY    = %6.2f PERCENT",
2227
                                                            netcx.pin,
2228
                                                            tmp1,
2229
                                                            fpat.ploss,
2230
                                                            netcx.pnls,
2231
                                                            tmp2);
2232
 
2233
                                                } /* if( (fpat.ixtyp == 0) || (fpat.ixtyp == 5)
2234
                                                     ) */
2235
 
2236
                                                igo = 4;
2237
 
2238
                                                if (yparm.ncoup > 0)
2239
                                                        couple(crnt.cur, data.wlam);
2240
 
2241
                                                if (iflow == 7)
2242
                                                {
2243
                                                        if ((fpat.ixtyp > 0) &&
2244
                                                            (fpat.ixtyp < 4))
2245
                                                        {
2246
                                                                nthic++;
2247
                                                                inc++;
2248
                                                                xpr1 += xpr4;
2249
 
2250
                                                                if (nthic <= nthi)
2251
                                                                        continue; /* continue
2252
                                                                                     excitation
2253
                                                                                     loop */
2254
 
2255
                                                                nthic = 1;
2256
                                                                xpr1 = thetis;
2257
                                                                xpr2 = xpr2 + xpr5;
2258
                                                                nphic++;
2259
 
2260
                                                                if (nphic <= nphi)
2261
                                                                        continue; /* continue
2262
                                                                                     excitation
2263
                                                                                     loop */
2264
 
2265
                                                                break;
2266
 
2267
                                                        } /* if( (fpat.ixtyp >= 1) &&
2268
                                                             (fpat.ixtyp <= 3) ) */
2269
 
2270
                                                        if (nfrq != 1)
2271
                                                        {
2272
                                                                jmp_floop = TRUE;
2273
                                                                break; /* continue the freq
2274
                                                                          loop */
2275
                                                        }
2276
 
2277
                                                        fprintf(output_fp, "\n\n\n");
2278
                                                        jmp_iloop = TRUE;
2279
 
2280
                                                        break; /* continue card input loop */
2281
 
2282
                                                } /*if( iflow == 7) */
2283
                                                  /* fall through */
2284
                                        case 4:   /* label_71 */
2285
                                                igo = 5;
2286
                                                /* fall through */
2287
                                        /* label_72 */
2288
                                        case 5: /* near field calculation */
2289
 
2290
                                                if (fpat.near != -1)
2291
                                                {
2292
                                                        nfpat();
2293
 
2294
                                                        if (mhz == nfrq)
2295
                                                                fpat.near = -1;
2296
 
2297
                                                        if (nfrq == 1)
2298
                                                        {
2299
                                                                fprintf(output_fp, "\n\n\n");
2300
                                                                jmp_iloop = TRUE;
2301
                                                                break; /* continue card input
2302
                                                                          loop */
2303
                                                        }
2304
 
2305
                                                } /* if( fpat.near != -1) */
2306
 
2307
                                                /* fall through */
2308
                                        /* label_78 */
2309
                                        case 6: /* standard far field calculation */
2310
 
2311
                                                if (gnd.ifar != -1)
2312
                                                {
2313
                                                        fpat.pinr = netcx.pin;
2314
                                                        fpat.pnlr = netcx.pnls;
2315
                                                        rdpat();
2316
                                                        fprintf(output_fp, "\n\n\n\n");
2317
                                                }
2318
 
2319
                                                if ((fpat.ixtyp == 0) || (fpat.ixtyp >= 4))
2320
                                                {
2321
                                                        if (mhz == nfrq)
2322
                                                                gnd.ifar = -1;
2323
 
2324
                                                        if (nfrq != 1)
2325
                                                        {
2326
                                                                jmp_floop = TRUE;
2327
                                                                break;
2328
                                                        }
2329
 
2330
                                                        fprintf(output_fp, "\n\n\n");
2331
                                                        jmp_iloop = TRUE;
2332
                                                        break;
2333
 
2334
                                                } /* if( (fpat.ixtyp == 0) || (fpat.ixtyp >= 4)
2335
                                                     ) */
2336
 
2337
                                                nthic++;
2338
                                                inc++;
2339
                                                xpr1 += xpr4;
2340
 
2341
                                                if (nthic <= nthi)
2342
                                                        continue; /* continue excitation loop
2343
                                                                   */
2344
 
2345
                                                nthic = 1;
2346
                                                xpr1 = thetis;
2347
                                                xpr2 += xpr5;
2348
                                                nphic++;
2349
 
2350
                                                if (nphic > nphi)
2351
                                                        break;
2352
 
2353
                                        } /* do (l_54) */
2354
                                        while (TRUE);
2355
 
2356
                                        /* jump to freq. or input loop */
2357
                                        if (jmp_iloop)
2358
                                                break;
2359
 
2360
                                        if (jmp_floop)
2361
                                                continue;
2362
 
2363
                                        nphic = 1;
2364
                                        xpr2 = phiss;
2365
 
2366
                                        /* normalized receiving pattern printed */
2367
                                        if (iptflg >= 2)
2368
                                        {
2369
                                                itmp1 = nthi * nphi;
2370
 
2371
                                                tmp1 = fnorm[0];
2372
                                                for (j = 1; j < itmp1; j++)
2373
                                                        if (fnorm[j] > tmp1)
2374
                                                                tmp1 = fnorm[j];
2375
 
2376
                                                fprintf(
2377
                                                    output_fp,
2378
                                                    "\n\n\n"
2379
                                                    "                     "
2380
                                                    "---- NORMALIZED RECEIVING PATTERN ----\n"
2381
                                                    "                      "
2382
                                                    "NORMALIZATION FACTOR: %11.4E\n"
2383
                                                    "                      "
2384
                                                    "ETA: %7.2f DEGREES\n"
2385
                                                    "                      "
2386
                                                    "TYPE: %s\n"
2387
                                                    "                      AXIAL RATIO: "
2388
                                                    "%6.3f\n"
2389
                                                    "                      SEGMENT No: %d\n\n"
2390
                                                    "                      "
2391
                                                    "THETA     PHI       ---- PATTERN ----\n"
2392
                                                    "                      "
2393
                                                    "(DEG)    (DEG)       DB     MAGNITUDE",
2394
                                                    tmp1,
2395
                                                    xpr3,
2396
                                                    hpol[fpat.ixtyp - 1],
2397
                                                    fpat.xpr6,
2398
                                                    isave);
2399
 
2400
                                                for (j = 0; j < nphi; j++)
2401
                                                {
2402
                                                        itmp2 = nthi * j;
2403
 
2404
                                                        for (i = 0; i < nthi; i++)
2405
                                                        {
2406
                                                                itmp3 = i + itmp2;
2407
 
2408
                                                                if (itmp3 < itmp1)
2409
                                                                {
2410
                                                                        tmp2 = fnorm[itmp3] /
2411
                                                                               tmp1;
2412
                                                                        tmp3 = db20(tmp2);
2413
 
2414
                                                                        fprintf(
2415
                                                                            output_fp,
2416
                                                                            "\n"
2417
                                                                            "                 "
2418
                                                                            "   %7.2f  %7.2f  "
2419
                                                                            " %7.2f  %11.4E",
2420
                                                                            xpr1,
2421
                                                                            xpr2,
2422
                                                                            tmp3,
2423
                                                                            tmp2);
2424
 
2425
                                                                        xpr1 += xpr4;
2426
                                                                }
2427
 
2428
                                                        } /* for( i = 0; i < nthi; i++ ) */
2429
 
2430
                                                        xpr1 = thetis;
2431
                                                        xpr2 += xpr5;
2432
 
2433
                                                } /* for( j = 0; j < nphi; j++ ) */
2434
 
2435
                                                xpr2 = phiss;
2436
 
2437
                                        } /* if( iptflg >= 2) */
2438
 
2439
                                        if (mhz == nfrq)
2440
                                                gnd.ifar = -1;
2441
 
2442
                                        if (nfrq == 1)
2443
                                        {
2444
                                                fprintf(output_fp, "\n\n\n");
2445
                                                jmp_iloop = TRUE;
2446
                                                break; /* continue card input loop */
2447
                                        }
2448
 
2449
                                } /*** do (frequency loop) (l_42) ***/
2450
                                while ((++mhz <= nfrq));
2451
 
2452
                                /* Jump to card input loop */
2453
                                if (jmp_iloop)
2454
                                        break;
2455
 
2456
                                if (iped != 0)
2457
                                {
2458
                                        int iss;
2459
 
2460
                                        if (vsorc.nvqd > 0)
2461
                                                iss = vsorc.ivqd[vsorc.nvqd - 1];
2462
                                        else
2463
                                                iss = vsorc.isant[vsorc.nsant - 1];
2464
 
2465
                                        fprintf(
2466
                                            output_fp,
2467
                                            "\n\n\n"
2468
                                            "                            "
2469
                                            " -------- INPUT IMPEDANCE DATA --------\n"
2470
                                            "                                     "
2471
                                            " SOURCE SEGMENT NO.= %d\n"
2472
                                            "                                  "
2473
                                            " NORMALIZATION FACTOR:%12.5E\n\n"
2474
                                            "              ----------- UNNORMALIZED IMPEDANCE "
2475
                                            "----------  "
2476
                                            "  ------------ NORMALIZED IMPEDANCE -----------\n"
2477
                                            "      FREQ    RESISTANCE    REACTANCE    "
2478
                                            "MAGNITUDE    PHASE  "
2479
                                            "  RESISTANCE    REACTANCE    MAGNITUDE    PHASE\n"
2480
                                            "       MHz       OHMS         OHMS         OHMS  "
2481
                                            "   DEGREES  "
2482
                                            "     OHMS         OHMS         OHMS     DEGREES",
2483
                                            iss,
2484
                                            zpnorm);
2485
 
2486
                                        itmp1 = nfrq;
2487
                                        if (ifrq == 0)
2488
                                                tmp1 = save.fmhz - (nfrq - 1) * delfrq;
2489
                                        else if (ifrq == 1)
2490
                                                tmp1 = save.fmhz / (powl(delfrq, (nfrq - 1)));
2491
 
2492
                                        for (i = 0; i < itmp1; i++)
2493
                                        {
2494
                                                itmp2 = 4 * i;
2495
                                                tmp2 = fnorm[itmp2] / zpnorm;
2496
                                                tmp3 = fnorm[itmp2 + 1] / zpnorm;
2497
                                                tmp4 = fnorm[itmp2 + 2] / zpnorm;
2498
                                                tmp5 = fnorm[itmp2 + 3];
2499
 
2500
                                                fprintf(
2501
                                                    output_fp,
2502
                                                    "\n"
2503
                                                    " %9.3f   %11.4E  %11.4E  %11.4E  %7.2f  "
2504
                                                    " %11.4E  %11.4E  %11.4E  %7.2f",
2505
                                                    tmp1,
2506
                                                    fnorm[itmp2],
2507
                                                    fnorm[itmp2 + 1],
2508
                                                    fnorm[itmp2 + 2],
2509
                                                    fnorm[itmp2 + 3],
2510
                                                    tmp2,
2511
                                                    tmp3,
2512
                                                    tmp4,
2513
                                                    tmp5);
2514
 
2515
                                                if (ifrq == 0)
2516
                                                        tmp1 += delfrq;
2517
                                                else if (ifrq == 1)
2518
                                                        tmp1 *= delfrq;
2519
 
2520
                                        } /* for( i = 0; i < itmp1; i++ ) */
2521
 
2522
                                        fprintf(output_fp, "\n\n\n");
2523
 
2524
                                } /* if( iped != 0) */
2525
 
2526
                                nfrq = 1;
2527
                                mhz = 1;
2528
 
2529
                        } /* switch( igox ) */
2530
 
2531
                } /* while( ! next_job ): Main input section (l_14) */
2532
 
2533
        } /* while(TRUE): Main execution loop (l_1) */
2534
 
2535
        fclose(output_fp);
2536
 
2537
        return (0);
2538
 
2539
} /* end of main() */
2540
 
2541
/*-----------------------------------------------------------------------*/
2542
 
2543
/*  Null_Pointers()
2544
 *
2545
 *  Nulls pointers used in mem_realloc
2546
 */
2547
void Null_Pointers(void)
2548
{
2549
        crnt.air = crnt.aii = NULL;
2550
        crnt.bir = crnt.bii = NULL;
2551
        crnt.cir = crnt.cii = NULL;
2552
        crnt.cur = NULL;
2553
 
2554
        data.x = data.y = data.z = NULL;
2555
        data.x1 = data.y1 = data.z1 = NULL;
2556
        data.x2 = data.y2 = data.z2 = NULL;
2557
        data.si = data.bi = data.sab = NULL;
2558
        data.cab = data.salp = NULL;
2559
        data.itag = data.icon1 = data.icon2 = NULL;
2560
        data.px = data.py = data.pz = NULL;
2561
        data.t1x = data.t1y = data.t1z = NULL;
2562
        data.t2x = data.t2y = data.t2z = NULL;
2563
        data.pbi = data.psalp = NULL;
2564
 
2565
        netcx.ntyp = netcx.iseg1 = netcx.iseg2 = NULL;
2566
        netcx.x11r = netcx.x11i = NULL;
2567
        netcx.x12r = netcx.x12i = NULL;
2568
        netcx.x22r = netcx.x22i = NULL;
2569
 
2570
        save.ip = NULL;
2571
 
2572
        segj.jco = NULL;
2573
        segj.ax = segj.bx = segj.cx = NULL;
2574
 
2575
        smat.ssx = NULL;
2576
 
2577
        vsorc.isant = vsorc.ivqd = vsorc.iqds = NULL;
2578
        vsorc.vqd = vsorc.vqds = vsorc.vsant = NULL;
2579
 
2580
        yparm.y11a = yparm.y12a = NULL;
2581
        yparm.ncseg = yparm.nctag = NULL;
2582
 
2583
        zload.zarray = NULL;
2584
 
2585
} /* Null_Pointers() */
2586
 
2587
/*-----------------------------------------------------------------------*/
2588
 
2589
/* prnt sets up the print formats for impedance loading */
2590
void prnt(
2591
    int in1,
2592
    int in2,
2593
    int in3,
2594
    double fl1,
2595
    double fl2,
2596
    double fl3,
2597
    double fl4,
2598
    double fl5,
2599
    double fl6,
2600
    char *ia,
2601
    int ichar)
2602
{
2603
        /* record to be output and buffer used to make it */
2604
        char record[101 + ichar * 4], buff[15];
2605
        int in[3], i1, i;
2606
        double fl[6];
2607
 
2608
        in[0] = in1;
2609
        in[1] = in2;
2610
        in[2] = in3;
2611
        fl[0] = fl1;
2612
        fl[1] = fl2;
2613
        fl[2] = fl3;
2614
        fl[3] = fl4;
2615
        fl[4] = fl5;
2616
        fl[5] = fl6;
2617
 
2618
        /* integer format */
2619
        i1 = 0;
2620
        strcpy(record, "\n ");
2621
 
2622
        if ((in1 == 0) && (in2 == 0) && (in3 == 0))
2623
        {
2624
                strcat(record, " ALL");
2625
                i1 = 1;
2626
        }
2627
 
2628
        for (i = i1; i < 3; i++)
2629
        {
2630
                if (in[i] == 0)
2631
                        strcat(record, "     ");
2632
                else
2633
                {
2634
                        snprintf(buff, 6, "%5d", in[i]);
2635
                        strcat(record, buff);
2636
                }
2637
        }
2638
 
2639
        /* floating point format */
2640
        for (i = 0; i < 6; i++)
2641
        {
2642
                if (fabsl(fl[i]) >= 1.0e-20)
2643
                {
2644
                        snprintf(buff, 15, " %11.4f", (double)fl[i]);
2645
                        strcat(record, buff);
2646
                }
2647
                else
2648
                        strcat(record, "            ");
2649
        }
2650
 
2651
        strcat(record, "   ");
2652
        strcat(record, ia);
2653
        fprintf(output_fp, "%s", record);
2654
 
2655
        return;
2656
}
2657
 
2658
/*-----------------------------------------------------------------------*/
2659
 
2660
#if defined USE_SIG_HANDLER
2661
static void sig_handler(int signal)
2662
{
2663
        fprintf(stderr, "\n");
2664
        switch (signal)
2665
        {
2666
        case SIGINT:
2667
                fprintf(stderr, "%s\n", "nec2c: exiting via user interrupt");
2668
                exit(signal);
2669
 
2670
        case SIGSEGV:
2671
                fprintf(stderr, "%s\n", "nec2c: segmentation fault");
2672
                exit(signal);
2673
 
2674
        case SIGFPE:
2675
                fprintf(stderr, "%s\n", "nec2c: floating point exception");
2676
                exit(signal);
2677
 
2678
        case SIGABRT:
2679
                fprintf(stderr, "%s\n", "nec2c: abort signal received");
2680
                exit(signal);
2681
 
2682
        case SIGTERM:
2683
                fprintf(stderr, "%s\n", "nec2c: termination request received");
2684
 
2685
                stop(signal);
2686
        }
2687
 
2688
} /* end of sig_handler() */
2689
#endif
2690
/*------------------------------------------------------------------------*/