-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path1_setup_dyna.sh
110 lines (84 loc) · 3.05 KB
/
1_setup_dyna.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
#!/bin/bash --login
# directory of the current script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
echo $SCRIPTPATH
source /opt/intel/oneapi/setvars.sh --force
export PYTHONPATH=$SCRIPTPATH/umat:$PYTHONPATH
export PYTHONPATH=$SCRIPTPATH/external_packages:$PYTHONPATH
export PYTHONPATH=$SCRIPTPATH/mixed_languages:$PYTHONPATH
repo_files=repo_files
folder=lsdyna_object_version
folder_ref=lsdyna_object_version_ref
generate_patch() { diff -u $folder_ref/$1 $folder/$1 > $repo_files/$1.patch; }
mode="$1"
if [[ "$mode" == "quick" ]] || [[ "$mode" == "q" ]]; then
echo "Quick mode"
rm -rf $folder
cp -r $folder_ref $folder
elif [[ "$mode" == "debug" ]] || [[ "$mode" == "d" ]]; then
echo "use edited files"
else
echo "Normal mode"
# Install lsprepost
rm -rf lsprepost_common
wget -q https://ftp.lstc.com/anonymous/outgoing/lsprepost/4.10/linux64/lsprepost-4.10.2-common-05Apr2023.tgz -O ${PROJECT_DIR}/lsprepost.tgz
tar xf ${PROJECT_DIR}/lsprepost.tgz -C ${PROJECT_DIR}
mv lsprepost4.10_common lsprepost_common
rm -rf $folder $folder_ref
tar xf ls-dyna_smp_d_R12_0_0_x64_redhat65_ifort160.tgz && mv -f usermat $folder_ref
cp -rf $folder_ref $folder
fi
# fix file formatting, to install relevant tools: pip install yapf clang-format fprettify
# yapf -i **/**/umat.py
# clang-format -i **/**/*.cpp
# fprettify **/**/umat_elastic_44_14.F90
# fprettify **/**/umat_elastic_43_13.F90
# add new files from the git repo
ln -sf $(pwd)/$repo_files/* $folder
cp $folder/patch_files/* $folder
cd $folder
# apply batches when not debugging
if [[ "$mode" != "debug" ]] && [[ "$mode" != "d" ]]; then
# patch files generated with diff -u old new > ***.patch
# function defined in set_env.sh file
# call forpy_initialize and forpy_finalize only once
patch < init_dyn21.f.patch
patch < dyn21.f.patch
# compiler options
patch < Makefile.patch
# change Fortran comments from `c` to `!` in order to include in .f90 files
patch < nhisparm.inc.patch
# comment subroutine umat43 & subroutine umat44
patch < dyn21umats.f.patch
# comment subroutine umat43v & subroutine umat44v
patch < dyn21umatv.f.patch
# comment subroutine utan43, utan43v, utan44, utan44v
# also fixes a BUG in dyn21utan -> urtanh -> aux33loc
patch < dyn21utan.f.patch
# comment subroutine thumat13 & subroutine thumat14
patch < dyn21tumat.f.patch
# dae_rve [discontinued]
# patch < dyn21umat.f.patch
rm -rf *.patch
# patch files are generated via:
# generate_patch Makefile
# generate_patch dyn21umats.f
# generate_patch dyn21umatv.f
# generate_patch dyn21utan.f
# generate_patch dyn21tumat.f
# generate_patch nhisparm.inc
# generate_patch dyn21.f
# generate_patch init_dyn21.f
# generate_patch dyn21umat.f
fi
make -B
cd $SCRIPTPATH
chmod -R 777 lsdyna*
chmod -R 777 lsprepost*
# Debugging
# meld lsdyna_object_version_ref lsdyna_object_version
# configure debugging flags
# gdb-oneapi lsdyna_object_version/lsdyna
# run
# i=input.k