- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am going slightly mad trying to fix the following error message:
"A CHARACTER data type is required in this context"
The code I got looks like
CHARACTER*(*) VAR1
.
.
.
VAR1 = SCHAUM()
.
.
.
CHARACTER*(*) FUNCTION SCHAUM ()
SCHAUM = 'SCHAUMSCHLAEGER'
RETURN
END FUNCTION SCHAUM
It does not help if I replace the *(*) figures by (len=80) or so. Besides I have no idea about the meaning of CHARACTER*(*) VAR1, haven't found any documentation about it.
Anyone here knowing more about this issue?
TIA
H.
I am going slightly mad trying to fix the following error message:
"A CHARACTER data type is required in this context"
The code I got looks like
CHARACTER*(*) VAR1
.
.
.
VAR1 = SCHAUM()
.
.
.
CHARACTER*(*) FUNCTION SCHAUM ()
SCHAUM = 'SCHAUMSCHLAEGER'
RETURN
END FUNCTION SCHAUM
It does not help if I replace the *(*) figures by (len=80) or so. Besides I have no idea about the meaning of CHARACTER*(*) VAR1, haven't found any documentation about it.
Anyone here knowing more about this issue?
TIA
H.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You probably need an explicit interface to function SCHAUM(), so the compiler knows that SCHAUM returns with a character variable.
Add something like:
Interface
CHARACTER*(*) FUNCTION SCHAUM ()
SCHAUM = 'SCHAUMSCHLAEGER'
RETURN
END FUNCTION SCHAUM
SCHAUM = 'SCHAUMSCHLAEGER'
RETURN
END FUNCTION SCHAUM
End interface
to your declarations.
Walter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Walter,
adding your two interface lines unfortunately does not change a thing, still the same error message. What might be of interest is that this code is contained in a file which begins with
SUBROUTINE MyFunc(Var1, Var2, Var3)
Maybe this plays a role in this issue?
adding your two interface lines unfortunately does not change a thing, still the same error message. What might be of interest is that this code is contained in a file which begins with
SUBROUTINE MyFunc(Var1, Var2, Var3)
Maybe this plays a role in this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I have been a bit messy in my reply.
The following code for a complete program shows what I mean.
A charcacter*(*) function return value is not accepted in an interface block, so I changed it into character(len=15).
Walter
Code:
program CharString implicit none ! Variables CHARACTER(len=80) VAR1 ! Body of CharString CALL MyFunc(Var1) end program CharString SUBROUTINE MyFunc(Var1) implicit none CHARACTER*(*) VAR1 Interface CHARACTER(len=15) FUNCTION SCHAUM () END FUNCTION SCHAUM End interface VAR1 = SCHAUM() END SUBROUTINE CHARACTER(len=15) FUNCTION SCHAUM () implicit none SCHAUM = 'SCHAUMSCHLAEGER' RETURN END FUNCTION SCHAUM
Message Edited by wkramer on 03-18-2005 04:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Walter,
thx a bunch, I got it working now. :)
thx a bunch, I got it working now. :)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page