diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8edae433..25dcf1e9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install dependencies - run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev + run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev libblas-dev liblapack-dev - name: Install ED2 run: | cd ED/build @@ -43,7 +43,7 @@ jobs: with: name: ed2-binary - name: Install dependencies - run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev + run: sudo apt-get install -y --no-install-recommends gfortran libhdf5-openmpi-dev libopenmpi-dev libblas-dev liblapack-dev - name: Run ED2 working-directory: ./EDTS/ run: | diff --git a/BRAMS/build/bin/Makefile b/BRAMS/build/bin/Makefile index 3e6a5d8b3..8f3a505a0 100644 --- a/BRAMS/build/bin/Makefile +++ b/BRAMS/build/bin/Makefile @@ -23,7 +23,7 @@ endif #----- Compiler commands. -----------------------------------------------------------------# -INCLUDES = $(PAR_INCS) -I$(UTILS_INCS) $(HDF5_INCS) $(MPI_INCS) +INCLUDES = $(PAR_INCS) -I$(UTILS_INCS) $(HDF5_INCS) $(MPI_INCS) $(LAPACK_INCS) F90_COMMAND = $(F_COMP) -c $(F_OPTS) $(INCLUDES) $(PAR_DEFS) F90_LOWO_COMMAND = $(F_COMP) -c $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS) FPP_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \ @@ -63,7 +63,7 @@ gendep: $(EXE): $(LIBMODEL) $(MAINOBJ) @echo "" $(LOADER) -o $(EXE) rammain.o $(LOADER_OPTS) $(LIBMODEL) \ - $(HDF4_LIBS) $(HDF5_LIBS) $(PAR_LIBS) $(NC_LIBS) $(LIBS) + $(HDF4_LIBS) $(HDF5_LIBS) $(PAR_LIBS) $(LAPACK_LIBS) $(NC_LIBS) $(LIBS) @echo "" @echo Finished building === $(EXE) @echo "" diff --git a/BRAMS/build/bin/include.mk.opt.32intel b/BRAMS/build/bin/include.mk.opt.32intel index b0f810879..cd8f33a49 100644 --- a/BRAMS/build/bin/include.mk.opt.32intel +++ b/BRAMS/build/bin/include.mk.opt.32intel @@ -54,6 +54,22 @@ HDF5_LIBS=-L/n/Moorcroft_Lab/Users/mlongo/util/hdflib/hdf5_32/hdf5/lib \ # may benefit from collective I/O, then use this flag = 1 # Otherwise, set it to zero. + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + USE_COLLECTIVE_MPIO=0 #--------------------------------------------------------------- @@ -222,11 +238,11 @@ MOD_EXT=mod # face problems. If it successfully compiles, then you can switch to B. # #------------------------------------------------------------------------------------------# #USE_INTERF=0 -#F_OPTS= -FR -O0 -recursive -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \ +#F_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \ -warn interfaces -debug extended -debug inline_debug_info -debug-parameters all \ -traceback -ftrapuv -fp-stack-check -implicitnone -openmp -static #C_OPTS= -O0 -DLITTLE -g -traceback -debug extended -static -#LOADER_OPTS= -FR -O0 -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \ +#LOADER_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -gen-interfaces \ -warn interfaces -debug extended -debug inline_debug_info \ -debug-parameters all -traceback -ftrapuv -fp-stack-check -implicitnone -openmp -static #C_LOADER_OPTS=-v -g -traceback @@ -241,13 +257,13 @@ MOD_EXT=mod # Note, however, that if you change arguments you should first try A. # #------------------------------------------------------------------------------------------# USE_INTERF=1 -F_OPTS= -FR -O0 -recursive -Vaxlib -check all -g -fpe0 -ftz -debug extended \ +F_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -debug extended \ -debug inline_debug_info -static -debug-parameters all -traceback -ftrapuv \ -fp-stack-check -implicitnone -openmp C_OPTS= -O0 -DLITTLE -g -traceback -debug extended -static -LOADER_OPTS= -FR -O0 -Vaxlib -static -check all -g -fpe0 -ftz -debug extended \ - -debug inline_debug_info -debug-parameters all -traceback -ftrapuv \ - -fp-stack-check -implicitnone -openmp +LOADER_OPTS= -FR -O0 -recursive -qmkl -Vaxlib -static -check all -g -fpe0 -ftz \ + -debug extended -debug inline_debug_info -debug-parameters all -traceback \ + -ftrapuv -fp-stack-check -implicitnone -openmp C_LOADER_OPTS=-v -g -traceback -static #------------------------------------------------------------------------------------------# @@ -259,11 +275,11 @@ C_LOADER_OPTS=-v -g -traceback -static # failing or giving instabilities, or funny results after a long time. # #------------------------------------------------------------------------------------------# #USE_INTERF=1 -#F_OPTS= -FR -O2 -recursive -Vaxlib -check all -g -fpe0 -ftz -debug extended \ +#F_OPTS= -FR -O2 -recursive -qmkl -Vaxlib -check all -g -fpe0 -ftz -debug extended \ -debug inline_debug_info -debug-parameters all -traceback -ftrapuv \ -fp-stack-check -implicitnone -openmp -static #C_OPTS= -O2 -DLITTLE -g -traceback -debug extended -static -#LOADER_OPTS= -FR -O2 -Vaxlib -check all -g -fpe0 -ftz -debug extended \ +#LOADER_OPTS= -FR -O2 -Vaxlib -recursive -qmkl -check all -g -fpe0 -ftz -debug extended \ -debug inline_debug_info -debug-parameters all -traceback -ftrapuv \ -fp-stack-check -implicitnone -openmp -static #C_LOADER_OPTS=-v -g -traceback -static @@ -276,10 +292,10 @@ C_LOADER_OPTS=-v -g -traceback -static # or if you have a good idea of which problem you are dealing with. # #------------------------------------------------------------------------------------------# #USE_INTERF=1 -#F_OPTS= -FR -O2 -recursive -Vaxlib -check all -fpe0 -ftz -traceback -ftrapuv \ +#F_OPTS= -FR -O2 -recursive -qmkl -Vaxlib -check all -fpe0 -ftz -traceback -ftrapuv \ -fp-stack-check -implicitnone -openmp #C_OPTS= -O2 -DLITTLE -traceback -#LOADER_OPTS= -FR -O2 -Vaxlib -check all -fpe0 -ftz -traceback -ftrapuv \ +#LOADER_OPTS= -FR -O2 -Vaxlib -recursive -qmkl -check all -fpe0 -ftz -traceback -ftrapuv \ -fp-stack-check -implicitnone -openmp #C_LOADER_OPTS=-v -traceback #------------------------------------------------------------------------------------------# @@ -292,9 +308,9 @@ C_LOADER_OPTS=-v -g -traceback -static # velopers. # #------------------------------------------------------------------------------------------# #USE_INTERF=1 -#F_OPTS= -FR -O3 -recursive -Vaxlib -traceback +#F_OPTS= -FR -O3 -recursive -qmkl -Vaxlib -traceback #C_OPTS= -O3 -DLITTLE -traceback -#LOADER_OPTS= -FR -O3 -Vaxlib -traceback +#LOADER_OPTS= -FR -O3 -recursive -qmkl -Vaxlib -traceback #C_LOADER_OPTS=-v -traceback #------------------------------------------------------------------------------------------# diff --git a/BRAMS/build/bin/include.mk.opt.gfortran b/BRAMS/build/bin/include.mk.opt.gfortran index 6ae2bb70e..451175435 100644 --- a/BRAMS/build/bin/include.mk.opt.gfortran +++ b/BRAMS/build/bin/include.mk.opt.gfortran @@ -56,6 +56,22 @@ HDF5_LIBS=-lz -L/opt/hdf5/1.8.1/ompi-tcp-gnu41/lib \ +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + # HDF libraries------------------------------------------------- # HDF4 library: Instructions to install: www.cptec.inpe.br/brams # If you run "configure" script, you don't need to edit line bellow diff --git a/BRAMS/build/bin/include.mk.opt.gnu b/BRAMS/build/bin/include.mk.opt.gnu index 0887a8ad0..458b64e30 100644 --- a/BRAMS/build/bin/include.mk.opt.gnu +++ b/BRAMS/build/bin/include.mk.opt.gnu @@ -62,6 +62,22 @@ HDF4_LIBS=-L./.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz USE_MPIWTIME=0 +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #----------------- SGI -n32 ------------------------------------ #CMACH=SGI #F_COMP=f90 diff --git a/BRAMS/build/bin/include.mk.opt.intel b/BRAMS/build/bin/include.mk.opt.intel index f817e1144..d095b547c 100644 --- a/BRAMS/build/bin/include.mk.opt.intel +++ b/BRAMS/build/bin/include.mk.opt.intel @@ -62,6 +62,22 @@ HDF5_LIBS= -lz -lm -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -130,7 +146,7 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces C_OPTS= -O0 -DLITTLE -g -traceback @@ -139,7 +155,7 @@ ifeq ($(KIND_COMP),A) endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces C_OPTS= -O0 -DLITTLE -g -traceback @@ -148,7 +164,7 @@ ifeq ($(KIND_COMP),B) endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl C_OPTS= -O0 -DLITTLE -g -traceback @@ -157,17 +173,17 @@ ifeq ($(KIND_COMP),C) endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all-fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl + F_OPTS= -FR -O0 -recursive -qmkl -check all-fpe0 -no-ftz -traceback -ftrapuv \ + -fp-stack-check -implicitnone -assume byterecl C_OPTS= -O0 -DLITTLE -g -traceback LOADER_OPTS=$(F_OPTS) #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl C_OPTS= -O3 -DLITTLE -traceback - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl LOADER_OPTS=$(F_OPTS) #---------------------------------------------------------------------------------------# endif diff --git a/BRAMS/build/bin/include.mk.opt.macosx b/BRAMS/build/bin/include.mk.opt.macosx index 0b1ea1fb5..bd9a95f2f 100644 --- a/BRAMS/build/bin/include.mk.opt.macosx +++ b/BRAMS/build/bin/include.mk.opt.macosx @@ -78,6 +78,22 @@ NC_LIBS=-L/dev/null # -------------------------------------------------------------- +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + # MPI_Wtime. --------------------------------------------------- # If USE_MPIWTIME=1, then it will use MPI libraries to compute # the wall time (the only double-precision intrinsic). In case diff --git a/BRAMS/build/bin/include.mk.opt.nec b/BRAMS/build/bin/include.mk.opt.nec index cdb2792de..e63634577 100644 --- a/BRAMS/build/bin/include.mk.opt.nec +++ b/BRAMS/build/bin/include.mk.opt.nec @@ -63,6 +63,22 @@ HDF4_LIBS= USE_MPIWTIME=1 +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #----------------- SGI -n32 ------------------------------------ #CMACH=SGI #F_COMP=f90 diff --git a/BRAMS/build/bin/include.mk.opt.odyssey b/BRAMS/build/bin/include.mk.opt.odyssey index 06d9b5d0a..eba7719d2 100644 --- a/BRAMS/build/bin/include.mk.opt.odyssey +++ b/BRAMS/build/bin/include.mk.opt.odyssey @@ -62,6 +62,22 @@ HDF5_LIBS= -lz -lm -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -130,7 +146,7 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces C_OPTS= -O0 -DLITTLE -g -traceback @@ -139,7 +155,7 @@ ifeq ($(KIND_COMP),A) endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces C_OPTS= -O0 -DLITTLE -g -traceback @@ -148,7 +164,7 @@ ifeq ($(KIND_COMP),B) endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl C_OPTS= -O0 -DLITTLE -g -traceback @@ -157,17 +173,17 @@ ifeq ($(KIND_COMP),C) endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all-fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl + F_OPTS= -FR -O0 -recursive -qmkl -check all-fpe0 -no-ftz -traceback -ftrapuv \ + -fp-stack-check -implicitnone -assume byterecl C_OPTS= -O0 -DLITTLE -g -traceback LOADER_OPTS=$(F_OPTS) #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl C_OPTS= -O3 -DLITTLE -traceback - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl LOADER_OPTS=$(F_OPTS) #---------------------------------------------------------------------------------------# endif diff --git a/BRAMS/build/bin/include.mk.opt.pgi b/BRAMS/build/bin/include.mk.opt.pgi index 00bcf85e7..d32e2fe91 100644 --- a/BRAMS/build/bin/include.mk.opt.pgi +++ b/BRAMS/build/bin/include.mk.opt.pgi @@ -42,6 +42,22 @@ HDF4_LIBS= #HDF4_LIBS=-L.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz # -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + # HDF 5 Libraries # ED2 HAS OPTIONAL HDF 5 I/O # If you wish to use this functionality specify USE_HDF5=1 diff --git a/BRAMS/src/cuparm/grell_cupar_dynamic.f90 b/BRAMS/src/cuparm/grell_cupar_dynamic.f90 index f0d705ee4..539d48a35 100644 --- a/BRAMS/src/cuparm/grell_cupar_dynamic.f90 +++ b/BRAMS/src/cuparm/grell_cupar_dynamic.f90 @@ -29,7 +29,7 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max ,dzu_cld & ! intent(in) - Delta-height for updraft calculations [ m] ,exner & ! intent(in) - Forced Exner funtion [ J/kg/K] ,exnersur & ! intent(in) - Surface Exner function [ J/kg/K] - ,mconv & ! intent(in) - Integrated moisture convergence [kg/m�/s] + ,mconv & ! intent(in) - Integrated moisture convergence [kg/m2/s] ,mkx & ! intent(in) - Number of vertical levels [ ---] ,omeg & ! intent(in) - Vertical velocity in pressure, dp/dt: [ Pa/s] ,p & ! intent(in) - Pressure with forcing [ Pa] @@ -42,7 +42,7 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max ,qliqsur & ! intent(in) - surface liquid water mixing ratio [ kg/kg] ,qice & ! intent(in) - Ice mixing ratio with forcing. [ kg/kg] ,qicesur & ! intent(in) - surface ice mixing ratio [ kg/kg] - ,rho & ! intent(in) - Air density [ kg/m�] + ,rho & ! intent(in) - Air density [ kg/m3] ,theiv & ! intent(in) - THETA-Eiv with forcing [ K] ,theivsur & ! intent(in) - Surface ice-vapour equiv. pot. temp. [ K] ,thil & ! intent(in) - THETA-il with forcing [ K] @@ -56,12 +56,12 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max ,cdu & ! intent(out) - Normalised updraft detrainment rate [ ---] ,mentrd_rate & ! intent(out) - Normalised downdraft entrainment rate [ ---] ,mentru_rate & ! intent(out) - Normalised updraft entrainment rate [ ---] - ,dbyd & ! intent(out) - Buoyancy associated with downdrafts [ m/s�] - ,dbyu & ! intent(out) - Buoyancy associated with updrafts [ m/s�] + ,dbyd & ! intent(out) - Buoyancy associated with downdrafts [ m/s2] + ,dbyu & ! intent(out) - Buoyancy associated with updrafts [ m/s2] ,etad_cld & ! intent(out) - normalised downdraft mass flux [ ---] ,etau_cld & ! intent(out) - normalised updraft mass flux [ ---] - ,rhod_cld & ! intent(out) - Downdraft density [ kg/m�] - ,rhou_cld & ! intent(out) - Updraft density [ kg/m�] + ,rhod_cld & ! intent(out) - Downdraft density [ kg/m3] + ,rhou_cld & ! intent(out) - Updraft density [ kg/m3] ,qliqd_cld & ! intent(out) - Liquid water mixing ratio at dndraft [ kg/kg] ,qliqu_cld & ! intent(out) - Liquid water mixing ratio at updraft [ kg/kg] ,qiced_cld & ! intent(out) - Ice mixing ratio at downdraft [ kg/kg] @@ -72,8 +72,8 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max ,x_co2_cup & ! intent(out) - CO2 mixing ratio [ ppm] ,x_co2d_cld & ! intent(out) - CO2 mixing ratio [ ppm] ,x_co2u_cld & ! intent(out) - CO2 mixing ratio [ ppm] - ,x_dbyd & ! intent(out) - Buoyancy acceleration [ m/s�] - ,x_dbyu & ! intent(out) - Buoyancy acceleration [ m/s�] + ,x_dbyd & ! intent(out) - Buoyancy acceleration [ m/s2] + ,x_dbyu & ! intent(out) - Buoyancy acceleration [ m/s2] ,x_exner_cup & ! intent(out) - Exner function [ J/kg] ,x_p_cup & ! intent(out) - Pressure [ Pa] ,x_pwav & ! intent(out) - Integrated condensation [ kg/kg] @@ -99,9 +99,9 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max ,x_qsat_cup & ! intent(out) - Saturation mixing ratio [ kg/kg] ,x_qsatd_cld & ! intent(out) - Sat. mixing ratio [ kg/kg] ,x_qsatu_cld & ! intent(out) - Sat. mixing ratio [ kg/kg] - ,x_rho_cup & ! intent(out) - Density [ kg/m�] - ,x_rhod_cld & ! intent(out) - Density [ kg/m�] - ,x_rhou_cld & ! intent(out) - Density [ kg/m�] + ,x_rho_cup & ! intent(out) - Density [ kg/m3] + ,x_rhod_cld & ! intent(out) - Density [ kg/m3] + ,x_rhou_cld & ! intent(out) - Density [ kg/m3] ,x_t & ! intent(out) - Temperature [ K] ,x_t_cup & ! intent(out) - Temperature [ K] ,x_td_cld & ! intent(out) - Temperature [ K] @@ -192,7 +192,7 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max !---------------------------------------------------------------------------------------! ! Miscellaneous parameters ! !---------------------------------------------------------------------------------------! - real, dimension(maxens_lsf) :: mbprime ! Arbitrary m. flux to modify environm. [kg/m�/s] + real, dimension(maxens_lsf) :: mbprime ! Arbitrary m. flux to modify environm. [kg/m2/s] real, dimension(maxens_lsf) :: one_b ! 1-b, Krishnamurti et al. (1983) [ ---] real, dimension(nclouds) :: edt ! Alias for the downdraft/updraft ratio. !------ Printing aux. variables. -------------------------------------------------------! @@ -489,7 +489,7 @@ subroutine grell_cupar_dynamic(cldd,clds,nclouds,dtime,maxens_cap,maxens_eff,max ! efficiency, static control, and large-scale forcing. Inside this subroutine we ! ! will find all members of the dynamic control for all clouds. The outcome will be ! ! a vector of reference updraft mass flux for that member. ! - ! mass flux will then have maxens_eff � maxens_lsf � maxens_dyn different values. ! + ! mass flux will then have maxens_eff * maxens_lsf * maxens_dyn different values. ! !---------------------------------------------------------------------------------------! stacloop2: do icap=1,maxens_cap @@ -732,7 +732,7 @@ subroutine grell_dyncontrol_ensemble(nclouds,mgmzp,maxens_dyn,cldd,clds,dtime,cl end do mcloop !---------------------------------------------------------------------------------------! - ! 6. Ensemble, based on Grell and D�v�nyi (2002) ! + ! 6. Ensemble, based on Grell and Devenyi (2002) ! ! Here for each different dynamic control style, the first element is the standard, ! ! like in the previous cases, and the others are perturbations. ! !---------------------------------------------------------------------------------------! @@ -859,7 +859,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr integer :: jsol ! Yet another cloud index real :: dtimei ! Scratch, inverse of delta-t integer :: nsolv ! # of clouds we are still solving. - logical :: is_sing ! Flag. The kernel was singular. [T|F] + integer :: info ! Lapack Flag for errors (0 means fine). !----- Auxilliary variables, containing flags and references. --------------------------! logical, dimension(nclouds) :: okcld ! This cloud is still ok to use. integer, dimension(nclouds) :: cloud ! Absolute cloud index. @@ -868,6 +868,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr real , dimension(:) , allocatable :: diagkke ! Diagonal of kke real , dimension(:) , allocatable :: mfo ! Minus the large-scale forcing real , dimension(:) , allocatable :: mb ! Mass flux + integer, dimension(:) , allocatable :: pivot ! Pivot (needed by Lapack, not used) integer, dimension(:) , allocatable :: cldidx ! Cloud index, to copy back to ensemble !---------------------------------------------------------------------------------------! @@ -915,6 +916,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr allocate(diagkke (nsolv)) allocate(mfo (nsolv)) allocate(mb (nsolv)) + allocate(pivot (nsolv)) allocate(cldidx (nsolv)) !----- Store the actual cloud number of the clouds that exist. ----------------------! @@ -943,10 +945,13 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr !------------------------------------------------------------------------------------! - ! Solve the linear system using a Gaussian elimination method. The system, as ! - ! stated in Lord et al. (1982), is : K * Mb = -F. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand side ! + ! vector with the solution, so we first copy the right hand side to the output ! + ! vector. ! !------------------------------------------------------------------------------------! - call lisys_solver(nsolv,kke,mfo,mb,is_sing) + mb(:) = mfo(:) + call sgesv(nsolv,1,kke,nsolv,pivot,mb,nsolv,info) !------------------------------------------------------------------------------------! @@ -954,7 +959,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr ! First we check whether the solution is an appropriate one or something went ! ! wrong. ! !------------------------------------------------------------------------------------! - if (is_sing) then + if (info > 0) then !---------------------------------------------------------------------------------! ! The matrix is singular or almost singular, so we cannot solve these clouds. ! ! We can quit this routine after freeing the allocated arrays. ! @@ -963,6 +968,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! exit queq_loop @@ -983,6 +989,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! else @@ -1001,6 +1008,7 @@ subroutine grell_grell_solver(nclouds,cldd,clds,dtime,fac,aatot0,aatot,mfke,ierr deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! exit queq_loop @@ -1111,6 +1119,7 @@ subroutine grell_arakschu_solver(nclouds,cldd,clds,mgmzp,dtime,p_cup,clim,whlev, allocate(diagkke (nsolv)) allocate(mfo (nsolv)) allocate(mb (nsolv)) + allocate(pivot (nsolv)) allocate(cldidx (nsolv)) !----- Store the actual cloud number of those clouds @@ -1160,12 +1169,14 @@ subroutine grell_arakschu_solver(nclouds,cldd,clds,mgmzp,dtime,p_cup,clim,whlev, - !------------------------------------------------------------------------------------! - ! Solve the linear system using a Gaussian elimination method. The system, as ! - ! stated in Lord et al. (1982), is : K * Mb = -F. ! + ! Solve the linear system. The system, as stated in Lord et al. (1982), is: ! + ! K * Mb = -F. We invoke the Linear Algebra Package (LAPACK) procedure for solving ! + ! the system efficiently. LAPACK rewrites the right hand side vector with the ! + ! solution, so we first copy the right hand side to the output vector. ! !------------------------------------------------------------------------------------! - call lisys_solver(nsolv,kke,mfo,mb,is_sing) + mb(:) = mfo(:) + call sgesv(nsolv,1,kke,nsolv,pivot,mb,nsolv,info) !------------------------------------------------------------------------------------! @@ -1173,7 +1184,7 @@ subroutine grell_arakschu_solver(nclouds,cldd,clds,mgmzp,dtime,p_cup,clim,whlev, ! First we check whether the solution is an appropriate one or something went ! ! wrong. ! !------------------------------------------------------------------------------------! - if (is_sing) then + if (info > 0) then !---------------------------------------------------------------------------------! ! The matrix is singular or almost singular, so we cannot solve these clouds. ! ! We can quit this routine after freeing the allocated arrays. ! @@ -1182,6 +1193,7 @@ subroutine grell_arakschu_solver(nclouds,cldd,clds,mgmzp,dtime,p_cup,clim,whlev, deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) exit queq_loop elseif (any(mb < 0.) .or. any(diagkke == 0.)) then @@ -1200,6 +1212,7 @@ subroutine grell_arakschu_solver(nclouds,cldd,clds,mgmzp,dtime,p_cup,clim,whlev, deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! else @@ -1218,6 +1231,7 @@ subroutine grell_arakschu_solver(nclouds,cldd,clds,mgmzp,dtime,p_cup,clim,whlev, deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! exit queq_loop @@ -1321,6 +1335,7 @@ subroutine grell_inre_solver(nclouds,cldd,clds,tscal,fac,aatot0,mfke,ierr,upmf,u allocate(diagkke (nsolv)) allocate(mfo (nsolv)) allocate(mb (nsolv)) + allocate(pivot (nsolv)) allocate(cldidx (nsolv)) !------------------------------------------------------------------------------------! @@ -1350,10 +1365,13 @@ subroutine grell_inre_solver(nclouds,cldd,clds,tscal,fac,aatot0,mfke,ierr,upmf,u !------------------------------------------------------------------------------------! - ! Solve the linear system using a Gaussian elimination method. The system, as ! - ! stated in Lord et al. (1982), is : K * Mb = -F. ! + ! Solve the linear system. The system, as stated in Lord et al. (1982), is: ! + ! K * Mb = -F. We invoke the Linear Algebra Package (LAPACK) procedure for solving ! + ! the system efficiently. LAPACK rewrites the right hand side vector with the ! + ! solution, so we first copy the right hand side to the output vector. ! !------------------------------------------------------------------------------------! - call lisys_solver(nsolv,kke,mfo,mb,is_sing) + mb(:) = mfo(:) + call sgesv(nsolv,1,kke,nsolv,pivot,mb,nsolv,info) !------------------------------------------------------------------------------------! @@ -1371,6 +1389,7 @@ subroutine grell_inre_solver(nclouds,cldd,clds,tscal,fac,aatot0,mfke,ierr,upmf,u deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) exit inre_loop elseif (any(mb < 0.) .or. any(diagkke == 0.)) then @@ -1389,6 +1408,7 @@ subroutine grell_inre_solver(nclouds,cldd,clds,tscal,fac,aatot0,mfke,ierr,upmf,u deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! else @@ -1407,6 +1427,7 @@ subroutine grell_inre_solver(nclouds,cldd,clds,tscal,fac,aatot0,mfke,ierr,upmf,u deallocate(diagkke) deallocate(mfo ) deallocate(mb ) + deallocate(pivot ) deallocate(cldidx ) !---------------------------------------------------------------------------------! exit inre_loop diff --git a/BRAMS/src/lib/numutils.f90 b/BRAMS/src/lib/numutils.f90 index aadaf4a6c..512b10241 100644 --- a/BRAMS/src/lib/numutils.f90 +++ b/BRAMS/src/lib/numutils.f90 @@ -1921,233 +1921,6 @@ end function check_real - -!==========================================================================================! -!==========================================================================================! -! This subroutine will solve the linear system AA . X = Y for given AA and Y, using ! -! the Gaussian elimination method with partial pivoting and back-substitution. ! -! This subroutine is based on: ! -! ! -! Press, W. H., S. A. Teukolsky, W. T. Vetterling, B. P. Flannery: 1992. Numerical recipes ! -! in Fortran 77. Cambridge University Press. ! -!------------------------------------------------------------------------------------------! -subroutine lisys_solver(nsiz,AA,Y,X,sing) - implicit none - !----- Arguments. ----------------------------------------------------------------------! - integer , intent(in) :: nsiz ! matrix and vector size - real(kind=4), dimension(nsiz,nsiz), intent(in) :: AA ! matrix - real(kind=4), dimension(nsiz) , intent(in) :: Y ! right-hand side vector - real(kind=4), dimension(nsiz) , intent(out) :: X ! unknown vector - logical , intent(out) :: sing ! The matrix is singular [T|F] - !----- Local variables. ----------------------------------------------------------------! - real(kind=4), dimension(nsiz,nsiz) :: EE ! Copy of AA, for elimination. - real(kind=4), dimension(nsiz) :: Z ! Copy of Y, for scaling - real(kind=4), dimension(nsiz) :: dumvec ! Dummy vector (row swapping) - real(kind=4) :: pivot ! The pivot - real(kind=4) :: multip ! Multiplier - integer :: r ! Row index - integer :: b ! Row below index - integer :: c ! Column index - integer :: p ! Pivot index - real(kind=4) :: dumsca ! Dummy scalar (row swapping) - !----- Local parameters. ---------------------------------------------------------------! - real(kind=4) , parameter :: tinyoff=1.e-20 - !---------------------------------------------------------------------------------------! - - !----- First thing, we copy AA to EE and Y to Z. ---------------------------------------! - EE(:,:) = AA(:,:) - Z (:) = Y (:) - dumvec = 0. - dumsca = 0. - !---------------------------------------------------------------------------------------! - ! We initialise X with a huge, non-sense value, which will become the answer when ! - ! the matrix is singular. ! - !---------------------------------------------------------------------------------------! - X (:) = -huge(1.) - !----- We first assume that everything will be fine. -----------------------------------! - sing = .false. - - !---------------------------------------------------------------------------------------! - ! 1. Main elimination loop, done row by row. ! - !---------------------------------------------------------------------------------------! - elimloop: do r = 1, nsiz-1 - !------ 1a. Finding the largest element, which will become our pivot ----------------! - p = (r-1) + maxloc(abs(EE(r:nsiz,r)),dim=1) - - pivot = maxval(abs(EE(r:nsiz,r))) - !------------------------------------------------------------------------------------! - ! 1b. Check the pivot and make sure it is a good one. If not, then this matrix is ! - ! singular or almost singular, and we cannot solve it, so we switch the flag and ! - ! return. ! - !------------------------------------------------------------------------------------! - if (pivot < tinyoff) then - sing = .true. - return - end if - - !----- 1c. If the best pivot is not the current row, we must swap them. -------------! - if (p /= r) then - dumvec(r:nsiz) = EE(r,r:nsiz) - dumsca = Z(r) - EE(r,r:nsiz) = EE(p,r:nsiz) - Z(r) = Z(p) - EE(p,r:nsiz) = dumvec(r:nsiz) - Z(p) = dumsca - end if - - !------------------------------------------------------------------------------------! - ! 1d. Eliminate rows below, everything to the left of the (,r) column will become ! - ! zero (we won't compute that, but they will be.). ! - !------------------------------------------------------------------------------------! - belowloop: do b=r+1,nsiz - multip = EE(b,r)/EE(r,r) - EE(b,r:nsiz) = EE(b,r:nsiz) - multip * EE(r,r:nsiz) - Z(b) = Z(b) - multip * Z(r) - end do belowloop - end do elimloop - - !---------------------------------------------------------------------------------------! - ! 2. We may be unlucky and discover that the matrix is singular at the last line, so we ! - ! check the last pivot too. ! - !---------------------------------------------------------------------------------------! - if (abs(EE(nsiz,nsiz)) < tinyoff) then - sing = .true. - return - end if - - !---------------------------------------------------------------------------------------! - ! 3. We now perform the back-substitution, to find the solution. ! - !---------------------------------------------------------------------------------------! - X(nsiz) = Z(nsiz) / EE(nsiz,nsiz) - backsubloop: do r=nsiz-1,1,-1 - b = r+1 - X(r) = (Z(r) - sum(EE(r,b:nsiz)*x(b:nsiz))) / EE(r,r) - end do backsubloop - - return -end subroutine lisys_solver -!==========================================================================================! -!==========================================================================================! - - - - - - - -!==========================================================================================! -!==========================================================================================! -! This subroutine is the double precision version of the linear system solver above. ! -! It will solve the linear system AA . X = Y for given AA and Y, using the Gaussian ! -! elimination method with partial pivoting and back-substitution. This subroutine is ! -! based on: ! -! ! -! Press, W. H., S. A. Teukolsky, W. T. Vetterling, B. P. Flannery: 1992. Numerical recipes ! -! in Fortran 77. Cambridge University Press. ! -!------------------------------------------------------------------------------------------! -subroutine lisys_solver8(nsiz,AA,Y,X,sing) - implicit none - !----- Arguments. ----------------------------------------------------------------------! - integer , intent(in) :: nsiz ! matrix and vector size - real(kind=8), dimension(nsiz,nsiz), intent(in) :: AA ! matrix - real(kind=8), dimension(nsiz) , intent(in) :: Y ! right-hand side vector - real(kind=8), dimension(nsiz) , intent(out) :: X ! unknown vector - logical , intent(out) :: sing ! The matrix was singular [T|F] - !----- Local variables. ----------------------------------------------------------------! - real(kind=8), dimension(nsiz,nsiz) :: EE ! Copy of AA, for elimination. - real(kind=8), dimension(nsiz) :: Z ! Copy of Y, for scaling - real(kind=8), dimension(nsiz) :: dumvec ! Dummy vector (row swapping) - real(kind=8) :: pivot ! The pivot - real(kind=8) :: multip ! Multiplier - integer :: r ! Row index - integer :: b ! Row below index - integer :: c ! Column index - integer :: p ! Pivot index - real(kind=8) :: dumsca ! Dummy scalar (row swapping) - !----- Local parameters. ---------------------------------------------------------------! - real(kind=8) , parameter :: tinyoff=1.d-20 - !---------------------------------------------------------------------------------------! - - !----- First thing, we copy AA to EE and Y to Z. ---------------------------------------! - EE(:,:) = AA(:,:) - Z (:) = Y (:) - dumvec = 0.d0 - dumsca = 0.d0 - !---------------------------------------------------------------------------------------! - ! We initialise X with a huge, non-sense value, which will become the answer when ! - ! the matrix is singular. ! - !---------------------------------------------------------------------------------------! - X (:) = -huge(1.d0) - !----- We first assume that everything will be fine. -----------------------------------! - sing = .false. - - !---------------------------------------------------------------------------------------! - ! 1. Main elimination loop, done row by row. ! - !---------------------------------------------------------------------------------------! - elimloop: do r = 1, nsiz-1 - !------ 1a. Finding the largest element, which will become our pivot ----------------! - p = (r-1) + maxloc(abs(EE(r:nsiz,r)),dim=1) - - pivot = maxval(abs(EE(r:nsiz,r))) - !------------------------------------------------------------------------------------! - ! 1b. Check the pivot and make sure it is a good one. If not, then this matrix is ! - ! singular or almost singular, and we cannot solve it, so we switch the flag and ! - ! return. ! - !------------------------------------------------------------------------------------! - if (pivot < tinyoff) then - sing = .true. - return - end if - - !----- 1c. If the best pivot is not the current row, we must swap them. -------------! - if (p /= r) then - dumvec(r:nsiz) = EE(r,r:nsiz) - dumsca = Z(r) - EE(r,r:nsiz) = EE(p,r:nsiz) - Z(r) = Z(p) - EE(p,r:nsiz) = dumvec(r:nsiz) - Z(p) = dumsca - end if - - !------------------------------------------------------------------------------------! - ! 1d. Eliminate rows below, everything to the left of the (,r) column will become ! - ! zero (we won't compute that, but they will be.). ! - !------------------------------------------------------------------------------------! - belowloop: do b=r+1,nsiz - multip = EE(b,r)/EE(r,r) - EE(b,r:nsiz) = EE(b,r:nsiz) - multip * EE(r,r:nsiz) - Z(b) = Z(b) - multip * Z(r) - end do belowloop - end do elimloop - - !---------------------------------------------------------------------------------------! - ! 2. We may be unlucky and discover that the matrix is singular at the last line, so we ! - ! check the last pivot too. ! - !---------------------------------------------------------------------------------------! - if (abs(EE(nsiz,nsiz)) < tinyoff) then - sing = .true. - return - end if - - !---------------------------------------------------------------------------------------! - ! 3. We now perform the back-substitution, to find the solution. ! - !---------------------------------------------------------------------------------------! - X(nsiz) = Z(nsiz) / EE(nsiz,nsiz) - backsubloop: do r=nsiz-1,1,-1 - b = r+1 - X(r) = (Z(r) - sum(EE(r,b:nsiz)*x(b:nsiz))) / EE(r,r) - end do backsubloop - - return -end subroutine lisys_solver8 -!==========================================================================================! -!==========================================================================================! - - - - - - !==========================================================================================! !==========================================================================================! ! This function checks whether a number is finite or not. This test will return true ! diff --git a/BRAMS/src/surface/leaf3_radiate.f90 b/BRAMS/src/surface/leaf3_radiate.f90 index c8cf3df65..c192f1fc0 100644 --- a/BRAMS/src/surface/leaf3_radiate.f90 +++ b/BRAMS/src/surface/leaf3_radiate.f90 @@ -1215,7 +1215,8 @@ subroutine leaf3_2stream_lw(grnd_emiss4,grnd_temp4,rlong_top4,nveg,lai,wai,leaf_ integer :: i2p1 integer :: i2m1 integer :: i2p2 - logical :: sing + integer :: info + integer , dimension(:) , allocatable :: xvec real(kind=8), dimension(:) , allocatable :: black real(kind=8), dimension(:) , allocatable :: expl_plus real(kind=8), dimension(:) , allocatable :: expl_minus @@ -1264,6 +1265,7 @@ subroutine leaf3_2stream_lw(grnd_emiss4,grnd_temp4,rlong_top4,nveg,lai,wai,leaf_ allocate(mmat (ncoh2p2,ncoh2p2) ) allocate(yvec (ncoh2p2) ) allocate(xvec (ncoh2p2) ) + allocate(pivot (ncoh2p2) ) allocate(elai (ncohp1) ) allocate(etai (ncohp1) ) allocate(mu (ncohp1) ) @@ -1449,16 +1451,16 @@ subroutine leaf3_2stream_lw(grnd_emiss4,grnd_temp4,rlong_top4,nveg,lai,wai,leaf_ - !---------------------------------------------------------------------------------------! - ! Solve the linear system. In the future we could use a band diagonal solver, ! - ! which is a lot cheaper than the regular Gauss elimination, but for the time being, we ! - ! go with a tested method. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand side ! + ! vector with the solution, so we first copy the right hand side to the output vector. ! !---------------------------------------------------------------------------------------! - call lisys_solver8(nsiz,mmat,yvec,xvec,sing) - if (sing) then + xvec(:) = yvec(:) + call dgesv(nsiz,1,mmat,nsiz,pivot,xvec,nsiz,info) + if (info > 0) then call abort_run('LW radiation failed... The matrix is singular!' & - ,'leaf3_2stream_lw','leaf3_radiate.f90') + ,'leaf3_2stream_lw','leaf3_radiate.f90') end if !---------------------------------------------------------------------------------------! @@ -1522,6 +1524,7 @@ subroutine leaf3_2stream_lw(grnd_emiss4,grnd_temp4,rlong_top4,nveg,lai,wai,leaf_ deallocate(mmat ) deallocate(yvec ) deallocate(xvec ) + deallocate(pivot ) deallocate(elai ) deallocate(etai ) deallocate(mu ) @@ -1620,13 +1623,14 @@ subroutine leaf3_2stream_sw(grnd_alb_par4,grnd_alb_nir4,cosz4,par_beam_norm4 integer :: i2p1 integer :: i2m1 integer :: i2p2 - logical :: sing + integer :: info real(kind=4) :: nir_beam real(kind=4) :: nir_diff real(kind=8) :: leaf_scatter real(kind=8) :: wood_scatter real(kind=8) :: leaf_backscatter real(kind=8) :: wood_backscatter + integer , dimension(:) , allocatable :: pivot real(kind=8), dimension(:) , allocatable :: expl_plus real(kind=8), dimension(:) , allocatable :: expl_minus real(kind=8), dimension(:) , allocatable :: expm0_minus @@ -1692,6 +1696,7 @@ subroutine leaf3_2stream_sw(grnd_alb_par4,grnd_alb_nir4,cosz4,par_beam_norm4 allocate(mmat (ncoh2p2,ncoh2p2)) allocate(yvec (ncoh2p2) ) allocate(xvec (ncoh2p2) ) + allocate(pivot (ncoh2p2) ) allocate(elai (ncohp1) ) allocate(etai (ncohp1) ) allocate(mu (ncohp1) ) @@ -1990,12 +1995,14 @@ subroutine leaf3_2stream_sw(grnd_alb_par4,grnd_alb_nir4,cosz4,par_beam_norm4 !------------------------------------------------------------------------------------! - ! Solve the linear system. In the future we could use a tridiagonal solver, ! - ! which is a lot cheaper than the regular Gauss elimination, but for the time being, ! - ! we go with a tested method. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand side ! + ! vector with the solution, so we first copy the right hand side to the output ! + ! vector. ! !------------------------------------------------------------------------------------! - call lisys_solver8(nsiz,mmat,yvec,xvec,sing) - if (sing) then + xvec(:) = yvec(:) + call dgesv(nsiz,1,mmat,nsiz,pivot,xvec,nsiz,info) + if (info > 0) then call abort_run('SW radiation failed... The matrix is singular!' & ,'leaf3_2stream_sw','leaf3_radiate.f90') end if @@ -2108,6 +2115,7 @@ subroutine leaf3_2stream_sw(grnd_alb_par4,grnd_alb_nir4,cosz4,par_beam_norm4 deallocate(mmat ) deallocate(yvec ) deallocate(xvec ) + deallocate(pivot ) deallocate(elai ) deallocate(etai ) deallocate(mu ) diff --git a/Dockerfile.gnu b/Dockerfile.gnu index fac933349..396eccd80 100644 --- a/Dockerfile.gnu +++ b/Dockerfile.gnu @@ -18,6 +18,8 @@ RUN apt-get update \ build-essential \ gfortran \ libhdf5-openmpi-dev \ + libblas-dev \ + liblapack-dev \ && rm -rf /var/lib/apt/lists/* # copy the source only, this prevents a full rebuild in case of changes to Dockerfile or non source files @@ -41,6 +43,8 @@ FROM ubuntu:22.04 RUN apt-get update \ && apt-get install -y --no-install-recommends \ libhdf5-openmpi-103 \ + libblas-dev \ + liblapack-dev \ libgomp1 \ && rm -rf /var/lib/apt/lists/* diff --git a/ED/build/make/Makefile b/ED/build/make/Makefile index 6c48ee2e9..54ee8c773 100644 --- a/ED/build/make/Makefile +++ b/ED/build/make/Makefile @@ -25,7 +25,7 @@ ifeq ($(OPT),"dbg") endif #----- Compiler commands. -----------------------------------------------------------------# -INCLUDES = $(PAR_INCS) -I$(ED_INCS) $(HDF5_INCS) $(MPI_INCS) +INCLUDES = $(PAR_INCS) -I$(ED_INCS) $(HDF5_INCS) $(MPI_INCS) $(LAPACK_INCS) F90_COMMAND = $(F_COMP) -c $(F_OPTS) $(INCLUDES) $(PAR_DEFS) F90_LOWO_COMMAND = $(F_COMP) -c $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS) FPP_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \ @@ -74,8 +74,8 @@ gendep: $(EXE): $(LIBMODEL) $(MAINOBJ) @echo "" - $(LOADER) -o $(EXE) edmain.o $(LOADER_OPTS) $(INCLUDES) $(LIBMODEL) $(HDF5_LIBS) \ - $(PAR_LIBS) $(NC_LIBS) $(LIBS) $(LOADER_OPTS) + $(LOADER) -o $(EXE) edmain.o $(LOADER_OPTS) $(INCLUDES) $(LIBMODEL) $(HDF5_LIBS) \ + $(LAPACK_LIBS) $(PAR_LIBS) $(LIBS) $(LOADER_OPTS) @echo "" @echo Finished building === $(EXE) @echo "" diff --git a/ED/build/make/include.mk.absoft b/ED/build/make/include.mk.absoft index 73c967d72..930537d4f 100644 --- a/ED/build/make/include.mk.absoft +++ b/ED/build/make/include.mk.absoft @@ -25,18 +25,6 @@ BASE=$(ED_ROOT)/build/ # Activate appropriate parts below, comment out others. -#--------------------------------------------------------------- -# If you are using a real distribution of NCAR Graphics... -#NCARG_DIR=/usr/local/ncarg-4.3.0/lib -#LIBNCARG=-L$(NCARG_DIR) -lncarg -lncarg_gks -lncarg_c -L/usr/X11R6/lib -lX11 -ldl -#--------------------------------------------------------------- - -# HDF libraries ----------------------------------------------- -# HDF4 library: Instructions to install: www.cptec.inpe.br/brams -# If you run "configure" script, you don't need to edit line bellow -#HDF_LIBS=-L.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz -# -------------------------------------------------------------- - # HDF 5 Libraries #HDF5_INCS=-I/n/Moorcroft_Lab/Lab/apps/i91/lib -I/n/Moorcroft_Lab/Lab/apps/i91/include #HDF5_LIBS=-L/n/Moorcroft_Lab/Lab/apps/i91/lib -lhdf5 -lm -lhdf5_fortran -lhdf5 -lhdf5_hl \ @@ -69,14 +57,21 @@ USE_COLLECTIVE_MPIO=0 #--------------------------------------------------------------- -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.arch_linux b/ED/build/make/include.mk.arch_linux index 8b934ac90..6fb7e969a 100644 --- a/ED/build/make/include.mk.arch_linux +++ b/ED/build/make/include.mk.arch_linux @@ -11,14 +11,23 @@ BASE=$(ED_ROOT)/build/ HDF5_INCS= HDF5_LIBS=-lhdf5 -lm -lhdf5_fortran -lhdf5 -lhdf5_hl -lz USE_COLLECTIVE_MPIO=1 - -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null +------------------------------------------------------------------------------------# + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.bnl b/ED/build/make/include.mk.bnl index 6028ded24..204546ad3 100644 --- a/ED/build/make/include.mk.bnl +++ b/ED/build/make/include.mk.bnl @@ -12,10 +12,22 @@ HDF5_HOME=/data/software/hdf5/1.8.19-gcc540 HDF5_INCS=-I${HDF5_HOME}/include HDF5_LIBS=-L${HDF5_HOME}/lib -lhdf5 -lm -lhdf5_fortran -lhdf5 -lhdf5_hl -lz USE_COLLECTIVE_MPIO=0 - -# netCDF libraries -USENC=0 -NC_LIBS=-L/dev/null + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface USE_INTERF=1 diff --git a/ED/build/make/include.mk.bu_geo b/ED/build/make/include.mk.bu_geo index a22538eb9..26cc72970 100644 --- a/ED/build/make/include.mk.bu_geo +++ b/ED/build/make/include.mk.bu_geo @@ -40,14 +40,21 @@ USE_COLLECTIVE_MPIO=1 #--------------------------------------------------------------- -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.cannon b/ED/build/make/include.mk.cannon index 4e28cf388..f100fe8e4 100644 --- a/ED/build/make/include.mk.cannon +++ b/ED/build/make/include.mk.cannon @@ -23,13 +23,28 @@ BASE=$(ED_ROOT)/build/ # HDF5 libraries compiled with the same compiler you set for F_COMP and C_COMP. You may # # still be able to compile without HDF5 but the code is not going to run. # #------------------------------------------------------------------------------------------# -#HDF5_PATH=/n/sw/fasrcsw/apps/MPI/intel/17.0.2-fasrc01/impi/2017.2.174-fasrc01/hdf5/1.10.1-fasrc01 -HDF5_PATH=/n/home00/mlongo/Util/Modules/hdf5/1.10.2_intel +HDF5_PATH=$(HOME)/Util/Modules/hdf5/1.14.6_intel HDF5_INCS=-I$(HDF5_PATH)/include HDF5_LIBS= -lz -lm -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -42,13 +57,10 @@ USE_COLLECTIVE_MPIO=0 #################################### COMPILER SETTINGS ##################################### CMACH=ODYSSEY -#F_COMP=mpif90 -fc=ifort -#C_COMP=mpicc -cc=icc -#LOADER=mpif90 -fc=ifort FC_TYPE=INTEL -F_COMP=mpif90 -C_COMP=mpicc -LOADER=mpif90 +F_COMP=ifx +C_COMP=icx +LOADER=ifx LIBS= MOD_EXT=mod #------------------------------------------------------------------------------------------# @@ -87,58 +99,56 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ - -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ - -warn declarations -gen-interfaces -qopenmp -diag-error=all -static + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug full \ + -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -implicitnone \ + -assume byterecl -warn unused -warn uncalled -warn usage -warn declarations \ + -gen-interfaces -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ - -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ - -warn declarations -gen-interfaces -qopenmp -diag-error=all + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug full \ + -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -implicitnone \ + -assume byterecl -warn unused -warn uncalled -warn usage -warn declarations \ + -gen-interfaces -qopenmp -diag-error=all #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ - -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ - -warn interfaces -warn declarations -warn errors -qopenmp -static + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug full \ + -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -implicitnone \ + -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces \ + -warn declarations -warn errors -qopenmp -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ - -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ - -warn interfaces -warn declarations -warn errors -qopenmp + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug full \ + -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -implicitnone \ + -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces \ + -warn declarations -warn errors -qopenmp #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ - -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -qopenmp -diag-error=all -static + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug full \ + -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -implicitnone \ + -assume byterecl -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ - -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -qopenmp -diag-error=all + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug full \ + -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -implicitnone \ + -assume byterecl -qopenmp -diag-error=all #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ - -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp \ - -diag-error=all -static + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ + -ftrapuv -implicitnone -assume byterecl -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ - -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp \ - -diag-error=all + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -fpe0 -no-ftz \ + -traceback -ftrapuv -implicitnone -assume byterecl -qopenmp -diag-error=all #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl -qopenmp -static + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl -qopenmp -static C_OPTS= -O3 -DLITTLE -traceback -qopenmp -static - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl -qopenmp -static - LOADER_OPTS=-FR -O3 -recursive -traceback -assume byterecl -qopenmp + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl -qopenmp -static + LOADER_OPTS=-FR -O3 -recursive -qmkl -traceback -assume byterecl -qopenmp #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# @@ -155,8 +165,8 @@ endif MPI_PATH= PAR_INCS= PAR_LIBS= -#PAR_DEFS= -PAR_DEFS=-DRAMS_MPI +PAR_DEFS= +#PAR_DEFS=-DRAMS_MPI #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.cornell b/ED/build/make/include.mk.cornell index 9614c72d5..06ac81d1e 100644 --- a/ED/build/make/include.mk.cornell +++ b/ED/build/make/include.mk.cornell @@ -31,6 +31,22 @@ HDF5_LIBS=-L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl -lm -lz #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # diff --git a/ED/build/make/include.mk.dbg.sdumont b/ED/build/make/include.mk.dbg.sdumont index 735886808..88949d631 100644 --- a/ED/build/make/include.mk.dbg.sdumont +++ b/ED/build/make/include.mk.dbg.sdumont @@ -30,6 +30,22 @@ HDF5_LIBS=-L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5 #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -84,53 +100,54 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces \ -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ + -gen-interfaces #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl -warn unused -warn uncalled -warn usage + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -static + F_OPTS= -FR -O0 -recursive -qmkl -check all -fpe0 -no-ftz -traceback -ftrapuv \ + -fp-stack-check -implicitnone -assume byterecl -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -fpe0 -no-ftz -traceback -ftrapuv \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -fpe0 -no-ftz -traceback -ftrapuv \ -fp-stack-check -implicitnone -assume byterecl #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl -static + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl -static C_OPTS= -O3 -DLITTLE -traceback -static - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl -static - LOADER_OPTS= -FR -O3 -recursive -traceback -assume byterecl + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl -static + LOADER_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.dbg.sunhpc b/ED/build/make/include.mk.dbg.sunhpc index f19174a42..41da2f52c 100644 --- a/ED/build/make/include.mk.dbg.sunhpc +++ b/ED/build/make/include.mk.dbg.sunhpc @@ -30,6 +30,22 @@ HDF5_LIBS=-lm -L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -l #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -85,12 +101,12 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -gen-interfaces -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -gen-interfaces -qopenmp -diag-error=all @@ -98,42 +114,43 @@ ifeq ($(KIND_COMP),A) endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces \ -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ + -warn interfaces #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -static + F_OPTS= -FR -O0 -recursive -qmkl -check all -fpe0 -no-ftz -traceback -ftrapuv \ + -fp-stack-check -implicitnone -assume byterecl -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -fpe0 -no-ftz -traceback -ftrapuv \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -fpe0 -no-ftz -traceback -ftrapuv \ -fp-stack-check -implicitnone -assume byterecl #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl -static + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl -static C_OPTS= -O3 -DLITTLE -traceback -static - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl -static - LOADER_OPTS= -FR -O3 -recursive -traceback -assume byterecl + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl -static + LOADER_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.dmm b/ED/build/make/include.mk.dmm index 449f3b684..7f0055606 100644 --- a/ED/build/make/include.mk.dmm +++ b/ED/build/make/include.mk.dmm @@ -25,31 +25,26 @@ BASE=$(ED_ROOT)/build/ # Activate appropriate parts below, comment out others. -#--------------------------------------------------------------- -# If you are using a real distribution of NCAR Graphics... -#NCARG_DIR=/usr/local/ncarg-4.3.0/lib -#LIBNCARG=-L$(NCARG_DIR) -lncarg -lncarg_gks -lncarg_c -L/usr/X11R6/lib -lX11 -ldl -#--------------------------------------------------------------- - -# HDF libraries ----------------------------------------------- -# HDF4 library: Instructions to install: www.cptec.inpe.br/brams -# If you run "configure" script, you don't need to edit line bellow -#HDF_LIBS=-L.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz -# -------------------------------------------------------------- - # HDF 5 Libraries HDF5_INCS=-I/n/Moorcroft_Lab/Lab/apps/i91/lib -I/n/Moorcroft_Lab/Lab/apps/i91/include HDF5_LIBS=-L/n/Moorcroft_Lab/Lab/apps/i91/lib -lhdf5 -lm -lhdf5_fortran \ -lhdf5 -lhdf5_hl -L/n/Moorcroft_Lab/Users/mlongo/util/hdflib/hdf4_64/zlib/lib -lz -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.docker b/ED/build/make/include.mk.docker index a291b0bb2..5d428e888 100644 --- a/ED/build/make/include.mk.docker +++ b/ED/build/make/include.mk.docker @@ -15,9 +15,21 @@ HDF5_LIBS=-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi -lz -lhdf5_fortran -lhdf5 -lh #HDF5_LIBS=-lz -lhdf5_fortran -lhdf5 -lhdf5_hl USE_COLLECTIVE_MPIO=0 -# netCDF libraries -USENC=0 -NC_LIBS=-L/dev/null + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface USE_INTERF=1 diff --git a/ED/build/make/include.mk.docker.gnu b/ED/build/make/include.mk.docker.gnu index 02a5559dd..f7051965a 100644 --- a/ED/build/make/include.mk.docker.gnu +++ b/ED/build/make/include.mk.docker.gnu @@ -23,6 +23,22 @@ HDF5_LIBS= -L/usr/lib/$(shell uname -m)-linux-gnu/hdf5/openmpi -lhdf5_fortran -l #------------------------------------------------------------------------------------------# + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # # collective I/O, then use this flag = 1. Otherwise, set it to zero. # diff --git a/ED/build/make/include.mk.docker.intel b/ED/build/make/include.mk.docker.intel index 6defd47fe..ebfd603f0 100644 --- a/ED/build/make/include.mk.docker.intel +++ b/ED/build/make/include.mk.docker.intel @@ -24,6 +24,22 @@ HDF5_LIBS=-L$(HDF5_PATH)/lib -lhdf5_fortran -lhdf5_f90cstub -lhdf5_hl -lhdf5 \ -lz -lszaec -laec -lm #------------------------------------------------------------------------------------------# + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # # collective I/O, then use this flag = 1. Otherwise, set it to zero. # @@ -81,12 +97,12 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -warn declarations -gen-interfaces -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -warn declarations -gen-interfaces -qopenmp -diag-error=all -static @@ -94,12 +110,12 @@ ifeq ($(KIND_COMP),A) endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -warn interfaces -warn declarations -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -warn interfaces -warn declarations -qopenmp -diag-error=all -static @@ -107,32 +123,32 @@ ifeq ($(KIND_COMP),B) endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -qopenmp -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -qopenmp -diag-error=all -static #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp \ -diag-error=all -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ - -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -fpe0 -no-ftz \ + -traceback -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp \ -diag-error=all -static #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS=-FR -O3 -recursive -traceback -assume byterecl -qopenmp -static - C_OPTS=-O3 -DLITTLE -traceback -qopenmp -static - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl -qopenmp -static - LOADER_OPTS=-FR -O3 -recursive -traceback -assume byterecl -qopenmp -static + F_OPTS=-FR -O3 -recursive -qmkl -traceback -assume byterecl -qopenmp -static + C_OPTS=-O3 -DLITTLE -traceback -qmkl -qopenmp -static + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl -qopenmp -static + LOADER_OPTS=-FR -O3 -recursive -qmkl -traceback -assume byterecl -qopenmp -static #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.ebi b/ED/build/make/include.mk.ebi index 734137e74..28541c138 100644 --- a/ED/build/make/include.mk.ebi +++ b/ED/build/make/include.mk.ebi @@ -24,20 +24,6 @@ MAKE=/usr/bin/make BASE=$(ED_ROOT)/build/ LIBUTILS=$(BASE)/libutils-$(UTILS_VERSION)-opt.a -# Activate appropriate parts below, comment out others. - -#--------------------------------------------------------------- -# If you are using a real distribution of NCAR Graphics... -#NCARG_DIR=/usr/local/ncarg-4.3.0/lib -#LIBNCARG=-L$(NCARG_DIR) -lncarg -lncarg_gks -lncarg_c -L/usr/X11R6/lib -lX11 -ldl -#--------------------------------------------------------------- - -# HDF libraries ----------------------------------------------- -# HDF4 library: Instructions to install: www.cptec.inpe.br/brams -# If you run "configure" script, you don't need to edit line bellow -#HDF_LIBS=-L.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz -# -------------------------------------------------------------- - # HDF 5 Libraries USE_COLLECTIVE_MPIO=0 HDF5_INCS=-I/home/mdietze/hdf5-1.8.1/hdf5/include @@ -45,14 +31,20 @@ HDF5_LIBS=-L/home/mdietze/hdf5-1.8.1/hdf5/lib -lhdf5 -lm -lhdf5_fortran -lhdf5 - -lz -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.gfortran b/ED/build/make/include.mk.gfortran index 0d09c0aec..9218cfdc4 100644 --- a/ED/build/make/include.mk.gfortran +++ b/ED/build/make/include.mk.gfortran @@ -44,18 +44,25 @@ HDF5C_INCS=-I${HDF5_HOME}/include HDF5_LIBS=-lhdf5 -lhdf5_fortran -lhdf5_hl -lz USE_COLLECTIVE_MPIO=0 + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# #--------------------------------------------------------------- -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- - # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. # Interfaces usually make the compilation to crash when the diff --git a/ED/build/make/include.mk.gfortran2 b/ED/build/make/include.mk.gfortran2 index 1adc4b389..48eaa5270 100644 --- a/ED/build/make/include.mk.gfortran2 +++ b/ED/build/make/include.mk.gfortran2 @@ -76,14 +76,21 @@ USE_COLLECTIVE_MPIO=0 #--------------------------------------------------------------- -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.gnu b/ED/build/make/include.mk.gnu index 370c9bf2a..7c927e6ea 100644 --- a/ED/build/make/include.mk.gnu +++ b/ED/build/make/include.mk.gnu @@ -26,41 +26,36 @@ LIBUTILS=$(BASE)/libutils-$(UTILS_VERSION)-opt.a # Activate appropriate parts below, comment out others. -# NCAR Graphics. - -#--------------------------------------------------------------- -# If you are using a standard installation of NCAR Graphics, set: -# LOADER=ncargf90 -# in the machine-dependent sections below -#LIBNCARG= -#--------------------------------------------------------------- -# If you are using the NCAR dummy libraries... - -NCARG_DIR=$(BASE) -#LIBNCARG=-L$(NCARG_DIR) -lncarg-$(UTILS_VERSION) -lncarg_c-$(UTILS_VERSION) \ -# -lncarg_gks-$(UTILS_VERSION) -#LIBNCARG=-L$(NCARG_DIR) -lncarg-$(UTILS_VERSION) -LIBNCARG=$(BASE)/libncarg-$(UTILS_VERSION).a -#--------------------------------------------------------------- -# If you are using a real distribution of NCAR Graphics... -#NCARG_DIR=/usr/local/ncarg-4.3.0/lib -#LIBNCARG=-L$(NCARG_DIR) -lncarg -lncarg_gks -lncarg_c -L/usr/X11R6/lib -lX11 -ldl -#--------------------------------------------------------------- - -# HDF libraries------------------------------------------------- -# HDF4 library: Instructions to install: www.cptec.inpe.br/brams -# If you run "configure" script, you don't need to edit line bellow -HDF_LIBS=-L./.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz -# -------------------------------------------------------------- - -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=.TRUE. and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=.FALSE. and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=.FALSE. -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# HDF5 libraries # +# # +# Since ED-2.1, this is no longer optional for real simulations. You must have HDF5 # +# libraries compiled with the same compiler you set for F_COMP and C_COMP. You may still # +# be able to compile without HDF5 but it will not run. # +#------------------------------------------------------------------------------------------# +ZLIB_PATH=/usr/local +HDF5_PATH=/usr/local +HDF5_INCS=-I$(HDF5_PATH)/include +HDF5C_INCS=$(HDF5_INCS) +HDF5_LIBS=-L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5_fortran -lhdf5 -lhdf5_hl +#------------------------------------------------------------------------------------------# + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # MPI_Wtime. --------------------------------------------------- # If USE_MPIWTIME=1, then it will use MPI libraries to compute diff --git a/ED/build/make/include.mk.gnu-odyssey b/ED/build/make/include.mk.gnu-odyssey index b9ad5404a..2fd570fb8 100644 --- a/ED/build/make/include.mk.gnu-odyssey +++ b/ED/build/make/include.mk.gnu-odyssey @@ -26,6 +26,22 @@ HDF5_LIBS= -lz -lm -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/n/home00/mlongo/Util/Modules/lapack/3.12.0_gnu +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # # collective I/O, then use this flag = 1. Otherwise, set it to zero. # diff --git a/ED/build/make/include.mk.intel b/ED/build/make/include.mk.intel index b110fa806..a2c185086 100644 --- a/ED/build/make/include.mk.intel +++ b/ED/build/make/include.mk.intel @@ -30,6 +30,22 @@ HDF5_LIBS= -lz -lm -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5_hl #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/n/home00/mlongo/Util/Modules/lapack/3.12.0_intel +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # diff --git a/ED/build/make/include.mk.jpl b/ED/build/make/include.mk.jpl index 66a1fcf31..f1dbdee29 100644 --- a/ED/build/make/include.mk.jpl +++ b/ED/build/make/include.mk.jpl @@ -30,6 +30,22 @@ HDF5_LIBS= -lm -L$(ZLIB_PATH) -lz -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/home/mlongo/Util/Modules/lapack/3.12.0_intel +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # diff --git a/ED/build/make/include.mk.macos_homebrew b/ED/build/make/include.mk.macos_homebrew index 0473fa1f4..f58b45fce 100644 --- a/ED/build/make/include.mk.macos_homebrew +++ b/ED/build/make/include.mk.macos_homebrew @@ -30,6 +30,37 @@ HDF5_LIBS=-L$(BREW_PREFIX)/lib -lhdf5_fortran -lhdf5 -lhdf5_hl -lz #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# HDF5 libraries # +# # +# Since ED-2.1, this is no longer optional for real simulations. You must have HDF5 # +# libraries compiled with the same compiler you set for F_COMP and C_COMP. You may still # +# be able to compile without HDF5 but it will not run. # +#------------------------------------------------------------------------------------------# +ZLIB_PATH=/usr/local +HDF5_PATH=/usr/local +HDF5_INCS=-I$(HDF5_PATH)/include +HDF5C_INCS=$(HDF5_INCS) +HDF5_LIBS=-L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5_fortran -lhdf5 -lhdf5_hl +#------------------------------------------------------------------------------------------# + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # # collective I/O, then use this flag = 1. Otherwise, set it to zero. # diff --git a/ED/build/make/include.mk.macosx b/ED/build/make/include.mk.macosx index cae11ddb9..87d016cee 100644 --- a/ED/build/make/include.mk.macosx +++ b/ED/build/make/include.mk.macosx @@ -28,6 +28,22 @@ HDF5_LIBS=-L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5_fortran -lhdf5 -lhdf5 #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=$(HOMEBREW_PREFIX)/opt/lapack +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # # collective I/O, then use this flag = 1. Otherwise, set it to zero. # @@ -37,7 +53,6 @@ USE_COLLECTIVE_MPIO=0 - #------------------------------------------------------------------------------------------# # This should be 1 unless you are running with -gen-interfaces. Interfaces usually # # make the compilation to crash when the -gen-interfaces option are on, so this flag # diff --git a/ED/build/make/include.mk.ncsa b/ED/build/make/include.mk.ncsa index 1789d7424..d4cbab4d0 100644 --- a/ED/build/make/include.mk.ncsa +++ b/ED/build/make/include.mk.ncsa @@ -47,14 +47,20 @@ USE_COLLECTIVE_MPIO=0 #--------------------------------------------------------------- -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.nec b/ED/build/make/include.mk.nec index 19dbfd100..de77fdcb7 100644 --- a/ED/build/make/include.mk.nec +++ b/ED/build/make/include.mk.nec @@ -47,20 +47,32 @@ LIBNCARG=$(BASE)/libncarg-$(UTILS_VERSION).a #LIBNCARG=-L$(NCARG_DIR) -lncarg -lncarg_gks -lncarg_c -L/usr/X11R6/lib -lX11 -ldl #--------------------------------------------------------------- -# HDF libraries------------------------------------------------- -# HDF4 library: Instructions to install: www.cptec.inpe.br/brams -# If you run "configure" script, you don't need to edit line bellow -HDF_LIBS=-L./.hdf4_libs -lmfhdf -ldf -lz -ljpeg -lsz -# -------------------------------------------------------------- - -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=.TRUE. and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=.FALSE. and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=.FALSE. -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# HDF5 libraries # +# # +# Since ED-2.1, this is no longer optional for real simulations. You must have HDF5 # +# libraries compiled with the same compiler you set for F_COMP and C_COMP. You may still # +# be able to compile without HDF5 but it will not run. # +#------------------------------------------------------------------------------------------# +ZLIB_PATH=/usr/local +HDF5_PATH=/usr/local +HDF5_INCS=-I$(HDF5_PATH)/include +HDF5C_INCS=$(HDF5_INCS) +HDF5_LIBS=-L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5_fortran -lhdf5 -lhdf5_hl +#------------------------------------------------------------------------------------------# + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# compile the code with the Math Kernel Library option instead (-mkl or -qmkl depending on # +# the ifort/icc version). Otherwise, provide the path to Lapack installation. # +#------------------------------------------------------------------------------------------# # MPI_Wtime. diff --git a/ED/build/make/include.mk.pecan2 b/ED/build/make/include.mk.pecan2 index e63fe2494..9ea14c65d 100644 --- a/ED/build/make/include.mk.pecan2 +++ b/ED/build/make/include.mk.pecan2 @@ -48,14 +48,24 @@ USE_COLLECTIVE_MPIO=0 #--------------------------------------------------------------- -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- + + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/fs/data2/rykelly/local +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.pgi b/ED/build/make/include.mk.pgi index 7cadc0dfd..4c2a3e877 100644 --- a/ED/build/make/include.mk.pgi +++ b/ED/build/make/include.mk.pgi @@ -59,15 +59,20 @@ USE_COLLECTIVE_MPIO=0 #--------------------------------------------------------------- - -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS=-L/dev/null -# -------------------------------------------------------------- +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/opt/lapack/X.X.X/ompi-tcp-gnu41 +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # interface ---------------------------------------------------- # This should be 1 unless you are running with -gen-interfaces. diff --git a/ED/build/make/include.mk.sdumont b/ED/build/make/include.mk.sdumont index 2d27a5ad7..0142084ad 100644 --- a/ED/build/make/include.mk.sdumont +++ b/ED/build/make/include.mk.sdumont @@ -30,6 +30,22 @@ HDF5_LIBS=-L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -lhdf5 #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -83,12 +99,12 @@ ifeq ($(KIND_COMP),) endif ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -gen-interfaces -qopenmp -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -gen-interfaces -qopenmp @@ -96,12 +112,12 @@ ifeq ($(KIND_COMP),A) endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -warn interfaces -qopenmp -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ -warn interfaces -qopenmp @@ -109,30 +125,30 @@ ifeq ($(KIND_COMP),B) endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -qopenmp -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -g -debug extended \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -g -debug extended \ -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ -implicitnone -assume byterecl -qopenmp #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ + F_OPTS= -FR -O0 -recursive -qmkl -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp -static C_OPTS= -O0 -DLITTLE -g -traceback -qopenmp -static - LOADER_OPTS=-FR -O0 -recursive -check all,noarg_temp_created -fpe0 -no-ftz -traceback \ - -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all,noarg_temp_created -fpe0 -no-ftz \ + -traceback -ftrapuv -fp-stack-check -implicitnone -assume byterecl -qopenmp #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl -qopenmp -static + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl -qopenmp -static C_OPTS= -O3 -DLITTLE -traceback -qopenmp -static - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl -qopenmp -static - LOADER_OPTS=-FR -O3 -recursive -traceback -assume byterecl -qopenmp + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl -qopenmp -static + LOADER_OPTS=-FR -O3 -recursive -qmkl -traceback -assume byterecl -qopenmp #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.sunhpc b/ED/build/make/include.mk.sunhpc index 64d5f00cd..7d6ce8280 100644 --- a/ED/build/make/include.mk.sunhpc +++ b/ED/build/make/include.mk.sunhpc @@ -30,6 +30,22 @@ HDF5_LIBS=-lm -L$(ZLIB_PATH)/lib -lz -L$(HDF5_PATH)/lib -lhdf5 -lhdf5_fortran -l #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # @@ -84,54 +100,56 @@ endif #------------------------------------------------------------------------------------------# ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces \ -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ + -gen-interfaces #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces \ -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl -warn unused -warn uncalled -warn usage -warn interfaces + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage \ + -warn interfaces #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),C) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ - -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ - -assume byterecl + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -g -debug extended \ + -debug-parameters used -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ + -implicitnone -assume byterecl #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O0 -recursive -check all -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check \ - -implicitnone -assume byterecl -static + F_OPTS= -FR -O0 -recursive -qmkl -check all -fpe0 -no-ftz -traceback -ftrapuv \ + -fp-stack-check -implicitnone -assume byterecl -static C_OPTS= -O0 -DLITTLE -g -traceback -static - LOADER_OPTS=-FR -O0 -recursive -check all -fpe0 -no-ftz -traceback -ftrapuv \ + LOADER_OPTS=-FR -O0 -recursive -qmkl -check all -fpe0 -no-ftz -traceback -ftrapuv \ -fp-stack-check -implicitnone -assume byterecl #---------------------------------------------------------------------------------------# endif ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl -static + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl -static C_OPTS= -O3 -DLITTLE -traceback -static - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl -static - LOADER_OPTS= -FR -O3 -recursive -traceback -assume byterecl + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl -static + LOADER_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.travisci b/ED/build/make/include.mk.travisci index 35ade16d0..a287660da 100644 --- a/ED/build/make/include.mk.travisci +++ b/ED/build/make/include.mk.travisci @@ -29,6 +29,22 @@ HDF5_LIBS=-lz -L/usr/lib/x86_64-linux-gnu/hdf5/openmpi -lhdf5 -lhdf5_fortran -lh #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/usr/local +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# + + #------------------------------------------------------------------------------------------# # If you have a version of hdf5 compiled in parallel, then you may benefit from # diff --git a/ED/build/make/include.mk.ugent b/ED/build/make/include.mk.ugent index 2fbaf4e2d..348134163 100644 --- a/ED/build/make/include.mk.ugent +++ b/ED/build/make/include.mk.ugent @@ -37,6 +37,22 @@ endif #------------------------------------------------------------------------------------------# +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH= +LAPACK_INCS= +LAPACK_LIBS= +#------------------------------------------------------------------------------------------# + + #################################### COMPILER SETTINGS ##################################### CMACH=PC_INTEL @@ -83,15 +99,15 @@ endif ################################# DEBUG BUILD ######################################### ifeq ($(KIND_COMP),A) USE_INTERF=0 - F_OPTS= -FR -O0 -check -g -debug extended -debug-parameters -traceback -ftrapuv -u \ - -fp-stack-check -assume byterecl -warn unused -warn uncalled -gen-interfaces + F_OPTS= -FR -O0 -qmkl -check -g -debug extended -debug-parameters -traceback -ftrapuv \ + -u -fp-stack-check -assume byterecl -warn unused -warn uncalled -gen-interfaces C_OPTS= -O0 -g -traceback #---------------------------------------------------------------------------------------# endif ############################ LEGACY DEBUG BUILD ######################################### ifeq ($(KIND_COMP),B) USE_INTERF=0 - F_OPTS= -FR -O0 -recursive -check all -g -debug extended -debug-parameters used \ + F_OPTS= -FR -O0 -recursive -qmkl -check all -g -debug extended -debug-parameters used \ -fpe0 -no-ftz -traceback -ftrapuv -fp-stack-check -implicitnone \ -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces C_OPTS= -O0 -DLITTLE -g -traceback @@ -100,33 +116,33 @@ endif ######################## DEBUG BUILD WITH INTEL PROFILING ############################### ifeq ($(KIND_COMP),C) USE_INTERF=0 - F_OPTS= -O0 -check -g -prof-gen=srcpos -debug extended -debug-parameters -traceback -u \ - -ftrapuv -fp-stack-check -assume byterecl -gen-interfaces + F_OPTS= -O0 -qmkl -check -g -prof-gen=srcpos -debug extended -debug-parameters \ + -traceback -u -ftrapuv -fp-stack-check -assume byterecl -gen-interfaces C_OPTS= -O0 -g -traceback #---------------------------------------------------------------------------------------# endif ############################### LEGACY OPTIMIZED BUILD #################################### ifeq ($(KIND_COMP),D) USE_INTERF=1 - F_OPTS= -FR -O3 -recursive -traceback -assume byterecl + F_OPTS= -FR -O3 -recursive -qmkl -traceback -assume byterecl C_OPTS= -O3 -DLITTLE -traceback - F_LOWO_OPTS=-FR -O2 -recursive -traceback -assume byterecl + F_LOWO_OPTS=-FR -O2 -recursive -qmkl -traceback -assume byterecl #---------------------------------------------------------------------------------------# endif ###################################### OPTIMIZED BUILD ################################## ifeq ($(KIND_COMP),E) USE_INTERF=1 - F_OPTS= -O3 -xHost -g -assume byterecl + F_OPTS= -O3 -xHost -qmkl -g -assume byterecl C_OPTS= -O3 -xHost -g - F_LOWO_OPTS= -O2 -xHost -g + F_LOWO_OPTS= -O2 -xHost -qmkl -g #---------------------------------------------------------------------------------------# endif ########################### OPTIMIZED BUILD WITH OpenMP ################################# ifeq ($(KIND_COMP),F) USE_INTERF=1 - F_OPTS= -O3 -xHost -g -assume byterecl -qopenmp - C_OPTS= -O3 -xHost -g -qopenmp - F_LOWO_OPTS= -O2 -xHost -g -qopenmp + F_OPTS= -O3 -xHost -qmkl -g -assume byterecl -qopenmp + C_OPTS= -O3 -xHost -qmkl -g -qopenmp + F_LOWO_OPTS= -O2 -xHost -qmkl -g -qopenmp #---------------------------------------------------------------------------------------# endif #------------------------------------------------------------------------------------------# diff --git a/ED/build/make/include.mk.xlf b/ED/build/make/include.mk.xlf index a60ee150e..67ea65d42 100644 --- a/ED/build/make/include.mk.xlf +++ b/ED/build/make/include.mk.xlf @@ -61,14 +61,21 @@ HDF5_LIBS=-lz /sw/hdf5-1.8.0-xlf/lib/libhdf5_fortran.a \ /sw/hdf5-1.8.0-xlf/lib/libhdf5_hl.a -# netCDF libraries --------------------------------------------- -# If you have netCDF set USENC=1 and type the lib folder -# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib). -# If you don't have it, leave USENC=0 and type a dummy -# folder for NC_LIBS (e.g. -L/dev/null or leave it blank) -USENC=0 -NC_LIBS= -# -------------------------------------------------------------- + +#------------------------------------------------------------------------------------------# +# Linear Algebra Package (LAPACK) libraries. # +# # +# Lapack is a well-established package for solving linear systems in Fortran. This is # +# more efficient than the former built-in solution, and thus it became the new default. # +# # +# For those compiling the code with Intel compilers (ifort/icc), leave these empty and # +# add -qmkl to F_OPTS and LOADER_OPTS instead. Otherwise, provide the path to Lapack # +# installation. # +#------------------------------------------------------------------------------------------# +LAPACK_PATH=/sw/lapack-X.X.X +LAPACK_INCS=-I$(LAPACK_PATH)/include +LAPACK_LIBS=-L$(LAPACK_PATH)/lib -llapack -lblas +#------------------------------------------------------------------------------------------# # MPI_Wtime. diff --git a/ED/src/dynamics/multiple_scatter.f90 b/ED/src/dynamics/multiple_scatter.f90 index c04727163..c8b26ad29 100644 --- a/ED/src/dynamics/multiple_scatter.f90 +++ b/ED/src/dynamics/multiple_scatter.f90 @@ -65,7 +65,8 @@ subroutine lw_multiple_scatter(grnd_emiss4,grnd_temp4,rlong_top4,ncoh,pft,lai,wa integer :: i2p1 integer :: i2m1 integer :: i2p2 - logical :: sing + integer :: info + integer , dimension(2*ncoh+2) :: pivot real(kind=8), dimension(ncoh) :: locetai real(kind=8), dimension(ncoh) :: elai real(kind=8), dimension(ncoh) :: etai @@ -274,12 +275,14 @@ subroutine lw_multiple_scatter(grnd_emiss4,grnd_temp4,rlong_top4,ncoh,pft,lai,wa !------------------------------------------------------------------------------------! - ! Solve the linear system. In the future we could use a tridiagonal solver, ! - ! which is a lot cheaper than the regular Gauss elimination, but for the time being, ! - ! we go with a tested method. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand side ! + ! vector with the solution, so we first copy the right hand side to the output ! + ! vector. ! !------------------------------------------------------------------------------------! - call lisys_solver8(nsiz,amat,cvec,lwvec,sing) - if (sing) then + lwvec(:) = cvec(:) + call dgesv(nsiz,1,amat,nsiz,pivot,lwvec,nsiz,info) + if (info > 0) then call fatal_error('LW radiation failed... The matrix is singular!' & ,'lw_multiple_scatter','multiple_scatter.f90') end if @@ -458,7 +461,8 @@ subroutine sw_multiple_scatter(grnd_alb_par4,grnd_alb_nir4,cosaoi4,nir_beam_norm integer :: i2p1 integer :: i2m1 integer :: i2p2 - logical :: sing + integer :: info + integer , dimension(2*ncoh+2) :: pivot real(kind=8) :: alb_par real(kind=8) :: alb_nir real(kind=8) :: mu @@ -805,12 +809,14 @@ subroutine sw_multiple_scatter(grnd_alb_par4,grnd_alb_nir4,cosaoi4,nir_beam_norm !---------------------------------------------------------------------------------! - ! Solve the linear system. In the future we could use a tridiagonal ! - ! solver, which is a lot cheaper than the regular Gauss elimination, but for the ! - ! time being, we go with a tested method. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand ! + ! side vector with the solution, so we first copy the right hand side to the ! + ! output vector. ! !---------------------------------------------------------------------------------! - call lisys_solver8(nsiz,amat,cvec,swvec,sing) - if (sing) then + swvec(:) = cvec(:) + call dgesv(nsiz,1,amat,nsiz,pivot,swvec,nsiz,info) + if (info > 0) then call fatal_error('SW radiation failed... The matrix is singular!' & ,'sw_multiple_scatter','multiple_scatter.f90') end if diff --git a/ED/src/dynamics/twostream_rad.f90 b/ED/src/dynamics/twostream_rad.f90 index b016eebb7..30088ddba 100644 --- a/ED/src/dynamics/twostream_rad.f90 +++ b/ED/src/dynamics/twostream_rad.f90 @@ -70,7 +70,8 @@ subroutine lw_two_stream(grnd_emiss4,grnd_temp4,rlong_top4,ncoh,pft,lai,wai,cai integer :: i2p1 integer :: i2m1 integer :: i2p2 - logical :: sing + integer :: info + integer , dimension(2*ncoh+2) :: pivot real(kind=8), dimension(ncoh+1) :: black real(kind=8), dimension(ncoh+1) :: expl_plus real(kind=8), dimension(ncoh+1) :: expl_minus @@ -284,12 +285,14 @@ subroutine lw_two_stream(grnd_emiss4,grnd_temp4,rlong_top4,ncoh,pft,lai,wai,cai !------------------------------------------------------------------------------------! - ! Solve the linear system. In the future we could use a band diagonal solver, ! - ! which is a lot cheaper than the regular Gauss elimination, but for the time being, ! - ! we go with a tested method. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand side ! + ! vector with the solution, so we first copy the right hand side to the output ! + ! vector. ! !------------------------------------------------------------------------------------! - call lisys_solver8(nsiz,mmat,yvec,xvec,sing) - if (sing) then + xvec(:) = yvec(:) + call dgesv(nsiz,1,mmat,nsiz,pivot,xvec,nsiz,info) + if (info > 0) then call fatal_error('LW radiation failed... The matrix is singular!' & ,'lw_two_stream','twostream_rad.f90') end if @@ -437,7 +440,8 @@ subroutine sw_two_stream(grnd_alb_par4,grnd_alb_nir4,cosaoi4,nir_beam_norm integer :: i2p1 integer :: i2m1 integer :: i2p2 - logical :: sing + integer :: info + integer , dimension(2*ncoh+2) :: pivot real(kind=4), dimension(ncoh) :: nir_beam_flip real(kind=4), dimension(ncoh) :: nir_diff_flip real(kind=8), dimension(ncoh+1) :: expl_plus @@ -783,12 +787,14 @@ subroutine sw_two_stream(grnd_alb_par4,grnd_alb_nir4,cosaoi4,nir_beam_norm !---------------------------------------------------------------------------------! - ! Solve the linear system. In the future we could use a tridiagonal ! - ! solver, which is a lot cheaper than the regular Gauss elimination, but for the ! - ! time being, we go with a tested method. ! + ! Solve the linear system. We invoke the Linear Algebra Package (LAPACK) ! + ! procedure for solving the system efficiently. LAPACK rewrites the right hand ! + ! side vector with the solution, so we first copy the right hand side to the ! + ! output vector. ! !---------------------------------------------------------------------------------! - call lisys_solver8(nsiz,mmat,yvec,xvec,sing) - if (sing) then + xvec(:) = yvec(:) + call dgesv(nsiz,1,mmat,nsiz,pivot,xvec,nsiz,info) + if (info > 0) then call fatal_error('SW radiation failed... The matrix is singular!' & ,'sw_two_stream','twostream_rad.f90') end if diff --git a/ED/src/utils/numutils.f90 b/ED/src/utils/numutils.f90 index e8930d092..422ed089c 100644 --- a/ED/src/utils/numutils.f90 +++ b/ED/src/utils/numutils.f90 @@ -424,121 +424,6 @@ end subroutine cumsum - - - -!==========================================================================================! -!==========================================================================================! -! This subroutine is the double precision version of the linear system solver above. ! -! It will solve the linear system AA . X = Y for given AA and Y, using the Gaussian ! -! elimination method with partial pivoting and back-substitution. This subroutine builds ! -! on the algorithm described in P92, but adopting a vector-based approach compatible with ! -! modern Fortran. ! -! ! -! Press, W. H., S. A. Teukolsky, W. T. Vetterling, B. P. Flannery: 1992. Numerical recipes ! -! in Fortran 77. Cambridge University Press (P92). ! -!------------------------------------------------------------------------------------------! -subroutine lisys_solver8(nsiz,AA,Y,X,sing) - implicit none - !----- Arguments. ----------------------------------------------------------------------! - integer , intent(in) :: nsiz ! matrix and vector size - real(kind=8), dimension(nsiz,nsiz), intent(in) :: AA ! matrix - real(kind=8), dimension(nsiz) , intent(in) :: Y ! right-hand side vector - real(kind=8), dimension(nsiz) , intent(out) :: X ! unknown vector - logical , intent(out) :: sing ! The matrix was singular [T|F] - !----- Local variables. ----------------------------------------------------------------! - real(kind=8), dimension(nsiz,nsiz) :: EE ! Copy of AA, for elimination. - real(kind=8), dimension(nsiz) :: Z ! Copy of Y, for scaling - real(kind=8), dimension(nsiz) :: dumvec ! Dummy vector (row swapping) - real(kind=8) :: pivot ! The pivot - real(kind=8) :: multip ! Multiplier - integer :: r ! Row index - integer :: b ! Row below index - integer :: p ! Pivot index - real(kind=8) :: dumsca ! Dummy scalar (row swapping) - !----- Local parameters. ---------------------------------------------------------------! - real(kind=8) , parameter :: tinyoff=1.d-20 - !---------------------------------------------------------------------------------------! - - !----- First thing, we copy AA to EE and Y to Z. ---------------------------------------! - EE(:,:) = AA(:,:) - Z (:) = Y (:) - dumvec = 0.d0 - dumsca = 0.d0 - !---------------------------------------------------------------------------------------! - ! We initialise X with a huge, non-sense value, which will become the answer when ! - ! the matrix is singular. ! - !---------------------------------------------------------------------------------------! - X (:) = -huge(1.d0) - !----- We first assume that everything will be fine. -----------------------------------! - sing = .false. - - !---------------------------------------------------------------------------------------! - ! 1. Main elimination loop, done row by row. ! - !---------------------------------------------------------------------------------------! - elimloop: do r = 1, nsiz-1 - !------ 1a. Finding the largest element, which will become our pivot ----------------! - p = (r-1) + maxloc(abs(EE(r:nsiz,r)),dim=1) - - pivot = maxval(abs(EE(r:nsiz,r))) - !------------------------------------------------------------------------------------! - ! 1b. Check the pivot and make sure it is a good one. If not, then this matrix is ! - ! singular or almost singular, and we cannot solve it, so we switch the flag and ! - ! return. ! - !------------------------------------------------------------------------------------! - if (pivot < tinyoff) then - sing = .true. - return - end if - - !----- 1c. If the best pivot is not the current row, we must swap them. -------------! - if (p /= r) then - dumvec(r:nsiz) = EE(r,r:nsiz) - dumsca = Z(r) - EE(r,r:nsiz) = EE(p,r:nsiz) - Z(r) = Z(p) - EE(p,r:nsiz) = dumvec(r:nsiz) - Z(p) = dumsca - end if - - !------------------------------------------------------------------------------------! - ! 1d. Eliminate rows below, everything to the left of the (,r) column will become ! - ! zero (we won't compute that, but they will be.). ! - !------------------------------------------------------------------------------------! - belowloop: do b=r+1,nsiz - multip = EE(b,r)/EE(r,r) - EE(b,r:nsiz) = EE(b,r:nsiz) - multip * EE(r,r:nsiz) - Z(b) = Z(b) - multip * Z(r) - end do belowloop - end do elimloop - - !---------------------------------------------------------------------------------------! - ! 2. We may be unlucky and discover that the matrix is singular at the last line, so we ! - ! check the last pivot too. ! - !---------------------------------------------------------------------------------------! - if (abs(EE(nsiz,nsiz)) < tinyoff) then - sing = .true. - return - end if - - !---------------------------------------------------------------------------------------! - ! 3. We now perform the back-substitution, to find the solution. ! - !---------------------------------------------------------------------------------------! - X(nsiz) = Z(nsiz) / EE(nsiz,nsiz) - backsubloop: do r=nsiz-1,1,-1 - b = r+1 - X(r) = (Z(r) - sum(EE(r,b:nsiz)*x(b:nsiz))) / EE(r,r) - end do backsubloop - - return -end subroutine lisys_solver8 -!==========================================================================================! -!==========================================================================================! - - - - - !==========================================================================================! !==========================================================================================! ! EIFUN8 -- This function computes the exponential integral function, defined by !