[2774] | 1 | #!/usr/bin/env bash |
---|
| 2 | #------------------------------------------------------------------------------# |
---|
| 3 | # This file is part of PALM. |
---|
| 4 | # |
---|
| 5 | # PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | # terms of the GNU General Public License as published by the Free Software |
---|
| 7 | # Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | # version. |
---|
| 9 | # |
---|
| 10 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | # |
---|
| 14 | # You should have received a copy of the GNU General Public License along with |
---|
| 15 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | # |
---|
| 17 | # Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
| 18 | #------------------------------------------------------------------------------# |
---|
| 19 | # Temporary trunk side of the automatic installation scipt |
---|
| 20 | # WARNING: This script does not work as a standalone installer! |
---|
| 21 | #------------------------------------------------------------------------------# |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | # install PALM |
---|
| 25 | palm_installer_build() { |
---|
| 26 | printf "%s\n" "${program_name} installer is configuring using cmake..." |
---|
| 27 | palm_installer_create_files |
---|
| 28 | rm -rf ${build_dir} |
---|
| 29 | mkdir -p ${build_dir} |
---|
| 30 | cd ${build_dir} |
---|
| 31 | cp ${trunk_dir}/SCRIPTS/.palm.config.default.in ${source_dir}/.palm.config.default.in |
---|
| 32 | cmake -Wno-dev ${CUSTOM_FORTRAN_COMPILER:+-DCMAKE_Fortran_COMPILER=}${CUSTOM_FORTRAN_COMPILER} \ |
---|
| 33 | ${NETCDF_C_ROOT:+-DNETCDF_C_ROOT=}${NETCDF_C_ROOT} \ |
---|
| 34 | ${NETCDF_FORTRAN_ROOT:+-DNETCDF_FORTRAN_ROOT=}${NETCDF_FORTRAN_ROOT} \ |
---|
| 35 | -DPALM_CORES=$NUM_PROC_BUILD \ |
---|
| 36 | -DCMAKE_BUILD_TYPE=Release \ |
---|
| 37 | ${install_prefix:+-DCMAKE_INSTALL_PREFIX=}${install_prefix} \ |
---|
| 38 | -DCMAKE_USERNAME=${USER} \ |
---|
| 39 | ${source_dir} |
---|
| 40 | if [[ $? -ne 0 ]]; then |
---|
| 41 | hrule |
---|
| 42 | printf "| \e[1;31m%-${number_of_cols}s\e[0m |\n" "Configuration failed!" |
---|
| 43 | palm_installer_ticket_message |
---|
| 44 | hrule |
---|
| 45 | exit 1 |
---|
| 46 | else |
---|
| 47 | hrule |
---|
| 48 | printf "| \e[1;32m%-${number_of_cols}s\e[0m |\n" "Configuration finished!" |
---|
| 49 | hrule |
---|
| 50 | fi |
---|
| 51 | palm_read_yn "Please check the configuration!!! Would you like to continue?" "RESPONSE_CONFIGURE" |
---|
| 52 | if [[ "$RESPONSE_CONFIGURE" != "y" ]]; then |
---|
| 53 | palm_installer_abort_message |
---|
| 54 | fi |
---|
| 55 | cd ${install_prefix} |
---|
| 56 | rm -rf ${source_dir} |
---|
| 57 | rm -rf MAKE_DEPOSITORY_parallel |
---|
| 58 | bash ${trunk_dir}/SCRIPTS/palmbuild -v -h "default" |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | palm_installer_set_path() { |
---|
| 62 | [[ -w ${HOME}/.mybashrc ]] && shell_profile=${HOME}/.mybashrc |
---|
| 63 | if [[ ! -w ${shell_profile} ]]; then |
---|
| 64 | printf "\e[1;31mWARNING\e[0m: ${program_name} binary \e[1;31mpath could not be written\e[0m to \"${shell_profile}\"\n" |
---|
| 65 | printf "In order to run the ${program_name} execution script \"mrun\" you need to set the following paths\n" |
---|
| 66 | printf " export PALM_BIN=${trunk_dir}/SCRIPTS\n" |
---|
| 67 | printf " export PATH=\$PALM_BIN:\$PATH\n" |
---|
| 68 | elif grep -q "^export PALM_BIN=${trunk_dir}/SCRIPTS" ${shell_profile}; then |
---|
| 69 | printf "${program_name} binary \e[1;32mpath already set correctly\e[0m in \"${shell_profile}\"\n" |
---|
| 70 | else |
---|
| 71 | if grep -q "PALM_BIN" ${shell_profile}; then |
---|
| 72 | sed -i "s@^[^#]\(.*PALM_BIN.*\)@#e\1@" ${shell_profile} |
---|
| 73 | printf "${program_name} binary \e[1;32mpath updated\e[0m in \"${shell_profile}\"" |
---|
| 74 | else |
---|
| 75 | printf "${program_name} binary \e[1;32mpath written\e[0m to \"${shell_profile}\"" |
---|
| 76 | fi |
---|
| 77 | cat >> ${shell_profile} << EOF |
---|
| 78 | #------------------------------------------------------------------------------- |
---|
| 79 | ##PALM## |
---|
| 80 | export PALM_BIN=${trunk_dir}/SCRIPTS |
---|
| 81 | export PATH=\$PALM_BIN:\$PATH |
---|
| 82 | |
---|
| 83 | EOF |
---|
| 84 | fi |
---|
| 85 | export PALM_BIN=${trunk_dir}/SCRIPTS |
---|
| 86 | export PATH=$PALM_BIN:$PATH |
---|
| 87 | echo " " |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | palm_installer_test() { |
---|
| 91 | hrule |
---|
| 92 | printf "Testing ${program_name} with \"${1}\"... " |
---|
| 93 | source ${shell_profile} |
---|
| 94 | local input_dir=${install_prefix}/JOBS/${1}/INPUT/ |
---|
| 95 | local monitoring_dir=${install_prefix}/JOBS/${1}/MONITORING/ |
---|
| 96 | local test_dir=${trunk_dir}/INSTALL |
---|
| 97 | if [[ ! -f ${test_dir}/${1}_p3d ]] || [[ ! -f ${test_dir}/${1}_rc ]]; then |
---|
| 98 | printf "\e[1;31m test not found\e[0m\n" |
---|
| 99 | return 1 |
---|
| 100 | fi |
---|
| 101 | rm -rf ${monitoring_dir} |
---|
| 102 | mkdir -p ${input_dir} |
---|
| 103 | cp ${test_dir}/${1}_p3d ${input_dir} |
---|
| 104 | [[ -f ${test_dir}/${1}_topo ]] && cp ${test_dir}/${1}_topo ${input_dir} |
---|
| 105 | bash ${trunk_dir}/SCRIPTS/palmrun -d ${1} -a "d3#" -h "default" -X "$NUM_PROC_TEST" -T "$NUM_PROC_TEST" -v -B > ${install_prefix}/${logfile_test} 2>&1 |
---|
| 106 | grep -A 99999 "Run-control output" JOBS/${1}/MONITORING/${1}_rc 1> ${install_prefix}/RC_LOCAL 2> /dev/null |
---|
| 107 | grep -A 99999 "Run-control output" ${test_dir}/${1}_rc 1> ${install_prefix}/RC_DEFAULT 2> /dev/null |
---|
| 108 | diff_output=$(diff ${install_prefix}/RC_DEFAULT ${install_prefix}/RC_LOCAL) |
---|
| 109 | rm ${install_prefix}/RC_LOCAL ${install_prefix}/RC_DEFAULT |
---|
| 110 | if [[ "${diff_output}" == "" ]]; then |
---|
| 111 | printf "\e[1;32m passed\e[0m\n" |
---|
| 112 | return 0 |
---|
| 113 | else |
---|
| 114 | printf "\e[1;31m failed\e[0m\n" |
---|
| 115 | test_status="failed" |
---|
| 116 | return 1 |
---|
| 117 | fi |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | palm_installer_test_suite() { |
---|
| 121 | rm -f ${install_prefix}/${logfile_test} |
---|
| 122 | for test_path in ${trunk_dir}/INSTALL/*_p3d; do |
---|
| 123 | testname_p3d=$(basename $test_path) |
---|
| 124 | palm_installer_test "${testname_p3d%_p3d}" |
---|
| 125 | done |
---|
| 126 | hrule |
---|
| 127 | cat ${install_prefix}/${logfile_test} >> ${logfile_all} |
---|
| 128 | if [[ "${test_status}" == "failed" ]]; then |
---|
| 129 | printf "| \e[1;31m%-${number_of_cols}s\e[0m \n" "Some tests failed. ${program_name} installation not successful :-(" |
---|
| 130 | printf "| \e[1;31m%-${number_of_cols}s\e[0m \n" "More detailed information regarding the failure can be found in file:" |
---|
| 131 | printf "| \e[1;31m%-${number_of_cols}s\e[0m \n" " ${install_prefix}/${logfile_test}" |
---|
| 132 | palm_installer_ticket_message |
---|
| 133 | hrule |
---|
| 134 | exit 1 |
---|
| 135 | else |
---|
| 136 | printf "| \e[1;32m%-${number_of_cols}s\e[0m |\n" "All found tests passed. ${program_name} installation successful :-)" |
---|
| 137 | rm -f ${install_prefix}/${logfile_test} |
---|
| 138 | rm -rf ${install_prefix}/tmp/* |
---|
| 139 | hrule |
---|
| 140 | fi |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | palm_post_installer_help() { |
---|
| 144 | hrule |
---|
| 145 | printf "| %-${number_of_cols}s \n" " " |
---|
| 146 | printf "| %-${number_of_cols}s \n" "-- To use ${program_name} it is required to update your PATH variable. Please type:" |
---|
| 147 | printf "| %-${number_of_cols}s \n" " " |
---|
| 148 | printf "| %-${number_of_cols}s \n" " source ${shell_profile}" |
---|
| 149 | printf "| %-${number_of_cols}s \n" " " |
---|
| 150 | printf "| %-${number_of_cols}s \n" " or restart your shell." |
---|
| 151 | printf "| %-${number_of_cols}s \n" " " |
---|
| 152 | printf "| %-${number_of_cols}s \n" "-- To work with ${program_name} please go to your ${program_name} base directory:" |
---|
| 153 | printf "| %-${number_of_cols}s \n" " " |
---|
| 154 | printf "| %-${number_of_cols}s \n" " cd ${install_prefix}" |
---|
| 155 | printf "| %-${number_of_cols}s \n" " " |
---|
| 156 | printf "| %-${number_of_cols}s \n" "-- To start the model, please use \"palmrun\" with appropriate options. For example:" |
---|
| 157 | printf "| %-${number_of_cols}s \n" " " |
---|
| 158 | printf "| %-${number_of_cols}s \n" " palmrun -d example_cbl -a \"d3#\" -h \"default\" -X \"$NUM_PROC_TEST\" -T \"$NUM_PROC_TEST\" " |
---|
| 159 | printf "| %-${number_of_cols}s \n" " | | | | | " |
---|
| 160 | printf "| %-${number_of_cols}s \n" " Job name | configuration | tasks per node " |
---|
| 161 | printf "| %-${number_of_cols}s \n" " I/O control list number of cores " |
---|
| 162 | printf "| %-${number_of_cols}s \n" " " |
---|
| 163 | printf "| %-${number_of_cols}s \n" "-- Edit \".palm.config.default\" to customize this ${program_name} installation." |
---|
| 164 | printf "| %-${number_of_cols}s \n" "-- To rebuild ${program_name} type: palmbuild -h \"default\"" |
---|
| 165 | printf "| %-${number_of_cols}s \n" " " |
---|
| 166 | printf "| %-${number_of_cols}s \n" "-- For further questions go to: https://palm.muk.uni-hannover.de/." |
---|
| 167 | printf "| %-${number_of_cols}s \n" " " |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | palm_installer_create_files() { |
---|
| 171 | mkdir -p ${source_dir} |
---|
| 172 | |
---|
| 173 | cat > ${source_dir}/CMakeLists.txt << EOF |
---|
| 174 | # This is the CMake configuration file for PALM |
---|
| 175 | |
---|
| 176 | cmake_minimum_required (VERSION 2.8) |
---|
| 177 | |
---|
| 178 | # set program name |
---|
| 179 | set(PALM_PROGRAM_NAME "PALM") |
---|
| 180 | |
---|
| 181 | project(\${PALM_PROGRAM_NAME} NONE) |
---|
| 182 | exec_program( hostname OUTPUT_VARIABLE PALM_HOSTNAME) |
---|
| 183 | |
---|
| 184 | # .palm.config locations |
---|
| 185 | set(config_in \${CMAKE_CURRENT_SOURCE_DIR}/.palm.config.default.in) |
---|
| 186 | set(config \${CMAKE_INSTALL_PREFIX}/.palm.config.default) |
---|
| 187 | |
---|
| 188 | # include local cmake files |
---|
| 189 | set(PALM_CMAKE_FILES \${CMAKE_CURRENT_SOURCE_DIR}) |
---|
| 190 | list(APPEND CMAKE_MODULE_PATH \${PALM_CMAKE_FILES}) |
---|
| 191 | |
---|
| 192 | # enabling Fortran language support |
---|
| 193 | enable_language(Fortran) # required to compile the main model and all utilities |
---|
| 194 | |
---|
| 195 | # check for Fortran MPI support |
---|
| 196 | find_package(MPI REQUIRED) |
---|
| 197 | |
---|
| 198 | # check for netCDF |
---|
| 199 | #set(NETCDF_C "YES") |
---|
| 200 | set(NETCDF_FORTRAN "YES") |
---|
| 201 | find_package (NetCDF REQUIRED) |
---|
| 202 | find_program(NETCDF_FORTRAN_COMPILER_FULL NAMES \${NETCDF_FORTRAN_COMPILER}) |
---|
| 203 | if(NOT \${CMAKE_Fortran_COMPILER} STREQUAL \${NETCDF_FORTRAN_COMPILER_FULL} ) |
---|
| 204 | message(WARNING "Fortran compiler \"\${CMAKE_Fortran_COMPILER}\" does not match netCDF Fortran compiler \"\${NETCDF_FORTRAN_COMPILER_FULL}\".") |
---|
| 205 | else() |
---|
| 206 | message(STATUS "Fortran compiler matches netCDF Fortran compiler.") |
---|
| 207 | endif() |
---|
| 208 | |
---|
| 209 | # extract subversion info |
---|
| 210 | if (${SVN_CMAKE_CHECK}) |
---|
| 211 | find_package(Subversion) |
---|
| 212 | if(SUBVERSION_FOUND) |
---|
| 213 | Subversion_WC_INFO(\${PROJECT_SOURCE_DIR}/../trunk PALM) |
---|
| 214 | message(STATUS "Your \${PALM_PROGRAM_NAME} installation will be based on revision \${PALM_WC_REVISION}.") |
---|
| 215 | else(SUBVERSION_FOUND) |
---|
| 216 | message(WARNING "Subversion not found. Wondering how you aquired the PALM code. :-)") |
---|
| 217 | endif(SUBVERSION_FOUND) |
---|
| 218 | endif() |
---|
| 219 | |
---|
| 220 | # check for fftw |
---|
| 221 | find_package(FFTW) |
---|
| 222 | if(FFTW_FOUND) |
---|
| 223 | message(STATUS "\${PALM_PROGRAM_NAME} is using an external fftw library.") |
---|
| 224 | list(APPEND PALM_CPP_OPTIONS __fftw) |
---|
| 225 | else(FFTW_FOUND) |
---|
| 226 | message(STATUS "\${PALM_PROGRAM_NAME} is using the buildin fft algorithm.") |
---|
| 227 | endif(FFTW_FOUND) |
---|
| 228 | |
---|
| 229 | # compiler flag management |
---|
| 230 | if(\${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray") |
---|
| 231 | set(PALM_COMPILER_OPTIONS "-em -K trap=fp -O3 -hnoomp -hnoacc -hfp3 -hdynamic") |
---|
| 232 | set(PALM_LINKER_OPTIONS "\${PALM_COMPILER_OPTIONS} -dynamic") |
---|
| 233 | set(PALM_CPP_FLAGS "-eZ") |
---|
| 234 | elseif(\${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") |
---|
| 235 | set(PALM_COMPILER_OPTIONS "-O3 -fp-model source -fno-alias -fpe0 -ftz -no-prec-div -no-prec-sqrt -ip -nbs -diag-disable 8290,8291") |
---|
| 236 | set(PALM_LINKER_OPTIONS "\${PALM_COMPILER_OPTIONS}") |
---|
| 237 | set(PALM_CPP_FLAGS "-cpp") |
---|
| 238 | list(APPEND PALM_CPP_OPTIONS __intel_compiler) |
---|
| 239 | elseif(\${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") |
---|
| 240 | set(PALM_COMPILER_OPTIONS "-Ofast -ffree-line-length-none") |
---|
| 241 | set(PALM_LINKER_OPTIONS "\${PALM_COMPILER_OPTIONS}") |
---|
| 242 | set(PALM_CPP_FLAGS "-cpp") |
---|
| 243 | list(APPEND PALM_CPP_OPTIONS __gfortran) |
---|
| 244 | endif() |
---|
| 245 | |
---|
| 246 | # workaround |
---|
| 247 | list(APPEND PALM_CPP_OPTIONS __parallel) |
---|
| 248 | |
---|
| 249 | # adding cpp options |
---|
| 250 | list(APPEND PALM_CPP_OPTIONS MPI_REAL=MPI_DOUBLE_PRECISION) |
---|
| 251 | list(APPEND PALM_CPP_OPTIONS MPI_2REAL=MPI_2DOUBLE_PRECISION) |
---|
| 252 | if(NETCDF_FOUND) |
---|
| 253 | list(APPEND PALM_CPP_OPTIONS __netcdf) |
---|
| 254 | set(PALM_COMPILER_OPTIONS "\${PALM_COMPILER_OPTIONS} -I \${NETCDF_INCLUDES}") |
---|
| 255 | set(PALM_LINKER_OPTIONS "\${PALM_LINKER_OPTIONS} \${NETCDF_LIBRARIES}") |
---|
| 256 | endif() |
---|
| 257 | |
---|
| 258 | if(FFTW_FOUND) |
---|
| 259 | set(PALM_COMPILER_OPTIONS "\${PALM_COMPILER_OPTIONS} -I \${FFTW_INCLUDES}") |
---|
| 260 | set(PALM_LINKER_OPTIONS "\${PALM_LINKER_OPTIONS} \${FFTW_LIBRARIES}") |
---|
| 261 | endif() |
---|
| 262 | |
---|
| 263 | string(REPLACE ";" " -D" PALM_CPP_OPTIONS_STR_1 "\${PALM_CPP_OPTIONS}") |
---|
| 264 | set(PALM_CPP_OPTIONS_STR "\${PALM_CPP_FLAGS} -D\${PALM_CPP_OPTIONS_STR_1}") |
---|
| 265 | |
---|
| 266 | # configuring the .palm.config |
---|
| 267 | configure_file(\${config_in} \${config} @ONLY) |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | EOF |
---|
| 271 | |
---|
| 272 | cat > ${source_dir}/FindFFTW.cmake << EOF |
---|
| 273 | # - Find FFTW |
---|
| 274 | # Find the native FFTW includes and library |
---|
| 275 | # |
---|
| 276 | # FFTW_INCLUDES - where to find fftw3.h |
---|
| 277 | # FFTW_LIBRARIES - List of libraries when using FFTW. |
---|
| 278 | # FFTW_FOUND - True if FFTW found. |
---|
| 279 | |
---|
| 280 | if (FFTW_INCLUDES) |
---|
| 281 | # Already in cache, be silent |
---|
| 282 | set (FFTW_FIND_QUIETLY TRUE) |
---|
| 283 | endif (FFTW_INCLUDES) |
---|
| 284 | |
---|
| 285 | #exec_program(sed ARGS -i '/%fftw_inc.*/d' \${config}) |
---|
| 286 | #list(APPEND NETCDF_HINTS "\$ENV{LD_LIBRARY_PATH}") |
---|
| 287 | |
---|
| 288 | find_path (FFTW_INCLUDES fftw3.f03 HINTS \${NETCDF_HINTS} ENV LD_LIBRARY_PATH PATH_SUFFIXES include Include) |
---|
| 289 | find_library(NETCDF_FORTRAN_LIB netcdff HINTS \${NETCDF_HINTS} ENV LD_LIBRARY_PATH PATH_SUFFIXES lib lib64) |
---|
| 290 | |
---|
| 291 | find_library (FFTW_LIBRARIES NAMES fftw3) |
---|
| 292 | |
---|
| 293 | # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if |
---|
| 294 | # all listed variables are TRUE |
---|
| 295 | include (FindPackageHandleStandardArgs) |
---|
| 296 | find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES) |
---|
| 297 | |
---|
| 298 | mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES) |
---|
| 299 | |
---|
| 300 | EOF |
---|
| 301 | |
---|
| 302 | cat > ${source_dir}/FindNetCDF.cmake << EOF |
---|
| 303 | # - Find NetCDF |
---|
| 304 | # Find the native NetCDF includes and library |
---|
| 305 | # |
---|
| 306 | # NETCDF_INCLUDES - where to find netcdf.h, etc |
---|
| 307 | # NETCDF_LIBRARIES - Link these libraries when using NetCDF |
---|
| 308 | # NETCDF_FOUND - True if NetCDF found including required interfaces (see below) |
---|
| 309 | # |
---|
| 310 | # Your package can require certain interfaces to be FOUND by setting these |
---|
| 311 | # |
---|
| 312 | # NETCDF_C - require the C interface and link the C library |
---|
| 313 | # NETCDF_CXX - require the C++ interface and link the C++ library |
---|
| 314 | # NETCDF_FORTRAN - require the Fortran interface and link the Fortran library |
---|
| 315 | # |
---|
| 316 | # The following are not for general use and are included in |
---|
| 317 | # NETCDF_LIBRARIES if the corresponding option above is set. |
---|
| 318 | # |
---|
| 319 | # NETCDF_LIBRARIES_C - Just the C interface |
---|
| 320 | # NETCDF_LIBRARIES_CXX - C++ interface, if available |
---|
| 321 | # NETCDF_LIBRARIES_FORTRAN - Fortran 90 interface, if available |
---|
| 322 | # |
---|
| 323 | # Normal usage would be: |
---|
| 324 | # set (NETCDF_FORTRAN "YES") |
---|
| 325 | # find_package (NetCDF REQUIRED) |
---|
| 326 | # target_link_libraries (uses_f90_interface \${NETCDF_LIBRARIES}) |
---|
| 327 | |
---|
| 328 | if (NETCDF_INCLUDES AND NETCDF_LIBRARIES) |
---|
| 329 | # Already in cache, be silent |
---|
| 330 | set (NETCDF_FIND_QUIETLY TRUE) |
---|
| 331 | endif (NETCDF_INCLUDES AND NETCDF_LIBRARIES) |
---|
| 332 | |
---|
| 333 | |
---|
| 334 | macro(NETCDF_CONFIG flag output) |
---|
| 335 | if(NETCDF_CONFIG_EXECUTABLE) |
---|
| 336 | exec_program( \${NETCDF_CONFIG_EXECUTABLE} ARGS \${flag} |
---|
| 337 | OUTPUT_VARIABLE \${output} RETURN_VALUE return_value) |
---|
| 338 | if(NOT \${return_value} EQUAL 0 ) |
---|
| 339 | message( STATUS "Unable to determine \${flag} from \${NETCDF_CONFIG_EXECUTABLE}." ) |
---|
| 340 | endif() |
---|
| 341 | endif(NETCDF_CONFIG_EXECUTABLE) |
---|
| 342 | endmacro() |
---|
| 343 | |
---|
| 344 | if(NETCDF_C_ROOT) |
---|
| 345 | list(APPEND NETCDF_HINTS "\${NETCDF_C_ROOT}") |
---|
| 346 | else() |
---|
| 347 | list(APPEND NETCDF_HINTS "\$ENV{NETCDF_ROOT}") |
---|
| 348 | endif() |
---|
| 349 | |
---|
| 350 | if(NETCDF_FORTRAN_ROOT) |
---|
| 351 | list(APPEND NETCDF_HINTS "\${NETCDF_FORTRAN_ROOT}") |
---|
| 352 | else() |
---|
| 353 | list(APPEND NETCDF_HINTS "\$ENV{NETCDF_ROOT}") |
---|
| 354 | endif() |
---|
| 355 | |
---|
| 356 | if(NETCDF_C_ROOT) |
---|
| 357 | find_program(NETCDF_C_CONFIG_EXECUTABLE NAMES nc-config |
---|
| 358 | HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin NO_DEFAULT_PATH |
---|
| 359 | DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." ) |
---|
| 360 | else() |
---|
| 361 | find_program(NETCDF_C_CONFIG_EXECUTABLE NAMES nc-config |
---|
| 362 | HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin |
---|
| 363 | DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." ) |
---|
| 364 | endif() |
---|
| 365 | |
---|
| 366 | set(NETCDF_CONFIG_EXECUTABLE \${NETCDF_C_CONFIG_EXECUTABLE}) |
---|
| 367 | if(NETCDF_C_CONFIG_EXECUTABLE) |
---|
| 368 | NETCDF_CONFIG(--cc NETCDF_C_COMPILER_C) |
---|
| 369 | NETCDF_CONFIG(--fc NETCDF_C_COMPILER_FORTRAN) |
---|
| 370 | NETCDF_CONFIG(--prefix NETCDF_C_ROOT) |
---|
| 371 | NETCDF_CONFIG(--includedir NETCDF_C_INCLUDE) |
---|
| 372 | NETCDF_CONFIG(--version NETCDF_C_VERSION) |
---|
| 373 | #NETCDF_CONFIG(--has-c++ NETCDF_C_CXX) |
---|
| 374 | #NETCDF_CONFIG(--has-f77 NETCDF_C_F77) |
---|
| 375 | NETCDF_CONFIG(--has-f90 NETCDF_C_F90) |
---|
| 376 | #NETCDF_CONFIG(--has-dap NETCDF_C_DAP) |
---|
| 377 | #NETCDF_CONFIG(--has-nc2 NETCDF_C_NC2) |
---|
| 378 | #NETCDF_CONFIG(--has-nc4 NETCDF_C_NC4) |
---|
| 379 | #NETCDF_CONFIG(--has-hdf4 NETCDF_C_HDF4) |
---|
| 380 | #NETCDF_CONFIG(--has-hdf5 NETCDF_C_HDF5) |
---|
| 381 | #NETCDF_CONFIG(--has-pnetcdf NETCDF_C_PARALLEL) |
---|
| 382 | list(APPEND NETCDF_INCLUDE_HINTS "\${NETCDF_C_INCLUDE}") |
---|
| 383 | list(APPEND NETCDF_HINTS "\${NETCDF_C_ROOT}") |
---|
| 384 | message(STATUS "Found \${NETCDF_C_VERSION} compiled with \${NETCDF_C_COMPILER_C}") |
---|
| 385 | else(NETCDF_C_CONFIG_EXECUTABLE) |
---|
| 386 | message(STATUS "nc-config not found") |
---|
| 387 | endif(NETCDF_C_CONFIG_EXECUTABLE) |
---|
| 388 | |
---|
| 389 | if(NETCDF_C_ROOT AND NETCDF_FORTRAN_ROOT) |
---|
| 390 | find_program(NETCDF_FORTRAN_CONFIG_EXECUTABLE NAMES nf-config |
---|
| 391 | HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin NO_DEFAULT_PATH |
---|
| 392 | DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." ) |
---|
| 393 | else() |
---|
| 394 | find_program(NETCDF_FORTRAN_CONFIG_EXECUTABLE NAMES nf-config |
---|
| 395 | HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin |
---|
| 396 | DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." ) |
---|
| 397 | endif() |
---|
| 398 | |
---|
| 399 | set(NETCDF_CONFIG_EXECUTABLE \${NETCDF_FORTRAN_CONFIG_EXECUTABLE}) |
---|
| 400 | if(NETCDF_FORTRAN_CONFIG_EXECUTABLE) |
---|
| 401 | NETCDF_CONFIG(--cc NETCDF_FORTRAN_COMPILER_C) |
---|
| 402 | NETCDF_CONFIG(--fc NETCDF_FORTRAN_COMPILER_FORTRAN) |
---|
| 403 | NETCDF_CONFIG(--prefix NETCDF_FORTRAN_ROOT) |
---|
| 404 | NETCDF_CONFIG(--includedir NETCDF_FORTRAN_INCLUDE) |
---|
| 405 | NETCDF_CONFIG(--version NETCDF_FORTRAN_VERSION) |
---|
| 406 | #NETCDF_CONFIG(--has-c++ NETCDF_FORTRAN_CXX) |
---|
| 407 | #NETCDF_CONFIG(--has-f77 NETCDF_FORTRAN_F77) |
---|
| 408 | NETCDF_CONFIG(--has-f90 NETCDF_FORTRAN_F90) |
---|
| 409 | #NETCDF_CONFIG(--has-dap NETCDF_FORTRAN_DAP) |
---|
| 410 | #NETCDF_CONFIG(--has-nc2 NETCDF_FORTRAN_NC2) |
---|
| 411 | #NETCDF_CONFIG(--has-nc4 NETCDF_FORTRAN_NC4) |
---|
| 412 | #NETCDF_CONFIG(--has-hdf4 NETCDF_FORTRAN_HDF4) |
---|
| 413 | #NETCDF_CONFIG(--has-hdf5 NETCDF_FORTRAN_HDF5) |
---|
| 414 | #NETCDF_CONFIG(--has-pnetcdf NETCDF_FORTRAN_PARALLEL) |
---|
| 415 | list(APPEND NETCDF_INCLUDE_HINTS "\${NETCDF_FORTRAN_INCLUDE}") |
---|
| 416 | list(APPEND NETCDF_HINTS "\${NETCDF_FORTRAN_ROOT}") |
---|
| 417 | message(STATUS "Found \${NETCDF_FORTRAN_VERSION} compiled with \${NETCDF_FORTRAN_COMPILER_FORTRAN}") |
---|
| 418 | else(NETCDF_FORTRAN_CONFIG_EXECUTABLE) |
---|
| 419 | #message(STATUS "nf-config not found") |
---|
| 420 | set(NETCDF_FORTRAN_COMPILER_C \${NETCDF_C_COMPILER_C}) |
---|
| 421 | set(NETCDF_FORTRAN_COMPILER_FORTRAN \${NETCDF_C_COMPILER_FORTRAN}) |
---|
| 422 | set(NETCDF_FORTRAN_ROOT \${NETCDF_C_ROOT}) |
---|
| 423 | set(NETCDF_FORTRAN_INCLUDE \${NETCDF_C_INCLUDE}) |
---|
| 424 | set(NETCDF_FORTRAN_VERSION \${NETCDF_C_VERSION}) |
---|
| 425 | #set(NETCDF_FORTRAN_CXX \${NETCDF_C_CXX}) |
---|
| 426 | #set(NETCDF_FORTRAN_F77 \${NETCDF_C_F77}) |
---|
| 427 | set(NETCDF_FORTRAN_F90 \${NETCDF_C_F90}) |
---|
| 428 | #set(NETCDF_FORTRAN_DAP \${NETCDF_C_DAP}) |
---|
| 429 | #set(NETCDF_FORTRAN_NC2 \${NETCDF_C_NC2}) |
---|
| 430 | #set(NETCDF_FORTRAN_NC4 \${NETCDF_C_NC4}) |
---|
| 431 | #set(NETCDF_FORTRAN_HDF4 \${NETCDF_C_HDF4}) |
---|
| 432 | #set(NETCDF_FORTRAN_HDF5 \${NETCDF_C_HDF5}) |
---|
| 433 | #set(NETCDF_FORTRAN_PARALLEL \${NETCDF_C_PARALLEL}) |
---|
| 434 | if(NETCDF_FORTRAN_F90) |
---|
| 435 | message(STATUS "Found \${NETCDF_FORTRAN_VERSION} compiled with \${NETCDF_FORTRAN_COMPILER_FORTRAN}") |
---|
| 436 | else(NETCDF_FORTRAN_F90) |
---|
| 437 | message(STATUS "nc-config found no netCDF Fortran libraries") |
---|
| 438 | endif(NETCDF_FORTRAN_F90) |
---|
| 439 | endif(NETCDF_FORTRAN_CONFIG_EXECUTABLE) |
---|
| 440 | |
---|
| 441 | # find netcdf c |
---|
| 442 | if(NOT NETCDF_C_INCLUDE) |
---|
| 443 | find_path(NETCDF_C_INCLUDE netcdf.h HINTS \${NETCDF_HINTS} PATH_SUFFIXES include Include) |
---|
| 444 | endif() |
---|
| 445 | find_library(NETCDF_C_LIB netcdf HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64) |
---|
| 446 | #message(STATUS "NETCDF_C_INCLUDE so far: \${NETCDF_C_INCLUDE}") |
---|
| 447 | #message(STATUS "NETCDF_C_LIB so far: \${NETCDF_C_LIB}") |
---|
| 448 | |
---|
| 449 | # find netcdf fortran |
---|
| 450 | if(NOT NETCDF_FORTRAN_INCLUDE) |
---|
| 451 | find_path(NETCDF_FORTRAN_INCLUDE netcdf.mod HINTS \${NETCDF_HINTS} PATH_SUFFIXES include Include) |
---|
| 452 | endif() |
---|
| 453 | find_library(NETCDF_FORTRAN_LIB netcdff HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64) |
---|
| 454 | if(NOT NETCDF_FORTRAN_LIB) |
---|
| 455 | find_library(NETCDF_FORTRAN_LIB netcdf HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64) |
---|
| 456 | endif() |
---|
| 457 | #message(STATUS "NETCDF_FORTRAN_INCLUDE so far: \${NETCDF_FORTRAN_INCLUDE}") |
---|
| 458 | #message(STATUS "NETCDF_FORTRAN_LIB so far: \${NETCDF_FORTRAN_LIB}") |
---|
| 459 | |
---|
| 460 | if ((NOT NETCDF_C_LIB) OR (NOT NETCDF_C_INCLUDE)) |
---|
| 461 | message(STATUS "Trying to find NetCDF using LD_LIBRARY_PATH (we're desperate)...") |
---|
| 462 | file(TO_CMAKE_PATH "\$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH) |
---|
| 463 | find_library(NETCDF_C_LIB NAMES netcdf HINTS \${LD_LIBRARY_PATH}) |
---|
| 464 | |
---|
| 465 | if (NETCDF_C_LIB) |
---|
| 466 | get_filename_component(NETCDF_LIB_DIR \${NETCDF_C_LIB} PATH) |
---|
| 467 | string(REGEX REPLACE "/lib/?\$" "/include" NETCDF_H_HINT \${NETCDF_LIB_DIR}) |
---|
| 468 | find_path (NETCDF_C_INCLUDE netcdf.h HINTS \${NETCDF_H_HINT} DOC "Path to netcdf.h") |
---|
| 469 | message(STATUS "found netcdf.h in: \${NETCDF_C_INCLUDE}") |
---|
| 470 | list(APPEND NETCDF_INCLUDE_HINTS "\${NETCDF_C_INCLUDE}") |
---|
| 471 | endif() |
---|
| 472 | endif() |
---|
| 473 | |
---|
| 474 | get_filename_component (NETCDF_C_LIB_DIR "\${NETCDF_C_LIB}" PATH) |
---|
| 475 | get_filename_component (NETCDF_FORTRAN_LIB_DIR "\${NETCDF_FORTRAN_LIB}" PATH) |
---|
| 476 | list(APPEND NETCDF_LIB_HINTS "\${NETCDF_C_LIB_DIR}") |
---|
| 477 | list(APPEND NETCDF_LIB_HINTS "\${NETCDF_FORTRAN_LIB_DIR}") |
---|
| 478 | |
---|
| 479 | #message(STATUS "All include Hints: \${NETCDF_INCLUDE_HINTS}") |
---|
| 480 | #message(STATUS "All lib Hints: \${NETCDF_LIB_HINTS}") |
---|
| 481 | |
---|
| 482 | macro(NetCDF_add_interface lang) |
---|
| 483 | if(NETCDF_\${lang}) |
---|
| 484 | if(NETCDF_\${lang}_INCLUDE AND NETCDF_\${lang}_LIB) |
---|
| 485 | list(INSERT NetCDF_includes 0 \${NETCDF_\${lang}_INCLUDE}) |
---|
| 486 | list(INSERT NetCDF_libs 0 \${NETCDF_\${lang}_LIB}) # prepend so that -lnetcdf is last |
---|
| 487 | else() |
---|
| 488 | set(NetCDF_has_interfaces "NO") |
---|
| 489 | message(STATUS "Failed to find NetCDF interface for \${lang}") |
---|
| 490 | endif() |
---|
| 491 | endif(NETCDF_\${lang}) |
---|
| 492 | endmacro(NetCDF_add_interface) |
---|
| 493 | |
---|
| 494 | set(NetCDF_has_interfaces "YES") # will be set to NO if we're missing any interfaces |
---|
| 495 | NetCDF_add_interface(C) |
---|
| 496 | NetCDF_add_interface(CXX) |
---|
| 497 | NetCDF_add_interface(FORTRAN) |
---|
| 498 | |
---|
| 499 | # macro (NetCDF_check_interface lang header libs) |
---|
| 500 | # if (NETCDF_\${lang}) |
---|
| 501 | # find_path (NETCDF_INCLUDES_\${lang} NAMES \${header} HINTS \${NETCDF_HINTS} PATH_SUFFIXES include Include NO_DEFAULT_PATH) |
---|
| 502 | # find_library (NETCDF_LIBRARIES_\${lang} NAMES \${libs} HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH) |
---|
| 503 | # mark_as_advanced (NETCDF_INCLUDES_\${lang} NETCDF_LIBRARIES_\${lang}) |
---|
| 504 | # if (NETCDF_INCLUDES_\${lang} AND NETCDF_LIBRARIES_\${lang}) |
---|
| 505 | # list (INSERT NetCDF_libs 0 \${NETCDF_LIBRARIES_\${lang}}) # prepend so that -lnetcdf is last |
---|
| 506 | # else (NETCDF_INCLUDES_\${lang} AND NETCDF_LIBRARIES_\${lang}) |
---|
| 507 | # set (NetCDF_has_interfaces "NO") |
---|
| 508 | # message (STATUS "Failed to find NetCDF interface for \${lang}") |
---|
| 509 | # endif (NETCDF_INCLUDES_\${lang} AND NETCDF_LIBRARIES_\${lang}) |
---|
| 510 | # endif (NETCDF_\${lang}) |
---|
| 511 | # endmacro (NetCDF_check_interface) |
---|
| 512 | # |
---|
| 513 | # set (NetCDF_has_interfaces "YES") # will be set to NO if we're missing any interfaces |
---|
| 514 | # NetCDF_check_interface (C netcdf.h netcdf) |
---|
| 515 | # NetCDF_check_interface (CXX netcdfcpp.h netcdf_c++) |
---|
| 516 | # NetCDF_check_interface (FORTRAN netcdf.mod netcdff) |
---|
| 517 | |
---|
| 518 | set (NETCDF_C_COMPILER "\${NETCDF_C_COMPILER_C}" CACHE STRING "The C compiler used to build netCDF") |
---|
| 519 | set (NETCDF_FORTRAN_COMPILER "\${NETCDF_FORTRAN_COMPILER_FORTRAN}" CACHE STRING "The Fortran compiler used to build netCDF") |
---|
| 520 | set (NETCDF_INCLUDES "\${NetCDF_includes}" CACHE STRING "All NetCDF includes required for interface level") |
---|
| 521 | set (NETCDF_LIBRARIES "\${NetCDF_libs}" CACHE STRING "All NetCDF libraries required for interface level") |
---|
| 522 | |
---|
| 523 | # handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if |
---|
| 524 | # all listed variables are TRUE |
---|
| 525 | include (FindPackageHandleStandardArgs) |
---|
| 526 | find_package_handle_standard_args (NetCDF DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDES NetCDF_has_interfaces) |
---|
| 527 | |
---|
| 528 | mark_as_advanced (NETCDF_LIBRARIES NETCDF_INCLUDES) |
---|
| 529 | |
---|
| 530 | #message(STATUS "netCDF library: \${NETCDF_LIBRARIES}") |
---|
| 531 | #message(STATUS "netCDF include: \${NETCDF_INCLUDES}") |
---|
| 532 | |
---|
| 533 | EOF |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | ################################################################################ |
---|
| 537 | |
---|
| 538 | palm_installer_build |
---|
| 539 | palm_installer_set_path |
---|
| 540 | palm_installer_test_suite |
---|
| 541 | palm_post_installer_help |
---|