! Copyright 2017-2018, UT-Battelle, LLC ! ! SPDX-License-Identifier: BSD-3-Clause ! License-Filename: LICENSE module myoperators use forteuchos use fortpetra implicit none type, extends(ForTpetraOperator) :: TriDiagOperator contains procedure :: apply => my_apply procedure :: getDomainMap => my_getDomainMap procedure :: getRangeMap => my_getRangeMap procedure :: release => delete_TriDiagOperator end type interface TriDiagOperator procedure new_TriDiagOperator end interface contains function new_TriDiagOperator() & result(self) use, intrinsic :: ISO_C_BINDING type(TriDiagOperator) :: self self = ForTpetraOperator() end function subroutine my_apply(self, x, y, mode, alpha, beta) use, intrinsic :: ISO_C_BINDING implicit none class(TriDiagOperator), intent(in) :: self class(TpetraMultiVector), intent(in) :: x class(TpetraMultiVector), intent(inout) :: y integer(kind(TeuchosETransp)), intent(in) :: mode real(scalar_type), intent(in) :: alpha real(scalar_type), intent(in) :: beta type(TeuchosComm) :: comm type(TpetraMap) :: map type(TpetraMultiVector) :: aux comm = TeuchosComm() map = TpetraMap(TPETRA_GLOBAL_INVALID, INT(10,size_type), comm); aux = TpetraMultiVector(map, INT(1,size_type)); call aux%release() call map%release() call comm%release() end subroutine function my_getDomainMap(self) & result(domain_map) use, intrinsic :: ISO_C_BINDING implicit none class(TriDiagOperator), intent(in) :: self type(TpetraMap) :: domain_map ! Do nothing end function function my_getRangeMap(self) & result(range_map) use, intrinsic :: ISO_C_BINDING implicit none class(TriDiagOperator), intent(in) :: self type(TpetraMap) :: range_map ! Do nothing end function subroutine delete_TriDiagOperator(self) class(TriDiagOperator), intent(inout) :: self ! #ifdef __GNUC__ ! Call base class release() call self%ForTpetraOperator%release() ! #endif end subroutine end module program main #include "ForTrilinosInterface_config.hpp" #include "ForTrilinos.h" use ISO_FORTRAN_ENV use, intrinsic :: ISO_C_BINDING #ifdef HAVE_MPI use mpi #endif #include "ForTrilinos.h" use fortpetra use fortest use myoperators implicit none integer(size_type) :: n integer :: ierr class(ForTpetraOperator), allocatable :: op allocate(op, source=TriDiagOperator()) call init_ForTpetraOperator(op); FORTRILINOS_CHECK_IERR() call op%release(); FORTRILINOS_CHECK_IERR() deallocate(op) end program