Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge x and xf into single inout argument in step procedures #30

Open
HugoMVale opened this issue Jul 20, 2023 · 1 comment
Open

Merge x and xf into single inout argument in step procedures #30

HugoMVale opened this issue Jul 20, 2023 · 1 comment

Comments

@HugoMVale
Copy link
Contributor

Currently, step methods have an interface like so:

subroutine step_func_fixed(me,t,x,h,xf)
!! rk step function for the fixed-step methods.
import :: rk_fixed_step_class,wp
implicit none
  class(rk_fixed_step_class),intent(inout) :: me
  real(wp),intent(in)                      :: t  !! initial time
  real(wp),dimension(me%n),intent(in)      :: x  !! initial state vector
  real(wp),intent(in)                      :: h  !! time step \( |\Delta t| \)
  real(wp),dimension(me%n),intent(out)     :: xf !! final state vector
end subroutine step_func_fixed

There is no need for a separate arguments x intent(in) and xf, intent(out). They can be merged into a single argument x, intent(inout), thereby avoiding a redundant state vector.

For instance, for Euler:

module procedure euler
associate (f1 => me%funcs(:,1))
    call me%f(t,x,f1)
    x = x + h*f1
end associate
end procedure euler

The change should be more or less straightforward for all methods expressed in the classical the rk form. For SSP and LS methods, one registry will probably have to be added because the implementations were already making use of the extra x. I can help with that; just let me know what you think.

@jacobwilliams
Copy link
Owner

Yes, that seems reasonable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants