forked from johannesgerer/jburkardt-f
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathex1_gfortran_gcc.sh
44 lines (44 loc) · 926 Bytes
/
ex1_gfortran_gcc.sh
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
#!/bin/bash
#
# Compile the FORTRAN file.
#
gfortran -c -fno-underscoring ex1_main.f90 >& compiler.txt
if [ $? -ne 0 ]; then
echo "Errors compiling ex1_main.f90"
exit
fi
rm compiler.txt
#
# Compile the C file.
#
gcc -c ex1_sub.c >& compiler.txt
if [ $? -ne 0 ]; then
echo "Errors compiling ex1_sub.c"
exit
fi
rm compiler.txt
#
# Use the GFORTRAN program to load.
# In some cases, the C libraries may need to be included,
# using an argument like "-lc", as well as the C math libraries,
# using an argument like "-lm".
#
gfortran ex1_main.o ex1_sub.o -lc -lm
if [ $? -ne 0 ]; then
echo "Errors linking and loading ex1_main.o + ex1_sub.o"
exit
fi
#
mv a.out ex1_gfortran_gcc
rm *.o
#
# Run the program.
#
ex1_gfortran_gcc > ex1_gfortran_gcc_output.txt
if [ $? -ne 0 ]; then
echo "Errors running ex1_gfortran_gcc."
exit
fi
rm ex1_gfortran_gcc
#
echo "Program output written to ex1_gfortran_gcc_output.txt"