Reputation: 47
I am trying to initialize a derived type using a parameter declaration. When I compile, I get the following error
Element in INTEGER(4) array constructor at (1) is CHARACTER(1).
User defined kinds values ip
and dp
are found in fasst_global
. They are:
integer,parameter:: ip = selected_int_kind(8)
integer,parameter:: dp = selected_real_kind(15,307)
I have tried using 1_ip
instead of 1
as the first element and it made no difference. What am I doing wrong?
module fasst_derived_types
use fasst_global
implicit none
type fasst_default_soil
integer(ip):: sid
character(len=2):: ssname
real(dp):: dens,pors,ssemis,ssalb,shc,smin,smax,salpha,svgn
real(dp):: sspheat,sorgan,spsand,spsilt,spclay,spgravel
end type fasst_default_soil
type(fasst_default_soil),parameter:: fasst_soil(1) = fasst_default_soil( &
(/1, 'GW',1.947_dp,0.293_dp, 0.92_dp,0.40_dp,1.1197e-2_dp, &
0.01_dp,0.293_dp,22.6125_dp, 3.45_dp, 820.0_dp, &
0.0_dp, 5.0_dp, 2.0_dp, 2.0_dp,91.0_dp/))
end module fasst_derived_types
Upvotes: 3
Views: 213
Reputation: 32366
You are trying to use two constructors here:
You have the correct syntax for each, but you are using them incorrectly.
The array constructor (/.../)
is to construct an array. But you want an array of derived type values (well, one value) rather than an array as the component for a single derived type value. The syntax error comes from attempting to create an array with various different/incompatible types.
So, instead you want
type(fasst_default_soil),parameter:: fasst_soil(1) = (/fasst_default_soil(1_ip,'GW', ...)/)
Or, as you just want a single element array you don't even need to construct that array of derived types.
Upvotes: 3