Silverfrost Forums

Welcome to our forums

Fortan program for harmonic synthesis

12 Sep 2006 7:03 #1028

Hello

I am having some problems getting this code which is available on the internet to compile properly as availably fom here:

http://www.igfs.net/

During compilation it generates a number of warning messages and one fatal error that causes compilation to fail at the position indicated below where I have put 'compilation fails here' I have included a small section of the program code where the error is occurring--- the full code can be downloaded from the website link

c c----------------------------------------------------------------------- c parameter(iglob = 1-(int(((deast-dwest)/360.d0) + 1.d-5)), & ncols = nint((deast-dwest)/dlon) & +(1-icell)*(1-iflag)iglob, & nrows = nint((dnorth-dsouth)/dlat) & +(1-icell)(1-iflag), & mmax0 = max(lmax,kmax), & nmax0 = max(mmax0,jmax), & nmax01 = nmax0+1, & nmax02 = nmax0+2, & jcol = nint(360.d0/dlon), & jfft = max(jcol,nmax01)) -------- compilation fails here

c c-----------------------------------------------------------------------

error messages from compilation

Compiling file: harmonic_synth_v02.f D:\gmt\User\harmonic_synth_v02.F(136) : error 922 - INT with REAL(KIND=2) arguments is not permitted in an initialisation expression .... plus a lot of warning messgages

The program is stated as being written in Fortran 77, but I would not have thought that would be a big issue. I am just starting out on Fortran programming so need some advice as to what is causing the fatal error at compilation. I have contacted the program code distributors and was told that the reason the program fails to compile is because it may depend on the compiler used, which sounds odd if it is standard F77 code. Thanks

Lester

'Imagination is more important than knowledge' - Albert Einstein (1879 - 1955)

12 Sep 2006 9:06 #1030

Lester

FTN95 does not allow you to use NINT in a PARAMETER statement. This is probably standard conforming and the code was written for a compiler that allowed this as an extension.

All you have to do is move the assignment out of a PARAMETER statement.

12 Sep 2006 2:30 #1031

Hi Paul

Thanks for the explanation. Sorry for a very basic question, but how do you move the assignment out of the PARAMETER statement as you put it?

  parameter(iglob    = 1-(int(((deast-dwest)/360.d0) + 1.d-5)),
 &          ncols    = nint((deast-dwest)/dlon)
 &                                     +(1-icell)*(1-iflag)*iglob,
 &          nrows    = nint((dnorth-dsouth)/dlat)
 &                                     +(1-icell)*(1-iflag),
 &          mmax0    = max(lmax,kmax),
 &          nmax0    = max(mmax0,jmax),
 &          nmax01   = nmax0+1,
 &          nmax02   = nmax0+2,
 &          jcol     = nint(360.d0/dlon),
 &          jfft     = max(jcol,nmax01))

c c----------------------------------------------------------------------- c real8 zonals(10),cz(20),da(5) real8 batch(ncolsmaxr),grsv(15) real8 cnm(nmax01,nmax01),snm(nmax01,nmax01) real8 scrd(ncols,2),statd(22),ddlon(ncols) real8 flat(maxr),flon(maxr),dist(maxr),pt(maxr) real8 pt_a(maxpt),ga(maxpt),zeta(maxpt),corr(maxpt) real8 flat_a(maxpt),flon_a(maxpt),dist_a(maxpt),horth_a(maxpt) c real8 uc(maxr),tc(maxr),uic(maxr),uic2(maxr) real8 cotc(maxr),thet2(maxr),thet1(maxr),thetc(maxr) c real8 pmm_a(nmax01,maxr+1),pmm_b(nmax01,maxr),f_n(maxr),f_s(maxr) real8 p(nmax02,maxr),p1(nmax02,maxr),p2(nmax02,maxr) real8 c_ev(nmax01,maxr),s_ev(nmax01,maxr),kk(nmax01,maxr) real8 c_od(nmax01,maxr),s_od(nmax01,maxr) real8 cr1(jfft),sr1(jfft),cr2(jfft),sr2(jfft) real8 aux(2jcol),wrkfft(2jcol),factn(nmax01),k(nmax01) real8 cml(nmax01),sml(nmax01) c real4 data(ncols,nrows) integer*4 it(maxr),it_a(maxpt),iex(maxr),zero(maxr+1)

Thanks

Lester

'Imagination is more important than knowledge' - Albert Einstein (1879 - 1955)

12 Sep 2006 11:38 #1033

Lester

A PARAMETER statement takes the form

INTEGER,PARAMETER::MAX_PATH = 260

or its equivalent under Fortran 77.

The alternative assignment is

INTEGER MAX_PATH MAX_PATH = 260

In the first case the assignment has already been applied when the program is loaded and MAX_PATH cannot be changed at runtime. In the second case the assignment is carried out at runtime (when the statement is executed) and the compiler will not complain if you change MAX_PATH at runtime. The Fortran standard limits the kind of assignments that you are allowed to make in a PARAMETER statement because the result has to be expanded at compile time.

Please login to reply.