Same code runs on my local machine but not the cluster
<p>So I have a c++ code (with fortran subroutines from netlib.org) which I interface and compile using these instructions:</p>

<pre><code>g++ -c new.cpp
g++ -o new new.o 3j6j9jlib.a -lgfortran
</code></pre>

<p>Where library 3j6j9jlib.a consists of the compiled versions of drc3jm.f, drc6j.f and dependencies (obtained from <a href="http://www.netlib.org/slatec/src/" rel="nofollow">http://www.netlib.org/slatec/src/</a>), as well as the few codes (clebsch.f ninej.f90)which use these as a base to calculate other quantities:</p>

<pre><code>clebsch.o  drc3jm.o  fdump.o   j4save.o  ninej.o   test9j.o  xerhlt.o  xerprn.o  xgetua.o   d1mach.o   drc6j.o   i1mach.o  new.o     r1mach.o  xercnt.o  xermsg.o  xersve.o
</code></pre>

<p>The compilation instructions I used for compilation of the library are:</p>

<pre><code>gfortran -c *.f
gfortran -c *.f90
ar rv 3j6j9jlib.a *.o
</code></pre>

<p>Now the error it gives me when I try to compile the object file new.o is as follows:</p>

<pre><code>-bash-4.1$ g++ -o new new.o 3j6j9jlib.a -lgfortran
3j6j9jlib.a(ninej.o): In function `w9j_':
ninej.f90:(.text+0xc9): undefined reference to `_gfortran_transfer_character_write'
ninej.f90:(.text+0x129): undefined reference to `_gfortran_transfer_character_write'
ninej.f90:(.text+0x147): undefined reference to `_gfortran_transfer_integer_write'
ninej.f90:(.text+0x165): undefined reference to `_gfortran_transfer_integer_write'
ninej.f90:(.text+0x183): undefined reference to `_gfortran_transfer_integer_write'
ninej.f90:(.text+0x1a1): undefined reference to `_gfortran_transfer_integer_write'
ninej.f90:(.text+0x1bf): undefined reference to `_gfortran_transfer_integer_write'
3j6j9jlib.a(ninej.o):ninej.f90:(.text+0x1dd): more undefined references to `_gfortran_transfer_integer_write' follow
3j6j9jlib.a(ninej.o): In function `w9j_':
ninej.f90:(.text+0xeb5): undefined reference to `_gfortran_transfer_character_write'
3j6j9jlib.a(xermsg.o): In function `xermsg_':
xermsg.f:(.text+0xbdd): undefined reference to `_gfortran_transfer_integer_write'
3j6j9jlib.a(xerprn.o): In function `xerprn_':
xerprn.f:(.text+0x2bd): undefined reference to `_gfortran_transfer_character_write'
xerprn.f:(.text+0x7e3): undefined reference to `_gfortran_transfer_character_write'
3j6j9jlib.a(xersve.o): In function `xersve_':
xersve.f:(.text+0x1c7): undefined reference to `_gfortran_transfer_character_write'
xersve.f:(.text+0x1f2): undefined reference to `_gfortran_transfer_character_write'
xersve.f:(.text+0x227): undefined reference to `_gfortran_transfer_character_write'
xersve.f:(.text+0x252): undefined reference to `_gfortran_transfer_integer_write'
xersve.f:(.text+0x27d): undefined reference to `_gfortran_transfer_integer_write'
xersve.f:(.text+0x2a8): undefined reference to `_gfortran_transfer_integer_write'
xersve.f:(.text+0x33d): undefined reference to `_gfortran_transfer_integer_write'
3j6j9jlib.a(d1mach.o): In function `d1mach_':
d1mach.f:(.text+0x644): undefined reference to `_gfortran_stop_numeric_f08'
d1mach.f:(.text+0x6aa): undefined reference to `_gfortran_stop_numeric_f08'
d1mach.f:(.text+0x6d4): undefined reference to `_gfortran_stop_numeric_f08'
d1mach.f:(.text+0x744): undefined reference to `_gfortran_transfer_character_write'
d1mach.f:(.text+0x762): undefined reference to `_gfortran_transfer_integer_write'
d1mach.f:(.text+0x77b): undefined reference to `_gfortran_transfer_character_write'
3j6j9jlib.a(i1mach.o): In function `i1mach_':
i1mach.f:(.text+0x1c0): undefined reference to `_gfortran_stop_numeric_f08'
i1mach.f:(.text+0x51e): undefined reference to `_gfortran_stop_numeric_f08'
i1mach.f:(.text+0x6c8): undefined reference to `_gfortran_transfer_character_write'
i1mach.f:(.text+0x6e6): undefined reference to `_gfortran_transfer_integer_write'
i1mach.f:(.text+0x6ff): undefined reference to `_gfortran_transfer_character_write'
collect2: ld returned 1 exit status
</code></pre>

<p>And this error isn't there on my local machine. It compiles just fine.
I have g++ version 4.8.4 and gfortran version 4.8.4 installed.
The cluster g++ version is 4.4.6 and gfortran version is 4.4.6 installed.
And if anyone requires the code (probably not a problem with it) then:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;string&gt;
#include &lt;string.h&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;
#include &lt;cmath&gt;
#include &lt;stdio.h&gt;
#include &lt;algorithm&gt;
#define pi 3.14159

using namespace std;

extern "C"
{
    double drc3jm_ (double*, double*, double*, 
                double*, double*, double*, double*, int*, int*);

    double drc6j_ (double*, double*, double*, double*, double*, 
                double*, double*, double*, int*, int*);

    double w9j_ (int*, int*, int*, int*, int*, 
                int*, int*, int*, int*, int*, int*, double*);

    double clebsch_ (int*, double*, double*, 
                double*, double*, double*, double*, double*);



}

class imaginary
{
    public:
        double re;
        double im;

        imaginary prod ( imaginary a, imaginary b )
        {
            imaginary c;
            c.re = (a.re*b.re) - (a.im*b.im);
            c.im = (a.im*b.re) + (a.re*b.im);
            return c;
        }

        imaginary add ( imaginary a, imaginary b )
        {
            imaginary c;
            c.re = a.re + b.re;
            c.im = a.im + b.im;
            return c;
        }
        imaginary prod ( imaginary a, double b )
        {
            imaginary c;
            c.re = a.re*b;
            c.im = a.im*b;
            return c;
        }
        void reset (imaginary &amp;a)
        {
            a.re = 0;
            a.im = 0;
//          return a;           
        }


};

//extraction of mask

//change if condition according to what point you want to read it

void extract (vector &lt; vector &lt;imaginary&gt; &gt;&amp; BipoSH)
{
    ifstream wlm;
    wlm.open("wlm.dat");

    if(wlm.is_open())
    {
        double c;
        int l = 0, k = 0; 

        imaginary obj;
        vector &lt;imaginary&gt; lval,lvalf;


        while (!wlm.eof())
        {
            for(int m = 0; m &lt; l+1; m++)
            {
                wlm &gt;&gt; c;
                obj.re = c;
                wlm &gt;&gt; c;
                obj.im = c;

                lval.push_back(obj);
                obj.re = pow(-1,-m)*obj.re;
                obj.im = pow(-1,-m-1)*obj.im;
                lvalf.insert(lvalf.begin(),obj);

            }
            lvalf.insert(lvalf.end(),lval.begin()+1,lval.end());
            BipoSH.push_back(lvalf);
            lval.clear();
            lvalf.clear();

            l++;
            if( l &gt; 500 )       //this is the condition we need to change. here l is l1
                return ;

        }
        return ;


    }
    else 
        cout&lt;&lt;"File isn't open"&lt;&lt;endl;
    wlm.close();
}

//extraction of power coeffs

//change m maximum value in for loop according to what point you wish to read the power spepctrum values

void power(vector &lt;double&gt;&amp; Power)
{
    ifstream Cl;
    Cl.open("Cl_val.dat");
    double c;
    if(Cl.is_open())
    {
        while(!Cl.eof())
        {
            for(int m =0; m &lt; 1000; m++)            //change the condition m&lt;65 to any other condition
            {
                Cl &gt;&gt; c;
                Cl &gt;&gt; c;
                Power.push_back(c);
            }
            return ;
        }
    }
    else
        cout&lt;&lt;"File didn't open"&lt;&lt;endl;
    Cl.close();
}

//links clebsch function of fortran to c++

double* cleb ( double L, double L1, double L2, double M, double &amp; Mmin, double &amp; Mmax )
{
    double* clebsch;
    int N = 500;

    clebsch = new double [ N ];

    clebsch_ ( &amp;N, &amp;L, &amp;L1, &amp;L2, &amp;M, &amp;Mmin, &amp;Mmax, clebsch );  

    return clebsch ;
}
/*

F and Hcalc calculate the shape function.

*/

double F(int l1,int L, int l2)
{
    return (l1*(l1+1)+L*(L+1)-l2*(l2+1))/2;
}


double Hcalc(int L, int l1, int l2, vector &lt;double&gt; c)
{
    double Gmod,Gabr;
    double Mmin,Mmax;
    double *clebsch = cleb(L, l1, l2, 0, Mmin, Mmax);
    double b = 3.0;
    Gmod = clebsch[0];
    Gmod*=pow(2*l1+1,0.5)*pow(2*l2+1,0.5)/pow(2*L+1,0.5);
    Gmod*=pow(4*pi,-0.5)*(c.at(l1)+c.at(l2));
    Gabr = pow(4*pi,-0.5)*((c.at(l1)*F(l1,L,l2))+(c.at(l2)*F(l2,L,l1)));
    return (b*Gmod) - Gabr;
}


int main()
{

   clock_t t;
    t = clock();

    int ier, k, N = 500;

    double* coef9j;
    double h;
    double M2min = 0, M2max = 0, Mmin = 0, Mmax = 0, M1min = 0, M1max = 0;

    imaginary temp, temp1, temp2, ugabuga;
    temp.re = 0;
    temp.im = 0;

    vector &lt; vector &lt; vector &lt; vector &lt;imaginary&gt; &gt; &gt; &gt; Lvec;
    vector &lt; vector &lt; vector &lt;imaginary&gt; &gt; &gt; L1vec;
    vector &lt; vector &lt;imaginary&gt; &gt; L2vec, Kvec;
    vector &lt;imaginary&gt; Mvec, Kl2vec;

    vector &lt; vector &lt;imaginary&gt; &gt; Bip;
    vector &lt;double&gt; c_val;
    extract(Bip);
    power(c_val);

    cout&lt;&lt;"extraction is done"&lt;&lt;endl;

    //now I begin calculation of mask

    int L, Lmax = 10, L1, L1max = 30, L2, L2max, M, L5max = 30;


    //change L1max, L5max according to what you want to calculate

    //they are computationally epensive so don't go above L1max = 50, L5max = 50

    //L5max must be equal to L1max

    //Lmax is fed according to what mask value we want to calculate upto


    for ( L = 0; L &lt; Lmax; L++ )
    {
        for ( L1 = 0; L1 &lt; L1max; L1++ )
        {
            for ( L2 = abs(L - L1); L2 &lt; abs(L + L1)+1; L2++ )
            {
                for(M = -L;M&lt;L+1;M++)
                {
                    double* clebsch = cleb( L, L1, L2, M, M1min, M1max );
                    for ( int i = (int)M1min; i &lt; (int)M1max + 1; i++ )
                    {

                        temp1.re = Bip.at(L1).at(i+L1).re*clebsch[i-(int)M1min];
                        temp1.im = Bip.at(L1).at(i+L1).im*clebsch[i-(int)M1min];

                        temp2.re = Bip.at(L2).at(M-i+L2).re;
                        temp2.im = Bip.at(L2).at(M-i+L2).im;

                        temp = ugabuga.add( temp, ugabuga.prod( temp1, temp2 ) );

                    }
                    Mvec.push_back(temp);
                    temp.re = 0;
                    temp.im = 0;
                }
                L2vec.push_back(Mvec);
            }
            L1vec.push_back(L2vec);
            L2vec.clear();
        }
        Lvec.push_back(L1vec);
        L1vec.clear();
    }
    //delete *L1vec, *L2vec, *Mvec;
    vector&lt; vector &lt; vector &lt;imaginary&gt; &gt; &gt;().swap(L1vec);
    vector&lt; vector &lt;imaginary&gt; &gt;().swap(L2vec);
    vector &lt;imaginary&gt;().swap(Mvec);

    cout&lt;&lt;"Mask parsed into vector"&lt;&lt;endl;

    double temporary;
    imaginary im,sum;
    int Lprime, Mprime;
    int m=0,x=0;
    int t1,t2;


    ugabuga.reset(sum);

    //now I begin calculation of the MSF

    //L1max, L5max take the value previously declared


    L = 1; M = 0; Lprime = 1, Mprime = 0;
    for (L1 =0; L1 &lt; L1max;L1++)
    {
        for (L2 = abs(L1-L);L2&lt;abs(L1+L)+1; L2++)
        {
            for(int l5=0;l5&lt;L5max;l5++)
            {
                for(int J=abs(L-Lprime);J&lt;abs(L+Lprime)+1;J++)
                {
                    for(int l6=abs(l5-J);l6&lt;abs(l5+J)+1;l6++)
                    {
                        for(int l3=min(abs(L1-l5),(int)c_val.size()-L);l3&lt;min((L1+l5),(int)c_val.size()-L)+1;l3++)
                        {
                            if(abs(L1-l5)&gt;(int)c_val.size()-L)
                            {
                                return 0;
                            }

                            t2 = min(l3+Lprime,L2+l6);
                            t1 = max(abs(l3-Lprime),abs(L2-l6));
                            N = t2-t1+1;

                            if(N&lt;1)
                                continue;

                            coef9j = new double [ N ];

                            w9j_ ( &amp;Lprime, &amp;l3, &amp;l6, &amp;J, &amp;l5, &amp;L2, &amp;L, &amp;L1, &amp;t1, &amp;t2, &amp;N, coef9j );

                            for(int l4 = max(abs(l3-Lprime),abs(L2-l6));l4&lt;min(l3+Lprime,L2+l6)+1;l4++)
                            {
                                //cout&lt;&lt;"l4 "&lt;&lt;l4&lt;&lt;endl;
                                h=pow(2*Lprime+1,0.5)*pow(2*l3+1,0.5)*pow(2*l4+1,0.5)*pow(4*pi,-0.5);
                                //cout&lt;&lt;"power mult "&lt;&lt;h&lt;&lt;endl;
                                h*=Hcalc(Lprime,l3,l4,c_val);
                                //cout&lt;&lt;"after Hcalc "&lt;&lt;h&lt;&lt;endl;

                                temporary = h*pow(2*l5+1,0.5)*pow(2*l6+1,0.5)*pow(4*pi,-0.5);
                                //cout&lt;&lt;"temporary "&lt;&lt;temporary&lt;&lt;endl; 
                                double* cleb1 = cleb( L1, l3, l5, m, M1min, M1max );
                                //cout&lt;&lt;"cleb1"&lt;&lt;endl;

                                //cout&lt;&lt;"L2, l4, l6, m:"&lt;&lt;L2&lt;&lt;" "&lt;&lt;l4&lt;&lt;" "&lt;&lt;l6&lt;&lt;" "&lt;&lt;m&lt;&lt;endl;

                                double* cleb2 = cleb( L2, l4, l6, m, M2min, M2max );
                                //cout&lt;&lt;"cleb2"&lt;&lt;endl;

                                temporary = temporary*cleb1[0]*cleb2[0];
                                double* cleb3 = cleb( L, Lprime, J, M, Mmin, Mmax );
                                //cout&lt;&lt;"cleb3"&lt;&lt;endl;

                                temporary = temporary*coef9j[l4-max(abs(l3-L),abs(L2-l6))]*pow(2*J+1,0.5);
                                //cout&lt;&lt;"temporary after w9j multi "&lt;&lt;temporary&lt;&lt;endl;
                                //cout&lt;&lt;"coef9j hoga pakka se"&lt;&lt;endl;
                                temporary = temporary*cleb3[Mprime-(int)Mmin];
                                //cout&lt;&lt;"last temp "&lt;&lt;temporary&lt;&lt;endl;
                                im = ugabuga.prod(Lvec.at(J).at(l5).at(l6-abs(l5-J)).at(M-Mprime),temporary);
                                sum = ugabuga.add(sum,im);
                                //cout&lt;&lt;"this is the sum"&lt;&lt;sum.re&lt;&lt;endl;
                                delete cleb1;
                                delete cleb2;
                                delete cleb3;
                            }
                            delete coef9j;

                        }
                    }
                }
            }
            Kl2vec.push_back(sum);
            ugabuga.reset(sum);
        }
        Kvec.push_back(Kl2vec);
        Kl2vec.clear();
        //if(L1%5==0)
            cout&lt;&lt;"MSF upto l1 = "&lt;&lt;L1&lt;&lt;" is done"&lt;&lt;endl;
    }

    cout&lt;&lt;"MSF parsed into a vector"&lt;&lt;endl;

    //now I start writing the results into a file

    //filename is stored in string s

    fstream foo;

    string s;
    char g[10],j[100];
    int b=0;

    sprintf(j,"L_%dLprime_%dM_%dMprime_%d",L,Lprime,M,Mprime);
    for(int i=0;i&lt;(int)strlen(j);i++)
        s.push_back(j[i]);

    int l=0;
    l=s.size();

    s+=".dat";

    foo.open(s.c_str(), ios::out | ios::binary );
    b = 0;

    if(foo.is_open())   
    for(L1=0;L1&lt;L1max;L1++)
    {
        foo &lt;&lt; L1&lt;&lt;"    ";

        for(L2 = abs(L-L1);L2&lt;abs(L+L1)+1;L2++)
        {           
                foo &lt;&lt;" "&lt;&lt;Kvec.at(L1).at(L2-abs(L-L1)).re&lt;&lt;"   "&lt;&lt;Kvec.at(L1).at(L2-abs(L-L1)).im;         
        }
        foo&lt;&lt;endl;
    }
    else
    {
        cout&lt;&lt;"not open"&lt;&lt;endl;
    }

    foo.close();


    cout&lt;&lt;"file writing done"&lt;&lt;endl;

    //displaying the time taken for the process now

    t = clock() - t;
    cout&lt;&lt;"Time = "&lt;&lt;(float)t/CLOCKS_PER_SEC&lt;&lt;endl;

}
</code></pre>

<p>Any help would be greatly appreciated. Clawing my hair out for the possible reason of the error. Please comment on what other information I should provide since I am clueless.</p>