- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi
What should I do in multithreading if I change from x32 to x64 in Visual studio Fortran. I've tried a simple multithread test program under win32 platform and it runs well. However, it cannot pass the build process if I change the configuration to X64 platform. I will appreciate if anybody could give some help, thanks
here is my test code:
use IFMT
external threadfunc
PARAMETER(mTHREAD=2)
common /thread/A(2,10000)
integer(4) para(mThread)
integer hthread(mthread),idthread(mthread),hticketmutex
logical(4) waitall
integer(4) nresult,nwaitresult,nticket
common /ticket/nticket
common/mutex/hticketmutex
NTICKET=1
HTICKETMUTEX=CREATEMUTEX(0,.FALSE.,0)
WAITALL=.TRUE.
DO I=1,mTHREAD
para(i)=i
HTHREAD(I)=CREATETHREAD(0,0,THREADFUNC,loc(para(i)),0,IDTHREAD(I))
END DO
NWAITRESULT=WAITFORMULTIPLEOBJECTS(mTHREAD,HTHREAD(1),WAITALL,
& WAIT_INFINITE)
LOU=CLOSEHANDLE(hTicketMutex)
DO IJ=1,mTHREAD
LOU=CLOSEHANDLE(HTHREAD(IJ))
IF(LOU.EQ.0) THEN
PRINT *,'FAIL TO CLOSE HANDLES HTHREAD'
STOP
END IF
END DO
DO I=1,4
WRITE(*,*) A(1,I),A(2,I)
END DO
PAUSE
STOP
END
integer(4) function threadfunc(arg)
use IFMT
PARAMETER(mTHREAD=2)
common /thread/A(2,10000)
integer(4) arg
integer hticketmutex
logical(4) waitall
integer(4) nresult,nwaitresult,nticket
common /ticket/nticket
common/mutex/hticketmutex
nwaitresult=waitforsingleobject(hticketmutex,WAIT_INFINITE)
K1=NTICKET
nticket=nticket+1
DO I=1,10000
A(K1,I)=I*K1
END DO
threadfunc = 0
end function
Error 1 error #6284: There is no matching specific function for this generic function reference. [CREATEMUTEX] C:\jiang\Multithread tests\mt\mtest.FOR 16
Error 2 error #6284: There is no matching specific function for this generic function reference. [CREATETHREAD] C:\jiang\Multithread tests\mt\mtest.FOR 20
these codes work well under 32bit configurartion. Does it mean I need to use some different functions (such as CREATEMUTEX, CREATETHREAD) or change the configuration in project properties under X64 platform?
thanks again
What should I do in multithreading if I change from x32 to x64 in Visual studio Fortran. I've tried a simple multithread test program under win32 platform and it runs well. However, it cannot pass the build process if I change the configuration to X64 platform. I will appreciate if anybody could give some help, thanks
here is my test code:
use IFMT
external threadfunc
PARAMETER(mTHREAD=2)
common /thread/A(2,10000)
integer(4) para(mThread)
integer hthread(mthread),idthread(mthread),hticketmutex
logical(4) waitall
integer(4) nresult,nwaitresult,nticket
common /ticket/nticket
common/mutex/hticketmutex
NTICKET=1
HTICKETMUTEX=CREATEMUTEX(0,.FALSE.,0)
WAITALL=.TRUE.
DO I=1,mTHREAD
para(i)=i
HTHREAD(I)=CREATETHREAD(0,0,THREADFUNC,loc(para(i)),0,IDTHREAD(I))
END DO
NWAITRESULT=WAITFORMULTIPLEOBJECTS(mTHREAD,HTHREAD(1),WAITALL,
& WAIT_INFINITE)
LOU=CLOSEHANDLE(hTicketMutex)
DO IJ=1,mTHREAD
LOU=CLOSEHANDLE(HTHREAD(IJ))
IF(LOU.EQ.0) THEN
PRINT *,'FAIL TO CLOSE HANDLES HTHREAD'
STOP
END IF
END DO
DO I=1,4
WRITE(*,*) A(1,I),A(2,I)
END DO
PAUSE
STOP
END
integer(4) function threadfunc(arg)
use IFMT
PARAMETER(mTHREAD=2)
common /thread/A(2,10000)
integer(4) arg
integer hticketmutex
logical(4) waitall
integer(4) nresult,nwaitresult,nticket
common /ticket/nticket
common/mutex/hticketmutex
nwaitresult=waitforsingleobject(hticketmutex,WAIT_INFINITE)
K1=NTICKET
nticket=nticket+1
DO I=1,10000
A(K1,I)=I*K1
END DO
threadfunc = 0
end function
Error 1 error #6284: There is no matching specific function for this generic function reference. [CREATEMUTEX] C:\jiang\Multithread tests\mt\mtest.FOR 16
Error 2 error #6284: There is no matching specific function for this generic function reference. [CREATETHREAD] C:\jiang\Multithread tests\mt\mtest.FOR 20
these codes work well under 32bit configurartion. Does it mean I need to use some different functions (such as CREATEMUTEX, CREATETHREAD) or change the configuration in project properties under X64 platform?
thanks again
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please repost this in the Fortran for Windows forum.
Also, try changing the types for your handles to HANDLE as opposed to integer(4)
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page