c_sizeof(x) calculates the number of bytes of storage the expression
n = c_sizeof(x)
x- The argument shall be of any type, rank or shape.
The return value is of type integer and of the system-dependent kind
c_size_t (from the iso_c_binding module). Its value is the number of bytes occupied by the argument. If the argument has the
pointer attribute, the number of bytes of the storage area pointed to is returned. If the argument is of a derived type with
allocatable components, the return value doesn’t account for the sizes of the data pointed to by these components.
use iso_c_binding integer(c_int) :: i real(c_float) :: r, s(5) print *, (c_sizeof(s)/c_sizeof(r) == 5) end
The example will print
.true. unless you are using a platform where default
real variables are unusually padded.