Title: | Digital Fortran |
Notice: | Read notes 1.* for important information |
Moderator: | QUARK::LIONEL |
Created: | Thu Jun 01 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 1333 |
Total number of notes: | 6734 |
Hi, I need to find an information about include cdd record in program fortran and how the data are padded/aligned . With the little code below everything is ok structure /item/ character*3 elem1 character*3 elem2 integer*4 elem3 character*5 elem4 end structure record /item/item_list(2) When compiling as fort/noop/deb/show=all/lis/align=record=natural/cross In the lis file we see FIELD SCALARS Offset Field Structure Type Bytes References 00000000 ELEM1 ITEM CHAR 3 4 00000003 ELEM2 ITEM CHAR 3 5 00000008 ELEM3 ITEM I*4 4 6 0000000C ELEM4 ITEM CHAR 5 7 This seem to be normal for ELEM3 offset 8 But if the program include cdd record ,the padding is not there and the offset is at 6 using sqlpreprocessor or fortran v7.1-107. program envoi exec sql include from dictionnary 'cdd_record.reffins0' C record /reffins0/ essai essai.cdev = 'BOF' essai.njour = 60 call lit(%ref(essai)) END program lit #dictionary "cdd$top.bip.record.reffins0"; struct essai { char chaine[3]; int valeur; }; lit(struct reffins0 *val) { int b; b = val->njour; } And definition for dictionnary and compil/link $ set verify $ define cdd$default SYS$COMMON:[CDDPLUS]BIP $ define cdd_record SYS$COMMON:[CDDPLUS]BIP.record $ goto suite $ repos opera define directory field_c. define directory field_n. define directory field_l. define directory field_d. define directory field_h. define field field_c.cdev datatype text size 3. define field field_c.cinstr datatype text size 3. define field field_n.njour datatype signed longword. define field field_l.linstr datatype text size 30. define field field_d.dstk datatype date . define field field_h.hstk datatype signed longword . define directory record. define record record.reffins0 . field_c.cdev. field_c.cinstr. field_n.njour. field_d.dstk. field_h.hstk. end record. exit $ suite: $ sqlpre/fortran/debug/noopt/show=all/lis envoi.sfo $ sqlpre/cc/debug/noopt/show=all/lis lit.sc $ show logical sql$user $ link envoi,lit,sql$user/library $ set noverify In the lis file FIELD SCALARS Offset Field Structure Type Bytes References 00000000 CDEV REFFINS0 CHAR 3 9 32 00000003 CINSTR REFFINS0 CHAR 3 10 00000028 DSTK REFFINS0 STRC 8 13 00000030 HSTK REFFINS0 I*4 4 16 0000000A LINSTR REFFINS0 CHAR 30 12 00000006 NJOUR REFFINS0 I*4 4 11 33 NJOUR is at offset 6 and not 8 The result is the same if compiled directly with fortran/decc and using /pad Normaly it will be correct because the datas are issued from a database and can't be aligned without changing theirs contents .But I need a confirmation.. Thank for any input. Patrice
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
1212.1 | Alignment is picked when you *insert* definition into CDD | WIBBIN::NOYCE | Pulling weeds, pickin' stones | Thu Mar 06 1997 10:09 | 6 |
> Normaly it will be correct because the datas are issued from a database and > can't be aligned without changing theirs contents .But I need a confirmation.. Exactly. The CDD records the actual offset for each member of the structure, so the definition you get in FORTRAN will match the database (or whatever) that the definition is intended to describe. | |||||
1212.2 | QUARK::LIONEL | Free advice is worth every cent | Thu Mar 06 1997 10:44 | 4 | |
Right - in fact we had to teach the compiler to specifically NOT apply its own alignment rules to CDD records. Steve |