In Fortran 90-95:
type food INTEGER,pointer :: NBananasLeft(:) INTEGER,pointer :: NApplesLeft(:) end type food
you must distribute the arrays yourself using allocate(var%NBananasLeft(NBananaTypes))) .
In Fortran 2003:
type food INTEGER,allocatable :: NBananasLeft(:) INTEGER,allocatable :: NApplesLeft(:) end type food
you must also allocate arrays yourself using allocate(var%NBananasLeft(NBananaTypes))) , but you avoid memory leaks.
In Fortran 2003, parameterized data types (only a few compilers support this):
type food(NBananaTypes,NAppleTypes) integer,len :: NBananaTypes,NAppleTypes INTEGER :: NBananasLeft(NBananaTypes) INTEGER :: NApplesLeft(NAppleTypes) end type food
source share