Silverfrost Forums

Welcome to our forums

Not compiling with /UNDEF

1 Jul 2019 8:10 #23879

This is a bit strange, but with /undef it fails. The code is:

!ftn95$free
MODULE CPP_SHARED

  TYPE CPP_STRUCT_TYPE
    INTEGER, POINTER               :: CPP_INTEGER => NULL()
    REAL, POINTER                  :: CPP_REAL    => NULL()       
  END TYPE

  TYPE(CPP_STRUCT_TYPE), DIMENSION(50,50)   :: CPP_STRUCTURE

 CONTAINS

SUBROUTINE INITIALISE_CPP_STRUCTURES()
    INTEGER IWIN, IFLD
    DO IWIN = 1, 50, 1
        DO IFLD = 1, 50, 1
            CPP_STRUCTURE(IWIN, IFLD)%CPP_INTEGER => NULL()
            CPP_STRUCTURE(IWIN, IFLD)%CPP_REAL    => NULL()
        END DO
    END DO        
END SUBROUTINE

end module

The error is:

************** Compiling testnull
0017) CPP_STRUCTURE(IWIN, IFLD)%CPP_INTEGER => NULL()
*** Error 1188: This pointer assignment would assign a pointer to the wrong kind of data
0018) CPP_STRUCTURE(IWIN, IFLD)%CPP_REAL    => NULL()
*** Error 1188: This pointer assignment would assign a pointer to the wrong kind of data
0017) CPP_STRUCTURE(IWIN, IFLD)%CPP_INTEGER => NULL()
*** Error 250: You cannot assign an expression of type void to a variable of type INTEGER(KIND=3)
*** Error 891: Different types in pointer assignment - the left hand side is INTEGER(KIND=3), yet the right is void
0018) CPP_STRUCTURE(IWIN, IFLD)%CPP_REAL    => NULL()
*** Error 250: You cannot assign an expression of type void to a variable of type REAL(KIND=1)
*** Error 891: Different types in pointer assignment - the left hand side is REAL(KIND=1), yet the right is void
        6 ERRORS  [<INITIALISE_CPP_STRUCTURES> FTN95 v8.51.1]
*** Compilation failed
2 Jul 2019 6:41 #23880

First of all I only get error 1188 and I am puzzled by this.

FTN95 does not allow ⇒NULL() in this context but you can use NULLIFY....

NULLIFY(CPP_STRUCTURE(IWIN, IFLD)%CPP_INTEGER)

Having said this, the initialising on line 5 has already done this for you at least in the first instance.

At the moment I don't know what the Fortran Standard says about this.

p.s. I need to look further into this. It compiles OK without /CHECK.

2 Jul 2019 8:56 #23881

This is what I use to compile

ftn95 /windows /undef /f2k /sparam 1 /cfpp

Without the /undef it compiles fine.

2 Jul 2019 11:05 #23884

This will now be accepted by FTN95 in the next release. It currently works without /CHECK and will in future also work with /CHECK (and any options such as /UNDEF that imply /CHECK).

Please login to reply.