m4 expert needed
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri Nov 11 20:04:00 GMT 2005
So who's our resident m4 expert? Anyone have a favorite
on-line m4 tutorial?
Here's the problem: we need to autogenerate the TRANSFER
functions for libgfortran when either SOURCE or MOLD is an
array. If SOURCE and MOLD are both scalar, then tran-intrinsic.c
appears to automagically build appropriate SSA trees. If
either SOURCE or MOLD is non-scalar, we need library routines.
So, we have TRANSFER(SOURCE,MOLD,[SIZE]) with SIZE optional.
SOURCE and MOLD can be any type and scalar or array. This
means we need
SOURCE: character, logical(1,2,4,8), integer(1,2,4,8),
real(4,8,[10,16]), complex(4,8,[10,16])
13 to 17 source type and kind types
MOLD: ditto.
So, 13*13 = 169 and 17*17 = 289 functions.
Things may not be that bad. We should be able to transform
a certain number of the 169 to 289 into loops over the
scalar-scalar case except we need to be mindful of the difference
between an array section and an array element. For example,
program t
integer i
real a, b, x(4), y(4)
complex c, z(2)
x = (/1.1, 2.2, 3.3, 4.4/)
c = (0.,0.)
a = 1.
b = x(1)
! Need _gfortran_transfer_r4a_c4s
! r4a == real(4) array
! c4s == complex(4) scalar
z = transfer(x, c)
print '(4f5.1)', z
! Need _gfortran_transfer_r4a_r4s
! r4a == real(4) array
! r4s == real(4) scalar
y = transfer(x, a)
print '(4f5.1)', y
!
! Equivalent loop over scalar-scalar case.
!
do i = 1, 4
write(*,'(f5.1)',advance='no') transfer(b, a)
end do
print *
end program t
Comments?
--
Steve
More information about the Fortran
mailing list