forked from HPSCTerrSys/eCLM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
148 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,7 @@ docs/_build/* | |
*.py[cod] | ||
build | ||
bld | ||
|
||
*.a | ||
*.so | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gcc -c hello.c -o hello.o | ||
ar rcs libhello.a hello.o | ||
|
||
gcc -shared -o libhello.so -Wl,--whole-archive libhello.a -Wl,--no-whole-archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Save this as example.c | ||
int add(int a, int b) { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Define the function signature and call it | ||
lib = "./libhello.so" | ||
|
||
function add(a::Int32, b::Int32)::Int32 | ||
return ccall( | ||
(:add, lib), # Function and static library path | ||
Int32, # Return type | ||
(Int32, Int32), # Argument types | ||
a, b # Arguments | ||
) | ||
end | ||
|
||
# Call the function | ||
result = add(Int32(3), Int32(5)) | ||
println(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# using NCDatasets | ||
|
||
lib = "bld/clm5/libclm.so" | ||
# lib = "bld/clm5/libclm.a" | ||
# real(r8) function daylength(lat, decl) | ||
const FT = Cdouble | ||
|
||
daylength(lat::FT, decl::FT) = | ||
@ccall lib.__daylengthmod_MOD_daylength(lat::Ref{FT}, decl::Ref{FT})::FT | ||
|
||
lat = 20.0 |> deg2rad | ||
decl = 20.0 |> deg2rad | ||
|
||
@show daylength(lat, decl) | ||
|
||
## Fix curl error | ||
# > /home/kong/packages/julias/julia-1.10/bin/../lib/julia/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by /lib/x86_64-linux-gnu/libnetcdf.so.19) | ||
|
||
# /home/kong/packages/julias/julia-1.10/bin/../lib/julia/libcurl.so.4 -> libcurl.so.4.8.0 | ||
# ll /home/kong/packages/julias/julia-1.10/lib/julia/libcurl.so.4 | ||
|
||
# ln -sf /home/kong/packages/julias/julia-1.10/lib/julia/libcurl.so.4.8.0 /home/kong/packages/julias/julia-1.10/lib/julia/libcurl.so.4 | ||
# ln -sf /usr/lib/x86_64-linux-gnu/libcurl.so.4.7.0 /home/kong/packages/julias/julia-1.10/lib/julia/libcurl.so.4 | ||
|
||
|
||
## Julia | ||
# ln -sf libcurl.so.4.8.0 /home/kong/packages/julias/julia-1.10/lib/julia/libcurl.so.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## 之前版本 | ||
# export NETCDF=${HOME}/environment/netcdf | ||
# export PNDIR=${HOME}/environment/pnetcdf | ||
# export LD_LIBRARY_PATH="$NETCDF/lib:$PNDIR/lib" | ||
|
||
## github actions版本 | ||
export NETCDF="/opt/netcdf_v4.9.2_openmpi" | ||
export PNDIR="$NETCDF" | ||
export LD_LIBRARY_PATH="$NETCDF/lib" | ||
|
||
# export PATH=$NETCDF/bin:$PATH | ||
# export NETCDF=$NETCDF | ||
export NETCDF_C_PATH=$NETCDF | ||
export NETCDF_FORTRAN_PATH=$NETCDF | ||
export PNETCDF_PATH=$PNDIR | ||
|
||
|
||
export CFLAGS="-fPIC -shared" | ||
export FFLAGS="-fPIC -shared" | ||
|
||
# User-specific variables | ||
BUILD_DIR="bld" | ||
INSTALL_DIR="eclm" | ||
|
||
mkdir bld | ||
|
||
# Run cmake | ||
cmake -S src -B "$BUILD_DIR" \ | ||
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ | ||
-DCMAKE_C_COMPILER=mpicc \ | ||
-DCMAKE_Fortran_FLAGS="-fallow-argument-mismatch -fallow-invalid-boz -fPIC" \ | ||
-DCMAKE_Fortran_COMPILER=mpifort | ||
|
||
cd bld | ||
make -j8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ clean: | |
|
||
# DEPENDENCIES: | ||
|
||
$(OBJS_ALL): $(MCTPATH)/libmct.a | ||
$(OBJS_ALL): $(MCTPATH)/libmct.so | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ clean: | |
|
||
# DEPENDENCIES: | ||
|
||
$(OBJS_ALL): $(MCTPATH)/libmct.a | ||
$(OBJS_ALL): $(MCTPATH)/libmct.so | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ clean: | |
|
||
# DEPENDENCIES: | ||
|
||
$(OBJS_ALL): $(MCTPATH)/libmct.a | ||
$(OBJS_ALL): $(MCTPATH)/libmct.so | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,4 @@ clean: | |
|
||
# DEPENDENCIES: | ||
|
||
$(OBJS_ALL): $(MCTPATH)/libmct.a | ||
$(OBJS_ALL): $(MCTPATH)/libmct.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.