Linking to shared library

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
trinefrisbaek
Posts: 6
Joined: Mon May 09, 2016 4:05 pm
Location: University of Copenhagen

Linking to shared library

#1 Unread post by trinefrisbaek »

Hi
I have a small ecosystem module with several subroutines that I would like to call from ROMS. It is written in free format and still being developed so I would like to link to this module as a shared or static library. However, I cannot get ROMS to recognize its existence.
I have added a path for my library and the modules in the build script:

Code: Select all

export   MY_ECO_DIR=${MY_PROJECT_DIR}/Ecosystem
In Linux_gfortran.mk I have added

Code: Select all

LIBS += $(MY_ECO_DIR)/libeco.so
LIBS += $(MY_ECO_DIR)/mod_eco.o
and I have tried adding

Code: Select all

LIBS += -L$(MY_ECO_DIR) -leco
In subroutine fennel_tile where have tried using it I write

Code: Select all

USE mod_eco

Code: Select all

biology.f90:212.10:

      USE mod_eco
          1
Fatal Error: Can't open module file 'mod_eco.mod' for reading at (1): No such file or directory 
I am clearly missing something but I cannot figure out what. I have tried linking the module to a small dummy program and it works well using

Code: Select all

gfortran -L. eco_main.f90 -leco -o main
Any help would be very appriciated!
Thanks

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Linking to shared library

#2 Unread post by kate »

You have already compiled your library externally? There is a mod_eco.mod file in that directory? If so, you need to tell the compiler how to find that file. Or you could copy it into the ROMS build directory, which is what is done with the netcdf.mod and friends files.

trinefrisbaek
Posts: 6
Joined: Mon May 09, 2016 4:05 pm
Location: University of Copenhagen

Re: Linking to shared library

#3 Unread post by trinefrisbaek »

Thank you Kate! The reference to netcdf.mod was just what I needed. It works now

Post Reply