Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMSL Library / Module usage 1

Status
Not open for further replies.

woodlands

Technical User
Jul 21, 2010
4
FR
Hi.

I am trying to run a program not written by myselfr. It accesses ISML functions. I can see those functions in a .f90 source code, but I am not able to compile this module code (Error: undefined symbol "_MAIN_" in module "jwe_xrt0"). I am not very used to handle those modules.

My questions are:
1) How about this error while compiling the .f90 module code?
2) How to make the main program "see" the ISML functions? Is it enough to start with a USE statement, giving the libraries name? Or do I have to declare the ISML functions as EXTERNALS (where?)?

Thanks.
Woodlands.
 
You didn't specified compiler which you are using, but IMHO undefined symbol "_MAIN_" probably means that you try to compile and link and doesn't have the main program.

If the function is in the module - e.g.:
Code:
module mymodule
...
contains
  real function myfoo(a, b, c)
...
then in the main program USE the module and call the function - e.g.:
Code:
program myprog
  use mymodule
  ...
  myfoo_rslt = myfoo(x, y, z)
 
Thank you very much.

I have the main and I have the module. But using the module with USE statement gives now e.g. the error

Error LINK.3230: Undefined symbol "_u4inf_" in module "CRPFANv2y" at location 0041D4C5

I am using Lahey Fortran 95 PRO v.5.6

DO I have to use IMPLICT statement after use? I have seen this in many examples. But then I create about 150 errors for not declared variables :-/
 
This is a linker error. It probably means that the module has not been added to the link.

I'll have to check up on the use of implicit.
 
Thank you very much.
Would be nice and possibly helpful to have any feedback on that!
 
implicit has to come after the use statement.

Say I have two programs
main.f95
Code:
program main
   ! Lahey moans about this
   ! implicit none
   use Other
   implicit none ! this is the proper place
   integer:: used
   used = 10
   call OtherNew (used)
   call OtherExec ()
   call OtherDelete ()
   stop
end program main

other.f95
Code:
module Other
   implicit none
   integer::mVal
contains
   subroutine OtherNew (pinVal)
      integer, intent(in):: pinVal
      mVal = pinVal
      return
   end subroutine OtherNew

   subroutine OtherDelete ()
      write (*, *) 'mVal = ', mVal
      return
   end subroutine OtherDelete

   subroutine OtherExec ()
      mVal = mVal * mVal
      return
   end subroutine OtherExec
end module Other
First build other.f95

elf90 other.f95

This will create a library other.lib and a mod file other.mod.

Then build main.f95

elf90 main.f95

This will create main.exe

Alternatively, you can specify all the files in one line but they must be in order of usage

elf90 other.f95 main.f95


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top