# to create libinterposg95.a (does not need link to lapack routines, includes dpgbtrf_s.f90) PROG = interposg95 # to create libinterposifort.a PROG_ifort = interposifort # to create libinterpospgi.a PROG_pgi = interpospgi # to create libinterpospgi.a PROG_pgf95 = interpospgf95 # to create libinterpospgi.a PROG_gfortran = interposgfortran # to create intrepos.mexa64 matlab mex file in ../matlab folder PROG_mex = interposmex # to create .so lib for idl, tdi, etc add c_wrapper to interpos shared library and force real*8 PROG_gfortran_cwrapper = interposgfortran_cwrapper # to create libinterposg95_wolapack.a (needs link to lapack routines) PROG_wolapack = interposg95_wolapack # to create libinterposifort_wolapack.a (needs link to lapack routines) PROG_ifortwolapack = interposifort_wolapack # to create libinterpospgi_wolapack.a (needs link to lapack routines) PROG_pgiwolapack = interpospgi_wolapack PROG_pgf95wolapack = interpospgf95_wolapack PROG_gfortranwolapack = interposgfortran_wolapack # to create interpostest_f90 program from interpostest.f90 PROG_interpostest_f90 = interpostest_f90 PROG_interpostest_f90_pgi = interpostest_f90_pgi PROG_interpostest_eqdsk = interpostest_f90_eqdsk # to compile matlab interpos routine: either from within matlab with mex interpos.f90 after creating interpos.f90 # create interpos.f90 for matlab including already lapack routines PROG_interpos_for_matlab = interpos_for_matlab PROG_interpos_for_matlab32bits = interpos_for_matlab32bits # create interpos.f90 for matlab and needs link to wolapack PROG_interpos_for_matlab_wolapack = interpos_for_matlab_wolapack # mex directly matlab routine with own lapack routine, no link needed PROG_interpos = interpos_mex # mex directly matlab routine with own lapack routine, no link needed PROG_interpos_wolapack = interpos_mex_wolapack # create interpos.f90 for python including lapack routines PROG_interpos_for_python = interpos_for_python # interpos_source.f90 for CHEASE or other standalone versions (avoid having a library linked) PROG_interpos_source = interpos_source # interpos_source_all.f90 includes also prec_const and checknanos, not lapack so need mkl libraries PROG_interpos_source_all = interpos_source_all # interpos_source_all_withlapack.f90 includes also prec_const and checknanos AND dpgbtrf_s.f90 (used in ASTRA) PROG_interpos_source_all_withlapack = interpos_source_all_withlapack SRCS_LIB = cbsplgen.f90 cbsplgenp.f90 cbfitbnd.f90 cbfitper.f90 \ splipera.f90 splibnda.f90 intlinear.f90 intquadratic.f90 MODS = prec_rkind.f90 checknanos_module.f90 interpos_module.f90 MODS_for_interpos_source = prec_rkind.f90 checknanos_module.f90 interpos_module.f90 MODS_for_interpos_source_all = prec_rkind.f90 checknanos_module.f90 interpos_module.f90 SRCS_topmatlab = interpos_matlab_top.f90 SRCS_topmatlab32bits = interpos_matlab_top32bits.f90 SRCS_testf90 = interpostest3.f90 SRCS_testf90 = interpostest_profile.f90 SRCS_testf90_eqdsk = interpostest_2Deqdsk.f90 indexx.f90 SRCS_c_wrapper = interpos_wrapper_c.c SRCS_f90_wrapper = c_wrapper_to_interpos.f90 SRCS_lap = dpgbtrf_s.f90 OBJS_LIB = $(SRCS_LIB:.f90=.o) LIBS_nolap = LIBS_lap = -L${MKL} -lmkl_lapack -lmkl -lguide -lpthread F90_95 = g95 F90_ifort = ifort F90_pgi = pgf90 F90_pgf95 = pgf95 F90_gfortran = gfortran FC_95 = -O3 -fPIC -fno-omit-frame-pointer FC_ifort = -O3 -r8 -fPIC FC_pgi = -O3 -r8 -fPIC -Mnosecond_underscore FC_pgf95 = -O3 -r8 -fPIC -Mnosecond_underscore FC_gfortran = -g -fPIC -O0 -Wall -ffree-line-length-none -fdefault-real-8 FC_gfortran = -O3 -fPIC -Wall -ffree-line-length-none -fdefault-real-8 #setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH':/usr/gnu/64/lib' (to get -lgfortran to work on sxaug) system = $(shell uname -s) hardware = $(shell uname -m) ifeq ($(system),Linux) CFLAGS = -g -O2 -fPIC -m64 LDFLAGS_shared = -O2 -shared -m64 -fPIC -lgfortran -lm else # Note: on SunOS, use "gmake" instead of "make" otherwise ifeq not allowed CFLAGS = -g -O2 -fPIC -m64 LDFLAGS_shared = -O2 -shared -m64 -fPIC -lm endif matlabfile = $(shell which matlab) MATLABbin = $(shell dirname $(matlabfile)) mexcmd = $(shell which mex) ifeq ($(mexcmd),) # at SPC-EPFL need to specify effective path for mex, no in default path ifneq (,$(findstring lac,$(HOSTNAME))) # mexcmd=/usr/local/MATLAB/R2017a/bin/mex # does not work for earlier versions like matlab850 mexcmd=/usr/local/MATLAB/R2015a/bin/mex # works for previous and later version like matlab920 else mexcmd="mex to be defined for this "`echo $(HOSTNAME)` endif else mexcmd=$(MATLABbin)/mex endif ifeq ($(DIRTARGET),) DIRTARGET = . endif all1: $(PROG) $(PROG_ifort) $(PROG_pgi) $(PROG_pgf95) $(PROG_wolapack) $(PROG_ifortwolapack) $(PROG_pgiwolapack) $(PROG_pgf95wolapack) $(PROG_interpos_for_matlab) $(PROG_interpos_source) $(PROG_gfortran) $(PROG_gfortranwolapack) $(PROG): $(F90_95) -c $(FC_95) $(MODS) $(F90_95) -c $(FC_95) $(SRCS_LIB) $(SRCS_lap) ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) @mkdir -p g95_libs mv $(MODS:.f90=.mod) lib$@.a g95_libs echo "now can compile with: $(F90_95) -o file_a_out $(FC_95) file.f90 -L$(PWD)/g95_libs -l$@" $(PROG_ifort): $(F90_ifort) -fpic -c $(FC_ifort) $(MODS) $(F90_ifort) -fpic -c $(FC_ifort) $(SRCS_LIB) $(SRCS_lap) $(F90_ifort) -shared -fpic $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) -o lib$@.so ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) @mkdir -p ifort_libs mv $(MODS:.f90=.mod) lib$@.a lib$@.so ifort_libs echo "now can compile with: $(F90_ifort) -o file_a_out $(FC_ifort) file.f90 -L$(PWD)/ifort_libs -l$@" $(PROG_pgi): $(F90_pgi) -c $(FC_pgi) $(MODS) $(F90_pgi) -c $(FC_pgi) $(SRCS_LIB) $(SRCS_lap) ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) @mkdir -p pgi_libs mv $(MODS:.f90=.mod) lib$@.a pgi_libs echo "now can compile with: $(F90_pgi) -o file_a_out $(FC_pgi) file.f90 -L$(PWD)/pgi_libs -l$@" $(PROG_pgf95): $(F90_pgf95) -c $(FC_pgf95) $(MODS) $(F90_pgf95) -c $(FC_pgf95) $(SRCS_LIB) $(SRCS_lap) ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) @mkdir -p pgf95_libs mv $(MODS:.f90=.mod) lib$@.a pgf95_libs echo "now can compile with: $(F90_pgf95) -o file_a_out $(FC_pgf95) file.f90 -L$(PWD)/pgf95_libs -l$@" $(PROG_gfortran): $(F90_gfortran) -fPIC -c $(FC_gfortran) $(MODS) $(F90_gfortran) -fPIC -c $(FC_gfortran) $(SRCS_LIB) $(SRCS_lap) $(F90_gfortran) -fPIC -shared -fPIC $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) -o lib$@.so ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) $(SRCS_lap:.f90=.o) @mkdir -p gfortran_libs mv $(MODS:.f90=.mod) lib$@.a lib$@.so gfortran_libs cp -p gfortran_libs/*.a gfortran_libs/*.so $(DIRTARGET) echo "now can compile with: $(F90_gfortran) -o file_a_out $(FC_gfortran) file.f90 -L$(PWD)/gfortran_libs -l$@" $(PROG_gfortran_cwrapper): $(F90_gfortran) -fPIC -fdefault-real-8 -m64 -c $(MODS) $(F90_gfortran) -fPIC -fdefault-real-8 -m64 -c $(FC_gfortran) $(SRCS_LIB) $(SRCS_lap) echo "$(LDFLAGS_shared) " $(F90_gfortran) -fPIC -fdefault-real-8 -m64 -c $(SRCS_f90_wrapper) gcc -c $(CFLAGS) $(SRCS_c_wrapper) gcc $(LDFLAGS_shared) interpos_wrapper_c.o $(MODS:.f90=.o) c_wrapper_to_interpos.o $(OBJS_LIB) $(SRCS_lap:.f90=.o) -o lib$@.so @mkdir -p gfortran_cwrapper mv lib$@.so gfortran_cwrapper echo "now can use the shared library within idl or else: $(PWD)/gfortran_cwrapper/lib$@.so" $(PROG_wolapack): $(F90_95) -c $(FC_95) $(MODS) $(F90_95) -c $(FC_95) $(SRCS_LIB) ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) @mkdir -p g95_libs mv lib$@.a g95_libs echo "now can compile with: $(F90_95) -o file_a_out $(FC_95) file.f90 -L$(PWD)/g95_libs $(LIBS_lap) -l$@" $(PROG_ifortwolapack): $(F90_ifort) -fpic -c $(FC_ifort) $(MODS) $(F90_ifort) -fpic -c $(FC_ifort) $(SRCS_LIB) $(F90_ifort) -shared -fpic $(MODS:.f90=.o) $(OBJS_LIB) -o lib$@.so ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) @mkdir -p ifort_libs mv lib$@.a lib$@.so ifort_libs echo "now can compile with: $(F90_ifort) -o file_a_out $(FC_ifort) file.f90 -L$(PWD)/ifort_libs $(LIBS_lap) -l$@" $(PROG_pgiwolapack): $(F90_pgi) -c $(FC_pgi) $(MODS) $(F90_pgi) -c $(FC_pgi) $(SRCS_LIB) ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) @mkdir -p pgi_libs mv lib$@.a pgi_libs echo "now can compile with: $(F90_pgi) -o file_a_out $(FC_pgi) file.f90 -L$(PWD)/pgi_libs $(LIBS_lap) -l$@" $(PROG_pgf95wolapack): $(F90_pgf95) -c $(FC_pgf95) $(MODS) $(F90_pgf95) -c $(FC_pgf95) $(SRCS_LIB) ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) @mkdir -p pgf95_libs mv $(MODS:.f90=.mod) lib$@.a pgf95_libs echo "now can compile with: $(F90_pgf95) -o file_a_out $(FC_pgf95) file.f90 -L$(PWD)/pgf95_libs $(LIBS_lap) -l$@" $(PROG_gfortranwolapack): $(F90_gfortran) -fPIC -c $(FC_gfortran) $(MODS) $(F90_gfortran) -fPIC -c $(FC_gfortran) $(SRCS_LIB) $(F90_gfortran) -fPIC -shared -fPIC $(MODS:.f90=.o) $(OBJS_LIB) -o lib$@.so ar -rv lib$@.a $(MODS:.f90=.o) $(OBJS_LIB) @mkdir -p gfortran_libs mv $(MODS:.f90=.mod) lib$@.a lib$@.so gfortran_libs echo "now can compile with: $(F90_gfortran) -o file_a_out $(FC_gfortran) file.f90 -L$(PWD)/gfortran_libs $(LIBS_lap) -l$@" $(PROG_interpostest_f90): $(PROG_gfortran) # gfortran more standard now # $(F90_95) -o $@ $(FC_95) $(SRCS_testf90) -I$(PWD)/g95_libs -L$(PWD)/g95_libs -l$(PROG) $(F90_gfortran) -o $@ $(FC_gfortran) $(SRCS_testf90) -I$(PWD)/gfortran_libs -L$(PWD)/gfortran_libs -linterposgfortran @echo " " @echo "now can execute './$@ > out_test_$@.m' (should work and can run '>>out_test_$@' in matlab to get outputs)" $(PROG_interpostest_f90_pgi): $(PROG_pgi) $(F90_pgi) -o $@ $(FC_pgi) $(SRCS_testf90) -L$(PWD)/pgi_libs -l$(PROG_pgi) $(PROG_interpostest_eqdsk):$(PROG_gfortran) $(F90_gfortran) -o $@ $(FC_gfortran) $(SRCS_testf90_eqdsk) -I$(PWD)/gfortran_libs -L$(PWD)/gfortran_libs -linterposgfortran # $(F90_95) -o $@ $(FC_95) $(SRCS_testf90_eqdsk) -I$(PWD)/g95_libs -L$(PWD)/g95_libs -l$(PROG) # $(F90_pgi) -o $@ $(FC_pgi) $(SRCS_testf90_eqdsk) -I$(PWD)/pgi_libs -L$(PWD)/pgi_libs -l$(PROG_pgi) $(PROG_interpos_for_matlab): cat $(MODS) $(SRCS_topmatlab) $(SRCS_LIB) $(SRCS_lap) > ../matlab/interpos.f90 echo "within matlab >> mex interpos.f90" $(PROG_interpos_for_matlab32bits): cat $(MODS) $(SRCS_topmatlab32bits) $(SRCS_LIB) $(SRCS_lap) > ../matlab/interpos32bits.f90 echo "after cp interpos32bits.f90 interpos.f90, within matlab >> mex interpos.f90" $(PROG_mex): @cat $(MODS) $(SRCS_topmatlab) $(SRCS_LIB) $(SRCS_lap) > ../matlab/interpos.f90 @cd ../matlab; $(mexcmd) interpos.f90 @cd ../matlab; rm -f interpos_module.mod checknanos_module.mod prec_rkind.mod @cd ../matlab; matlab -nodesktop -nodisplay -singleCompThread -r "interpostest_time;quit" cd ../matlab; cp -p interpos.mexa64 interpos.m $(DIRTARGET) @echo "OK mex file created in ../matlab"; ls -l ../matlab/interpos.mexa64 @echo "using $(mexcmd)" $(PROG_interpos_for_matlab_wolapack): cat $(MODS) $(SRCS_topmatlab) $(SRCS_LIB) > ../matlab/interpos.f90 echo "within matlab >> mex FLIBS='-Wl,-rpath-link,/usr/local/matlab-7.7.0/bin/glnxa64 -L/usr/local/matlab-7.7.0/bin/glnxa64 -lmx -lmex -lmat -lm -lmwlapack' interpos.f90" $(PROG_interpos): $(PROG_interpos_for_matlab) g95 -c -I/usr/local/matlab-7.7.0/extern/include -I/usr/local/matlab-7.7.0/simulink/include -fexceptions -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -O3 ../matlab/interpos.f90 g95 -O3 -pthread -shared -Wl,--version-script,/usr/local/matlab-7.7.0/extern/lib/glnxa64/fexport.map -Wl,--no-undefined -o "../matlab/interpos.mexa64" interpos.o "/usr/local/matlab-7.7.0/extern/lib/glnxa64/version4.o" -Wl,-rpath-link,/usr/local/matlab-7.7.0/bin/glnxa64 -L/usr/local/matlab-7.7.0/bin/glnxa64 -lmx -lmex -lmat -lm rm interpos.o $(PROG_interpos_wolapack): $(PROG_interpos_for_matlab_wolapack) g95 -c -I/usr/local/matlab-7.7.0/extern/include -I/usr/local/matlab-7.7.0/simulink/include -fexceptions -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -O3 ../matlab/interpos.f90 g95 -O3 -pthread -shared -Wl,--version-script,/usr/local/matlab-7.7.0/extern/lib/glnxa64/fexport.map -Wl,--no-undefined -o "../matlab/interpos.mexa64" interpos.o "/usr/local/matlab-7.7.0/extern/lib/glnxa64/version4.o" -Wl,-rpath-link,/usr/local/matlab-7.7.0/bin/glnxa64 -L/usr/local/matlab-7.7.0/bin/glnxa64 -lmx -lmex -lmat -lm -lmwlapack rm interpos.o $(PROG_interpos_for_python): cat $(MODS) $(SRCS_LIB) $(SRCS_lap) > ../python/interpos.f90 $(PROG_interpos_source): cat $(MODS_for_interpos_source) $(SRCS_LIB) > interpos_source.f90 @echo "you can now copy interpos_source.f90 to your directory" $(PROG_interpos_source_all_withlapack): cat $(MODS_for_interpos_source) $(SRCS_lap) $(SRCS_LIB) > interpos_source_all_withlapack.f90 @echo "you can now copy interpos_source_all_withlapack.f90 to your directory" clean: rm -f *.o *.a *.mod *.so source: cat $(MODS) $(SRCS_LIB) > ../interpos_source.f90