[Mesa-users] MESA with intel compilers

Warrick Ball W.H.Ball at bham.ac.uk
Mon Apr 29 03:27:54 EDT 2019


Hi Phil,

I've attached a `utils/makefile_header` that I just used to build r11554. 
I'm using ifort 18.0.1 and I had to set the optimisation flag to -O1 
(rather than -O2, as distributed).  My University cluster provides 
packages and libraries with the Environment Modules system, so I get a 
convenient environment variable for the locations of the HDF5 libraries.

I just tried building with ifort 17.0.1, 16.0.1 and 15.0.2 instead with 
the same `makefile_header` and `crlibm` built fine.  Could you attach your 
`makefile_header` and `build.log` after a top-level `./touch`?  In all 
three cases GCC is version 5.4.0.

Regarding the optimisation flag, most of MESA builds OK with -O2 but the 
`star` module fails its unit test.  The small test evolutionary run just 
never seems to converge on a model and I've never really had the time to 
work out why.  I accidentally did a mixed build of -O2 in the modules and 
-O1 in `star` last week.  That passed on *nearly* the whole test suite.* 
The long and short is that if you're only using some of the modules, you 
can possibly try your like with -O2 but know that the modules are 
currently only integration-tested with -O1.

I did spend some time building different files in `star` with different 
optimisation flags and seeing when `star`'s unit test passed and it looks 
like `star/private/star_bcyclic.f90` might be where the -O2 vs -O1 problem 
comes in.  But even if that were fixed it also looks like something in 
another module causes the few test case failures.*

Cheers,
Warrick

* For interested readers, the test cases that failed in my 
accidentally-mixed build were

25M_pre_ms_to_core_collapse
black_hole
example_make_pre_ccsn
split_burn_20M_si_burn_qp
split_burn_big_net_30M
split_burn_big_net_30M_logT_9.8





------------
Warrick Ball
Postdoc, School of Physics and Astronomy
University of Birmingham, Edgbaston, Birmingham B15 2TT
W.H.Ball at bham.ac.uk
+44 (0)121 414 4552


On Sat, 27 Apr 2019, Philip Chang wrote:

> Hello All,
>
> I heard a rumor recently that someone in the mesa community has gotten
> recent versions of mesa to compile with the intel compiler.\A0 Up to now I
> have been compiling mesa with gcc (no supplied by the mesasdk) to
> crosslink it with my moving-mesh code.\A0 This isn't perfect as mesa does
> not build all the way with compilers not in the sdk, but does build
> mesaeos which is all I need.
>
> I have gotten some limited progress with the intel compiler -- before it
> was failing on crlibm.\A0 Now it get by, but fails on a bad test
> comparison in crlibm. If any can tell me their secret sauce on compiling
> with the intel compilers, I would be really grateful.
>
> Cheers,
>
> Phil
>
> _______________________________________________
> mesa-users at lists.mesastar.org
> https://lists.mesastar.org/mailman/listinfo/mesa-users
-------------- next part --------------
#!/bin/bash


# NOTE: MESA is no longer supported on 32-bit systems.  This isn't by design;
# we simply haven't been able to get it to work!  So if you really-really want 
# to use an antique 32-bit system for mesa, you'll have to try to make it work yourself.
# But I think you'd be better off switching to a 64-bit machine.

# Step 0) Check if you have set the correct environment variables

ifndef MESA_DIR
ifndef MESA_DIR_INTENTIONALLY_EMPTY
$(error MESA_DIR enviroment variable is not set)
endif
endif

# step 1) specify your compilers

# NOTE: recent versions of mesa have required reduced optimization 
# in order to work with ifort; we suggest using gfortran instead of ifort if possible.

CC = gcc
FC = ifort

#FC = gfortran


# if you need special flags for the compiler, define them here:
SPECIAL_FC_FLAGS = 
SPECIAL_C_FLAGS   = 

# step 1.a) [temporary workaround for loader problem on Mac:] 
#           go down to select the correct entry for LOAD_MATRIX 
#           depending on whether you are on Linux or Mac 

# step 2) specify whether isnan is supported or not

# pick one of the following options:

UTILS_ISNAN = utils_isnan_okay
#UTILS_ISNAN = utils_isnan_nope

# If you aren't sure, try setting UTILS_ISNAN = utils_isnan_okay
# If this works, great.  Otherwise, the compilation of the
# mesa/utils module will complain when it tries to invoke isnan.
# In case that happens, you can simply change this makefile_header
# to the UTILS_ISNAN = utils_isnan_nope setting and redo the
# ./install command for mesa.


# step 3) specify which BLAS and LAPACK libraries to use for mesa/mtx

# these are the standard defaults
WHICH_LAPACK = USE_SRCS
LOAD_LAPACK = -lmesalapack
WHICH_BLAS = USE_SRCS
LOAD_BLAS = -lmesablas
MKL_INCLUDE = 

# step 4) do you want to use PGPLOT with mesa/star?                                                                                     
# you can have onscreen plots updated at each step,                                                                                     
# and you can save files for making movies.  very cool!                                                                                 

# NOTE: you need to have a PGPLOT built using the same fortran and c compiler as you                                                    
# are using for mesa.                                                                                                                   

# if you don't already have a compatible pgplot,                                                                                         
# follow the instructions in pgplot/README                                                                                               

# to access pgplot from mesa/star,                                                                                                       
# set USE_PGSTAR = YES and set LOAD_PGPLOT to load the libraries.                                                                       
# in mesa/star, set the control parameter pgstar_flag = .true. in &star_job                                                             
# when you run star it will open a window using X and draw plots using PGSTAR                                                           
# the plots will be updated each time a log entry is made.                                                                               
# see star/test/src/pgstar_defaults.dek for details.                                                                                     

# NOTE: if you have libpng, then include '-lpng' in the LOAD_PGPLOT line.                                                               
# the *.png files are excellent for making movies.                                                                                       
# but if you don't have libpng and can't get it, no problem; it isn't required.                                                         
# just remove '-lpng' from the LOAD_PGPLOT line.                                                                                         

# Similarly, if you don't have X windows and don't want to make onscreen plots,                                                         
# then you can load PGPLOT without it.  Just delete the X stuff from LOAD_PGPLOT.                                                       

# for users of Red Hat OS: Georgios Magkotsios reports success with these settings:                                                     
#LOAD_PGPLOT = -L${PGPLOT_DIR} -lpgplot -L/usr/lib64 -lX11 -lsvml -lpng                                                                 
#FCstatic = -shared-intel #-Bstatic -static-intel                                                                                       

# for Ubuntu, Philip Pinto found these libraries to be necessary:                                                                       
#LOAD_PGPLOT = -L${PGPLOT_DIR} -lpgplot  -lX11 -lxcb -lXau -lXdmcp -lXext -lpng -lz                                                    

# for Fedora 12 (x86_64), Mike Zingale reported that the following worked                                                               
# 1. at the terminal:                                                                                                                   
#  yum install pgplot pgplot-devel                                                                                                       
# 2. in the mesa/util/makefile_header                                                                                                   
# USE_PGSTAR = YES                                                                                                                       
# LOAD_PGPLOT = -lpgplot -L/usr/lib64 -lX11 -lpng                                                                                       
# 3. it is also important that the following environment variable be set:                                                               
# export PGPLOT_DIR=/usr/share/pgplot/  


# NOTE: a change in USE_PGSTAR doesn't take effect until you next recompile mesa/star

# for now, GYRE is only available with the mesasdk 
USE_GYRE = NO

# See http://www.gnu.org/software/make/manual/make.html#Testing-Flags for findstring
ifneq (,$(findstring ifort,$(FC)))

USE_PGSTAR = NO
LOAD_PGPLOT = 

#USE_PGSTAR = YES
#LOAD_PGPLOT = -L/Users/bpaxton/mesa/utils/pgplot -lpgplot -L/usr/X11R6/lib -lX11 -lpng
#LOAD_PGPLOT = -L/rpod2/opt/pgplot -lpgplot -L/usr/X11R6/lib -lX11 -lpng

else
ifneq (,$(findstring gfortran,$(FC)))

USE_PGSTAR = NO
LOAD_PGPLOT = 
# USE_PGSTAR = YES
# LOAD_PGPLOT = -L/Users/bpaxton/mesa/utils/pgplot_gfortran -lpgplot -L/usr/X11R6/lib -lX11 -lpng

else

USE_PGSTAR = NO
LOAD_PGPLOT = 

endif
endif





# step 5) Load options for HDF5, this must be compiled with the same compilier as mesa

# To install hdf5 in $MESA_DIR/utils with ifort run:
#export CC=icc
#export F9X=ifort
#export CXX=icpc
#export VERSION=1.8.17
#cd $MESA_DIR/utils
#rm -rf hdf5* 2>/dev/null
#wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${VERSION%.*}/hdf5-"$VERSION"/src/hdf5-"$VERSION".tar.bz2
#tar xvf hdf5-"$VERSION".tar.bz2
#cd hdf5-"$VERSION"
#CCFLAGS=-D_Float128=__float128 FCFLAGS="-D_Float128=__float128" ./configure --enable-fortran --enable-fortran2003
#make
#make install
#cd $MESA_DIR

#
#
# and set in this makefile
# LOAD_HDF5 = -L${MESA_DIR}/utils/hdf5/lib -lhdf5_fortran -lhdf5 -lz
# INCLUDE_HDF5 = -I${MESA_DIR}/utils/hdf5/include
#
# And in your shell
# export LD_LIBRARY_PATH=$MESA_DIR/utils/hdf5/lib:$LD_LIBRARY_PATH

# These are if you are using the sdk hdf5 implementation
# LOAD_HDF5 = `mesasdk_hdf5_link`
# INCLUDE_HDF5 = -I${MESASDK_ROOT}/include

# If not YES then we don't use HDF5, thus you wont have access to custom weak rates
# Also the rates test suite will not pass so do: /usr/bin/touch $MESA_DIR/rates/skip_test
# if you change this option
USE_HDF5 = YES
LOAD_HDF5 = -L${HDF5_DIR}/lib -lhdf5_fortran -lhdf5 -lz
INCLUDE_HDF5 = -I${HDF5_DIR}/include


# step 6) now do the mesa install

USE_OPENMP = YES

USE_STUB_FOR_CRLIBM = NO

# step 7) Build shared libraries? Needed if you want mesa to be usable in python

USE_SHARED = NO

# do install at the top level mesa directory

# NOTE: do NOT run the install scripts at the subdirectory level
# those are for use by the top level script

# Unless you are adding a new compiler to the list of options,
# you shouldn't need to change any of the following stuff.
# It simply defines things for use by the module makefiles.


ifneq (,$(findstring ifort,$(FC)))

#FCbasic = $(SPECIAL_FC_FLAGS) -assume protect-parens -fp-model source -prec-div -prec-sqrt -ftz -traceback -error-limit 6
FCbasic = $(SPECIAL_FC_FLAGS) -assume protect-parens -fp-model source -prec-div -prec-sqrt -traceback -error-limit 6

# use -vec-report2 to check on vectorization

FCimpno = -implicitnone 
FCchecks = -check uninit -check pointers -check bounds -check all
FCwarn = -warn all -warn nounused
FCwarn_unused = -warn unused
FC_fixed_preprocess = -fpp
FC_free_preprocess = -fpp
FCfixed = -fixed -132 $(FC_fixed_preprocess)
FCfixed72 = -fixed $(FC_fixed_preprocess)
FCfree = -free $(FC_free_preprocess)
FCopt = -O2
FCdebug = -g
SLOW_COMPILE = 
ifeq ($(USE_OPENMP),YES)
FCopenmp = -qopenmp -threads
else
FCopenmp = 
endif
FCstatic =

else
ifneq (,$(findstring gfortran,$(FC)))

FCbasic = -fno-range-check -fmax-errors=100 -ggdb $(SPECIAL_FC_FLAGS) -fprotect-parens -fno-sign-zero
# -Warray-temporaries
 
FCimpno = -fimplicit-none  
FCchecks = -fbounds-check
FCwarn = -Wunused-value -W -Wno-compare-reals -Wno-unused-parameter
#FCwarn = -Wunused-value -Werror -W -Wno-compare-reals -Wno-unused-parameter
# -Wno-unused-parameter
 
FC_fixed_preprocess = -x f77-cpp-input
FC_free_preprocess = -x f95-cpp-input
FCfixed = -ffixed-form -ffixed-line-length-132 $(FC_fixed_preprocess)
FCfixed72 = -ffixed-form $(FC_fixed_preprocess)
FCfree = -ffree-form $(FC_free_preprocess)
FCopt = -O2
FCdebug = -ggdb
FCstatic =
SLOW_COMPILE = -fno-var-tracking
ifeq ($(USE_OPENMP),YES)
FCopenmp = -fopenmp
else
FCopenmp = 
endif

else

FCbasic = UNKNOWN COMPILER
FCchecks =
FCwarn = 
FCfixed =
FCfree =
FCopt = 
FCdebug = 
FCopenmp = 
SLOW_COMPILE = 
endif
endif


# Flags needed for shared libraries
ifeq ($(USE_SHARED), YES)
   UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
   MD := $(shell realpath $(MESA_DIR)/lib)
   # Rpaths need to resolve relative to module/test folder plus the final location of the library
   LIB_FLAGS = -fPIC -shared
   LD_FLAGS = -Wl,-rpath=../make:../../lib:$(MD)
   LIB_SUFFIX = so
endif
ifeq ($(UNAME_S),Darwin)
# Macs dont have realpath so cd to dir and get its location manually
# We check if folder exists first, to stop adipls getting confused
# when it can't find ../../lib
ifneq ($(wildcard $(MESA_DIR)/lib/.*),)
   MD := $(shell cd "$(MESA_DIR)/lib"; pwd -P)
endif
   LIB_FLAGS = -dynamiclib
   LD_FLAGS = -Wl,-rpath,../make,-rpath,../../lib,-rpath,$(MD)
   LIB_SUFFIX = dylib
endif
   LIB_TOOL = $(FC) $(LIB_FLAGS) $(FCopenmp) $(LD_FLAGS) -o

else
   # Static library options
   LIB_TOOL = ar crs
   LIB_SUFFIX = a
   LIB_FLAGS =
   LIBS =
endif


# some definitions used in the module makefiles
MODULE_DIR = ..
MOD_PUBLIC_DIR = $(MODULE_DIR)/public
MOD_PRIVATE_DIR = $(MODULE_DIR)/private
MODULE_INCLUDES = -I$(MOD_PUBLIC_DIR) -I$(MOD_PRIVATE_DIR)
OTHER_INCLUDES = -I$(MESA_DIR)/include
INCLUDES = $(MODULE_INCLUDES) $(OTHER_INCLUDES)

COMPILE_BASIC_FLAGS = $(FCbasic) $(FCopenmp) $(FCstatic) $(INCLUDES)
COMPILE_BASIC = $(FC) $(COMPILE_BASIC_FLAGS)

COMPILE_TO_TEST   = $(COMPILE_BASIC) $(FCwarn) $(FCimpno) $(FCchecks) $(FCopt) $(FCdebug) -c
COMPILE_TO_DEPLOY = $(COMPILE_BASIC) $(FCwarn) $(FCimpno) $(FCopt) -c

COMPILE_NO_OPENMP_NO_OPT = \
   $(FC) $(FCbasic) $(INCLUDES) $(FCwarn) $(FCimpno) $(FCchecks) $(FCdebug) -c -O
COMPILE_ASAP = \
   $(FC) $(FCbasic) $(INCLUDES) $(FCwarn) $(FCimpno) $(FCdebug) -c -O

COMPILE_FAST = $(COMPILE_BASIC) -c
COMPILE_NO_CHECKS = $(COMPILE_BASIC) $(FCopt) -c
COMPILE_NO_OPT    = $(COMPILE_BASIC) $(FCwarn) $(FCimpno) $(FCchecks) $(FCdebug) -c -O
COMPILE_DEVEL     = $(COMPILE_NO_OPT)


# some definitions used in the module makefiles
MODULE_DIR = ..
MOD_PUBLIC_DIR = $(MODULE_DIR)/public
MOD_PRIVATE_DIR = $(MODULE_DIR)/private
MODULE_INCLUDES = -I$(MOD_PUBLIC_DIR) -I$(MOD_PRIVATE_DIR)
OTHER_INCLUDES = -I$(MESA_DIR)/include $(INCLUDE_HDF5)
INCLUDES = $(MODULE_INCLUDES) $(OTHER_INCLUDES) 

COMPILE_BASIC_FLAGS = $(FCbasic) $(FCopenmp) $(FCstatic) $(LIB_FLAGS) $(INCLUDES) $(LIB_FLAGS)
COMPILE_BASIC = $(FC) $(COMPILE_BASIC_FLAGS)

COMPILE_TO_TEST   = $(COMPILE_BASIC) $(FCwarn) $(FCimpno) $(FCchecks) $(FCopt) $(FCdebug) -c
COMPILE_TO_DEPLOY = $(COMPILE_BASIC) $(FCwarn) $(FCimpno) $(FCopt) -c

COMPILE_NO_OPENMP_NO_OPT = \
   $(FC) $(FCbasic) $(INCLUDES) $(FCwarn) $(FCimpno) $(FCchecks) $(FCdebug) -c -O
COMPILE_ASAP = \
   $(FC) $(FCbasic) $(INCLUDES) $(FCwarn) $(FCimpno) $(FCdebug) -c -O

COMPILE_FAST = $(COMPILE_BASIC) -c
COMPILE_NO_CHECKS = $(COMPILE_BASIC) $(FCopt) -c
COMPILE_NO_OPT    = $(COMPILE_BASIC) $(FCwarn) $(FCimpno) $(FCchecks) $(FCdebug) -c -O
COMPILE_DEVEL     = $(COMPILE_NO_OPT)

# some definitions used in the test makefiles and client makefiles

WORK_COMPILE = \
   $(FC) $(FCbasic) $(FCopenmp) -O0 $(FCchecks) $(FCdebug) $(FCfree) \
   $(FC_free_preprocess) -I$(MESA_INCLUDE_DIR) $(INCLUDE_HDF5) -c
 
ifeq ($(USE_PGPLOT),YES)
	WORK_COMPILE += -DUSE_PGPLOT
endif
 
TEST_DIR = ..
TEST_SRC_DIR = $(TEST_DIR)/src
PACKAGE_DIR = ../..
LOCAL_LIB_DIR = $(PACKAGE_DIR)/make
MESA_LIB_DIR = $(MESA_DIR)/lib

MESA_INCLUDE_DIR = $(MESA_DIR)/include
TEST_INCLUDES = -I$(LOCAL_LIB_DIR) -I$(PACKAGE_DIR)/public -I$(MESA_INCLUDE_DIR)
TEST_COMPILE_FLAGS = $(FCbasic) $(FCopenmp) $(TEST_INCLUDES) $(FCchecks) $(FCdebug) $(LIB_FLAGS) -c
TEST_COMPILE = $(FC) $(TEST_COMPILE_FLAGS) $(LD_FLAGS)

ifeq ($(USE_STUB_FOR_CRLIBM),NO)
LOAD_CRLIBM = -lcrlibm
endif

LOAD_MATRIX = -lf2crlibm $(LOAD_CRLIBM) -lmtx -lconst -lutils $(LOAD_LAPACK) $(LOAD_BLAS)

LOAD_MESA_NUMERICS = -linterp_2d -linterp_1d -lnum $(LOAD_MATRIX) $(LOAD_HDF5)

# micro uses numerics
LOAD_MESA_MICRO = \
   -lnet -leos -lkap -lrates -lneu -lchem \
   $(LOAD_MESA_NUMERICS)

# macro uses micro
LOAD_MESA_MACRO = \
   -lionization -latm -lcolors $(LOAD_MESA_MICRO)

# star_support uses macro (for now, LOAD_MESA_STAR_SUPPORT just = LOAD_MESA_MACRO)
LOAD_MESA_STAR_SUPPORT = $(LOAD_MESA_MACRO)  $(LD_FLAGS)

# star uses star_support
LOAD_STAR_MODS = -lstar $(LOAD_MESA_STAR_SUPPORT)
ifeq ($(USE_PGSTAR),YES)
	STAR_LOAD_LIST = $(LOAD_STAR_MODS) $(LOAD_PGPLOT)
else
	STAR_LOAD_LIST = $(LOAD_STAR_MODS)
endif
LOAD_MESA_STAR = -L$(MESA_LIB_DIR) $(STAR_LOAD_LIST)
LOAD_MESA_BINARY = -L$(MESA_LIB_DIR) -lbinary $(STAR_LOAD_LIST)

# LOADER creates executables
LOADER = $(FC)

STAR_WORK_OBJS = \
   run_star_extras.o run_star.o 

BINARY_WORK_OBJS = \
   $(STAR_WORK_OBJS) run_binary_extras.o run_binary.o
   
#Test if we are on windows
BUILD_ON_WINDOWS=NO
ifeq ($(OS),Windows_NT)
   BUILD_ON_WINDOWS=YES
endif


More information about the Mesa-users mailing list