Skip to content

Commit d416bde

Browse files
committed
Merge branch 'mnlevy1981-cmake_updates'
2 parents 3019c4e + 04cc49f commit d416bde

8 files changed

Lines changed: 49 additions & 25 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ python:
1414
script:
1515
- cd bld; ./cvmix_setup gfortran $(dirname $(dirname $(which nc-config)))
1616
- cd ../CVMix_tools; ./run_test_suite.sh --already-ran-setup
17+
- cd ../reg_tests/Bryan-Lewis/; ./Bryan-Lewis-test.sh --cmake
1718

1819
branches:
1920
only:

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required( VERSION 3.10 )
1+
cmake_minimum_required( VERSION 3.9 )
22

33
project( cvmix VERSION 4.0.1 LANGUAGES Fortran )
44

@@ -42,8 +42,8 @@ add_subdirectory( src )
4242
# Note - KB:
4343
# Building static and shared libs require an ugly construct to build on both
4444
# Windows and Linux. Windows will not create the libraries unless a Fortran
45-
# file is explicitly given - and Linux complains (I think due to a race
46-
# condition) if it is. Therefor the construct below - a proper solution is
45+
# file is explicitly given - and Linux complains (I think due to a race
46+
# condition) if it is. Therefor the construct below - a proper solution is
4747
# most welcome.
4848

4949
# Add static lib target

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ INSTALLATION NOTES
3838
------------------
3939

4040
CVMix can be installed using two different methods. The original uses Make
41-
and a set of Makefiles. The new method uses CMake and two CMakelists.txt
41+
and a set of Makefiles. The new method uses CMake and two CMakelists.txt
4242
files.
4343

4444
#### Building/installing using Make
@@ -72,42 +72,39 @@ to configure and compile CVMix. Note that CVMix has been build on Windows using
7272
VisualStudio and the Intel Fortran compiler but NetCDF support has not been
7373
tested.
7474

75-
In this recipe CVMIX\_BASE is a convinient environmental variable pointing to
76-
the CVMix source directory. It is possible to execute the following commands
77-
providing the full path.
78-
79-
80-
1. mkdir ~/build/cvmix
81-
* [CMake](https://cmake.org/) promotes out of source compilation
82-
2. cd ~/build/cvmix
83-
3. cmake $CVMIX\_BASE
75+
1. cd $CVMix/bld/cmake_bld
76+
* [CMake](https://cmake.org/) promotes out of source compilation,
77+
any such directory will do.
78+
2. cmake $CVMix
8479
* The simplest configuration - using default Fortran compiler
85-
4. cmake $CVMIX\_BASE -DCMAKE\_Fortran\_COMPILER=ifort
80+
3. cmake $CVMix -DCMAKE\_Fortran\_COMPILER=ifort
8681
* Specifying a Fortran compiler
87-
5. cmake $CVMIX\_BASE -DCVMIX\_BUILD\_DRIVER=on
82+
4. cmake $CVMix -DCVMIX\_BUILD\_DRIVER=on
8883
* Build the CVMix driver program - off by default
89-
6. cmake $CVMIX\_BASE -DCVMIX\_BUILD\_DRIVER=on CVMIX\_USE\_NetCDF=on
84+
5. cmake $CVMix -DCVMIX\_BUILD\_DRIVER=on CVMIX\_USE\_NetCDF=on
9085
* Include support for NetCDF in the driver model(1)
9186
* Note that this requires proper configuration of the installed NetCDF library.
9287
* Setting NetCDF\_INCLUDE and NetCDF\_LIBRARIES might help.
93-
7. cmake $CVMIX\_BASE -DCMAKE\_INSTALL\_PREFIX=~/local
94-
* Providing an installation folder
88+
6. cmake $CVMix -DCMAKE\_INSTALL\_PREFIX=$CVMix/bin
89+
* Providing an installation folder (again, any such directory will do)
9590

9691
Combination of the above commands is possible.
9792

9893
After configuration has been done compilation is as simple as:
94+
9995
```
10096
make
10197
```
10298

10399
and installation by:
100+
104101
```
105102
make install
106103
```
107104

108105
After installation the build directory can be removed.
109106

110-
The support for CMake builds provides sufficient infrastructure for CVMix
107+
The support for CMake builds provides sufficient infrastructure for CVMix
111108
being included in ocean models using the GIT submodule feature. This has
112109
been used in the [GOTM](https:/gotm.net) inclusion of the CVMix mixing
113110
models as a supplement to the original turbulence models in GOTM.
@@ -120,7 +117,7 @@ DIRECTORY STRUCTURE
120117
bin/ -- Default location for the cvmix executable.
121118

122119
bld/ -- Contains auxiliary files needed by the build system. CompileFlags.mak
123-
has default compile flags for 5 different compilers -- gfortran,
120+
has default compile flags for 5 different compilers -- gfortran,
124121
pgf90, ifort, xlf90, and nagfor, as well as ftn (the Cray wrapper for
125122
pgf90). At this time, no other compilers are supported on Cray systems.
126123
cvmix_setup is a python script that saves information about what
@@ -234,7 +231,7 @@ src/ -- Contains the source code, organized as follows. The top directory
234231

235232
src/drivers/ -- Subroutines called by the driver (one per test).
236233

237-
src/shared/ -- Where all the modules that are needed to use CVMix with an
234+
src/shared/ -- Where all the modules that are needed to use CVMix with an
238235
outside model are stored. Also contains the Makefile used to
239236
build the libcvmix.a library.
240237

bld/cmake_bld/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

cmake_bin/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin
2+
include
3+
lib
4+
cmake

reg_tests/common/build.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22

33
build () {
44
if [ -z ${NO_BUILD} ]; then
5-
make -f $CVMix/src/Makefile CVMIX_ROOT=$CVMix ${USE_NETCDF}
6-
if [ $? != 0 ]; then
5+
if [ "${CMAKE_BUILD}" == "TRUE" ]; then
6+
CWD=$PWD
7+
cd $CVMix/bld/cmake_bld
8+
cmake $CVMix -DCVMIX_BUILD_DRIVER=on \
9+
-DCMAKE_Fortran_COMPILER=gfortran \
10+
-DCMAKE_INSTALL_PREFIX=$CVMix/cmake_bin \
11+
&& make && make install
12+
STATUS=$?
13+
cd $CWD
14+
else
15+
make -f $CVMix/src/Makefile CVMIX_ROOT=$CVMix ${USE_NETCDF}
16+
STATUS=$?
17+
fi
18+
if [ $STATUS != 0 ]; then
719
echo "Build error!"
820
exit 2
921
fi
@@ -12,7 +24,7 @@ build () {
1224
if [ "`cat ../../bld/.netcdf_info`" == "YES" ]; then
1325
USE_NETCDF=netcdf
1426
fi
15-
fi
27+
fi
1628
fi
1729

1830
}

reg_tests/common/parse_inputs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ while [ $# -gt 0 ]; do
4343
bad_input $1
4444
fi
4545
;;
46+
-cm|--cmake)
47+
CMAKE_BUILD=TRUE
48+
;;
4649
* )
4750
bad_input $1
4851
;;

reg_tests/common/run.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
run () {
44

5-
$CVMix/bin/cvmix < $NAMELIST
5+
if [ "${CMAKE_BUILD}" == "TRUE" ]; then
6+
CVMIX_EXE=$CVMix/cmake_bin/bin/cvmix_driver
7+
else
8+
CVMIX_EXE=$CVMix/bin/cvmix
9+
fi
10+
${CVMIX_EXE} < $NAMELIST
611

712
if [ $? != 0 ]; then
813
echo "Error in execution!"

0 commit comments

Comments
 (0)