Asher Langton | 1 Aug 2007 02:41

OpenMP and local arrays

Hi all,

Here's a strange problem involving OpenMP and local arrays that are
treated as static:

program rd
  implicit none
  integer id
  integer omp_get_thread_num
!$omp parallel private (id)
  id = omp_get_thread_num()
  call foo (id)
!$omp end parallel
end program rd

subroutine foo (id)
  implicit none
  integer id
  real x(100,100)
  print *,"thread",id,"loc(x)",loc(x)
end subroutine foo

Using 'ifort -openmp' or 'pgf90 -mp', each thread has its own copy of
the array x.  However, with 'gfortran -fopenmp', all of the threads
are competing for the same copy of x.  It appears that ifort's
'-openmp' implies '-auto', and pgf90's '-mp' invokes an internal flag
called '-nostatic' (equivalent to '-Mrecursive', I think).

I couldn't find a comparable flag in gfortran to invoke with
'-fopenmp'.  The '-fautomatic' flag (which is on by default) is not
(Continue reading)

Craig Powers | 1 Aug 2007 07:35
Picon

Re: Mixed entries and 12.5.2.5

Tobias Burnus wrote:
> 
> In Fortran 77 one finds the following which does not seem to have the
> default-kind restriction (as there were no TYPE and POINTER there is
> obviously no such restriction):

Might have something to do with Fortran 77 not having KINDs, either. :)

ppanta | 1 Aug 2007 10:03
Picon
Favicon

compilation problem: undefined reference


Hi, 
I need some help with the compilation problem. I looked around the site and
I didn't get a satisfactory clue to solving my problem .. or I didn't look
good enough. Anyway, it seems to be missing some kind of library?
I'm new with Fortran so please let me know what I need to include in my file
as a header or 
option for compilation.
Below are the types of error I'm getting. The makefile I used is also listed
below.

=====================================

AAmainRain.o: In function `MAIN__':
AAmainRain.F:(.text+0x22): undefined reference to `_gfortran_set_std'
AAmainRain.F:(.text+0x58): undefined reference to `_gfortran_st_write'
AAmainRain.F:(.text+0x76): undefined reference to
`_gfortran_transfer_character'
AAmainRain.F:(.text+0x84): undefined reference to `_gfortran_st_write_done'
AAmainRain.F:(.text+0xbc): undefined reference to `ieee_handler_'
AAmainRain.F:(.text+0xfb): undefined reference to `_gfortran_st_write'
AAmainRain.F:(.text+0x119): undefined reference to
`_gfortran_transfer_character'
AAmainRain.F:(.text+0x127): undefined reference to `_gfortran_st_write_done'
AAmainRain.F:(.text+0x133): undefined reference to `_gfortran_exit_i4'
AAmainRain.F:(.text+0x161): undefined reference to `ieee_handler_'
AAmainRain.F:(.text+0x1a0): undefined reference to `_gfortran_st_write'
AAmainRain.F:(.text+0x1be): undefined reference to
`_gfortran_transfer_character'
AAmainRain.F:(.text+0x1cc): undefined reference to `_gfortran_st_write_done'
(Continue reading)

FX Coudert | 1 Aug 2007 10:13
Picon

Re: compilation problem: undefined reference

> %.o: %.F $(DEPS)
> 	$(CC) -c $< -o $ <at> 
> $(PROGRAM): $(OBJECTS)
> 	$(CC) -v $^ -o $ <at>  -lm

You should define FC=gfortran and compile and link your program with $ 
(FC) instead of $(CC).

FX

Tobias Burnus | 1 Aug 2007 10:20
Picon

Re: compilation problem: undefined reference

Hi,

ppanta wrote:
> I need some help with the compilation problem. I looked around the site and
> I didn't get a satisfactory clue to solving my problem .. or I didn't look
> good enough. Anyway, it seems to be missing some kind of library?
> I'm new with Fortran so please let me know what I need to include in my file
> as a header or option for compilation.
>   
In general, it would help to know on which platform and with which
version of gfortran the problem occurs ("gfortran -v" shows this
information).

But in this special case I think I know what the problem is:
> CC= gcc
> %.o: %.F $(DEPS)
> 	$(CC) -c $< -o $ <at> 
> $(PROGRAM): $(OBJECTS)
> 	$(CC) -v $^ -o $ <at>  -lm
>   

You use "gcc" to compile the Fortran programs and not "gfortran". While
for the compilation it does not make a difference, for the linking it
does: "gfortran" links different/additionally libraries than "gcc". For
Fortran programs you should therefore use:

FC=gfortran
%.o: %.F $(DEPS)
    $(FC) -c $< -o $ <at> 
$(PROGRAM): $(OBJECTS)
(Continue reading)

Daniel Franke | 1 Aug 2007 12:53
Picon

Re: [patch, fortran] more about namelists

On Tuesday 31 July 2007 16:51:15 Dominique Dhumieres wrote:
> and gfortran.dg/namelist_33.f90 fails due to:
>
> /opt/gcc/gcc-4.3-work/gcc/testsuite/gfortran.dg/namelist_33.f90:31.15:
>
>   namelist /nml/ i
>               1
> Error: NAMELIST object 'i' was declared PRIVATE and cannot be member of
> PUBLIC namelist 'nml' at (1)

Sorted out on IRC.
The first patch was applied although already committed, thus hitting 

	http://gcc.gnu.org/ml/gcc-patches/2007-07/msg02022.html

Daniel Franke | 1 Aug 2007 13:02
Picon

[patch, fortran] PR32945 - ICE in initialization expression


Attached patch fixes the ICE initially reported by Florian Ladtstaedter:
	http://gcc.gnu.org/ml/fortran/2007-07/msg00587.html

:ADDPATCH fortran:

gcc/fortran:
2007-08-01  Daniel Franke  <franke.daniel <at> gmail.com>

	PR fortran/32945
	* expr.c (check_specification_function): Skip check if no symtree 
	is available.

gcc/testsuite:
2007-08-01  Daniel Franke  <franke.daniel <at> gmail.com>

	PR fortran/32945
	* gfortran.dg/initialization_12.f90: New test.

Bootstrapped and regression tested on i686-pc-linux-gnu. Ok for trunk?

Regards
	Daniel
Attachment (pr32945.patch): text/x-diff, 1380 bytes
Daniel Franke | 1 Aug 2007 13:26
Picon

-Wunused-parameter


Follow-up to 
	http://gcc.gnu.org/ml/fortran/2007-07/msg00545.html

gcc/fortran:
2007-08-01  Daniel Franke  <franke.daniel <at> gmail.com>

	* trans-decl.c (generate_local_decl): Emit warning on unused parameter
	on "-Wall -Wextra" or "-Wunused-parameter" but not on "-Wall".
	* invoke.texi (-Wparameter-unused): Document differences between gcc 
	and gfortran regarding this option.

gcc/testsuite:
2007-08-01  Daniel Franke  <franke.daniel <at> gmail.com>

	* gfortran.dg/parameter_unused.f90: Adjusted dg-options.

Bootstrapped and regression tested on i686-pc-linux-gnu.
Ok for trunk?

Regards
	Daniel
Attachment (unused-parameter.patch): text/x-diff, 2195 bytes
Tobias Burnus | 1 Aug 2007 13:47
Picon

Re: [patch, fortran] PR32945 - ICE in initialization expression

:REVIEWMAIL:

Daniel Franke wrote:
> Bootstrapped and regression tested on i686-pc-linux-gnu. Ok for trunk?
>   
OK -- the fix is obvious.

Thanks,

Tobias

PS: Does anyone have the time to look at the patch for Florian's other
problem (allocate & STAT=function result),
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32936 ?
The patch is here:
http://gcc.gnu.org/ml/gcc-patches/2007-07/msg02125.html

Tobias Schlüter | 1 Aug 2007 14:20
Picon
Favicon

Re: -Wunused-parameter

Daniel Franke wrote:
> Index: fortran/trans-decl.c
> ===================================================================
> --- fortran/trans-decl.c	(revision 127062)
> +++ fortran/trans-decl.c	(working copy)
>  <at>  <at>  -3031,7 +3031,7  <at>  <at>  generate_local_decl (gfc_symbol * sym)
>      }
>    else if (sym->attr.flavor == FL_PARAMETER)
>      {
> -      if (warn_unused_variable 
> +      if (warn_unused_parameter
>             && !sym->attr.referenced
>             && !sym->attr.use_assoc)
>  	gfc_warning ("unused parameter '%s' declared at %L", sym->name,
                       ^
While you're touching this area, can you change this to uppercase, as is 
the convention elsewhere?

As far as the patch itself goes, does -Wunused-parameter affect warnings 
for unused dummy arguments in Fortran code?  In that case, your patch 
may not be the right thing, otherwise I'm all in favor of applying it.

Thanks,
- Tobi


Gmane