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