Skip to content

Commit

Permalink
Equipe all object-constructors with assignment operator
Browse files Browse the repository at this point in the history
Equipe all object-constructors with assignment operator

Why:

The first key to trim out `allocate(source=)`.

Side effects:

Nothing.
  • Loading branch information
szaghi committed Apr 20, 2017
1 parent f6fcc2f commit 8331c49
Show file tree
Hide file tree
Showing 20 changed files with 370 additions and 8 deletions.
31 changes: 29 additions & 2 deletions src/lib/abstract_objects/wenoof_base_object.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ module wenoof_base_object

type, abstract :: base_object_constructor
!< Abstract base object constructor.
integer(I_P) :: S=0_I_P !< Stencils dimension.
real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero.
integer(I_P) :: S=0_I_P !< Stencils dimension.
real(R_P) :: eps=EPS_DEF !< Small epsilon to avoid division by zero.
contains
! public methods
procedure, pass(self) :: create => create_base_object_constructor
! public operators
generic :: assignment(=) => constr_assign_constr !< `=` overloading.
! public deferred methods
procedure(constr_assign_constr_interface), pass(lhs), deferred :: constr_assign_constr !< `=` operator.
! public non overridable methods
procedure, pass(lhs), non_overridable :: assign_ => assign_constr_ !< Assign object.
endtype base_object_constructor

type, abstract :: base_object
Expand All @@ -41,6 +48,16 @@ module wenoof_base_object
procedure, pass(self), non_overridable :: destroy_ !< Destroy object.
endtype base_object

abstract interface
!< Abstract interfaces of [[base_object_constructor]].
subroutine constr_assign_constr_interface(lhs, rhs)
!< `=` operator.
import :: base_object_constructor
class(base_object_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.
endsubroutine constr_assign_constr_interface
endinterface

abstract interface
!< Abstract interfaces of [[base_object]].
subroutine object_assign_object_interface(lhs, rhs)
Expand Down Expand Up @@ -88,6 +105,16 @@ subroutine create_base_object_constructor(self, S, eps)
if (present(eps)) self%eps = eps
endsubroutine create_base_object_constructor

! public non overridable methods
subroutine assign_constr_(lhs, rhs)
!< Assign object constructor.
class(base_object_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

lhs%S = rhs%S
lhs%eps = rhs%eps
endsubroutine assign_constr_

! base object

! public non overridable methods
Expand Down
2 changes: 0 additions & 2 deletions src/lib/abstract_objects/wenoof_interpolations_object.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module wenoof_interpolations_object

type, extends(base_object_constructor), abstract :: interpolations_object_constructor
!< Abstract interpolations object constructor.
real(R_P), allocatable :: stencil(:) !< Stencil used for interpolation, [1-S:S-1].
real(R_P) :: x_target !< Coordinate of the interpolation point.
endtype interpolations_object_constructor

type, extends(base_object), abstract :: interpolations_object
Expand Down
2 changes: 1 addition & 1 deletion src/lib/abstract_objects/wenoof_weights_object.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module wenoof_weights_object
public :: weights_object
public :: weights_object_constructor

type, extends(base_object_constructor) :: weights_object_constructor
type, extends(base_object_constructor), abstract :: weights_object_constructor
!< Abstract weights object constructor.
endtype weights_object_constructor

Expand Down
14 changes: 14 additions & 0 deletions src/lib/concrete_objects/wenoof_alpha_int_js.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ module wenoof_alpha_int_js

type, extends(alpha_object_constructor) :: alpha_int_js_constructor
!< Jiang-Shu alpha object constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype alpha_int_js_constructor

type, extends(alpha_object) :: alpha_int_js
Expand All @@ -34,6 +37,17 @@ module wenoof_alpha_int_js
endtype alpha_int_js

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(alpha_int_js_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! deferred public methods
subroutine create(self, constructor)
!< Create alpha.
Expand Down
18 changes: 18 additions & 0 deletions src/lib/concrete_objects/wenoof_alpha_int_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module wenoof_alpha_int_m
type, extends(alpha_object_constructor) :: alpha_int_m_constructor
!< Henrick alpha (non linear weights) object constructor.
character(len=:), allocatable :: base_type !< Base alpha coefficient type.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype alpha_int_m_constructor

type, extends(alpha_object) :: alpha_int_m
Expand All @@ -40,6 +43,21 @@ module wenoof_alpha_int_m
endtype alpha_int_m

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(alpha_int_m_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
select type(rhs)
type is(alpha_int_m_constructor)
if (allocated(rhs%base_type)) lhs%base_type = rhs%base_type
endselect
endsubroutine constr_assign_constr

! deferred public methods
subroutine create(self, constructor)
!< Create alpha.
Expand Down
14 changes: 14 additions & 0 deletions src/lib/concrete_objects/wenoof_alpha_int_z.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module wenoof_alpha_int_z

type, extends(alpha_object_constructor) :: alpha_int_z_constructor
!< Borges alpha (non linear weights) object constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype alpha_int_z_constructor

type, extends(alpha_object) :: alpha_int_z
Expand All @@ -35,6 +38,17 @@ module wenoof_alpha_int_z
procedure, pass(lhs) :: object_assign_object !< `=` operator.
endtype alpha_int_z
contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(alpha_int_z_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! public deferred methods
subroutine create(self, constructor)
!< Create alpha.
Expand Down
14 changes: 14 additions & 0 deletions src/lib/concrete_objects/wenoof_alpha_rec_js.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ module wenoof_alpha_rec_js

type, extends(alpha_object_constructor) :: alpha_rec_js_constructor
!< Jiang-Shu alpha object constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype alpha_rec_js_constructor

type, extends(alpha_object) :: alpha_rec_js
Expand All @@ -34,6 +37,17 @@ module wenoof_alpha_rec_js
endtype alpha_rec_js

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(alpha_rec_js_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! deferred public methods
subroutine create(self, constructor)
!< Create alpha.
Expand Down
18 changes: 18 additions & 0 deletions src/lib/concrete_objects/wenoof_alpha_rec_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module wenoof_alpha_rec_m
type, extends(alpha_object_constructor) :: alpha_rec_m_constructor
!< Henrick alpha (non linear weights) object constructor.
character(len=:), allocatable :: base_type !< Base alpha coefficient type.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype alpha_rec_m_constructor

type, extends(alpha_object) :: alpha_rec_m
Expand All @@ -40,6 +43,21 @@ module wenoof_alpha_rec_m
endtype alpha_rec_m

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(alpha_rec_m_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
select type(rhs)
type is(alpha_rec_m_constructor)
if (allocated(rhs%base_type)) lhs%base_type = rhs%base_type
endselect
endsubroutine constr_assign_constr

! deferred public methods
subroutine create(self, constructor)
!< Create alpha.
Expand Down
15 changes: 15 additions & 0 deletions src/lib/concrete_objects/wenoof_alpha_rec_z.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module wenoof_alpha_rec_z

type, extends(alpha_object_constructor) :: alpha_rec_z_constructor
!< Borges alpha (non linear weights) object constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype alpha_rec_z_constructor

type, extends(alpha_object) :: alpha_rec_z
Expand All @@ -34,7 +37,19 @@ module wenoof_alpha_rec_z
procedure, pass(self) :: destroy !< Destroy alpha.
procedure, pass(lhs) :: object_assign_object !< `=` operator.
endtype alpha_rec_z

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(alpha_rec_z_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! public deferred methods
subroutine create(self, constructor)
!< Create alpha.
Expand Down
14 changes: 14 additions & 0 deletions src/lib/concrete_objects/wenoof_beta_int_js.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module wenoof_beta_int_js

type, extends(beta_object_constructor) :: beta_int_js_constructor
!< Jiang-Shu and Gerolymos-Senechal-Vallet beta object constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype beta_int_js_constructor

type, extends(beta_object) :: beta_int_js
Expand All @@ -38,6 +41,17 @@ module wenoof_beta_int_js
endtype beta_int_js

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(beta_int_js_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! public deferred methods
subroutine create(self, constructor)
!< Create beta.
Expand Down
14 changes: 14 additions & 0 deletions src/lib/concrete_objects/wenoof_beta_rec_js.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module wenoof_beta_rec_js

type, extends(beta_object_constructor) :: beta_rec_js_constructor
!< Jiang-Shu and Gerolymos-Senechal-Vallet beta object constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype beta_rec_js_constructor

type, extends(beta_object) :: beta_rec_js
Expand All @@ -40,6 +43,17 @@ module wenoof_beta_rec_js
endtype beta_rec_js

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(beta_rec_js_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! public deferred methods
subroutine create(self, constructor)
!< Create beta.
Expand Down
25 changes: 25 additions & 0 deletions src/lib/concrete_objects/wenoof_interpolations_int_js.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module wenoof_interpolations_int_js

type, extends(interpolations_object_constructor) :: interpolations_int_js_constructor
!< Jiang-Shu (Lagrange) interpolations object for function interpolation constructor.
real(R_P), allocatable :: stencil(:) !< Stencil used for interpolation, [1-S:S-1].
real(R_P) :: x_target !< Coordinate of the interpolation point.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype interpolations_int_js_constructor

type, extends(interpolations_object) :: interpolations_int_js
Expand All @@ -37,6 +42,26 @@ module wenoof_interpolations_int_js
endtype interpolations_int_js

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(interpolations_int_js_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
select type(rhs)
type is(interpolations_int_js_constructor)
if (allocated(rhs%stencil)) then
lhs%stencil = rhs%stencil
else
if (allocated(lhs%stencil)) deallocate(lhs%stencil)
endif
lhs%x_target = rhs%x_target
endselect
endsubroutine constr_assign_constr

! public deferred methods
subroutine create(self, constructor)
!< Create interpolations.
Expand Down
14 changes: 14 additions & 0 deletions src/lib/concrete_objects/wenoof_interpolations_rec_js.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module wenoof_interpolations_rec_js

type, extends(interpolations_object_constructor) :: interpolations_rec_js_constructor
!< Jiang-Shu (Lagrange) interpolations object for derivative reconstruction constructor.
contains
! public deferred methods
procedure, pass(lhs) :: constr_assign_constr !< `=` operator.
endtype interpolations_rec_js_constructor

type, extends(interpolations_object) :: interpolations_rec_js
Expand All @@ -40,6 +43,17 @@ module wenoof_interpolations_rec_js
endtype interpolations_rec_js

contains
! constructor

! deferred public methods
subroutine constr_assign_constr(lhs, rhs)
!< `=` operator.
class(interpolations_rec_js_constructor), intent(inout) :: lhs !< Left hand side.
class(base_object_constructor), intent(in) :: rhs !< Right hand side.

call lhs%assign_(rhs=rhs)
endsubroutine constr_assign_constr

! public deferred methods
subroutine create(self, constructor)
!< Create interpolations.
Expand Down
Loading

0 comments on commit 8331c49

Please sign in to comment.