source: palm/trunk/INSTALL/palm_installer_components @ 4829

Last change on this file since 4829 was 4729, checked in by raasch, 4 years ago

option -T removed from the automatic installation process

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