Topic: Unusual Syntax Behavior

Hi Jeff,
I've encountered a syntax issue when using the extended line character symbol '&' followed by a backslash '\' and a space ' '.  I receive Warning messages regarding the backslash and newline are separated by space. In the example code below, when the '?' mark after the backslash is removed, the Warnings appear. Once the Warnings appear, then I also get the following error messages:
  'Error Symbol 'a' at (1) already has basic type of Integer'
  'Error: Symbol 'ia' at (1) has no Implicit type'

Do you have an explanation for this behavior in the Simply Fortran editor?

            INTEGER, PARAMETER :: I4 = Selected_Int_Kind(9)   
            INTEGER, PARAMETER :: I4B  = KIND(1_I4)             

            !--- Warning: backslash and newline separated by space
            INTEGER(I4B) :: A      ! After    \ ?
            INTEGER(I4B) :: B      ! Before    >  Factors
            INTEGER(I4B) :: C      ! Current  /

            !--- Warning: backslash and newline separated by space
            INTEGER(I4B) :: &   ! \ ?
            IA,    &            !  \ ?
            IB,    &            !   \  DO loop indicies.
            IC,    &            !   /
            IE,    &            !  /

            !--- Initialize parameters
            !--- Error Symbol 'a' at (1) already has basic type of Integer
            A = 1
            B = 1
            C = 1
            !--- Error: Symbol 'ia' at (1) has no Implicit type
            IA = 1
            IB = 1
            IC = 1
            IE = 1

On a different subject, what does the following option do?
Options->Appearance & Behavior->Launching-> [X] Use resilient process creation

Happy New Year 2022!
Frank

Re: Unusual Syntax Behavior

Frank,

The first error is caused by the comma trailing the declaration of IE.  Because of a continuation character, the compiler thinks you're trying to declare A with an initial value of 1.

The second error is not one I'm really seeing.  Are you entering this code as free-format Fortran (with a .f90, amongst others) or as fixed-format Fortran (with a .f extension)?

The Resilient Process Creation system basically launches a thread which subsequently attempts to launch your executable.  Simply Fortran's main thread then waits for a few seconds for the launching thread to return.  If the launching thread never returns, the process creation operation never worked. 

The reason for the feature is that many consumer-grade virus scanners will simply block a new executable (like one you just compiled) from executing at all without so much as a notice to the user.  This routine will guess that a virus scanner has interfered and let the user know. This methodology is only necessary on Windows, of course.

Jeff Armstrong
Approximatrix, LLC

Re: Unusual Syntax Behavior

Jeff,

The comma after the 'IE' was a transcription error.  The issue persists even when there is no comma after 'IE'. The code is entered in free-format with a '.F90' appended to the file name. To see if you can reproduce this nuisance syntax, I've placed some mock code below that produces the problem on my MS Surface Pro running Windows 10.  In the example code below, when the '?' marks after the backslash are removed, the Warnings appear, 'Symbol B has no Implicit type.'.  Let me know what you find.

BTW, thanks for the detailed explanation of the Resilient Process Creation.

Wishing you and your family a Happy and Healthy New Year 2022!

Frank

        SUBROUTINE SPCFFT( N, U, ISIN, WORK )
            IMPLICIT NONE

            INTEGER, PARAMETER :: I4 = Selected_Int_Kind(9)       
            INTEGER, PARAMETER :: I4B  = KIND(1_I4)               
            INTEGER, PARAMETER :: p6 = Selected_Real_Kind(6,30)   
            INTEGER, PARAMETER :: SP = KIND(1.0_p6)               
            INTEGER, PARAMETER :: p15 = Selected_Real_Kind(15,30)
            INTEGER, PARAMETER :: DP = KIND(1.0_p15)             

            INTEGER(I4B), INTENT(IN)      :: N
            INTEGER(I4B), INTENT(IN)      :: ISIN
            COMPLEX(DP), INTENT(IN OUT)   :: U(N)
            COMPLEX(DP), INTENT(OUT)      :: WORK(N)

            !--- Warning: backslash and newline separated by space?
            INTEGER(I4B) :: A      ! After    \ ???
            INTEGER(I4B) :: B      ! Before    >  Factors of N
            INTEGER(I4B) :: C      ! Current  /
            REAL(DP)  :: D

            A = 1
            B = N
            C = 1
            D = 0.0_DP

            IF (ISIN <= 0) THEN
                D = 1.0_DP
            END IF

            !--- Calculate Fourier transform
            !--- Code removed for illustration purposes!

            RETURN
        END SUBROUTINE SPCFFT

Re: Unusual Syntax Behavior

Frank,

The problem is actually occurring because of the file extension you've chosen.  With our compiler (and many others), using a Fortran extension with capitalized letters, like .F90, will cause the C preprocessor to run through the Fortran code prior to compilation.  The C preprocessor considers backslash characters to be line continuation characters when nothing follows them.  When I stored your subroutine in a file with the extension .f90, it compiled just fine.

Jeff Armstrong
Approximatrix, LLC

Re: Unusual Syntax Behavior

Jeff,

Great news, I was hoping for a straight forward answer.  From now on, I'll be more conscientious about using the lower case 'f' for '.f90' and not 'F90'.  Perhaps other users may also find this informative.

As the year comes to an end, I would like to thank you and all your effort in developing SimplyFortran. It's brought life back to FORTRAN revealing its utility for scientific computation.  From the 1950's until 2022, it's hear to stay.

Frank