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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

module regression and compiling 1

Status
Not open for further replies.

pingat

Programmer
Jan 10, 2015
7
AT
Hello there :)

I need to edit and include some old fortran codes in my program. But i'm not familiar with fortran as i thought :D

The code should work but compiling it brings some errors. If I want to compile it with gfortran, the most annoying one is this regression thing:

Code:
sub.f90:5.6:

  use interface
      1

Error: 'sub' of module 'interface', imported at (1), is also the name of the current program unit

I'm struggling with this for a while now. Are there some compiler options, that can solve this error? Or do i need to make some changes in the code?

Hopefully someone has any idea.

Thanks so far.
 
I can't see your source code, but it may be that the error message is right on...you should try being more specific and meaningful when you name your source files, subroutines, functions and modules...

...for starters, I would stay away from trivial names like "sub"

...secondly, I would stay away from Fortran keywords; in other words, don't name your module 'interface'...again, this is meaningless, add something as to what the interface is for "atom_model_api"

...but, most importantly, "interface" is already a meaningful concept in Fortran, so, maybe you should name your module something like "my_car_model_api" or something specific.
 
oh i'm sorry, in the real code they are named different. i just changed the names to post it here. in origin it looks like that:

Code:
kro.f90:5.6:

  use kur
      1
Error: 'kro' of module 'kur', imported at (1), is also the name of the current program unit

so, thats not the problem. but thanks for your effort.

I didn't wrote this code by myself, so it should work. It contains many modules with many subroutines and interfaces. I read in old codes it was common to provide all interfaces of all subroutines to all of them, and this may cause the problem. I thought of a compiler option to set or something.
 
are you reading the error message? it says that you may be importing something that has the same name as the current procedure...
 
yes of course. But it's not that easy.

kro uses kur and kur calls many functions that are defined in kro, that makes this error.

But this code once worked, i didn't wrote it on my own. I think this regression became illegal after the code was written. So i search something to make this working and not rewriting all the code.
 
It seems, that the fortran USE statement makes posiible to rename some module identifiers or to use ONLY some of them we need - see for example this:
So in kro I would try to use from kur only that what is needed:
Code:
USE kur, ONLY: [i]what, is, needed, here[/i]

or simply rename the identifier kro from kur to somethig else, so it will be not conflicting:
Code:
USE kur, KRO_FROM_MODULE_KUR => kro
 
exactly that solved my problem :) thank you really much!

I will try to get more into this module thing now, thank you for the tutorial as well.


best regards
pingat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top