# make file
# see also
# http://mrbook.org/tutorials/make/
CURR_REVISION := "$(shell svn info oriented_template.mpi.F | awk '/^Revision:/ {print $2}')"
information_inside_source=-D__DATE_COMPILED_ON__="$(shell date)" \
-D__COMPUTER_COMPILED_ON__="$(shell uname -n)" \
-D__SVN_REVISION__=$(CURR_REVISION) \
-D__USER_NAME__="$(shell whoami)" \
-D__ARCH__="$(shell uname -m)"
debug=-g
source_extension=.f
parallel_extension=.mpi
template_name=oriented_template.mpi.F
executable_extension=.lex
name_output=oriented
does_ifort_exist=$(shell which ifort | wc -l)
does_gfortran_exist=$(shell which gfortran | wc -l)
# Kraken, Ranger
does_pgf90_exist=$(shell which pgf90 | wc -l)
does_mpif90_exist=$(shell which mpif90 | wc -l)
does_pdflatex_exist=$(shell which pdflatex | wc -l)
# Kraken:
does_ftn_exist=$(shell which ftn | wc -l)
does_python_exist=$(shell which python | wc -l)
does_graphviz_exist=$(shell which neato | wc -l)
parallel_compiler=mpif77
parallel_INTEL_switches=-i8 -r8 -shared-intel -align
parallel_FTN_switches=-r8 -Mextend -Mdalign -Msave
serial_GNU_compiler=gfortran
genrate_GNU_source= -E
serial_INTEL_compiler=ifort
genrate_INTEL_source=-fpp -EP -save-temps
genrate_PG_source=-E
serial_PG_compiler=pgf90
no_parallelism_name=_no_parallelism
loop6parallel_name=_loop6parallel
loop64parallel_name=_loop64parallel
loop643parallel_name=_loop643parallel
generated_source_cleanup=| sed '/\#.*/d' | sed '/^$$/d' | sed '/^!makedigraph:.*/d' # remove lines left by preprocess and blank lines
# note: input files must be created prior to compiling due to include statements
all: compile_extra_files compile_FPP_to_source compile source
compile_FPP_to_source: compile_FPP_to_source_NOT_parallel_no_MPI compile_FPP_to_source_NOT_parallel compile_FPP_to_source_LOOP_SIX_parallel compile_FPP_to_source_LOOPS_SIX_FOUR_parallel compile_FPP_to_source_LOOPS_SIX_FOUR_THREE_parallel
compile source: compile_source_NOT_parallel_no_MPI compile_source_NOT_parallel compile_source_LOOP_SIX_parallel compile_source_LOOPS_SIX_FOUR_parallel compile_source_LOOPS_SIX_FOUR_THREE_parallel
compile_extra_files: create_H2dat_file create_H2ionpot_file create_H2neutraldensity_file create_H2neutralpot_file create_orientedpar_file create_input_file create_H2dat_file create_documentation
compile_FPP_to_source_NOT_parallel_no_MPI:
ifeq ($(does_gfortran_exist),1)
$(serial_GNU_compiler) $(genrate_GNU_source) -D__no_parallelism__ -D__NO_MPI__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(no_parallelism_name)$(source_extension)
else
$(serial_INTEL_compiler) $(genrate_INTEL_source) -D__no_parallelism__ -D__NO_MPI__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(no_parallelism_name)$(source_extension)
endif
compile_source_NOT_parallel_no_MPI:
ifeq ($(does_pgf90_exist),1)
pgf90 $(parallel_FTN_switches) $(name_output)$(no_parallelism_name)$(source_extension) -o $(name_output)$(no_parallelism_name)$(executable_extension)
else
ifort $(parallel_INTEL_switches) $(name_output)$(no_parallelism_name)$(source_extension) -o $(name_output)$(no_parallelism_name)$(executable_extension)
endif
compile_FPP_to_source_NOT_parallel:
ifeq ($(does_gfortran_exist),1)
$(serial_GNU_compiler) $(genrate_GNU_source) -D__no_parallelism__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(no_parallelism_name)$(parallel_extension)$(source_extension)
else
$(serial_INTEL_compiler) $(genrate_INTEL_source) -D__no_parallelism__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(no_parallelism_name)$(parallel_extension)$(source_extension)
endif
compile_source_NOT_parallel:
ifeq ($(does_ftn_exist),1)
ftn $(parallel_FTN_switches) $(name_output)$(no_parallelism_name)$(source_extension) -o $(name_output)$(no_parallelism_name)$(parallel_extension)$(executable_extension)
else
$(parallel_compiler) $(parallel_INTEL_switches) $(name_output)$(no_parallelism_name)$(source_extension) -o $(name_output)$(no_parallelism_name)$(parallel_extension)$(executable_extension)
endif
compile_FPP_to_source_LOOP_SIX_parallel:
ifeq ($(does_gfortran_exist),1)
$(serial_GNU_compiler) $(genrate_GNU_source) -D__loop6parallel__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(loop6parallel_name)$(parallel_extension)$(source_extension)
else
$(serial_INTEL_compiler) $(genrate_INTEL_source) -D__loop6parallel__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(loop6parallel_name)$(parallel_extension)$(source_extension)
endif
compile_source_LOOP_SIX_parallel:
ifeq ($(does_ftn_exist),1)
ftn $(parallel_FTN_switches) $(name_output)$(loop6parallel_name)$(parallel_extension)$(source_extension) -o $(name_output)$(loop6parallel_name)$(parallel_extension)$(executable_extension)
else
$(parallel_compiler) $(parallel_INTEL_switches) $(name_output)$(loop6parallel_name)$(parallel_extension)$(source_extension) -o $(name_output)$(loop6parallel_name)$(parallel_extension)$(executable_extension)
endif
compile_FPP_to_source_LOOPS_SIX_FOUR_parallel:
ifeq ($(does_gfortran_exist),1)
$(serial_GNU_compiler) $(genrate_GNU_source) -D__loop64parallel__ -D__factor_correction__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(loop64parallel_name)$(parallel_extension)$(source_extension)
else
$(serial_INTEL_compiler) $(genrate_INTEL_source) -D__loop64parallel__ -D__factor_correction__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(loop64parallel_name)$(parallel_extension)$(source_extension)
endif
compile_source_LOOPS_SIX_FOUR_parallel:
ifeq ($(does_ftn_exist),1)
ftn $(parallel_FTN_switches) $(name_output)$(loop64parallel_name)$(parallel_extension)$(source_extension) -o $(name_output)$(loop64parallel_name)$(parallel_extension)$(executable_extension)
else
$(parallel_compiler) $(parallel_INTEL_switches) $(name_output)$(loop64parallel_name)$(parallel_extension)$(source_extension) -o $(name_output)$(loop64parallel_name)$(parallel_extension)$(executable_extension)
endif
compile_FPP_to_source_LOOPS_SIX_FOUR_THREE_parallel:
ifeq ($(does_gfortran_exist),1)
$(serial_GNU_compiler) $(genrate_GNU_source) -D__loop643parallel__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(loop643parallel_name)$(parallel_extension)$(source_extension)
else
$(serial_INTEL_compiler) $(genrate_INTEL_source) -D__loop643parallel__ $(information_inside_source) $(template_name) $(generated_source_cleanup) > $(name_output)$(loop643parallel_name)$(parallel_extension)$(source_extension)
endif
compile_source_LOOPS_SIX_FOUR_THREE_parallel:
ifeq ($(does_ftn_exist),1)
ftn $(parallel_FTN_switches) $(name_output)$(loop643parallel_name)$(parallel_extension)$(source_extension) -o $(name_output)$(loop643parallel_name)$(parallel_extension)$(executable_extension)
else
$(parallel_compiler) $(parallel_INTEL_switches) $(name_output)$(loop643parallel_name)$(parallel_extension)$(source_extension) -o $(name_output)$(loop643parallel_name)$(parallel_extension)$(executable_extension)
endif
create_input_file:
sed -n '/^cinputfileparameters/p' $(template_name) | sed 's/cinputfileparameters //' > oriented.in
create_H2dat_file:
sed -n '/^cH2DATfile /p' $(template_name) | sed 's/cH2DATfile //' > H2.dat
create_H2ionpot_file:
sed -n '/^cH2IONPOTfile /p' $(template_name) | sed 's/cH2IONPOTfile //' > H2.ion.pot
create_H2neutraldensity_file:
sed -n '/^cH2NEUTRALDENSITYfile /p' $(template_name) | sed 's/cH2NEUTRALDENSITYfile //' > H2.neutral.density
create_H2neutralpot_file:
sed -n '/^cH2NEUTRALPOTfile /p' $(template_name) | sed 's/cH2NEUTRALPOTfile //' > H2.neutral.pot
create_orientedpar_file:
sed -n '/^cORIENTEDPARfile /p' $(template_name) | sed 's/cORIENTEDPARfile //' > oriented.par
create_documentation:
sed -n '/^cdocumentationInput/p' $(template_name) | sed 's/cdocumentationInput //' > oriented_documentation.tex
ifeq ($(does_pdflatex_exist),1)
pdflatex oriented_documentation.tex
pdflatex oriented_documentation.tex
endif
create_variable_dependence_map:
sed -n '/^cmakedigraph:/p' $(template_name) | sed 's/cmakedigraph: //' > oriented_variable_dependence.gv
ifeq ($(does_graphviz_exist),1)
# if graphviz is availble, compile .gv to .png
neato -Tpng quasi1d_rect_variable_dependence.gv > quasi1d_rect_variable_dependence.png
endif
clean:
rm oriented_doc* oriented_no_* oriented_loop* *.mod H2.* oriented.*