forked from adrienhaxaire/fortun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfortun_compile.f90
72 lines (43 loc) · 1.65 KB
/
fortun_compile.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module fortun_compile
implicit none
private
public :: compile_tests, compile_sources
contains
!-------------------------------------------------------------- compile_sources
subroutine compile_tests(test_files)
implicit none
character(len=*), dimension(:), intent(IN) :: test_files
print *, "Compiling tests..."
call compile(test_files)
print *, "Compilation of tests successful."
end subroutine compile_tests
!-------------------------------------------------------------- compile_sources
subroutine compile_sources(source_files)
implicit none
character(len=*), dimension(:), intent(IN) :: source_files
print *, "Compiling sources..."
call compile(source_files)
print *, "Compilation of source files successful."
end subroutine compile_sources
!---------------------------------------------------------------------- compile
subroutine compile(files)
use fortun_utils, only : CHAR_LENGTH
implicit none
character(len=*), dimension(:), intent(IN) :: files
character(CHAR_LENGTH) :: compile_cmd, cmd_prefix, file
integer :: i, error
cmd_prefix = 'gfortran -c -Wall -g -fbounds-check '
do i=1,size(files)
file = files(i)
compile_cmd = trim(cmd_prefix) // " " // trim(file)
print *, "Compiling " // trim(file)
call system(trim(compile_cmd), status=error)
if (error .ge. 1) then
print *, "Error occured during compilation. See log above."
print *, "The command was: " // trim(compile_cmd)
print *, "[fortun] stop"
stop
end if
end do
end subroutine compile
end module fortun_compile