<
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