-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp0mod.f
51 lines (51 loc) · 1.36 KB
/
mp0mod.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
!-----------------------------------------------------------------------
!
module mp0d
!
! Fortran90 interface for initializing Multi-tasking library MacMP.f
! written by viktor k. decyk, ucla
! copyright 2000, regents of the university of california
! update: november 12, 2007
!
implicit none
private
public :: mpinit, ncpus, ntasks
!
! ncpus = number of cpus found
! ntasks = number of additional tasks for threaded programming
integer, save :: ncpus = 1, ntasks = 0
!
! define interface to original Fortran77 procedures
!
interface
subroutine MP_INIT(nproc)
implicit none
integer nproc
end subroutine
end interface
!
! define Fortran90 interface functions to Fortran77 library
!
contains
!
function mpinit(sntasks)
! initialize for multiprocessing
implicit none
integer mpinit
integer, optional :: sntasks
call MP_INIT(ncpus)
if (ncpus==0) then
write (2,*) 'MPLibrary not installed'
ntasks= 0
! return the number of processors on host computer
else
ntasks = ncpus - 1
! set specific number of tasks if requested
if (present(sntasks)) then
if (sntasks >= 0) ntasks = sntasks
endif
endif
mpinit = ntasks
end function
!
end module mp0d