-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·165 lines (137 loc) · 4.96 KB
/
install.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# Install script for SEIDART toolbox
# ----------------------------- Anaconda install ------------------------------
VER="v0.2"
echo "--------------------------------------------
SeidarT Anaconda-based installer $VER
Univ. of Maine / Univ. of Washington, 2020
--------------------------------------------
This installer will check for Anaconda/Miniconda
and install a SeidarT environment prior to compiling from
source.
You will have the option to install Miniconda
if no existing conda is found.
Please follow instructions in prompts.
"
read -rp $'Press Enter to continue...\n'
echo '
Do you wish to delete source files after installation?
This will not affect how the program runs, but you will
not be able to edit source code.
'
# ask if we should enable pure end-user mode and delete the source scripts
read -rp $'Type "yes" and press Enter to delete source files. (default: no)\n' EUMODE
if [[ "$EUMODE" == "yes" || "$EUMODE" == "Yes" || "$EUMODE" == "YES" ]] ; then
# end-user mode
EUMODE="yes"
else
# developer mode
unset EUMODE
echo "Developer mode enabled. Source scripts will not be deleted."
fi
bash conda_deps.sh ||
echo "Conda installation failed. Try installing dependencies the run the noconda_install script." ||
exit 1
`grep etc/profile.d/conda.sh ~/.bashrc` &&
conda activate SeidarT &&
echo "conda activate SeidarT : Successfully activated SeidarT environment." ||
echo "Could not find SeidarT conda environment. Exiting." ||
exit 1
echo ""
echo "Starting compiling/installation process..."
# -----------------------------------------------------------------------------
# Make sure we have a folder to put everything in
if [ ! -d "bin" ]; then
mkdir bin
fi
# --------------------------------- Clean Up ----------------------------------
# Typically, install will overwrite everything but when there is a compile
# error this can make debugging difficult if it goes unnoticed. Not everyone
# can read the f2py or gfortran outputs
# Just clean up if specified
CLEAN=${1:-"none"}
if [[ $CLEAN == "clean" ]] ; then
# Clear the bin folder
rm -rf bin/*
# Remove .mod and .o (if any) files generated during the fortran compile
rm fdtd/*.mod
rm fdtd/*.o
exit 1
fi
# -----------------------------------------------------------------------------
# Make sure everything is in unix format
dos2unix vis/*
dos2unix survey_wrappers/*
dos2unix exe/*
dos2unix materials/*
dos2unix fdtd/*
# Compile the fortran code
#2D
cd fdtd
f2py3 -c --fcompiler=gnu95 -DNPY_NO_DEPRECATED_API -m emfdtd2d emFDTD2D.f95
f2py3 -c --fcompiler=gnu95 -DNPY_NO_DEPRECATED_API -m seismicfdtd2d seismicFDTD2D.f95
f2py3 -c --fcompiler=gnu95 -DNPY_NO_DEPRECATED_API -m emfdtd25d emFDTD25D.f95
f2py3 -c --fcompiler=gnu95 -DNPY_NO_DEPRECATED_API -m seismicfdtd25d seismicFDTD25D.f95
mv *.so ../bin
cd ..
# Synthetic microstructure
cd materials
f2py3 -c --fcompiler=gnu95 -m orientsynth orientsynth.f95
mv *.so ../bin
cd ..
# --------------------------- Create the executables --------------------------
# Start with the python scripts
cp exe/prjbuild.py bin/prjbuild
cp exe/prjrun.py bin/prjrun
cp exe/sourcefunction.py bin/sourcefunction
cp materials/orientation_tensor.py bin/orientation_tensor
# Move the visualization tools
cp vis/arraybuild.py bin/arraybuild
cp vis/rcxdisplay.py bin/rcxdisplay
cp vis/im2anim.py bin/im2anim
cp vis/vtkbuild.py bin/vtkbuild
cp vis/wiggleplot.py bin/wiggleplot
cp vis/imgen.py bin/imgen.py # The generalized image functions module
cp vis/imvector.py bin/imvector
cp vis/vectoranim.py bin/vectoranim
cp vis/implot.py bin/implot
# move the conversion scripts
cp io/array2segy.py bin/array2segy
# Change them to executables
chmod +x bin/prjbuild \
bin/prjrun \
bin/sourcefunction \
bin/arraybuild \
bin/rcxdisplay \
bin/wiggleplot \
bin/im2anim \
bin/orientation_tensor \
bin/array2segy \
bin/vtkbuild \
bin/imvector \
bin/vectoranim \
bin/implot
# Now do the bash scripts
cp survey_wrappers/common_offset bin/common_offset
cp survey_wrappers/common_midpoint bin/common_midpoint
cp io/array2sac bin/array2sac
chmod +x bin/common_offset bin/common_midpoint bin/array2sac
# ---------------- Move all other required files to bin folder ----------------
cp materials/material_functions.py bin/material_functions.py
cp materials/definitions.py bin/definitions.py
if [ ! -z ${EUMODE+x} ]; then
echo "Deleting source files..."
rm -rfv exe materials vis io survey_wrappers
echo '
[end user mode]:
Source files deleted. You will need to download the
software again if you would like to edit source files.
Developers should not commit changes on this branch as
this will cause unwanted consequences in source control.
Developers can also use the git command "git restore ."
to restore all deleted files to source control.'
unset EUMODE
fi
echo '
Done!
Type "conda activate SeidarT" to access the SeidarT environment.'