- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
It tells me I have a "multiply defined symbol," but the symbol is
the name of a COMMON block.
Of course one would have the same COMMON block in different routines.
The name of the COMMON region is only used for that, nothing else.
They are all the same size and content. It appears in several routines.
What could cause that? How can I isolate tit?
Would I get that if they were diffent sizes (by accident)?
This may have to do with having record structures in the Common block,
but I am just guessing.
the name of a COMMON block.
Of course one would have the same COMMON block in different routines.
The name of the COMMON region is only used for that, nothing else.
They are all the same size and content. It appears in several routines.
What could cause that? How can I isolate tit?
Would I get that if they were diffent sizes (by accident)?
This may have to do with having record structures in the Common block,
but I am just guessing.
Ссылка скопирована
10 Ответы
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Suggestion: COMMON is obsolete. Put the content in a module, once, and then USE the module wherever needed.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
I will try that.
But, obsolete or otherwise, why should there be a problem with this?
But, obsolete or otherwise, why should there be a problem with this?
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Ensure that only one instance of the common block has initialization(s) of its contents.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
You mean like a DATA statement?
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Yes. Often, a BLOCK DATA subprogram was used to initialize variables that belonged to common blocks. Only one such subprogram is allowed, which helps avoid multiple initializations. If, instead, common blocks are defined in more than one place and have DATA declarations for common block variables in more than one place, linker errors arise such as those that you ran into.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
This problem usually occurs when you have an include file that declares the COMMON and has DATA statements to initialize the COMMON. As has been said, you are allowed to initialize the common only once in a program. On some operating systems, the linker allows multiple initializations and uses a "last wins" approach. Most others, including Windows and Linux, disallow this.
The usual solution is to move the initializations to a BLOCK DATA subprogram that also includes the COMMON declarations.
The usual solution is to move the initializations to a BLOCK DATA subprogram that also includes the COMMON declarations.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
I tried replacing the COMMON blocks with modules.
But then the problem I encountered was:
I don't any longer have a way to initialize the variables to something at the
very start of execution.
For example some non-arrays need to be set =ZERO.
So, what would I use to replace the DATA statements?
It won't let me me inititalize variable that way any longer.
Can I assume that they have some initial value, or are they just random like before?
But then the problem I encountered was:
I don't any longer have a way to initialize the variables to something at the
very start of execution.
For example some non-arrays need to be set =ZERO.
So, what would I use to replace the DATA statements?
It won't let me me inititalize variable that way any longer.
Can I assume that they have some initial value, or are they just random like before?
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
You can continue to use data statements - they just need to be in the module that declares the module variable. If you still have issues with them then elaborate.
You can also use the F90 style of initialization - where you put the initial value after a '=' in the type declaration statement for the variable. This is what I prefer.
[fortran]MODULE SomeVariables IMPLICIT NONE ! Data... REAL :: a DATA a/45.6/ ! F90 style... INTEGER :: b = 123 END MODULE SomeVariables [/fortran]
You can also use the F90 style of initialization - where you put the initial value after a '=' in the type declaration statement for the variable. This is what I prefer.
[fortran]MODULE SomeVariables IMPLICIT NONE ! Data... REAL :: a DATA a/45.6/ ! F90 style... INTEGER :: b = 123 END MODULE SomeVariables [/fortran]
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
According to the standard, any DATA statements used to initialize COMMON must be in a BLOCK DATA, with all DATA statements or f90 style initialization referring to a given labeled COMMON being in a single BLOCK DATA. Most compilers accept COMMON initialization other than in BLOCK DATA, but Steve explained that you must not scatter initialization of a given COMMON across more than one procedure.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
we're not talking about Common blocks any more, here.
If I want to abandon Common regions, then I guess I will use Steve's suggestion about the = sign.
If I keep any Common blocks, I would just use BLOCK DATA as suggested.
If I want to abandon Common regions, then I guess I will use Steve's suggestion about the = sign.
If I keep any Common blocks, I would just use BLOCK DATA as suggested.
Ответить
Параметры темы
- Подписка на RSS-канал
- Отметить тему как новую
- Отметить тему как прочитанную
- Выполнить отслеживание данной Тема для текущего пользователя
- Закладка
- Подписаться
- Страница в формате печати