anchor.diff:        INTEGER(IntKi)                       :: ErrStat2                                    ! Error status
         CHARACTER(LEN(ErrMsg))               :: ErrMsg2                                     ! Error message
   
  +      
  +   !-----------------------------------------------------------------------------------------------------------------------------
  +   !  For debug purposes, close an output file for writing the current timestep's inputs and outputs for HydroDyn
  +   !
  +   ! TODO:  All of these should be outputs in HD or FAST and the debug would not be necessary! GJH 7/12/2013
  +
  +        CLOSE( HD_DebugUn )
  +   !
  +   !-----------------------------------------------------------------------------------------------------------------------------
  +      
  +      
  +      
         !...............................................................................................................................
         ! Clean up modules (and write binary FAST output file), destroy any other variables
         !...............................................................................................................................
  
positive.code:    CALL ED_CopyInput (ED_Input(1),  u_ED,  MESH_NEWCOPY, Errstat, ErrMsg) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
        CALL CheckError( ErrStat, 'Message from ED_CopyInput (u_ED): '//NewLine//ErrMsg )
     
     
     
     ! ........................
     ! initialize ServoDyn 
  
negative.code:         CALL Write_HD_Debug(HD_DebugUn, t_global, HD_Input(1), y_HD, ED_Input(1), OtherSt_HD, MeshMapData, ErrStat, ErrMsg)
     !
     !-----------------------------------------------------------------------------------------------------------------------------
  !<<<<<<<
  
        END IF
  
  
        IF ( p_FAST%CompSub ) THEN
           
  !         CALL SD_InputSolve( y_ED, SD_Input(1), MeshMapData, ErrStat, ErrMsg )
              CALL CheckError( ErrStat, 'Message from HD_InputSolve: '//NewLine//ErrMsg  )
  
           CALL SubDyn_CalcOutput( this_time, SD_Input(1), p_SD, x_SD_this, xd_SD_this, z_SD_this, OtherSt_SD, y_SD, ErrStat, ErrMsg )
              CALL CheckError( ErrStat, 'Message from SubDyn_CalcOutput: '//NewLine//ErrMsg  )
                          
        END IF
        
  
        IF ( p_FAST%CompMAP ) THEN
           
  !         CALL MAP_InputSolve( y_ED, MAP_Input(1), MeshMapData, ErrStat, ErrMsg )
              CALL CheckError( ErrStat, 'Message from MAP_InputSolve: '//NewLine//ErrMsg  )
  
           CALL MAP_CalcOutput( this_time, MAP_Input(1), p_MAP, x_MAP_this, xd_MAP_this, z_MAP_this, OtherSt_MAP, y_MAP, ErrStat, ErrMsg )
              CALL CheckError( ErrStat, 'Message from MAP_CalcOutput: '//NewLine//ErrMsg  )
                 
        END IF
        
        
  