Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-07 Thread Jon Agirre
Dear Fred,

I would say that you're using a buggy gfortran version
(http://lists.debian.org/debian-gcc/2009/03/msg00070.html). You may
want to check your version with 'gfortran --version' in order to be
sure of it. The '-malign-double' switch provides only a slight
optimization and as you have already proven, it may be removed with
very little impact on performance.

Cheers,

Jon

2013/3/6 vellieux frederic.velli...@ibs.fr:
 Dear all,

 By popular request here is an example of some code where gfortran gives run
 time errors. This is at the very beginning of the program, the first write
 statement where a parenthesis is seen as missing at run time: (the first
 hyphens are not within the Fortran code but there to indicate the number of
 spaces before each character, 6 and nothing more or less).

 Also enclosed as part.f herewith (as an attachment)

 [I must admit that, somehow, when modifying a Fortran program using vim on
 this new box, the number of characters at the beginning of Fortran cards
 seems to reset to 8 when there are 6 blanks to start with, I have no idea
 why this is so.]

 Help most welcome, and I'd hate to have to retype every single program...

 Ta,

 Fred.

 --

   ORDER='A'
   NATM=0
   DO 5,I=1,3
  NGRID(2,I)= 9
  NGRID(3,I)=-9
  XMIN(I)= .
  XMAX(I)=-.
   5  CONTINUE
 C
 C   OPEN INPUT FILE
 C
   WRITE (*,10)
10 FORMAT(///,25X,'*',
  . /,25X,'*   *',


 --
 Fred. Vellieux (B.Sc., Ph.D., hdr)
 ouvrier de la recherche
 IBS / ELMA
 41 rue Jules Horowitz
 F-38027 Grenoble Cedex 01
 Tel: +33 438789605
 Fax: +33 438785494




-- 
Jon Agirre, PhD
Unit of Biophysics (CSIC-UPV/EHU)
http://sourceforge.net/projects/projectrecon/
+34656756888


Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-07 Thread vellieux

Hi Jon,

Thanks for the feedback. The version I am using (which is not that 
reported in the web page you mention, Version: 4:4.3.2-2) is:

GNU Fortran (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4).

Hence it appears that the bug hasn't been entirely dealt with. Ian 
Tickle was getting segmentation faults (so he may be using gfortran V 
4.3.2-2), I was only getting a binary that crashes due to a missing left 
parenthesis in a FORMAT statement (the parenthesis was there as far as I 
could see...).


Thanks again,

Fred.

On 07/03/13 10:23, Jon Agirre wrote:

Dear Fred,

I would say that you're using a buggy gfortran version
(http://lists.debian.org/debian-gcc/2009/03/msg00070.html). You may
want to check your version with 'gfortran --version' in order to be
sure of it. The '-malign-double' switch provides only a slight
optimization and as you have already proven, it may be removed with
very little impact on performance.

Cheers,

Jon



--
Fred. Vellieux (B.Sc., Ph.D., hdr)
ouvrier de la recherche
IBS / ELMA
41 rue Jules Horowitz
F-38027 Grenoble Cedex 01
Tel: +33 438789605
Fax: +33 438785494


Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-07 Thread Ian Tickle
I'm using gcc 4.7.2 (latest stable version I think).  I don't get the
compilation error of the FORMAT statement but I do get the segfault error
on running with the '-malign-double' switch that I reported.  So it would
appear that even the current stable version is buggy!  As Jon said the
workaround is to leave off '-malign-double': it has very little effect on
performance anyway.  Or use ifort (main reason I use it is past bugs in Gnu
compilers).

Cheers

-- Ian


On 7 March 2013 09:44, vellieux frederic.velli...@ibs.fr wrote:

 Hi Jon,

 Thanks for the feedback. The version I am using (which is not that
 reported in the web page you mention, Version: 4:4.3.2-2) is:
 GNU Fortran (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4).

 Hence it appears that the bug hasn't been entirely dealt with. Ian Tickle
 was getting segmentation faults (so he may be using gfortran V 4.3.2-2), I
 was only getting a binary that crashes due to a missing left parenthesis in
 a FORMAT statement (the parenthesis was there as far as I could see...).

 Thanks again,

 Fred.


 On 07/03/13 10:23, Jon Agirre wrote:

 Dear Fred,

 I would say that you're using a buggy gfortran version
 (http://lists.debian.org/**debian-gcc/2009/03/msg00070.**htmlhttp://lists.debian.org/debian-gcc/2009/03/msg00070.html).
 You may
 want to check your version with 'gfortran --version' in order to be
 sure of it. The '-malign-double' switch provides only a slight
 optimization and as you have already proven, it may be removed with
 very little impact on performance.

 Cheers,

 Jon



 --
 Fred. Vellieux (B.Sc., Ph.D., hdr)
 ouvrier de la recherche
 IBS / ELMA
 41 rue Jules Horowitz
 F-38027 Grenoble Cedex 01
 Tel: +33 438789605
 Fax: +33 438785494



[ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread vellieux

Hello,

For those who still know the Fortran language and its Fortran 77 
variant, I used to have a g77 compiler here (Linux box), and now on the 
new box it's no longer g77 but gfortran.


When compiling Fortran77 code (these are the flags used for compilation: 
-o ../bin/$1 -std=legacy -Wno-globals -w -O3 -malign-double 
-funroll-loops -ffast-math -fno-second-underscore $1.f , followed by the 
libraries on that same compile line)


I get errors (at run time) of the type:

At line 138 of file program.f (unit = 6, file = 'stdout')
Fortran runtime error: Missing initial left parenthesis in format

When looking at this code (which compiled perfectly well using g77 - I 
removed the flag -fno-globals which doesn't seem to exist any more in 
gfortran) the Fortran code that I see appears to have all parentheses in 
the correct places.


Any idea of what must be done with existing Fortran 77 code in order to 
get it to compile and run with gfortran ? Otherwise any idea which 
compiler should be used to compile Fortran 77 code ?


Thanks in advance,

Fred.

--
Fred. Vellieux (B.Sc., Ph.D., hdr)
ouvrier de la recherche
IBS / ELMA
41 rue Jules Horowitz
F-38027 Grenoble Cedex 01
Tel: +33 438789605
Fax: +33 438785494


Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Harry Powell

Hi Fred

If you look very carefully at your Fortran code you will probably   
find a small error/inconsistency that g77 allowed but gfortran picked  
up on or compiled as written rather than as intended. My move from  
g77 to gfortran when building Mosflm (which is moderately large) was  
pretty painless, but I did find that when I got errors of this type  
the fault was when the code did not adhere to standards.


Generally speaking, gfortran adheres to the current Fortran standards  
more strictly than g77. Recent versions give Mosflm executables that  
are within a few percent of the performance that I get with the Intel  
Fortran ifort compilers (actually, sometimes faster, sometimes  
slower)- I've checked this on both Mac and Linux.


I use gfortran for development, ifort for checking things are still  
okay, and also run an old Linux box with g77 for further checking in  
case I've missed something earlier. My Windows executable of Mosflm  
still uses g77 (the mingw cross-compiler run on OSX).


However, there are persistent reports out there of people who find  
their code runs much faster when compiled with ifort - so I guess  
this is very much code dependent.


I can have a look at your code if it would help.

HTH

On 6 Mar 2013, at Wed6 Mar 09:48, vellieux wrote:


Hello,

For those who still know the Fortran language and its Fortran 77  
variant, I used to have a g77 compiler here (Linux box), and now on  
the new box it's no longer g77 but gfortran.


When compiling Fortran77 code (these are the flags used for  
compilation: -o ../bin/$1 -std=legacy -Wno-globals -w -O3 -malign- 
double -funroll-loops -ffast-math -fno-second-underscore $1.f ,  
followed by the libraries on that same compile line)


I get errors (at run time) of the type:

At line 138 of file program.f (unit = 6, file = 'stdout')
Fortran runtime error: Missing initial left parenthesis in format

When looking at this code (which compiled perfectly well using g77  
- I removed the flag -fno-globals which doesn't seem to exist any  
more in gfortran) the Fortran code that I see appears to have all  
parentheses in the correct places.


Any idea of what must be done with existing Fortran 77 code in  
order to get it to compile and run with gfortran ? Otherwise any  
idea which compiler should be used to compile Fortran 77 code ?


Thanks in advance,

Fred.

--
Fred. Vellieux (B.Sc., Ph.D., hdr)
ouvrier de la recherche
IBS / ELMA
41 rue Jules Horowitz
F-38027 Grenoble Cedex 01
Tel: +33 438789605
Fax: +33 438785494


Harry
--
Dr Harry Powell, MRC Laboratory of Molecular Biology, MRC Centre,  
Hills Road, Cambridge, CB2 0QH
Chairman of European Crystallographic Association SIG9  
(Crystallographic Computing)







Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Ian Tickle
Hi Fred

I regularly compile F77 code with gfortran: I always get lots of warnings
and the occasional error that I didn't get with g77 mainly because gfortran
is much stricter applying the standard (and a good thing too!).  I also
regularly use ifort (which isn't quite as strict as gfortran and
consequently sometimes doesn't spot some real errors).

Maybe if you could post the bit of code it's complaining about (including
say +=5 lines on each side) we could make some specific suggestions.  It's
hard to make suggestions which will cover all eventualities.

Cheers

-- Ian


On 6 March 2013 09:48, vellieux frederic.velli...@ibs.fr wrote:

 Hello,

 For those who still know the Fortran language and its Fortran 77 variant,
 I used to have a g77 compiler here (Linux box), and now on the new box it's
 no longer g77 but gfortran.

 When compiling Fortran77 code (these are the flags used for compilation:
 -o ../bin/$1 -std=legacy -Wno-globals -w -O3 -malign-double -funroll-loops
 -ffast-math -fno-second-underscore $1.f , followed by the libraries on that
 same compile line)

 I get errors (at run time) of the type:

 At line 138 of file program.f (unit = 6, file = 'stdout')
 Fortran runtime error: Missing initial left parenthesis in format

 When looking at this code (which compiled perfectly well using g77 - I
 removed the flag -fno-globals which doesn't seem to exist any more in
 gfortran) the Fortran code that I see appears to have all parentheses in
 the correct places.

 Any idea of what must be done with existing Fortran 77 code in order to
 get it to compile and run with gfortran ? Otherwise any idea which compiler
 should be used to compile Fortran 77 code ?

 Thanks in advance,

 Fred.

 --
 Fred. Vellieux (B.Sc., Ph.D., hdr)
 ouvrier de la recherche
 IBS / ELMA
 41 rue Jules Horowitz
 F-38027 Grenoble Cedex 01
 Tel: +33 438789605
 Fax: +33 438785494



Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Thomas, Jens
Hi Fred,


From: CCP4 bulletin board [CCP4BB@JISCMAIL.AC.UK] on behalf of vellieux 
[frederic.velli...@ibs.fr]
 When compiling Fortran77 code (these are the flags used for compilation:
 -o ../bin/$1 -std=legacy -Wno-globals -w -O3 -malign-double
 -funroll-loops -ffast-math -fno-second-underscore $1.f , followed by the
 libraries on that same compile line)

 I get errors (at run time) of the type:

 At line 138 of file program.f (unit = 6, file = 'stdout')
 Fortran runtime error: Missing initial left parenthesis in format

It might be something to do with fixed vs free format, although I'd have 
thought the -std=legacy should have dealt with that.

You could try adding -ffixed-format and maybe experiment with different values 
for -ffixed-line-length

Things that have bitten me in the past include different backslash 
interpretations, so you could try -fbackslash and also -fd-lines-as-comments if 
there are lines beginning with a D.

If none of that works, maybe you could post the bit of code around the lines 
where you're seeing the error message to see if someone can spot what's 
tripping the compiler up.

Best wishes,

Jens



Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Ian Clifton
Hi Fred,

vellieux frederic.velli...@ibs.fr writes:


[...]

 I get errors (at run time) of the type:

 At line 138 of file program.f (unit = 6, file = 'stdout')
 Fortran runtime error: Missing initial left parenthesis in format


[...]

Mmm, that kind of error rings a bell … is the relevant format a string
rather than given in a FORMAT statement? If so, you need round brackets
INSIDE the format string, i.e.

   write (*, '(i5)') 123

rather than

   write (*, 'i5') 123

—this can manifest itself at run‐time, especially if the format is in a
character variable.
-- 
Ian ◎


Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread vellieux

Dear all,

By popular request here is an example of some code where gfortran gives 
run time errors. This is at the very beginning of the program, the first 
write statement where a parenthesis is seen as missing at run time: (the 
first hyphens are not within the Fortran code but there to indicate the 
number of spaces before each character, 6 and nothing more or less).


Also enclosed as part.f herewith (as an attachment)

[I must admit that, somehow, when modifying a Fortran program using vim 
on this new box, the number of characters at the beginning of Fortran 
cards seems to reset to 8 when there are 6 blanks to start with, I have 
no idea why this is so.]


Help most welcome, and I'd hate to have to retype every single program...

Ta,

Fred.

--

  ORDER='A'
  NATM=0
  DO 5,I=1,3
 NGRID(2,I)= 9
 NGRID(3,I)=-9
 XMIN(I)= .
 XMAX(I)=-.
  5  CONTINUE
C
C   OPEN INPUT FILE
C
  WRITE (*,10)
   10 FORMAT(///,25X,'*',
 . /,25X,'*   *',

--
Fred. Vellieux (B.Sc., Ph.D., hdr)
ouvrier de la recherche
IBS / ELMA
41 rue Jules Horowitz
F-38027 Grenoble Cedex 01
Tel: +33 438789605
Fax: +33 438785494

  ORDER='A'
  NATM=0
  DO 5,I=1,3
NGRID(2,I)= 9
NGRID(3,I)=-9
XMIN(I)= .
XMAX(I)=-.
  5   CONTINUE
C
C OPEN INPUT FILE
C
  WRITE (*,10)
   10 FORMAT(///,25X,'*',
 . /,25X,'*   *',


Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Ian Tickle
Fred

The relevant bit of code, with the FORMAT statement closed with a ')' and
an END statement added to make it a viable program, is:

  WRITE (*,10)
   10 FORMAT(///,25X,'*',
 . /,25X,'*   *')
  END

For me this compiles and runs without error using gfortran (gcc version
4.7.2).  Maybe you have an old version of gfortran with bugs.  Note that a
statement with continuation lines containing errors usually generates an
error message which specifies only the first line of the statement.  What's
in the rest of the FORMAT statement?

-- Ian


On 6 March 2013 10:37, vellieux frederic.velli...@ibs.fr wrote:

 Dear all,

 By popular request here is an example of some code where gfortran gives
 run time errors. This is at the very beginning of the program, the first
 write statement where a parenthesis is seen as missing at run time: (the
 first hyphens are not within the Fortran code but there to indicate the
 number of spaces before each character, 6 and nothing more or less).

 Also enclosed as part.f herewith (as an attachment)

 [I must admit that, somehow, when modifying a Fortran program using vim on
 this new box, the number of characters at the beginning of Fortran cards
 seems to reset to 8 when there are 6 blanks to start with, I have no idea
 why this is so.]

 Help most welcome, and I'd hate to have to retype every single program...

 Ta,

 Fred.

 --

   ORDER='A'
   NATM=0
   DO 5,I=1,3
  NGRID(2,I)= 9
  NGRID(3,I)=-9
  XMIN(I)= .
  XMAX(I)=-.
   5  CONTINUE
 C
 C   OPEN INPUT FILE
 C
   WRITE (*,10)
10 FORMAT(///,25X,'***',
  . /,25X,'*   *',


 --
 Fred. Vellieux (B.Sc., Ph.D., hdr)
 ouvrier de la recherche
 IBS / ELMA
 41 rue Jules Horowitz
 F-38027 Grenoble Cedex 01
 Tel: +33 438789605
 Fax: +33 438785494




Re: [ccp4bb] SOLVED [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread vellieux

Hi all,

Problem solved thanks to Jorge Navaza's suggestion: remove all 
compilation flags but only have -Wall as a compilation flag.


There is no run time error any more and there is no error at compilation 
time. The program runs fine.


Thanks to Thomas Jens, Harry Powell, Ian Tickle, Ian Clifton and 
Bernhard Rupp for their suggestions.


Fred.

On 06/03/13 10:48, vellieux wrote:

Hello,

For those who still know the Fortran language and its Fortran 77 
variant, I used to have a g77 compiler here (Linux box), and now on 
the new box it's no longer g77 but gfortran.


When compiling Fortran77 code (these are the flags used for 
compilation: -o ../bin/$1 -std=legacy -Wno-globals -w -O3 
-malign-double -funroll-loops -ffast-math -fno-second-underscore $1.f 
, followed by the libraries on that same compile line)


I get errors (at run time) of the type:

At line 138 of file program.f (unit = 6, file = 'stdout')
Fortran runtime error: Missing initial left parenthesis in format

When looking at this code (which compiled perfectly well using g77 - I 
removed the flag -fno-globals which doesn't seem to exist any more 
in gfortran) the Fortran code that I see appears to have all 
parentheses in the correct places.


Any idea of what must be done with existing Fortran 77 code in order 
to get it to compile and run with gfortran ? Otherwise any idea which 
compiler should be used to compile Fortran 77 code ?


Thanks in advance,

Fred.




--
Fred. Vellieux (B.Sc., Ph.D., hdr)
ouvrier de la recherche
IBS / ELMA
41 rue Jules Horowitz
F-38027 Grenoble Cedex 01
Tel: +33 438789605
Fax: +33 438785494


Re: [ccp4bb] SOLVED [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Ian Tickle
Fred, OK I just noticed I didn't have the  -malign-double flag.  With that
it compiles but on running I get:

Program received signal SIGSEGV: Segmentation fault - invalid memory
reference.

Backtrace for this error:
#0  0x12244B
#1  0x122A9C
#2  0x473907
#3  0x1BD238
#4  0x1CB4BF
#5  0x80486E2 in MAIN__
Segmentation fault

Without that flag it compiles  runs without error.  So you may want to try
it just without that flag.

Cheers

-- Ian



On 6 March 2013 12:33, vellieux frederic.velli...@ibs.fr wrote:

 Hi all,

 Problem solved thanks to Jorge Navaza's suggestion: remove all compilation
 flags but only have -Wall as a compilation flag.

 There is no run time error any more and there is no error at compilation
 time. The program runs fine.

 Thanks to Thomas Jens, Harry Powell, Ian Tickle, Ian Clifton and Bernhard
 Rupp for their suggestions.

 Fred.

 On 06/03/13 10:48, vellieux wrote:

 Hello,

 For those who still know the Fortran language and its Fortran 77 variant,
 I used to have a g77 compiler here (Linux box), and now on the new box it's
 no longer g77 but gfortran.

 When compiling Fortran77 code (these are the flags used for compilation:
 -o ../bin/$1 -std=legacy -Wno-globals -w -O3 -malign-double -funroll-loops
 -ffast-math -fno-second-underscore $1.f , followed by the libraries on that
 same compile line)

 I get errors (at run time) of the type:

 At line 138 of file program.f (unit = 6, file = 'stdout')
 Fortran runtime error: Missing initial left parenthesis in format

 When looking at this code (which compiled perfectly well using g77 - I
 removed the flag -fno-globals which doesn't seem to exist any more in
 gfortran) the Fortran code that I see appears to have all parentheses in
 the correct places.

 Any idea of what must be done with existing Fortran 77 code in order to
 get it to compile and run with gfortran ? Otherwise any idea which compiler
 should be used to compile Fortran 77 code ?

 Thanks in advance,

 Fred.



 --
 Fred. Vellieux (B.Sc., Ph.D., hdr)
 ouvrier de la recherche
 IBS / ELMA
 41 rue Jules Horowitz
 F-38027 Grenoble Cedex 01
 Tel: +33 438789605
 Fax: +33 438785494



Re: [ccp4bb] SOLVED [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread vellieux

Hi again Ian and list,

The following flags seem to work fine:
gfortran -o ../bin/$1 -std=legacy -ffixed-format -Wno-globals -w -O3 
-funroll-loops -ffast-math -fno-second-underscore $1.f (followed by the 
library or libraries, compiled with the same flags).


Problem solved as far as I am concerned (until there is yet another 
compiler I guess, next Linux box down the road).


Fred.

On 06/03/13 13:55, Ian Tickle wrote:
Fred, OK I just noticed I didn't have the  -malign-double flag.  With 
that it compiles but on running I get:


Program received signal SIGSEGV: Segmentation fault - invalid memory 
reference.


Backtrace for this error:
#0  0x12244B
#1  0x122A9C
#2  0x473907
#3  0x1BD238
#4  0x1CB4BF
#5  0x80486E2 in MAIN__
Segmentation fault

Without that flag it compiles  runs without error.  So you may want 
to try it just without that flag.


Cheers

-- Ian


--
Fred. Vellieux (B.Sc., Ph.D., hdr)
ouvrier de la recherche
IBS / ELMA
41 rue Jules Horowitz
F-38027 Grenoble Cedex 01
Tel: +33 438789605
Fax: +33 438785494


Re: [ccp4bb] compiling Fortran 77 code on a Linux box (using gfortran ?)

2013-03-06 Thread Francois Berenger

Hi,

The command:
$ aptitude install fort77
would install an f77 command on Ubuntu/Debian Linux.
In fact that's a wrapper for f2c, but maybe it behaves like
a real f77 compiler, I would give it a try personnally.

On 03/06/2013 06:48 PM, vellieux wrote:

Hello,

For those who still know the Fortran language and its Fortran 77
variant, I used to have a g77 compiler here (Linux box), and now on the
new box it's no longer g77 but gfortran.

When compiling Fortran77 code (these are the flags used for compilation:
-o ../bin/$1 -std=legacy -Wno-globals -w -O3 -malign-double
-funroll-loops -ffast-math -fno-second-underscore $1.f , followed by the
libraries on that same compile line)

I get errors (at run time) of the type:

At line 138 of file program.f (unit = 6, file = 'stdout')
Fortran runtime error: Missing initial left parenthesis in format

When looking at this code (which compiled perfectly well using g77 - I
removed the flag -fno-globals which doesn't seem to exist any more in
gfortran) the Fortran code that I see appears to have all parentheses in
the correct places.

Any idea of what must be done with existing Fortran 77 code in order to
get it to compile and run with gfortran ? Otherwise any idea which
compiler should be used to compile Fortran 77 code ?

Thanks in advance,

Fred.