Hello!
I still have a problem allocating derived datatypes.
My setup now reads as followed:
I have a module_gv in which my derived datatype is declared like this:
type, public :: w_field
sequence
double precision :: wx,wy,wz
end type w_field
type(w_field),allocatable,dimension,:, :: w
then in the program main main.F90
i declared:
use module_gv
allocate(w(32,32,32))
write(*,*) allocated(w), " w allocated position 1"
w is being used in another subroutine sub(w) which is called in main.F90 after allocation and it has the following declarations with respect to w:
subroutine sub(w)
implicit none
use module_gv
type (w_field),dimension(32,32,32)::w
double precision:: wx,wy,wz
write(*,*) shape(w) , "size of w"
write(*,*) allocated(w) , " that w is allocated" !command #1
w(2,3,4)%wx=3 !command #2
write(*,*) w(2,3,4)%wx , " =3 "
compiling the code with gfortran and command #1 and #2 on gets me the following message:
ERROR 'array' argument of 'allocated' intrinsic at (1) must be allocatable
compiling the code with command #2 on and #1 off reports no compiling errors.but when i actually run the code with valgrind -v it still gives me following message and error:
T w allocated at position 1 !so this worked
invalid write of size 4 ! ERROR
at sub ! w is being used in subroutine sub
...
i think something is wrong with my declarations within sub so that w is not beeing recognised as an allocatable array in sub(which should be already allocated as confirmed in main.F90 )
i would be glad if someone could help me with this error!
thanks alot!
I still have a problem allocating derived datatypes.
My setup now reads as followed:
I have a module_gv in which my derived datatype is declared like this:
type, public :: w_field
sequence
double precision :: wx,wy,wz
end type w_field
type(w_field),allocatable,dimension,:, :: w
then in the program main main.F90
i declared:
use module_gv
allocate(w(32,32,32))
write(*,*) allocated(w), " w allocated position 1"
w is being used in another subroutine sub(w) which is called in main.F90 after allocation and it has the following declarations with respect to w:
subroutine sub(w)
implicit none
use module_gv
type (w_field),dimension(32,32,32)::w
double precision:: wx,wy,wz
write(*,*) shape(w) , "size of w"
write(*,*) allocated(w) , " that w is allocated" !command #1
w(2,3,4)%wx=3 !command #2
write(*,*) w(2,3,4)%wx , " =3 "
compiling the code with gfortran and command #1 and #2 on gets me the following message:
ERROR 'array' argument of 'allocated' intrinsic at (1) must be allocatable
compiling the code with command #2 on and #1 off reports no compiling errors.but when i actually run the code with valgrind -v it still gives me following message and error:
T w allocated at position 1 !so this worked
invalid write of size 4 ! ERROR
at sub ! w is being used in subroutine sub
...
i think something is wrong with my declarations within sub so that w is not beeing recognised as an allocatable array in sub(which should be already allocated as confirmed in main.F90 )
i would be glad if someone could help me with this error!
thanks alot!