I am developing Fortran code to solve a PDE system.
The way it is being developed now is that I have a type Variablethat has several attributes, the most important of which is an array valthat stores the value.
Now I also have a class solverthat will do the calculations on Variable. I decided that passing the whole to the Variablesolver and working with it variable%valevery time I want to start it (several thousand times during the exectution) would be inefficient, so I decided to define the pointer fields in solverto bind the solver to the corresponding variable. for instance
program example
use variable
use solvers
type(Variable) T
type(Solver) solver_temperature
!Contructors
call T%create()
call solver_temperature%create(T)
call solver_temperature%solve()
end program example
And solver module
module solvers
type Solver
real*8, pointer :: T(:,:)
contains
procedure :: create
procedure :: solve
end type
contains
subroutine create(this,T)
type(Solver) :: this
type(Variable) :: T
this%T => T%val
end subroutine
end module
, , .
, , ? . T solve ? ?