# p1demo_code - Aug. 29, 2006 ATMS 502 - CS 505 - CSE 566...

This preview shows pages 1–3. Sign up to view the full content.

1 Aug. 29, 2006 ATMS 502 - CS 505 - CSE 566 Jewett Computer program 1 - ATMS 502 - Demo code (FORTRAN first, C code begins on page 3) c c ATMS 502 Fall, 2006 Program 1 c Linear and nonlinear advection c c Compile with: "ncargf77 p1demo.f" c You'll need the following in your home .cshrc file: c setenv NCARG_ROOT /afs/ncsa/packages/ncar/AIX32_5.1 c set path = (\$NCARG_ROOT \$path) c program pgm1 implicit none c c . .. Definitions ................................................... c logical linear integer nx,maxstep parameter (nx = 25, maxstep = 200, linear = .true.) c . .. Arrays real u1(0:nx+1),u2(0:nx+1) real utrace(maxstep),c,dt,dx,courant,umax integer i,n,nstep,nplot c . .. Variables for run history integer worksize parameter (worksize = 2*nx*maxstep+nx+maxstep) real history(nx,maxstep) real workarray(worksize) c c . .. Parameters and input .......................................... c c = 1. dx = 0.1 print*,'Enter courant number:' read*,courant dt = courant*dx/c print*,'Number of steps for one complete loop =', > ( dx*real(nx) / c / dt ) print*,'Enter number of time steps:' read*,nstep print*,'Enter plot interval, in steps:' read*,nplot c c . .. Open the graphics package and set plot bounds c . .. To invert black/white colors, omit the two "gscr" calls. c call opngks call gscr(1,0,1.,1.,1.) call gscr(1,1,0.,0.,0.) call anotat('I','U',0,0,0,0) call agsetf('Y/MINIMUM.',-1.2) call agsetf('Y/MAXIMUM.', 1.2) c c . .. Set and plot the initial condition c call ic(u1,dx,nx) call stats(u1,nx,0,umax) call doplot(u1,nx,0,umax) c c . .. Integrate ..................................................... c do n = 1,nstep c . . . . Set boundary conditions call bc(u1,nx) c . . . . Compute values at next step call integrate(u1,u2,c,dx,dt,nx,linear) c . . . . Do array update at end of time step. call update(u1,u2,nx) c . . . . Copy latest solution u2(1:nx) to history array. history(1:nx,n) = u2(1:nx) c . . . . Stats call stats(u2,nx,n,umax) utrace(n) = umax c . . . . Plot fields when needed if (mod(n,nplot).eq.0) then call doplot(u2,nx,n,umax) endif c . . . . Check if problem out of bounds if (umax.gt.1.5) then print*,'Stop - solution blowing up at step',n call doplot(u2,nx,n,umax) nstep = n go to 100 endif enddo c c . .. Run complete - do final plots ................................. c 100 continue c . .. Plot Umax(t) call agsetf('Y/MIN.',0.) call agsetf('Y/MAX.',1.5) call anotat('STEP','Umax',0,0,0,0) call ezy(utrace,nstep,'Umax vs. time') c . .. Plot history surface u(x,t) call ezsrfc(history,nx,nstep,-90., 0.,workarray) call ezsrfc(history,nx,nstep,-30.,20.,workarray)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 c c . .. Close graphics package and stop. c
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/06/2009 for the course ATMOSPHERI 502 taught by Professor Jewett during the Fall '09 term at University of Illinois at Urbana–Champaign.

### Page1 / 5

p1demo_code - Aug. 29, 2006 ATMS 502 - CS 505 - CSE 566...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online