SIC structures

###
SIC structures

SIC structures are imported in Python into instances of the special class named SicStructure:

    >>> Sic.comm('DEFINE STRUCTURE E')
    >>> e
    <pgutils.SicStructure instance at 0xb7f00bcc>

SIC structure elements are stored in attributes of SicStructure instances, and these attributes are themselves SicVar instances. Call the print statement to print all (and only) SicVar (or SicStructure) attributes, and some details on them.

    >>> Sic.comm('DEFINE INTEGER E%A')
    >>> Sic.comm('DEFINE REAL E%B[2]')
    >>> Sic.comm('DEFINE DOUBLE E%C[2,3]')
    >>> e
    <sicutils.SicStructure instance at 0xb7f009cc>
    >>> print e # Detailed printing
    <SicStructure instance>
    a = 0                                 INTEGER*4 0D
    c = [[ 0.  0.] [ 0.  0.] [ 0.  0.]]      REAL*8 2D (2x3x0x0)
    b = [ 0.  0.]                            REAL*4 1D (2x0x0x0)
    >>> print e.c # 'c' attribute is a SicVar instance
    <SicVar instance>
    array([[ 0.,  0.],
           [ 0.,  0.],
           [ 0.,  0.]])

Nested structures can be recursively imported:

    >>> Sic.comm('DEFINE STRUCTURE E%D')
    >>> Sic.comm('DEFINE INTEGER E%D%A')
    >>> print e
    <SicStructure instance>
    a = 0                                 INTEGER*4 0D
    c = [[ 0.  0.] [ 0.  0.] [ 0.  0.]]      REAL*8 2D (2x3x0x0)
    b = [ 0.  0.]                            REAL*4 1D (2x0x0x0)
    d = <SicStructure>
    >>> print e.d
    <SicStructure instance>
    a = 0                                 INTEGER*4 0D

SicStructure instances can be added new attributes and these attributes are automatically instantiated in the SIC structure10:

    >>> e.e = 1
    E%E             is a      INTEGER*4, 0D             (GLOBAL,RW) -> e.e
    >>> Sic.comm('EXA E%E')
    E%E             =            1               ! Integer GLOBAL
    >>>
    >>> e.f = (1,2,3)
    E%F             is a      INTEGER*4, 1D (3x0x0x0)   (GLOBAL,RW) -> e.f
    >>> Sic.comm('EXA E%F')
    E%F             is an integer Array      of dimensions      3
                1            2            3
    >>>
    >>> import numpy
    >>> e.g = numpy.zeros((3,3))  # Create a 3x3 real numpy array
    E%G             is a         REAL*8, 2D (3x3x0x0)   (GLOBAL,RW) -> e.g
    >>> Sic.comm('EXA E%G')
    E%G             is a double precision Array      of dimensions      3     3
       0.00000000000000000       0.00000000000000000       0.00000000000000000
       0.00000000000000000       0.00000000000000000       0.00000000000000000
       0.00000000000000000       0.00000000000000000       0.00000000000000000