Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

BLOCK DATA

chat1983
Einsteiger
1.080Aufrufe
hi ,

i'm new to fortran and hope any of you could help me.

i'm involved in modifiying an exisiting fortran code ( using ifort in fedora)

I'm using multiple source files and when complied it gives no error.
when object files are linked it gives the following error.

k2lib/hklib.o:(.data+0x0): multiple definition of `lek_'
k2lib/fuelib.o:(.bss+0x0): first defined here

and i have shown here the files associated in error.

the content of the file 1
-------------------------------------------
block data fuelib

include 'main.h'

integer n
data (hk(n,1),n=1,51) / 51*0.0 /

end
-----------------------------------------------------

content of the file 2

--------------------------------------------------------

block data hklib

include 'main.h'
integer n

data (hk(n,2),n=1,51) /-2.075,-1.381,-.685,.013,.724,1.455,2.21,2.
1 988,3.786,4.6,5.427,6.266,7.114,7.971,8.835,9.706,10.583,11.465,1
2 2.354,13.249,14.149,15.054,15.966,16.882,17.804,18.732,19.664,20.
3 602,21.545,22.493,23.446,24.403,25.365,26.331,27.302,28.276,29.25
4 4,30.236,31.221,32.209,33.201,34.196,35.193,36.193,37.196,38.201,
5 39.208,40.218,41.229,42.242,43.257/


data (hk(n,3),n=1,51) / values same as above .../
data (hk(n,2),n=1,51) /bvalues same as above .../
.......

end

----------------------------------------------------------------------------

notes : in the header file main.h the array has difined as shown below

real*8 ek,eliq,pvap,visliq,hk(51,lnsp),hlat0(51)
common /lek/ ek(51,lnsp),eliq(51),pvap(lvap),visliq(lvap)
equivalence (ek,hk),(eliq,hlat0)

** values for lnsp etc have been assigned appropriately

also , if i comment the data statements in file 2 it works fine.

therefore i guess this a problem as they are difned in 2 files . but i can not change that since the array is called by many of other routines included in many other multiple files.

I really appricitae your help in this

thanks.


0 Kudos
6 Antworten
TimP
Geehrter Beitragender III
1.080Aufrufe
Compilers which reject multiple BLOCK DATA initializations are correct. As only one of them could take effect, even with a compiler which accepted it, you must eliminate (or comment out) the unwanted one.
jimdempseyatthecove
Geehrter Beitragender III
1.080Aufrufe

I might add to Tim's comment that if you have two subroutines, each initializing the same named array, this may be in indication the each of the subroutines believe they are the only subroutines using that array. What this may mean, in some cases, the second routine called may have as its first time call data, data that has been modified since it was initialized but before the first run of the second subroutine. This may or may not be a problem. You have to look at this on a case by case basis.

Jim Dempsey
chat1983
Einsteiger
1.080Aufrufe
Quoting - tim18
Compilers which reject multiple BLOCK DATA initializations are correct. As only one of them could take effect, even with a compiler which accepted it, you must eliminate (or comment out) the unwanted one.

thanks alot for your reply,

could you pls explain your ans. ) and i'd lke to add these as well


in file 1,
data (hk(n,1),n=1,51) / 51*0.0 /

file 2
data (hk(n,2),n=1,51) /-2.075,-1.381,-.685,.013,.724,1.455,2.21,2.........

here ,in both files it assigns the values for same array but different locations.

hence no unwanted parts.

also this is from a part of standard program ( but little bit old) .

cheers!!


TimP
Geehrter Beitragender III
1.080Aufrufe
It is an unusual extension to support initializing different parts of an array in multiple BLOCK DATA procedures, and I would have doubts about the extent to which it was validated, even by a compiler which allows it. Definitely not a standard program.
Steven_L_Intel1
Mitarbeiter
1.080Aufrufe
Quoting - chat1983

also this is from a part of standard program ( but little bit old) .



The program is non-standard. The standard says:

"The same named common block shall not be specified in more than one block data program unit in a program."

I could imagine an implementation that allowed this to work, but Intel's doesn't.
chat1983
Einsteiger
1.080Aufrufe

The program is non-standard. The standard says:

"The same named common block shall not be specified in more than one block data program unit in a program."

I could imagine an implementation that allowed this to work, but Intel's doesn't.


yep, u guys are right. I found that this is not the exact std program. std one is in a one single file. this is a split version of it. i trasfered the body of file 2 in to file 1 and made the array assignment in a file. now that rouitne works fine.

thanks alot for you guys
Antworten