Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Assigning Data to A TYPE array

Intel_C_Intel
Employee
836 Views
I have the following type:

	TYPE PROP_INFO
		CHARACTER	fl_name*10				! Fluid name
		CHARACTER	prop_class*10			! Property calculator class
		CHARACTER	std_item*10				! Standard property calculator item name
		INTEGER*4	choices(MAX_CALCS)		! Choices for calculations
	END TYPE


and the following data statements:

	DATA (prop_info(i)%fl_name, i = 1, 4) / 'AIR_CMB', 'AIR_STD', 'H2O', '' /
	DATA (prop_info(i)%prop_class, i = 1, 4) / 'AIR_C_PROP', 'AIR_S_PROP', 'H2O_PROP', 'MDC_PROP' /
	DATA (prop_info(i)%std_item, i = 1, 4) / 'AIR_CMB', 'AIR_STD', 'H2O', 'PROPERTY' /
	DATA (prop_info(i)%choice, i = 1, 4) / STR_CHOICE_2, STR_CHOICE_2, STR_CHOICE_2, STR_CHOICE_2 /


Is there an easier/more succinct way of performing this assignment? Can I have a second implied DO to assign to the choices arrays?

Incidently, Steve and FORTRAN documentation peeps, I've notice that a lot of the examples in the documentation deal only with the simple, almost trivial cases and not with anything more complicated (and thus more in need of documenting!) Data assignment to an array of TYPEs for instance.....
0 Kudos
1 Reply
Steven_L_Intel1
Employee
836 Views
Look up "structure constructor" (and "array constructor") in the documentation. A combination of these is probably what you're looking for. You may also want to use an initialization value on the variable declaration rather than DATA.

Steve
0 Kudos
Reply