Shop OBEX P1 Docs P2 Docs Learn Events
Fortran Programs on the Propeller — Parallax Forums

Fortran Programs on the Propeller

HumanoidoHumanoido Posts: 5,770
edited 2012-07-22 22:36 in Propeller 1
Is anyone running a version of Fortran on the Propeller chip?
I have a lot of very useful physics programs that run in this
language and would like to see these on the prop for a future
project.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-11 08:35
    Fortran just doesn't make sense on a Propeller. The sorts of programs you're talking about tend to be either small and fairly simple or very large and very complex with a need for at least a significant amount of data. On the Propeller, there's not that much room for program or data unless you move it all out to external SRAM where there's a huge performance hit. If you're talking about small and fairly simple programs, why not transliterate them into Spin or C? Remember that the Propeller just has single precision software floating point. It's pretty fast as these things go, but it's still relatively slow by today's computing standards ... several microseconds per basic operation.

    I think there's a GCC front end for Fortran, but it would take a lot of work to integrate that and particularly to provide the necessary run-time library.
  • LeonLeon Posts: 7,620
    edited 2012-07-11 08:39
    There are programs that automatically convert Fortran code to C. I used one on a large and complex Fortran application, and got it working on a PC with a C compiler without any problems.
  • pik33pik33 Posts: 2,413
    edited 2012-07-11 08:51
    When I was student, (1984-89) I learned Fortran. We programmed a machine called Odra 1305; a big machine, which was installed in big climatized room. it had 256k 24-bit words of operating memory and multitasking/multiuser operating system called George 3. We had to write our programs on perforated cards...

    The Propeller has less memory (32k) but it has acces to some GB of SD card and more processing power than this Odra. I thnk Fortran programming should be possible with it if only someone can write a compiler.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2012-07-11 08:57
    Uh Oh.. Someone said something wasn't possible on a Propeller again...

    Starting stopwatch... <grin>

    OBC
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-07-11 08:57
    In addition to C and C++, GCC supports Objective-C, Fortran, Java, Ada and Go. All of the languages compile to an intermediate language call GENERIC. The compiler passes after that are essentially the same for each language, so implementing the other languages mostly requires modifying the front-end for that language.
  • jazzedjazzed Posts: 11,803
    edited 2012-07-11 09:32
    Isn't Fortran already supported in Heater's ZOG emulation?

    Would be neat to get the other GCC languages with Propeller-GCC.
  • Heater.Heater. Posts: 21,230
    edited 2012-07-11 09:47
    Can't rememeber now how far I got with Fortran in Zog.
    For sure I rebuilt the zpugcc to support Fortran and then managed to compile at least a simple Hello World program with it.
    Can't remember now if I ever got it to run. Perhaps it is mentioned in the Zog thread somewhere.
    So I imagine propgcc can do the same. Just enable Fortran in the configure step before building propgcc.
    After that what libraries it may need to make it useful is beond me.
  • cavelambcavelamb Posts: 724
    edited 2012-07-11 15:44
    Uh Oh.. Someone said something wasn't possible on a Propeller again...

    Starting stopwatch... <grin>

    OBC


    Nevada Fortran - running under CP/M
  • Cluso99Cluso99 Posts: 18,071
    edited 2012-07-11 17:13
    I believe fortran runs on ZiCog & CPM2.2
    Couldn't run any slower than thos old days when you programmed on punch cards and submitted the deck and waited for your results next day ;)
  • wmosscropwmosscrop Posts: 409
    edited 2012-07-12 10:25
    Humanoido wrote: »
    Is anyone running a version of Fortran on the Propeller chip?

    Well, technically, I am :)...

    ...If you count Fortran 4 on an IBM 1130 emulator. 16K bytes of memory, 16 bit integers, no booleans, only arithmetic if statements. But it does have "extended precision" (I believe 48 bit) floating point...

    That said, there was a gentleman from the local electric company who wrote a series of complex Fortran programs on the 1130 that helped him calculate the costs for building electrical substations.

    Here's the output from a sample job (and please note that the "8K" values are referring to words, not bytes):
    PAGE   1
    
    // JOB    2BAD
    
    LOG DRIVE   CART SPEC   CART AVAIL  PHY DRIVE
      0000        2BAD        2BAD        0000
    
    V2 M12   ACTUAL  8K  CONFIG  8K
    
    // FOR
    *IOCS(1403 PRINTER)
    *LIST SOURCE PROGRAM
          INTEGER I, PRT
          REAL PI, RSLT
          PRT = 5
          PI = 3.14159
          DO 1 I = 1, 10
          RSLT = I * PI
        1 WRITE(PRT, 20) I, RSLT
       20 FORMAT(1X, I2, ' * PI = ',F8.5)
          CALL EXIT
          END
    
    FEATURES SUPPORTED
     IOCS
    
    CORE REQUIREMENTS FOR
     COMMON      0  VARIABLES      8  PROGRAM     78
    
    END OF COMPILATION
    
    // XEQ
    
     1 * PI =  3.14159
     2 * PI =  6.28318
     3 * PI =  9.42477
     4 * PI = 12.56636
     5 * PI = 15.70794
     6 * PI = 18.84954
     7 * PI = 21.99113
     8 * PI = 25.13272
     9 * PI = 28.27430
    10 * PI = 31.41589
    

    Walter
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-07-13 09:25
    wmosscrop wrote: »
    Well, technically, I am :)...
    ...If you count Fortran 4 on an IBM 1130 emulator. 16K bytes of memory, 16 bit integers, no booleans, only arithmetic if statements. But it does have "extended precision" (I believe 48 bit) floating point...Walter

    Walter, can you direct me to your web site describing the IBM 1130 emulator running on a Propeller chip? Or is this running on a PC?
  • wmosscropwmosscrop Posts: 409
    edited 2012-07-13 10:36
    Humanoido wrote: »
    Walter, can you direct me to your web site describing the IBM 1130 emulator running on a Propeller chip? Or is this running on a PC?

    Humanoido,

    It is running on a Propeller. It's still very much a work-in-progress (I just worked out some CPU emulation issues that affected the assembler earlier this month). The CPU emulation is about 3X the speed of the original machine; the disk emulation is about 50-100X faster.

    My blog is at http://forums.parallax.com/blog.php?58796-Retrocomputing...and-whatever-else-comes-to-mind. I hope to get another entry posted this weekend as I have made significant progress since my last post.

    I would be happy to post a schematic and the source code to date, if you're interested.

    Walter
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-07-14 03:44
    wmosscrop wrote: »
    Humanoido,
    It is running on a Propeller. It's still very much a work-in-progress (I just worked out some CPU emulation issues that affected the assembler earlier this month). The CPU emulation is about 3X the speed of the original machine; the disk emulation is about 50-100X faster.
    My blog is at http://forums.parallax.com/blog.php?58796-Retrocomputing...and-whatever-else-comes-to-mind. I hope to get another entry posted this weekend as I have made significant progress since my last post.
    I would be happy to post a schematic and the source code to date, if you're interested.
    Walter

    Walter, yes please post the schematic and source code, and any instructions about running it on the Propeller. This is a very interesting project and could lead to some form of Tiny Fortran implement.
  • ersmithersmith Posts: 6,184
    edited 2012-07-15 19:05
    The gfortran compiler (the fortran front end to gcc) builds with propgcc. Building the compiler itself is very straightforward -- it's just a matter of unpacking the gfortran-4.6.1.tar.gz file into the propgcc source tree (moving the stuff from gcc-4.6.1/ into propgcc/gcc/) and then rebuilding propgcc. The library is another matter -- it needs some support from the C library that propgcc beta is missing. I've checked those functions in to the propgcc tree. The library also doesn't build properly with -m32bit-doubles, so not all the automatically built versions are OK. But that's easy enough to work around.

    The disappointment is that the library is huge, so even a fortran version of "hello world" ends up compiling to 180K or so. There also seems to be a bug in the I/O functions so that only the first part of the message comes out. I'll look at it later, but the huge size of the binaries makes building fortran only useful in XMM or XMMC modes, which is a bit disappointing.

    Eric
  • wmosscropwmosscrop Posts: 409
    edited 2012-07-15 19:29
    Humanoido wrote: »
    Walter, yes please post the schematic and source code, and any instructions about running it on the Propeller. This is a very interesting project and could lead to some form of Tiny Fortran implement.

    Humanoido,

    I should be able to do this by the end of the week. Was hoping to do so this weekend but didn't get to it--sorry!

    Walter
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-07-15 19:43
    ersmith wrote: »
    The gfortran compiler (the fortran front end to gcc) builds with propgcc. Building the compiler itself is very straightforward -- it's just a matter of unpacking the gfortran-4.6.1.tar.gz file into the propgcc source tree (moving the stuff from gcc-4.6.1/ into propgcc/gcc/) and then rebuilding propgcc. The library is another matter -- it needs some support from the C library that propgcc beta is missing. I've checked those functions in to the propgcc tree. The library also doesn't build properly with -m32bit-doubles, so not all the automatically built versions are OK. But that's easy enough to work around. The disappointment is that the library is huge, so even a fortran version of "hello world" ends up compiling to 180K or so. There also seems to be a bug in the I/O functions so that only the first part of the message comes out. I'll look at it later, but the huge size of the binaries makes building fortran only useful in XMM or XMMC modes, which is a bit disappointing. Eric
    Eric, thanks for checking this. It is a bit disappointing that so many sources quote GCC as a viable front end to Fortran. What's needed is a Tiny Fortran version to compile into a chip manageable binary.
  • ersmithersmith Posts: 6,184
    edited 2012-07-16 05:25
    Humanoido wrote: »
    Eric, thanks for checking this. It is a bit disappointing that so many sources quote GCC as a viable front end to Fortran. What's needed is a Tiny Fortran version to compile into a chip manageable binary.

    Well, I think Mike nailed it in the second comment on this thread. Getting the GCC fortran compiler itself to work was trivial (a matter of 5 minutes of work). Getting a Propeller friendly runtime library is the hard part. The 180KB or so for the included gfortran library is probably considered tiny these days for PCs, so nobody has bothered to make it smaller (yet).

    Of course even without the library gfortran is still usable for some purposes -- for example you could compile fortran functions that could be called from C or from PASM.

    Eric
  • jazzedjazzed Posts: 11,803
    edited 2012-07-16 07:38
    ersmith wrote: »
    Well, I think Mike nailed it in the second comment on this thread. Getting the GCC fortran compiler itself to work was trivial (a matter of 5 minutes of work). Getting a Propeller friendly runtime library is the hard part. The 180KB or so for the included gfortran library is probably considered tiny these days for PCs, so nobody has bothered to make it smaller (yet).

    I suppose GCJ and Objective C would have similar results. I know of at least one person who might be interested in contributing to Objective C development. I'm a little worried about growing our current repository though - it's getting tough to make new clones.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-07-16 08:27
    I think a better approach with Fortran is to use a Fortran-to-C converter, and then work with the C code. I started out programming in Fortran, as many of us did in the 70's. I then started programming in Ratfor in the early 80's after one of my co-workers ported the Ratfor pre-processor to our main work computer. He refused to program in Fortran, and we didn't have a C compiler for our computer, so Ratfor was as close as we could get to C on that machine. I then started programming in C around 1983 or '84.

    An internet search of Fortran-to-C converters shows that f2c is a popular converter. It was developed at Bell Labs, and is open-source software.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-07-16 08:33
    Man, we're a bunch of old coots on these forums! Too bad Parallax doesn't give AARP discounts or have early bird specials at UPEW, UPEC and UPENE. :lol:
  • wmosscropwmosscrop Posts: 409
    edited 2012-07-18 18:03
    Humanoido wrote: »
    Walter, yes please post the schematic and source code, and any instructions about running it on the Propeller. This is a very interesting project and could lead to some form of Tiny Fortran implement.

    Humanoido,

    I've attached a zip file containing my (rather hastily assembled) documentation, schematic, source files, and images. Hopefully you can make sense of this work-in-progress... if not, please feel free to ask questions (my direct email is included in the documentation).

    Good luck!

    Walter
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-07-22 22:36
    wmosscrop wrote: »
    ...I've attached a zip file containing my (rather hastily assembled) documentation, schematic, source files, and images...
    Walter, thanks for following through with this impressive collection of work! You really have opened up new doors for the Propeller chip with your results. Thanks!
Sign In or Register to comment.