Syntax error in data declaration at 1

I have been following books and PDFs on writing in FORTRAN to write an integration program. I compile the code with gfortran and get several copies of the following errors. 1)Unexpected data decla...

I have been following books and PDFs on writing in FORTRAN to write an integration program. I compile the code with gfortran and get several copies of the following errors.

1)Unexpected data declaration statement at (1)
2)Unterminated character constant beginning at (1)
3)Unclassifiable statement at (1)
4)Unexpected STATEMENT FUNCTION statement at (1)
5)Expecting END PROGRAM statement at (1)
6)Syntax error in data declaration at (1)
7)Statement function at (1) is recursive
8)Unexpected IMPLICIT NONE statement at (1)

I do not know hat they truly mean or how to fix them, google search has proven null and the other topics on this site we about other errors. for Error 5) i put in Program main and end program main like i might in C++ but still got the same result. Error 7) makes no sense, i am trying for recursion in the program. Error 8) i read implicit none was to prevent unnecessary decelerations.

Ill post the code itself but i am more interested in the compiling errors because i still need to fine tune the array data handling, but i cant do that until i get it working.

         Program main
  implicit none      
  real, dimension(:,:), allocatable :: m, oldm
  real a
  integer io, nn
  character(30) :: filename
  real, dimension(:,:), allocatable :: alt, temp, nue, oxy
  integer locationa, locationt, locationn, locationo, i
  integer nend
  real dz, z, integral
  real alti, tempi, nuei, oxyi
  integer y, j

  allocate( m(0, 0) ) ! size zero to start with?

  nn = 0
  j = 0

   write(*,*) 'Enter input file name: '

   read(*,*) filename

   open( 1, file = filename )



  do !reading in data file

   read(1, *, iostat = io) a

   if (io < 0 ) exit

   nn = nn + 1

   allocate( oldm( size(m), size(m) ) )

   oldm = m 

   deallocate( m )

   allocate( m(nn, nn) )

   m = oldm

   m(nn, nn) = a ! The nnth value of m

   deallocate( oldm )

  enddo



  ! Decompose matrix array m into column arrays [1,n]

  write(*,*) 'Enter Column Number for Altitude'
  read(*,*) locationa
  write(*,*) 'Enter Column Number for Temperature'
  read(*,*) locationt
  write(*,*) 'Enter Column Number for Nuetral Density'
  read(*,*) locationn 
  write(*,*) 'Enter Column Number for Oxygen density'
  read(*,*) locationo

  nend = size(m, locationa) !length of column #locationa

  do i = 1, nend

   alt(i, 1) = m(i, locationa)

   temp(i, 1) = log(m(i, locationt))

   nue(i, 1) = log(m(i, locationn))

   oxy(i, 1) = log(m(i, locationo))

  enddo



  ! Interpolate Column arrays, Constant X value will be array ALT with the 3 other arrays

  !real dz = size(alt)/100, z, integral = 0
  !real alti, tempi, nuei, oxyi
  !integer y, j = 0
  dz = size(alt)/100


  do z = 1, 100, dz
  y = z !with chopped rounding alt(y) will always be lowest integer for smooth transition.
  alti = alt(y, 1) + j*dz ! the addition of j*dz's allow for all values not in the array between two points of the array. 

   tempi = exp(linear_interpolation(alt, temp, size(alt), alti))

   nuei = exp(linear_interpolation(alt, nue, size(alt), alti))

   oxyi = exp(linear_interpolation(alt, oxy, size(alt), alti))
   j = j + 1



   !Integration

   integral = integral + tempi*nuei*oxyi*dz 

  enddo


  end program main


  !Functions

  real function linear_interpolation(x, y, n, x0)

   implicit none

   integer :: n, i, k

   real :: x(n), y(n), x0, y0

   k = 0


  do i = 1, n-1

   if ((x0 >= x(i)) .and. (x0 <= x(i+1))) then  

    k = i ! k is the index where: x(k) <= x <= x(k+1)
    exit ! exit loop

   end if

  enddo


  if (k > 0) then  ! compute the interpolated value for a point not in the array

   y0 = y(k) + (y(k+1)-y(k))/(x(k+1)-x(k))*(x0-x(k))

  else

   write(*,*)'Error computing the interpolation !!!'

   write(*,*) 'x0 =',x0, ' is out of range <', x(1),',',x(n),'>'

  end if

  ! return value

     linear_interpolation = y0

  end function linear_interpolation

I can provide a more detailed description of the exact errors, i was hoping that the error name would be enough since i have a few of each type.

INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Thanks. We have received your request and will respond promptly.

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!

  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It’s Free!

*Tek-Tips’s functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help with infinite series calculation of SIN

Help with infinite series calculation of SIN

(OP)

12 Oct 08 19:49

hello, i am a new fortran user in college… our teacher is a first year teacher and has assigned us 3 programs to write, none of which she explained how to do. i read the entire book up to where we are but apparently i still do not grasp the full concept yet. we are supposed to write a program that calculates the value of Sin(x) with the infinite series (-1)**(n-1)*x**(2n-1)/factorial(2n-1)… i have written a program with 2 internal functions but i can not get it to compile without errors. here is the code

CODE

program infiniteSeries
    IMPLICIT NONE
    real :: x = 0.
    integer :: n = 1
    real :: degRad = 3.1415926 / 180
    real :: sinIntrinsic = 0., mySin = 0.
    real :: sinApprox
    write(*,*)»Please enter a value in degrees»
    read(*,*)x
    x = x * degRad
    sinIntrinsic = sin(x)
    do n = 1, 10
        mySin = sinApprox(x,n)
        write(*,*)n, mySin
    end do
    write(*,*)sinIntrinsic
end

real function sinApprox(x,n)
    implicit none
    sinApprox = 0.
    real, intent(in) :: x
    integer, intent(in) :: n
    integer :: i = 1
    real :: fact
    integer :: a = 0
    a = 2n — 1
    do i = 1, n
        sinApprox = sinApprox + (-1)**(n-1) * x**(2*n-1) / fact(a)
    end do
end

real function fact(a)
    implicit none
    integer, intent(in) :: a
    fact = 1.
    integer :: i = 1
    do i = 1, a
        fact = fact * i
    end do
end

and here are my error messages:
 In file infiniteSeries.f95:42

 real, intent(in) :: x
                     1
Error: Unexpected data declaration statement at (1)
 In file infiniteSeries.f95:43

 integer, intent(in) :: n
                        1
Error: Unexpected data declaration statement at (1)
 In file infiniteSeries.f95:44

 integer :: i = 1
                1
Error: Unexpected data declaration statement at (1)
 In file infiniteSeries.f95:45

 real :: fact
            1
Error: Unexpected data declaration statement at (1)
 In file infiniteSeries.f95:46

 integer :: a = 2n — 1
                1
Error: Syntax error in data declaration at (1)
 In file infiniteSeries.f95:37

real function sinApprox(x,n)
                        1
Error: Symbol ‘x’ at (1) has no IMPLICIT type
 In file infiniteSeries.f95:37

real function sinApprox(x,n)
                          1
Error: Symbol ‘n’ at (1) has no IMPLICIT type
 In file infiniteSeries.f95:48

 do i = 1, n
    1
Error: Symbol ‘i’ at (1) has no IMPLICIT type
 In file infiniteSeries.f95:49

  sinApprox = sinApprox + (-1)**(n-1) * x**(2*n-1) / fact(a)
                                                          1
Error: Symbol ‘a’ at (1) has no IMPLICIT type
 In file infiniteSeries.f95:49

  sinApprox = sinApprox + (-1)**(n-1) * x**(2*n-1) / fact(a)
                                                        1
Error: Function ‘fact’ at (1) has no IMPLICIT type
 In file infiniteSeries.f95:61

 integer :: i = 1
                1
Error: Unexpected data declaration statement at (1)
 In file infiniteSeries.f95:63

 do i = 1, a
    1
Error: Symbol ‘i’ at (1) has no IMPLICIT type

if anyone could at least point me in the right direction as to where i am messing up, i would greatly appreciate it. thanks

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Join Tek-Tips® Today!

Join your peers on the Internet’s largest technical computer professional community.
It’s easy to join and it’s free.

Here’s Why Members Love Tek-Tips Forums:

  • Tek-Tips ForumsTalk To Other Members
  • Notification Of Responses To Questions
  • Favorite Forums One Click Access
  • Keyword Search Of All Posts, And More…

Register now while it’s still free!

Already a member? Close this window and log in.

Join Us             Close

Skip to forum content

Approximatrix Forums

For discussions of all Approximatrix products and related software

You are not logged in. Please login or register.

Active topics Unanswered topics

Pages 1

You must login or register to post a reply

1 2013-03-15 12:26:24 (edited by SteveH 2013-03-15 12:28:42)

  • SteveH
  • New member
  • Offline

Topic: Building a project using Silverfrost source code and Clearwin+

I am a new starter to SF and went thru your Getting Started and successfully built Hello World.

Sadly, I have not got very far.

I have now Saved an Executable project of all the source files for a new project. This includes those files referred to by the INCLUDE statements. Remembering what Silverfrost told me to do, I replaced the INCLUDE of their .INS files by «USE MSWIN» in the source code. Following your notes I went and identified the folder where MSWIN.MOD resided within SF’s Include/Search Directories.

On a Build gFortran came back with «Fatal Error: File ‘mswin.mod’ opened at (1) is not a GFORTRAN module file». I could not find the equivalent file in your installation.

Thanks

2 Reply by SteveH 2013-03-15 15:35:47 (edited by SteveH 2013-03-15 15:43:37)

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

I am still attempting a Build. Following my previous attempt the Include Directory ( of Modules ) is now not applicable and I accessed the source code for the module ( see beow ) and after Saving the project I got the following error :

      USE MSWIN                                                         
         1
Fatal Error: Can’t open module file ‘mswin.mod’ for reading at (1): No such file or directory

The USE MSWIN statement is at the top of my .FOR source code.

MSWIN.F95 source is as follows

module mswin
  use mswinprm
  use mswinapi
  use clrwin
end module mswin

I have source code MSWINPRM.F95, MSWINAPI.F95, CLRWIN.F95 which all happen to have a module defined by their same filename within them.

What does the error mean ? How do I overcome the problem ? Thanks

3 Reply by jeff 2013-03-15 15:36:28

  • jeff
  • Administrator
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Steve,

Is MSWIN a module that is provided by ClearWin+?  If so, they’ll need to rebuild it to use with GNU Fortran.  Module files are not compatible between Fortran compilers, only module source code.

Jeff Armstrong
Approximatrix, LLC

4 Reply by SteveH 2013-03-15 17:26:47

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Our entries overlapped in the forum.

I have now included the .f95 source in the project pane. In case there is an order problem with modules needing to be compiled — to create their .mod — before they are referenced by the INC file I have included them in a folder at the top of the project pane.

Sadly, this makes no difference : the same error message appears.

I notice there is no way to delete/purge projects. I fiddled about with Windows explorer in my «project folder» and then was not able to re-open a project in SF. The error on Build — above — still stands as I created a new project from scratch.

5 Reply by jeff 2013-03-18 00:32:24

  • jeff
  • Administrator
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Steve,

I’ve had a cursory look at Silverfrost’s MSWIN module information online.  It appears this module is a Silverfrost-provided port of the Microsoft Win32 API to Fortran.  We don’t currently have an equivalent available for Simply Fortran.  However, if Silverfrost includes the source for said module somewhere in their distribution, it may compile fine with Simply Fortran.

Jeff Armstrong
Approximatrix, LLC

6 Reply by SteveH 2013-03-18 09:38:35

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

I am afraid transferring from Silverfrost is not straight forward. If there is to be a ‘migration’ to gFortran in order to create 64-bit code I feel there could be an easier transition — and I am still on the first rung of the ladder.

As I said earlier I have brought across the f95 from the Silverfrost installation ( admittedly for the 64 -bit ) which contains the following lines of code for one of the functions the compiler outputs messages :

function close_get_next$(h) bind(C,Name=’__close_get_next’)
use ISO_C_BINDING
integer(C_INT)::close_get_next$
integer(C_LONG_LONG),value::h
end function close_get_next$
end interface

Running Build with additional compiler options creates loads of messages, the top of which looks like :

    «C:Program Files (x86)Simply Fortranmingw-w64bingfortran.exe» -c -o «buildmswin.o» -g -m32  -fdollar-ok -fno-range-check -fno-underscoring -Jmodules «….Program FilesSilverfrost — amended for gFortranFTN95source64mswin.f95»
    «C:Program Files (x86)Simply Fortranmingw-w64bingfortran.exe» -o «fortran-library.dll» -shared -m32 «buildclrwin.o» «buildmswin.o» «buildmswinapi.o» «buildmswinprm.o» -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/ -mrtd -static
Warning: resolving _LoadLibraryA by linking to _LoadLibraryA@4
Use —enable-stdcall-fixup to disable these warnings
Use —disable-stdcall-fixup to disable these fixups
buildclrwin.o: In function `_clrwin_MOD_get_files$’:
C:SimplyFortranModules/../../Program Files/Silverfrost — amended for gFortran/FTN95/source64/clrwin.f95:3682: undefined reference to `__close_get_next’
C:SimplyFortranModules/../../Program Files/Silverfrost — amended for gFortran/FTN95/source64/clrwin.f95:3688: undefined reference to `__close_get_next’
C:SimplyFortranModules/../../Program Files/Silverfrost — amended for gFortran/FTN95/source64/clrwin.f95:3689: undefined reference to `__get_errno’

The code that these message refer :

 
  subroutine get_files$(wildcard,files,maxfiles,nfiles,ic)
  integer,parameter::short=selected_int_kind(4)
  integer(kind=short)::maxfiles,nfiles,ic,i
  character*(*) wildcard,files(maxfiles)
  character*256 wildcard1,filename
  integer(kind=CW_HANDLE)::thandle,handle
  ic=0
  i=index(wildcard,»)
  if(i == 0)then
    wildcard1=wildcard
  else
    i=len_trim(wildcard)
    do while(wildcard(i:i) /= »)
      i=i-1
    enddo
    wildcard1=wildcard(i+1:)
  endif
  nfiles = 0
  filename = ‘ ‘
  handle = get_first_file_name$(wildcard1, filename)
  thandle = handle
  do while(thandle > 0)
    if(nfiles < maxfiles) then
      nfiles = nfiles + 1
      files(nfiles) = filename
    else
      irtn=close_get_next$(handle) ! line 3682
      ic = 34 !ERANGE
      return
    endif
    thandle = get_next_file_name$(filename, handle)
  enddo
  if(handle > 0) irtn=close_get_next$(handle)
  if(thandle < 0) ic = get_errno$()
  end subroutine get_files$

Hoping you can put me in the correct direction, thanks.

7 Reply by jeff 2013-03-19 13:28:10

  • jeff
  • Administrator
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Steve,

The problem is that the functions «close_get_next» and «get_errno» are undefined.  These functions are neither part of the Fortran standard not the Microsoft Windows API.  I’m not sure where these functions would be found.  Are they extensions of Silverfrost’s compiler?

Jeff Armstrong
Approximatrix, LLC

8 Reply by SteveH 2013-03-19 15:13:34

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

I am not getting very far am I ?

I am now going to start with a single .f95 which will create a .MOD and build a .dll

The top few lines of this enormous file are as follows :

module clrwin
  use ISO_C_BINDING
  integer,parameter::CW_HANDLE=C_LONG_LONG
  type edit_info
    sequence
    integer(C_INT)      ::h_position         !Cursor horizontal character position
    integer(C_INT)      ::v_position         !Cursor vertical character position
    integer(C_INT)      ::last_line          !Total no of lines in the buffer
    integer(CW_HANDLE)  ::buffer             !Buffer
    integer(C_INT)      ::buffer_size        !Size of buffer contents (excluding nul terminator)
    integer(C_INT)      ::max_buffer_size    !Size of memory block
    integer(CW_HANDLE)  ::current_position   !Buffer position corresponding to h_position/v_position
    integer(CW_HANDLE)  ::selection          !Points to selected text if any
    integer(C_INT)      ::n_selected         !No of selected characters
    integer(C_INT)      ::vk_key             !Set to VK… if this handles a key press
    integer(C_INT)      ::vk_shift           !Shift state corresponding to key
    integer(C_INT)      ::active             !Set when call-back invoked, reset afterwards
    integer(C_INT)      ::modified           !Set to 1 each time the buffer is modified
    integer(C_INT)      ::closing            !Set when buffer is about to be closed
    integer(C_INT)      ::n_chars_to_colour  !Set if this is a call to supply text colours
    integer(CW_HANDLE)  ::text_to_colour     !Pointer into buffer for region to colour 
    integer(CW_HANDLE)  ::text_colours       !Forground colours
    integer(CW_HANDLE)  ::background_colours !Background colours
    integer(C_INT)      ::modification_count
    integer(C_INT)      ::modification_flag  !Reserved
    integer(C_SHORT)    ::reserved           !For future enhancements   
  end type

  integer,parameter::Y_PERMANENTLY  = 0
  integer,parameter::Y_TEMPORARILY  = 1
  integer,parameter::Y_NEVER        = 2
  integer,parameter::CURSOR_ARROW   = 32512
  integer,parameter::CURSOR_IBEAM   = 32513
  integer,parameter::CURSOR_WAIT    = 32514
  integer,parameter::CURSOR_CROSS   = 32515
  integer,parameter::CURSOR_UPARROW = 32516
  integer,parameter::CURSOR_SIZE    = 32640
  integer,parameter::CURSOR_ICON    = 32641
  integer,parameter::CURSOR_SIZENWSE= 32642
  integer,parameter::CURSOR_SIZENESW= 32643
  integer,parameter::CURSOR_SIZEWE  = 32644
  integer,parameter::CURSOR_SIZENS  = 32645

    integer,external::winio@
  external window_update@

!——————————————-
abstract interface
function clrwin_cb@() bind(C)
use,intrinsic::ISO_C_BINDING
integer(C_INT)::clrwin_cb@
end function clrwin_cb@
end interface

!!General functions….
!——————————————-
interface
function windows_instance@() bind(C,Name=’__windows_instance’)
use ISO_C_BINDING
integer(C_LONG_LONG)::windows_instance@
end function windows_instance@
end interface
!——————————————-

When attempting to compile, SF generates the following :

Open Watcom Make Version 1.9 (Built on Feb  4 2013)
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
    «C:Program Files (x86)Simply Fortranmingw-w64bingfortran.exe» -c -o «buildclrwin.o» -g -m32  -fdollar-ok -fno-range-check -fno-underscoring -Jmodules «….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95»
….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95:44.25:

  integer,external::winio@
                         1
Error: Syntax error in data declaration at (1)
….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95:45.24:

  external window_update@
                        1
Error: Unexpected character in variable list at (1)
….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95:49.18:

function clrwin_cb@() bind(C)
                  1
Error: Expected formal argument list in function definition at (1)
….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95:50.29:

use,intrinsic::ISO_C_BINDING
                             1
Error: Unexpected USE statement in INTERFACE block at (1)
….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95:51.26:

integer(C_INT)::clrwin_cb@
                          1
Error: Syntax error in data declaration at (1)
….Program FilesSilverfrost — amended for gFortranFTN95source64clrwin.f95:52.4:

end function clrwin_cb@
    1
Error: Expecting END INTERFACE statement at (1)

I cannot find a Users Guide of gnu gFortran in the SF Help. So I wonder if you could explain the compiler errors.

Thanks

9 Reply by jeff 2013-03-19 15:45:59

  • jeff
  • Administrator
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Steve,

The «@» symbol is not allowed as part of an identifier in Fortran, hence the multitude of errors related.  If I remove all occurrences of «@» and add «end module clrwin» at the end of your source listing, I can successfully compile this snippet.

My guess would be that the «@» symbol is some sort of Silverfrost extension that is instructing the compiler to use the stdcall format for calling functions perhaps, but it should be unnecessary with GNU Fortran.

The GNU Fortran manual can be opened from «Contents…» in the Help menu.  The entire manual is under «Compiler Reference.»  However, the manual contains little to no information concerning specific errors.

Jeff Armstrong
Approximatrix, LLC

10 Reply by SteveH 2013-03-19 16:19:07

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Thanks, Jeff.

Silverfrost must have changed their @ calls for $ in their 64 bit version of Clearwin+ for this very reason.

I’ll give it a go but I’m sure I’ll be back again to continue the thread !

11 Reply by SteveH 2013-03-20 11:39:24 (edited by SteveH 2013-03-20 16:32:06)

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

I have included the clearwin64.dll as part of the project and the clearwin routine Clearwin_String$ is not being recognised as a function :

  100 CREASON = CLEARWIN_STRING$(‘CALL_BACK_REASON’)                   
                1
Error: Can’t convert REAL(8) to CHARACTER(1) at (1)

Do I have to state all the clearwin functions as External ( with their appropriate data declaration ) within the calling routine ?

(edited 16:22) :-

I have indeed defined these dll functions as EXTERNAL and they happen to get thru the compilation ( ? ).

I have now got a similar problem with api calls :

      IF (IHFIND.NE.INVALID_HANDLE_VALUE) LOGRET = FINDCLOSE(IHFIND)   
                                                                                   1
Error: Can’t convert REAL(8) to LOGICAL(4) at (1)

A previous compilation error on an api meant I needed to define the function in my .f95 which was used to create a .dll. I have FindClose defined as an EXTERNAL LOGICAL in the caling routine as well as this .dll definition :-

module name
.
.
interface
function FindClose(hfile) bind(C,Name=’FindClose’)
  use ISO_C_BINDING
  logical(C_BOOL)::FindClose
  integer(C_INT)::hfile
end function FindClose
end interface
.
.
endmodule name

What have I done wrong, please ? [ I may have the parameter declaration incorrect but this should not interfere with the compilation ? ]

Thank

12 Reply by jeff 2013-03-21 10:22:26

  • jeff
  • Administrator
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Steve,

It doesn’t seem to be picking up the FindClose interface definition from the module for some reason.  You have «use <module name>» in the particular program/function/subroutine from which it’s called? 

It could also be that the definition is wrong.  The compiler might have the problem you’re describing if the interface of FindClose does not match the usage of FindClose.  Additionally, I wouldn’t include a definition of FindClose (as EXTERNAL LOGICAL) in the calling function as «use»-ing the module should be sufficient to pull it into the calling routine.

Jeff Armstrong
Approximatrix, LLC

13 Reply by SteveH 2013-03-22 16:56:10

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Thanks, Jeff

I’ve been in touch with Silverfrost and apparently the only route for us is to go straight for the 64 bit solution. With this in mind I then attempted to use the S supplied modules in 64 bit which had been compiled in gFortran. Once the directory was linked in with the SF project  error messages immediately appeared stating the version of the MODs was ‘8’ and when they were expected to be ‘9’.

How much of a problem is this ? Does this mean S have got to keep re-compiling their code to create MODs for the latest gFortran compiler ? I attempted to build a 64 bit .dll from the module source code and got the ‘undefined references’ messages I mentioned above on 2013-03-18 10:38:35.

14 Reply by JohnWasilewski 2013-03-22 19:24:50

  • JohnWasilewski
  • Member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

I’m curious.  Do you mind saying why you are using Silverfrost and SF together?

I ask because I understand that, as well as being a compiler/linker/loader, S also comes with its own IDE, which means it ought already to do most, if not all of the same as SF does.

I was tempted to try Silverfrost — the free ‘personal’ edition, because I wanted access to a Fortran interface to Windows, so that I could create a GUI for my console-based projects.  I forget the full reasons why I abandoned that idea.  I recall that one reason for not using S was that, although I was content not to use S for commercial purposes, and always to acknowledge the use of S in my development and coding, I did not like having to accept a SIlverfrost banner on all my output.  I think there may have been other reasons.  Does the personal version exclude things I needed, like the Fortran Windows interface bits?

Are you using Silverfrost so that you can use the Windows GUI facilities or is your Fortran project console-based, using the DOS command screen?  I ask because, if all the hard work you’ve put in to develop the software has gong into developing and programming mathematical or engineering analysis algorithms, rather than poncing about with Windows graphics, then you might like to consider dropping S altogether and just using the full install of SF.  Many people here will vouch for the fact that GFortran is a very mature product, and it truly hums under SF!

Alternatively, if you need a Widows GUI as well, you can still provide it using SF, by installing the DISLIN libraries.  DISLIN is a magnificent piece of work by Max Planck Institute, which is free for non-commercial use.

I’d be very interested in your comments, Steve,

John

15 Reply by jeff 2013-03-23 15:23:33

  • jeff
  • Administrator
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Steve,

GNU Fortran regularly changes their module standard as features are added, hence the version updates.  In fact, as a warning to everyone, GNU Fortran 4.8.0 will again increment the module version, meaning everything will need to be recompiled for the next release.

Generally speaking, yes, Silverfrost would have to continuously update their modules if they were providing them pre-compiled.  The usual fix is to ship a Fortran source file rather than a module containing the necessary interface blocks such that the end user can recompile the modules themselves without relying on pre-compiled ones.  DISLIN, thankfully, does this with their closed-source solution, for example.

The process can be a pain, but the easy solution, a source file defining the interface, is always a sensible alternative.

Jeff Armstrong
Approximatrix, LLC

16 Reply by JohnWasilewski 2013-03-23 16:08:25

  • JohnWasilewski
  • Member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

With modules (eg DISLIN) and, I suppose Silverfrost, if I used it, I’d just add the module source file to the SF project files list and let SF look after everything.

J.

17 Reply by SteveH 2013-03-25 08:48:24

  • SteveH
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

Thanks, Jeff, I shall investigate further with Silverfrost. I attempted to take their source but had a compilation problem : I may be back !

John : we have used Fortran since the mid-80s and have retained using the same DOS based editing/linking BAT based tools and just not concerned ourselves with an IDE. Having investigated SFs environment I am very impressed.

But Windows GUI was our main reason for introducing Silverfrost’s Clearwin+ product which allowed us to get started into the Windows world. And we also have a graphics capability. As you can tell, there are, however, a few hurdles to overcome moving between compilers. We are a commercial product and so have always had a licence and so the S logo is not evident.

Thanks for your interest, John, maybe we should consider looking at DISLIN too.

18 Reply by xbones 2022-08-08 05:56:26 (edited by xbones 2022-08-18 08:40:18)

  • xbones
  • New member
  • Offline

Re: Building a project using Silverfrost source code and Clearwin+

I’m new to Simply Fortran but have seen that you can mix Fortran and C/C++ in projects.

Would you be able to seperate the computation and GUI parts of your program?

It’s easy to use ClearWin+ with Simply Fortran’s C/C++ compiler. You just have to configure the paths for libs and includes and add the ClearWin lib. I tried their Editor.cpp sample file and it compiles and runs.

AppGraphics is much easier though.

Posts: 18

Pages 1

You must login or register to post a reply

Я следил за книгами и PDF-файлами по написанию на FORTRAN, чтобы написать программу интеграции. Я компилирую код с помощью gfortran и получаю несколько копий следующих ошибок.

1)Unexpected data declaration statement at (1)
2)Unterminated character constant beginning at (1)
3)Unclassifiable statement at (1)
4)Unexpected STATEMENT FUNCTION statement at (1)
5)Expecting END PROGRAM statement at (1)
6)Syntax error in data declaration at (1)
7)Statement function at (1) is recursive
8)Unexpected IMPLICIT NONE statement at (1)

Я не знаю, что они на самом деле означают и как их исправить, поиск в Google оказался нулевым, а другие темы на этом сайте посвящены другим ошибкам. для ошибки 5) я вставил основную программу и конечную программу, как и в С++, но все равно получил тот же результат. Ошибка 7) не имеет смысла, я пытаюсь выполнить рекурсию в программе. Ошибка 8) я читал, что имплицитный none должен был предотвращать ненужные замедления.

Я опубликую сам код, но меня больше интересуют ошибки компиляции, потому что мне все еще нужно точно настроить обработку данных массива, но я не могу этого сделать, пока не заработаю.

         Program main
  implicit none      
  real, dimension(:,:), allocatable :: m, oldm
  real a
  integer io, nn
  character(30) :: filename
  real, dimension(:,:), allocatable :: alt, temp, nue, oxy
  integer locationa, locationt, locationn, locationo, i
  integer nend
  real dz, z, integral
  real alti, tempi, nuei, oxyi
  integer y, j

  allocate( m(0, 0) ) ! size zero to start with?

  nn = 0
  j = 0

   write(*,*) 'Enter input file name: '

   read(*,*) filename

   open( 1, file = filename )



  do !reading in data file

   read(1, *, iostat = io) a

   if (io < 0 ) exit

   nn = nn + 1

   allocate( oldm( size(m), size(m) ) )

   oldm = m 

   deallocate( m )

   allocate( m(nn, nn) )

   m = oldm

   m(nn, nn) = a ! The nnth value of m

   deallocate( oldm )

  enddo



  ! Decompose matrix array m into column arrays [1,n]

  write(*,*) 'Enter Column Number for Altitude'
  read(*,*) locationa
  write(*,*) 'Enter Column Number for Temperature'
  read(*,*) locationt
  write(*,*) 'Enter Column Number for Nuetral Density'
  read(*,*) locationn 
  write(*,*) 'Enter Column Number for Oxygen density'
  read(*,*) locationo

  nend = size(m, locationa) !length of column #locationa

  do i = 1, nend

   alt(i, 1) = m(i, locationa)

   temp(i, 1) = log(m(i, locationt))

   nue(i, 1) = log(m(i, locationn))

   oxy(i, 1) = log(m(i, locationo))

  enddo



  ! Interpolate Column arrays, Constant X value will be array ALT with the 3 other arrays

  !real dz = size(alt)/100, z, integral = 0
  !real alti, tempi, nuei, oxyi
  !integer y, j = 0
  dz = size(alt)/100


  do z = 1, 100, dz
  y = z !with chopped rounding alt(y) will always be lowest integer for smooth transition.
  alti = alt(y, 1) + j*dz ! the addition of j*dz's allow for all values not in the array between two points of the array. 

   tempi = exp(linear_interpolation(alt, temp, size(alt), alti))

   nuei = exp(linear_interpolation(alt, nue, size(alt), alti))

   oxyi = exp(linear_interpolation(alt, oxy, size(alt), alti))
   j = j + 1



   !Integration

   integral = integral + tempi*nuei*oxyi*dz 

  enddo


  end program main


  !Functions

  real function linear_interpolation(x, y, n, x0)

   implicit none

   integer :: n, i, k

   real :: x(n), y(n), x0, y0

   k = 0


  do i = 1, n-1

   if ((x0 >= x(i)) .and. (x0 <= x(i+1))) then  

    k = i ! k is the index where: x(k) <= x <= x(k+1)
    exit ! exit loop

   end if

  enddo


  if (k > 0) then  ! compute the interpolated value for a point not in the array

   y0 = y(k) + (y(k+1)-y(k))/(x(k+1)-x(k))*(x0-x(k))

  else

   write(*,*)'Error computing the interpolation !!!'

   write(*,*) 'x0 =',x0, ' is out of range <', x(1),',',x(n),'>'

  end if

  ! return value

     linear_interpolation = y0

  end function linear_interpolation

Я могу предоставить более подробное описание точных ошибок, я надеялся, что названия ошибки будет достаточно, так как у меня есть несколько ошибок каждого типа.

Понравилась статья? Поделить с друзьями:
  • Syntax error gothic 3
  • Syntax error expected name found
  • Syntax error expected gthtdjl
  • Syntax error expected but identifier readln found
  • Syntax error expected but found перевод