I am sorry that I can't reply to the original post.
The interface of 'writestring' is as follows:
subroutine writestring(filename,msg) bind(c,name='writestring') use iso_c_binding implicit none type(c_ptr),value::filename,msg end subroutine
After I replaced 'C_LOC' by 'LOC', the following error displayed:
So I think it can't be replaced.
error #6633: The type of the actual argument differs from the type of the dummy argument. [LOC]
The type returned by LOC is integer of size of 4 or 8 depending on 32 or 64 bit build
Whereas the type returned by C_LOC is C_PTR.
You have to be consistent with regards to argument type (in INTERFACE and CALL (and receiver function)) even though the bit patters may be the same.