Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
QuickSched
Commits
86dea08e
Commit
86dea08e
authored
8 years ago
by
Aidan Chalk
Browse files
Options
Downloads
Patches
Plain Diff
started on a naive n squared particle algorithm using tasks
parent
0ac73215
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fortran_examples/test_n2.F90
+174
-0
174 additions, 0 deletions
fortran_examples/test_n2.F90
with
174 additions
and
0 deletions
fortran_examples/test_n2.F90
0 → 100644
+
174
−
0
View file @
86dea08e
!*******************************************************************************
!* This file is part of QuickSched.
! * Coypright (c) 2017 Aidan Chalk (aidan.chalk@stfc.ac.uk)
! *
! * This program is free software: you can redistribute it and/or modify
! * it under the terms of the GNU Lesser General Public License as published
! * by the Free Software Foundation, either version 3 of the License, or
! * (at your option) any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public License
! * along with this program. If not, see <http://www.gnu.org/licenses/>.
! *
! ******************************************************************************/
Module
parts
Use
,
Intrinsic
::
ISO_C_BINDING
Implicit
None
Integer
,
Parameter
::
sp
=
Selected_Real_Kind
(
6
,
37
)
! single real
Integer
,
Parameter
::
dp
=
Selected_Real_Kind
(
15
,
307
)
! double real
Integer
(
Kind
=
C_INT
),
Parameter
::
type_self
=
1
,
type_pair
=
2
Type
Cell
Real
(
Kind
=
dp
),
dimension
(:),
Allocatable
::
fx
,
fy
,
fz
,
dx
,
dy
,
dz
Integer
::
num_parts
End
Type
Cell
Type
(
Cell
),
Dimension
(:),
Allocatable
::
cells
Contains
Subroutine
Interact_single
(
cell_i
)
Integer
::
i
,
j
End
Subroutine
Subroutine
Interact
(
cell_i
,
cell_j
)
Integer
,
Intent
(
in
)
::
cell_i
,
cell_j
Integer
::
i
,
j
Real
(
Kind
=
dp
)
::
xx
,
yy
,
zz
,
r
,
f
,
ir
,
ir6
,
ir12
,
fxx
,
fyy
,
fzz
,
fix
,
fiy
,
fiz
do
i
=
1
,
cells
(
cell_i
)
%
num_parts
fix
=
0.0_dp
fiy
=
0.0_dp
fiz
=
0.0_dp
do
j
=
1
,
cells
(
cell_j
)
%
num_parts
xx
=
cells
(
cell_i
)
%
dx
(
i
)
-
cells
(
cell_j
)
%
dx
(
j
)
yy
=
cells
(
cell_i
)
%
dy
(
i
)
-
cells
(
cell_j
)
%
dy
(
j
)
zz
=
cells
(
cell_i
)
%
dz
(
i
)
-
cells
(
cell_j
)
%
dz
(
j
)
r
=
xx
*
xx
+
yy
*
yy
+
zz
*
zz
r
=
sqrt
(
r
)
ir
=
0.1_dp
/
r
ir6
=
ir
*
ir
ir6
=
ir6
*
ir6
*
ir6
ir12
=
ir6
*
ir6
f
=
4.0_dp
*
(
ir12
-
ir6
)
fxx
=
f
*
xx
fyy
=
f
*
yy
fzz
=
f
*
zz
fix
=
fix
+
fxx
fiy
=
fiy
+
fyy
fiz
=
fiz
+
fzz
cells
(
cell_j
)
%
fx
(
j
)
=
cells
(
cell_j
)
%
fx
(
j
)
-
fxx
cells
(
cell_j
)
%
fy
(
j
)
=
cells
(
cell_j
)
%
fy
(
j
)
-
fyy
cells
(
cell_j
)
%
fz
(
j
)
=
cells
(
cell_j
)
%
fz
(
j
)
-
fzz
end
do
cells
(
cell_i
)
%
fx
(
i
)
=
cells
(
cell_i
)
%
fx
(
i
)
+
fix
cells
(
cell_i
)
%
fy
(
i
)
=
cells
(
cell_i
)
%
fy
(
i
)
+
fiy
cells
(
cell_i
)
%
fz
(
i
)
=
cells
(
cell_i
)
%
fz
(
i
)
+
fiz
end
do
End
Subroutine
Subroutine
init_cells
(
cell_num
,
count
)
Integer
,
Intent
(
in
)
::
cell_num
,
count
Allocate
(
cells
(
cell_num
)
%
fx
(
1
:
count
))
Allocate
(
cells
(
cell_num
)
%
fy
(
1
:
count
))
Allocate
(
cells
(
cell_num
)
%
fz
(
1
:
count
))
Allocate
(
cells
(
cell_num
)
%
dx
(
1
:
count
))
Allocate
(
cells
(
cell_num
)
%
dy
(
1
:
count
))
Allocate
(
cells
(
cell_num
)
%
dz
(
1
:
count
))
cells
(
cell_num
)
%
fx
=
0.0_dp
cells
(
cell_num
)
%
fy
=
0.0_dp
cells
(
cell_num
)
%
fz
=
0.0_dp
Call
Random_Number
(
cells
(
cell_num
)
%
dx
)
Call
Random_Number
(
cells
(
cell_num
)
%
dy
)
Call
Random_Number
(
cells
(
cell_num
)
%
dz
)
dx
=
dx
*
10.0_dp
dy
=
dy
*
10.0_dp
dz
=
dz
*
10.0_dp
End
Subroutine
init_cells
Subroutine
runner
(
typ
,
data
)
BIND
(
C
)
Use
,
Intrinsic
::
ISO_C_BINDING
Use
quicksched
Implicit
None
Integer
(
Kind
=
C_INT
),
VALUE
::
typ
Type
(
C_PTR
),
VALUE
::
data
Integer
(
Kind
=
C_INT
),
Pointer
::
c
(:)
call
c_f_pointer
(
data
,
c
,
[
2
])
If
(
typ
==
type_self
)
then
else
call
Interact
(
c
(
1
),
c
(
2
))
end
if
End
Subroutine
runner
End
Module
parts
Program
main
Use
,
Intrinsic
::
ISO_C_BINDING
Use
quicksched
Use
parts
Implicit
None
Integer
(
Kind
=
C_INT
)
::
i
,
j
,
temp
Type
(
C_PTR
)
::
sched
Integer
(
Kind
=
C_INT
),
Target
::
data
(
0
:
10
)
Type
(
C_PTR
)
::
dta_ptr
Integer
(
Kind
=
C_INT
),
Dimension
(
1
:
1000
)
::
cell_res
Allocate
(
cells
(
1
:
1000
))
do
i
=
1
,
1000
call
cell_init
(
i
,
1000
)
end
do
sched
=
f_qsched_create
()
call
qsched_init
(
qsched
,
24
,
0
)
do
i
=
1
,
1000
cell_res
(
i
)
=
qsched_addres
(
qsched
,
qsched_owner_none
,
qsched_res_none
)
end
do
do
i
=
1
,
1000
data
do
j
=
i
+1
,
1000
end
do
end
do
end
Program
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment