Created
January 29, 2015 00:59
-
-
Save nicolasbock/03841ce79f7148b4ff30 to your computer and use it in GitHub Desktop.
using a source when allocating in Fortran
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program test | |
type :: a_t | |
integer, pointer :: i => null() | |
end type a_t | |
type(a_t), pointer :: a, b | |
nullify(a, b) | |
allocate(a) | |
allocate(a%i) | |
a%i = 1 | |
allocate(b, source=a) | |
if(associated(a, b)) then | |
write(*,*) "a and b point to the same target" | |
endif | |
if(associated(a%i, b%i)) then | |
write(*,*) "a%i and b%i point to the same target" | |
endif | |
end program test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment