Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

namelist problem

472 views
Skip to first unread message

mariog...@gmail.com

unread,
Apr 8, 2016, 11:06:08 AM4/8/16
to
Hello everybody

I have a problem with a namelist. I am developing a FORTRAN code, and I have used two namelist to include many variables from two differents .txt files.

I have complied the code with ifort and this was accomplished successfully, and the code is executed well. By other hand, I would like to compile this code with gfortran, I have made the makefile for gfortran, but when I try to compile it, I get the follow error message:

------------------------------------------------------------------------------
gfortran -fdefault-real-8 -O3 -c -o main.o main.f
main.f:97.72:

> density_f,HD,facmom
1
Error: Unexpected NAMELIST statement at (1)
main.f:99.25:

read(102,nml=input2)
1
Error: Symbol 'input2' at (1) must be a NAMELIST group name
make: *** [main.o] Error 1
------------------------------------------------------------------------------

The part of the code I have and presents problems is this one (This works and compile well with ifort but not with gfortran):
------------------------------------------------------------------------------

! Generating set-up variables from input file for the quadrilateral domain
namelist/input/swcase,kap_coeff,n,nsubx,nsubz,courant,velmax,
> tfin,frames,nonlinear,ynfilter,pmodes,ti_method,
> pbgxa,pbgya,pbgxb,pbgyb,pbgxc,pbgyc
open(unit=101,file='SMPM_quad.in')
read(101,nml=input)
close(101)
!
! Generating set-up variables from input file for the debris flow parameters
namelist/param/kappa,fric_bed,fric_int,anglex,angley,
> fluid_vol,solid_vol,fluid_visco,density_s,
> density_f,HD,facmom
open(unit=102,file='SMPM_param.in')
read(102,nml=param)
close(102)
------------------------------------------------------------------------------

Can someone help me to find the problem, or give me an idea.

Thanks

Mario G.

Richard Maine

unread,
Apr 8, 2016, 11:39:07 AM4/8/16
to
<mariog...@gmail.com> wrote:
[much elided]
> > density_f,HD,facmom
> 1
> Error: Unexpected NAMELIST statement at (1)

This is the real problem. The "unexpected" bit implies that it
recognizes this as a namelist statement, but doesn't think it belongs
here. See below for more.

> read(102,nml=input2)
> 1
> Error: Symbol 'input2' at (1) must be a NAMELIST group name

This is just a consequence of the first error. SInce the first error
kept the namelist statement from compiling, the namelist group name
isn't declared.

> (This works and compile well with ifort but not with gfortran):

I suggest using ifort's option to warn about violations of the standard.
It would have told you about this problem, as well as 2 others. When I
did so, I got.

Europa:~/temp> ifort -c -warn stderrors clf.f
ifort: command line warning #10249: -warn stderrors sets -std
clf.f(3): error #5113: Extension to FORTRAN-90: tab formatting
namelist/input/swcase,kap_coeff,n,nsubx,nsubz,courant,velmax,
^
clf.f(1): warning #7373: Fixed form source is an obsolescent feature in
Fortran 2003.
subroutine sub
^
clf.f(11): error #7775: Placement of NAMELIST statement is non-standard.
namelist/param/kappa,fric_bed,fric_int,anglex,angley,
--------^
compilation aborted for clf.f (code 1)

The first two messages warn about the source form. Fixed source form is
obsolescent. It is also more error-prone than free source form. I
recommend using free source form except for old codes where there is
reason not to fuss with conversion to free form. This code uses a tab
variant of fixed source form; that has never been standard conforming.

The last message is about the problem you asked about. Like gfortran,
ifort recognizes that the namelist statement doesn't belong here. The
difference is that gfortran treats it as an error, whereas ifort allows
it as a nonstandard feature. IFort is fairly "bad" (depending on one's
definitions of that term) about not warning about nonstandard code
unless you go out of your way to explicily ask it to. I recommend
getting in the habbit of doing so.

Oh yes, and the actual answer to your question (way down here so you
have to go through the above explanations first :-)). The namelist
statement is a specification statement and must go up at the top of the
procedure, along with the other specifications.

iFort apparently has an extension to allow it elsewhere, but that's not
standard Fortran and should not be expected to work with other
compilers. That's one of the kinds of reasons for making it a habbit to
ask it for warnings about standard violations. Another reason is that
sometimes such violations are a sign of actual errors that might not do
what you intended. (Not always, but sometimes).

--
Richard Maine
email: last name at domain . net
dimnain: summer-triangle

Marco

unread,
Apr 8, 2016, 11:44:00 AM4/8/16
to
Am Fri, 08 Apr 2016 08:06:06 -0700 schrieb mariogermantv:

> Hello everybody
>
> I have a problem with a namelist.

Mario, I think other are going to reply asking you to post the actual
code, so I am doing it now to speed up the process.

The error that you report and the code that you show do not match: the
error is about a namelist "input2", while your code fragment includes
namelists "input" and "param".

Could you please post the code which produces the error, without any
modification? Without that, it is difficult to understand what
happens.

Marco

mariog...@gmail.com

unread,
Apr 8, 2016, 6:18:11 PM4/8/16
to
Thank you very much Richard, I have corrected the mistake as soon as I gave the instructions. But, I have other error messages caused by violations of the standard, so I'll work about them.

Mario G.
0 new messages