Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Creating FORTRAN Libraries

  1. May 17, 2012 #1
    First time poster... I am trying to create fortran libraries for a test code I am writing. I had some success in doing so with a few examples from (specifically the kronrod src files):

    john burkardt website (sorry I can't post URLs)

    I would like to create a library from a file "electron_interactions.f95" that contains functions which are called by the main source. This is not an issue as long as I remove the global variables that are used throughout "electron_interactions.f95." This is what the commands look like in terminal:

    g95 -c -g electron_interactions.f95
    ar qc libelectron_interactions.a electron_interactions.o
    mv libelectron_interactions.a /Users/David/lib/

    g95 -c -g test.f95
    g95 test.o -L$HOME/lib/ -ltest
    mv a.out test

    Where test.f95 is some main program calling the functions contained in the library.

    Is it possible to create a library from a module that stores global variables, so I don't have to remove them to build the executable test?

    Currently, I have src files with "use global" everywhere I want to access these variables. I wind up needing a nasty makefile.
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted