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!

simple ? 1

Status
Not open for further replies.

bobo12

Programmer
Dec 26, 2004
74
US
please consider the following...the code below works...
CHARACTER*127 FMAT
FORMAT (/' input a FORTRAN-type FORMAT for the data')
READ (*,'(A)') FMAT
CALL CHKFMT (FMAT,IFMT)

and then...
SUBROUTINE CHKFMT (FMAT,IFMT)
CHARACTER*127 FMAT...

ok so here is my ?, how are we allowed to declare FMAT twice. most compilers in java & c complain about this b/c u can't make a distinciton as to which FMAT i am referring to. would someone plz explain how FMAT can be delcared twice and are all instances of FMAT referring to the same varialbe or not?

thanks
 
SUBROUTINE CHKFMT starts a new scope. In this scope FMAT (in parentesis) denotes formal parameter, next declaration add this parameter type and attributes. It's normal scope rules. All other FMAT declarations are hided in this scope (for example, you may have FMAT() subroutine). What's a problem?
Obviously, 1st four lines are placed in another scope (program, another subroutine etc). FMATs from different subroutines denotes different entities (variables).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top