Author Topic: FORTRAN  (Read 16436 times)

Neil Waldhauer

  • Hero Member
  • *****
  • Posts: 1024
  • Karma: +24/-0
    • View Profile
    • Blonde Guy
FORTRAN
« on: March 08, 2022, 03:09:32 am »
I'm interested in finding GFortran. All I've found so far is an emx-based build from 1999 on Hobbes.

https://hobbes.nmsu.edu/?path=%2Fpub%2Fos2%2Fdev%2Femx%2Fcontrib%2Fg77
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: FORTRAN
« Reply #1 on: March 08, 2022, 03:47:39 am »
Hey Neil - some of my gcc builds include gfortran - not really tested but it builds :)

Neil Waldhauer

  • Hero Member
  • *****
  • Posts: 1024
  • Karma: +24/-0
    • View Profile
    • Blonde Guy
Re: FORTRAN
« Reply #2 on: March 08, 2022, 04:44:49 pm »
This one has gfortran.exe included.

https://smedley.id.au/downloads/gcc-8.3.0-os2-20190324.zip

I set up the environment, and gfortran executes

Code: [Select]
/* my command file to set up the GCC 8.3.0 environment */
GCCDir = 'f:\programs\gcc830\usr'
GCCDir2 = translate(GCCDir, '/', '\')
ToolkitDir = 'f:\programs\os2tk45'
ToolkitDir2 = translate(ToolkitDir, '/', '\')
localName = 'local830'
localCPU = 'i686-pc-os2-emx'
localVer = ''localVer''

'set PATH='GCCDir'\'localName'\bin;'GCCDir'\'localName'\libexec\gcc\'localCPU'\'localVer';%path%'
'set C_INCLUDE_PATH='GCCDir2'/'localName'/lib/gcc/'localCPU'/'localVer'/include;'ToolkitDir2'/H;'
'set CPLUS_INCLUDE_PATH='GCCDir2'/'localName'/include/c++/'localVer';'GCCDir2'/'localName'/include/c++/'localVer'/'localCPU';'GCCDir2'/'localName'/lib/gcc/'localCPU'/'localVer'/include;'GCCDir2'/'localName'/include/c++/'localVer'/backward;'GCCDir2'/'localName'/include;'
'set LIBRARY_PATH='GCCDir2'/'localName'/lib/gcc/'localCPU'/'localVer';'GCCDir2'/'localName'/lib;'
'set BEGINLIBPATH='GCCDir'\'localName'\lib;'

But I'm not getting a good compile for hello world.

hello.for
--------
print *, "Hello, world"
end


Quote
{0} gfortran hello.for
hello.for:1:1:

 print *, "Hello, world"
 1
Error: Non-numeric character in statement label at (1)
hello.for:1:1:

 print *, "Hello, world"
 1
Error: Unclassifiable statement at (1)
hello.for:2:1:

 end
 1
Error: Non-numeric character in statement label at (1)
hello.for:2:1:

 end
 1

Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Doug Clark

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +7/-1
    • View Profile
Re: FORTRAN
« Reply #3 on: March 13, 2022, 12:32:38 am »
I don't know if this helps, but fortan is include in Open Watcom. 

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: FORTRAN
« Reply #4 on: March 13, 2022, 03:50:11 am »
Thought I'd try as I have various versions of Paul's GCC installed. Named the hello world program hello.f90 as suggested at https://riptutorial.com/fortran/example/3044/hello--world (suffix might be important) and used this command line,
Code: [Select]
gfortran -o hello.exe hello.f90
Works with GCC 4.4.6, 5.3.0 required gcc530.dll to run and all newer fail like,
Code: [Select]
[H:\tmp\r]gfortran -o hello.exe hello.f90
../.././libbacktrace/mmap.c:190 (K:/USR/local620/lib/gfortran.a(mmap.o)): Undefined symbol _munmap referenced from text segment
../.././libbacktrace/mmap.c:145 (K:/USR/local620/lib/gfortran.a(mmap.o)): Undefined symbol _mmap referenced from text segment

No GCC 8.3.0 installed but 6.2.0, 7.1.0 and 9.1.0 all failed with same mmap error. 5.5.0 is missing gfortran.
Attempting to build with -lcx, which would fix things with gcc and g++ didn't help and quickly reading the documentation doesn't show how to link to libcx.
So gcc530 is the newest version that simply works here, at least with gcc530.dll on the LIBPATH.

For my environment, I unzip to @unixroot\usr so k:\usr\local530 etc and use the attached cmd file, installed in @unixroot\usr\bin. To change which GCC it sets up, change the name and edit line 73 the part that says 'gcc530'. Thanks to KOMH for the cmd file, I have multiple ones,
Code: [Select]
[K:\usr\bin]dir gcc*env.cmd

The volume label in drive K is Unixroot.
The Volume Serial Number is 2CFE:A5C0.
Directory of K:\usr\bin

 3-23-19  7:59p        13,349 13,555 a---  gcc446env.cmd
 4-01-18 11:01p        13,349    124 a---  gcc510env.cmd
 6-10-18 11:10p        13,349 13,555 a---  gcc530env.cmd
 6-11-18  7:22a        13,349 13,555 a---  gcc550env.cmd
11-26-18  5:03p        13,349 13,555 a---  gcc620env.cmd
11-26-18  5:03p        13,381 13,555 a---  gcc710env.cmd
 5-05-19 10:41a        13,381 13,555 a---  gcc910env.cmd
        7 file(s)      93,507 bytes used

Edit: Actually attach cmd file
« Last Edit: March 13, 2022, 07:35:15 am by Dave Yeo »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: FORTRAN
« Reply #5 on: March 13, 2022, 04:06:33 am »
Thanks for testing Dave - I might try re-enabling it with GCC 9.3.0

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: FORTRAN
« Reply #6 on: March 13, 2022, 05:18:54 am »
With GCC 9.1.0, this command line works here,
Code: [Select]
[H:\tmp\r]gfortran -Zomf -Xlinker 'k:/usr/lib/libcx0.lib' -o hello.exe hello.f90

[H:\tmp\r]hello
 Hello world!

I'd assume it works with other versions.
I notice that gfortran doesn't seem to support the -Zlinker option.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: FORTRAN
« Reply #7 on: March 13, 2022, 05:22:03 am »
More portable,
Code: [Select]
[H:\tmp\r]gfortran -Zomf -Xlinker '/@unixroot/usr/lib/libcx0.lib' -o hello.exe hello.f90

[H:\tmp\r]hello
 Hello world!

hello.exe is quite big,
Code: [Select]
3-12-22  8:19p       509,299      0 a---  hello.exe

Edit, adding -Zmap to the compile line and then doing "mapxqs hello.map" will produce more informative trp reports if the program crashes.
« Last Edit: March 13, 2022, 06:08:49 am by Dave Yeo »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: FORTRAN
« Reply #8 on: March 13, 2022, 05:45:38 am »
Building gcc 9.4.0 now. Will see if I can avoid the need to  add xlinker :)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: FORTRAN
« Reply #9 on: March 13, 2022, 06:13:04 am »
Building gcc 9.4.0 now. Will see if I can avoid the need to  add xlinker :)

OTOH, linking against libcx does have benefits such as exceptq support I believe and looking at the map file, some other functions are pulled in from libcx0.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: FORTRAN
« Reply #10 on: March 13, 2022, 07:49:43 am »
Building gcc 9.4.0 now. Will see if I can avoid the need to  add xlinker :)

OTOH, linking against libcx does have benefits such as exceptq support I believe and looking at the map file, some other functions are pulled in from libcx0.

I was more thinking that if things like mmap are unavoidable,then I'd automate dragging in libcx :)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: FORTRAN
« Reply #11 on: March 13, 2022, 08:49:11 am »

I was more thinking that if things like mmap are unavoidable,then I'd automate dragging in libcx :)

OK, that was going to be my suggestion.

Neil Waldhauer

  • Hero Member
  • *****
  • Posts: 1024
  • Karma: +24/-0
    • View Profile
    • Blonde Guy
Re: FORTRAN
« Reply #12 on: March 13, 2022, 08:52:34 am »
I'm trying gcc830 with the .f90 suffix, and that does help.

{0} gfortran -Zomf -Xlinker '/@unixroot/usr/lib/libcx0.lib' -o hello.exe hello.f90
emxomfld: _abspath failed on 'crt0.obj'!!!

Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: FORTRAN
« Reply #13 on: March 13, 2022, 08:57:32 am »
I'm trying gcc830 with the .f90 suffix, and that does help.

{0} gfortran -Zomf -Xlinker '/@unixroot/usr/lib/libcx0.lib' -o hello.exe hello.f90
emxomfld: _abspath failed on 'crt0.obj'!!!
crt0.obj comes as part of the original klibc dev environment - probably also in rpm?

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: FORTRAN
« Reply #14 on: March 13, 2022, 09:05:27 am »
I'm trying gcc830 with the .f90 suffix, and that does help.

{0} gfortran -Zomf -Xlinker '/@unixroot/usr/lib/libcx0.lib' -o hello.exe hello.f90
emxomfld: _abspath failed on 'crt0.obj'!!!

Sounds like an environment problem. crt0.obj should be in /@unixroot/usr/lib