Silverfrost Forums

Welcome to our forums

Statement Structures

23 Sep 2008 3:16 #3837

IN MICROSOFT FORTRAN, THE STATEMENTS: CHARACTER CINPUT21(8), CINPUT38 AND EQUIVALENCE (CINPUT2(1),CINPUT3) WILL CREATE A VARIABLE CINPUT2, WITH DIMENSION 8, EACH ELEMENT BEING 1 CHARACTER LONG AND WILL EQUIVALENCE ARRAY ELEMENT 1 IN CINPUT2 TO THE FIRST CHARACTER IN CINPUT3, THE 2ND ARRAY ELEMENT IN CINPUT2 TO CINPUT3, 2ND CHARACTER AND SO FORTH. IN ORDER TO RE-PRODUCE THIS SEQUENCE IN SILVERFROST FORTRAN, ONE HAS TO KNOW WHAT THE STATEMENT STRUCTURE IS FOR SILVERFROST FORTRAN, THE QUESTION IS, WHERE IS THIS STATEMENT STRUCTURE TO BE FOUND? WHEN I TRY TO COMPILE AS IS, I GET AND ERROR THAT SAYS 'IN VARIABLE CINPUT2*1(8), '(' WHERE VARIABLE NAME EXPECTED' ??? PLEASE LET ME KNOW WHERE THE STATEMENT STRUCTURE DEFINITION IS. THANKS, SID KRAFT

23 Sep 2008 6:00 #3838

Sid,

Please don't post all in capitals, as it makes your post look loud and harsh on the eye. Also use [code] for source code to prevent unwanted smilies appearing.

Regards, John

23 Sep 2008 6:26 #3839

FTN95 obeys the rules of standard Fortran 95. It allows some extensions to the standard but if you stick to standard Fortran then you should be OK.

If you want to post the code fragment that causes the error report then someone will probably help you to locate the programming error.

23 Sep 2008 7:53 #3840

The format of the character statement is a little wrong. Try this:

      character*1 CINPUT2(8)
      character*8 CINPUT3
      EQUIVALENCE (CINPUT2(1),CINPUT3)
      cinput3 = 'qwertyui'
      print *,cinput2
      end

And if you wish to access a single character of CINPUT3 by using equivalence so that you can refer to a single array element in CINPUT2, why not forget about EQUIVALENCE and access the desired character as:

  CINPUT3(i:i)

Instead of

  CINPUT2(i)

EQUIVALENCE would only really make sense if you wanted to access individual characters as integer1 numbers. i.e. replace character1 with integer*1.

Regards

Ian

Please login to reply.