Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7790927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:44:11+00:00 2026-06-01T21:44:11+00:00

I have a Fortran program that uses modules, i.e. it creates .mod -files during

  • 0

I have a Fortran program that uses modules, i.e. it creates .mod-files during compilation.
I also wrote a Makefile that uses all the .f90-files from src/ puts all created .o-files in obj/ and the binary in the current folder, and everything works fine.

I now recompile my program in different folders for different calculations (say calc1/), i.e. I copy the Makefile into calc1/, type make all in calc1/ and all it does is the linking, because the object-files already exist. However, if the program includes any modules the compiler needs the corresponding .mod-files to be present in calc1/. Until now, I recompiled everything (make clean all), but with the program growing this takes too much time!

A possible solution I came up with is to have one specific folder for the binaries (bin/). But this is not a viable option because I have jobs in the queue, which obviously need a stable binary, while I also try new features in the meantime.

So, I’m looking for a solution that somehow treats the .mod-files similar to .o-files, e.g. places them in obj/.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:44:12+00:00Added an answer on June 1, 2026 at 9:44 pm

    I would expect that (most?) compilers would specify an option to change the module file path. with gfortran, the option is -J or -M (from the man page):

    -Jdir
    -Mdir
           This option specifies where to put .mod files for compiled modules.  It is also
           added to the list of directories to searched by an "USE" statement.
    
           The default is the current directory.
    
           -M is deprecated to avoid conflicts with existing GCC options.
    

    I think that most compilers look for .mod files in directories included with -I

    EDIT

    As of gfortran 4.6, -M is no longer supported. Use -J

    based on one of my configure scripts, the flag is -module for ifort and pgf90 although I almost never use those compilers these days so somebody else should confirm that …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a FORTRAN 95 program that needs to make some calls to the
I have a old command line based program (its fortran if that matters) that
I have a fortran program generating unformatted files and I am trying to read
I have a program in Fortran that saves the results to a file. At
I have a bash script that runs a simulation program written in Fortran 90,
I have an old Fortran program for reading records from text files. The records
I have a fortran dll, and I want to know the assemblies that it
I have a Fortran program, which I can compile using f77, f95 or ifort
Purpose: Create a program that takes two separate files, opens and reads them, assigns
I have numbers outputted from a FORTRAN program in the following format: 0.12961924D+01 How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.