anchor.diff:  INTEGER(IntKi)                        :: ErrStat                                 ! Error status
   CHARACTER(1024)                       :: ErrMsg                                  ! Error message
   
  +LOGICAL                               :: calcJacobian                            ! Should we calculate Jacobians in Option 1?
   
      !...............................................................................................................................
      ! initialization
  
positive.code:                   
        END IF
     
     
     
        IF ( p_FAST%CompHydro == Module_HD ) THEN ! HydroDyn-{ElastoDyn or SubDyn}
        
        
           IF ( p_FAST%CompSub /= Module_SD ) THEN ! these get mapped to ElastoDyn
                                      
              CALL AllocAry( MeshMapData%Jacobian_ED_SD_HD, SizeJac_ED_HD, SizeJac_ED_HD, 'Jacobian for ED-HD coupling', ErrStat, ErrMsg )
  
negative.code: 
     ! Solve input-output relations; this section of code corresponds to Eq. (35) in Gasmi et al. (2013)
     ! This code will be specific to the underlying modules
     
  #ifdef SOLVE_OPTION_1_BEFORE_2
  ! used for Option 1 before Option 2:
  
     IF ( p_FAST%CompSub == Module_SD .OR. p_FAST%CompHydro == Module_HD ) THEN
     ! Because SubDyn needs a better initial guess from ElastoDyn, we'll add an additional call to ED_CalcOutput to get them:
     ! (we'll do the same for HydroDyn, though I'm not sure it's as critical)
     
        CALL ED_CalcOutput( t_global, ED_Input(1), p_ED, x_ED, xd_ED, z_ED, OtherSt_ED, ED_Output(1), ErrStat, ErrMsg )
           CALL CheckError( ErrStat, 'Message from ED_CalcOutput: '//NewLine//ErrMsg  )    
        
        CALL Transfer_ED_to_HD_SD_Mooring( p_FAST, ED_Output(1), HD_Input(1), SD_Input(1), MAP_Input(1), FEAM_Input(1), MeshMapData, ErrStat, ErrMsg )         
           CALL CheckError( ErrStat, ErrMsg  )    
                 
     END IF   
  #endif   
     
     CALL CalcOutputs_And_SolveForInputs(  t_global &
                          , x_ED  , xd_ED  , z_ED   &
                          , x_SrvD, xd_SrvD, z_SrvD &
                          , x_HD  , xd_HD  , z_HD   &
  