I'm developing a Fortran program for scientific computing. I want to use procedure pointers to assign the boundary conditions in the problem, shown in the following main program
program main
use boundary
implicit none
bc1 => boundaryA
bc2 => boundaryB
bc3 => boundaryC
call comp_boundary
end program
I define all the boundary operations "boundaryA/B/C" in a "boundary" module
module boundary
implicit none
procedure(boundary_type), pointer :: bc1,bc2,bc3
abstract interface
subroutine boundary_type(i)
integer :: i
end subroutine
end interface
contains
subroutine boundaryA(i)
integer :: i
print*, 'Boundary A at ',i
end subroutine
subroutine boundaryB(i)
integer :: i
print*, 'Boundary B at ',i
end subroutine
subroutine boundaryC(i)
integer :: i
print*, 'Boundary C at',i
end subroutine
subroutine comp_boundary
call bc1(1)
call bc2(2)
call bc3(3)
end subroutine
end module
This works well.
But my question is that if, say, boundaryC
has not one input argument, but two, then my definition for the abstract interface boundary_type
doesn't work now.
Is that possible to use the procedure pointer to deal with this case? Or any other way around?