Skip to content

Commit

Permalink
API refactoring
Browse files Browse the repository at this point in the history
API refactoring

The API has been refactored: all objects (alpha, beta, kappa,
interpolations and weights) now compute their values into volatile
buffers thus the interpolator can be defined as `intent(in)` when used
for computing an interpolation.

Why:

Efficiency reasons: now an interpolator can be defined as a member of
user derived type and used to interpolate values even into procedure
where the user derived type is defined as `intent(in)` without the
unnecessary re-initialization or unsafe *global* definition.

This change addresses the need by:

API of all objects has been changed.

Side effects:

Backward compatibility lost.
  • Loading branch information
szaghi committed Apr 10, 2017
1 parent b2ce4ac commit e7a79c2
Show file tree
Hide file tree
Showing 32 changed files with 1,280 additions and 1,333 deletions.
131 changes: 0 additions & 131 deletions quarantena/wenoof_alpha_int_m.F90

This file was deleted.

136 changes: 0 additions & 136 deletions quarantena/wenoof_alpha_rec_m.F90

This file was deleted.

31 changes: 13 additions & 18 deletions src/lib/abstract_objects/wenoof_alpha_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ module wenoof_alpha_object
#else
use penf, only: RPP=>R8P
#endif
use wenoof_base_object
use wenoof_beta_object
use wenoof_kappa_object
use wenoof_base_object, only : base_object, base_object_constructor

implicit none
private
Expand All @@ -23,35 +21,32 @@ module wenoof_alpha_object

type, extends(base_object), abstract :: alpha_object
!< Abstract alpha (non linear weights) object.
! real(RPP), allocatable :: values_rank_1(:) !< Alpha values [0:S-1].
! real(RPP) :: values_sum_rank_1 !< Sum of alpha coefficients.
! real(RPP), allocatable :: values_rank_2(:,:) !< Alpha values [1:2,0:S-1].
! real(RPP), allocatable :: values_sum_rank_2(:) !< Sum of alpha coefficients [1:2].
contains
! public methods
generic :: compute => compute_int, compute_rec !< Compute alpha.
! public deferred methods
procedure(compute_interpolate_interface), pass(self), deferred :: compute_interpolate !< Compute alpha (interpolate).
procedure(compute_reconstruct_interface), pass(self), deferred :: compute_reconstruct !< Compute alpha (reconstruct).
generic :: compute => compute_interpolate, compute_reconstruct
procedure(compute_int_interface), pass(self), deferred :: compute_int !< Compute alpha (interpolate).
procedure(compute_rec_interface), pass(self), deferred :: compute_rec !< Compute alpha (reconstruct).
endtype alpha_object

abstract interface
!< Abstract interfaces of [[alpha_object]].
pure subroutine compute_interpolate_interface(self, beta, kappa, values)
!< Compute alpha.
import :: alpha_object, beta_object, kappa_object
pure subroutine compute_int_interface(self, beta, kappa, values)
!< Compute alpha (interpolate).
import :: alpha_object, RPP
class(alpha_object), intent(in) :: self !< Alpha.
real(RPP), intent(in) :: beta(0:) !< Beta [0:S-1].
real(RPP), intent(in) :: kappa(0:) !< Kappa [0:S-1].
real(RPP), intent(out) :: values(0:) !< Alpha values [0:S-1].
endsubroutine compute_interpolate_interface
endsubroutine compute_int_interface

pure subroutine compute_reconstruct_interface(self, beta, kappa, values)
!< Compute alpha.
import :: alpha_object, beta_object, kappa_object
pure subroutine compute_rec_interface(self, beta, kappa, values)
!< Compute alpha (reconstruct).
import :: alpha_object, RPP
class(alpha_object), intent(in) :: self !< Alpha.
real(RPP), intent(in) :: beta(1:,0:) !< Beta [1:2,0:S-1].
real(RPP), intent(in) :: kappa(1:,0:) !< Kappa [1:2,0:S-1].
real(RPP), intent(out) :: values(1:,0:) !< Alpha values [1:2,0:S-1].
endsubroutine compute_reconstruct_interface
endsubroutine compute_rec_interface
endinterface
endmodule wenoof_alpha_object
7 changes: 4 additions & 3 deletions src/lib/abstract_objects/wenoof_base_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ subroutine create_interface(self, constructor)
class(base_object_constructor), intent(in) :: constructor !< Object constructor.
endsubroutine create_interface

pure function description_interface(self) result(string)
pure function description_interface(self, prefix) result(string)
!< Return object string-description.
import :: base_object
class(base_object), intent(in) :: self !< Object.
character(len=:), allocatable :: string !< String-description.
class(base_object), intent(in) :: self !< Object.
character(len=*), intent(in), optional :: prefix !< Prefixing string.
character(len=:), allocatable :: string !< String-description.
endfunction description_interface

elemental subroutine destroy_interface(self)
Expand Down
26 changes: 13 additions & 13 deletions src/lib/abstract_objects/wenoof_beta_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module wenoof_beta_object
#else
use penf, only: RPP=>R8P
#endif
use wenoof_base_object
use wenoof_base_object, only : base_object, base_object_constructor

implicit none
private
Expand All @@ -20,30 +20,30 @@ module wenoof_beta_object

type, extends(base_object), abstract :: beta_object
!< Abstract Beta coefficients (smoothness indicators of stencil interpolations) object.
real(RPP), allocatable :: values_rank_1(:) !< Beta values [0:S-1].
contains
! public methods
generic :: compute => compute_stencil_rank_1, compute_stencil_rank_2
generic :: compute => compute_int, compute_rec !< Compute beta.
! deferred public methods
procedure(compute_stencil_rank_1_interface), pass(self), deferred :: compute_stencil_rank_1 !< Compute beta.
procedure(compute_stencil_rank_2_interface), pass(self), deferred :: compute_stencil_rank_2 !< Compute beta.
procedure(compute_int_interface), pass(self), deferred :: compute_int !< Compute beta (interpolate).
procedure(compute_rec_interface), pass(self), deferred :: compute_rec !< Compute beta (reconstruct).
endtype beta_object

abstract interface
!< Abstract interfaces of [[beta_object]].
pure subroutine compute_stencil_rank_1_interface(self, stencil)
!< Compute beta.
pure subroutine compute_int_interface(self, stencil, values)
!< Compute beta (interpolate).
import :: beta_object, RPP
class(beta_object), intent(inout) :: self !< Beta.
real(RPP), intent(in) :: stencil(1-self%S:) !< Stencil used for the interpolation, [1-S:-1+S].
endsubroutine compute_stencil_rank_1_interface
class(beta_object), intent(in) :: self !< Beta.
real(RPP), intent(in) :: stencil(1-self%S:) !< Stencil used for the interpolation, [1-S:-1+S].
real(RPP), intent(out) :: values(0:) !< Beta values [0:S-1].
endsubroutine compute_int_interface

pure subroutine compute_stencil_rank_2_interface(self, stencil, values)
!< Compute beta.
pure subroutine compute_rec_interface(self, stencil, values)
!< Compute beta (reconstruct).
import :: beta_object, RPP
class(beta_object), intent(in) :: self !< Beta.
real(RPP), intent(in) :: stencil(1:,1-self%S:) !< Stencil used for the interpolation, [1:2, 1-S:-1+S].
real(RPP), intent(out) :: values(1:,0:) !< Beta values [1:2,0:S-1].
endsubroutine compute_stencil_rank_2_interface
endsubroutine compute_rec_interface
endinterface
endmodule wenoof_beta_object
Loading

0 comments on commit e7a79c2

Please sign in to comment.