Fortran90 static library and .mod files 
Author Message
 Fortran90 static library and .mod files

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.



Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran90 static library and .mod files

Quote:

> 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.



Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran90 static library and .mod files


Quote:
>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.

--

Amnesty International calls for new trial for Mumia Abu-Jamal
<http://www.refuseandresist.org/mumia/021700amnesty.html>



Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran90 static library and .mod files

Quote:

> 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)?


Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran90 static library and .mod files


Quote:


>> 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)?

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.

--

Amnesty International calls for new trial for Mumia Abu-Jamal
<http://www.refuseandresist.org/mumia/021700amnesty.html>



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problem linking static Fortran90 library built in DVF6.0A

2. 'library' of .mod files

3. mod sound file editing library?

4. f90 mod files and library construction

5. compile problems: .mod files and libraries

6. Tcl shared libraries and static libraries

7. MOD Library ?

8. Link mod unable to find library...

9. NAG fortran90 library in NCSA

10. How to use F77 library in Fortran90 ?

11. MOD and /MOD with Pygmy Forth

12. SM/REM FM/MOD and UM/MOD on a 32bit cell ix86 Forth

 

 
Powered by phpBB® Forum Software