## Just replace Hello throughout with your chare's name. ##
## and add your chare's personal data below where indicated ##
## Everything else remains the same ##
MODULE HelloMod
TYPE Hello
## your chare's data goes here ##
integer data
END TYPE
TYPE HelloPtr
TYPE (Hello), POINTER :: obj
integer*8 aid
END TYPE
END MODULE
In the Fortran file you must write an allocate funtion for this chare with the name: Hello_allocate.
## Just replace Hello throughout with your chare's name. ##
## Everything else remains the same ##
SUBROUTINE Hello_allocate(objPtr, aid, index)
USE HelloMod
TYPE(HelloPtr) objPtr
integer*8 aid
integer index
allocate(objPtr%obj)
objPtr%aid = aid;
## you can initialize the Chare user data here
objPtr%obj%data = index
END SUBROUTINE
Now that you have the chare and the chare constructor function, you can start to write one or more entry functions as declared in .ci files.
## p1, p2, etc represent user parameters
## the "objPtr, myIndex" stuff is required in every Entry Point.
## CkExit() must be called by the chare to terminate.
SUBROUTINE SayHi(objPtr, myIndex, data, data2, len, s)
USE HelloMod
IMPLICIT NONE
TYPE(HelloPtr) objPtr
integer myIndex
integer data
double precision data2
integer len
integer s(len)
objPtr%obj%data = 20
if (myIndex < 4) then
call SendTo_Hello_SayHi(objPtr%aid, myIndex+1, 1, data2, len, s);
else
call CkExit()
endif
Now, you can write the main program to create the chare array and start the program by sending the first message.
SUBROUTINE f90charmmain()
USE HelloMod
integer i
double precision d
integer*8 aid
integer s(8)
call Hello_CkNew(5, aid)
call set_ChunkSize(10);
do i=1,8
s(i) = i;
enddo
d = 2.50
call SendTo_Hello_SayHi(aid, 0, 1, d, 4, s(3:6));
END
This main program creates an chare array Hello of size 5 and send a message with
an integer, an double and array of integers to the array element of index 0.
June 29, 2008
Charm Homepage