Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
13 Views

Initialize Types

 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
Highlighted
13 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