public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiling file with subroutines using gfortran
@ 2023-01-01  8:52 Hans Lonsdale
  2023-01-01 11:59 ` Patrick Begou
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Lonsdale @ 2023-01-01  8:52 UTC (permalink / raw)
  To: Gcc Help



I want to compile a file containing a number of subroutines.

I am using the command

gfortran -O3 -ffree-form -o myfile.f

But getting problems with recursive and END PROGRAM statement.

All I want is making the object file.

44 | recursive subroutine quicksort (array)
      | 1
Error: Unclassifiable statement at (1)
myfile.f:112:3:

  112 | end subroutine quicksort
      |   1
Error: Expecting END PROGRAM statement at (1)
myfile.f:122:35:

Have done

gfortran -O3 -ffree-form -o myfile.f

The command is supposed to make the object file, but I get errors with END PROGRAM declaration.


-- 
Sent with https://mailfence.com  
Secure and private email

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiling file with subroutines using gfortran
  2023-01-01  8:52 Compiling file with subroutines using gfortran Hans Lonsdale
@ 2023-01-01 11:59 ` Patrick Begou
  2023-01-01 13:32   ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Begou @ 2023-01-01 11:59 UTC (permalink / raw)
  To: Hans Lonsdale; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

You are using a wrong option that may overwrite your fortran source file 
with the result of the compilation..
To create only the .o file use:

gfortran -O3 -ffree-form*-c*  myfile.f

or, f you want:

gfortran -O3 -ffree-form*-c*  myfile.f*-o myfile.o*

it will do the same thing.

Patrick

Le 01/01/2023 à 09:52, Hans Lonsdale via Gcc-help a écrit :
>
> I want to compile a file containing a number of subroutines.
>
> I am using the command
>
> gfortran -O3 -ffree-form -o myfile.f
>
> But getting problems with recursive and END PROGRAM statement.
>
> All I want is making the object file.
>
> 44 | recursive subroutine quicksort (array)
>        | 1
> Error: Unclassifiable statement at (1)
> myfile.f:112:3:
>
>    112 | end subroutine quicksort
>        |   1
> Error: Expecting END PROGRAM statement at (1)
> myfile.f:122:35:
>
> Have done
>
> gfortran -O3 -ffree-form -o myfile.f
>
> The command is supposed to make the object file, but I get errors with END PROGRAM declaration.
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiling file with subroutines using gfortran
  2023-01-01 11:59 ` Patrick Begou
@ 2023-01-01 13:32   ` Jonathan Wakely
  2023-01-01 14:41     ` Hans Lonsdale
  2023-01-01 16:21     ` Patrick Begou
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Wakely @ 2023-01-01 13:32 UTC (permalink / raw)
  To: Patrick Begou; +Cc: Hans Lonsdale, gcc-help

[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]

On Sun, 1 Jan 2023, 12:01 Patrick Begou via Gcc-help, <gcc-help@gcc.gnu.org>
wrote:

> You are using a wrong option that may overwrite your fortran source file
> with the result of the compilation..
> To create only the .o file use:
>
> gfortran -O3 -ffree-form*-c*  myfile.f
>
> or, f you want:
>
> gfortran -O3 -ffree-form*-c*  myfile.f*-o myfile.o*
>


This markup doesn't really help in plain text rendering.




> it will do the same thing.
>
> Patrick
>
> Le 01/01/2023 à 09:52, Hans Lonsdale via Gcc-help a écrit :
> >
> > I want to compile a file containing a number of subroutines.
> >
> > I am using the command
> >
> > gfortran -O3 -ffree-form -o myfile.f
> >
> > But getting problems with recursive and END PROGRAM statement.
> >
> > All I want is making the object file.
> >
> > 44 | recursive subroutine quicksort (array)
> >        | 1
> > Error: Unclassifiable statement at (1)
> > myfile.f:112:3:
> >
> >    112 | end subroutine quicksort
> >        |   1
> > Error: Expecting END PROGRAM statement at (1)
> > myfile.f:122:35:
> >
> > Have done
> >
> > gfortran -O3 -ffree-form -o myfile.f
> >
> > The command is supposed to make the object file, but I get errors with
> END PROGRAM declaration.
> >
> >
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiling file with subroutines using gfortran
  2023-01-01 13:32   ` Jonathan Wakely
@ 2023-01-01 14:41     ` Hans Lonsdale
  2023-01-01 16:21     ` Patrick Begou
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Lonsdale @ 2023-01-01 14:41 UTC (permalink / raw)
  To: Jonathan Wakely, Patrick Begou; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 2243 bytes --]



January 1, 2023 at 2:32:49 PM CET Jonathan Wakely <jwakely.gcc@gmail.com> wrote:

On Sun, 1 Jan 2023, 12:01 Patrick Begou via Gcc-help, <gcc-help@gcc.gnu.org> wrote:

You are using a wrong option that may overwrite your fortran source file 
with the result of the compilation..
To create only the .o file use:

gfortran -O3 -ffree-form*-c*  myfile.f

or, f you want:

gfortran -O3 -ffree-form*-c*  myfile.f*-o myfile.o*

This markup doesn't really help in plain text rendering.

The file is not complicated, I just have defined an array and a recursive subroutine.

implicit none
integer, parameter :: prec=kind(1d0), i64=selected_int_kind(15)

integer, parameter :: L(0:43) = (/                     &
 1, 1, 3, 5, 9, 15, 25, 41, 67, 109,                   &
 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361,     &
 13529, 21891, 35421, 57313, 92735, 150049,            &
 242785, 392835, 635621, 1028457, 1664079, 2692537,    &
 4356617, 7049155, 11405773, 18454929, 29860703,       &
 48315633, 78176337, 126491971, 204668309, 331160281,  &
 535828591, 866988873, 1402817465 /)

recursive subroutine quicksort (array)
 real(prec), intent(inout) :: array(:)
 real(prec) :: temp, pivot
 integer :: i, j, last, left, right

 last = size (array)
end subroutine quicksort

 

it will do the same thing.

Patrick

Le 01/01/2023 à 09:52, Hans Lonsdale via Gcc-help a écrit :
>
> I want to compile a file containing a number of subroutines.
>
> I am using the command
>
> gfortran -O3 -ffree-form -o myfile.f
>
> But getting problems with recursive and END PROGRAM statement.
>
> All I want is making the object file.
>
> 44 | recursive subroutine quicksort (array)
>        | 1
> Error: Unclassifiable statement at (1)
> myfile.f:112:3:
>
>    112 | end subroutine quicksort
>        |   1
> Error: Expecting END PROGRAM statement at (1)
> myfile.f:122:35:
>
> Have done
>
> gfortran -O3 -ffree-form -o myfile.f
>
> The command is supposed to make the object file, but I get errors with END PROGRAM declaration.
>
>

-- Sent with https://mailfence.com  Secure and private email

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Compiling file with subroutines using gfortran
  2023-01-01 13:32   ` Jonathan Wakely
  2023-01-01 14:41     ` Hans Lonsdale
@ 2023-01-01 16:21     ` Patrick Begou
  1 sibling, 0 replies; 5+ messages in thread
From: Patrick Begou @ 2023-01-01 16:21 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Hans Lonsdale, gcc-help

[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

You're right Jonathan, sorry forthe mistake.
Please read:
gfortran -O3  -ffree-form  -c  myfile.f
and
gfortran -O3  -ffree-form  -c myfile.f   -o myfile.o

Patrick

Le 01/01/2023 à 14:32, Jonathan Wakely a écrit :
>
>
> On Sun, 1 Jan 2023, 12:01 Patrick Begou via Gcc-help, 
> <gcc-help@gcc.gnu.org> wrote:
>
>     You are using a wrong option that may overwrite your fortran
>     source file
>     with the result of the compilation..
>     To create only the .o file use:
>
>     gfortran -O3 -ffree-form*-c*  myfile.f
>
>     or, f you want:
>
>     gfortran -O3 -ffree-form*-c*  myfile.f*-o myfile.o*
>
>
>
> This markup doesn't really help in plain text rendering.
>
>
>
>
>     it will do the same thing.
>
>     Patrick
>
>     Le 01/01/2023 à 09:52, Hans Lonsdale via Gcc-help a écrit :
>     >
>     > I want to compile a file containing a number of subroutines.
>     >
>     > I am using the command
>     >
>     > gfortran -O3 -ffree-form -o myfile.f
>     >
>     > But getting problems with recursive and END PROGRAM statement.
>     >
>     > All I want is making the object file.
>     >
>     > 44 | recursive subroutine quicksort (array)
>     >        | 1
>     > Error: Unclassifiable statement at (1)
>     > myfile.f:112:3:
>     >
>     >    112 | end subroutine quicksort
>     >        |   1
>     > Error: Expecting END PROGRAM statement at (1)
>     > myfile.f:122:35:
>     >
>     > Have done
>     >
>     > gfortran -O3 -ffree-form -o myfile.f
>     >
>     > The command is supposed to make the object file, but I get
>     errors with END PROGRAM declaration.
>     >
>     >
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-01 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-01  8:52 Compiling file with subroutines using gfortran Hans Lonsdale
2023-01-01 11:59 ` Patrick Begou
2023-01-01 13:32   ` Jonathan Wakely
2023-01-01 14:41     ` Hans Lonsdale
2023-01-01 16:21     ` Patrick Begou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).