Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts

    Global variables in FORTRAN

    Ok where are all the old folks at? Yeah you old timers that grew up learning Fortran back in the 50's.

    How are global variables in Fortran declared? Do you just declare them outside any functions for them to be global or is there some keyword I need to use?
    Last edited by Spookster; 01-21-2003 at 03:49 AM.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I'm using Fortran77 by the way.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Ok after much digging I found the answer. Using the COMMON block statement allows one to share variables among different functions/subroutines:

    http://www.obliquity.com/computer/fortran/common.html
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    And by the way I just spent the last week learning Fortran so if anybody has questions on Fortran, ask away.

    Next week I will learn COBOL, then the next week Shell scripting, then Prolog, then LISP.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    IN, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why would you need to learn all of those languages- I thought they were ancient.
    Just call me Crash...
    "Crash- and BURN!"
    -Cereal Killer

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Yes they are all pretty old. Especially Fortran. Why learn them?

    1. These old languages were the basis for all future languages. Learning those will make learning other newer languages easier.

    2. Many businesses do still use languages like Fortran and Cobol. Especially Cobol. Lisp is the most widely used language for AI.

    3. They are all required for my bachelors degree in computer science.

    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also there is a shortage of cobol programmers so if you can do it you can earn big bucks.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Don't forget Pascal, Forth and Ada.

    I mean, we wouldn't want to leave anyone out.

    When I took Fortran IV I was also learning Compiled Basic on the new Vax 11/780 (Super hot stuff!), and I'm not that old! Even so, I couldn't have given you the answer without diggin through my books or old programs.

    Scott
    Scott Stewart
    Always happy to learn from pros.

  • #9
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    External variables in FORTRAN

    Quote Originally Posted by Spookster View Post
    Ok after much digging I found the answer. Using the COMMON block statement allows one to share variables among different functions/subroutines:

    http://www.obliquity.com/computer/fortran/common.html
    Hey there!
    I've found your comment by browsing i-net.
    Problem is the next: when I making main program in Fortran by that manner for defining common blocks it conflicts with the _main() C++ program.

    I trying to make mixed C++\Fortran program, for usage old Fortran modules. There no problem with functions an local variables, but in the case of global variables - need help!

  • #10
    New Coder
    Join Date
    May 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Spookster View Post
    And by the way I just spent the last week learning Fortran so if anybody has questions on Fortran, ask away.
    This post is pretty old; is your offer still open?

    I often translate FORTRAN programs into C++ and Javascript. To help me understand what a program does, I have downloaded and installed the OpenWATCOM compiler. One small piece of code I have recently come across has me puzzled: the FORTRAN 77 program uses a variable "L" without declaring it anywhere. Does FORTRAN default undeclared variables to a particular type?

    Regards.


    David

  • #11
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,589
    Thanks
    0
    Thanked 644 Times in 634 Posts
    Fortran defaults variables starting with I, J, K, L, and M to integer and everything else to float. That is why I is the variable usually chosen to control loops since it was the shortest variable name to use as a loop control that comes earliest in the alphabet.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #12
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah but why were they chosen like that in the first place? Because those letters (as lower case subscripts) are used in mathematics all the time! Implementing mathematical algorithms was the design principle behind FORmula TRANslator in the first place

  • #13
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,589
    Thanks
    0
    Thanked 644 Times in 634 Posts
    Quote Originally Posted by scroots View Post
    Also there is a shortage of cobol programmers so if you can do it you can earn big bucks.
    Only if you live in India and only relative to what other Indians earn. All the CoBOL jobs went to India about ten years ago when companies realised how much cheaper it was. They had employed the Indians to work on Y2K in order to get the necessary hundreds of extra staff needed for that project at an affordable price and once it was finished it was basically the local staff who were let go and the Indians retained to maintain the systems.

    The more programming languages that you know the easier it is to learn additional similar languages and to make sens of code in languages that you don't know. After learning the first language in any given programming style it becomes easier to learn additional programs that use that style. If is the first procedure based, object oriented, rules based etc language that is the hardest to learn. Just to know one of each type of language would mean learning a dozen or more different languages. I know languages in each of the three styles mentioned but not any of the others. Fortran was the first language I learnt - back in the mid 70s before I had access to a computer.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #14
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,208
    Thanks
    7
    Thanked 268 Times in 267 Posts
    I can certainly attest to the "new type of language" issue. Some of the hardest languages I ever learned were SNOBOL (string oriented), APL (sort of a mathematical symbol language), LISP (a language for people fond of parentheses), and JAM (to program the Xerox Star, with a stack as the only memory available).

    For me at least, any of these were harder than C or Assembly, because they were different enough that normal assumptions about programming didn't always apply.

    Dave


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •