1 | #!/bin/ksh |
---|
2 | |
---|
3 | # install_rrtmg - install script for creating a RRTMG library |
---|
4 | |
---|
5 | #--------------------------------------------------------------------------------# |
---|
6 | # This file is part of the PALM model system. |
---|
7 | # |
---|
8 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
9 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
10 | # either version 3 of the License, or (at your option) any later version. |
---|
11 | # |
---|
12 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
14 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License along with |
---|
17 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | # |
---|
19 | # Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
20 | #--------------------------------------------------------------------------------# |
---|
21 | # |
---|
22 | # Current revisions: |
---|
23 | # ------------------ |
---|
24 | # |
---|
25 | # |
---|
26 | # Former revisions: |
---|
27 | # ----------------- |
---|
28 | # $Id: install_rrtmg 2718 2018-01-02 08:49:38Z witha $ |
---|
29 | # |
---|
30 | # 1613 2015-07-08 14:53:29Z maronga |
---|
31 | # Bugfix: compilation of shared library fails due to misplaced rm command |
---|
32 | # |
---|
33 | # 1585 2015-04-30 07:05:52Z maronga |
---|
34 | # Initial revision |
---|
35 | # |
---|
36 | #--------------------------------------------------------------------------------# |
---|
37 | # install_rrtmg - install script for creating a RRTMG library |
---|
38 | #--------------------------------------------------------------------------------# |
---|
39 | |
---|
40 | # the following variables must be modified for the local system according to |
---|
41 | # .mrun.config |
---|
42 | # |
---|
43 | # Example 1 (lcmuk): |
---|
44 | # compiler_name="mpif90" |
---|
45 | # fopts="-fltconsistency -O3 -cpp -r8 -nbs -convert little_endian -I /muksoft/packages/netcdf/4_intel/include" |
---|
46 | # fopts_trace="-fpe0 -C -check nooutput_conversion -debug -traceback -g -w -xT -O0 -ftz -fno-alias -no-prec-div -no-prec-sqrt -ip -nbs -convert little_endian -diag-disable 8290,8291 -I /muksoft/packages/netcdf/4_intel/include" |
---|
47 | # |
---|
48 | # Example 2 (lccrayh): |
---|
49 | # compiler_name="ftn" |
---|
50 | # fopts="-em -s real64 -O3 -hnoomp -hfp3 -hdynamic" |
---|
51 | # fopts_trace="-eD -em -g -R b -K trap=fp -O0 -hnoomp" |
---|
52 | # |
---|
53 | # |
---|
54 | |
---|
55 | compiler_name="mpif90" |
---|
56 | fopts="-fltconsistency -O3 -cpp -r8 -nbs -convert little_endian -I /muksoft/packages/netcdf/4_intel/include" |
---|
57 | fopts_trace="-fpe0 -C -check nooutput_conversion -debug -traceback -g -w -xT -O0 -ftz -fno-alias -no-prec-div -no-prec-sqrt -ip -nbs -convert little_endian -diag-disable 8290,8291 -I /muksoft/packages/netcdf/4_intel/include" |
---|
58 | install_path="$HOME/rrtmg" |
---|
59 | compile_static=false |
---|
60 | compile_shared=false |
---|
61 | compile_static_debug=true |
---|
62 | compile_shared_debug=true |
---|
63 | |
---|
64 | while getopts p: option |
---|
65 | do |
---|
66 | case $option in |
---|
67 | (p) install_path=$OPTARG;; |
---|
68 | |
---|
69 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
70 | printf "\n --> type \"$0 ?\" for available options \n" |
---|
71 | locat=parameter;exit;; |
---|
72 | esac |
---|
73 | done |
---|
74 | |
---|
75 | (( to_shift = $OPTIND - 1 )) |
---|
76 | shift $to_shift |
---|
77 | |
---|
78 | # PRINT SHORT DESCRIPTION OF OPTIONS |
---|
79 | if [[ "$1" = "?" ]] |
---|
80 | then |
---|
81 | (printf "\n *** rrtmg_install can be called as follows:\n" |
---|
82 | printf "\n rrtmg_install -p.\n" |
---|
83 | printf "\n Description of available options:\n" |
---|
84 | printf "\n Option Description Default-Value" |
---|
85 | printf "\n -p installation path ./" |
---|
86 | |
---|
87 | printf "\n " |
---|
88 | printf "\n Possible values of positional parameter <modus>:" |
---|
89 | printf "\n \"?\" - this outline \n\n") | more |
---|
90 | exit |
---|
91 | elif [[ "$1" != "" ]] |
---|
92 | then |
---|
93 | printf "\n +++ positional parameter $1 unknown \n" |
---|
94 | locat=parameter; exit |
---|
95 | fi |
---|
96 | |
---|
97 | prog="librrtmg" |
---|
98 | version="1.0" |
---|
99 | |
---|
100 | |
---|
101 | # 1 static |
---|
102 | |
---|
103 | if [[ $compile_static = true ]] |
---|
104 | then |
---|
105 | printf "\n Start compiling static library $prog... (make)\n\n" |
---|
106 | mkdir -p static/lib |
---|
107 | mkdir -p static/include |
---|
108 | make -f Makefile_static F90=$compiler_name PROG=$prog F90FLAGS="$fopts" |
---|
109 | cp $prog.a static/lib |
---|
110 | cp *.mod static/include |
---|
111 | make -f Makefile_static clean |
---|
112 | mkdir -p $install_path/static/lib |
---|
113 | mkdir -p $install_path/static/include |
---|
114 | cp static/lib/$prog.a $install_path/static/lib |
---|
115 | cp static/include/*.mod $install_path/static/include/ |
---|
116 | rm -rf static |
---|
117 | printf "\n finished.\n" |
---|
118 | fi |
---|
119 | |
---|
120 | # 2 static debug |
---|
121 | if [[ $compile_static_debug = true ]] |
---|
122 | then |
---|
123 | printf "\n Start compiling static debug library $prog... (make)\n\n" |
---|
124 | mkdir -p static_trace/lib |
---|
125 | mkdir -p static_trace/include |
---|
126 | make -f Makefile_static F90=$compiler_name PROG=$prog F90FLAGS="$fopts_trace" |
---|
127 | cp $prog.a static_trace/lib |
---|
128 | cp *.mod static_trace/include |
---|
129 | make -f Makefile_static clean |
---|
130 | mkdir -p $install_path/static_trace/lib |
---|
131 | mkdir -p $install_path/static_trace/include |
---|
132 | cp static_trace/lib/$prog.a $install_path/static_trace/lib |
---|
133 | cp static_trace/include/*.mod $install_path/static_trace/include/ |
---|
134 | rm -rf static_trace |
---|
135 | printf "\n finished.\n" |
---|
136 | fi |
---|
137 | |
---|
138 | # 3 shared |
---|
139 | if [[ $compile_shared = true ]] |
---|
140 | then |
---|
141 | printf "\n Start compiling shared (dynamic) library $prog... (make)\n\n" |
---|
142 | mkdir -p shared/lib |
---|
143 | mkdir -p shared/include |
---|
144 | make -f Makefile F90=$compiler_name PROG=$prog F90FLAGS="$fopts" |
---|
145 | cp $prog.so shared/lib/$prog.so.$version |
---|
146 | cp *.mod shared/include/ |
---|
147 | make -f Makefile clean |
---|
148 | mkdir -p $install_path/shared/lib |
---|
149 | mkdir -p $install_path/shared/include |
---|
150 | cp shared/lib/$prog.so.$version $install_path/shared/lib/ |
---|
151 | cp shared/include/*.mod $install_path/shared/include/ |
---|
152 | if [ -f $install_path/shared/lib/$prog.so.1 ] |
---|
153 | then |
---|
154 | rm $install_path/shared/lib/$prog.so.1 |
---|
155 | fi |
---|
156 | ln -s $install_path/shared/lib/$prog.so.$version $install_path/shared/lib/$prog.so.1 |
---|
157 | if [ -f $install_path/shared/lib/$prog.so ] |
---|
158 | then |
---|
159 | rm $install_path/shared/lib/$prog.so |
---|
160 | fi |
---|
161 | ln -s $install_path/shared/lib/$prog.so.1 $install_path/shared/lib/$prog.so |
---|
162 | rm -rf shared |
---|
163 | printf "\n finished.\n" |
---|
164 | fi |
---|
165 | |
---|
166 | # 4 shared debug |
---|
167 | if [[ $compile_static_debug = true ]] |
---|
168 | then |
---|
169 | printf "\n Start compiling shared debug library $prog... (make)\n\n" |
---|
170 | mkdir -p shared_trace/lib |
---|
171 | mkdir -p shared_trace/include |
---|
172 | make -f Makefile F90=$compiler_name PROG=$prog F90FLAGS="$fopts_trace" |
---|
173 | cp $prog.so shared_trace/lib/$prog.so.$version |
---|
174 | cp *.mod shared_trace/include/ |
---|
175 | make -f Makefile clean |
---|
176 | mkdir -p $install_path/shared_trace/lib |
---|
177 | mkdir -p $install_path/shared_trace/include |
---|
178 | cp shared_trace/lib/$prog.so.$version $install_path/shared_trace/lib |
---|
179 | cp shared_trace/include/*.mod $install_path/shared_trace/include/ |
---|
180 | if [ -f $install_path/shared_trace/lib/$prog.so.1 ] |
---|
181 | then |
---|
182 | rm $install_path/shared_trace/lib/$prog.so.1 |
---|
183 | fi |
---|
184 | ln -s $install_path/shared_trace/lib/$prog.so.$version $install_path/shared_trace/lib/$prog.so.1 |
---|
185 | if [ -f $install_path/shared_trace/lib/$prog.so ] |
---|
186 | then |
---|
187 | rm $install_path/shared_trace/lib/$prog.so |
---|
188 | fi |
---|
189 | ln -s $install_path/shared_trace/lib/$prog.so.1 $install_path/shared_trace/lib/$prog.so |
---|
190 | rm -rf shared_trace |
---|
191 | printf "\n finished.\n" |
---|
192 | fi |
---|
193 | |
---|
194 | printf "\n Libraries $prog are installed in \"$install_path\".\n\n" |
---|
195 | printf "\n\n *** all actions complete." |
---|
196 | |
---|