Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

X11-Fortran Problems

Hello to all,


I am in the process of compiling a Fortran code on my machine. I'm running 10.7.3 and compiling using gfortran. It was originally written on a Linux box and it has been successfully compiled on Linux Mint using X11.


The code requires two separate steps to compile the program. The first step compiles the graphics and gets X11 going while the second step compiles the rest of the code. It uses two makefiles, one for each step. I'm comfortable with using makefiles. I have gotten throught the entire compilation process without erroring out. I'm able to run the codes but the graphics don't work. An X11 window pops up but there are a bunch of lines simply stretching all across the window. Hence, I think the problem lies with my graphics compilation step.


There is a line in the graphics makefile that reads:

LINKLIB = -L/usr/X11/lib -lX11


My X11 library is in /usr/X11/lib and I verified that. I'm also using the following Fortran flags (double precision)

FFLAGS = -O3 $(DP)


Are there any thoughts as to why the graphics would be bombing on my machine?


Thanks.

iMac, Mac OS X (10.7.3)

Posted on Mar 29, 2012 7:17 AM

Reply
20 replies

Mar 29, 2012 11:01 AM in response to etresoft

The graphics aren't needed for the compilation process. I can compile the whole way through, but the X11 graphics in the total code do not work. The over arching code that is being compiled, though, requires X11 to run. According to the provided Linux documentation in the readme, a graphics build must be performed prior to the full code being built. This isn't a build of X11 but a build of a graphics (plotting) code that the mother code uses. The full documentation is weak but the graphics step creates a file named libPlt.a and the full code needs to use this libPlt.a to properly operate.

Mar 29, 2012 12:18 PM in response to aerohead

Is this an open source project that some one else could look at? I have never heard of such a thing.


Has this code ever been compiled on a Mac before and/or recently? One of the strengths, or weaknesses, of Linux is that it will compile just about anything, regardless of quality. That code may not work on a 64-bit architecture or it may have some old Mac hacks that assume a PowerPC chip. It sounds like a one-of-a-kind, cobbled together mess. All bets are off.

Mar 29, 2012 1:52 PM in response to etresoft

Thanks for the quick response.


Yes, it is open source. It's licensed under GNU general public license. It'd be fine for you to take a look at it. How should I transfer it to you?


I dug up a paragraph on what is called the original author calls the "graphics library." Here's what it says:

The graphics library employed by all plotting programs is Xplot11 (libPlt.a), which is aimed at driving X-terminals. It also allows a PostScript file plot.ps to be generated from the current visible screen plot at any time. Both color and black&white output is supported.


I know that a close relative of this code has been ported to OS X and I have used a third-party build of that with no problem at all. I don't know any more beyond that, though. I've tried contacting that party but they have not provided any help.


Thanks for all your help.

Mar 29, 2012 3:04 PM in response to aerohead

aerohead wrote:


Yes, it is open source. It's licensed under GNU general public license.



Just so you know, open source and GPL are distinctly different. Open source means the project is distributed as source. GNU GPL means that you, the developer, is under some very significant restrictions and obligations.


It'd be fine for you to take a look at it. How should I transfer it to you?


Well, I don't have gfortran and I'm way too busy to install it right now. Is this project posted anywhere? I'm mainly trying to figure out how X11 is used in the build process. I was hoping the documentation might explain that.


I dug up a paragraph on what is called the original author calls the "graphics library." Here's what it says:

The graphics library employed by all plotting programs is Xplot11 (libPlt.a), which is aimed at driving X-terminals. It also allows a PostScript file plot.ps to be generated from the current visible screen plot at any time. Both color and black&white output is supported.



The idea of the build machine needing to construct some postscript file from a plot is just wrong. Generate the postscript files on the Linux machine and include the output in the project. Then eliminate the whole X11 part of the build process. Postscript files are resource files. There should be no need to construct those as part of a build script. It isn't a Mac vs Linux thing. The issue is constructing postscript files during build time. Something unusual like that needs a good justification.

Mar 29, 2012 3:31 PM in response to etresoft

Hi again


Once again, thanks for your quick response! Thanks for the clarification on the GPL vs. GNU. Duly noted.


The project is supported my Mark Drela (an aerodynamics professor out of MIT). It is called MSES. The online documentation for MSES is relatively weak if not completely nonexistent. Nevertheless, it is a very close relative of a much better documented code called XFoil (http://web.mit.edu/drela/Public/web/xfoil/). I use a third party build of XFoil on my machine here.


There is really good documentation on the XFoil build process on a Linux box on these two sites:

http://ubuntuforums.org/archive/index.php/t-994912.html

http://remmirath-en.blogspot.com/2007/10/how-to-build-and-install-xfoil-on.html


XFoil uses the same graphics engine as MSES (my code). The culprit, I think is the libPlt.a or the libPltDP.a (for double precision).


I have some more documentation that came with the code when we got it from the author. I've picked through it and the only part that I have found about the graphics build is what I had mentioned in my previous response. Almost all of the documentation involves how to use the code and numerous README files to help with the compiling. The author only offers Linux support.


In reference to your final comment.... you think the problem doesn't lie with the build of libPltDP.a (the graphics plotting program) but rather in the MSES build itself? I am able to get the whole way through the MSES build without an error and am able to start up the program. Everything seems to work fine until I try to do a command which requires graphics.

Mar 29, 2012 4:21 PM in response to aerohead

aerohead wrote:


Once again, thanks for your quick response! Thanks for the clarification on the GPL vs. GNU.


Actually the issue is open source vs GPL. GNU and GPL are synonymous. But enough with that.


In reference to your final comment.... you think the problem doesn't lie with the build of libPltDP.a (the graphics plotting program) but rather in the MSES build itself?


I don't really know. That's the problem.


I am able to get the whole way through the MSES build without an error and am able to start up the program. Everything seems to work fine until I try to do a command which requires graphics.


You really have to clarify what, precisely, is the problem.


From what I understood, the build process includes a part where it opens an X11 windows, draws some stuff in it, and exports the contents of that window to a postscript file. I understood that what it was drawing was incorrect.


Now, you say it "works fine" until you try to do a command which requires graphics. What do you mean by "not working fine"? Do you get an error message? What does it say? Does it do nothing? What should it do? Are there any crash reports or Console.app log entries?


I really like to get things working on the Mac, but these academic projects really rub me the wrong way. The idea that people will push this junka and never update it in ten years really bothers me. Now, you want to run it on some machine that is ever so slightly different than its original build. I'm sure the author would blame the Mac. Why shouldn't he? It's not his problem. I'm doing his support for him, aren't I?


But I digress. I've had issues with academics lately.


What it sounds like now is that the software was just designed for the author's lab network at MIT in 1994 and has never been upgraded. It works fine on Linux because Linux was...designed in 1994 and has never been upgraded. In particular, it may be expecting a DISPLAY variable to be set. On the Mac, DISPLAY is set dynamically. Of course, I'm just guessing here. See about any error messages or log file entries. Dig into the script that it is exectuting and maybe add some debug statements.

Mar 30, 2012 7:44 AM in response to etresoft

Thanks for the great response. Hopefully I can shed a little light on the problem.


The build process is two steps. The first step builds a graphics plotting program - the name of that program is pltLibDP.a. This plotting program uses X11 as the graphics engine and the plotting program is called by the larger program, called MSES.


The second step of the build is to compile MSES itself. MSES calls the graphics program during the operation of the code. X11 windows are not called during the compiling process - the X11 windows are part of the code operation.

I'm able to compile the graphics program (pltLibDP.a) and the mother program (MSES). However, when I go to run MSES, the graphics window that pops up is a bunch of garble de gook. See this picture - this is what pops up when I run MSES on my computer

User uploaded file


Here is what it is supposed to look like:


User uploaded file


As I mentioned, the X11 windows are all after the compiling process. They are part of just running and using the code.

Mar 30, 2012 8:15 AM in response to aerohead

OK. I get it now. That makes much more sense.


Alas, your job is much, much more difficult now. Obviously either the X11 or MSES portion was coded very poorly and has failed. Debugging it will be a tedious process to say the least. What you will probably have to do is isolate the various parts and test them individually. Once you find out where the failure lies, you can start to look for the cause.


One way you might be able to cheat is to rebuild the entire thing using Apple's new clang compiler. Not the FORTRAN parts, of course. Review the many thousands of warnings it is sure to emit. You may have to go into the Makefiles and remove the flags that hide those pesky things. You could do that with GCC too. It might be a good idea to start with full warnings on GCC. The only problem is that GCC's warnings are much harder to dechiper than those of clang. It will likely identify those places where the code is making invalid assumptions about endianness and the size and compatibility of data types. Then, it is just a matter of fixing the code.

Mar 30, 2012 8:51 AM in response to etresoft

Great - thanks for the input on the debugging. It sounds like I have many frustrating days ahead of me...


Thanks for the Clang suggestion. I'll delve into that and see if anything fruitful comes out of that investigation. The warnings for the GNU compilers are a good thought, too. We'll see how I do in terms of debugging everything and if I learn anything miraculous, I will certainly post my solution on here. I've been thinking about your comment yesterday about the fact that Linux can compile a bunch of stuff easily and the code was written back in the era when Linux was first being born. That may be a definite contributing factor. I wouldn't be surprised if there was more than one contributing factor. I'm going to give the entire process a go with XQuartz, too. We'll see if I have any more luck there.


Keith, in reference to the zooming... this code has been compiled on a Linux box successfully. I was trying to get it up and running on my Mac. I don't think it's a zoom/viewing issue, unfortunately. That would have solved a lot of problems if it did, though!

Mar 30, 2012 10:54 AM in response to aerohead

aerohead wrote:


Keith, in reference to the zooming... this code has been compiled on a Linux box successfully. I was trying to get it up and running on my Mac. I don't think it's a zoom/viewing issue, unfortunately. That would have solved a lot of problems if it did, though!

I'm with Keith. It is quite possible everything is being drawn normalized and something about that has gotten lost. Instead of drawing on a 1024 x 1024 canvas, you have a 1 x 1 canvas.

Jul 6, 2012 8:53 AM in response to Keith Barkley

Hello all,


Problem resolved so I thought I would update the thread to help someone in the future and let you know what the problem was.


I've been having an epic battle royale with this code the last few months since the thread quited down here. The problem was solved when I compiled everything in double precision. I was hoping to get away with using single precision for the graphics engine to save memory and speed it up. I was trying to use double precision for the main engine of the code. Problem solved when I kicked everything into double.


At least now the graphics work. Now off to figure out the rest of this code...


User uploaded file

X11-Fortran Problems

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.