-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.f90
44 lines (35 loc) · 1.57 KB
/
main.f90
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
program main
use, intrinsic :: iso_fortran_env
use mesh_generator
implicit none
! Command line arguments
integer :: argl
character(len=:), allocatable :: a
integer(kind=int64) :: box_size
real(kind=real64) :: edge_size
! Mesh variables
integer(kind=int64) :: num_nodes, num_elements, num_boundary_nodes, &
num_edges_per_boundary
integer(kind=int64), dimension(:, :), allocatable :: elements, boundary_edges
real(kind=real64), dimension(:, :), allocatable :: nodes
! Get command line args (Fortran 2003 standard)
if (command_argument_count() > 0) then
call get_command_argument(1, length=argl)
allocate(character(argl) :: a)
call get_command_argument(1, a)
read(a,*) box_size
call get_command_argument(2, a)
read(a,*) edge_size
end if
! Output start message
write(*,'(A)') "Generating mesh using:"
write(*,'(A,1I16)') "box size: ", box_size
write(*,*) " process: ", edge_size
call calculate_mesh_parameters(box_size, edge_size, num_edges_per_boundary, num_nodes, num_boundary_nodes, num_elements)
! Allocate arrays
allocate(nodes(2, num_nodes))
allocate(elements(3, num_elements))
allocate(boundary_edges(3, num_boundary_nodes))
call calculate_mesh(num_edges_per_boundary, num_nodes, num_elements, num_boundary_nodes, nodes, elements, boundary_edges)
call write_mesh_to_file(num_nodes, num_elements, num_boundary_nodes, nodes, elements, boundary_edges)
end program main