Skip to content

Commit 3fbe0c5

Browse files
authored
Merge pull request #175 from gaelforget/v0p5p15b
V0p5p15b
2 parents d81e816 + d169963 commit 3fbe0c5

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MITgcm"
22
uuid = "dce5fa8e-68ce-4431-a242-9469c69627a0"
33
authors = ["gaelforget <gforget@mit.edu>"]
4-
version = "0.5.14"
4+
version = "0.5.15"
55

66
[deps]
77
ClimateModels = "f6adb021-9183-4f40-84dc-8cea6f651bb0"

lib/build_mitgcm_lib.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,24 @@ if ! grep -q '_BYTESWAPIO' "$BUILD_DIR/Makefile" 2>/dev/null; then
132132
make depend 2>&1 | tail -3
133133
fi
134134

135-
echo " Compiling MITgcm..."
136-
make -j$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4) 2>&1 | tail -5
135+
# For shared library mode, compile everything with -fPIC
136+
echo " Compiling MITgcm with -fPIC for shared library..."
137+
138+
# Clean previous builds to force recompilation with new flags
139+
make clean 2>&1 | tail -2
140+
make depend 2>&1 | tail -3
141+
142+
# Build with -fPIC appended to all compiler flags
143+
# Extract existing flags first
144+
EXISTING_FFLAGS=$(grep '^FFLAGS = ' "$BUILD_DIR/Makefile" | sed 's/^FFLAGS = //' | head -1)
145+
EXISTING_FOPTIM=$(grep '^FOPTIM = ' "$BUILD_DIR/Makefile" | sed 's/^FOPTIM = //' | head -1)
146+
EXISTING_CFLAGS=$(grep '^CFLAGS = ' "$BUILD_DIR/Makefile" | sed 's/^CFLAGS = //' | head -1)
147+
148+
make -j$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4) \
149+
FFLAGS="${EXISTING_FFLAGS} -fPIC" \
150+
FOPTIM="${EXISTING_FOPTIM} -fPIC" \
151+
CFLAGS="${EXISTING_CFLAGS} -fPIC" \
152+
2>&1 | tail -5
137153

138154
echo " MITgcm build complete."
139155
echo ""
@@ -216,6 +232,15 @@ else
216232
done
217233
fi
218234

235+
echo ">> $FC"
236+
echo ">> $SHLIB_FLAGS"
237+
echo ">> $OUTPUT_DIR"
238+
echo ">> $OBJ_FILES"
239+
echo ">> $SHLIB_NAME"
240+
echo ">> $LIBS"
241+
242+
#echo "$FC $SHLIB_FLAGS -o $OUTPUT_DIR/$SHLIB_NAME $OBJ_FILES $LIBS"
243+
219244
$FC $SHLIB_FLAGS -o "$OUTPUT_DIR/$SHLIB_NAME" $OBJ_FILES $LIBS
220245

221246
echo " Created: $OUTPUT_DIR/$SHLIB_NAME"

src/MITgcmBuild.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Scratch
2+
using MITgcm.ClimateModels.Suppressor
23

34
const MITGCM_GIT_URL = "https://github.com/MITgcm/MITgcm.git"
45
const MITGCM_DEFAULT_CHECKOUT = "checkpoint69j"
@@ -63,7 +64,8 @@ Returns a NamedTuple `(library_path, run_dir)`.
6364
function build_mitgcm_library(mitgcm_dir::String;
6465
output_dir::String = mktempdir(),
6566
code_dir::String = default_code_dir(mitgcm_dir),
66-
input_dir::String = default_input_dir(mitgcm_dir))
67+
input_dir::String = default_input_dir(mitgcm_dir),
68+
verbose=false)
6769

6870
mitgcm_dir = abspath(mitgcm_dir)
6971
output_dir = abspath(output_dir)
@@ -94,7 +96,11 @@ function build_mitgcm_library(mitgcm_dir::String;
9496

9597
cmd = `bash $build_script $mitgcm_dir $output_dir $code_dir $input_dir $wrapper_src`
9698
@info "Building MITgcm shared library..." output_dir code_dir input_dir
97-
run(cmd)
99+
if verbose
100+
run(cmd)
101+
else
102+
@suppress run(cmd)
103+
end
98104

99105
lib_name = Sys.isapple() ? "libmitgcm.dylib" : "libmitgcm.so"
100106
library_path = joinpath(output_dir, lib_name)

test/test_mitgcm_library.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ else
2323

2424
@testset "build_mitgcm_library" begin
2525
result = MITgcm.build_mitgcm_library(mitgcm_dir;
26-
output_dir, code_dir, input_dir)
26+
output_dir, code_dir, input_dir, verbose=false)
2727
@test isfile(result.library_path)
2828
@test isdir(result.run_dir)
2929
end
@@ -206,8 +206,8 @@ else
206206
@test any(ocean.salt .!= 0)
207207

208208
# Physical constants
209-
@test ocean.ρ₀ > 0
210-
@test ocean.cₚ > 0
209+
@test ocean.reference_density > 0
210+
@test ocean.heat_capacity > 0
211211

212212
# eltype
213213
@test eltype(ocean) == Float64

0 commit comments

Comments
 (0)