----- Original Message -----
From: "Ben Blackwell" <[log in to unmask]>
To: <[log in to unmask]>
Sent: 12 February 2004 12:28
Subject: memory allocation in conjuction with modules
> I am having difficulty with memory allocation when the variables were
> declared in a module. For example,
>
Your code is incomplete, in particular lacking a use statement. The
following works perfectly well:
MODULE MOD1
REAL, DIMENSION(:), ALLOCATABLE :: A, B
END MODULE MOD1
PROGRAM MAIN
use mod1
REAL, DIMENSION(:), ALLOCATABLE :: C, D
integer :: status
num_node = 2
max_num_tstep = 3
ALLOCATE(C(NUM_NODE), STAT=STATUS)
ALLOCATE(D(NUM_NODE), STAT=STATUS)
ALLOCATE(A(MAX_NUM_TSTEP), STAT=STATUS)
ALLOCATE(B(MAX_NUM_TSTEP), STAT=STATUS)
c = 1
d = 2
a = 3
b = 4
print *, c(1), d(1), a(1), b(1)
END PROGRAM MAIN
Regards,
Mike Metcalf
|