Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake build system for cfl3d #5

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
f3d6a2f
gfortran compilation, major part can be run
Jul 21, 2017
9a8ba1e
add *.swp to .gitignore
Jul 21, 2017
7ae0997
precfl compile pass
Jul 21, 2017
49e93f0
fixed spalart.F for complex cfl3d
Jul 21, 2017
bf1a88e
linux_gfortran_openmpi OK
Jul 21, 2017
a0b48e7
fix makefile_linux_gfotran_openmpi
Jul 21, 2017
9e1d076
add 编译修正过程.md
Jul 21, 2017
0eff618
Update 编译修正过程.md
Jul 21, 2017
d95f7ec
Update 编译修正过程.md
Jul 21, 2017
a7b8607
add test cases
Jul 22, 2017
e49799d
Merge branch 'master' of https://github.com/chengdi123000/CFL3D
Jul 22, 2017
15eb56e
Update 编译修正过程.md
Jul 22, 2017
cf7efe5
update .gitignore
Jul 26, 2017
eaa891b
add create_use_cfl3d
Jul 26, 2017
2d1fc87
exclude test cases, just download it by your self
Aug 1, 2017
3e5f4da
slightly modified .gitignore
Aug 1, 2017
6790612
remove Chinese name
Aug 1, 2017
2501e29
cfl3d_seq compiled successfully.
Aug 4, 2017
3f8dfc6
added CGNS as submodule
Aug 6, 2017
2ffd086
remove CGNS
Aug 6, 2017
a3eecce
add CGNS as IMPORTED library in CMake system
Aug 6, 2017
1034f7b
cgns lib fix
Aug 7, 2017
683b1eb
CMakeLists.txt fix: no MPI, no FASTIO
Aug 7, 2017
1413d32
found BC2010 error
Aug 8, 2017
1bdf4d3
fixed cfl3d/libs/bc2010.F: add real() to variabls who might be comple…
Aug 8, 2017
cff1cb5
successfully compiled all components with CGNS and OpenMPI using gfor…
Aug 8, 2017
1e9b0dd
README.md updated
Aug 8, 2017
c35f779
remove CFL3D bin: there is CFL3D/build/bin
Aug 8, 2017
3943606
modify README.md: add usage section and test section
Aug 8, 2017
b1c2c92
add build_cgns
Aug 10, 2017
3880a26
fix makefile_linux_gfortran_openmpi: I just give up to make makefile …
Aug 10, 2017
69147f3
fix .gitignore
Aug 10, 2017
8179e0c
merge CMake version to master
Aug 10, 2017
df1295d
fix README.md to use coding.net
Aug 10, 2017
2a46f33
update README.md: add a tag v6.7_gfortran_openmpi to release the orig…
Aug 10, 2017
f52c3e4
delete cgnslib_2.5-5.tar.gz, you can download it by yourself
Aug 10, 2017
7f4aaf1
merge form nasa/cfl3d ; and remove all content in build dir of origi…
Aug 10, 2017
3b738ef
fixed create_use_cfl3d, and tested it
Aug 10, 2017
4b5fc54
rm CFL3D/bin folder
Aug 11, 2017
c9e3507
delete notes_cn.md
Aug 11, 2017
0087a7f
change CMakeLists.txt version requirement
Aug 11, 2017
e38b69e
fix CMakeLists.txt: compatible with ubuntu 14.04 cmake 2.8 from apt-get
Aug 11, 2017
aeae8e7
create 'tools' target
Aug 19, 2017
9a6b416
modify build_cgns, make it install to a standard place and in a stand…
Aug 19, 2017
22f2450
modify create_use_cfl3d to make it work correctly
Aug 19, 2017
41129e8
fixed MinGW error
Aug 24, 2017
30232e8
fix CMakeLists.txt: add mpich2-1.4.1p1 (at most) support.
Aug 26, 2017
a5323a5
add few test
Aug 27, 2017
8eee569
add testcase files
Aug 27, 2017
4a12cc6
fix test, using abs path of target executables
Aug 27, 2017
14ef10e
missing bumpperiodic.inp in MPI test
Aug 27, 2017
81ed892
some fix of MPI test: missing split.inp_1blk
Aug 27, 2017
f323cb2
fastio problem in MinGW, turn it off in MinGW
Aug 27, 2017
dc92a1c
change default fastio behavior: off
Aug 27, 2017
d1fa67e
modified ronnie.F: fix gfortran segmentation fault. comment the
Aug 28, 2017
549d2b3
modify build_cgns script: add some conditional statement to check if …
Aug 29, 2017
0676ef8
modify build_cgns, some typo, there must be a space between [ and -e …
Aug 30, 2017
3f92e89
add direct cgns dependency to tools. add gfortran conditional compila…
Aug 30, 2017
bcae694
fix CMakeLists.txt: add -DCGNS to TOOLS_SHARE target
Aug 30, 2017
6bc34f3
fix build_cgns: add debug info
Aug 31, 2017
23028ac
fix CMakeLists.txt: judge fortran compiler more wisely
Aug 31, 2017
bcfc6ec
fix build_cgns: remove debug option
Aug 31, 2017
e5a23a2
compile and test on TH2 supercomputer
Aug 31, 2017
b20da2d
fix CMakeLists.txt: CMake_Fortran_COMPILER_ID should be CMAKE_FORTRAN…
Sep 1, 2017
3654196
update create_use_cfl3d.
Oct 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 9 additions & 54 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,55 +1,10 @@
# Untracked files:
*.o
build/makefile
build/tools/seq/*.F*
build/splitcmplx/seq/*.F*
build/split/seq/*.F*
build/ron/seq/*.F*
build/preron/seq/*.F*
build/precfl/seq/*.F*
build/mag/seq/*.F*
build/cflcmplx/seq/*.F*
build/cflcmplx/mpi/*.F*
build/cflcmplx/libs/*.F*
build/cflcmplx/libs/bessel.c
build/cfl/libs/bessel.c
build/cfl/seq/*.F*
build/cfl/mpi/*.F*
build/cfl/libs/*.F*
build/cfl/libs/*.mod
libcommon.a
libdist.a
cfl3d_seq
cfl3d_mpi
cfl3dcmplx_seq
cfl3dcmplx_mpi
maggie
precfl3d
preronnie
ronnie
splitter
splittercmplx
build/mag/seq/mag1.h
build/tools/seq/Get_FD
build/tools/seq/INGRID_to_p3d
build/tools/seq/XINTOUT_to_ovrlp
build/tools/seq/cfl3d_to_nmf
build/tools/seq/cfl3d_to_pegbc
build/tools/seq/cfl3dinp_to_FVBND
build/tools/seq/cgns_readhist
build/tools/seq/cgns_to_cfl3dinput
build/tools/seq/everyother_xyz
build/tools/seq/grid_perturb
build/tools/seq/grid_perturb_cmplx
build/tools/seq/initialize_field
build/tools/seq/libs.a
build/tools/seq/moovmaker
build/tools/seq/nmf_to_cfl3dinput
build/tools/seq/p3d_to_INGRID
build/tools/seq/p3d_to_cfl3drst
build/tools/seq/plot3dg_to_cgns
build/tools/seq/v6_restart_mod
build/tools/seq/v6_ronnie_mod
build/tools/seq/v6inpdoubhalf
build/tools/seq/gridswitchijk
build/tools/seq/v6inpswitchijk
build/
testcase/
*.orig
*.gz
external/

*.swp
bin/
external/cgns/cgnslib_2.5/
213 changes: 213 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
cmake_minimum_required(VERSION 2.6)
project(CFL3D)
set(CFL3D_VERSION_MAJOR 6)
set(CFL3D_VERSION_MINOR 7)
enable_language(Fortran C)
SET (CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include CACHE PATH "Single Directory for all fortran modules.")

## output some information
message("CMAKE_SYSTEM: ${CMAKE_SYSTEM}")
message("MSYS: ${MSYS}")
## options
option(USE_SINGLE "use single precision? " OFF)
option(USE_CGNS "use CGNS? " ON)
option(USE_NO_REDIRECT "use no-redirect? " OFF)
option(USE_FASTIO "use fast-io of mpi? It is effective when mpi is found. " OFF)
option(BUILD_MPI "build MPI version? " ON)
option(BUILD_CMPLX "build complex version? " ON)

## default Build Type is Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)

## no redirect
if(USE_NO_REDIRECT)
add_definitions(-DNOREDIRECT)
endif(USE_NO_REDIRECT)



# no FindCGNS in CMake release
# using Paraview's FindCGNS.cmake
# https://github.com/Kitware/ParaView/raw/master/CMake/FindCGNS.cmake
# modified to find `cgnslib_f.h` and `libcgns.a`
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

if(USE_CGNS)
find_package(CGNS 2.4 REQUIRED)
if(CGNS_FOUND)
message("Found CGNS for CFL3D")
message("CGNS include dir: ${CGNS_INCLUDE_DIR}")
message("CGNS library: ${CGNS_LIBRARY}")
add_library(cgns STATIC IMPORTED)
set_property(TARGET cgns PROPERTY IMPORTED_LOCATION ${CGNS_LIBRARY})
set_property(TARGET cgns PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES Fortran)
set_property(TARGET cgns PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${CGNS_INCLUDE_DIR}>)
set_property(TARGET cgns PROPERTY INTERFACE_COMPILE_DEFINITIONS CGNS)
##add_definitions(-DCGNS)
else(CGNS_FOUND)
message(WARNING "system CGNS not found for CFL3D")
set(USE_CGNS OFF CACHE BOOL "use CGNS? (not available)" FORCE) # set the CGNS not available
endif(CGNS_FOUND)
else(USE_CGNS)
message("NO CGNS for CFL3D")
endif(USE_CGNS)

if(BUILD_MPI)
find_package(MPI 1.0 REQUIRED)
if(MPI_Fortran_FOUND)
message("Found MPI for Fortran")
## add mpi library
add_library(mpi STATIC IMPORTED)
set_property(TARGET mpi PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MPI_Fortran_INCLUDE_PATH})
message("Choose the first element of libs: ${MPI_Fortran_LIBRARIES}")
set(other_elems ${MPI_Fortran_LIBRARIES})
list(GET other_elems 0 first_elem)
list(REMOVE_AT other_elems 0)
set_property(TARGET mpi PROPERTY IMPORTED_LOCATION ${first_elem})
set_property(TARGET mpi PROPERTY INTERFACE_LINK_LIBRARIES ${other_elems})
set_property(TARGET mpi APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "DIST_MPI")
set_property(TARGET mpi APPEND PROPERTY LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}")
set_property(TARGET mpi APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_Fortran_COMPILE_FLAGS}")

## if using MinGW in Windows
if(MINGW)
message(WARNING "fast-io is not available in MinGW.")
set(USE_FASTIO OFF CACHE BOOL "fast-io is not available in MinGW, turn it off" FORCE) # set the fastio not available

message("Using MinGW compilers, in Windows, MPICH2 1.4.1p1 is supported.")
get_filename_component(MPI_Fortran_LIB_DIR ${first_elem} DIRECTORY)
find_library(MPICH2_WIN libfmpich2g.a ${MPI_Fortran_LIB_DIR})
if(MPICH2_WIN)
message("libfmpich2g.a of mpich2 for MinGW fortran 77 is found and used: ${MPICH2_WIN}")
set_property(TARGET mpi PROPERTY IMPORTED_LOCATION "${MPICH2_WIN}")
set(MPIEXEC_PREFLAGS ${MPIEXEC_PREFLAGS} "-localroot")
else(MPICH2_WIN)
message("libfmpich2g.a of mpich2 for MinGW fortran 77 is not found, trying to use ${first_elem}")
endif(MPICH2_WIN)
else(MINGW)
## FAST-io
if(USE_FASTIO)
set_property(TARGET mpi APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "FASTIO")
endif(USE_FASTIO)
endif(MINGW)

else(MPI_Fortran_FOUND)
## FAST-io
if(USE_FASTIO)
message(WARNING "no mpi, no fast-io.")
set(USE_FASTIO OFF CACHE BOOL "build MPI? (not available)" FORCE) # set the fastio not available
endif(USE_FASTIO)
set(BUILD_MPI OFF CACHE BOOL "build MPI? (not available)" FORCE) # set the MPI not available
endif(MPI_Fortran_FOUND)
else(BUILD_MPI)
endif(BUILD_MPI)

# in LINUX system
if(UNIX)
message("in Linux or Linux-like system")
add_definitions(-DLINUX)
endif(UNIX)

if(MINGW)
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition")
else(MINGW)
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z muldefs")
endif(MINGW)

## use options to setup flags and find libraries
if(USE_SINGLE)
# do nothing
else(USE_SINGLE)
add_definitions(-DDBLE_PRECSN)
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -fdefault-real-8)
else(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -r8)
endif(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
endif(USE_SINGLE)


## project compiler dependent settings
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
add_definitions(-DINTEL)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -xHost)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -traceback)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -fpe0)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -ip)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -fno-alias)
# no `-w` option, do not turn warnings off.
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CFL3D_FLAGS ${CFL3D_FLAGS} -march=native)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -Wno-align-commons)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -fbacktrace)
else()
message(WARNING "Untested compiler iD: " ${CMAKE_Fortran_COMPILER_ID})
message(WARNING "Supported compiler iD: Intel/GNU")
message(WARNING "Try to use GNU options")
set(CFL3D_FLAGS ${CFL3D_FLAGS} -march=native)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -Wno-align-commons)
set(CFL3D_FLAGS ${CFL3D_FLAGS} -fbacktrace)
endif()

message("Final compile flags for fortran is: ${CFL3D_FLAGS}")


# it seems always use P3D_SINGLE in original Install script
add_definitions(-DP3D_SINGLE)

message("---------------------CFL3D programs summary--------------------------")
message("Build type? " ${CMAKE_BUILD_TYPE})
message("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message("CMAKE Fortran compiler ID: " ${CMAKE_Fortran_COMPILER_ID})
message("---------------------------------------------------------------------")

# set output library
# use CMAKE_XXX_OUTPUT_DIRECTORY to set the default dirs when create targets
# set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/lib/fortran)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

add_subdirectory(source)

#test
enable_testing()
add_test(
NAME 2D_SEQ_FLATPLATE
COMMAND sh -c "$<TARGET_FILE:splitter><split.inp_1blk && $<TARGET_FILE:cfl3d_seq><grdflat5.inp"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/testcase/Flatplate
)

add_test(
NAME 2D_RONNIE_BACKSTEP
COMMAND sh -c "$<TARGET_FILE:splitter> < split.inp_1blk && $<TARGET_FILE:ronnie> < ron_step_grdgen.inp && $<TARGET_FILE:cfl3d_seq> < step_grdgen.inp"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/testcase/Backstep
)
add_test(
NAME 2D_MAGGIE_NACA4412
COMMAND sh -c "$<TARGET_FILE:splitter> < split.inp_xmera && $<TARGET_FILE:maggie> < maggie.inp && $<TARGET_FILE:cfl3d_seq> < cfl3d.inp_xmera"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/testcase/NACA_4412
)

if(BUILD_MPI)
add_test(
NAME 2.5D_MPI_AXIBUMP
COMMAND sh -c "$<TARGET_FILE:splitter> < split.inp_3blk && ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} $<TARGET_FILE:cfl3d_mpi> ${MPIEXEC_POSTFLAGS} < bumpperiodic.inp_3blk"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/testcase/Axibump
)
endif(BUILD_MPI)

if(USE_CGNS)
add_test(
NAME 3D_SEQ_DELTA_PLOT3D_TO_CGNS
COMMAND sh -c "$<TARGET_FILE:plot3dg_to_cgns> < plot3dg_to_cgns.inp"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/testcase/Delta_cgns
)
add_test(
NAME 3D_SEQ_DELTA_CGNS_RUN
COMMAND sh -c "$<TARGET_FILE:cfl3d_seq> < delta_cgns.inp"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/testcase/Delta_cgns
)
endif(USE_CGNS)
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,57 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.

------------
## About the CMake branch
As a practice of cmake, I had ported the make system of cfl3d to CMake, a modern industry-level build system. Which is much more easy to use, understand, modify and maintain.

Now the CMake branch has been merged into master, you can download the original `Intall and makefile build system` version using:
```shell
git clone --depth=1 --branch v6.7_gfortran_openmpi https://github.com/chengdi123000/cfl3d.git
```

### Compilation
```shell
## prerequirement (tested in Ubuntu 16.04)
sudo apt-get install libopenmpi-dev gfortran build-essential git cmake -y
# in RHEL/CentOS, you may try this:
# sudo yum install openmpi-devel gcc gcc-gfortran git cmake

## download
git clone https://git.coding.net/chengdi123000/CFL3D.git

## manually build cgns 2.5 without hdf5 and mpi
# you can also use your own cgns library if you put your cgnslib_f.h and libcgns.a in /usr/share/include and /usr/share/lib respectively
cd CFL3D/external/cgns
./build_cgns

## build cfl3d executables out of source
cd ../../build
cmake ..
make
# or you may benefit from parallel run, try:
# make -j`nproc`
# There will be a lot of warnings because I do not turn off all warnings as the original CFL3D build system do.
```

### Test
First set the PATH
```shell
## When completed, the executables will be in CFL3D/build/bin directory.
# suggest to use this line of script to add executables to PATH
# export PATH=$PWD/bin:$PATH
# You can use following line of script to add a command `use_cfl3d` to load executables ready to run after re-login
# echo "alias use_cfl3d='export PATH=$PWD/bin:\$PATH'">>$HOME/.bashrc
```
Then you need to download testcases
```shell
cd CFL3D/testcase
./download_testcases #wget is needed.
cd cfl3d.larc.nasa.gov/Cfl3dv6/2DTestcases/Flatplate
tar xvf Flatplate.tar.Z
# use_cfl3d
splitter < split.inp_1blk
cfl3d_seq < grdflat5.inp &
tail -f cfl3d.out #monitor the steps and residuals
```
Loading