-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_particle_solver_netcdf
executable file
·58 lines (45 loc) · 1.73 KB
/
build_particle_solver_netcdf
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
#!/bin/bash
#Note that this bash script is heavily based on that provided in
#PX913 workshop 7.
#The error catching section of this buildscript is taken from
#https://stackoverflow.com/questions/1024525/how-to-check-if-gcc-has-failed-returned-a-warning-or-succeeded-in-bash?noredirect=1&lq=1
#and adapted for gfortran.
#Name of main program file to compile, with version number.
filename="main_program.f90"
#All non netcdf library f90 files to compile, seperated by spaces
myprogramfiles="data_structures.f90 create_axis.f90 chargedensitygenerator.f90 fieldsolver.f90 particlevelocitysolver.f90 command_line.f90 particle_write_netcdf.f90 "$filename
#-----------CHANGE RUNTIME PARAMETERS HERE----------
nx=100
ny=100
problem='single'
#-------------------------------------------------
#Argument:
#Name of compiled file
outfile="particles_in_field"
#Name of compiler
fc=gfortran
#Use nf-config to grab the compile and link flags. Backticks run command and grab output
fflags=`nf-config --fflags`
flibs=`nf-config --flibs`
#Attempt to compile.
$fc -Wall -std=f2008 -g $fflags $myprogramfiles $flibs -o $outfile
#test if the output from this line is non 0 (indicating compiler failiure!)
if [ $? -ne 0 ]
then
echo "Compile failed!"
exit 1
fi
#Test compile again, this time with warnings being treated as as errors and returned.
#If the return value is now non-zero, the compile succeeded, but with warnings.
$fc -Wall -Werror -std=f2008 -g $fflags $myprogramfiles $flibs -o $outfile
if [ $? -ne 0 ]
then
echo "Compile succeeded, but with warnings"
exit 2
else
echo "Compile succeeded without warnings"
fi
#Run the file with the runtime parameters specified above
echo "Running file"
./$outfile nx=$nx ny=$ny problem=$problem
python3 plot.py