Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: a fortran environment

  1. #1
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152

    a fortran environment

    I've been trying both C and PBCC6 to make something, that for me, is relatively big.

    So far, I find both of them to be somewhat unpleasant for big programs.

    (This is just my thinking today, tomorrow may be different.)

    I would say there is not enough encapsulation in either of them.

    So, I decided to try going back to fortran.

    I am trying GNU fortran, i.e., "gfortran".

    It is at least partially complete through the Fortran 2008 standard (which includes OOP).

    So far, I am content with the fact that it supports modules, which go back to the Fortran 90 standard.

    Additionally, I found an IDE that, until now, seems to work really good with gfortran, "Code::Blocks".

    I was able to make a project using Code::Blocks, that contains a main program file, and a module file.

    Believe it or not, it compiled, linked, and ran correctly.

    I just downloaded Code::Blocks a day or two ago, and tonight everything worked good.

    And, the IDE looks good too.

    (I checked, and the two files are actually compiled separately, i.e., there are two object files.)

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

    gfortran Wiki:

    http://gcc.gnu.org/wiki/GFortran

    Binaries available for gfortran:

    http://gcc.gnu.org/wiki/GFortranBinaries

    If you want to get gfortran, go to the following link, and double click on the green button that says, "Download".

    http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/

    (Underneath, "Download", also on the green button it says, "mingw-get-inst-...exe".)

    The download is approximately 0.5 MB.

    When you get the exe file, run it.

    You will see the MinGW-Get Setup Wizard.

    You can check, "Use pre-packaged repository catalogues".

    Accept the License Agreement, or, you'll be installing nothing.

    You can put it in the default folder, "C:\MinGW".

    When you get to the panel labeled, "Select Components", all you need to check is, "Fortran Compiler".

    Click, "Install", and a console window will open, and all you need will download and install.

    After it finishes, you have to put, "c:\mingw\bin", on you path.

    To see if it is there, open a console window, and execute, "gfortran -v".

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

    Code::Blocks website

    http://darmar.vgtu.lt/

    If you have trouble compiling a fortran program: -->

    Go to, "Settings" - "Compiler and debugger" - "Global compiler settings".

    For, "Selected compiler", choose, "GNU Fortran Compiler".

    Then, go below in the same dialog to the tab, "Toolchain executables".

    Make sure for "Compiler's installation directory", it is, "c:\mingw\bin".

    Below, still in the same dialog, for the tab, "Program Files", the choices for both, "C compiler", and "C++ compiler", should be, "gfortran.exe".

    (Hopefully, that will work. My version of gfortran is actually somewhere else, "c:\program files\gfortran\bin". I have had it for awhile, I forget how I got it. I am going to download the latest version of gfortran, using the method shown above, but, I haven't done it yet.)

    Last edited by danbaron; 19-10-2011 at 09:36.
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  2. #2
    Hi Dan,

    Have you tried thinBasic or maybe even ScriptBasic with your project effort? Is this a CPU intensive application and only a compiled program makes sense?

    John
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  3. #3
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152
    My idea, John, if it ever gets that far, is to make something which is compiled, and can be called from scripting languages.

    (From experience, my conscience is not clear if I never post here about something that can ultimately be used with a scripting language.)

    The Basic scripting languages work good, I know that.

    But, like many programmers, I would like to create something, if I can.

    If I ever can make something which can be called from scripting languages, or at least, if I am attempting to do so, then, that seems to be the best way.

    (Actually, having an interpreter which can call compiled functions which other people create, seems like a great situation for everyone - in that way, all can feel a part of the project - then, I think, everyone wins.)

    It seems to me, that, theoretically, a person could use any compiled language to create (I guess you call them), DLLs or SLLs.

    But first, I think I have to make something which someone else would like to use, before I worry about DLLs and SLLs.

    Dan

    Last edited by danbaron; 19-10-2011 at 20:18.
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  4. #4
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152
    So far, everything works.

    I have two test files in a project, "main.f08", and, "reg.f08".

    It compiles, links, and runs.

    (And, as I said I would do, above, I have installed the latest version of gfortran into, c:\mingw\bin.)

    ' main.f08 -------------------------------------------------------------------------------------------
    
    program something
    
    use reg
    implicit none
    type(regtype)::r
    
    call allocatereg(r,1000)
    call zeroreg(r)
    print *, r%d(r%ndigits - 1)
    
    end program
    
    ' reg.f08 --------------------------------------------------------------------------------------------
    
    module reg
    
    type regtype
    integer(4)::ndigits
    integer(1),pointer,dimension(:)::d
    integer(4)::maxpower
    logical::sgn
    end type regtype
    
    contains
    
    subroutine allocatereg(r,ndigits)
    type(regtype),intent(inout)::r
    integer(4),intent(in)::ndigits
    r%ndigits = ndigits
    r%maxpower = -1
    r%sgn = .true.
    allocate(r%d(ndigits))
    end subroutine allocatereg
    
    subroutine zeroreg(r)
    type(regtype),intent(inout)::r
    r%d(0:r%ndigits) = 0
    end subroutine zeroreg
    
    end module reg
    
    Last edited by danbaron; 21-10-2011 at 08:04.
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  5. #5
    IMO, Basic and C are the only two languages one would ever need to use. Everything else is a derivative.

    Basic for ease of use and minimal coding.

    C for speed and low level access to resources.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  6. #6
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  7. #7
    ScriptBasic was written in ANSI/ISO C back in 1998. This same code base has remained unchanged for the most part except for a couple deprecated gcc keywords that were compensated for. Going to 64 bit with ScriptBasic was nothing more than a compiler command line option change. (same for moving SB to the OS X)

    I've never used Fortran so it's portability aspects are unknown to me.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  8. #8
    John, if you would stop promoting ScriptBasic every chance you get, people might actually be more inclined to try it.
    Dan, I toyed with Fortran a bit also and as I understand it, interfacing with C or Basic can be a bit tricky.
    for simple types like integer or double there's no problem but arrays are another story.
    Last edited by jack; 21-10-2011 at 23:17.

  9. #9
    John, if you would stop promoting ScriptBasic every chance you get, people might actually be more inclined to try it.
    I was just pointing out the portability aspect of writing a high level language in ANSI/ISO C. After almost fifteen years, the same code still compiles.

    I don't make a penny promoting ScriptBasic which is a open source LGPL language. I have 6 years invested in supporting and keeping the language alive. If I make a comment using SB as an example, I don't understand what you're upset about. What if Ford or GM stopped promoting their cars and said people will buy them if they see them on the street?

    Give SB a try Jack and if you think it sucks then I'll stop posting about it.
    Last edited by John Spikowski; 22-10-2011 at 02:17.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  10. #10
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404
    Dan, about code::blocks, it is also very easy to make it portable. That is to put onto a memory device and take with you to any other windows os device.
    http://wiki.codeblocks.org/index.php...ks_portable.3F

    Fortran was the first language I learned in the 1970's. It still makes very fast executable's. http://shootout.alioth.debian.org/u3...re-fastest.php

    Found this a Fortran that is the best of Fortran 90 getting rid of what was bad.
    http://www.fortran.com/F/

Page 1 of 3 123 LastLast

Similar Threads

  1. Space environment creator by kryton9
    By kryton9 in forum User tools
    Replies: 36
    Last Post: 08-02-2010, 07:04

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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