Skip to content

Commit 266aa04

Browse files
authored
Merge pull request #410 from mpaiao/mpaiao-pr-lapack
Replace built-in linear system solver with LAPACK
2 parents 0624b70 + 9aa50c9 commit 266aa04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+909
-755
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616
- name: Install dependencies
17-
run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev
17+
run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev libblas-dev liblapack-dev
1818
- name: Install ED2
1919
run: |
2020
cd ED/build
@@ -43,7 +43,7 @@ jobs:
4343
with:
4444
name: ed2-binary
4545
- name: Install dependencies
46-
run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev
46+
run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev libblas-dev liblapack-dev
4747
- name: Run ED2
4848
working-directory: ./EDTS/
4949
run: |

BRAMS/build/bin/Makefile

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

2424

2525
#----- Compiler commands. -----------------------------------------------------------------#
26-
INCLUDES = $(PAR_INCS) -I$(UTILS_INCS) $(HDF5_INCS) $(MPI_INCS)
26+
INCLUDES = $(PAR_INCS) -I$(UTILS_INCS) $(HDF5_INCS) $(MPI_INCS) $(LAPACK_INCS)
2727
F90_COMMAND = $(F_COMP) -c $(F_OPTS) $(INCLUDES) $(PAR_DEFS)
2828
F90_LOWO_COMMAND = $(F_COMP) -c $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS)
2929
FPP_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \
@@ -63,7 +63,7 @@ gendep:
6363
$(EXE): $(LIBMODEL) $(MAINOBJ)
6464
@echo ""
6565
$(LOADER) -o $(EXE) rammain.o $(LOADER_OPTS) $(LIBMODEL) \
66-
$(HDF4_LIBS) $(HDF5_LIBS) $(PAR_LIBS) $(NC_LIBS) $(LIBS)
66+
$(HDF4_LIBS) $(HDF5_LIBS) $(PAR_LIBS) $(LAPACK_LIBS) $(NC_LIBS) $(LIBS)
6767
@echo ""
6868
@echo Finished building === $(EXE)
6969
@echo ""

BRAMS/build/bin/include.mk.opt.32intel

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ HDF5_LIBS=-L/n/Moorcroft_Lab/Users/mlongo/util/hdflib/hdf5_32/hdf5/lib \
5454
# may benefit from collective I/O, then use this flag = 1
5555
# Otherwise, set it to zero.
5656

57+
58+
#------------------------------------------------------------------------------------------#
59+
# Linear Algebra Package (LAPACK) libraries. #
60+
# #
61+
# Lapack is a well-established package for solving linear systems in Fortran. This is #
62+
# more efficient than the former built-in solution, and thus it became the new default. #
63+
# #
64+
# For those compiling the code with Intel compilers (ifort/icc), leave these empty and #
65+
# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on #
66+
# the ifort/icc version). Otherwise, provide the path to Lapack installation. #
67+
#------------------------------------------------------------------------------------------#
68+
LAPACK_PATH=
69+
LAPACK_INCS=
70+
LAPACK_LIBS=
71+
#------------------------------------------------------------------------------------------#
72+
5773
USE_COLLECTIVE_MPIO=0
5874

5975
#---------------------------------------------------------------
@@ -222,11 +238,11 @@ MOD_EXT=mod
222238
# face problems. If it successfully compiles, then you can switch to B. #
223239
#------------------------------------------------------------------------------------------#
224240
#USE_INTERF=0
225-
#F_OPTS= -FR -O0 -recursive -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \
241+
#F_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \
226242
-warn interfaces -debug extended -debug inline_debug_info -debug-parameters all \
227243
-traceback -ftrapuv -fp-stack-check -implicitnone -openmp -static
228244
#C_OPTS= -O0 -DLITTLE -g -traceback -debug extended -static
229-
#LOADER_OPTS= -FR -O0 -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \
245+
#LOADER_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \
230246
-warn interfaces -debug extended -debug inline_debug_info \
231247
-debug-parameters all -traceback -ftrapuv -fp-stack-check -implicitnone -openmp -static
232248
#C_LOADER_OPTS=-v -g -traceback
@@ -241,13 +257,13 @@ MOD_EXT=mod
241257
# Note, however, that if you change arguments you should first try A. #
242258
#------------------------------------------------------------------------------------------#
243259
USE_INTERF=1
244-
F_OPTS= -FR -O0 -recursive -Vaxlib -check all -g -fpe0 -ftz -debug extended \
260+
F_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -debug extended \
245261
-debug inline_debug_info -static -debug-parameters all -traceback -ftrapuv \
246262
-fp-stack-check -implicitnone -openmp
247263
C_OPTS= -O0 -DLITTLE -g -traceback -debug extended -static
248-
LOADER_OPTS= -FR -O0 -Vaxlib -static -check all -g -fpe0 -ftz -debug extended \
249-
-debug inline_debug_info -debug-parameters all -traceback -ftrapuv \
250-
-fp-stack-check -implicitnone -openmp
264+
LOADER_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -static -check all -g -fpe0 -ftz \
265+
-debug extended -debug inline_debug_info -debug-parameters all -traceback \
266+
-ftrapuv -fp-stack-check -implicitnone -openmp
251267
C_LOADER_OPTS=-v -g -traceback -static
252268
#------------------------------------------------------------------------------------------#
253269

@@ -259,11 +275,11 @@ C_LOADER_OPTS=-v -g -traceback -static
259275
# failing or giving instabilities, or funny results after a long time. #
260276
#------------------------------------------------------------------------------------------#
261277
#USE_INTERF=1
262-
#F_OPTS= -FR -O2 -recursive -Vaxlib -check all -g -fpe0 -ftz -debug extended \
278+
#F_OPTS= -FR -O2 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -debug extended \
263279
-debug inline_debug_info -debug-parameters all -traceback -ftrapuv \
264280
-fp-stack-check -implicitnone -openmp -static
265281
#C_OPTS= -O2 -DLITTLE -g -traceback -debug extended -static
266-
#LOADER_OPTS= -FR -O2 -Vaxlib -check all -g -fpe0 -ftz -debug extended \
282+
#LOADER_OPTS= -FR -O2 -Vaxlib -recursive -qmkl -check all -g -fpe0 -ftz -debug extended \
267283
-debug inline_debug_info -debug-parameters all -traceback -ftrapuv \
268284
-fp-stack-check -implicitnone -openmp -static
269285
#C_LOADER_OPTS=-v -g -traceback -static
@@ -276,10 +292,10 @@ C_LOADER_OPTS=-v -g -traceback -static
276292
# or if you have a good idea of which problem you are dealing with. #
277293
#------------------------------------------------------------------------------------------#
278294
#USE_INTERF=1
279-
#F_OPTS= -FR -O2 -recursive -Vaxlib -check all -fpe0 -ftz -traceback -ftrapuv \
295+
#F_OPTS= -FR -O2 -recursive -qmkl -Vaxlib -check all -fpe0 -ftz -traceback -ftrapuv \
280296
-fp-stack-check -implicitnone -openmp
281297
#C_OPTS= -O2 -DLITTLE -traceback
282-
#LOADER_OPTS= -FR -O2 -Vaxlib -check all -fpe0 -ftz -traceback -ftrapuv \
298+
#LOADER_OPTS= -FR -O2 -Vaxlib -recursive -qmkl -check all -fpe0 -ftz -traceback -ftrapuv \
283299
-fp-stack-check -implicitnone -openmp
284300
#C_LOADER_OPTS=-v -traceback
285301
#------------------------------------------------------------------------------------------#
@@ -292,9 +308,9 @@ C_LOADER_OPTS=-v -g -traceback -static
292308
# velopers. #
293309
#------------------------------------------------------------------------------------------#
294310
#USE_INTERF=1
295-
#F_OPTS= -FR -O3 -recursive -Vaxlib -traceback
311+
#F_OPTS= -FR -O3 -recursive -qmkl -Vaxlib -traceback
296312
#C_OPTS= -O3 -DLITTLE -traceback
297-
#LOADER_OPTS= -FR -O3 -Vaxlib -traceback
313+
#LOADER_OPTS= -FR -O3 -recursive -qmkl -Vaxlib -traceback
298314
#C_LOADER_OPTS=-v -traceback
299315
#------------------------------------------------------------------------------------------#
300316

BRAMS/build/bin/include.mk.opt.gfortran

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ HDF5_LIBS=-lz -L/opt/hdf5/1.8.1/ompi-tcp-gnu41/lib \
5656

5757

5858

59+
#------------------------------------------------------------------------------------------#
60+
# Linear Algebra Package (LAPACK) libraries. #
61+
# #
62+
# Lapack is a well-established package for solving linear systems in Fortran. This is #
63+
# more efficient than the former built-in solution, and thus it became the new default. #
64+
# #
65+
# For those compiling the code with Intel compilers (ifort/icc), leave these empty and #
66+
# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on #
67+
# the ifort/icc version). Otherwise, provide the path to Lapack installation. #
68+
#------------------------------------------------------------------------------------------#
69+
LAPACK_PATH=/usr/local/opt/lapack
70+
LAPACK_INCS=-I$(LAPACK_PATH)/include
71+
LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas
72+
#------------------------------------------------------------------------------------------#
73+
74+
5975
# HDF libraries-------------------------------------------------
6076
# HDF4 library: Instructions to install: www.cptec.inpe.br/brams
6177
# If you run "configure" script, you don't need to edit line bellow

BRAMS/build/bin/include.mk.opt.gnu

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ HDF4_LIBS=-L./.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz
6262
USE_MPIWTIME=0
6363

6464

65+
#------------------------------------------------------------------------------------------#
66+
# Linear Algebra Package (LAPACK) libraries. #
67+
# #
68+
# Lapack is a well-established package for solving linear systems in Fortran. This is #
69+
# more efficient than the former built-in solution, and thus it became the new default. #
70+
# #
71+
# For those compiling the code with Intel compilers (ifort/icc), leave these empty and #
72+
# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on #
73+
# the ifort/icc version). Otherwise, provide the path to Lapack installation. #
74+
#------------------------------------------------------------------------------------------#
75+
LAPACK_PATH=/usr/local/opt/lapack
76+
LAPACK_INCS=-I$(LAPACK_PATH)/include
77+
LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas
78+
#------------------------------------------------------------------------------------------#
79+
80+
6581
#----------------- SGI -n32 ------------------------------------
6682
#CMACH=SGI
6783
#F_COMP=f90

BRAMS/build/bin/include.mk.opt.intel

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ HDF5_LIBS= -lz -lm -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl
6262
#------------------------------------------------------------------------------------------#
6363

6464

65+
#------------------------------------------------------------------------------------------#
66+
# Linear Algebra Package (LAPACK) libraries. #
67+
# #
68+
# Lapack is a well-established package for solving linear systems in Fortran. This is #
69+
# more efficient than the former built-in solution, and thus it became the new default. #
70+
# #
71+
# For those compiling the code with Intel compilers (ifort/icc), leave these empty and #
72+
# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on #
73+
# the ifort/icc version). Otherwise, provide the path to Lapack installation. #
74+
#------------------------------------------------------------------------------------------#
75+
LAPACK_PATH=
76+
LAPACK_INCS=
77+
LAPACK_LIBS=
78+
#------------------------------------------------------------------------------------------#
79+
80+
6581

6682
#------------------------------------------------------------------------------------------#
6783
# If you have a version of hdf5 compiled in parallel, then you may benefit from #
@@ -130,7 +146,7 @@ endif
130146
#------------------------------------------------------------------------------------------#
131147
ifeq ($(KIND_COMP),A)
132148
USE_INTERF=0
133-
F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \
149+
F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \
134150
-fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \
135151
-assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces
136152
C_OPTS= -O0 -DLITTLE -g -traceback
@@ -139,7 +155,7 @@ ifeq ($(KIND_COMP),A)
139155
endif
140156
ifeq ($(KIND_COMP),B)
141157
USE_INTERF=0
142-
F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \
158+
F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \
143159
-fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \
144160
-assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces
145161
C_OPTS= -O0 -DLITTLE -g -traceback
@@ -148,7 +164,7 @@ ifeq ($(KIND_COMP),B)
148164
endif
149165
ifeq ($(KIND_COMP),C)
150166
USE_INTERF=1
151-
F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \
167+
F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \
152168
-fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \
153169
-assume byterecl
154170
C_OPTS= -O0 -DLITTLE -g -traceback
@@ -157,17 +173,17 @@ ifeq ($(KIND_COMP),C)
157173
endif
158174
ifeq ($(KIND_COMP),D)
159175
USE_INTERF=1
160-
F_OPTS= -FR -O0 -recursive -check all-fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \
161-
-implicitnone -assume byterecl
176+
F_OPTS= -FR -O0 -recursive -qmkl -check all-fpe0 -no-ftz -traceback -ftrapuv \
177+
-fp-stack-check -implicitnone -assume byterecl
162178
C_OPTS= -O0 -DLITTLE -g -traceback
163179
LOADER_OPTS=$(F_OPTS)
164180
#---------------------------------------------------------------------------------------#
165181
endif
166182
ifeq ($(KIND_COMP),E)
167183
USE_INTERF=1
168-
F_OPTS= -FR -O3 -recursive -traceback -assume byterecl
184+
F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl
169185
C_OPTS= -O3 -DLITTLE -traceback
170-
F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl
186+
F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl
171187
LOADER_OPTS=$(F_OPTS)
172188
#---------------------------------------------------------------------------------------#
173189
endif

BRAMS/build/bin/include.mk.opt.macosx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ NC_LIBS=-L/dev/null
7878
# --------------------------------------------------------------
7979

8080

81+
#------------------------------------------------------------------------------------------#
82+
# Linear Algebra Package (LAPACK) libraries. #
83+
# #
84+
# Lapack is a well-established package for solving linear systems in Fortran. This is #
85+
# more efficient than the former built-in solution, and thus it became the new default. #
86+
# #
87+
# For those compiling the code with Intel compilers (ifort/icc), leave these empty and #
88+
# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on #
89+
# the ifort/icc version). Otherwise, provide the path to Lapack installation. #
90+
#------------------------------------------------------------------------------------------#
91+
LAPACK_PATH=/usr/local/opt/lapack
92+
LAPACK_INCS=-I$(LAPACK_PATH)/include
93+
LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas
94+
#------------------------------------------------------------------------------------------#
95+
96+
8197
# MPI_Wtime. ---------------------------------------------------
8298
# If USE_MPIWTIME=1, then it will use MPI libraries to compute
8399
# the wall time (the only double-precision intrinsic). In case

BRAMS/build/bin/include.mk.opt.nec

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ HDF4_LIBS=
6363
USE_MPIWTIME=1
6464

6565

66+
#------------------------------------------------------------------------------------------#
67+
# Linear Algebra Package (LAPACK) libraries. #
68+
# #
69+
# Lapack is a well-established package for solving linear systems in Fortran. This is #
70+
# more efficient than the former built-in solution, and thus it became the new default. #
71+
# #
72+
# For those compiling the code with Intel compilers (ifort/icc), leave these empty and #
73+
# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on #
74+
# the ifort/icc version). Otherwise, provide the path to Lapack installation. #
75+
#------------------------------------------------------------------------------------------#
76+
LAPACK_PATH=/usr/local/opt/lapack
77+
LAPACK_INCS=-I$(LAPACK_PATH)/include
78+
LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas
79+
#------------------------------------------------------------------------------------------#
80+
81+
6682
#----------------- SGI -n32 ------------------------------------
6783
#CMACH=SGI
6884
#F_COMP=f90

0 commit comments

Comments
 (0)