Re: Crazy Problem

From: Paul Van Delst (paul.vandelst_at_noaa.gov)
Date: 09/01/04


Date: Wed, 01 Sep 2004 14:22:33 -0400

joeslide wrote:
> Compiler is Compaq Visual Fortran 6.6.
> The other 6 errors were the same.
>
> This code compiles and links:
>
> !MS$NOFREEFORM

Aha.

This is "fixed form" code:

c 1 2 3 4 5 6 7
c234567890123456789012345678901234567890123456789012345678901234567890123
       program junk
       dimension an(4,4,3), bn(4,4), bo(4,4)
       data an/-4.5,9.0,-5.5,1.0,13.5,-22.5,9.0,0.0,-13.5,18.0,-4.5,0.0,
      +4.5,-4.5,1.0,0.0,0.0,1.0,0.0,3.0,0.0,1.0,0.0,2.0,0.0,1.0,1.0,1.0,
      +1.0,1.0,0.0,0.0,2.0,-3.0,0.0,1.0,-2.0,3.0,0.0,0.0,1.0,-2.0,1.0,
      +0.0,1.0,-1.0,0.0,0.0/
       print *, 'Hello World'
       end program junk

I replaced your ">" with "+" since my newsreader interprets those chars as indicating a
previous quote. Note that the continuation characters (the "+"s) are in column #6 (which
you already know about).

This is "free form" code:

       program junk
       dimension an(4,4,3), bn(4,4), bo(4,4)
       data an/-4.5,9.0,-5.5,1.0,13.5,-22.5,9.0,0.0,-13.5,18.0,-4.5,0.0,&
       4.5,-4.5,1.0,0.0,0.0,1.0,0.0,3.0,0.0,1.0,0.0,2.0,0.0,1.0,1.0,1.0,&
       1.0,1.0,0.0,0.0,2.0,-3.0,0.0,1.0,-2.0,3.0,0.0,0.0,1.0,-2.0,1.0,&
       0.0,1.0,-1.0,0.0,0.0/
       print *, 'Hello World'
       end program junk

Note that there are no continuation characters at the start of newlines, but at the end of
the previous one. And "&" is the only character you can use. And, of course, there's no
mandate about starting code in column 7, but I did in the example above so as to change
only one thing at a time.

Most, but not all, compilers will assume that a file with an .f90 or .f95 suffix is in
free format, and a file with a .f suffix is in fixed format.

My preference is to tell the compiler that the code is fixed or free form using a compiler
switch rather than a directive. But, either will get the job done.

cheers,

paulv

>
> ! junk.f90
> !
> ! FUNCTIONS:
> ! junk - Entry point of console application.
> !
> ! Example of displaying 'Hello World' at execution time.
> !
>
> !****************************************************************************
> !
> ! PROGRAM: junk
> !
> ! PURPOSE: Entry point for 'Hello World' sample console application.
> !
> !****************************************************************************
>
> program junk
>
>
> dimension an(4,4,3), bn(4,4), bo(4,4)
>
> data an/-4.5,9.0,-5.5,1.0,13.5,-22.5,9.0,0.0,-13.5,18.0,-4.5,0.0,
> >4.5,-4.5,1.0,0.0,0.0,1.0,0.0,3.0,0.0,1.0,0.0,2.0,0.0,1.0,1.0,1.0,
> >1.0,1.0,0.0,0.0,2.0,-3.0,0.0,1.0,-2.0,3.0,0.0,0.0,1.0,-2.0,1.0,
> >0.0,1.0,-1.0,0.0,0.0/
>
> print *, 'Hello World'
>
> end program junk
>
> But if I change !MS$NOFREEFORM to cDEC$ FREEFORM, then the errors
> return.
> I *really* appreciated the responses, after posting to the managed
> DirectX group, you guys are refreshing....
>
> joeslide
>
> overacliff@yahoo.com (joeslide) wrote in message news:<32686ec6.0408311323.69cb06a4@posting.google.com>...
>
>>I started out with the default hello world program and added an array
>>with initialization to see how the array contents are laid out.
>>
>>Here's the code
>>
>> program junk
>> implicit none
>> dimension an(4,4,3), bn(4,4), bo(4,4)
>>
>> data an/-4.5,9.0,-5.5,1.0,13.5,-22.5,9.0,0.0,-13.5,18.0,-4.5,0.0,
>> >4.5,-4.5,1.0,0.0,0.0,1.0,0.0,3.0,0.0,1.0,0.0,2.0,0.0,1.0,1.0,1.0,
>> >1.0,1.0,0.0,0.0,2.0,-3.0,0.0,1.0,-2.0,3.0,0.0,0.0,1.0,-2.0,1.0,
>> >0.0,1.0,-1.0,0.0,0.0/
>>
>> print *, 'Hello World'
>>
>> end program junk
>>
>>Here's the complaints:
>>
>>Error: Syntax error, found END-OF-STATEMENT when expecting one of: (
>><IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM>
>><CHARACTER_CONSTANT> <INTEGER_CONS
>>TANT> ...
>> data an/-4.5,9.0,-5.5,1.0,13.5,-22.5,9.0,0.0,-13.5,18.0,-4.5,0.0,
>>---------------------------------------------------------------------------^
>><6 more error's>
>>junk.exe - 7 error(s), 0 warning(s)
>>
>>What's going on?
>>
>>Thanks for any help.



Relevant Pages

  • Re: SOURCEFORMAT AND COPY LIBRARY
    ... >>> Compiler (either fixed form or free form reference format). ... >>> If, on the other hand, one is creating source code that will be valid ...
    (comp.lang.cobol)
  • Re: Absoft Fortran Problem
    ... I use absoft fortran compiler to compile this code which was written ... There is no advantage in trying to make part of the source code partly compatible with f90 free form, if you don't change all comments to free form. ... Most compilers will accept combinations of f77 fixed form and f90 free form comments, such as you have here, but there is no guarantee. ...
    (comp.lang.fortran)
  • Re: SOURCEFORMAT AND COPY LIBRARY
    ... > Compiler (either fixed form or free form reference format). ... > If, on the other hand, one is creating source code that will be valid ...
    (comp.lang.cobol)
  • Re: too long function
    ... then copy and paste the answer in fortran. ... compiler thinks you are using fixed form instead of free. ... to tell the compiler that you are using free form. ... you usually can't use an & for continuation in the middle of a name ...
    (comp.lang.fortran)
  • Re: SOURCEFORMAT AND COPY LIBRARY
    ... The '02 Standard also makes portable conditional ... >> Compiler (either fixed form or free form reference format). ...
    (comp.lang.cobol)