- #1
shitij
- 19
- 0
Hi all !
I have a derived type as:
I have an array of this type as:
I want to pass this array to a subroutine. I have made an interface in the same file for the subroutine
But I am getting an error as:
I tried redefining the whole TYPE in the interface, but that didn't work.
How do I make the type 'global' ? Or is there any other way to pass derived type arguments to functions?
Thank you in advance !
I have a derived type as:
Code:
TYPE type_atom_type_info
integer:: type_code
character(len=4)::type_cname
real(kind=dbl)::mass
end TYPE type_atom_type_info
Code:
TYPE(type_atom_type_info) atom_type_info(250)
I want to pass this array to a subroutine. I have made an interface in the same file for the subroutine
Code:
interface
subroutine cname_to_code(atom_type_info,cname,code)
TYPE(type_atom_type_info),intent(in)::atom_type_info(250)
character(len=4),intent(in)::cname
integer,intent(out)::code
end subroutine cname_to_code
end interface
But I am getting an error as:
Code:
nma.f90:234.60:
TYPE(type_atom_type_info),intent(in)::atom_type_info(250)
1
Error: the type of 'atom_type_info' at (1) has not been declared within the interface
nma.f90:1496.20:
call cname_to_code(atom_type_info,'NH1',temp_k)
1
Error: Type mismatch in argument 'atom_type_info' at (1); passed TYPE(type_atom_type_info) to REAL(4)
nma.f90:4072.26:
TYPE(type_atom_type_info),intent(in)::atom_type_info(250)
1
Error: Derived type 'type_atom_type_info' at (1) is being used before it is defined
I tried redefining the whole TYPE in the interface, but that didn't work.
How do I make the type 'global' ? Or is there any other way to pass derived type arguments to functions?
Thank you in advance !