<p>The SM developers seem to have <a href="https://www.astro.princeton.edu/%7Erhl/sm/sm.html#SEC51" rel="nofollow noreferrer">anticipated</a> such issues.
In your <code>nm</code> output sample,
<br/><code>T sm_ylabel</code> is the native C function, and
<br/><code>T sm_ylabel_</code> is its wrapper to be called from Fortran.</p>
<p><code>gfortran</code> usually appends single underscores to external symbol names.
If the MOOG object files were in fact built with the <code>gfortran</code> options in the question, the symbol references should match the wrappers in the SM library.
The double underscore suffixes may be left over from a prior build attempt with <code>-ff2c</code>.
When you change compiler options, remember to <code>make clean</code> before rebuilding.</p>
<p>If that doesn't lead to a solution, and nothing else is using SM,
the SM manual <a href="https://www.astro.princeton.edu/%7Erhl/sm/sm.html#SEC57" rel="nofollow noreferrer">suggests</a>
that you could rebuild it with this in its <code>options.h</code>:</p>
<pre><code>#define FORTRAN_APPEND __
</code></pre>

CC BY-SA 4.0
2020-10-08T19:55:58.960Z
Thanks! Cleaning and recompiling did the trick!
anine
CC BY-SA 4.0
2020-09-06T19:13:54.193Z
2020-09-06T19:20:35.560Z
2020-09-06T19:20:35.560Z
Mike G
<p>I've been trying to install MOOG Nov2019 (<a href="http://www.as.utexas.edu/%7Echris/moog.html" rel="nofollow noreferrer">utexas</a>, <a href="https://en.wikipedia.org/wiki/Moog_(code)" rel="nofollow noreferrer">Wiki</a>) on my desktop running OpenSUSE 13.1. I have the SM and X11 library paths copied into the makefile, and I am <em>3-sigma confident</em> that they are the correct pathways. I'm using cc as the C compiler, and gfortan for Fortran. When I run the makefile, I get a string of errors that looks like this:</p>
<pre><code>gfortran -Wall -g -std=legacy 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 Moog.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 -o MOOG -L/usr/local/lib/X11  -lX11 \
        -L/usr/local/pkg/sm/2.4.36-F90/lib -lplotsub -ldevices -lutils

Abunplot.o: In function `abunplot_':
Abunplot.f:(.text+0x624): undefined reference to `sm_defvar__'
Abunplot.f:(.text+0x64e): undefined reference to `sm_window__'
Abunplot.f:(.text+0x66c): undefined reference to `sm_limits__'
Abunplot.f:(.text+0x6c6): undefined reference to `sm_ticksize__'
.
.
.
</code></pre>
<p>Running the nm command in the sm library yields:</p>
<pre><code>&gt; nm /usr/local/pkg/sm/2.4.36-F90/lib/libplotsub.a | grep ylabel
0000000000001cc6 T sm_ylabel
                 U sm_ylabel
0000000000000dae T sm_ylabel_
                 U sm_ylabel
</code></pre>
<p>Based on the readme for MOOGStokes (<a href="https://www2.mpia-hd.mpg.de/homes/deen/Software/MoogStokes/MoogStokes.README.txt" rel="nofollow noreferrer">https://www2.mpia-hd.mpg.de/homes/deen/Software/MoogStokes/MoogStokes.README.txt</a>), it looks like this error arises from how gfortran and SM handle underscores. I've tried using the gfortran flags listed in the MOOGStokes readme, but the problem persists. Are there other flags I should use, or is there another way to resolve this?</p>

CC BY-SA 4.0
2020-09-05T13:56:54.463Z
MOOG obviously has dependencies. Have you satisfied those dependencies>
David Hammen
CC BY-SA 4.0
2020-09-05T14:29:07.310Z
Try adding `-fno-second-underscore` to the gfortran compile flags
astrosnapper
CC BY-SA 4.0
2020-09-05T21:39:10.620Z
@astrosnapper  - No luck including that flag.
anine
CC BY-SA 4.0
2020-09-05T21:39:20.910Z
@DavidHammen - Which dependencies are you referring to?
anine
CC BY-SA 4.0
2020-10-08T19:56:39.960Z
@uhoh Yes! Sorry, I had gotten caught up in other work
anine
<spectroscopy><software>
MOOG 2019 and gfortran
anine
# MOOG 2019 and gfortran

(Asked by: username_0 on 2020-09-04)

I've been trying to install MOOG Nov2019 (utexas, Wiki) on my desktop running OpenSUSE 13.1. I have the SM and X11 library paths copied into the makefile, and I am 3-sigma confident that they are the correct pathways. I'm using cc as the C compiler, and gfortan for Fortran. When I run the makefile, I get a string of errors that looks like this:
gfortran -Wall -g -std=legacy 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 Moog.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 -o MOOG -L/usr/local/lib/X11  -lX11 \
        -L/usr/local/pkg/sm/2.4.36-F90/lib -lplotsub -ldevices -lutils

Abunplot.o: In function `abunplot_':
Abunplot.f:(.text+0x624): undefined reference to `sm_defvar__'
Abunplot.f:(.text+0x64e): undefined reference to `sm_window__'
Abunplot.f:(.text+0x66c): undefined reference to `sm_limits__'
Abunplot.f:(.text+0x6c6): undefined reference to `sm_ticksize__'
.
.
.

Running the nm command in the sm library yields:
> nm /usr/local/pkg/sm/2.4.36-F90/lib/libplotsub.a | grep ylabel
0000000000001cc6 T sm_ylabel
                 U sm_ylabel
0000000000000dae T sm_ylabel_
                 U sm_ylabel

Based on the readme for MOOGStokes (https://www2.mpia-hd.mpg.de/homes/deen/Software/MoogStokes/MoogStokes.README.txt), it looks like this error arises from how gfortran and SM handle underscores. I've tried using the gfortran flags listed in the MOOGStokes readme, but the problem persists. Are there other flags I should use, or is there another way to resolve this?

**Tags:** spectroscopy, software
> **Comments:**
> **username_1**: MOOG obviously has dependencies. Have you satisfied those dependencies>  
> **username_2**: Try adding `-fno-second-underscore` to the gfortran compile flags  
> **username_0**: @astrosnapper  - No luck including that flag.  
> **username_0**: @DavidHammen - Which dependencies are you referring to?  
> **username_0**: @uhoh Yes! Sorry, I had gotten caught up in other work  

---

## 1 answers

### Answer by username_3 on 2020-09-06. Score: 1 | Accepted answer

The SM developers seem to have anticipated such issues.
In your nm output sample,
T sm_ylabel is the native C function, and
T sm_ylabel_ is its wrapper to be called from Fortran.
gfortran usually appends single underscores to external symbol names.
If the MOOG object files were in fact built with the gfortran options in the question, the symbol references should match the wrappers in the SM library.
The double underscore suffixes may be left over from a prior build attempt with -ff2c.
When you change compiler options, remember to make clean before rebuilding.
If that doesn't lead to a solution, and nothing else is using SM,
the SM manual suggests
that you could rebuild it with this in its options.h:
#define FORTRAN_APPEND __

> **Comments:**
> **username_0**: Thanks! Cleaning and recompiling did the trick!  

---

