Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Misaligned structure fields

Ben136KBC
Novice
366 Views

Any suggestions for cleaning this up, please? I know you can usually do so put inserting dummy variables in the correct location, but with something this large it is hard to guess where.

 

instdata.f90: warning #6379: The structure contains one or more misaligned fields. [SHAREDDATACHUNK]
TYPE SharedDataChunk
-------^

 

 

MODULE SharedData

   INTEGER INEGASX
   PARAMETER (INEGASX = -5)
   integer, parameter :: MAXASSX  = 200
   INTEGER MMIDEXX, MSIDEXX,LYMSTKX
   PARAMETER (MMIDEXX=85000, MSIDEXX=15000,LYMSTKX=250)
   INTEGER MGSSIZX
   PARAMETER (MGSSIZX=100)
   INTEGER iMaxSuppressX
   PARAMETER (iMaxSuppressX=100)
   INTEGER LDBPX,LPX
   PARAMETER ( LDBPX = 44 + 83 , LPX = 94 )
   INTEGER NPCOMPX
   PARAMETER ( NPCOMPX = 83 )

  TYPE SharedDataChunk
!   This will end up having a ton of data.
      INTEGER ID

      INTEGER ASWRKF,ASWFLN,NXTASW
      INTEGER CPWRKF,CPWFLN,NXTCPW

      DOUBLE PRECISION PREDS(INEGASX:MAXASSX,7),TREDS(INEGASX:MAXASSX,7)
      DOUBLE PRECISION ETVAS(INEGASX:MAXASSX,7),ECORRS(INEGASX:MAXASSX,7)
      DOUBLE PRECISION PRESSS(INEGASX:MAXASSX,22),TEMPS(INEGASX:MAXASSX,22)
      DOUBLE PRECISION ADMWTS(INEGASX:MAXASSX,22),ECORR2(INEGASX:MAXASSX,22)

      DOUBLE PRECISION VALUE
      INTEGER ITYPE,NINSTR,NLINES,LEVEL,ICOL1,ICOL2,ICREAD,LTOKEN
      INTEGER IVAL,LLINE,FTYPE,NREC,RECL,IECHO,ECHMOD,KTTY,KPRNT,TAGSPC
      INTEGER L2BEGN 
      LOGICAL NEWINS,CONTFG,EOF,ENAKEY,ENASWT,ENAILA,ENASCI,ENAEQN
      LOGICAL ENAECH,ENAPMT,ENACON,ENACMA,ENATK8,KTTYFG,EOL,ENAMKW
      LOGICAL ENALOW,ENATAG,ENASDI,ENAMCA,ENAVFY,ENAKNF

      INTEGER MINDEX(MMIDEXX),SINDEX(MSIDEXX),PMODEL,PSCLST,MOFFST
      INTEGER YMSTCK(3,LYMSTKX),TOPYMS

      INTEGER ZZINDC(0:15,10),ZZIPTR(10),ZZLWID(10),ZZLINP(10)
      INTEGER ZZLINC(10),ZZIPT1(10),ZZIPT2(10),ZZNCOL(10),ZZPAGE(10)
      INTEGER ZZDSTK(10),ZZTOP,ZZCUR,ZZINDX(10)
      CHARACTER ZZWLIN(10)*133,ZZHDLN(10)*132,ZZSVLN(10)*133
      CHARACTER ZZCOLC(0:15,10)*1
      LOGICAL ZZSQFG(10),ZZGPAG(10),ZZUHD(10)

      integer doneMGINIT
      INTEGER iNumSuppress, iaSuppressClass(iMaxSuppressX)
      INTEGER iaSuppressMess(iMaxSuppressX)
      CHARACTER*1600 MGTEXT(MGSSIZX)
      CHARACTER*1600 MGTEXTNARGS(MGSSIZX)
      INTEGER MGCLAS(MGSSIZX),MGNUM(MGSSIZX),MGSEV(MGSSIZX),NMESS,MGADD
      INTEGER MGWARN,MGFLAG

      DOUBLE PRECISION  REF_T, REF_P, H2O_DENS,NMOLVOL

      INTEGER PRNMAD(100,100),PRMTAD(100,100)
      INTEGER PMSRCE(LDBPX),PMASSA(LDBPX),PMSRCP(LPX+14),PMPROP(LPX+4)
      INTEGER PMKVAL,PMGRES,PMCLCT,PMSYNO,PMSYNS,PMSYNN,IPTUIF
      INTEGER PMVFUG,PMLFUG,PMLACT,PMWATK,PMCRIT,PMSULS,PMVISS
      INTEGER PMOLES,PMSYNT,PMTHER,PMVIT,PMCACN,PMPPS,PMPPE,PMCDRY
      INTEGER PMCPNA       
      INTEGER CLOU14,PPCFLG,GLOADD
      DOUBLE PRECISION PMSMER(NPCOMPX,2),CPMT14(25)
      DOUBLE PRECISION GCRACF,CLOUR1,CLOUR2,CLX(5),CLY(5)
      DOUBLE PRECISION INDEXA,INDEXB,INDEXC
      CHARACTER*20 PMASSY,PMMNEM
      LOGICAL METH14,CNGASS

      integer SSTACK(103),TOPSTR,ISTTOT,SSTKSZ

      INTEGER NXTWFR,NSTRMS,NUTYPE,NEXTAS,NSTYPE,NSOLER,NSOLWR
      INTEGER SVSMSX,bypassRangeErrors
      LOGICAL OVRIDE
      CHARACTER OVTEXT*128,COMMND*32,CFSYMB*128

      INTEGER DTABLE(20),GETDRV,PUTDRV,EMODTG,VERMOD,PMTABN,PMTABD
      INTEGER PMTABC,EDEVTG,PMSALT,PMCOMF,PMHDRF,PMASIZ,PMCMKR,PMCSNO
      INTEGER DFCOMF,DFASIZ,DFCSNO,DFSALT,DFHDRF,PMWRTF,DFWRTF
      INTEGER DCHAR(10,20),TGLTOP,TGLMAX
      CHARACTER DRVCSP(20)*20,DFCMKR*20
      CHARACTER TAGLST(5000)*20,TAGVLS(5000)*80

      DOUBLE PRECISION UPARAM(30),FLOTOT

      INTEGER MSDEV,MSRLEN,MSBTOP,MSBSIZ,MSBMAX,MSLTB(100),MSDTB(200)
      INTEGER MSSTAT(200),MSTTY,MSPRNT
      INTEGER MSSREC,MSSUMF,MSSUMR,MSSMAX,MSSCMX,MSSPF(100),MXSPPL
      INTEGER MSINDX(30000),MSBIDX(60)
      CHARACTER MSNAME*128,MSSUMN*128,MSKEYS(50)*4
      LOGICAL MSOPEN,MSBAD,MSTTYF,MSUSUM,MSSDTB(50),MSRDKY

      DOUBLE PRECISION PLPBLV(2),ABPEND(5),XAMPRP,NIMSUM,VISCT(2)
      INTEGER PLMACR,PLCRUD,PLINFO,PLHIST,PLBLEN,PLECON,PLSUMY,PLMSGS
      INTEGER PLUTYS,PLINVT,PLUNTS,PLSTMS,PLCSEQ,PMXXXX,PLPBLN,NABPR
      INTEGER PMBEXL,NMBEXL,PLWTCH,WATCHP(5),NPPLIM
      LOGICAL PLSTLV,PLMDLV,PLCRLV,PLUTLV,PLNABP,WATCHF,PONAW,TBPWRQ

      DOUBLE PRECISION TOL,EMAX,DAMPF
      INTEGER IC,ITN,ITNMAX,NESTLV,METHOD,LOOPXX(50),CURTXX,SUBUNT
      LOGICAL CONV,INLOOP,DIAGPS,INFEAS,INFSXX(25),SVUMOD

      CHARACTER*6 YCINST(36),YNMODL(150),YSMODL(300),YRNSTK(100)
      CHARACTER*6 ZCINST(22)

  END TYPE

END MODULE

 

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
233 Views

In a command line (makefile) build, you would use /align:rec8byte (or on Linux/Mac, -align rec8byte). -Zp8 (not -zp8) will also work, but it isn't the recommended form.

In the source, you can bracket your type declaration with:

!DIR$ OPTIONS /ALIGN=RECORDS=ALL
...
!DIR$ END OPTIONS

This is a holdover from VAX (DEC) FORTRAN. See OPTIONS Directive (intel.com)

View solution in original post

6 Replies
mecej4
Black Belt
338 Views

The type declaration starts with seven integers, an odd number, which will cause the first double precision component to be misaligned. If you can tolerate it, rearrange the components such that the double precision variables are declared before the integer components, and so on.

You can ask the compiler to generate a cross-reference listing, and you can examine that listing for misaligned components.

The message is only a warning; unless the language rules prohibit it, the compiler may do padding to overcome misalignment.

Ben136KBC
Novice
300 Views

Thank you, but that is not the only cause of misalignment. How do you tell the compiler to generate a cross listing? I googled it but no luck.

Is there is an option to tell the compiler "If things are misaligned, add dummy argument or spacing all you want".

Steve_Lionel
Black Belt Retired Employee
280 Views

The listing file includes the cross reference. You can use /list or turn on Source Listing  from the Fortran > Output Files property page.

The option you want is Data > Structure Member Alignment > 8 Bytes.

Ben136KBC
Novice
243 Views

Thank you Lionel, you are a star. So in a makefile you would use: -zp8  ?. Also, it is possible to do it per file inside a file use !DEC$ ?

Steve_Lionel
Black Belt Retired Employee
234 Views

In a command line (makefile) build, you would use /align:rec8byte (or on Linux/Mac, -align rec8byte). -Zp8 (not -zp8) will also work, but it isn't the recommended form.

In the source, you can bracket your type declaration with:

!DIR$ OPTIONS /ALIGN=RECORDS=ALL
...
!DIR$ END OPTIONS

This is a holdover from VAX (DEC) FORTRAN. See OPTIONS Directive (intel.com)

Ben136KBC
Novice
219 Views

Thank you Lionel, this seems to work:

!DEC$ OPTIONS /ALIGN=(RECORDS=NATURAL)

   TYPE ....

   END TYPE

!DEC$ END OPTIONS

 

 

Reply