| 1 | #include <stdlib.h>
 | 
|---|
| 2 | #include <stdio.h>
 | 
|---|
| 3 | #include <cfortran.h>
 | 
|---|
| 4 | #include <packlib.h>
 | 
|---|
| 5 | 
 | 
|---|
| 6 | #define PAWC_SIZE 50000
 | 
|---|
| 7 | 
 | 
|---|
| 8 | typedef float PAWC_DEF[PAWC_SIZE];
 | 
|---|
| 9 | #define PAWC COMMON_BLOCK(PAWC,pawc)
 | 
|---|
| 10 | COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
 | 
|---|
| 11 | 
 | 
|---|
| 12 | main()
 | 
|---|
| 13 | {
 | 
|---|
| 14 |   int record_size=1024;
 | 
|---|
| 15 |   int istat, icycle;
 | 
|---|
| 16 | 
 | 
|---|
| 17 |   HLIMIT(PAWC_SIZE);
 | 
|---|
| 18 | 
 | 
|---|
| 19 |   HROPEN(1,"MYCWN","mycwn.hbook","NX",record_size,istat);
 | 
|---|
| 20 |   if (istat) {
 | 
|---|
| 21 |     printf("Error in opening file ...");
 | 
|---|
| 22 |     return EXIT_FAILURE;
 | 
|---|
| 23 |   }
 | 
|---|
| 24 | 
 | 
|---|
| 25 |   HBNT(1,"MYCWN"," ");
 | 
|---|
| 26 | 
 | 
|---|
| 27 |   {
 | 
|---|
| 28 |   /* Struct is required if defining more than one variable
 | 
|---|
| 29 |      within a single call to HBNAMC or HBNAME.
 | 
|---|
| 30 |      Struct may also be required in order to introduce
 | 
|---|
| 31 |      an aligned variable, see 'int align' below,
 | 
|---|
| 32 |      which ensures that the subsequent character arrays are aligned.
 | 
|---|
| 33 |      HBNAMC requires the characters to be aligned.
 | 
|---|
| 34 |    */
 | 
|---|
| 35 |   struct { int align; char a[8]; char b[3][4];} m;
 | 
|---|
| 36 |   struct { int align; char c[4]; } n;
 | 
|---|
| 37 |   HBNAMC(1,"BLOCK",m.a,"A:C*8,B(3):C");
 | 
|---|
| 38 |   HBNAMC(1,"BLOCK",n.c,"C:C");
 | 
|---|
| 39 | 
 | 
|---|
| 40 | 
 | 
|---|
| 41 |   /* Since HFNT() gets the character info. via
 | 
|---|
| 42 |      an adress stored in the HBNAMC call,
 | 
|---|
| 43 |      there is no way that cfortran.h can convert
 | 
|---|
| 44 |      from C strings to Fortran strings.
 | 
|---|
| 45 |      The character arrays have the same number of bytes in C as they do in
 | 
|---|
| 46 |      Fortran. i.e. there is no room for C's trailing '\0' character.
 | 
|---|
| 47 |      So use strncpy() and blank pad until the ed of the array.
 | 
|---|
| 48 |    */
 | 
|---|
| 49 | 
 | 
|---|
| 50 |   strncpy(m.a,    "hiho1   ",8);
 | 
|---|
| 51 |   strncpy(m.b[0], "ba  ",4);
 | 
|---|
| 52 |   strncpy(m.b[1], "bb  ",4); /* bb and bc don't show in PAW.                  */
 | 
|---|
| 53 |   strncpy(m.b[2], "bc  ",4); /* Either PAW is broken, or how I use cfortran.h.*/
 | 
|---|
| 54 |   strncpy(n.c,    "coco",4);
 | 
|---|
| 55 |   HFNT(1);
 | 
|---|
| 56 | 
 | 
|---|
| 57 |   strncpy(m.a,    "hiho2   ",8);
 | 
|---|
| 58 |   strncpy(m.b[0], "ba2 ",4);
 | 
|---|
| 59 |   strncpy(m.b[1], "bb2 ",4); /* Again bb2 and bc2 don't show in PAW. */
 | 
|---|
| 60 |   strncpy(m.b[2], "bc2 ",4);
 | 
|---|
| 61 |   strncpy(n.c,    "coc2",4);
 | 
|---|
| 62 |   HFNT(1);
 | 
|---|
| 63 |   }
 | 
|---|
| 64 | 
 | 
|---|
| 65 |   HROUT(0,icycle," ");
 | 
|---|
| 66 |   HREND("MYCWN");
 | 
|---|
| 67 |   KUCLOS(1," ",1);
 | 
|---|
| 68 | }
 | 
|---|