anchor.diff:     REAL(ReKi),          ALLOCATABLE:: elf(:)
      REAL(ReKi),          ALLOCATABLE:: elm(:,:)
      REAL(ReKi),          ALLOCATABLE:: elg(:,:)
  -   REAL(ReKi)                      :: EStif0_GL(6,6,node_elem-1)
  -   REAL(ReKi)                      :: EMass0_GL(6,6,node_elem-1)
  -   REAL(ReKi)                      :: DistrLoad_GL(6,node_elem-1)
  +   REAL(ReKi)           ALLOCATABLE:: EStif0_GL(:,:,:)
  +   REAL(ReKi)           ALLOCATABLE:: EMass0_GL(:,:,:)
  +   REAL(ReKi)           ALLOCATABLE:: DistrLoad_GL(:,:)
      INTEGER(IntKi)                  :: dof_elem
      INTEGER(IntKi)                  :: rot_elem
      INTEGER(IntKi)                  :: nelem
      INTEGER(IntKi)                  :: j
      INTEGER(IntKi)                  :: temp_id
  -   INTEGER(IntKi)                  :: allo_stat
  +   INTEGER(IntKi)                  :: ErrStat2                     ! Temporary Error status
  +   CHARACTER(ErrMsgLen)            :: ErrMsg2                      ! Temporary Error message
  +   CHARACTER(*),          PARAMETER:: RoutineName = 'BD_GenerateDynamicElementGA2'
  +
  +   ErrStat    = ErrID_None
  +   ErrMsg     = ""
  +   RHS(:)     = 0.0D0
  +   StifK(:,:) = 0.0D0
  +   MassM(:,:) = 0.0D0
  +   DampG(:,:) = 0.0D0
   
      dof_elem = dof_node * node_elem
      rot_elem = (dof_node/2) * node_elem
   
  -   ALLOCATE(Nuu0(dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   Nuu0 = 0.0D0
  -
  -   ALLOCATE(Nuuu(dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   Nuuu = 0.0D0
  -
  -   ALLOCATE(Nrr0(rot_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   Nrr0 = 0.0D0
  -
  -   ALLOCATE(Nrrr(rot_elem),STAT = allo_stat)
  -
  -   Nrrr = 0.0D0
  -
  -   ALLOCATE(Nvvv(dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   Nvvv = 0.0D0
  -
  -   ALLOCATE(Naaa(dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   Naaa = 0.0D0
  -
  -   ALLOCATE(elf(dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   elf = 0.0D0
  -
  -   ALLOCATE(elk(dof_elem,dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   elk = 0.0D0
  -
  -   ALLOCATE(elm(dof_elem,dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   elm = 0.0D0
  -
  -   ALLOCATE(elg(dof_elem,dof_elem),STAT = allo_stat)
  -   IF(allo_stat/=0) GOTO 9999
  -   elg = 0.0D0
  +   CALL AllocAry(Nuu0,dof_elem,'Nuu0',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(Nuuu,dof_elem,'Nuuu',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(Nrr0,rot_elem,'Nrr0',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(Nrrr,rot_elem,'Nrrr',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(Nvvv,dof_elem,'Nvvv',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(Naaa,dof_elem,'Naaa',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(elf,dof_elem,'elf',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(elk,dof_elem,dof_elem,'elk',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(elm,dof_elem,dof_elem,'elm',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(elg,dof_elem,dof_elem,'elg',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(EStif0_GL,6,6,node_elem-1,'EStif0_GL',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(EMass0_GL,6,6,node_elem-1,'EMass0_GL',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   CALL AllocAry(DistrLoad_GL,6,node_elem-1,'DistrLoad_GL',ErrStat2,ErrMsg2)
  +      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +   if (ErrStat >= AbortErrLev) then
  +       call Cleanup()
  +       return
  +   end if
  +   Nuu0(:)  = 0.0D0
  +   Nuuu(:)  = 0.0D0
  +   Nrr0(:)  = 0.0D0
  +   Nrrr(:)  = 0.0D0
  +   Nvvv(:)  = 0.0D0
  +   Naaa(:)  = 0.0D0
  +   elf(:)   = 0.0D0
  +   elk(:,:) = 0.0D0
  +   elm(:,:) = 0.0D0
  +   elg(:,:) = 0.0D0
  +   EStif0_GL(:,:,:)    = 0.0D0
  +   EMass0_GL(:,:,:)    = 0.0D0
  +   DistrLoad_GL(:,:,:) = 0.0D0
   
      DO nelem=1,elem_total
          Nuu0(:) = uuN0(:,nelem)
  -       CALL BD_ElemNodalDisp(uuNf,node_elem,dof_node,nelem,Nuuu)
  +       CALL BD_ElemNodalDisp(uuNf,node_elem,dof_node,nelem,Nuuu,ErrStat2,ErrMsg2)
  +          CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
          temp_id = (nelem-1)*ngp
          DO j=1,ngp
              EStif0_GL(1:6,1:6,j) = Stif0(1:6,1:6,temp_id+j)
  
positive.code: !   for uuN0, uuN, and vvn (initial nodal configuration, nodal displacements, and velocity of mass) these values
  !   are then passed back to GenerateDynamicElement.
  !**********************************************************************************************************************************
  SUBROUTINE BD_ElemNodalDisp(uu,node_elem,dof_node,nelem,Nu)
  
     REAL(ReKi),INTENT(IN):: uu(:) ! Initial position vector, nodal displacements, and velocity of mass
     INTEGER(IntKi),INTENT(IN):: node_elem ! Node per element
     INTEGER(IntKi),INTENT(IN):: dof_node ! Degrees of freedom per node
     INTEGER(IntKi),INTENT(IN):: nelem ! Number of elements, being looped from 1, elem_total
     REAL(ReKi),INTENT(INOUT):: Nu(:) ! Initial nodal configuration, nodal displacements, and velocity of mass at the nodes of each element
  
     INTEGER(IntKi):: i ! Index counter
     INTEGER(IntKi):: j ! Index counter
     INTEGER(IntKi):: temp_id1 ! Counter
     INTEGER(IntKi):: temp_id2 ! Counter
  
     DO i=1,node_elem
         DO j=1,dof_node
  
negative.code:    SUBROUTINE BD_GenerateDynamicElementGA2(uuN0,uuNf,vvNf,aaNf,                 &
                                             Stif0,Mass0,gravity,u,damp_flag,beta,&
                                             elem_total,node_elem,dof_node,ngp,   &
                                             StifK,RHS,MassM,DampG,&
                                             ErrStat,ErrMsg)
  
     REAL(ReKi),        INTENT(IN   ):: uuN0(:,:)
     REAL(ReKi),        INTENT(IN   ):: uuNf(:)
  