source: palm/trunk/INSTALL/palm_installer_components @ 4719

Last change on this file since 4719 was 4481, checked in by maronga, 5 years ago

Bugfix for copyright updates in document_changes; copyright update applied to all files

  • Property svn:executable set to *
File size: 25.6 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" -T "$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 -a \"d3#\" -c \"default\" -X \"$NUM_PROC_TEST\" -T \"$NUM_PROC_TEST\" "
190   printf "| %-${number_of_cols}s \n" "                      |           |          |        |     |            "
191   printf "| %-${number_of_cols}s \n" "                  Job name        |    configuration  | tasks per node   "
192   printf "| %-${number_of_cols}s \n" "                           I/O control list    number of cores           "
193   printf "| %-${number_of_cols}s \n" " "
194   printf "| %-${number_of_cols}s \n" "-- Edit \".palm.config.default\" to customize this ${program_name} installation."
195   printf "| %-${number_of_cols}s \n" "-- To rebuild ${program_name} type: palmbuild -c \"default\""
196   printf "| %-${number_of_cols}s \n" " "
197   printf "| %-${number_of_cols}s \n" "-- For further questions go to: https://palm.muk.uni-hannover.de/."
198   printf "| %-${number_of_cols}s \n" " "
199}
200
201palm_installer_create_files() {
202   mkdir -p ${source_dir}
203
204   cat > ${source_dir}/CMakeLists.txt << EOF
205# This is the CMake configuration file for PALM
206
207cmake_minimum_required (VERSION 2.8)
208
209# set program name
210set(PALM_PROGRAM_NAME "PALM")
211
212project(\${PALM_PROGRAM_NAME} NONE)
213exec_program( hostname OUTPUT_VARIABLE PALM_HOSTNAME)
214
215# .palm.config locations
216set(config_in \${CMAKE_CURRENT_SOURCE_DIR}/.palm.config.default.in)
217set(config \${CMAKE_INSTALL_PREFIX}/.palm.config.default)
218
219# palmtest.yml locations
220set(palmtest_in \${CMAKE_CURRENT_SOURCE_DIR}/.palmtest.yml.in)
221set(palmtest \${CMAKE_INSTALL_PREFIX}/palmtest.yml)
222
223# build_rrtmg locations
224set(build_rrtmg_in \${CMAKE_CURRENT_SOURCE_DIR}/build_rrtmg.in)
225set(build_rrtmg \${CMAKE_CURRENT_SOURCE_DIR}/rrtmg/build_rrtmg)
226
227# include local cmake files
228set(PALM_CMAKE_FILES \${CMAKE_CURRENT_SOURCE_DIR})
229list(APPEND CMAKE_MODULE_PATH \${PALM_CMAKE_FILES})
230
231# enabling Fortran language support
232enable_language(Fortran) # required to compile the main model and all utilities
233
234# check for Fortran MPI support
235find_package(MPI REQUIRED)
236
237# check for netCDF
238#set(NETCDF_C "YES")
239set(NETCDF_FORTRAN "YES")
240find_package (NetCDF REQUIRED)
241find_program(NETCDF_FORTRAN_COMPILER_FULL NAMES \${NETCDF_FORTRAN_COMPILER})
242if(NOT \${CMAKE_Fortran_COMPILER} STREQUAL \${NETCDF_FORTRAN_COMPILER_FULL} )
243   message(WARNING "Fortran compiler \"\${CMAKE_Fortran_COMPILER}\" does not match netCDF Fortran compiler \"\${NETCDF_FORTRAN_COMPILER_FULL}\".")
244else()
245   message(STATUS "Fortran compiler matches netCDF Fortran compiler.")
246endif()
247
248# extract subversion info
249if (${SVN_CMAKE_CHECK})
250find_package(Subversion)
251if(SUBVERSION_FOUND)
252   Subversion_WC_INFO(\${PROJECT_SOURCE_DIR}/../trunk PALM)
253   message(STATUS "Your \${PALM_PROGRAM_NAME} installation will be based on revision \${PALM_WC_REVISION}.")
254else(SUBVERSION_FOUND)
255   message(WARNING "Subversion not found. Wondering how you aquired the PALM code. :-)")
256endif(SUBVERSION_FOUND)
257endif()
258
259# check for fftw
260#find_package(FFTW)
261#if(FFTW_FOUND)
262#   message(STATUS "\${PALM_PROGRAM_NAME} is using an external fftw library.")
263#else(FFTW_FOUND)
264   message(STATUS "\${PALM_PROGRAM_NAME} is using the buildin fft algorithm.")
265#endif(FFTW_FOUND)
266
267# compiler flag management
268if(\${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray")
269   set(PALM_COMPILER_OPTIONS "-em -K trap=fp -O3 -hnoomp -hnoacc -hfp3 -hdynamic")
270   set(PALM_LINKER_OPTIONS "\${PALM_COMPILER_OPTIONS} -dynamic")
271   set(PALM_CPP_FLAGS "-eZ")
272elseif(\${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
273   set(PALM_COMPILER_OPTIONS "-O3 -fp-model source -fno-alias -fpe0 -ftz -no-prec-div -no-prec-sqrt -ip -nbs -diag-disable 8290,8291")
274   set(PALM_LINKER_OPTIONS "\${PALM_COMPILER_OPTIONS}")
275   set(PALM_CPP_FLAGS "-cpp")
276   list(APPEND PALM_CPP_OPTIONS __intel_compiler)
277elseif(\${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
278   set(PALM_COMPILER_OPTIONS "-Ofast -ffree-line-length-none")
279   set(PALM_LINKER_OPTIONS "\${PALM_COMPILER_OPTIONS}")
280   set(PALM_CPP_FLAGS "-cpp")
281   list(APPEND PALM_CPP_OPTIONS __gfortran)
282endif()
283
284# workaround
285list(APPEND PALM_CPP_OPTIONS __parallel)
286
287# adding cpp options
288list(APPEND PALM_CPP_OPTIONS MPI_REAL=MPI_DOUBLE_PRECISION)
289list(APPEND PALM_CPP_OPTIONS MPI_2REAL=MPI_2DOUBLE_PRECISION)
290if(NETCDF_FOUND)
291   list(APPEND PALM_CPP_OPTIONS __netcdf)
292   set(PALM_COMPILER_OPTIONS "\${PALM_COMPILER_OPTIONS} -I \${NETCDF_INCLUDES}")
293   set(PALM_LINKER_OPTIONS "\${PALM_LINKER_OPTIONS} \${NETCDF_LIBRARIES}")
294   set(PALMTEST_NETCDF_INCLUDES "netcdf: \"-I \${NETCDF_INCLUDES}\"")
295   set(PALMTEST_NETCDF_LIBRARIES "netcdf: \"\${NETCDF_LIBRARIES}\"")
296endif()
297
298#if(FFTW_FOUND)
299#   list(APPEND PALM_CPP_OPTIONS __fftw)
300#   set(PALM_COMPILER_OPTIONS "\${PALM_COMPILER_OPTIONS} -I \${FFTW_INCLUDES}")
301#   set(PALM_LINKER_OPTIONS "\${PALM_LINKER_OPTIONS} \${FFTW_LIBRARIES}")
302#   set(PALMTEST_FFTW_INCLUDES "fftw: \"-I \${FFTW_INCLUDES}\"")
303#   set(PALMTEST_FFTW_LIBRARIES "fftw: \"\${FFTW_LIBRARIES}\"")
304#endif()
305
306if(RRTMG_ROOT)
307   set(PALMTEST_RRTMG_INCLUDES "rrtmg: \"-I \${RRTMG_ROOT}/include\"")
308   set(PALMTEST_RRTMG_LIBRARIES "rrtmg: \"\${RRTMG_ROOT}/lib/librrtmg.so\"")
309endif()
310
311string(REPLACE ";" " -D" PALM_CPP_OPTIONS_STR_1 "\${PALM_CPP_OPTIONS}")
312set(PALM_CPP_OPTIONS_STR "\${PALM_CPP_FLAGS} -D\${PALM_CPP_OPTIONS_STR_1}")
313
314set(PALM_EXECUTE_COMMAND "mpirun -n {{mpi_tasks}}")
315
316# configuring the .palm.config
317configure_file(\${config_in} \${config} @ONLY)
318
319# configuring the palmtest.yml
320configure_file(\${palmtest_in} \${palmtest} @ONLY)
321
322if(RRTMG_ROOT)
323   # configuring the build_rrtmg
324   configure_file(\${build_rrtmg_in} \${build_rrtmg} @ONLY)
325endif()
326
327EOF
328
329   cat > ${source_dir}/FindFFTW.cmake << EOF
330# - Find FFTW
331# Find the native FFTW includes and library
332#
333#  FFTW_INCLUDES    - where to find fftw3.h
334#  FFTW_LIBRARIES   - List of libraries when using FFTW.
335#  FFTW_FOUND       - True if FFTW found.
336
337if (FFTW_INCLUDES)
338  # Already in cache, be silent
339  set (FFTW_FIND_QUIETLY TRUE)
340endif (FFTW_INCLUDES)
341
342#exec_program(sed ARGS -i '/%fftw_inc.*/d' \${config})
343#list(APPEND NETCDF_HINTS "\$ENV{LD_LIBRARY_PATH}")
344
345find_path (FFTW_INCLUDES fftw3.f03 HINTS \${NETCDF_HINTS} ENV LD_LIBRARY_PATH  PATH_SUFFIXES include Include)
346find_library(NETCDF_FORTRAN_LIB netcdff HINTS \${NETCDF_HINTS} ENV LD_LIBRARY_PATH PATH_SUFFIXES lib lib64)
347
348find_library (FFTW_LIBRARIES NAMES fftw3)
349
350# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
351# all listed variables are TRUE
352include (FindPackageHandleStandardArgs)
353find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES)
354
355mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES)
356
357EOF
358
359   cat > ${source_dir}/FindNetCDF.cmake << EOF
360# - Find NetCDF
361# Find the native NetCDF includes and library
362#
363#  NETCDF_INCLUDES    - where to find netcdf.h, etc
364#  NETCDF_LIBRARIES   - Link these libraries when using NetCDF
365#  NETCDF_FOUND       - True if NetCDF found including required interfaces (see below)
366#
367# Your package can require certain interfaces to be FOUND by setting these
368#
369#  NETCDF_C           - require the C interface and link the C library
370#  NETCDF_CXX         - require the C++ interface and link the C++ library
371#  NETCDF_FORTRAN     - require the Fortran interface and link the Fortran library
372#
373# The following are not for general use and are included in
374# NETCDF_LIBRARIES if the corresponding option above is set.
375#
376#  NETCDF_LIBRARIES_C        - Just the C interface
377#  NETCDF_LIBRARIES_CXX      - C++ interface, if available
378#  NETCDF_LIBRARIES_FORTRAN  - Fortran 90 interface, if available
379#
380# Normal usage would be:
381#  set (NETCDF_FORTRAN "YES")
382#  find_package (NetCDF REQUIRED)
383#  target_link_libraries (uses_f90_interface \${NETCDF_LIBRARIES})
384
385if (NETCDF_INCLUDES AND NETCDF_LIBRARIES)
386  # Already in cache, be silent
387  set (NETCDF_FIND_QUIETLY TRUE)
388endif (NETCDF_INCLUDES AND NETCDF_LIBRARIES)
389
390
391macro(NETCDF_CONFIG flag output)
392    if(NETCDF_CONFIG_EXECUTABLE)
393        exec_program( \${NETCDF_CONFIG_EXECUTABLE} ARGS \${flag}
394            OUTPUT_VARIABLE \${output} RETURN_VALUE return_value)
395        if(NOT \${return_value} EQUAL 0 )
396            message( STATUS "Unable to determine \${flag} from \${NETCDF_CONFIG_EXECUTABLE}." )
397        endif()
398    endif(NETCDF_CONFIG_EXECUTABLE)
399endmacro()
400
401if(NETCDF_C_ROOT)
402   list(APPEND NETCDF_HINTS "\${NETCDF_C_ROOT}")
403else()
404   list(APPEND NETCDF_HINTS "\$ENV{NETCDF_ROOT}")
405endif()
406
407if(NETCDF_FORTRAN_ROOT)
408   list(APPEND NETCDF_HINTS "\${NETCDF_FORTRAN_ROOT}")
409else()
410   list(APPEND NETCDF_HINTS "\$ENV{NETCDF_ROOT}")
411endif()
412
413if(NETCDF_C_ROOT)
414   find_program(NETCDF_C_CONFIG_EXECUTABLE NAMES nc-config
415      HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin NO_DEFAULT_PATH
416      DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." )
417else()
418   find_program(NETCDF_C_CONFIG_EXECUTABLE NAMES nc-config
419      HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin
420      DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." )
421endif()
422
423set(NETCDF_CONFIG_EXECUTABLE \${NETCDF_C_CONFIG_EXECUTABLE})
424   if(NETCDF_C_CONFIG_EXECUTABLE)
425      NETCDF_CONFIG(--cc NETCDF_C_COMPILER_C)
426      NETCDF_CONFIG(--fc NETCDF_C_COMPILER_FORTRAN)
427      NETCDF_CONFIG(--prefix NETCDF_C_ROOT)
428      NETCDF_CONFIG(--includedir NETCDF_C_INCLUDE)
429      NETCDF_CONFIG(--version NETCDF_C_VERSION)
430      #NETCDF_CONFIG(--has-c++ NETCDF_C_CXX)
431      #NETCDF_CONFIG(--has-f77 NETCDF_C_F77)
432      NETCDF_CONFIG(--has-f90 NETCDF_C_F90)
433      #NETCDF_CONFIG(--has-dap NETCDF_C_DAP)
434      #NETCDF_CONFIG(--has-nc2 NETCDF_C_NC2)
435      #NETCDF_CONFIG(--has-nc4 NETCDF_C_NC4)
436      #NETCDF_CONFIG(--has-hdf4 NETCDF_C_HDF4)
437      #NETCDF_CONFIG(--has-hdf5 NETCDF_C_HDF5)
438      #NETCDF_CONFIG(--has-pnetcdf NETCDF_C_PARALLEL)
439      list(APPEND NETCDF_INCLUDE_HINTS "\${NETCDF_C_INCLUDE}")
440      list(APPEND NETCDF_HINTS "\${NETCDF_C_ROOT}")
441      message(STATUS "Found \${NETCDF_C_VERSION} compiled with \${NETCDF_C_COMPILER_C}")
442   else(NETCDF_C_CONFIG_EXECUTABLE)
443      message(STATUS "nc-config not found")
444   endif(NETCDF_C_CONFIG_EXECUTABLE)
445
446if(NETCDF_C_ROOT AND NETCDF_FORTRAN_ROOT)
447   find_program(NETCDF_FORTRAN_CONFIG_EXECUTABLE NAMES nf-config
448       HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin NO_DEFAULT_PATH
449       DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." )
450else()
451   find_program(NETCDF_FORTRAN_CONFIG_EXECUTABLE NAMES nf-config
452       HINTS \${NETCDF_HINTS} PATH_SUFFIXES bin Bin
453       DOC "NETCDF CONFIG PROGRAM. Used to detect NETCDF compile flags." )
454endif()
455
456set(NETCDF_CONFIG_EXECUTABLE \${NETCDF_FORTRAN_CONFIG_EXECUTABLE})
457   if(NETCDF_FORTRAN_CONFIG_EXECUTABLE)
458      NETCDF_CONFIG(--cc NETCDF_FORTRAN_COMPILER_C)
459      NETCDF_CONFIG(--fc NETCDF_FORTRAN_COMPILER_FORTRAN)
460      NETCDF_CONFIG(--prefix NETCDF_FORTRAN_ROOT)
461      NETCDF_CONFIG(--includedir NETCDF_FORTRAN_INCLUDE)
462      NETCDF_CONFIG(--version NETCDF_FORTRAN_VERSION)
463      #NETCDF_CONFIG(--has-c++ NETCDF_FORTRAN_CXX)
464      #NETCDF_CONFIG(--has-f77 NETCDF_FORTRAN_F77)
465      NETCDF_CONFIG(--has-f90 NETCDF_FORTRAN_F90)
466      #NETCDF_CONFIG(--has-dap NETCDF_FORTRAN_DAP)
467      #NETCDF_CONFIG(--has-nc2 NETCDF_FORTRAN_NC2)
468      #NETCDF_CONFIG(--has-nc4 NETCDF_FORTRAN_NC4)
469      #NETCDF_CONFIG(--has-hdf4 NETCDF_FORTRAN_HDF4)
470      #NETCDF_CONFIG(--has-hdf5 NETCDF_FORTRAN_HDF5)
471      #NETCDF_CONFIG(--has-pnetcdf NETCDF_FORTRAN_PARALLEL)
472      list(APPEND NETCDF_INCLUDE_HINTS "\${NETCDF_FORTRAN_INCLUDE}")
473      list(APPEND NETCDF_HINTS "\${NETCDF_FORTRAN_ROOT}")
474      message(STATUS "Found \${NETCDF_FORTRAN_VERSION} compiled with \${NETCDF_FORTRAN_COMPILER_FORTRAN}")
475   else(NETCDF_FORTRAN_CONFIG_EXECUTABLE)
476      #message(STATUS "nf-config not found")
477      set(NETCDF_FORTRAN_COMPILER_C \${NETCDF_C_COMPILER_C})
478      set(NETCDF_FORTRAN_COMPILER_FORTRAN \${NETCDF_C_COMPILER_FORTRAN})
479      set(NETCDF_FORTRAN_ROOT \${NETCDF_C_ROOT})
480      set(NETCDF_FORTRAN_INCLUDE \${NETCDF_C_INCLUDE})
481      set(NETCDF_FORTRAN_VERSION \${NETCDF_C_VERSION})
482      #set(NETCDF_FORTRAN_CXX \${NETCDF_C_CXX})
483      #set(NETCDF_FORTRAN_F77 \${NETCDF_C_F77})
484      set(NETCDF_FORTRAN_F90 \${NETCDF_C_F90})
485      #set(NETCDF_FORTRAN_DAP \${NETCDF_C_DAP})
486      #set(NETCDF_FORTRAN_NC2 \${NETCDF_C_NC2})
487      #set(NETCDF_FORTRAN_NC4 \${NETCDF_C_NC4})
488      #set(NETCDF_FORTRAN_HDF4 \${NETCDF_C_HDF4})
489      #set(NETCDF_FORTRAN_HDF5 \${NETCDF_C_HDF5})
490      #set(NETCDF_FORTRAN_PARALLEL \${NETCDF_C_PARALLEL})
491      if(NETCDF_FORTRAN_F90)
492         message(STATUS "Found \${NETCDF_FORTRAN_VERSION} compiled with \${NETCDF_FORTRAN_COMPILER_FORTRAN}")
493      else(NETCDF_FORTRAN_F90)
494         message(STATUS "nc-config found no netCDF Fortran libraries")
495      endif(NETCDF_FORTRAN_F90)
496   endif(NETCDF_FORTRAN_CONFIG_EXECUTABLE)
497
498# find netcdf c
499if(NOT NETCDF_C_INCLUDE)
500   find_path(NETCDF_C_INCLUDE netcdf.h HINTS \${NETCDF_HINTS} PATH_SUFFIXES include Include)
501endif()
502find_library(NETCDF_C_LIB netcdf HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64)
503#message(STATUS "NETCDF_C_INCLUDE so far: \${NETCDF_C_INCLUDE}")
504#message(STATUS "NETCDF_C_LIB so far: \${NETCDF_C_LIB}")
505
506# find netcdf fortran
507if(NOT NETCDF_FORTRAN_INCLUDE)
508   find_path(NETCDF_FORTRAN_INCLUDE netcdf.mod HINTS \${NETCDF_HINTS} PATH_SUFFIXES include Include)
509endif()
510find_library(NETCDF_FORTRAN_LIB netcdff HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64)
511if(NOT NETCDF_FORTRAN_LIB)
512   find_library(NETCDF_FORTRAN_LIB netcdf HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64)
513endif()
514#message(STATUS "NETCDF_FORTRAN_INCLUDE so far: \${NETCDF_FORTRAN_INCLUDE}")
515#message(STATUS "NETCDF_FORTRAN_LIB so far: \${NETCDF_FORTRAN_LIB}")
516
517if ((NOT NETCDF_C_LIB) OR (NOT NETCDF_C_INCLUDE))
518   message(STATUS "Trying to find NetCDF using LD_LIBRARY_PATH (we're desperate)...")
519   file(TO_CMAKE_PATH "\$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH)
520   find_library(NETCDF_C_LIB NAMES netcdf HINTS \${LD_LIBRARY_PATH})
521
522   if (NETCDF_C_LIB)
523      get_filename_component(NETCDF_LIB_DIR \${NETCDF_C_LIB} PATH)
524      string(REGEX REPLACE "/lib/?\$" "/include" NETCDF_H_HINT \${NETCDF_LIB_DIR})
525      find_path (NETCDF_C_INCLUDE netcdf.h HINTS \${NETCDF_H_HINT} DOC "Path to netcdf.h")
526      message(STATUS "found netcdf.h in: \${NETCDF_C_INCLUDE}")
527      list(APPEND NETCDF_INCLUDE_HINTS "\${NETCDF_C_INCLUDE}")
528   endif()
529endif()
530
531get_filename_component (NETCDF_C_LIB_DIR "\${NETCDF_C_LIB}" PATH)
532get_filename_component (NETCDF_FORTRAN_LIB_DIR "\${NETCDF_FORTRAN_LIB}" PATH)
533list(APPEND NETCDF_LIB_HINTS "\${NETCDF_C_LIB_DIR}")
534list(APPEND NETCDF_LIB_HINTS "\${NETCDF_FORTRAN_LIB_DIR}")
535
536#message(STATUS "All include Hints: \${NETCDF_INCLUDE_HINTS}")
537#message(STATUS "All lib Hints: \${NETCDF_LIB_HINTS}")
538
539macro(NetCDF_add_interface lang)
540   if(NETCDF_\${lang})
541      if(NETCDF_\${lang}_INCLUDE AND NETCDF_\${lang}_LIB)
542         list(INSERT NetCDF_includes 0 \${NETCDF_\${lang}_INCLUDE})
543         list(INSERT NetCDF_libs 0 \${NETCDF_\${lang}_LIB}) # prepend so that -lnetcdf is last
544      else()
545         set(NetCDF_has_interfaces "NO")
546         message(STATUS "Failed to find NetCDF interface for \${lang}")
547      endif()
548   endif(NETCDF_\${lang})
549endmacro(NetCDF_add_interface)
550
551set(NetCDF_has_interfaces "YES") # will be set to NO if we're missing any interfaces
552NetCDF_add_interface(C)
553NetCDF_add_interface(CXX)
554NetCDF_add_interface(FORTRAN)
555
556# macro (NetCDF_check_interface lang header libs)
557#    if (NETCDF_\${lang})
558#       find_path (NETCDF_INCLUDES_\${lang} NAMES \${header} HINTS \${NETCDF_HINTS} PATH_SUFFIXES include Include NO_DEFAULT_PATH)
559#       find_library (NETCDF_LIBRARIES_\${lang} NAMES \${libs} HINTS \${NETCDF_HINTS} PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH)
560#       mark_as_advanced (NETCDF_INCLUDES_\${lang} NETCDF_LIBRARIES_\${lang})
561#       if (NETCDF_INCLUDES_\${lang} AND NETCDF_LIBRARIES_\${lang})
562#          list (INSERT NetCDF_libs 0 \${NETCDF_LIBRARIES_\${lang}}) # prepend so that -lnetcdf is last
563#       else (NETCDF_INCLUDES_\${lang} AND NETCDF_LIBRARIES_\${lang})
564#          set (NetCDF_has_interfaces "NO")
565#          message (STATUS "Failed to find NetCDF interface for \${lang}")
566#       endif (NETCDF_INCLUDES_\${lang} AND NETCDF_LIBRARIES_\${lang})
567#    endif (NETCDF_\${lang})
568# endmacro (NetCDF_check_interface)
569#
570# set (NetCDF_has_interfaces "YES") # will be set to NO if we're missing any interfaces
571# NetCDF_check_interface (C netcdf.h netcdf)
572# NetCDF_check_interface (CXX netcdfcpp.h netcdf_c++)
573# NetCDF_check_interface (FORTRAN netcdf.mod  netcdff)
574
575set (NETCDF_C_COMPILER "\${NETCDF_C_COMPILER_C}" CACHE STRING "The C compiler used to build netCDF")
576set (NETCDF_FORTRAN_COMPILER "\${NETCDF_FORTRAN_COMPILER_FORTRAN}" CACHE STRING "The Fortran compiler used to build netCDF")
577set (NETCDF_INCLUDES "\${NetCDF_includes}" CACHE STRING "All NetCDF includes required for interface level")
578set (NETCDF_LIBRARIES "\${NetCDF_libs}" CACHE STRING "All NetCDF libraries required for interface level")
579
580# handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if
581# all listed variables are TRUE
582include (FindPackageHandleStandardArgs)
583find_package_handle_standard_args (NetCDF DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDES NetCDF_has_interfaces)
584
585mark_as_advanced (NETCDF_LIBRARIES NETCDF_INCLUDES)
586
587#message(STATUS "netCDF library: \${NETCDF_LIBRARIES}")
588#message(STATUS "netCDF include: \${NETCDF_INCLUDES}")
589
590EOF
591
592   cat > ${source_dir}/.palmtest.yml.in << EOF
593---
594# this is a palmtest environments file
595
596palm_config_template:
597
598environments:
599
600  @CMAKE_Fortran_COMPILER_ID@:
601    executable: @CMAKE_Fortran_COMPILER@
602    mpi_wrapper: @MPI_Fortran_COMPILER@
603    include:
604      @PALMTEST_NETCDF_INCLUDES@
605      @PALMTEST_FFTW_INCLUDES@
606      @PALMTEST_RRTMG_INCLUDES@
607    lib:
608      @PALMTEST_NETCDF_LIBRARIES@
609      @PALMTEST_FFTW_LIBRARIES@
610      @PALMTEST_RRTMG_LIBRARIES@
611
612EOF
613
614   cat > ${source_dir}/build_rrtmg.in << EOF
615#!/usr/bin/env bash
616
617make -f Makefile F90=@MPI_Fortran_COMPILER@  PROG=librrtmg F90FLAGS="@PALM_COMPILER_OPTIONS@"
618
619EOF
620
621
622}
623
624################################################################################
625
626palm_installer_build
627palm_installer_set_path
628palm_installer_test_suite
629palm_post_installer_help
Note: See TracBrowser for help on using the repository browser.