Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Initialize Types

JohnNichols
Valued Contributor III
632 Views
 Type aBeam

        INTEGER             id
        integer             nodes(2)
        integer             restraint(2)        ! 0 - not restrained 7 000111 56 111000 63 111111
        integer             nodetype(2,6)
        integer :: flag   = 0
        REAL (KIND=dp)      x(2), y(2), z(2)
        REAL (KIND=dp)      mass(2)
        REAL (KIND=dp)      H(2)
        REAL (KIND=dp)      nu
        REAL (KIND=dp)      em
        REAL (KIND=dp)      x21
        REAL (KIND=dp)      area2
        REAL (KIND=dp)      esm(12,12)
        Real (KIND=dp)      Iz
        Real (KIND=dp)      Iy
        Real (KIND=dp)      G
        Real (KIND=dp)      Ix
        REAL (KIND=dp)      Area
        REAL (KIND=dp)      E
        REAL (KIND=dp)      Beta1
        REAL (KIND=dp)      Beta2
        REAL (KIND=dp)      length
        REAL (KIND=dp)      gamma

    end type

If I create an array of abeam, and I set length here to zero does it initialize that way -

0 Kudos
1 Reply
Steven_L_Intel1
Employee
632 Views

Not sure what you're asking. With the type declared that way, only the "flag" component gets initialized - the other components are undefined. If you add "= 0" (and the :: before the name) to "length" then anything you declare of that type will have the length component also initialized to zero. If it's a run-time allocation, I think you would be better off to explicitly initialize those two fields in the code rather than using type initialization.

0 Kudos
Reply