For Programmers: Free Programming Magazines  


Home > Archive > Fortran > May 2004 > helppppp....









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author helppppp....
Jeevan

2004-05-04, 3:06 pm

Dear all,

I want to get the header name from a data file and include it in the
function in the fortran.
For eg.

program main
character*80 getheader
open (1, file = 'input.doc', access= 'sequential',
& status = 'old')
read(1,'(A)')getheader
close(1)

call function(getheader)

end program main

subroutine function(getheader)

character*80 header

# include "getheader"
...............
.............

end


Now the problem is that it is not accepting the getheader
To be noted is that getheader conatins the path of the header
file...say ../inc/read.h

The error that i get is getheader is not a file or directory..

PLZZ can anyone throw light on this!!!!
Kevin G. Rhoads

2004-05-04, 3:06 pm

The line:
# include "getheader"
is a C preprocessor thing which is NOT part of Fortran.

In many cases you can do preprocessing on Fortran, but if you
wish to write this in Fortran, there are ways to do the "include"
which are compatible with the Fortran standard. That is
generally saner than unnecessarily grafting C-stuff onto
Fortran code.

More details as to platform, compiler &c would be useful.
junks

2004-05-04, 3:06 pm


A #include statement is expanded at compile time. It looks
like you are trying to do it at runtime, it cant be done
that way. At runtime you want to use a if-then statement.

All conditional compilation directives are expanded before
the compiler see them through the pre-processor( cpp or fpp).


Jeevan wrote:
> Dear all,
>
> I want to get the header name from a data file and include it in the
> function in the fortran.
> For eg.
>
> program main
> character*80 getheader
> open (1, file = 'input.doc', access= 'sequential',
> & status = 'old')
> read(1,'(A)')getheader
> close(1)
>
> call function(getheader)
>
> end program main
>
> subroutine function(getheader)
>
> character*80 header
>
> # include "getheader"
> ..............
> ............
>
> end
>
>
> Now the problem is that it is not accepting the getheader
> To be noted is that getheader conatins the path of the header
> file...say ../inc/read.h
>
> The error that i get is getheader is not a file or directory..
>
> PLZZ can anyone throw light on this!!!!


Jugoslav Dujic

2004-05-05, 4:34 am

Jeevan wrote:
| Dear all,
|
| I want to get the header name from a data file and include it in the
| function in the fortran.
| For eg.
|
| program main
| character*80 getheader
| open (1, file = 'input.doc', access= 'sequential',
| & status = 'old')
| read(1,'(A)')getheader
| close(1)
|
| call function(getheader)
| end program main
|
| subroutine function(getheader)
| character*80 header

| # include "getheader"
| end

| Now the problem is that it is not accepting the getheader
| To be noted is that getheader conatins the path of the header
| file...say ../inc/read.h

No can do. Whatever comes behind include must be a character
CONSTANT, i.e. path to a file known at compile-time -- you
cannot edit ../inc/read.h and expect it to be re-evaluated.

If you're trying to evaluate an expression set by user in run-time,
you need something far more complex. You can find a Fortran
expression evaluator here:

http://smidgley.customer.netspace.net.au/fortran/

Hope this helps,

--
Jugoslav
___________
www.geocities.com/jdujic

Please reply to the newsgroup.
You can find my real e-mail on my home page above.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com