[1585] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | # install_rrtmg - install script for creating a RRTMG library |
---|
| 4 | |
---|
| 5 | #--------------------------------------------------------------------------------# |
---|
| 6 | # This file is part of PALM. |
---|
| 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-2015 Leibniz Universitaet Hannover |
---|
| 20 | #--------------------------------------------------------------------------------# |
---|
| 21 | # |
---|
| 22 | # Current revisions: |
---|
| 23 | # ------------------ |
---|
[1613] | 24 | # Bugfix: compilation of shared library fails due to misplaced rm command |
---|
[1585] | 25 | # |
---|
| 26 | # Former revisions: |
---|
| 27 | # ----------------- |
---|
| 28 | # $Id: install_rrtmg 1613 2015-07-08 14:53:29Z maronga $ |
---|
| 29 | # |
---|
[1586] | 30 | # 1585 2015-04-30 07:05:52Z maronga |
---|
| 31 | # Initial revision |
---|
| 32 | # |
---|
[1585] | 33 | #--------------------------------------------------------------------------------# |
---|
| 34 | # install_rrtmg - install script for creating a RRTMG library |
---|
| 35 | #--------------------------------------------------------------------------------# |
---|
| 36 | |
---|
| 37 | # the following variables must be modified for the local system according to |
---|
| 38 | # .mrun.config |
---|
| 39 | # |
---|
| 40 | # Example 1 (lcmuk): |
---|
| 41 | # compiler_name="mpif90" |
---|
| 42 | # fopts="-fltconsistency -O3 -cpp -r8 -nbs -convert little_endian -I /muksoft/packages/netcdf/4_intel/include" |
---|
| 43 | # 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" |
---|
| 44 | # |
---|
| 45 | # Example 2 (lccrayh): |
---|
| 46 | # compiler_name="ftn" |
---|
| 47 | # fopts="-em -s real64 -O3 -hnoomp -hfp3 -hdynamic" |
---|
[1613] | 48 | # fopts_trace="-eD -em -g -R b -K trap=fp -O0 -hnoomp" |
---|
[1585] | 49 | # |
---|
| 50 | # |
---|
| 51 | |
---|
[1613] | 52 | compiler_name="ftn" |
---|
| 53 | fopts="-em -s real64 -O3 -hnoomp -hfp3 -hdynamic" |
---|
| 54 | fopts_trace="-eD -em -g -R b -K trap=fp -O0 -hnoomp -fpic" |
---|
| 55 | install_path="$HOME/rrtmg" |
---|
| 56 | compile_static=false |
---|
[1585] | 57 | compile_shared=true |
---|
| 58 | compile_static_debug=false |
---|
[1613] | 59 | compile_shared_debug=true |
---|
[1585] | 60 | |
---|
| 61 | while getopts p: option |
---|
| 62 | do |
---|
| 63 | case $option in |
---|
| 64 | (p) install_path=$OPTARG;; |
---|
| 65 | |
---|
| 66 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
| 67 | printf "\n --> type \"$0 ?\" for available options \n" |
---|
| 68 | locat=parameter;exit;; |
---|
| 69 | esac |
---|
| 70 | done |
---|
| 71 | |
---|
| 72 | (( to_shift = $OPTIND - 1 )) |
---|
| 73 | shift $to_shift |
---|
| 74 | |
---|
| 75 | # PRINT SHORT DESCRIPTION OF OPTIONS |
---|
| 76 | if [[ "$1" = "?" ]] |
---|
| 77 | then |
---|
| 78 | (printf "\n *** rrtmg_install can be called as follows:\n" |
---|
| 79 | printf "\n rrtmg_install -p.\n" |
---|
| 80 | printf "\n Description of available options:\n" |
---|
| 81 | printf "\n Option Description Default-Value" |
---|
| 82 | printf "\n -p installation path ./" |
---|
| 83 | |
---|
| 84 | printf "\n " |
---|
| 85 | printf "\n Possible values of positional parameter <modus>:" |
---|
| 86 | printf "\n \"?\" - this outline \n\n") | more |
---|
| 87 | exit |
---|
| 88 | elif [[ "$1" != "" ]] |
---|
| 89 | then |
---|
| 90 | printf "\n +++ positional parameter $1 unknown \n" |
---|
| 91 | locat=parameter; exit |
---|
| 92 | fi |
---|
| 93 | |
---|
| 94 | prog="librrtmg" |
---|
| 95 | version="1.0" |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | # 1 static |
---|
| 99 | |
---|
| 100 | if [[ $compile_static = true ]] |
---|
| 101 | then |
---|
| 102 | printf "\n Start compiling static library $prog... (make)\n\n" |
---|
| 103 | mkdir -p static/lib |
---|
| 104 | mkdir -p static/include |
---|
| 105 | make -f Makefile_static F90=$compiler_name PROG=$prog F90FLAGS="$fopts" |
---|
| 106 | cp $prog.a static/lib |
---|
| 107 | cp *.mod static/include |
---|
| 108 | make -f Makefile_static clean |
---|
| 109 | mkdir -p $install_path/static/lib |
---|
| 110 | mkdir -p $install_path/static/include |
---|
| 111 | cp static/lib/$prog.a $install_path/static/lib |
---|
| 112 | cp static/include/*.mod $install_path/static/include/ |
---|
| 113 | rm -rf static |
---|
| 114 | printf "\n finished.\n" |
---|
| 115 | fi |
---|
| 116 | |
---|
| 117 | # 2 static debug |
---|
| 118 | if [[ $compile_static_debug = true ]] |
---|
| 119 | then |
---|
| 120 | printf "\n Start compiling static debug library $prog... (make)\n\n" |
---|
| 121 | mkdir -p static_trace/lib |
---|
| 122 | mkdir -p static_trace/include |
---|
| 123 | make -f Makefile_static F90=$compiler_name PROG=$prog F90FLAGS="$fopts_trace" |
---|
| 124 | cp $prog.a static_trace/lib |
---|
| 125 | cp *.mod static_trace/include |
---|
| 126 | make -f Makefile_static clean |
---|
| 127 | mkdir -p $install_path/static_trace/lib |
---|
| 128 | mkdir -p $install_path/static_trace/include |
---|
| 129 | cp static_trace/lib/$prog.a $install_path/static_trace/lib |
---|
| 130 | cp static_trace/include/*.mod $install_path/static_trace/include/ |
---|
| 131 | rm -rf static_trace |
---|
| 132 | printf "\n finished.\n" |
---|
| 133 | fi |
---|
| 134 | |
---|
| 135 | # 3 shared |
---|
| 136 | if [[ $compile_shared = true ]] |
---|
| 137 | then |
---|
| 138 | printf "\n Start compiling shared (dynamic) library $prog... (make)\n\n" |
---|
| 139 | mkdir -p shared/lib |
---|
| 140 | mkdir -p shared/include |
---|
| 141 | make -f Makefile F90=$compiler_name PROG=$prog F90FLAGS="$fopts" |
---|
| 142 | cp $prog.so shared/lib/$prog.so.$version |
---|
| 143 | cp *.mod shared/include/ |
---|
| 144 | make -f Makefile clean |
---|
| 145 | mkdir -p $install_path/shared/lib |
---|
| 146 | mkdir -p $install_path/shared/include |
---|
[1613] | 147 | cp shared/lib/$prog.so.$version $install_path/shared/lib/ |
---|
[1585] | 148 | cp shared/include/*.mod $install_path/shared/include/ |
---|
[1613] | 149 | if [ -f $install_path/shared/lib/$prog.so.1 ] |
---|
| 150 | then |
---|
| 151 | rm $install_path/shared/lib/$prog.so.1 |
---|
| 152 | fi |
---|
[1585] | 153 | ln -s $install_path/shared/lib/$prog.so.$version $install_path/shared/lib/$prog.so.1 |
---|
[1613] | 154 | if [ -f $install_path/shared/lib/$prog.so ] |
---|
| 155 | then |
---|
| 156 | rm $install_path/shared/lib/$prog.so |
---|
| 157 | fi |
---|
[1585] | 158 | ln -s $install_path/shared/lib/$prog.so.1 $install_path/shared/lib/$prog.so |
---|
| 159 | rm -rf shared |
---|
| 160 | printf "\n finished.\n" |
---|
| 161 | fi |
---|
| 162 | |
---|
| 163 | # 4 shared debug |
---|
| 164 | if [[ $compile_static_debug = true ]] |
---|
| 165 | then |
---|
| 166 | printf "\n Start compiling shared debug library $prog... (make)\n\n" |
---|
| 167 | mkdir -p shared_trace/lib |
---|
| 168 | mkdir -p shared_trace/include |
---|
| 169 | make -f Makefile F90=$compiler_name PROG=$prog F90FLAGS="$fopts_trace" |
---|
| 170 | cp $prog.so shared_trace/lib/$prog.so.$version |
---|
| 171 | cp *.mod shared_trace/include/ |
---|
| 172 | make -f Makefile clean |
---|
| 173 | mkdir -p $install_path/shared_trace/lib |
---|
| 174 | mkdir -p $install_path/shared_trace/include |
---|
| 175 | cp shared_trace/lib/$prog.so.$version $install_path/shared_trace/lib |
---|
| 176 | cp shared_trace/include/*.mod $install_path/shared_trace/include/ |
---|
[1613] | 177 | if [ -f $install_path/shared_trace/lib/$prog.so.1 ] |
---|
| 178 | then |
---|
| 179 | rm $install_path/shared_trace/lib/$prog.so.1 |
---|
| 180 | fi |
---|
[1585] | 181 | ln -s $install_path/shared_trace/lib/$prog.so.$version $install_path/shared_trace/lib/$prog.so.1 |
---|
[1613] | 182 | if [ -f $install_path/shared_trace/lib/$prog.so ] |
---|
| 183 | then |
---|
| 184 | rm $install_path/shared_trace/lib/$prog.so |
---|
| 185 | fi |
---|
[1585] | 186 | ln -s $install_path/shared_trace/lib/$prog.so.1 $install_path/shared_trace/lib/$prog.so |
---|
| 187 | rm -rf shared_trace |
---|
| 188 | printf "\n finished.\n" |
---|
| 189 | fi |
---|
| 190 | |
---|
| 191 | printf "\n Libraries $prog are installed in \"$install_path\".\n\n" |
---|
| 192 | printf "\n\n *** all actions complete." |
---|
| 193 | |
---|