C_SIZEOF(3) - [ISO_C_BINDING] Size in bytes of an expression
result = c_sizeof(x)
C_SIZEOF(3) calculates the number of bytes of storage the expression X occupies.
o X : The argument shall be an interoperable data entity.
The return value is of type integer and of the system-dependent kind csize_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 pointer or allocatable components, the return value does not account for the sizes of the data pointed to by these components.
Sample program:
program demo_c_sizeof use iso_c_binding implicit none real(c_float) :: r, s(5) print *, (c_sizeof(s)/c_sizeof(r) == 5) end program demo_c_sizeofResults:
> TThe example will print .true. unless you are using a platform where default real variables are unusually padded.
Fortran 2008
STORAGE_SIZE(3)
Fortran intrinsic descriptions
Nemo Release 3.1 | c_sizeof (3fortran) | November 02, 2024 |