FORTRAN Generic Operator (^)


 
Thread Tools Search this Thread
Top Forums Programming FORTRAN Generic Operator (^)
# 1  
Old 10-21-2014
FORTRAN Generic Operator (^)

I am implementing the cross product of two vectors using ^, however I am getting an error.Not aware how the problem can be resolved.



Here is the code

Code:
Interface Operator (^)
  Module Procedure vector_cross_product
End Interface Operator (^)

Contains

Function vector_cross_product (u, v) Result (w)

  !!$ Input
  Type (Vector), Intent(in) :: u, v

  !!$ Output
  Type (Vector) :: w

  w% x = (u% y * v% z) - (u% z * v% y)
  w% y = (u% z * v% x) - (u% x * v% z)
  w% z = (u% x * v% y) - (u% y * v% x)

End Function vector_cross_product

This is the corresponding errer I am getting using gfortran

Code:
Interface Operator (^)
                    1
Error: Syntax error in generic specification at (1)
lib/vectors.f:110.18:

  Module Procedure vector_cross_product
                  1
Error: MODULE PROCEDURE at (1) must be in a generic module interface
lib/vectors.f:111.3:

End Interface Operator (^)
   1
Error: Expecting END MODULE statement at (1)

# 2  
Old 10-22-2014
Hi.

For your code on:
Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian 5.0.8 (lenny, workstation) 
ifort (IFORT) 11.1 20090827

The Intel Fortran compiler says:
Code:
$ ifort -c t.f90 
t.f90(1): error #5078: Unrecognized token '^' skipped
Interface Operator (^)
--------------------^
t.f90(1): error #5082: Syntax error, found ')' when expecting one of: * .NOT. + . - /) ** / // .LT. < .LE. <= .EQ. == .NE. /= .GT. > ...

Looks like it wants something from that list (presumably the standard operators) rather than "^", although I don't know if "..." is meant literally. Perhaps ".X." would work.

Good luck ... cheers, drl

---------- Post updated at 13:56 ---------- Previous update was at 12:23 ----------

Hi.
Quote:
Interfaces may also be used to define new unary or binary operators by referring to separately written functions. In such a case, the initial line is:

INTERFACE OPERATOR ( .op_abbrev. )

where .op_abbrev. is a character string (surrounded by periods) that will be used as a symbol for the new operator (by being placed before or between appropriate variables or constants). For further information, see section 16.3.
-- Math 60 -- Chapter 9

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FORTRAN Compiler

Need assistance in Fortran Compiler I need to install Fortran compiler on Linux distribution . I don't have root access to use rpm or yum to install compiler . Is there any way I can get it ? Are there any sites that has fortran compiler . Any links to download and install . (10 Replies)
Discussion started by: ajayram_arya
10 Replies

2. Shell Programming and Scripting

Generic Filewatcher

Hi, I have a requirement wherein i need to have a generic file watcher in place. On presence of a file in a particular directory,the file watcher should identify the related config file and execute the series of the shell scripts mentioned in the config file. eg.Config file a.sh b.sh... (7 Replies)
Discussion started by: dikesm
7 Replies

3. UNIX for Advanced & Expert Users

Is aclocal.m4 generic?

can we copy higher version aclocal to our software. Is there any good book for automake,aclocal.m4,configure.sub,configure.guess that explains clearly about how they are related , how to modify them etc Thanks Gopi (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

4. Programming

learning fortran

Can anyone recommend a very good Fortran online course for unix. It should also cover Fortran X11 programming if possible. I understand this learning cannot be rushed but a course that addresses useful topics sooner is best. If it isn't free, that's okay. (1 Reply)
Discussion started by: gav2251
1 Replies

5. Shell Programming and Scripting

generic way - help required

All, This is what I did: Suppose: $ line="23|12|21" $ eval $(echo "$line" | awk -F'|' '{print "V1="$1";V2="$2";V3="$3}') $ echo $V1 23 $ echo $V2 12 $ echo $V3 21 (3 Replies)
Discussion started by: uwork72
3 Replies

6. UNIX for Dummies Questions & Answers

FORTRAN compiling

Hello, I have a FORTRAN code that I want to compile using F90 compiler. However, when I enter the command: f90 ./code.f -o ./code.out It would give me prompt saying that absoft license has failed, or something. I remember, however, that I could enter some keyword that ends with 'soft' in... (1 Reply)
Discussion started by: Iamthe great
1 Replies

7. Linux

Fortran 90 compiler

Hi everybody: Could anybody help me where could I download Fortran 90 complier? Thanks in advance. :) (2 Replies)
Discussion started by: tonet
2 Replies

8. UNIX for Dummies Questions & Answers

GENERIC Kernel

How do I update, change, reconfigure or whatever it is that I have to do, in order to rid the GENERIC label. It just means that it is the basic kernel shipped with the OS right? Im using FBSD 4.5 (2 Replies)
Discussion started by: savage
2 Replies
Login or Register to Ask a Question