Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

User defined operator applied to array element component in output list of write statement in the action stmt of an if stmt

$
0
0

How's that for a descriptive title?

I like user defined operators, perhaps a bit too much at times.

MODULE M
  IMPLICIT NONE
  PRIVATE
  TYPE, PUBLIC :: Thing
    ! Rewind to F95 just for old times sake.
    CHARACTER(10) :: name
  END TYPE Thing
  INTERFACE OPERATOR(.NameOf.)
    MODULE PROCEDURE name_of
  END INTERFACE OPERATOR(.NameOf.)
CONTAINS
  FUNCTION name_of(object)
    TYPE(Thing), INTENT(IN) :: object
    CHARACTER(10) :: name_of
    !****
    name_of = object%name
  END FUNCTION name_of
END MODULE M

PROGRAM TroublesomeDots
  USE m
  IMPLICIT NONE

  TYPE Container
    TYPE(Thing) :: item
  END TYPE Container

  TYPE(Container) :: array(3)

  array(1)%item%name = 'Thomas'
  array(2)%item%name = 'Percy'
  array(3)%item%name = 'James'

  IF (.TRUE.) WRITE (*,*) .NameOf. array(1)%item
END PROGRAM TroublesomeDots

 

>ifort /check:all /warn:all /standard-semantics /stand:f95 "2014-09-24 operator.f90"
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.0.108 Build 20140726
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

2014-09-24 operator.f90(34): error #5082: Syntax error, found '.' when expecting one of: ( , <END-OF-STATEMENT> ; <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> ...
  IF (.TRUE.) WRITE (*,*) .NameOf. array(1)%item
--------------------------^
2014-09-24 operator.f90(34): error #5082: Syntax error, found '%' when expecting one of: * ) :: , <END-OF-STATEMENT> ; . (/ + - : ] /) . ' ** / // > .LT. ...
  IF (.TRUE.) WRITE (*,*) .NameOf. array(1)%item
-------------------------------------------^
compilation aborted for 2014-09-24 operator.f90 (code 1)

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>