Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module swapp
- type derived
- integer::index
- real::value
- end type derived
- interface swap
- module procedure swap_int,swap_real,swap_char,swap_int_real,swap_derived
- end interface
- contains
- elemental subroutine swap_int(a,b)
- integer,intent(inout)::a,b
- integer::temp
- temp=a
- a=b
- b=temp
- end subroutine swap_int
- elemental subroutine swap_real(a,b)
- real,intent(inout)::a,b
- real::temp
- temp=a
- a=b
- b=temp
- end subroutine swap_real
- elemental subroutine swap_char(a,b)
- character(len=*),intent(inout)::a,b
- character(len=len(a))::temp
- temp=a
- a=b
- b=temp
- end subroutine swap_char
- elemental subroutine swap_int_real(a,b)
- integer,intent(inout)::a
- integer::temp
- real,intent(inout)::b
- temp=real(a)
- a=int(b)
- b=temp
- end subroutine swap_int_real
- elemental subroutine swap_derived(a,b)
- type(derived),intent(inout)::a,b
- type(derived),allocatable::temp
- allocate (temp,source=a)
- a=b
- b=temp
- end subroutine swap_derived
- end module swapp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement