Die Situation ist in 2008 mit dem BLOCK-Konstrukt düsterer. Dieses Konstrukt gehört notwendigerweise zu den ausführbaren Anweisungen, ist aber oft nur zu dem Zweck da, die Fähigkeit hinzuzufügen, einige Spezifikationsanweisungen nach ausführbaren Anweisungen zu platzieren, etwa wenn ein angenommener Längenzeiger auf den anonymen Speicher gerichtet werden soll.
EDIT: Beispiel
module anonymous
use ISO_C_BINDING
implicit none
interface
function malloc(size) bind(C,name='malloc')
import
implicit none
type(C_PTR) malloc
integer(C_SIZE_T), value :: size
end function malloc
subroutine free(ptr) bind(C,name='free')
import
implicit none
type(C_PTR), value :: ptr
end subroutine free
function strlen(str) bind(C,name='strlen')
import
implicit none
type(C_PTR), value :: str
integer(C_SIZE_T) strlen
end function strlen
end interface
contains
function hello()
type(C_PTR) hello
character(LEN=*,KIND=C_CHAR), parameter :: world = &
'Hello, world'//C_NULL_CHAR
character(LEN=len(world),KIND=kind(world)), pointer :: fptr
hello = malloc(len(world,KIND=C_SIZE_T))
call C_F_POINTER(hello,fptr)
fptr = world
end function hello
end module anonymous
program test
use anonymous
implicit none
type(C_PTR) cptr
character(LEN=:,KIND=C_CHAR), pointer :: fptr
integer(C_SIZE_T) hello_len
cptr = hello()
hello_len = strlen(cptr)
BLOCK
character(LEN=hello_len,KIND=C_CHAR), pointer :: temp
call C_F_POINTER(cptr,temp)
fptr => temp
end BLOCK
write(*,'(*(g0))') fptr(1:strlen(cptr))
end program test
Ich wollte es einfach halten, denn dies ist ein Anfänger Frage. –