Prev: Libraries on Linux
Next: Write to file from DLL
From: John Harper on 22 Apr 2007 18:02 In article <1177045735.343912.80750(a)n76g2000hsh.googlegroups.com>, mintoo <varun.tangri(a)gmail.com> wrote: >i am not an expert but, i noticed one thing: > >open(1,'input.par') > I notice three things there. (1) open(1,file='input.par') is the standard Fortran ever since 1977. (3) Some systems use unit number 1 for special purposes; it may be safer to make sure you use a number that is not already in use for something else. 5 and 6 often are. Years ago our graphics package was Disspla, which used several unit numbers for its own purposes, and one got weird errors by using them for one's own. (2) If you're using free source form (often a program file name ending .f90) a Fortran statement may start in position 1 on the line, but if you're using fixed source form (often a program name ending .f) then every statement must start in or after position 7 and end in or before position 72. RTFM for what may go in positions 1-6. -- John Harper, School of Mathematics, Statistics and Computer Science, Victoria University, PO Box 600, Wellington 6140, New Zealand e-mail john.harper(a)vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
From: ben_nielsen20 on 23 Apr 2007 13:31 Does anyone know why this program won't run?: 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,file='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 ******************************************************* Is it a problem with the way I'm saving it in Notepad? If I save it as an ANSI file I get this error: C:\gfortran\bin>gfortran 3omega.f gfortran: CreateProcess: No such file or directory If I save it as Unicode I get this error: C:\GFORTRAN\BIN>gfortran 3omega.f 3omega.f:1.1: \xFF\xFEc version 1, 01-Nov-2001 1 Error: Non-numeric character in statement label at (1) 3omega.f:1.2: \xFF\xFEc version 1, 01-Nov-2001 1 Error: Invalid character in name at (1) Thanks, Ben
From: ben_nielsen20 on 23 Apr 2007 14:02 Thanks everyone for your help, but unfortunately I still haven't been able to get my program to run. Can anyone tell me why it won't run as it appears below? Is it a problem with the way I'm saving it in Notepad? If I save it as an ANSI file I get this error: C:\gfortran\bin>gfortran 3omega.f gfortran: CreateProcess: No such file or directory If I save it as a Unicode file I get this error: C:\gfortran\bin>gfortran 3omega.f 3omega.f:1.1: \xFF\xFEc version 1, 01-Nov-2001 1 Error: Non-numeric character in statement label at (1) 3omega.f:1.2: \xFF\xFEc version 1, 01-Nov-2001 1 Error: Invalid character in name at (1) 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,file='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 *******************************************************
From: Brooks Moses on 23 Apr 2007 14:34 ben_nielsen20(a)yahoo.com wrote: > Thanks everyone for your help, but unfortunately I still haven't been > able to get my program to run. Can anyone tell me why it won't run as > it appears below? Is it a problem with the way I'm saving it in > Notepad? > > If I save it as an ANSI file I get this error: > > C:\gfortran\bin>gfortran 3omega.f > gfortran: CreateProcess: No such file or directory This looks like an installation problem of some sort. The "gfortran" program calls a number of other programs to do the actual compilation, assembly, and linking. The error for the Unicode file indicates that the compilation part is running correctly, but perhaps the assembler or linker hasn't been installed. At a rough guess, perhaps there's a MinGW "binutils" package that GFortran depends on, which you haven't installed? If you try compiling a basic "Hello, World" program, do you get the same error? > If I save it as a Unicode file I get this error: > > C:\gfortran\bin>gfortran 3omega.f > 3omega.f:1.1: > > \xFF\xFEc version 1, 01-Nov-2001 > 1 > Error: Non-numeric character in statement label at (1) > 3omega.f:1.2: > > \xFF\xFEc version 1, 01-Nov-2001 > 1 > Error: Invalid character in name at (1) This is the expected error; GFortran doesn't currently understand Unicode files. - Brooks -- The "bmoses-nospam" address is valid; no unmunging needed.
From: FX on 23 Apr 2007 15:27
> If I save it as an ANSI file This is the right thing to do. > I get this error: > > C:\gfortran\bin>gfortran 3omega.f > gfortran: CreateProcess: No such file or directory This is an unexpected error. Can you indicate which gfortran version you have (output of "gfortran -v") and what is the setting of your PATH environment variable (quoting from memory, this should be given by "set PATH")? That bug has been reported and I thought I had it fixed in recent binaries ("recent" meaning "less than two weeks old"). -- FX |