From dfad515da194aa1a2dd4a9057b5cf4b5503787cd Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 5 Aug 2021 14:05:21 -0400 Subject: Add basic configuration script * Generate Moog.f with correct data path * Generate Makefile with properties set by configure script --- Makefile | 63 ------------------------------- Makefile.in | 79 +++++++++++++++++++++++++++++++++++++++ Moog.f | 117 ---------------------------------------------------------- Moog.f.in | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 79 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 278 insertions(+), 180 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.in delete mode 100755 Moog.f create mode 100755 Moog.f.in create mode 100755 configure diff --git a/Makefile b/Makefile deleted file mode 100644 index 9cc5c09..0000000 --- a/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# makefile for MOOG with all of the common block assignments; - -# here are the object files -OBJECTS = Abfind.o Abpop.o Abunplot.o Batom.o Begin.o Binary.o \ - Binplot.o Binplotprep.o Blankstring.o Blends.o Bmolec.o Boxit.o \ - Calmod.o Cdcalc.o Chabund.o Cog.o Cogplot.o Cogsyn.o \ - Correl.o Crosscorr.o Curve.o Damping.o Defcolor.o Discov.o \ - Doflux.o Drawcurs.o Eqlib.o Ewfind.o \ - Ewweighted.o Fakeline.o Findtic.o Finish.o \ - Fluxplot.o Gammabark.o Getasci.o Getcount.o Getnum.o Getsyns.o \ - Gridplo.o Gridsyn.o Infile.o Inlines.o Inmodel.o Invert.o \ - Jexpint.o Lineinfo.o Lineabund.o Linlimit.o \ - Makeplot.o Molquery.o Mydriver.o \ - Nansi.o Nearly.o Number.o Obshead.o \ - Oneline.o Opaccouls.o OpacHelium.o OpacHydrogen.o \ - Opacit.o Opacmetals.o Opacscat.o Params.o Partfn.o \ - Partnew.o Plotit.o Plotremember.o Pltabun.o Pltcog.o \ - Pltflux.o Pltspec.o Pointcurs.o Prinfo.o Putasci.o Readobs.o \ - Rinteg.o Setmols.o Smooth.o Specplot.o Stats.o Sunder.o Synpop.o \ - Synspec.o Synth.o Tablepop.o Taukap.o Total.o Trudamp.o Ucalc.o \ - Vargauss.o Vmacro.o Voigt.o Wavecalc.o Weedout.o Writenumber.o - -MOOG_ENTRY = Moog.o -MOOGSILENT_ENTRY = Moogsilent.o - -# here are the common files -COMMON = Atmos.com Dummy.com Equivs.com Factor.com Kappa.com Linex.com \ - Mol.com Multistar.com Obspars.com Pstuff.com \ - Quants.com Multimod.com Dampdat.com - -# the following lines point to some needed libraries -X11LIB = /usr/X11/lib -SMLIB = /usr/local/lib - -ifeq ($(MODERN_GCC), 1) -FFLAGS_GCC10PLUS=-fallow-argument-mismatch -endif - -FC = gfortran -FFLAGS = -Wall -Wextra -ff2c -fdefault-double-8 -fdefault-real-8 $(FFLAGS_GCC10PLUS) -LDFLAGS = -L$(X11LIB) -lX11 -ltcl -ltk -L$(SMLIB) -lplotsub -ldevices -lutils - -# here are the compilation and linking commands -all: MOOG MOOGSILENT - @echo ----------------------------------------------------------------- - @echo - @echo Set MOOG_DATA environment variable to path containing file\(s\): - @for x in *.dat; \ - do echo $$x; \ - done - @echo - @echo ----------------------------------------------------------------- - -MOOG: $(OBJECTS); - $(FC) -o MOOG $(MOOG_ENTRY) $(OBJECTS) $(FFLAGS) $(LDFLAGS) - -MOOGSILENT: $(OBJECTS) $(MOOGSILENT_ENTRY); - $(FC) -o MOOGSILENT $(MOOGSILENT_ENTRY) $(OBJECTS) $(FFLAGS) $(LDFLAGS) - -$(OBJECTS): $(COMMON) $(MOOG_ENTRY) $(MOOGSILENT_ENTRY) - -clean: - -rm -f *.o MOOG MOOGSILENT diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..6f7dc9a --- /dev/null +++ b/Makefile.in @@ -0,0 +1,79 @@ +# makefile for MOOG with all of the common block assignments; + +PREFIX=@PREFIX@ +BINDIR=@BINDIR@ +DATADIR=@DATADIR@ + +# here are the object files +OBJECTS = Abfind.o Abpop.o Abunplot.o Batom.o Begin.o Binary.o \ + Binplot.o Binplotprep.o Blankstring.o Blends.o Bmolec.o Boxit.o \ + Calmod.o Cdcalc.o Chabund.o Cog.o Cogplot.o Cogsyn.o \ + Correl.o Crosscorr.o Curve.o Damping.o Defcolor.o Discov.o \ + Doflux.o Drawcurs.o Eqlib.o Ewfind.o \ + Ewweighted.o Fakeline.o Findtic.o Finish.o \ + Fluxplot.o Gammabark.o Getasci.o Getcount.o Getnum.o Getsyns.o \ + Gridplo.o Gridsyn.o Infile.o Inlines.o Inmodel.o Invert.o \ + Jexpint.o Lineinfo.o Lineabund.o Linlimit.o \ + Makeplot.o Molquery.o Mydriver.o \ + Nansi.o Nearly.o Number.o Obshead.o \ + Oneline.o Opaccouls.o OpacHelium.o OpacHydrogen.o \ + Opacit.o Opacmetals.o Opacscat.o Params.o Partfn.o \ + Partnew.o Plotit.o Plotremember.o Pltabun.o Pltcog.o \ + Pltflux.o Pltspec.o Pointcurs.o Prinfo.o Putasci.o Readobs.o \ + Rinteg.o Setmols.o Smooth.o Specplot.o Stats.o Sunder.o Synpop.o \ + Synspec.o Synth.o Tablepop.o Taukap.o Total.o Trudamp.o Ucalc.o \ + Vargauss.o Vmacro.o Voigt.o Wavecalc.o Weedout.o Writenumber.o + +MOOG_ENTRY = Moog.o +MOOGSILENT_ENTRY = Moogsilent.o + +# here are the common files +COMMON = Atmos.com Dummy.com Equivs.com Factor.com Kappa.com Linex.com \ + Mol.com Multistar.com Obspars.com Pstuff.com \ + Quants.com Multimod.com Dampdat.com + +# the following lines point to some needed libraries +X11LIB = @WITH_X11@ +SMLIB = @WITH_SM@ + +FC = gfortran +FFLAGS = @FFLAGS@ +LDFLAGS = -L$(X11LIB) -lX11 -ltcl -ltk -L$(SMLIB) -lplotsub -ldevices -lutils + +# here are the compilation and linking commands +all: MOOG MOOGSILENT + @echo ----------------------------------------------------------------- + @echo + @echo Default MOOG_DATA path is $(DATADIR) + @echo + @echo To override this behavior set the MOOG_DATA environment variable + @echo + @echo "BASH: export MOOG_DATA=/path/to/dat/files" + @echo " CSH: setenv MOOG_DATA /path/to/dat/files" + @echo + @echo ----------------------------------------------------------------- + +MOOG: $(OBJECTS) + $(FC) -o MOOG $(MOOG_ENTRY) $(OBJECTS) $(FFLAGS) $(LDFLAGS) + +MOOGSILENT: $(OBJECTS) $(MOOGSILENT_ENTRY); + $(FC) -o MOOGSILENT $(MOOGSILENT_ENTRY) $(OBJECTS) $(FFLAGS) $(LDFLAGS) + +$(OBJECTS): $(COMMON) $(MOOG_ENTRY) $(MOOGSILENT_ENTRY) + +install: all + @for x in $(DESTDIR)$(BINDIR) $(DESTDIR)$(DATADIR); do \ + echo Creating $$x; \ + mkdir -p $(DESTDIR)$$x; \ + done; + @for x in MOOG MOOGSILENT; do \ + echo Installing $$x to $(DESTDIR)$(BINDIR); \ + install -m755 $$x $(DESTDIR)$(BINDIR); \ + done; + @for x in *.dat; do \ + echo Installing $$x to $(DESTDIR)$(DATADIR); \ + install -m755 $$x $(DESTDIR)$(DATADIR);\ + done; + +clean: + -rm -f *.o MOOG MOOGSILENT Makefile Moog.f diff --git a/Moog.f b/Moog.f deleted file mode 100755 index c9ac072..0000000 --- a/Moog.f +++ /dev/null @@ -1,117 +0,0 @@ - - program moog -c****************************************************************************** -c This is the main driver for MOOG. It reads the parameter -c file and sends MOOG to various controlling subroutines. -c This is the normal interactive version of the code; for batch -c processing without user decisions, run MOOGSILENT instead. -c****************************************************************************** - - include 'Atmos.com' - include 'Pstuff.com' - character yesno*1 - - -c$$$$$$$$$$$$$$$$$$$$$$$$ USER SETUP AREA $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -c*****in compiling MOOG, here the various machine-specific things are -c declared. First, define the directory where MOOG lives, in order to -c be able to pull in auxiliary data files; executing 'make' will -c generate a reminder of this necessity - write (moogpath,1001) - call get_environment_variable("MOOG_DATA", moogpath) - - -c*****What kind of machine are you using? Possible ones are: -c OBSOLETE -c "mac" = Intel-based Apple Mac -c "pcl" = a PC or desktop running some standard linux like Redhat -c "uni" = a machine running Unix, specifically Sun Solaris - machine = "" - - -c*****for x11 terminal types, define the parameters of plotting windows; -c set up an x11 screen geometry and placement that is good for spectrum -c syntheses (long, but not tall); the user should play with the format -c statements for particular machines. - write (smt1,1018) -c now do the same for line abundance trend plots (short but tall). - write (smt2,1017) -c$$$$$$$$$$$$$$$$$$$$$$$ END OF USER SETUP $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ - - -c*****declare this to be the normal interactive version; variable "silent" -c will be queried on all occasions that might call for user input; -c DON'T CHANGE THIS VARIABLE; -c if silent = 'n', the normal interactive MOOG is run; -c if silent = 'y', the non-interactive MOOG is run - silent = 'n' - - -c*****invoke the overall starting routine -1 control = ' ' - call begin - - -c*****use one of the standard driver routines - if (control == 'synplot') then - call plotit - elseif (control == 'synth ') then - call synth - elseif (control == 'cogsyn ') then - call cogsyn - elseif (control == 'blends ') then - call blends - elseif (control == 'abfind ') then - call abfind - elseif (control == 'ewfind ') then - call ewfind - elseif (control == 'cog ') then - call cog - elseif (control == 'calmod ') then - call calmod - elseif (control == 'doflux ') then - call doflux - elseif (control == 'weedout') then - call weedout - elseif (control == 'gridsyn') then - call gridsyn - elseif (control == 'gridplo') then - call gridplo - elseif (control == 'binary ') then - call binary - elseif (control == 'abpop ') then - call abpop - elseif (control == 'synpop ') then - call synpop - - -c*****or, put in your own drivers in the form below.... - elseif (control == 'mine ') then - call mydriver - - -c*****or else you are out of luck! - else - array = 'THIS IS NOT ONE OF THE DRIVERS. TRY AGAIN (y/n)?' - istat = ivwrite (4,3,array,49) - istat = ivmove (3,1) - read (*,*) yesno - if (yesno == 'y') then - go to 1 - else - call finish (0) - endif - endif - - -c*****format statements -1001 format (60(' ')) -1003 format (22x,'MOOG IS CONTROLLED BY DRIVER ',a7) -1017 format ('x11 -bg black -title MOOGplot -geom 700x800+650+000') -1018 format ('x11 -bg black -title MOOGplot -geom 1200x350+20+450') - - - end - - - diff --git a/Moog.f.in b/Moog.f.in new file mode 100755 index 0000000..cb63e11 --- /dev/null +++ b/Moog.f.in @@ -0,0 +1,120 @@ + + program moog +c****************************************************************************** +c This is the main driver for MOOG. It reads the parameter +c file and sends MOOG to various controlling subroutines. +c This is the normal interactive version of the code; for batch +c processing without user decisions, run MOOGSILENT instead. +c****************************************************************************** + + include 'Atmos.com' + include 'Pstuff.com' + character yesno*1 + + +c$$$$$$$$$$$$$$$$$$$$$$$$ USER SETUP AREA $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +c*****in compiling MOOG, here the various machine-specific things are +c declared. First, define the directory where MOOG lives, in order to +c be able to pull in auxiliary data files; executing 'make' will +c generate a reminder of this necessity + write (moogpath,1001) + call get_environment_variable("MOOG_DATA", moogpath) + + if (moogpath == "") then + moogpath = "@MOOGPATH_DEFAULT@" + endif + +c*****What kind of machine are you using? Possible ones are: +c OBSOLETE +c "mac" = Intel-based Apple Mac +c "pcl" = a PC or desktop running some standard linux like Redhat +c "uni" = a machine running Unix, specifically Sun Solaris + machine = "" + + +c*****for x11 terminal types, define the parameters of plotting windows; +c set up an x11 screen geometry and placement that is good for spectrum +c syntheses (long, but not tall); the user should play with the format +c statements for particular machines. + write (smt1,1018) +c now do the same for line abundance trend plots (short but tall). + write (smt2,1017) +c$$$$$$$$$$$$$$$$$$$$$$$ END OF USER SETUP $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + +c*****declare this to be the normal interactive version; variable "silent" +c will be queried on all occasions that might call for user input; +c DON'T CHANGE THIS VARIABLE; +c if silent = 'n', the normal interactive MOOG is run; +c if silent = 'y', the non-interactive MOOG is run + silent = 'n' + + +c*****invoke the overall starting routine +1 control = ' ' + call begin + + +c*****use one of the standard driver routines + if (control == 'synplot') then + call plotit + elseif (control == 'synth ') then + call synth + elseif (control == 'cogsyn ') then + call cogsyn + elseif (control == 'blends ') then + call blends + elseif (control == 'abfind ') then + call abfind + elseif (control == 'ewfind ') then + call ewfind + elseif (control == 'cog ') then + call cog + elseif (control == 'calmod ') then + call calmod + elseif (control == 'doflux ') then + call doflux + elseif (control == 'weedout') then + call weedout + elseif (control == 'gridsyn') then + call gridsyn + elseif (control == 'gridplo') then + call gridplo + elseif (control == 'binary ') then + call binary + elseif (control == 'abpop ') then + call abpop + elseif (control == 'synpop ') then + call synpop + + +c*****or, put in your own drivers in the form below.... + elseif (control == 'mine ') then + call mydriver + + +c*****or else you are out of luck! + else + array = 'THIS IS NOT ONE OF THE DRIVERS. TRY AGAIN (y/n)?' + istat = ivwrite (4,3,array,49) + istat = ivmove (3,1) + read (*,*) yesno + if (yesno == 'y') then + go to 1 + else + call finish (0) + endif + endif + + +c*****format statements +1001 format (60(' ')) +1003 format (22x,'MOOG IS CONTROLLED BY DRIVER ',a7) +1017 format ('x11 -bg black -title MOOGplot -geom 700x800+650+000') +1018 format ('x11 -bg black -title MOOGplot -geom 1200x350+20+450') + + + end + + + diff --git a/configure b/configure new file mode 100755 index 0000000..eaa9884 --- /dev/null +++ b/configure @@ -0,0 +1,79 @@ +#!/bin/bash +with_x11="/usr/X11/lib" +with_sm="/usr/local/sm" +fflags=(-Wall -Wextra -ff2c -fdefault-double-8 -fdefault-real-8) + +gcc_version=$(gcc --version | head -n 1 | awk -F' ' '{ print $3 }') +gcc_major="${gcc_version%%\.*}" + +if (( $gcc_major >= 10 )); then + fflags+=(--allow-argument-mismatch) +fi + +argv=() +for x in $@; do + if [[ "$x" =~ .*=.* ]]; then + key="${x%=*}" + value="${x#*=}" + argv+=($key) + argv+=($value) + else + argv+=(x) + fi +done + + +i=0 +nargs=${#argv[@]} +while [[ $i < $nargs ]]; do + key="${argv[$i]}" + value="${argv[$i+1]}" + case "$key" in + --prefix) + prefix="$value" + (( i++ )) + ;; + --bindir) + bindir="$value" + (( i++ )) + ;; + --datadir) + datadir="$value" + (( i++ )) + ;; + --with-x11) + with_x11="$value" + (( i++ )) + ;; + --with-sm) + with_sm="$value" + (( i++ )) + ;; + esac + (( i++ )) +done + +[[ -z "${prefix}" ]] && prefix="/usr/local" +[[ -z "${bindir}" ]] && bindir="${prefix}/bin" +[[ -z "${datadir}" ]] && datadir="${prefix}/share/moog" +fflags="${fflags[@]}" +sed "s|@PREFIX@|${prefix}|g;\ + s|@BINDIR@|${bindir}|g;\ + s|@DATADIR@|${datadir}|g;\ + s|@FFLAGS@|${fflags}|g;\ + s|@WITH_X11@|${with_x11}|g;\ + s|@WITH_SM@|${with_sm}|g;\ + " Makefile.in > Makefile +sed "s|@MOOGPATH_DEFAULT@|${datadir}/|" Moog.f.in > Moog.f + +printf " +Configured with: + +Installation prefix ... %s +X11 library ........... %s +SuperMongo library .... %s + +Run 'make' to compile +Run 'make install' to install + +" $prefix $with_x11 $with_sm -- cgit