Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write makefile if use IMSL library

Status
Not open for further replies.

mapi

Mechanical
Jan 30, 2007
53
0
0
US
Hi,
I am going to run my fortran code in a server and I need to write a makefile. Now in my fortran, I invoke the subroutine in IMSL.
So how do I write the makefile? or how to define the IMSL subroutine in makefile?

Thanks,
mapi

 
Replies continue below

Recommended for you

Need to know a few things first

1) What do you want the makefile to do? Do you want it to compile and link your fortran program or do you want it to run the program as well?

2) Is this a Unix or Windows system? The way in which you link libraries is different for Unix/Linux and Windows.

3) Which Fortran compiler are you using.

4) Is IMSL a library?
 
Hi,

1) I want the makefile to link the Fortran program and run them in a server (not my PC).

2) My computer is a Windows system. The server is a Linux system and I am using SSH.

3) I write my Fortran program in F77 format and I think in the makefile I use: g77.

4) IMSL is a libraly that provides many subroutines for user to call.

Thanks.
 
Confusion...I call 'source' any file you can read, ASCII text. To me that's source. You compile the 'source' code to get object files (assembly language, that is). You then compile the object files with the result an application or 'executable' file.

I prefer to use 'cygwin', a free F77 compiler that you can put onto a PC. Tried some fancier programs, better GUI, hated them, so I went back to the basics.

For instance, my makefile is
.f:
g77 $< -static -lm -o $*

I use the command 'make xxx.f' to compile xxx.f into an object and creates an executable at the same time, xxx.exe

So back to the original question--I am going to assume that this IMSL library is someplace you can look at the folder. The file names are *.f or *.o or what?
 
I don't have access to these source in the server. But I hear that the source is in default in some location/directory. And if we include these directory with the IMSL lib, we may run the IMSL with no problem. Otherwishe in my current case, the subroutine from IMSL lib is not recognized and said to be undefined.
Is it true?
 
There are two sources that seem to be referred to in this thread

1) The program source
2) The IMSL source

Assume the IMSL source is not available but the IMSL library and headers are.

Does the program source live on the Linux server or the Windows PC? If it lives on the Linux server, does the Linux server have access to the Windows PC's file system through Samba? If it doesn't, the files have to be ftp'd to the server.

Assuming the IMSL headers live in /opt/IMSL/include and the library lives in /opt/IMSL/lib and the library is called libIMSL.a or libIMSL.so the rule will look something like

.f.o:
g77 -c -I/opt/IMSL/include $<

This will create a .o from a .f. This rule appears first. Next comes the target. Say your program is aiamasal and the program source in main.f

aiamasal: main.o
g77 -o $@ $? -L/opt/IMSL/lib -lIMSL

-L tells it where to look for the library -l tells it the library name without the lib, .a or .so. This wil create the executable on Linux. You can run it on Linux but not on your Windows PC.
 
Status
Not open for further replies.
Back
Top