Search code examples
plotfortrangfortrandouble-precision

DISLIN double-precision libraries


I am trying to compile a program written in FORTRAN that plots graphs using the DISLIN libraries, but all data is in double precision. I cannot lose this precision, so passing everything to simple precision is not an option. When I attempt to link to the double precision libraries (_d), I still get the following error I would expect had I linked to simple precision libraries:

call graf(-1.D0, 1.D0, -1.D0, 2.D0/10.D0, -1.D0, 1.D0, -1.D0, 2.D0/10.)
         (1)
ERROR: Type mismatch in argument 'ax' at (1); passed from REAL(8) to REAL(4).

I also get other such errors in all plotting statements. My compiling command is (gfortran):

gfortran modulename.f95 progname.f95  C:\dislin\disgf_d.a -luser32 -lgdi32 -lopengl32

Note that disgf_d refers to the double precision libraries. Does anyone have any ideas here?

Relevant code:

call metafl("XWIN")
call disini()
call graf(-1.D0, 1.D0, -1.D0, 2.D0/10.D0, -1.D0, 1.D0, -1.D0, 2.D0/10.D0)
do i = 0, m
    Z(i) = -1.D0 + (2.D0*i) / m
    Y_Z(i) = Int_g(Z(i))
end do
call curve (Z, Y_Z, m + 1)
do i = 0, m
    Y_Z(i) = g(Z(i))
end do
call curve (Z, Y_Z, m + 1)
call endgrf()
call disfin()

Solution

  • I found that the solution was in the .MOD file with the machine code. Naturally, this object file has to correspond with the double precision libraries, and the default after installing DISLIN is for the .MOD file to refer to the simple precision libraries. There exists in a folder named real64 another dislin.MOD file that DOES correspond with the double precision files, however this usually won't work as it was compiled on another machine. One must compile the dislin.f90 file in the real 64 folder into the main dislin directory, replacing the default .MOD file, using the gfortran command:

    gfortran -c dislin.f90
    

    The -c indicates that the f.90 file won't be compiled into an exectuable, but into an object file. Since it is an .f90 module, this will be .MOD instead of .o.

    Then, with "use dislin", and the same command as in the original post, everything can be compiled properly linking to the double precision libraries.