#* Makefile for CEPAM -Code d'Evolution Planetaire Adaptatif et Modulaire #* (c) T. Guillot 2004 #* make : compiles all programs and creates bin/cepam #* make tar : creates in ../ a file Cepam__.tgz #* this tar file contains all the files in ${SAVED} #* The compilation uses either g95, gfortan, xlf, or g77, or f77, in that order #* In order to force the use of a given compiler, use (e.g.): #* make -e force "FOR=/sw/bin/g77" #------------------------------ # PARAMETERS (Can be redefined) REP = Cepam SAVED = ${REP}/Makefile ${REP}/README ${REP}/MODIFS ${REP}/DATE ${REP}/src ${REP}/expls ${REP}/graph ${REP}/input ${REP}/bin ${REP}/data FEXEC = bin/cepam #FFLAGS = -O -I. -I./src -I./src/Communs -J ./src FFLAGS = -O2 -I. -I./src -I./src/Communs -module ./src -parallel SHELL = /bin/bash EOSDATA = data/EOS/He_spleen_pt.b data/EOS/inter_spleen_pt.b data/EOS/ppt_spleen_pt.b data/EOS/He_spleen_pt.b2 data/EOS/inter_spleen_pt.b2 EXPLSFILES = expls/ #------------------------------ OBJS := $(shell echo `ls -m src/*/*\.f`| sed 's/\.f/\.o/g' | sed 's/\,//g') OBJS2 := $(shell echo `ls -m src/*/*\.f90`| sed 's/\.f90/\.o/g' | sed 's/\,//g') INCLUDES = src/cepam.inc FOR := $(shell if which ifort; then :;\ elif which gfortran; then :;\ elif which g95; then :;\ elif which xlf; then :;\ elif which f77; then :;\ elif which g77; then :;\ else echo 'I couldn''t find gfortran, ifort, g95, xlf, g77, f77'; exit 11; fi) THISDIR := $(shell pwd) #DATAS := $(shell find . -type l -name "data") DATAS = ./test_expls/evolutions/CoRoT-Exo-3_std/data ./test_expls/evolutions/HD149026_std/data ./test_expls/evolutions/HD209458_diss/data #Adds flag #ADFLAGS := $(shell if which g95; then echo '-Wall'; fi) #ADFLAGS = -Wall ADFLAGS = .f.o: ${FOR} ${FFLAGS} ${ADFLAGS} -c $*.f -o $*.o # 2 next targets are needed to compile f90 modules %.mod: %.o @if [! -f $@ ]; then \ rm $< \0 make $< \ fi %.o : %.f90 $(FOR) ${FFLAGS} ${ADFLAGS} -c -o $@ $< #.f90.o: # ${FOR} ${FFLAGS} -c $*.f90 -o $*.o .bin.basc: bin/cepasc2bin << EOF .PHONY: install simlinks test check clean force save tar date all # This installs & tests the whole code # (!Not ready for the optimization part!) install: bin/cepam bin/cepasc2bin simlinks @ echo "" symlinks: # @ /bin/rm ${DATAS} @ for syml in ${DATAS}; do \ if [ -e ${syml} ]; then /bin/rm -f ${syml}; fi; \ ln -s ${THISDIR}'/data' $$syml;\ echo 'ln -s '${THISDIR}'/data '$$syml; done @ echo "I''ve updated the symbolic links" ${DATAS} @ echo "They now point to "${THISDIR}"/data" test: bin/cepam bin/cepasc2bin symlinks @ /bin/bash com/test_cepam.bash check: bin/cepam bin/cepasc2bin symlinks @ /bin/bash com/test_cepam.bash -s all: bin/cepam bin/optimise bin/test_lim_ext bin/test_etat bin/cepasc2bin # This creates the executable file bin/cepam: src/cepamlaunch.f src/mod_inputs.mod ${OBJS2} ${OBJS} ${INCLUDES} ${EOSDATA} # @ echo ${FOR} @ if ${FOR} ${FFLAGS} ${ADFLAGS} src/cepamlaunch.f ${OBJS2} ${OBJS} -o bin/cepam; then \ echo ${FOR} ${FFLAGS} ${ADFLAGS} src/cepamlaunch.f ${OBJS2} ${OBJS} -o bin/cepam;\ echo "*** Compilation of bin/cepam successful";\ echo " (Try ''make test'' to test the code)";\ if [ -d ${HOME}/bin ]; then \ /bin/rm -f ${HOME}/bin/cepam;\ if ln -s ${THISDIR}/bin/cepam ${HOME}/bin/cepam; then \ echo "*** Created link from ${HOME}/bin/cepam"; fi;\ fi;\ else echo "!!! Compilation of bin/cepam FAILED !!!"; exit; fi # THIS IS A TEMPORARY PATCH FOR THE MODULE COMPILATION src/mod_inputs.mod: ${FOR} ${FFLAGS} ${ADFLAGS} -c src/mod_inputs.f90 # This is the optimisation code (for Jupiter and Saturn) bin/optimise: src/optimise.f ${OBJS} ${INCLUDES} ${EOSDATA} # @ echo ${FOR} @ if ${FOR} ${FFLAGS} ${ADFLAGS} src/optimise.f ${OBJS} -o bin/optimise; then \ echo ${FOR} ${FFLAGS} ${ADFLAGS} src/optimise.f ${OBJS} -o bin/optimise;\ echo "*** Compilation of bin/optimise successful";\ if [ -d ${HOME}/bin ]; then \ /bin/rm -f ${HOME}/bin/optimise;\ if ln -s ${THISDIR}/bin/optimise ${HOME}/bin/optimise; then \ echo "*** Created link from ${HOME}/bin/optimise"; fi;\ fi;\ else echo "!!! Compilation of bin/optimise FAILED !!!"; exit; fi # TEST routines bin/test_lim_ext: src-div/Tests/test_lim_ext.f ${OBJS} ${INCLUDES} # @ echo ${FOR} @ if ${FOR} ${FFLAGS} ${ADFLAGS} src-div/Tests/test_lim_ext.f ${OBJS} -o bin/test_lim_ext; then \ echo ${FOR} ${FFLAGS} ${ADFLAGS} src-div/Tests/test_lim_ext.f ${OBJS} -o bin/test_lim_ext;\ echo "*** Compilation of bin/test_lim_ext successful";\ if [ -d ${HOME}/bin ]; then \ /bin/rm -f ${HOME}/bin/test_lim_ext;\ if ln -s ${THISDIR}/bin/test_lim_ext ${HOME}/bin/test_lim_ext; then \ echo "*** Created link from ${HOME}/bin/test_lim_ext"; fi;\ fi;\ else echo "!!! Compilation of bin/test_lim_ext FAILED !!!"; exit; fi bin/test_etat: src-div/Tests/test_etat.f ${OBJS} ${INCLUDES} @ if ${FOR} ${FFLAGS} ${ADFLAGS} src-div/Tests/test_etat.f ${OBJS} -o bin/test_etat; then \ echo ${FOR} ${FFLAGS} ${ADFLAGS} src-div/Tests/test_etat.f ${OBJS} -o bin/test_etat;\ echo "*** Compilation of bin/test_etat successful";\ if [ -d ${HOME}/bin ]; then \ /bin/rm -f ${HOME}/bin/test_etat;\ if ln -s ${THISDIR}/bin/test_etat ${HOME}/bin/test_etat; then \ echo "*** Created link from ${HOME}/bin/test_etat"; fi;\ fi;\ else echo "!!! Compilation of bin/test_etat FAILED !!!"; exit; fi bin/test_eos: tests/test_eos.f ${OBJS} ${OBJS2} ${INCLUDES} @ if ${FOR} ${FFLAGS} tests/test_eos.f ${OBJS} ${OBJS2} -o bin/test_eos; then \ echo ${FOR} ${FFLAGS} tests/test_eos.f ${OBJS} ${OBJS2} -o bin/test_eos;\ echo "*** Compilation of bin/test_eos successful";\ if [ ! -L ${HOME}/bin/test_eos ]; then\ if ln -s ${THISDIR}/bin/test_eos ${HOME}/bin/test_eos; then \ echo "*** Created link from ${HOME}/bin/test_eos"; fi;\ fi;\ else echo "!!! Compilation of bin/test_eos FAILED !!!"; fi bin/test_opa_freedman: tests/test_opa_freedman.f ${OBJS} ${OBJS2} ${INCLUDES} @ if ${FOR} ${FFLAGS} tests/test_opa_freedman.f ${OBJS} ${OBJS2} -o bin/test_opa_freedman; then \ echo ${FOR} ${FFLAGS} tests/test_opa_freedman.f ${OBJS} ${OBJS2} -o bin/test_opa_freedman;\ echo "*** Compilation of bin/test_opa_freedman successful";\ if [ ! -L ${HOME}/bin/test_opa_freedman ]; then\ if ln -s ${THISDIR}/bin/test_opa_freedman ${HOME}/bin/test_opa_freedman; then \ echo "*** Created link from ${HOME}/bin/test_opa_freedman"; fi;\ fi;\ else echo "!!! Compilation of bin/test_opa_freedman FAILED !!!"; fi # Code to transform CEPAM ascii files to binary files and vice versa bin/cepasc2bin: src/cepasc2bin.f src/Listes/rwbin.o src/Maths/leng.o ${INCLUDES} @ echo ${FOR} @ if ${FOR} ${FFLAGS} ${ADFLAGS} src/cepasc2bin.f src/Listes/rwbin.o src/Maths/leng.o -o bin/cepasc2bin; then \ echo ${FOR} ${FFLAGS} ${ADFLAGS} src/cepasc2bin.f src/Listes/rwbin.o src/Maths/leng.o -o bin/cepasc2bin;\ echo "*** Compilation of bin/cepasc2bin successful";\ if [ -d ${HOME}/bin ]; then \ /bin/rm -f ${HOME}/bin/cepasc2bin;\ if ln -s ${THISDIR}/bin/cepasc2bin ${HOME}/bin/cepasc2bin; then \ echo "*** Created link from ${HOME}/bin/cepasc2bin"; fi;\ fi;\ else echo "!!! Compilation of bin/cepasc2bin FAILED !!!"; exit; fi # All object files are assumed to depend on include files ${OBJS}: ${INCLUDES} # This is how EOS data is reconstructed (ASCII -> BIN) ${EOSDATA}: src/a2b_EOS echo echo "****** RECONSTRUCTING BINARY EOS DATA ******" src/a2b_EOS # /bin/rm src/a2b_EOS echo "****** DONE .... ******" echo src/a2b_EOS: ${FOR} src/a2b_EOS.f -o src/a2b_EOS clean: /bin/rm -f core src/*.o src/*/*.o src/*/*.mod src/core expls/*/*.bin expls/*/*.ps data/EOS/*.b* data/*/*bin src/*/*~ src/*~ rmo: /bin/rm -f core src/*.o src/*/*.o src/*/*.mod src/core bin/* force: /bin/rm -f core src/*.o src/core bin/* ${MAKE} save: make tar # The following is to create a tar file # The parameters ${REP} (name of the main directory) and ${SAVED} # must be set properly tar: @ /bin/rm -f core src/core DATE @ /bin/mkdir -p ../diskdir.tmp @ /bin/mkdir -p ../diskdir.tmp/src @ /bin/mkdir -p ../diskdir.tmp/bin @ if /bin/mv -f src/*.o src/*~ ../diskdir.tmp/src/.; then :; fi @ if /bin/mv -f bin/* ../diskdir.tmp/bin/.; then :; fi echo "`date "+%d/%m/%Y %H:%M:%S"`; `whoami`" > DATE cd ..; name_file=${REP}_`date "+%Y_%m_%d"`_`whoami`.tgz;\ if tar cvfz $$name_file --exclude='*.o' --exclude='*.bin' --exclude='*~' ${SAVED};\ then echo "*** I successfully created "$$name_file;\ else echo "!!! I could not create "$$name_file; fi @ if /bin/mv ../diskdir.tmp/bin/* bin/.; then :; fi @ if /bin/mv ../diskdir.tmp/src/* src/.; then :; fi @ /bin/rm -r ../diskdir.tmp # To change the DATE file (eg. before a commit) date: @ /bin/rm -f core src/core DATE @ echo "`date "+%d/%m/%Y %H:%M:%S"`; `whoami`" > DATE @ cat DATE @ cat VERSION