- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcas:
- Intel® Fortran Compiler
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
In general, you can use Cray (integer) pointers, but they don't go along with normal Fortran pointers you have.
I use the following trick. It is based on CVF/IVF feature that a scalar pointer is the same as C pointer (a single address, i.e. void*). Thus, it's non-standard but a good thing is that it can be isolated in a separate source.
First, define a FUNCTION outside any module which just returns its argument passed by value:
function Cast(p)
!DEC$ATTRIBUTES VALUE:: p
integer(INT_PTR_SIZE()):: p
integer(INT_PTR_SIZE()):: Cast
Cast = p
end function Cast
Then, redefine an interface to "convince" the compiler that its return value is not an integer, but a pointer to something. You have to write one interface body for each type you want to cast:
interface
function CAST_PP(p)
!DEC$ATTRIBUTES DECORATE, ALIAS: "CAST":: CAST_PP
!DEC$ATTRIBUTES VALUE:: p
integer(int_ptr_size()), intent(in):: p
type(PP),pointer:: CAST_PP
endfunction
end interface
Finally, the usage is as simple as:
USE TheModuleWithInterface
type(pp), pointer:: p
p => CAST_PP(locp)
Note that this is basically a dirty trick, but it can get usefulon occasion:-) .
Jugoslav
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Another question: from your code I can get a known pointer from its address. But if I don't know what the structure of the pointer is, how can I get it? In other words, how can I get any kindof pointer from an address? just like
pointer(address, paddress)
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
module ppp
type node
type(node), pointer::next=>null()
endtype
type list
type(node), pointer::head=>null()
integer:: nodesize = 0
endtype
contains
subroutine pass( icurr, il)
integer icurr, ifl
type(node), pointer::curr
type(node), target:: T_curr
type(list), pointer::l
type(list), target:: T_l
pointer(icurr, T_curr)
pointer(il, T_l)
curr=>T_curr
l=>T_l
curr % next => l % head
l % head => curr
end subroutine
end module
use ppp
type(list), pointer::l
integer::t, tt
allocate(l)
l%nodesize=30
t=malloc(4 * l%nodesize)
do i=0,3
call pass(t+i*l%nodesize,loc(l))
enddo
end
Would you please point out the problems?
Sincerely,
Zhanghong Tang
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Without much involvement on what it does, I compiled & ran the codeon IVF8.
However, there's adebugger bug described here -- does it match your observations?
Jugoslav
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Thank you very much! In this program It's my default.
But I have a real project which is large (runs successfully in CVF). When compile one of the files, it displays 'Compilation Aborted (code 1)' and doesn't display any other information about the errors. Howshould I do to find out the bugs?
PS: The code I pasted above is among the file which I think leading to the error.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado

- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora