[solved] gfortran treating comments as code

All things involving the setup (compiling, NetCDF, etc.) of the WRF Model itself.

[solved] gfortran treating comments as code

Postby jrd » Fri Oct 25, 2013 7:42 am

This is a strange one. I'm trying to compile using configuration option 40 (x86_64 Linux, gfortran compiler with gcc (serial); basic nesting). There are only two hitches with setup, the first being that I have to manually locate the NetCDF includes and libs in /usr/include/ and /usr/lib/ and the second being the usual complaint about gfortran:

Code: Select all
************************** W A R N I N G ************************************
 
There are some Fortran 20003 features in WRF that your compiler does not recognize
The IEEE signaling call has been removed.  That may not be enough.
 
*****************************************************************************


All seems OK following configuration, but when I try

Code: Select all
./compile em_b_wave >& somelogfile


it becomes clear that gfortran is treating every single comment line as code, and trying to compile it:

Code: Select all
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
 1
Error: Invalid character in name at (1)
ESMF_Fraction.f:2.3:

   This file is part of the GNU C Library.
   1
Error: Unclassifiable statement at (1)
ESMF_Fraction.f:4.3:

   The GNU C Library is free software; you can redistribute it and/or
   1
Error: Unclassifiable statement at (1)


I've never seen anthing like this before. Does anyone have a workaround for this please? Thanks a lot in advance...
Last edited by jrd on Thu Nov 28, 2013 5:42 am, edited 1 time in total.
jrd
 
Posts: 1
Joined: Fri Oct 25, 2013 7:30 am

Re: gfortran treating comments as code

Postby tanksnr » Mon Oct 28, 2013 3:57 am

What version of gfortran are you using?

If you look here: viewtopic.php?f=5&t=6024
We do get errors with gfortran, but nothing like that.
tanksnr
 
Posts: 19
Joined: Mon Nov 26, 2012 5:37 am

Re: gfortran treating comments as code

Postby AParkinson » Sat Nov 09, 2013 8:27 am

I'm having exactly the same problem with gcc-gfortran 4.8.2. Did you manage to find a fix?
AParkinson
 
Posts: 7
Joined: Wed Dec 05, 2012 2:10 am

Re: gfortran treating comments as code

Postby ramirochg » Sun Nov 10, 2013 3:30 pm

Hello,

I had the same problem you reported. Probably it is related with the C preprocessor. A possible solution is change:

Code: Select all
CPP             =      /lib/cpp -C -P


to

Code: Select all
CPP             =      /lib/cpp -P


I think this avoid the addition of C-style comments to the .f90 files. However this should be changed for every makefile in the directories of WRF. The other solution is add -cpp to the gfortran. Basically you have to change two lines:
Code: Select all
FORMAT_FIXED    =       -ffixed-form -cpp
FORMAT_FREE     =       -ffree-form -ffree-line-length-none -cpp


Now the gfortran knows that cpp preprocessor is being used. The most easy way is generate the file configure.wrf as usual and before compile anything change manually those two lines by adding -cpp (and check before any compilation). Also is possible apply the changes on the ./configure script.

In my case these changes were enough to compile with gfortran. Anyway, previously to do this you may try

gfortran -v


the output would be the default configuration of gfortran on your machine, and probably there isn't anything like -cpp. I guess this output depends partially on your Linux distribution (or Unix system).

I hope it would be useful.

Cheers,
Ramiro.
--
--------------------------------------------------------------------------
Dr. Ramiro Checa-Garcia
Karlsruhe Institute of Technology (KIT)
Institut für Meteorologie und Klimaforschung (IMK)
---------------------------------------------------------------------------
ramirochg
 
Posts: 1
Joined: Sun Nov 10, 2013 8:45 am

Re: gfortran treating comments as code

Postby AParkinson » Tue Nov 12, 2013 2:44 am

Hi Ramiro,

Adding -cpp to both fixed and free form arguments in configure.wrf worked for me too (on Fedora 19). After some googling I found other people had the same type of errors with certain versions of gfortran, and I was about to go back and use an older gfortran version. Thanks a lot.

Cheers,

Anthony
AParkinson
 
Posts: 7
Joined: Wed Dec 05, 2012 2:10 am

Re: [solved] gfortran treating comments as code

Postby samhawkins » Thu Jul 03, 2014 11:54 am

For information, I also received this error while trying to compile WRFDA. A look in the configure.wrf file revealed that the culprit was this line:

CPP = /lib/cpp -P

which I had to change to be:

CPP = /lib/cpp -C -P
samhawkins
 
Posts: 4
Joined: Wed Jan 14, 2009 11:12 am

Re: [solved] gfortran treating comments as code

Postby nishadh » Tue Sep 16, 2014 2:17 am

I had same problem for compiling WPS 3.4.1 and WRF 3.4.1 with gfortran 4.8.2, gcc 4.8.2.
For WRF, as suggested by @ramirochg, edited configure.wrf line numbers 119 and 120
Code: Select all
FORMAT_FIXED    =       -ffixed-form
FORMAT_FREE     =       -ffree-form -ffree-line-length-none

to
Code: Select all
FORMAT_FIXED    =       -ffixed-form -cpp
FORMAT_FREE     =       -ffree-form -ffree-line-length-none -cpp

and for WPS, confiugre.wps line number 77 was edited from
Code: Select all
CPP                 = /usr/bin/cpp -C -P -traditional

to
Code: Select all
CPP                 = /usr/bin/cpp -P -traditional

After this editing both WRF and WPS was compiled successfully, other wise met with error related with gfortran.
nishadh
 
Posts: 6
Joined: Mon Aug 25, 2014 10:27 am

Re: [solved] gfortran treating comments as code

Postby pingtong » Wed Oct 08, 2014 10:29 pm

I used ifort. In case ifor, add -fpp

#FORMAT_FIXED = -FI
#FORMAT_FREE = -FR
FORMAT_FIXED = -FI -fpp
FORMAT_FREE = -FR -fpp
pingtong
 
Posts: 14
Joined: Fri Jul 15, 2011 1:50 am

Re: [solved] gfortran treating comments as code

Postby pingtong » Thu Oct 09, 2014 12:36 am

For WPS, change configure.wps:

#FFLAGS = -FR -convert big_endian
#F77FLAGS = -FI -convert big_endian
FFLAGS = -FR -fpp -convert big_endian
F77FLAGS = -FI -fpp -convert big_endian
pingtong
 
Posts: 14
Joined: Fri Jul 15, 2011 1:50 am

Re: [solved] gfortran treating comments as code

Postby TammaraBa33 » Tue Oct 14, 2014 8:45 pm

That's strange. I've never encountered that but you can try the reconfiguration as suggested in this forum.
TammaraBa33
 
Posts: 1
Joined: Tue Oct 14, 2014 12:58 am

Next

Return to Installation

Who is online

Users browsing this forum: No registered users and 8 guests