- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please disregard my previous posts in this regard. Attached herewith is a modified draft program (including the input file) where I have tried to create a subroutine called "fetchvalue"
I am having trouble with the driver program, when I am trying to call this subroutine. I am getting an error while compiling saying that the "fetchvalue" hasn't been declared. Any suggestions of pointers in this regard will be greatly helpful.
Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have:
CALL fetchvalue (1967,2,yr,param) val = fetchvalue (1967,2,yr,param)
The first line requires that fetchvalue be a subroutine (which it is). The second line requires that it be a function (or an array if declared as such.) So at first glance, the second line should be removed.
But when I look at fetchvalue, I see that it assigns to local variable "value" and then does nothing with it. Evidently you intended fetchvalue to be a function. If you change:
SUBROUTINE fetchvalue (yrin,ivalue,yr,param)
to
function fetchvalue (yrin,ivalue,yr,param) result(value)
and then remove the CALL line, it should work a bit better, though I have not tested the code. There may be other errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thank you very much for pointing out these two mistakes. I deleted the line after the CALL statement in the driver program and implemented your second suggestion by declaring the variable "value" in the subroutine as "INTENT (out)" variable. I am able to compile it fine.
But now when I do the final check of the program by trying to write out the value in the driver program, I am unable to get the correct result.
Can you please suggest me in this regard, or if you could suggest me ways to find out the error, I could work on that too?
Attached herewith is the modified program and input file.
As always thank you very much for all your valuable suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Please disregard my previous post, I think I was able to catch the error (it was on line39, that the variable for the array given was the variable for the year rather than the loop variable). Attached herewith again is the correct program and the input table.
Any expert suggestions to improve or enhance the program would also be greatly helpful.
As always thank you very much for everything.

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