module oc_chains_mod
  implicit none


contains

  subroutine oc_chain2_oper(op1, op2, adj, add, m_, d_, t1_)
    interface
      integer function op1(adj,add,m_,d_)
        logical            :: adj, add
        character(len=*)   :: m_, d_
      end function
      integer function op2(adj,add,m_,d_)
        logical            :: adj, add
        character(len=*)   :: m_, d_
      end function
    end interface

    logical            :: adj, add
    character(len=*)   :: m_, d_, t1_

    integer            :: stat

    if (adj) then
       stat = op1( .true., .false., t1_, d_ )    !!.. t = A'd
       stat = op2( .true.,     add,  m_, t1_)    !!.. m = B't = B'A'd
    else
       stat = op2(.false., .false.,  m_, t1_)    !!.. t1 = Bm
       stat = op1(.false.,     add, t1_, d_ )    !!.. d = At1 = ABm
    end if
    return
  end subroutine

end module
