compile.sh 6.97 KB
Newer Older
Cedric Jourdain's avatar
Cedric Jourdain committed
1
2
3
4
5
#!/bin/bash
echo "==> Choose supercomputer :"
echo "     - occigen"
echo "     - marenostrum "
echo "     - marconi-knl "
6
echo "     - daint-gpu "
Cedric Jourdain's avatar
Cedric Jourdain committed
7
echo "     - daint-cpu-only "
Cedric Jourdain's avatar
Cedric Jourdain committed
8
echo "     - davide "
Cedric Jourdain's avatar
Cedric Jourdain committed
9
echo "     - juwels"
10
echo "     - juwels_2018"
11
12
echo "     - irene-skl "
echo "     - irene-knl "
13
echo "     - dibona "
14
echo "     - frioul "
15
16
echo "     - deepsdv "
echo "     - hazelhen  "
17
18
echo "     - vega-gpu"
echo "     - vega-cpu"
19
20
echo "     - marconi100  "

Cedric Jourdain's avatar
Cedric Jourdain committed
21
22
read machine

23
24
export NEX_XI=384 #384 #416 #352 #320 #288 #256 #224 #192 #160 #128 #96 #288
export NPROC_XI=4
Cedric Jourdain's avatar
Cedric Jourdain committed
25
26
27
28
29
30
source ./env/env_${machine}

Untar(){
    echo "==> Untar "
    #Clone the repository
    cd $install_dir
31
32
33
34
35
36
37
    git -c http.sslVerify=false clone  https://github.com/geodynamics/specfem3d_globe.git
    code=$?
    if [[  $code != "0" ]]; then
        echo "Git clone failed, try a hard copy:"        
        Copy 
    else
        cd specfem3d_globe/
38
39
        git checkout b1d6ba966496f269611eff8c2cf1f22bcdac2bd9	# Checkout of 31 ocotbre 2017 version
        #git checkout v7.0.2	# Checkout v7.0.2, last version : unstable : tested on differents architectures and all simulations failed
40
41
42
43
44
45
    fi
    cd $ueabs_dir
}

Copy(){
    # Copy sources (Edit source_dir if needed)
46
47
48
    source_dir=$HOME/git/specfem3d_globe
    echo "Copy source"
    cp -r $source_dir $install_dir
Cedric Jourdain's avatar
Cedric Jourdain committed
49
50
51
52
53
}

Install(){
    echo "===>  Configure "
    answer=0
54
55
56
    echo "1. small_benchmark_run_to_test_more_complex_Earth : specfem3D_globe native benchmark to validate the behaviour of the code designed to run on 24 MPI process"
    echo "2. Test Case A is designed to run on Tier-1 sized systems (up to around 1,000 x86 cores, or equivalent)"
    echo "3. Test Case B is designed to run on Tier-0 sized systems (up to around 10,000 x86 cores, or equivalent)"
Cedric Jourdain's avatar
Cedric Jourdain committed
57
58
    while true
    do
59
        echo "===> Choose Test Case : (1, 2, or 3)"
Cedric Jourdain's avatar
Cedric Jourdain committed
60
        read answer
61
        if [[ $answer -eq 1 || $answer -eq 2 || $answer -eq 3 ]]; then break;fi
Cedric Jourdain's avatar
Cedric Jourdain committed
62
63
    done
    if [ $answer = "1" ]; then
64
65
66
67
68
69
	echo "===> small_benchmark_run_to_test_more_complex_Earth"
	cd $install_dir/specfem3d_globe/EXAMPLES/small_benchmark_run_to_test_more_complex_Earth
	sed -i "38a ./configure  --enable-openmp" run_this_example.sh
	echo "compilation proccess will be done directly in the job"
	exit 
    elif [ $answer = "2" ]; then
Cedric Jourdain's avatar
Cedric Jourdain committed
70
        echo "===> Copy test case A"
71
72
73
	export install_dir=$install_dir/TestCaseA
	mkdir -p $install_dir
	mv $install_dir/../specfem3d_globe  $install_dir/.
74
        cp test_cases/SPECFEM3D_TestCaseA/* $install_dir/specfem3d_globe/DATA/.
75
76
77
78
	sed -i s/"NEX_XI                          = 384"/"NEX_XI                          = $NEX_XI"/g $install_dir/specfem3d_globe/DATA/Par_file
	sed -i s/"NEX_ETA                         = 384"/"NEX_ETA                          = $NEX_XI"/g $install_dir/specfem3d_globe/DATA/Par_file
	sed -i s/"NPROC_XI                        = 4"/"NPROC_XI                        = $NPROC_XI"/g $install_dir/specfem3d_globe/DATA/Par_file
	sed -i s/"NPROC_ETA                       = 4"/"NPROC_ETA                       = $NPROC_XI"/g $install_dir/specfem3d_globe/DATA/Par_file
79
    elif [ $answer = "3" ]; then
Cedric Jourdain's avatar
Cedric Jourdain committed
80
        echo "===> Copy test case B"
81
82
83
	export install_dir=$install_dir/TestCaseB
	mkdir -p $install_dir
	mv $install_dir/../specfem3d_globe  $install_dir/.
84
        cp test_cases/SPECFEM3D_TestCaseB/* $install_dir/specfem3d_globe/DATA/.
Cedric Jourdain's avatar
Cedric Jourdain committed
85
86
    fi
    cd $install_dir/specfem3d_globe
87
88
    #Clean Configuration
    rm Makefile bin/*
Cedric Jourdain's avatar
Cedric Jourdain committed
89
    if [ $machine = "daint-gpu" ] || [ $machine = "davide" ]; then
90
91
92
	echo "Configure for CPU+GPU system"
	### replace `use mpi` if needed ###
	#cd utils
93
94
	#perl replace_use_mpi_with_include_mpif_dot_h.pl
	#cd ..
95
	sed -i s/"GPU_MODE                        = .false."/"GPU_MODE                        = .true."/g  $install_dir/specfem3d_globe/DATA/Par_file
Cedric Jourdain's avatar
Cedric Jourdain committed
96
97
98
99
100
	if [ $machine = "daint-gpu" ];then
		export MPI_INC=$MPICH_DIR/include
		export CUDA_LIB="$CUDATOOLKIT_HOME/lib64"
		export CUDA_INC="$CUDATOOLKIT_HOME/include"
	fi
101
	./configure --build=ppc64 --with-cuda=cuda5
102
103
104
105
106
    elif [ $machine = "vega-gpu" ]; then
	echo "Configure for Vega GPU partion"
	sed -i s/"GPU_MODE                        = .false."/"GPU_MODE                        = .true."/g  $install_dir/specfem3d_globe/DATA/Par_file
	sed -i s/"GPU_DEVICE                      = Tesla"/"GPU_DEVICE                      = *"/g  $install_dir/specfem3d_globe/DATA/Par_file
	./configure --build=ppc64 --with-cuda=cuda8 
107
108
109
110
111
112
    elif [ $machine = "marconi100" ]; then
        echo "Configure for Marconi100 GPU partion"
        sed -i s/"GPU_MODE                        = .false."/"GPU_MODE                        = .true."/g  $install_dir/specfem3d_globe/DATA/Par_file
        sed -i s/"GPU_DEVICE                      = Tesla"/"GPU_DEVICE                      = *"/g  $install_dir/specfem3d_globe/DATA/Par_file
        ./configure --build=ppc64 --with-cuda=cuda8
        sed -i s/"O4"/"O3"/g Makefile #-O4 is not supported with option -qoffload
113
114
    else
	echo "Configure for CPU only system"
115
        ./configure --enable-openmp
116
    fi
Cedric Jourdain's avatar
Cedric Jourdain committed
117
118
119
120
121
122
    echo $machine
    #if [ $machine = "occigen" ] || [ $machine = "marenostrum" ] || [ $machine = "marconi-knl" ];then
    #    echo "===> Edit Par_file (MemPerCor=50... )"
    #    sed -i s/"MEMORY_INSTALLED_PER_CORE_IN_GB = 2.5d0"/"MEMORY_INSTALLED_PER_CORE_IN_GB = 50d0"/g DATA/Par_file
    #fi
    echo "===> Build"
Cedric Jourdain's avatar
Cedric Jourdain committed
123
    make clean
Cedric Jourdain's avatar
Cedric Jourdain committed
124
125
126
    time -p make -j 12 all >& make.log &
}

Cedric Jourdain's avatar
Cedric Jourdain committed
127
Clean(){
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    if [ ! -z "$install_dir" ] && [ -d $install_dir ];then
	    echo "==> Clean installation directory"
	    answer=0
	    while true
            do
                echo "===> Choose Test Case to delete : (1, 2, or 3)"
                echo "1 : Not necessary to delete this folder"
                echo "2 : $install_dir/TestCaseA"
                echo "3 : $install_dir/TestCaseB"
                read answer
                if [[ $answer -eq 1 || $answer -eq 2 || $answer -eq 3 ]]; then break;fi
            done
            if [ $answer = "2" ]; then
                    rm -rf $install_dir/TestCaseA
            elif [ $answer = "3" ]; then
                    rm -rf $install_dir/TestCaseB
144
145
            elif [ $answer = "1" ]; then
                    rm -rf $install_dir/specfem3d_globe
146
147
148
149
150
151
152
            else
		    echo "Nothing has been deleted"
            fi
    else
	    echo "Error with install_dir variable"
	    exit
    fi
Cedric Jourdain's avatar
Cedric Jourdain committed
153
154
}

Cedric Jourdain's avatar
Cedric Jourdain committed
155
156
Deploy(){
    echo "install_dir ="$install_dir
157
    if [ $machine = "occigen" ] || [ $machine = "marenostrum" ] || [ $machine = "marconi-knl" ] || [ $machine = "daint-cpu-only" ] || [ $machine = "daint-gpu" ]  || [ $machine = "davide" ] || [ $machine = "juwels" ] || [ $machine = "irene-skl" ] || [ $machine = "irene-knl" ] || [ $machine = "dibona" ] || [ $machine = "frioul" ]  || [ $machine = "deepsdv" ] || [ $machine = "hazelhen" ] || [ $machine = "vega-cpu" ] || [ $machine = "vega-gpu" ] || [ $machine = "marconi100" ];then
Cedric Jourdain's avatar
Cedric Jourdain committed
158
        echo "==> Install on $machine :"
Cedric Jourdain's avatar
Cedric Jourdain committed
159
	mkdir -p $install_dir
160
	Clean
Cedric Jourdain's avatar
Cedric Jourdain committed
161
        export ueabs_dir=`pwd`
Cedric Jourdain's avatar
Cedric Jourdain committed
162
        Untar
Cedric Jourdain's avatar
Cedric Jourdain committed
163
164
        Install
    else
165
166
        echo "machine : $machine "
	echo "Wrong machine !"
Cedric Jourdain's avatar
Cedric Jourdain committed
167
168
169
170
171
        exit
    fi
}

Deploy