Skip to content

Commit 9f04c0f

Browse files
Mac build (#46)
1 parent 6ca0575 commit 9f04c0f

26 files changed

+763
-83
lines changed

.github/scripts/_typos.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ thi = "thi"
1616
doub = "doub"
1717
Doub = "Doub"
1818
Numer = "Numer"
19-
thr = "thr"
19+
thr = "thr"
20+
nd = "nd"

.github/workflows/ice.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
module load gcc/12.3.0 mvapich2/2.3.7-1 netcdf-c hdf5/1.14.1-2-mva2 intel-oneapi-mkl/2023.1.0 python/3.10.10 fftw/3.3.10-mva2 cmake
2929
set -e -x
30-
export PETSC_DIR=`pwd`/packages/petsc-3.19.6
30+
export PETSC_DIR=`pwd`/packages/petsc-3.21.3
3131
export PETSC_ARCH=arch-linux-c-opt
3232
mkdir build
3333
cd build

.github/workflows/mac.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'Test on MacOS'
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
self:
10+
name: Mac Runner
11+
runs-on: macos-latest
12+
continue-on-error: true
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Build Packages
18+
run: |
19+
set -x
20+
brew install gcc mpich gfortran pkg-config
21+
ln -s /opt/homebrew/bin/gfortran-14 /usr/local/bin/gfortran
22+
./rbc.sh install-mac
23+
24+
- name: Compile Cases
25+
run: |
26+
set -e -x
27+
export PETSC_DIR=`pwd`/packages/petsc-3.21.3
28+
export PETSC_ARCH=arch-darwin-c-opt
29+
mkdir build
30+
cd build
31+
cmake ..
32+
make
33+
echo "/common and all cases in /examples compiled successfully!"
34+

.github/workflows/phoenix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
module load gcc/12.1.0-qgxpzk mvapich2/2.3.7-733lcv netcdf-fortran cmake
3030
set -e -x
3131
export FFTWROOT=`pwd`/packages/fftw-3.3.10/build
32-
export PETSC_DIR=`pwd`/packages/petsc-3.19.6
32+
export PETSC_DIR=`pwd`/packages/petsc-3.21.3
3333
export PETSC_ARCH=arch-linux-c-opt
3434
cd common
3535
make .depend
@@ -43,7 +43,7 @@ jobs:
4343
run: |
4444
module load gcc/12.1.0-qgxpzk mvapich2/2.3.7-733lcv netcdf-fortran cmake
4545
set -e -x
46-
export PETSC_DIR=`pwd`/packages/petsc-3.19.6
46+
export PETSC_DIR=`pwd`/packages/petsc-3.21.3
4747
export PETSC_ARCH=arch-linux-c-opt
4848
mkdir build
4949
cd build

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ if (NOT DEFINED ENV{PETSC_ARCH})
3737
else ()
3838
# full path if PETSC_DIR and PETSC_ARCH env variables are set
3939
set(PETSC $ENV{PETSC_DIR}/$ENV{PETSC_ARCH})
40+
if ("$ENV{PETSC_ARCH}" STREQUAL "arch-darwin-c-opt")
41+
set(MAC on)
42+
elseif("$ENV{PETSC_ARCH}" STREQUAL "arch-linux-c-opt")
43+
set(LINUX on)
44+
else ()
45+
message(FATAL_ERROR "PETSC_ARCH $ENV{PETSC_ARCH} not recognized. Please add support in CMakeLists.txt")
46+
endif()
47+
4048
endif()
4149

4250
set(ENV{PKG_CONFIG_PATH} ${PETSC}/lib/pkgconfig)
@@ -51,7 +59,14 @@ if (FORTRAN_COMPILER)
5159
set(CMAKE_Fortran_COMPILER ${FORTRAN_COMPILER})
5260
# same compile options as Makefile.in
5361
add_compile_options(-fallow-argument-mismatch -freal-4-real-8 -O3)
54-
add_link_options(-ldl -lstdc++ -Wl,--copy-dt-needed-entries)
62+
add_link_options(-ldl -lstdc++)
63+
if (LINUX)
64+
# ice cluster install needs this extra link option
65+
add_link_options(-Wl,--copy-dt-needed-entries)
66+
elseif(MAC)
67+
# might be able to remove this if homebrew fixes bug
68+
add_link_options(-Wl,-no_warn_duplicate_libraries)
69+
endif()
5570
else ()
5671
message(FATAL_ERROR "PETSc Fortran compiler not found. Please ensure PETSc was configured with a Fortran compiler.")
5772
endif (FORTRAN_COMPILER)
@@ -85,11 +100,11 @@ endif(LAPACK_FOUND)
85100
if (DEFINED ENV{FFTWROOT})
86101
set(FFTW_INCLUDE "$ENV{FFTWROOT}/include")
87102
set(FFTW_LIB "-L$ENV{FFTWROOT}/lib -lfftw3")
88-
elseif(DEFINED ENV{FFTWROOT})
103+
elseif(DEFINED ENV{FFTW_ROOT})
89104
set(FFTW_INCLUDE "$ENV{FFTW_ROOT}/include")
90105
set(FFTW_LIB "-L$ENV{FFTW_ROOT}/lib -lfftw3")
91106
else ()
92-
message(WARNING "FFTWROOT and FFTW_ROOT environment variables from module load fftw not found. Assuming you installed FFTW in packages.")
107+
message(STATUS "FFTWROOT and FFTW_ROOT environment variables from module load fftw not found. Assuming you installed FFTW in packages.")
93108
set(FFTW_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/packages/fftw-3.3.10/build/include")
94109
set(FFTW_LIB "-L${CMAKE_CURRENT_SOURCE_DIR}/packages/fftw-3.3.10/build/lib -lfftw3")
95110
endif()
@@ -102,7 +117,7 @@ elseif (DEFINED ENV{NETCDF_FORTRAN_ROOT})
102117
set(NETCDF_INCLUDE "$ENV{NETCDF_FORTRAN_ROOT}/include")
103118
set(NETCDF_LIB "-L$ENV{NETCDF_FORTRAN_ROOT}/lib -lnetcdff")
104119
else ()
105-
message(WARNING "NETCDF_FORTRANROOT and NETCDF_FORTRAN_ROOT environment variables from module load fftw not found. Assuming you installed NETCDF-FORTRAN in packages.")
120+
message(STATUS "NETCDF_FORTRANROOT and NETCDF_FORTRAN_ROOT environment variables from module load fftw not found. Assuming you installed NETCDF-FORTRAN in packages.")
106121
set(NETCDF_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/packages/NETCDF_INST/include")
107122
# -rpath linker option to avoid having to add netcdf library to LD_LIBRARY_PATH
108123
set(NETCDF_LIB "-Wl,-rpath -Wl,${CMAKE_CURRENT_SOURCE_DIR}/packages/NETCDF_INST/lib -L${CMAKE_CURRENT_SOURCE_DIR}/packages/NETCDF_INST/lib -lnetcdff")

Makefile.in

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
WORK_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
33

44
# Package directories (shouldn't need to change these)
5-
PETSC_DIR = $(WORK_DIR)/packages/petsc-3.19.6
5+
PETSC_DIR = $(WORK_DIR)/packages/petsc-3.21.3
66
PETSC_ARCH = $(PETSC_DIR)/arch-linux-c-opt
77

88
SPHEREPACK_DIR = $(WORK_DIR)/packages/spherepack3.2
99

1010
LAPACK_DIR = $(WORK_DIR)/packages/lapack-3.11
11-
# if netcdf-fortran is manually installed then this will need to be set instead
11+
# if netcdf-fortran is manually installed, uncomment line below and comment the other one
1212
# NETCDF_DIR = $(WORK_DIR)/packages/NETCDF_INST
1313
NETCDF_DIR = $(NETCDF_FORTRANROOT)
14+
# if fftw is manually installed, use this instead
15+
# FFTW_DIR = $(WORK_DIR)/packages/fftw-3.3.10/build
16+
FFTW_DIR = $(FFTWROOT)
1417

1518
# Makedependf90 binary
1619
MAKEDEPEND_BIN = $(WORK_DIR)/packages/makedepf90/makedepf90
@@ -24,16 +27,16 @@ NETCDF_INCLUDE = $(NETCDF_DIR)/include
2427
# If you installed FFTW in packages through install/install-phoenix.sh
2528
# run: export FFTWROOT=`pwd`/packages/fftw-3.3.10/build from RBC3D root directory in terminal
2629
# or make a variable in this file
27-
FFTW_INCLUDE = $(FFTWROOT)/include
30+
FFTW_INCLUDE = $(FFTW_DIR)/include
2831

2932
COMMON_INCLUDE = -I$(WORK_DIR)/common
30-
# you can remove -I$(FFTW_INCLUDE) if you module loaded fftw
33+
# you can remove -I$(FFTW_DIR) if you module loaded fftw
3134
INCLUDE = $(COMMON_INCLUDE) -I$(PETSC_INCLUDE) -I$(PETSC_ARCH_INCLUDE) -I$(NETCDF_INCLUDE) -I$(FFTW_INCLUDE)
3235

3336
# Libraries
3437
COMMON_LIB = $(WORK_DIR)/common/libcommon.a
3538
SPHPK_LIB = -L$(SPHEREPACK_DIR)/lib -lspherepack
36-
FFTW_LIB = -L$(FFTWROOT)/lib -lfftw3
39+
FFTW_LIB = -L$(FFTW_DIR)/lib -lfftw3
3740
NETCDF_LIB = -L$(NETCDF_DIR)/lib -lnetcdff
3841
PETSC_LIB = -Wl,-rpath,$(PETSC_ARCH)/lib -L$(PETSC_ARCH)/lib -lpetsc -lstdc++
3942
MKL_LIB = -L$(MKL_ROOT)lib/intel64/ -lmkl_gf_lp64 -lmkl_core -lmkl_sequential -lpthread -lm -ldl

README.md

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,41 @@ This codebase solves the boundary integral form of the Stokes equations via an a
2323

2424
### Installation
2525

26-
<p align="left">
27-
<a href="https://github.com/comp-physics/RBC3D/actions/workflows/phoenix.yml">
28-
<img src="https://github.com/comp-physics/RBC3D/actions/workflows/phoenix.yml/badge.svg" />
29-
</a>
30-
<a href="https://github.com/comp-physics/RBC3D/actions/workflows/ice.yml">
31-
<img src="https://github.com/comp-physics/RBC3D/actions/workflows/ice.yml/badge.svg" />
32-
</a>
33-
</p>
34-
35-
To install on PACE Phoenix, you need to salloc a node to make sure `srun` is available and then run this in the RBC3D root directory:
36-
37-
```shell
38-
module load gcc/12.1.0-qgxpzk mvapich2/2.3.7-733lcv python/3.9.12-rkxvr6 netcdf-fortran cmake
39-
./rbc.sh install-phoenix
40-
```
26+
To install on a mac from the cloned repository, you can
4127

42-
Note that if the `gcc`, `mvapich2`, `mkl`, and `fftw` modules work on your Phoenix account, you should use this installer script for a faster build.
4328
```shell
44-
module load gcc mvapich2 mkl python/3.9.12-rkxvr6 netcdf-fortran fftw cmake
45-
./rbc.sh install
29+
brew install gcc mpich gfortran pkg-config wget cmake
30+
./rbc.sh install-mac
4631
```
4732

48-
Or if you're on the ICE cluster, you just need to load different modules to run the installer script.
33+
and then set these environment variables in your `~/.zshrc` or `~/.bashrc`. Note that `$HOME` will need to be replaced with the folder you cloned RBC3D in.
4934

50-
```shell
51-
module load gcc/12.3.0 mvapich2/2.3.7-1 netcdf-c hdf5/1.14.1-2-mva2 intel-oneapi-mkl/2023.1.0 python/3.10.10 fftw/3.3.10-mva2 cmake
52-
./rbc.sh install-ice
53-
```
54-
55-
Before you can run cmake, you must set these environment variables. You can place them in your `~/.bashrc`. If you didn't place `RBC3D` in your `$HOME` directory, then replace it with where you placed `RBC3D`.
5635
```shell
5736
export PETSC_DIR=$HOME/RBC3D/packages/petsc-3.19.6
58-
export PETSC_ARCH=arch-linux-c-opt
37+
export PETSC_ARCH=arch-darwin-c-opt
5938
```
6039

6140
Then to execute and run a case, you can:
6241
```shell
6342
mkdir build
6443
cd build
6544
cmake ..
66-
make case # or just `make` to make common and all the cases
67-
cd case
68-
srun -n 1 ./initcond # or mpiexec
69-
srun ./tube
45+
make -j 8 minicase # or just `make` to make common and all the cases
46+
cd minicase
47+
mpiexec -n 1 ./minit
48+
mpiexec -n 2 ./mtube # number of nodes can be changed
49+
```
50+
51+
This will generate output files in `build/minicase/D`. To keep output files in `examples/minicase/D` and use input files in `examples/minicase/Input`, you can do this instead once files are built in the `build` directory:
52+
53+
```shell
54+
cd examples/case
55+
mpiexec -n 1 ../../build/case/minit
56+
mpiexec -n 2 ../../build/case/mtube
7057
```
7158

72-
This will generate output files in `build/case/D`. To keep output files in `examples/case/D`, you can `cd examples/case` and `srun ../../build/case/initcond` and same for tube.
59+
To run a case with more cells and nodes, you should use a supercomputing cluster. Instructions on how to build RBC3D on a cluster are [available here](https://github.com/comp-physics/RBC3D/blob/master/install/readme.md).
7360

74-
On other supercomputing clusters, it should be easy to replace the module loads with the modules available on your system. If one of these isn't available, you can follow the manual build instructions [available here](https://github.com/comp-physics/RBC3D/blob/master/install/readme.md).
7561

7662
### Papers that use RBC3D
7763

common/ModConf.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ subroutine InitMPI(split_comm)
139139
print *, 'Node ', i, ' of ', numNodes, ' running on ', trim(machinename)
140140
end do ! i
141141
else
142-
call MPI_Send(lenname, 1, MPI_Integer, 0, 1, MPI_Comm_World, stat, ierr)
143-
call MPI_Send(machinename, lenname, MPI_Character, 0, 1, MPI_Comm_World, stat, ierr)
142+
call MPI_Send(lenname, 1, MPI_Integer, 0, 1, MPI_Comm_World, ierr)
143+
call MPI_Send(machinename, lenname, MPI_Character, 0, 1, MPI_Comm_World, ierr)
144144
end if
145145
call MPI_Barrier(MPI_COMM_WORLD, ierr)
146146

common/ModIO.F90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ subroutine IO_Init
4545

4646
if (rootWorld) then
4747
if (pgrad_out > 0) then
48-
write (fn, FMT=fn_FMT), 'D/', 'pgrad', Nt0, '.dat'
48+
write (fn, FMT=fn_FMT) 'D/', 'pgrad', Nt0, '.dat'
4949
open (pGrad_unit, file=trim(fn), action='write')
5050
end if
5151

5252
if (flow_out > 0) then
53-
write (fn, FMT=fn_FMT), 'D/', 'flow', Nt0, '.dat'
53+
write (fn, FMT=fn_FMT) 'D/', 'flow', Nt0, '.dat'
5454
open (flow_unit, file=trim(fn), action='write')
5555
end if
5656

5757
if (ftot_out > 0) then
58-
write (fn, FMT=fn_FMT), 'D/', 'ftot', Nt0, '.dat'
58+
write (fn, FMT=fn_FMT) 'D/', 'ftot', Nt0, '.dat'
5959
open (ftot_unit, file=trim(fn), action='write')
6060
end if
6161

@@ -553,6 +553,8 @@ subroutine ReadWallMesh(fn, wall)
553553
integer, allocatable :: connect(:, :)
554554
character(*), parameter :: func_name = "ReadWallMesh"
555555

556+
print *, "fn: ", trim(fn)
557+
556558
! Check whether the file exists
557559
ierr = NF90_OPEN(trim(fn), NF90_NOWRITE, ncid)
558560
if (ierr .ne. 0) then
@@ -824,22 +826,21 @@ subroutine ReadRestart(fn)
824826
write (*, *) 'vBkg = ', vBkg
825827
end if
826828

827-
print *, '1'
828829
call MPI_Bcast(Lb, 3, MPI_WP, 0, MPI_Comm_World, ierr)
829830
call MPI_Bcast(iLb, 3, MPI_WP, 0, MPI_Comm_World, ierr)
830831

831832
call MPI_Bcast(Nt0, 1, MPI_INTEGER, 0, MPI_Comm_World, ierr)
832833
call MPI_Bcast(time0, 1, MPI_WP, 0, MPI_Comm_World, ierr)
833834
call MPI_Bcast(vBkg, 3, MPI_WP, 0, MPI_Comm_World, ierr)
834-
print *, '2'
835+
835836
! cells
836837
if (rootWorld) then
837838
read (restart_unit) nrbc
838839

839840
write (*, *) 'nrbc = ', nrbc
840841
end if
841842
call MPI_Bcast(nrbc, 1, MPI_Integer, 0, MPI_Comm_World, ierr)
842-
print *, '3'
843+
843844
allocate (rbcs(nrbc))
844845

845846
do irbc = 1, nrbc
@@ -848,7 +849,6 @@ subroutine ReadRestart(fn)
848849
if (rootWorld) then
849850
read (restart_unit) nlat0, nlon0
850851
read (restart_unit) nlat, nlon
851-
! celltype = 1; print *,"NO READ CELL TYPE"
852852
read (restart_unit) celltype
853853
read (restart_unit) starting_area
854854
write (*, *) 'irbc : ', irbc, ' nlat0 = ', nlat0, 'type = ', celltype, 'starting_area = ', starting_area
@@ -888,7 +888,7 @@ subroutine ReadRestart(fn)
888888
end if
889889
call MPI_Bcast(rbc%x, size(rbc%x), MPI_WP, 0, MPI_Comm_World, ierr)
890890
end do ! irbc
891-
print *, '4'
891+
892892
! Walls
893893
if (rootWorld) then
894894
read (restart_unit) nwall

common/ModRbc.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ subroutine RBC_MakeSickle(cell, rad, xc)
229229
type(t_RBC) :: cell
230230
real(WP), optional :: xc(3)
231231

232-
integer :: ilat, ilon, ii
232+
integer :: ilat, ilon, ii, ierr
233233
real(WP) :: th, phi, r_u, r_l, r, p, rad
234234

235235
real(WP), dimension(0:5) :: a_l, a_u
236236
real(WP), dimension(2) :: b
237237

238238
print *, "The RBC_MakeSickle Cell Configuration is Not Confirmed Working Yet - Aborting"
239-
call MPI_Abort(MPI_COMM_WORLD, 1, 1)
239+
call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
240240

241241
a_u = (/1.36, -0.0403, 0.306, -0.00169, -0.0360, -0.0277/)
242242
a_l = (/-0.806, -0.1141, -0.00678, 0.00212, 0.0201, 0.0284/)

common/ModTimeInt.F90

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ subroutine TimeInt_Init
6464
! call RBC_ComputeGeometry(rbcRef) JBF: not needed???
6565
rbcRefs(1)%patch => rbcPatch
6666
rbcRefs(2)%patch => rbcPatch
67-
! rbcRefs(3)%patch => rbcPatch
67+
rbcRefs(3)%patch => rbcPatch
6868

6969
if (PhysEwald) then
7070
do irbc = 1, nrbc
@@ -122,11 +122,9 @@ subroutine TimeInt_Euler
122122
clockBgn = MPI_WTime() ! Start timing
123123

124124
! Evolve cells
125-
! print *,"NO VEL"
126125
call Compute_Rbc_Vel
127126

128127
! Enforce no-slip condition on the wall
129-
! print *,"NO NO SLIP"
130128
call NoSlipWall
131129

132130
! Evolve RBC
@@ -140,8 +138,6 @@ subroutine TimeInt_Euler
140138
! call FilterRbcs
141139
call ReboxRbcs
142140

143-
! print *,"MULTIVOL"
144-
145141
! call AddR0Motion
146142

147143
! call LeukWallRepulsion
@@ -954,7 +950,7 @@ subroutine VolConstrainRbcs
954950
fac = (rbcRefs(rbc%celltype)%vol - rbc%vol)/rbc%area
955951
fac = SIGN(MIN(ABS(fac), epsDist/20.), fac)
956952
if (rootWorld .and. ABS(fac) .gt. epsDist/40.) then
957-
print *, "VOL: ", rbcRefs(rbc%celltype)%vol, rbc%vol, fac
953+
print *, "VOL: ", rbc%celltype, rbcRefs(rbc%celltype)%vol, rbc%vol, fac
958954
end if
959955
do ilat = 1, rbc%nlat
960956
do ilon = 1, rbc%nlon

examples/case/Input/tube.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
10000 ! Nt
1515
0.0014 ! Ts
1616

17-
100 ! cell_out
17+
50 ! cell_out
1818
-10000 ! wall_out
1919
-10 ! pGrad_out
2020
-10 ! flow_out

examples/minicase/D/.gittouch

Whitespace-only changes.
85.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)