File: dyn88n.c

package info (click to toggle)
z88 13.0.0%2Bdfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 107,800 kB
  • ctags: 3,296
  • sloc: ansic: 45,530; sh: 71; makefile: 14
file content (507 lines) | stat: -rw-r--r-- 13,268 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* A FREE Finite Elements Analysis Program in ANSI C for the UNIX OS.
*
* Composed and edited and copyright by 
* Professor Dr.-Ing. Frank Rieg, University of Bayreuth, Germany
*
* eMail: 
* frank.rieg@uni-bayreuth.de
* dr.frank.rieg@t-online.de
* 
* V10.0  December 12, 2001
*
* Z88 should compile and run under any UNIX OS and Motif 2.0.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING.  If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
***********************************************************************/ 
/***********************************************************************
* Function dyn88n liest z88.dyn aus und laesst memory kommen
* hier wird File Z88.DYN geoffnet
* 27.5.2002 Rieg
***********************************************************************/ 

/***********************************************************************
* Fuer UNIX
***********************************************************************/
#ifdef FR_UNIX
#include <z88n.h>
#include <stdio.h>   /* FILE,NULL,fopen,fclose,fgets */
                     /* sscanf,fclose,rewind         */
#include <string.h>  /* strstr */
#include <stdlib.h>  /* FR_CALLOC */
#endif

/***********************************************************************
* Fuer Windows 95
***********************************************************************/
#ifdef FR_WIN95
#include <z88n.h>
#include <stdio.h>   /* FILE,NULL,fopen,fclose,fgets */
                     /* sscanf,fclose,rewind         */
#include <string.h>  /* strstr */
#include <stdlib.h>  /* FR_CALLOC */
#endif

/***********************************************************************
* Functions
***********************************************************************/
int wlog88n(FR_INT4,int);

/***********************************************************************
* hier beginnt Function dyn88n
***********************************************************************/
int dyn88n(void)
{
extern FILE *fdyn, *fwlo;
extern char cdyn[];

extern FR_DOUBLEAY x;
extern FR_DOUBLEAY y;
extern FR_DOUBLEAY z;
extern FR_DOUBLEAY xss;
extern FR_DOUBLEAY yss;
extern FR_DOUBLEAY zss;
extern FR_DOUBLEAY qparass;
extern FR_DOUBLEAY riyyss;
extern FR_DOUBLEAY emodss;
extern FR_DOUBLEAY rnuess;

extern FR_INT4AY koima;
extern FR_INT4AY join; 
extern FR_INT4AY koiss;
extern FR_INT4AY ioffss;
extern FR_INT4AY koffss;
extern FR_INT4AY jel;
extern FR_INT4AY iel;
extern FR_INT4AY kel;
extern FR_INT4AY ivonss;
extern FR_INT4AY ibisss;
extern FR_INT4AY intoss;
extern FR_INT4AY ivon;
extern FR_INT4AY ibis;

extern FR_INT4 MAXSE,MAXESS,MAXKSS,MAXK,MAXE,MAXNFG,MAXNEG,MAXAN;
extern FR_INT4 IDYNMEM;

extern FR_CHARAY cjmode;
extern FR_CHARAY cimode;
extern FR_CHARAY ckmode;

char cline[256], cdummy[80];
  
/*----------------------------------------------------------------------
* Dyn- Datei z88.dyn oeffnen
*---------------------------------------------------------------------*/
wlog88n(0,LOG_OPENDYN);
fdyn= fopen(cdyn,"r");
if(fdyn == NULL)
  {
  wlog88n(0,LOG_NODYN);
  fclose(fwlo);
  return(AL_NODYN);
  }
rewind(fdyn);

/*----------------------------------------------------------------------
* Dyn- Datei z88.dyn lesen
*---------------------------------------------------------------------*/
fgets(cline,256,fdyn);

if( (strstr(cline,"DYNAMIC START"))!= NULL)         /* Lesen File */
  {
  do
    {
    fgets(cline,256,fdyn);

    if( (strstr(cline,"NET START"))!= NULL)         /* Lesen NET */
      {
      do
        {
        fgets(cline,256,fdyn);
        if( (strstr(cline,"MAXSE"))!= NULL)         /* Lesen MAXSE */
          sscanf(cline,"%s %ld",cdummy,&MAXSE);
        if( (strstr(cline,"MAXESS"))!= NULL)        /* Lesen MAXESS */
          sscanf(cline,"%s %ld",cdummy,&MAXESS);
        if( (strstr(cline,"MAXKSS"))!= NULL)        /* Lesen MAXKSS */
          sscanf(cline,"%s %ld",cdummy,&MAXKSS);
        if( (strstr(cline,"MAXAN"))!= NULL)        /* Lesen MAXAN */
          sscanf(cline,"%s %ld",cdummy,&MAXAN);
        }
      while( (strstr(cline,"NET END"))== NULL);
      }

    if( (strstr(cline,"COMMON START"))!= NULL)      /* Lesen COMMON */
      {
      do
        {
        fgets(cline,256,fdyn);
        if( (strstr(cline,"MAXK"))!= NULL)          /* Lesen MAXK */
          sscanf(cline,"%s %ld",cdummy,&MAXK);
        if( (strstr(cline,"MAXE"))!= NULL)          /* Lesen MAXE */
          sscanf(cline,"%s %ld",cdummy,&MAXE);
        if( (strstr(cline,"MAXNFG"))!= NULL)        /* Lesen MAXNFG */
          sscanf(cline,"%s %ld",cdummy,&MAXNFG);
        if( (strstr(cline,"MAXNEG"))!= NULL)        /* Lesen MAXNEG */
          sscanf(cline,"%s %ld",cdummy,&MAXNEG);
        }
      while( (strstr(cline,"COMMON END"))== NULL);
      }                                             /* end if COMMON START */

    }
  while( (strstr(cline,"DYNAMIC END"))== NULL);     
    
  }                                                 /* end if DYNAMIC START */
else
  {
  wlog88n(0,LOG_WRONGDYN);
  fclose(fwlo);
  return(AL_WRONGDYN);
  }  

if(MAXSE <= 0 || MAXESS <= 0 || MAXKSS <= 0 || MAXK <= 0 ||
   MAXE <= 0 || MAXNFG <= 0 || MAXNEG <= 0 || MAXAN <= 0)
  {
  wlog88n(0,LOG_WRONGDYN);
  fclose(fwlo);
  return(AL_WRONGDYN);
  }  

/*----------------------------------------------------------------------
* korrekt gelesen, File fdyn schliessen
*---------------------------------------------------------------------*/
fclose(fdyn);

wlog88n(MAXSE,LOG_MAXSE);
wlog88n(MAXESS,LOG_MAXESS);
wlog88n(MAXKSS,LOG_MAXKSS);
wlog88n(MAXAN,LOG_MAXAN);
wlog88n(MAXK,LOG_MAXK);
wlog88n(MAXE,LOG_MAXE);
wlog88n(MAXNFG,LOG_MAXNFG);
wlog88n(MAXNEG,LOG_MAXNEG);
 
wlog88n(0,LOG_OKDYN);

/*----------------------------------------------------------------------
* Memory kommen lassen ..
*---------------------------------------------------------------------*/
wlog88n(0,LOG_ALLOCMEMY);

/*======================================================================
* Memory fuer x, y, z : 1,2,3
*=====================================================================*/
x= (FR_DOUBLEAY) FR_CALLOC(MAXSE,sizeof(FR_DOUBLE));
if(x == NULL)
  {
  wlog88n(1,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(1,LOG_ARRAYOK);

y= (FR_DOUBLEAY) FR_CALLOC(MAXSE,sizeof(FR_DOUBLE));
if(y == NULL)
  {
  wlog88n(2,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(2,LOG_ARRAYOK);

z= (FR_DOUBLEAY) FR_CALLOC(MAXSE,sizeof(FR_DOUBLE));
if(z == NULL)
  {
  wlog88n(3,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(3,LOG_ARRAYOK);

/*======================================================================
* Memory fuer xss, yss, zss: 4,5,6
*=====================================================================*/
xss= (FR_DOUBLEAY) FR_CALLOC(MAXKSS,sizeof(FR_DOUBLE));
if(xss == NULL)
  {
  wlog88n(4,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(4,LOG_ARRAYOK);

yss= (FR_DOUBLEAY) FR_CALLOC(MAXKSS,sizeof(FR_DOUBLE));
if(yss == NULL)
  {
  wlog88n(5,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(5,LOG_ARRAYOK);

zss= (FR_DOUBLEAY) FR_CALLOC(MAXKSS,sizeof(FR_DOUBLE));
if(zss == NULL)
  {
  wlog88n(6,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(6,LOG_ARRAYOK);

/*======================================================================
* Memory fuer qparass, emodss, rnuess, riyyss: 7,8,9,26
*=====================================================================*/
qparass= (FR_DOUBLEAY) FR_CALLOC(MAXNEG,sizeof(FR_DOUBLE));
if(qparass == NULL)
  {
  wlog88n(7,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(7,LOG_ARRAYOK);

emodss= (FR_DOUBLEAY) FR_CALLOC(MAXNEG,sizeof(FR_DOUBLE));
if(emodss == NULL)
  {
  wlog88n(8,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(8,LOG_ARRAYOK);

rnuess= (FR_DOUBLEAY) FR_CALLOC(MAXNEG,sizeof(FR_DOUBLE));
if(rnuess == NULL)
  {
  wlog88n(9,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(9,LOG_ARRAYOK);

riyyss= (FR_DOUBLEAY) FR_CALLOC(MAXNEG,sizeof(FR_DOUBLE));
if(riyyss == NULL)
  {
  wlog88n(26,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(26,LOG_ARRAYOK);

/*======================================================================
* Memory fuer koima, join, koiss: 10,11,12
*=====================================================================*/
koima= (FR_INT4AY) FR_CALLOC(MAXSE,sizeof(FR_INT4));
if(koima == NULL)
  {
  wlog88n(10,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(10,LOG_ARRAYOK);

join= (FR_INT4AY) FR_CALLOC((MAXESS*MAXAN),sizeof(FR_INT4));
if(join == NULL)
  {
  wlog88n(11,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(11,LOG_ARRAYOK);

koiss= (FR_INT4AY) FR_CALLOC((MAXESS*20),sizeof(FR_INT4));
if(koiss == NULL)
  {
  wlog88n(12,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(12,LOG_ARRAYOK);

/*======================================================================
* Memory fuer ioffss, koffss, jel, iel, kel: 13,14,15,16,17
*=====================================================================*/
ioffss= (FR_INT4AY) FR_CALLOC(MAXESS,sizeof(FR_INT4));
if(ioffss == NULL)
  {
  wlog88n(13,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(13,LOG_ARRAYOK);

koffss= (FR_INT4AY) FR_CALLOC(MAXESS,sizeof(FR_INT4));
if(koffss == NULL)
  {
  wlog88n(14,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(14,LOG_ARRAYOK);

jel= (FR_INT4AY) FR_CALLOC(MAXESS,sizeof(FR_INT4));
if(jel == NULL)
  {
  wlog88n(15,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(15,LOG_ARRAYOK);

iel= (FR_INT4AY) FR_CALLOC(MAXESS,sizeof(FR_INT4));
if(iel == NULL)
  {
  wlog88n(16,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(16,LOG_ARRAYOK);

kel= (FR_INT4AY) FR_CALLOC(MAXESS,sizeof(FR_INT4));
if(kel == NULL)
  {
  wlog88n(17,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(17,LOG_ARRAYOK);

/*======================================================================
* Memory fuer ivonss, ibisss, intoss, ivon, ibis: 18,19,20,21,22
*=====================================================================*/
ivonss= (FR_INT4AY) FR_CALLOC(MAXNEG,sizeof(FR_INT4));
if(ivonss == NULL)
  {
  wlog88n(18,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(18,LOG_ARRAYOK);

ibisss= (FR_INT4AY) FR_CALLOC(MAXNEG,sizeof(FR_INT4));
if(ibisss == NULL)
  {
  wlog88n(19,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(19,LOG_ARRAYOK);

intoss= (FR_INT4AY) FR_CALLOC(MAXNEG,sizeof(FR_INT4));
if(intoss == NULL)
  {
  wlog88n(20,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(20,LOG_ARRAYOK);

ivon= (FR_INT4AY) FR_CALLOC(MAXNEG,sizeof(FR_INT4));
if(ivon == NULL)
  {
  wlog88n(21,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(21,LOG_ARRAYOK);

ibis= (FR_INT4AY) FR_CALLOC(MAXNEG,sizeof(FR_INT4));
if(ibis == NULL)
  {
  wlog88n(22,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(22,LOG_ARRAYOK);

/*======================================================================
* Memory fuer cjmode, cimode, ckmode: 23,24,25
*=====================================================================*/
cjmode= (FR_CHARAY) FR_CALLOC(MAXESS,sizeof(char));
if(cjmode == NULL)
  {
  wlog88n(23,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(23,LOG_ARRAYOK);

cimode= (FR_CHARAY) FR_CALLOC(MAXESS,sizeof(char));
if(cimode == NULL)
  {
  wlog88n(24,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(24,LOG_ARRAYOK);

ckmode= (FR_CHARAY) FR_CALLOC(MAXESS,sizeof(char));
if(ckmode == NULL)
  {
  wlog88n(25,LOG_ARRAYNOTOK);
  fclose(fwlo);
  return(AL_NOMEMY);
  }
else
  wlog88n(25,LOG_ARRAYOK);

/***********************************************************************
* alles o.k. 
***********************************************************************/
IDYNMEM = 3*MAXSE*sizeof(FR_DOUBLE);
IDYNMEM+= 3*MAXKSS*sizeof(FR_DOUBLE);
IDYNMEM+= 4*MAXNEG*sizeof(FR_DOUBLE);
IDYNMEM+=   MAXSE *sizeof(FR_INT4);
IDYNMEM+=   MAXESS*MAXAN*sizeof(FR_INT4);
IDYNMEM+=   MAXESS*20*sizeof(FR_INT4);
IDYNMEM+= 5*MAXESS*sizeof(FR_INT4);
IDYNMEM+= 5*MAXNEG*sizeof(FR_INT4);
IDYNMEM+= 3*MAXESS*sizeof(char);

wlog88n(IDYNMEM,LOG_SUMMEMY);
wlog88n(0,LOG_EXITDYN88N);

return(0);
}