JoeCoolman
JoeCoolman

Reputation: 532

linking to modules in external directory

I wanted to put several modules in a folder and store programs in another one. When try to generate the a.out file I write in the console

    ifort  test.f90  -I~/Fortran/modulos/

test.f90 uses a grn module which was previously compiled in modulos folder. This doesn't run I got the following

test.f90(5): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [GRN]

What am I doing wrong?. I use intel fortran in Ubuntu :(

OK, I will add some details. My module is something like this:

    module grn
    contains
    !gaussian random number generator
    subroutine gaussian_rng ( rannumb )
    implicit none
    double precision , intent ( out ) ::rannumb
    blah blah....
    end subroutine gaussian_rng
    end module grn

this is compiled in my folder 'modulos' by command ifort -c gaussgen.f90, after that the corresponding .mod and .o files are created, then in my folder 'programs' I have one called test.f90

    Program testOrdeningAndStatistics
    use grn
    Implicit None
    Real (Kind(0.d0)):: x
    blah blah ...
    call gaussian_rng(x)
    blah blah ...
    end Program testOrdeningAndStatistics

And I want to generate the executable file with those. The idea is simple, I want to store programs and modules in separate folders.

Upvotes: 0

Views: 1873

Answers (2)

Bálint Aradi
Bálint Aradi

Reputation: 3812

The problem is, that the ~ character is not resolved into your home folder, since the shell only substitutes it, if it stays at the beginning of a word. So, either, insert a space between option and path:

ifort  test.f90  -I ~/Fortran/modulos/

or write the full path:

ifort  test.f90  -I/home/yourusername/Fortran/modulos/

Both works for me with ifort 12.1.0.

Upvotes: 1

spsgtn
spsgtn

Reputation: 1

You probably need to link the object file .o associated with the module. If you could post a simple example of source code plus compilation program it would be easier to understand what you are doing wrong.

Upvotes: 0

Related Questions