Prev: Libraries on Linux
Next: Write to file from DLL
From: ben_nielsen20 on 19 Apr 2007 19:46 Hello, I need some help, please!!! I'm a little clueless about Fortran. I'm trying to get the following program to run using a compiler for Windows I downloaded off here: http://gcc.gnu.org/wiki/GFortranBinaries Which also references another program located here: http://gams.nist.gov/serve.cgi/Module/CMLIB/DQAGI/592/ There is also this small data input file: 'file input.par' 'fundamental frequency, Hz' 333.0d0 'power, W' 7.52d-3 'line full width, cm' 1.83d-3 'line length, cm' 0.4d0 'thickness Si, cm' 0.072d0 'measurement temp. T2, deg c' 23.5d0 It doesn't seem to want to run either a "&" or a "*" for a line continuation. There are also a number of other errors. Thanks, B PROGRAM 3omega c version 1, 01-Nov-2001 c Calculate real temperature variation at a given frequency c for a silicon plate heated by a thin metal strip. c The calculation can be applied to plates composed of c material other than silicon if the thermal conductivity c and thermal diffusivity of that material are substituted c in the indicated lines below. c This is used for analyzing data obtained by the 3 omega c method c c library routine 'dqagi' used for integration c -------------------------------------------------------- c A data file named 'input.par' written in ASCII is needed c c A sample file is given in section A2. Just substitute data c in the appropriate lines. Double precision is used. c c Function Fcomplex is written for a two layer system. The c main program defines one of these layers as having zero c thickness and having the same material parameters as c the other layer. c -------------------------------------------------------- c Nomenclature (not necessarily the same as in the standard) c D =diffusivity c k =conductivity c L =substrate thickness c lnth=heater length c b =heater half-width c b2 =heater full width c w =angular frequency at 2 omega c f =fundamental frequency c f2 =frequency at 2 omega c q =power input to specimen c T =measurement temperature c tr =substrate temperature signal at 2 omega c c -------------------------------------------------------- c define integration parameters for dqagi double precision, external :: fr c double precision, parameter :: bound=0.d0 double precision, parameter :: epsabs=1.d-6 double precision, parameter :: epsrel=1.d-12 integer, parameter :: inf=1 integer, parameter :: limit=1000 integer, parameter :: lenw=limit*4 integer, parameter :: idim=2 c double precision result, abserr, work(lenw), T double precision f, f2, b2 integer neval, ier, last, iwork(limit) character*30, label c -------------------------------------------------------- c common variables double precision w, b double precision d(idim), k(idim), L(idim) common w, d, k, L, b c double precision q, pi double precision tr, lnth c 1 format(A12) 2 format(A30) 3 format(6(1x,d13.6)) 4 format(1x,A33,D12.4) c -------------------------------------------------------- pi=4.d0*atan(1.d0) c -------------------------------------------------------- open(1,'input.par') c read (1,2) read(1,2) label ; read(1,*) f read(1,2) label ; read(1,*) q read(1,2) label ; read(1,*) b2 read(1,2) label ; read(1,*) lnth read(1,2) label ; read(1,*) L(1) read(1,2) label ; read(1,*) T c f2=2*f w=2.d0*pi*f2 b=b2/2.d0 c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c The thermal conductivity of Si as a function of c temperature is computed in the line 90 below. If another c material is wanted, replace line 90 90 k(1)=1.685d0-8.73d-3*T+3.62d-5*T*T-9.0d-8*T*T*T c The thermal diffusivity of Si as a function of the c thermal conductivity of Si is computed in line 96 below. c If another material is wanted, replace line 96. 96 D(1)=0.093d0+0.268d0*k(1)+0.180d0*k(1)*k(1) c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ write(*,4)'thermal conductivity of Si, W/cm/K ', k(1) write(*,4)'thermal diffusivity of Si, cm2/s ', D(1) k(2)=k(1) D(2)=D(1) L(2)=0.d0 c c -------------------------------------------------------- c Calculate the temperature variation c c calculate average temperature (real and imaginary) using c dqagi c call dqagi(fr,bound,inf,epsabs,epsrel,result, *abserr,neval,ier,limit,lenw,last,iwork,work) if (ier.gt.0) then call list(bound,inf,epsabs,epsrel,result, *abserr,neval,ier,limit,lenw,last,'fr') end if c tr=result*q/pi/lnth c write(*,4) 'substrate thermal signal ', tr c -------------------------------------------------------- close(2) end c c ******************************************************* function fr(x) c real part of integrand for dqagi double precision x, fr complex*8 fcomplex c fr=real(fcomplex(x)) return end function fr c c ******************************************************* function fcomplex(x) c c complex integrand for 2 layers in vacuum c c common variables double precision w, b double precision d(2), k(2), L(2) common w, d, k, L, b c double precision x complex*8 u(2), ea1, ea2 complex*8 ci, gp, gm, ex1, ex2, bp, bm, ftr, fcomplex c ci=(0,1.d0) u(1)=sqrt(x*x-ci*w/d(1)) u(2)=sqrt(x*x-ci*w/d(2)) gp=u(1)*k(1)+u(2)*k(2) gm=u(1)*k(1)-u(2)*k(2) ea1= 2.d0*u(1)*L(1) if (real(ea1).gt.160) then ex1=0.d0 else ex1= exp(-ea1) end if ea2= 2.d0*u(2)*L(2) if (real(ea2).gt.160) then ex2=0.d0 else ex2= exp(-ea2) end if bp=(gp*ex2 + gm)*ex1 bm=(gm*ex2 + gp) ftr=(bm+bp)/(bm-bp)/u(1)/k(1) if(x.eq.0.d0) then fcomplex=ftr else fcomplex=ftr*sin(x*b)*sin(x*b)/x/x/b/b end if c print*,'end of fcomplex' return end function fcomplex c c ******************************************************* subroutine list(bound,inf,epsabs,epsrel,result, *abserr,neval,ier,limit,lenw,last,ri) c double precision bound,epsabs,epsrel,result, *abserr,integer inf,limit,lenw,neval,ier,last character*2 ri c print*,'list parameters from dqagi call to ', ri print*, 'epsabs=', epsabs print*, 'epsrel=', epsrel print*, ' limit=', limit print*, 'result=', result print*, ' neval=', neval print*, ' ier=', ier print*, ' last=', last print*, ' ' return end subroutine list c ******************************************************* END PROGRAM 3omega
From: Michael Metcalf on 19 Apr 2007 19:59 Please note that this is a fixed source form program: labels must be in columns 1-5, a continuation mark in column 6, and the statements in columns 7-72. That's the first thing to check. The file suffix will normally have to be .f and not .f90 (which normally implies free form source). HTH Mike Metcalf
From: ben_nielsen20 on 19 Apr 2007 20:26 On Apr 19, 4:59 pm, "Michael Metcalf" <michaelmetc...(a)compuserve.com> wrote: > Please note that this is a fixed source form program: labels must be in > columns 1-5, a continuation mark in column 6, and the statements in columns > 7-72. That's the first thing to check. The file suffix will normally have to > be .f and not .f90 (which normally implies free form source). > > HTH > > Mike Metcalf Hi Mike, I have it down to one error for this line: open(1, 'input.par') It says "Error: Syntax error in open statement at (1) line 71, column 13 Any ideas??? Thanks, Ben
From: Dan Nagle on 19 Apr 2007 20:27 Hello, A quick glance suggests that the end following the close(2) should be a contains instead. Decide whether you want internal procedures (use contains) or separate procedures in the same file (use end and lose the end program on the last source line). ben_nielsen20(a)yahoo.com wrote: > Hello, > > I need some help, please!!! I'm a little clueless about Fortran. > I'm trying to get the following program to run using a compiler for > Windows I downloaded off here: > http://gcc.gnu.org/wiki/GFortranBinaries > Which also references another program located here: > http://gams.nist.gov/serve.cgi/Module/CMLIB/DQAGI/592/ > > There is also this small data input file: > 'file input.par' > 'fundamental frequency, Hz' > 333.0d0 > 'power, W' > 7.52d-3 > 'line full width, cm' > 1.83d-3 > 'line length, cm' > 0.4d0 > 'thickness Si, cm' > 0.072d0 > 'measurement temp. T2, deg c' > 23.5d0 > > It doesn't seem to want to run either a "&" or a "*" for a line > continuation. There are also a number of other errors. > > Thanks, > B > > > PROGRAM 3omega > c version 1, 01-Nov-2001 > c Calculate real temperature variation at a given frequency > c for a silicon plate heated by a thin metal strip. > c The calculation can be applied to plates composed of > c material other than silicon if the thermal conductivity > c and thermal diffusivity of that material are substituted > c in the indicated lines below. > c This is used for analyzing data obtained by the 3 omega > c method > c > c library routine 'dqagi' used for integration > c -------------------------------------------------------- > c A data file named 'input.par' written in ASCII is needed > c > c A sample file is given in section A2. Just substitute data > c in the appropriate lines. Double precision is used. > c > c Function Fcomplex is written for a two layer system. The > c main program defines one of these layers as having zero > c thickness and having the same material parameters as > c the other layer. > c -------------------------------------------------------- > c Nomenclature (not necessarily the same as in the standard) > c D =diffusivity > c k =conductivity > c L =substrate thickness > c lnth=heater length > c b =heater half-width > c b2 =heater full width > c w =angular frequency at 2 omega > c f =fundamental frequency > c f2 =frequency at 2 omega > c q =power input to specimen > c T =measurement temperature > c tr =substrate temperature signal at 2 omega > c > c -------------------------------------------------------- > c define integration parameters for dqagi > double precision, external :: fr > c > double precision, parameter :: bound=0.d0 > double precision, parameter :: epsabs=1.d-6 > double precision, parameter :: epsrel=1.d-12 > integer, parameter :: inf=1 > integer, parameter :: limit=1000 > integer, parameter :: lenw=limit*4 > integer, parameter :: idim=2 > > c > double precision result, abserr, work(lenw), T > double precision f, f2, b2 > integer neval, ier, last, iwork(limit) > character*30, label > c -------------------------------------------------------- > c common variables > double precision w, b > double precision d(idim), k(idim), L(idim) > common w, d, k, L, b > c > double precision q, pi > double precision tr, lnth > c > 1 format(A12) > 2 format(A30) > 3 format(6(1x,d13.6)) > 4 format(1x,A33,D12.4) > c -------------------------------------------------------- > pi=4.d0*atan(1.d0) > c -------------------------------------------------------- > open(1,'input.par') > c > read (1,2) > read(1,2) label ; read(1,*) f > read(1,2) label ; read(1,*) q > read(1,2) label ; read(1,*) b2 > read(1,2) label ; read(1,*) lnth > read(1,2) label ; read(1,*) L(1) > read(1,2) label ; read(1,*) T > c > f2=2*f > w=2.d0*pi*f2 > b=b2/2.d0 > c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > c The thermal conductivity of Si as a function of > c temperature is computed in the line 90 below. If another > c material is wanted, replace line 90 > > 90 k(1)=1.685d0-8.73d-3*T+3.62d-5*T*T-9.0d-8*T*T*T > > c The thermal diffusivity of Si as a function of the > c thermal conductivity of Si is computed in line 96 below. > c If another material is wanted, replace line 96. > > 96 D(1)=0.093d0+0.268d0*k(1)+0.180d0*k(1)*k(1) > > c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > write(*,4)'thermal conductivity of Si, W/cm/K ', k(1) > write(*,4)'thermal diffusivity of Si, cm2/s ', D(1) > k(2)=k(1) > D(2)=D(1) > L(2)=0.d0 > c > c -------------------------------------------------------- > c Calculate the temperature variation > c > c calculate average temperature (real and imaginary) using > c dqagi > c > call dqagi(fr,bound,inf,epsabs,epsrel,result, > *abserr,neval,ier,limit,lenw,last,iwork,work) > if (ier.gt.0) then > call list(bound,inf,epsabs,epsrel,result, > *abserr,neval,ier,limit,lenw,last,'fr') > end if > c > tr=result*q/pi/lnth > c > write(*,4) 'substrate thermal signal ', tr > c -------------------------------------------------------- > close(2) > end > c > c ******************************************************* > function fr(x) > c real part of integrand for dqagi > double precision x, fr > complex*8 fcomplex > c > fr=real(fcomplex(x)) > return > end function fr > c > c ******************************************************* > function fcomplex(x) > c > c complex integrand for 2 layers in vacuum > c > c common variables > double precision w, b > double precision d(2), k(2), L(2) > common w, d, k, L, b > c > double precision x > complex*8 u(2), ea1, ea2 > complex*8 ci, gp, gm, ex1, ex2, bp, bm, ftr, fcomplex > c > ci=(0,1.d0) > u(1)=sqrt(x*x-ci*w/d(1)) > u(2)=sqrt(x*x-ci*w/d(2)) > gp=u(1)*k(1)+u(2)*k(2) > gm=u(1)*k(1)-u(2)*k(2) > ea1= 2.d0*u(1)*L(1) > if (real(ea1).gt.160) then > ex1=0.d0 > else > ex1= exp(-ea1) > end if > ea2= 2.d0*u(2)*L(2) > if (real(ea2).gt.160) then > ex2=0.d0 > else > ex2= exp(-ea2) > end if > bp=(gp*ex2 + gm)*ex1 > bm=(gm*ex2 + gp) > ftr=(bm+bp)/(bm-bp)/u(1)/k(1) > if(x.eq.0.d0) then > fcomplex=ftr > else > fcomplex=ftr*sin(x*b)*sin(x*b)/x/x/b/b > end if > c print*,'end of fcomplex' > return > end function fcomplex > c > c ******************************************************* > subroutine list(bound,inf,epsabs,epsrel,result, > *abserr,neval,ier,limit,lenw,last,ri) > c > double precision bound,epsabs,epsrel,result, > *abserr,integer inf,limit,lenw,neval,ier,last > character*2 ri > c > print*,'list parameters from dqagi call to ', ri > print*, 'epsabs=', epsabs > print*, 'epsrel=', epsrel > print*, ' limit=', limit > print*, 'result=', result > print*, ' neval=', neval > print*, ' ier=', ier > print*, ' last=', last > print*, ' ' > return > end subroutine list > c ******************************************************* > END PROGRAM 3omega > -- Dan Nagle Purple Sage Computing Solutions, Inc.
From: glen herrmannsfeldt on 19 Apr 2007 21:35
ben_nielsen20(a)yahoo.com wrote: > I need some help, please!!! I'm a little clueless about Fortran. > I'm trying to get the following program to run using a compiler for First, the * for continuation MUST be in column 6. Yours seem to be somewhere between 5 and 7. (snip) > PROGRAM 3omega Program names, like variable names, start with a letter. (snip) > open(1,'input.par') open(1,file='input.par') (snip) > END PROGRAM 3omega Remove this statement. The main program ended many lines ago. If the compiler actually does believe this, it gives you a second main program that doesn't do anything. Also, you don't need the apostrophe's on the input data if you are reading it in A format. If you do list directed read, you probably do need them, but you aren't doing that. -- glen |