But OP’s use case is toward two different KIND
s of the same intrinsic type integer
and here the approach shown by @plevold, provided the reference result provided by C_LOC
and the FPTR
are both integer
s, is alright.
Note this is what I had illustrated earlier in this thread with a simple container type. OP can pretty much take the container type example with the bitbucket_t
derived type shown therein and do what is stated in the original post, “To merge the sub records, I am converting the buffer “rec_data”, which is provided as 4-byte (default) integers to 1-byte integer vector so the sub-records can be easily merged.”
Or, OP can also use EQUIVALENCE
with “data” stored as a MODULE
entity and achieve a perfomant solution that way. EQUIVALENCE
, by the way, is forever going to be part of the standard even if it is labeled as obsolescent
(a big mistake by the committee on this) in the official publication.
OP can pursue a couple of different standard-conforming options, as stated here, that can work well performance-wise and which can also allow OP to not run into the gfortran
error, “Type mismatch in argument.”