Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fortran90 static library and .mod files

5 views
Skip to first unread message

Jaedeuk Lee

unread,
Sep 19, 2000, 3:00:00 AM9/19/00
to
When fortran90 codes are compiled, ".mod" files will be generated from
the source codes including module structure.

These ".mod" files are making a problem to me.

I want to make a static library (named "lib---.a") from fortran90 code.

This job was simple in fortran77 code.

Simply compiled, and used "ar" and "ranlib" commands.

And I can move generated lib---.a fils into /usr/local/lib directory.

When I want to use the library, I can simply link the library after I
compiled the source code.

However, in fortran90 code, I don't know how I treat the .mod files.

As you know, the fortran 90 source code which use some modules will be
compiled when the corresponding .mod files exist same directory.

Then Should I always copy the .mod files of the fortran90 library source
in the working directory?

That doesn't make sense?

Anyone know the solution?

Thanks.

charles d. russell

unread,
Sep 20, 2000, 3:00:00 AM9/20/00
to

Jaedeuk Lee wrote:

>
> I want to make a static library (named "lib---.a") from fortran90 code.
>
> This job was simple in fortran77 code.
>

> However, in fortran90 code, I don't know how I treat the .mod files.
>

I asked a similar question some time ago, and the gist of the answers was
that it is compiler-dependent, so I put off the problem until the day that I
encounter a compelling need to use f90.

I believe that the .mod files created by the compiler are not always needed,
so that if a library package is written carefully to avoid the need for
linking with .mod files, and the compiler/linker is intelligent enough not
to insist on a .mod file that it does not really need, it should still be
possible to have easy-to-link libraries in f90. Whether this is a problem
for some compilers, I don't know.


Dave Seaman

unread,
Sep 20, 2000, 3:00:00 AM9/20/00
to
In article <39C771B0...@NOSPAM.com>,

Jaedeuk Lee <jd...@NOSPAM.com> wrote:
>However, in fortran90 code, I don't know how I treat the .mod files.

You should think of the .mod files as being analogous to the .h files
that you need when accessing a C library. Collect them in one place and
tell the compiler to look there for the needed files.

Most Fortran 90 compilers have an option for specifying a location or a
path to search when looking for .mod files, or whatever they happen to be
called. For some compilers, the flag is "-I pathname", which looks just
like the corresponding flag with many C compilers. Check your manual.

--
Dave Seaman dse...@purdue.edu
Amnesty International calls for new trial for Mumia Abu-Jamal
<http://www.refuseandresist.org/mumia/021700amnesty.html>

charles d. russell

unread,
Sep 20, 2000, 3:00:00 AM9/20/00
to

Dave Seaman wrote:

>
> You should think of the .mod files as being analogous to the .h files
> that you need when accessing a C library.

But the makefile dependencies are different, aren't they? Any suggestions for
how to write makefiles that are compiler-independent (isolating platform
dependencies to the makefile defaults)?


Dave Seaman

unread,
Sep 20, 2000, 3:00:00 AM9/20/00
to
In article <39C922D6...@uabmc.edu>,

If the .mod files are part of your project and you want the Makefile to
reflect the dependencies, then you may be able to write a rule that
reflects how the .mod files are generated. Using GNU Make, I have had
some success with a rule like

%.o %.mod: %.f
${COMPILE.f} $<

This says that if you have a module FOO in a file foo.f, you can produce
both the files foo.o and foo.mod by just compiling in the usual way.
Then if you have a program unit BAR that USEs the module FOO, you can
write a dependency like:

bar.o: foo.mod

which causes bar.f to be recompiled if foo.mod has changed. This is not
guaranteed to work with every compiler, of course. In particular, you
may need to worry about upper/lower case differences in file names and
other details concerning the exact naming of the interface files (the
suffix is not always .mod). If the .mod files are associated with a
library and that library is likely to change often, you probably want a
separate Makefile for the library in its own directory.

0 new messages