public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gfortran -frecord-marker and linking with g++
@ 2008-12-08  6:17 blowingupstars
  0 siblings, 0 replies; 3+ messages in thread
From: blowingupstars @ 2008-12-08  6:17 UTC (permalink / raw)
  To: gcc-help

Hi,

I work with a code that uses both c++ and fortran, hence I compile
with g++ (4.3.2) and gfortran (4.3.2) and link
with g++ (4.3.2). For some old unformatted fortran files, I need to
use -frecord-marker=8 with gfortran. This
works beautifully when compiling and linking (a standalone code) with
gfortran. However, when wrapping a
fortran routine in c++ and linking with g++,  -frecord-marker=8 is
disregarded and the executable assumes the
standard record marker position.

Example code to reproduce the problem:

---- file blah.cc:
extern "C" {
  void readtest_();
}

int main(){
   readtest_() ;
}

--- file readtest.F90:

subroutine readtest

  implicit none
  integer ns,ni,nsi

  open(unit=401,file="tst.dat",form='unformatted')
  read(401) ns,ni,nsi
  write(6,*) ns,ni,nsi
  close(401)

end subroutine readtest

--------------------
File tst.dat is a standard old-fashioned unformatted binary fortran
file containing three integers.

Compilation and linking:

g++ -O0 -g -c blah.cc
gfortran -O0 -g -frecord-marker=8 -c readtest.F90
g++ -O0 -g -frecord-marker=8 -o blah blah.o readtest.o -lgfortran

-------------------------

Is this a bug, a feature, or am I doing something wrong here?

Thanks.

 - Christian Ott

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gfortran -frecord-marker and linking with g++
  2009-01-10 13:21 Christian Ott
@ 2009-01-13 15:26 ` Ian Lance Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2009-01-13 15:26 UTC (permalink / raw)
  To: Christian Ott; +Cc: gcc-help

"Christian Ott" <blowingupstars@gmail.com> writes:

> more than a months ago I ran in to the problem described
> in the following. Back then, I did not get any responses on gcc-help.
> I am not sure if this was because of flaws in my description of the
> problem or because gcc-help is not the right place to ask the particular
> questions I was asking.

gcc-help is a good place to ask, but I suspect that the problem is
simply that nobody knows.  We're mostly C/C++ people here.

You can also ask questions at fortran@gcc.gnu.org, and that may be a
better place for Fortran specific issues.  See
http://gcc.gnu.org/wiki/GFortran .


> I work with a code that uses both c++ and fortran, hence I compile
> with g++ (4.3.2) and gfortran (4.3.2) and link with g++ (4.3.2). For some
> old unformatted fortran files, I need to use -frecord-marker=8 with gfortran.
> This  works beautifully when compiling and linking (a standalone code) with
> gfortran. However, when wrapping a fortran routine in c++ and linking with
> g++,  -frecord-marker=8 is disregarded and the executable assumes the
> standard record marker position.

I took a quick look at the compiler source code, and it appears that
-frecord-marker is implemented by automatically inserting a function
call into the main program.  That means that it will only work for you
if you compile the main function in Fortran, not C++.  I have no idea
whether this is a bug, a misfeature, or working as intended.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* gfortran -frecord-marker and linking with g++
@ 2009-01-10 13:21 Christian Ott
  2009-01-13 15:26 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Ott @ 2009-01-10 13:21 UTC (permalink / raw)
  To: gcc-help

Hi,

more than a months ago I ran in to the problem described
in the following. Back then, I did not get any responses on gcc-help.
I am not sure if this was because of flaws in my description of the
problem or because gcc-help is not the right place to ask the particular
questions I was asking.

Okay, so here is my problem again, please let me know what you think.

I work with a code that uses both c++ and fortran, hence I compile
with g++ (4.3.2) and gfortran (4.3.2) and link with g++ (4.3.2). For some
old unformatted fortran files, I need to use -frecord-marker=8 with gfortran.
This  works beautifully when compiling and linking (a standalone code) with
gfortran. However, when wrapping a fortran routine in c++ and linking with
g++,  -frecord-marker=8 is disregarded and the executable assumes the
standard record marker position.

Example code to reproduce the problem:

---- file blah.cc:
extern "C" {
 void readtest_();
}

int main(){
  readtest_() ;
}

--- file readtest.F90:

subroutine readtest

 implicit none
 integer ns,ni,nsi

 open(unit=401,file="tst.dat",form='unformatted')
 read(401) ns,ni,nsi
 write(6,*) ns,ni,nsi
 close(401)

end subroutine readtest

--------------------
File tst.dat is a standard old-fashioned unformatted binary fortran
file containing three integers.

Compilation and linking:

g++ -O0 -g -c blah.cc
gfortran -O0 -g -frecord-marker=8 -c readtest.F90
g++ -O0 -g -frecord-marker=8 -o blah blah.o readtest.o -lgfortran

-------------------------

Is this a bug, a feature, or am I doing something wrong here?

Thanks.

 - Christian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-13 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-08  6:17 gfortran -frecord-marker and linking with g++ blowingupstars
2009-01-10 13:21 Christian Ott
2009-01-13 15:26 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).