The scope of a file descriptor

s8ngsu3_at_yahoo.com
Date: 12/28/04


Date: 28 Dec 2004 02:56:21 -0800

Is the scope of a file descriptor limited to the subroutine/function
where the file is opened, or can it be passed as an argument to another
subroutine? I.e., is it possible to open a file in the main part of a
program and write/read the file from some subroutine? I'm looking for a
Fortran equivalent of doing the following in C++:

void some_output (fstream& fout, int x)
{
fout << x;
}

int main ()
{
fstream afile ("somefile.txt", ios::out);
some_output (afile, 5);
    afile.close();
}



Relevant Pages

  • Re: Way to autogenerate C/C++ Headers?
    ... end subroutine odessa_segment_initialize ... #ifdef FTN_ALLCAPS ... int STDCALL odessa_segment_create_ ( ...
    (comp.lang.fortran)
  • Re: iso-c-binding problem
    ... void setDoublePointerList(float *dp, int l, float v) { ... subroutine printpbind ... end interface ... pointers from the FORTRAN side ...
    (comp.lang.fortran)
  • Re: Problem in declaration
    ... The way subroutine in which this statement, INTEGER*4 JR*2, ... an array of size INT. ... It seems that I need to have a reference book on MS FORTRAN. ...
    (comp.lang.fortran)
  • Re: recursion
    ... Why are you using globals? ... argument the subroutine needs explicitly, and to keep most variables local ... int powered; ... In the example you posted, however, powered must run twice, because the ...
    (comp.lang.c)
  • Re: is there a way to do this...
    ... >> changed from int * to int. ... > skip the execution of line i=6 .agreed this introduces architecture ... internals of the subroutine to the main routine. ... It is necessary for the change routine to communicate in some manner ...
    (comp.lang.c)