Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

The address of avariable in module is not Continuous?

 

why the address of LARGE is not   Continuous?

Thanks very much

avariable Address(LOC())
      SMALL        12117904  
      TOSMAL 12117912 8
      TRESML 12117920 8
      FORSML 12117928 8
      FIVSML 12117936 8
      SIXSML 12117944 8
      LARGE 12117896 -48
      HALF 12117952 56
      ZERO 12117960 8
      ONE 12117968 8
      TWO 12117976 8
      THREE 12117984 8
      FOUR 12117992 8
      FIVE 12118000 8
      SIX 12118008 8
      SEVEN 12118016 8
      EIGHT 12118024 8
      RNINE 12118032 8
      TEN 12118040 8
      ELEVEN 12118048 8
      TWELV 12118056 8
      CP1 12118064 8
      CP2 12118072 8
      CP3 12118080 8
      CP4 12118088 8
      CP5 12118096 8
      CP6 12118104 8
      CP7 12118112 8
      CP8 12118120 8
      CP9 12118128 8
      C1M2 12118136 8
      C1M3 12118144 8
      C1M4 12118152 8
      C1M5 12118160 8
      C1M6 12118168 8
      C1M7 12118176 8
      C1M8 12118184 8
      C1M9 12118192 8
      C2M5 12118200 8
      C1M10 12118208 8
      C1M11 12118216 8
      C1M12 12118224 8
      C8M2 12118232 8
      C5M2 12118240 8
      C5M3 12118248 8
      C5M5 12118256 8
      C98M4 12118264 8
      C71M1 12118272 8
      C95M2 12118280 8
      C23M1 12118288 8
      C23M2 12118296 8
      C55M1 12118304 8
      C75M1 12118312 8
      C25M1 12118320 8
      C25M2 12118328 8
      C72M1 12118336 8
      C49M3 12118344 8
      C26M1 12118352 8
      C11M1 12118360 8
      C45M1 12118368 8
      C267M6 12118376 8
      C719M1 12118384 8
      C743M1 12118392 8
      C924M1 12118400 8
      C886M1 12118408 8
      C546M2 12118416 8
      C207M3 12118424 8
      C316M1 12118432 8
      C116M1 12118440 8
      C125M1 12118448 8
      C766M1 12118456 8
      C758M2 12118464 8
      C292M1 12118472 8
      C7M1 12118480 8
      C63M4 12118488 8
      C215M7 12118496 8
      C264M5 12118504 8
      C35M1 12118512 8
      C19M3 12118520 8
      C809M1 12118528 8
      C157M1 12118536 8
      C562M1 12118544 8
      C15E2 12118552 8
      C175E0 12118560 8
      C17M1 12118568 8
      C24M1 12118576 8
      C1M15 12118584 8
      C95M1 12118592 8
      C30M2 12118600 8
      C105M2 12118608 8
      C84M2 12118616 8
      C3E1 12118624 8
      C15M1 12118632 8
      C16M1 12118640 8
      C33M1 12118648 8
      C43M1 12118656 8
      C44M2 12118664 8
      C2E4 12118672 8
      C70E1 12118680 8
      C16E0 12118688 8
      C108E0 12118696 8
      C113E0 12118704 8
      C687M1 12118712 8
      C72E1 12118720 8
      C397M2 12118728 8
      C148M1 12118736 8
      C524M1 12118744 8
      C773M1 12118752 8
      C325E1 12118760 8
      C1E4 12118768 8
      C1M18 12118776 8
      C98M1 12118784 8
      C1E5 12118792 8
      C1E6 12118800 8
      C52E0 12118808 8
      C57E0 12118816 8
      C21E0 12118824 8
      C102E0 12118832 8
      C1E2 12118840 8
      C2E2 12118848 8
      C5E2 12118856 8
      C2E3 12118864 8
      C3E3 12118872 8
      C5E3 12118880 8
      C2E5 12118888 8
      C2E6 12118896 8
      C1E9 12118904 8
      C1E10 12118912 8
      C1E12 12118920 8
      C64E1 12118928 8
      C13E1 12118936 8
      C16E1 12118944 8
      C55E0 12118952 8
      C18E1 12118960 8
      C45E1 12118968 8
      C24E1 12118976 8
      C36E1 12118984 8
      C75E1 12118992 8
      C25E1 12119000 8
      C50E1 12119008 8
      C35E0 12119016 8
      C15E0 12119024 8
      C25E0 12119032 8
      C24E0 12119040 8
      C11E0 12119048 8
      C23E0 12119056 8
      C1E3 12119064 8
      C18E2 12119072 8
      C2E1 12119080 8
      C139E0 12119088 8
      C312E0 12119096 8
      C413E0 12119104 8
      C118E0 12119112 8
      C44E0 12119120 8
      C135E0 12119128 8
      C115E0 12119136 8
      C132E0 12119144 8
      C101E0 12119152 8
      C185E0 12119160 8
      C245E0 12119168 8
      C176E1 12119176 8
      C186E1 12119184 8
      C141E1 12119192 8
      C273E2 12119200 8
      C351E2 12119208 8
      C267E3 12119216 8
      C116E0 12119224 8
      C216E0 12119232 8
      C243E0 12119240 8
      C177E0 12119248 8
      C137E1 12119256 8
      C12E0 12119264 8
      C1O7 12119272 8
      C1O6 12119280 8
      C1O24 12119288 8
      C1O3 12119296 8
      C4O3 12119304 8
      C3O4 12119312 8
      C4O7 12119320 8
      C6O7 12119328 8
      C8O3 12119336 8
      C3O8 12119344 8
      C2O3 12119352 8
      C9O16 12119360 8
      C24O31 12119368 8
      C15O4 12119376 8
      C71O6 12119384 8
      C37O6 12119392 8
      C31O6 12119400 8
      C65O6 12119408 8
      C110O3 12119416 8
      C106E0 12119424 8
      C156M1 12119432 8
      C193M1 12119440 8
      C476M1 12119448 8
      C103E0 12119456 8
      C152E0 12119464 8
      C176E0 12119472 8
      C389E0 12119480 8
      C266M2 12119488 8
      C3M8 12119496 8
      C5M8 12119504 8
      C6M8 12119512 8
      C201M4 12119520 8
      C387E5 12119528 8
      C812M1 12119536 8
      C452E0 12119544 8
      C771E0 12119552 8
      C137E3 12119560 8
      C98E5 12119568 8
      C567M8 12119576 8
      LNTEN 12119584 8
      PI 12119592 8
      PIO2 12119600 8
      TPI 12119608 8
      CGEOM 12119616 8
      SQRT8 12119624 8
      SQRT22 12119632 8
      SQRT3 12119640 8
      CPSML 12119648 8
      CQLGE 12119656 8
      CQSML 12119664 8
      GRAV 12119672 8
      STEF 12119680 8
      RCGAS 12119688 8
      LSCONS 12119696 8

module CONST
     IMPLICIT NONE

     REAL( kind = 8 ) :: SMALL
     REAL( kind = 8 ) :: TOSMAL
     REAL( kind = 8 ) :: TRESML
     REAL( kind = 8 ) :: FORSML
     REAL( kind = 8 ) :: FIVSML
     REAL( kind = 8 ) :: SIXSML
     REAL( kind = 8 ) :: LARGE
     REAL( kind = 8 ) :: HALF
     REAL( kind = 8 ) :: ZERO
     REAL( kind = 8 ) :: ONE
     REAL( kind = 8 ) :: TWO
     REAL( kind = 8 ) :: THREE
     REAL( kind = 8 ) :: FOUR
     REAL( kind = 8 ) :: FIVE
     REAL( kind = 8 ) :: SIX
     REAL( kind = 8 ) :: SEVEN
     REAL( kind = 8 ) :: EIGHT
     REAL( kind = 8 ) :: RNINE
     REAL( kind = 8 ) :: TEN
     REAL( kind = 8 ) :: ELEVEN
     REAL( kind = 8 ) :: TWELV
     REAL( kind = 8 ) :: CP1
     REAL( kind = 8 ) :: CP2
     REAL( kind = 8 ) :: CP3
     REAL( kind = 8 ) :: CP4
     REAL( kind = 8 ) :: CP5
     REAL( kind = 8 ) :: CP6
     REAL( kind = 8 ) :: CP7
     REAL( kind = 8 ) :: CP8
     REAL( kind = 8 ) :: CP9
     REAL( kind = 8 ) :: C1M2
     REAL( kind = 8 ) :: C1M3
     REAL( kind = 8 ) :: C1M4
     REAL( kind = 8 ) :: C1M5
     REAL( kind = 8 ) :: C1M6
     REAL( kind = 8 ) :: C1M7
     REAL( kind = 8 ) :: C1M8
     REAL( kind = 8 ) :: C1M9
     REAL( kind = 8 ) :: C2M5
     REAL( kind = 8 ) :: C1M10
     REAL( kind = 8 ) :: C1M11
     REAL( kind = 8 ) :: C1M12
     REAL( kind = 8 ) :: C8M2
     REAL( kind = 8 ) :: C5M2
     REAL( kind = 8 ) :: C5M3
     REAL( kind = 8 ) :: C5M5
     REAL( kind = 8 ) :: C98M4
     REAL( kind = 8 ) :: C71M1
     REAL( kind = 8 ) :: C95M2
     REAL( kind = 8 ) :: C23M1
     REAL( kind = 8 ) :: C23M2
     REAL( kind = 8 ) :: C55M1
     REAL( kind = 8 ) :: C75M1
     REAL( kind = 8 ) :: C25M1
     REAL( kind = 8 ) :: C25M2
     REAL( kind = 8 ) :: C72M1
     REAL( kind = 8 ) :: C49M3
     REAL( kind = 8 ) :: C26M1
     REAL( kind = 8 ) :: C11M1
     REAL( kind = 8 ) :: C45M1
     REAL( kind = 8 ) :: C267M6
     REAL( kind = 8 ) :: C719M1
     REAL( kind = 8 ) :: C743M1
     REAL( kind = 8 ) :: C924M1
     REAL( kind = 8 ) :: C886M1
     REAL( kind = 8 ) :: C546M2
     REAL( kind = 8 ) :: C207M3
     REAL( kind = 8 ) :: C316M1
     REAL( kind = 8 ) :: C116M1
     REAL( kind = 8 ) :: C125M1
     REAL( kind = 8 ) :: C766M1
     REAL( kind = 8 ) :: C758M2
     REAL( kind = 8 ) :: C292M1
     REAL( kind = 8 ) :: C7M1
     REAL( kind = 8 ) :: C63M4
     REAL( kind = 8 ) :: C215M7
     REAL( kind = 8 ) :: C264M5
     REAL( kind = 8 ) :: C35M1
     REAL( kind = 8 ) :: C19M3
     REAL( kind = 8 ) :: C809M1
     REAL( kind = 8 ) :: C157M1
     REAL( kind = 8 ) :: C562M1
     REAL( kind = 8 ) :: C15E2
     REAL( kind = 8 ) :: C175E0
     REAL( kind = 8 ) :: C17M1
     REAL( kind = 8 ) :: C24M1
     REAL( kind = 8 ) :: C1M15
     REAL( kind = 8 ) :: C95M1
     REAL( kind = 8 ) :: C30M2
     REAL( kind = 8 ) :: C105M2
     REAL( kind = 8 ) :: C84M2
     REAL( kind = 8 ) :: C3E1
     REAL( kind = 8 ) :: C15M1
     REAL( kind = 8 ) :: C16M1
     REAL( kind = 8 ) :: C33M1
     REAL( kind = 8 ) :: C43M1
     REAL( kind = 8 ) :: C44M2
     REAL( kind = 8 ) :: C2E4
     REAL( kind = 8 ) :: C70E1
     REAL( kind = 8 ) :: C16E0
     REAL( kind = 8 ) :: C108E0
     REAL( kind = 8 ) :: C113E0
     REAL( kind = 8 ) :: C687M1
     REAL( kind = 8 ) :: C72E1
     REAL( kind = 8 ) :: C397M2
     REAL( kind = 8 ) :: C148M1
     REAL( kind = 8 ) :: C524M1
     REAL( kind = 8 ) :: C773M1
     REAL( kind = 8 ) :: C325E1
     REAL( kind = 8 ) :: C1E4
     REAL( kind = 8 ) :: C1M18
     REAL( kind = 8 ) :: C98M1
     REAL( kind = 8 ) :: C1E5
     REAL( kind = 8 ) :: C1E6
     REAL( kind = 8 ) :: C52E0
     REAL( kind = 8 ) :: C57E0
     REAL( kind = 8 ) :: C21E0
     REAL( kind = 8 ) :: C102E0
     REAL( kind = 8 ) :: C1E2
     REAL( kind = 8 ) :: C2E2
     REAL( kind = 8 ) :: C5E2
     REAL( kind = 8 ) :: C2E3
     REAL( kind = 8 ) :: C3E3
     REAL( kind = 8 ) :: C5E3
     REAL( kind = 8 ) :: C2E5
     REAL( kind = 8 ) :: C2E6
     REAL( kind = 8 ) :: C1E9
     REAL( kind = 8 ) :: C1E10
     REAL( kind = 8 ) :: C1E12
     REAL( kind = 8 ) :: C64E1
     REAL( kind = 8 ) :: C13E1
     REAL( kind = 8 ) :: C16E1
     REAL( kind = 8 ) :: C55E0
     REAL( kind = 8 ) :: C18E1
     REAL( kind = 8 ) :: C45E1
     REAL( kind = 8 ) :: C24E1
     REAL( kind = 8 ) :: C36E1
     REAL( kind = 8 ) :: C75E1
     REAL( kind = 8 ) :: C25E1
     REAL( kind = 8 ) :: C50E1
     REAL( kind = 8 ) :: C35E0
     REAL( kind = 8 ) :: C15E0
     REAL( kind = 8 ) :: C25E0
     REAL( kind = 8 ) :: C24E0
     REAL( kind = 8 ) :: C11E0
     REAL( kind = 8 ) :: C23E0
     REAL( kind = 8 ) :: C1E3
     REAL( kind = 8 ) :: C18E2
     REAL( kind = 8 ) :: C2E1
     REAL( kind = 8 ) :: C139E0
     REAL( kind = 8 ) :: C312E0
     REAL( kind = 8 ) :: C413E0
     REAL( kind = 8 ) :: C118E0
     REAL( kind = 8 ) :: C44E0
     REAL( kind = 8 ) :: C135E0
     REAL( kind = 8 ) :: C115E0
     REAL( kind = 8 ) :: C132E0
     REAL( kind = 8 ) :: C101E0
     REAL( kind = 8 ) :: C185E0
     REAL( kind = 8 ) :: C245E0
     REAL( kind = 8 ) :: C176E1
     REAL( kind = 8 ) :: C186E1
     REAL( kind = 8 ) :: C141E1
     REAL( kind = 8 ) :: C273E2
     REAL( kind = 8 ) :: C351E2
     REAL( kind = 8 ) :: C267E3
     REAL( kind = 8 ) :: C116E0
     REAL( kind = 8 ) :: C216E0
     REAL( kind = 8 ) :: C243E0
     REAL( kind = 8 ) :: C177E0
     REAL( kind = 8 ) :: C137E1
     REAL( kind = 8 ) :: C12E0
     REAL( kind = 8 ) :: C1O7
     REAL( kind = 8 ) :: C1O6
     REAL( kind = 8 ) :: C1O24
     REAL( kind = 8 ) :: C1O3
     REAL( kind = 8 ) :: C4O3
     REAL( kind = 8 ) :: C3O4
     REAL( kind = 8 ) :: C4O7
     REAL( kind = 8 ) :: C6O7
     REAL( kind = 8 ) :: C8O3
     REAL( kind = 8 ) :: C3O8
     REAL( kind = 8 ) :: C2O3
     REAL( kind = 8 ) :: C9O16
     REAL( kind = 8 ) :: C24O31
     REAL( kind = 8 ) :: C15O4
     REAL( kind = 8 ) :: C71O6
     REAL( kind = 8 ) :: C37O6
     REAL( kind = 8 ) :: C31O6
     REAL( kind = 8 ) :: C65O6
     REAL( kind = 8 ) :: C110O3
     REAL( kind = 8 ) :: C106E0
     REAL( kind = 8 ) :: C156M1
     REAL( kind = 8 ) :: C193M1
     REAL( kind = 8 ) :: C476M1
     REAL( kind = 8 ) :: C103E0
     REAL( kind = 8 ) :: C152E0
     REAL( kind = 8 ) :: C176E0
     REAL( kind = 8 ) :: C389E0
     REAL( kind = 8 ) :: C266M2
     REAL( kind = 8 ) :: C3M8
     REAL( kind = 8 ) :: C5M8
     REAL( kind = 8 ) :: C6M8
     REAL( kind = 8 ) :: C201M4
     REAL( kind = 8 ) :: C387E5
     REAL( kind = 8 ) :: C812M1
     REAL( kind = 8 ) :: C452E0
     REAL( kind = 8 ) :: C771E0
     REAL( kind = 8 ) :: C137E3
     REAL( kind = 8 ) :: C98E5
     REAL( kind = 8 ) :: C567M8
     REAL( kind = 8 ) :: LNTEN
     REAL( kind = 8 ) :: PI
     REAL( kind = 8 ) :: PIO2
     REAL( kind = 8 ) :: TPI
     REAL( kind = 8 ) :: CGEOM
     REAL( kind = 8 ) :: SQRT8
     REAL( kind = 8 ) :: SQRT22
     REAL( kind = 8 ) :: SQRT3
     REAL( kind = 8 ) :: CPSML
     REAL( kind = 8 ) :: CQLGE
     REAL( kind = 8 ) :: CQSML
     REAL( kind = 8 ) :: GRAV
     REAL( kind = 8 ) :: STEF
     REAL( kind = 8 ) :: RCGAS
     INTEGER( kind = 4 ) :: LSCONS

ENDMODULE CONST

 

0 Kudos
6 Replies
Highlighted
Black Belt
1 View

Why would you expect any

Why would you expect any particular ordering in memory for individual variables? Only a SEQUENCE or BIND(C) derived type gives you that, and even then there may be padding between components. The compiler is free to assign separate variables to any memory locations it chooses. 

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
New Contributor I
1 View

It may be interesting to

It may be interesting to point out that modules are often viewed as a direct replacement for COMMON, especially for old-timers. Variables in common WERE stored sequentially in memory, and many coders took advantage of that property. They can be shocked to learn that it's not so simple with variables in a module.

0 Kudos
Highlighted
Black Belt
1 View

True, but a COMMON

True, but a COMMON declaration had a list of variables and you could have multiple COMMONs (still can, of course). One can put a COMMON in a module and get COMMON's storage association but still reference the variables as module variables. A bit anachronistic, but it works.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
New Contributor I
1 View

Quote:Steve Lionel (Ret.)

Steve Lionel (Ret.) wrote:

True, but a COMMON declaration had a list of variables and you could have multiple COMMONs (still can, of course). One can put a COMMON in a module and get COMMON's storage association but still reference the variables as module variables. A bit anachronistic, but it works.


​Sorry to disagree. How variables are located in memory is a matter of architecture and optimization. As I have already pointed out creating a copy of a common on a file is easy. Try to do the same thing with a module which does not include a common.  

 

0 Kudos
Highlighted
Beginner
1 View

Quote:Steve Lionel (Ret.)

Steve Lionel (Ret.) wrote:

True, but a COMMON declaration had a list of variables and you could have multiple COMMONs (still can, of course). One can put a COMMON in a module and get COMMON's storage association but still reference the variables as module variables. A bit anachronistic, but it works.

Thanks very mush

Because, I need to change old fortran 77 program to fortran 90, In old program, it use loc() get address and than calculate

As like what dboggs say,  modules are often viewed as a direct replacement for COMMO
so, I hope module can
realize, I don't need to modify a lot of code

Maybe, I will try what you say

 

0 Kudos
Highlighted
Black Belt
1 View

Quote:Luigi R. wrote:

Luigi R. wrote:

​Sorry to disagree. How variables are located in memory is a matter of architecture and optimization. As I have already pointed out creating a copy of a common on a file is easy. Try to do the same thing with a module which does not include a common.  

What, exactly, are you disagreeing with? Your statement about optimization echoes what I wrote originally. I don't understand your second point.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos