Spring, 2025
Jewett
Computer Program #1 ATMS 502 / CSE 566
Numerical Fluid Dynamics
Updated Wed. 2/12/2025; updates are in red

Description and Overview

  • Problem: 1-D linear and nonlinear advection
    • Method: Lax-Wendroff
    • Flow field: constant (for linear cases), nonlinear in third case.
    • Evaluation: save and plot maximum absolute value vs. time
    • Initial condition: Sine curve
    • Boundary conditions: periodic
  • Images fixed now - you should be able to see test case plots
  • My "run" script is on Keeling - copy from ~bjewett/502/Pgm1/run
  • Problem assignment handout: ComputerProb1.pdf (PDF, contains official problem settings)
  • Program-1 starting codes: See these on Keeling at ~bjewett/502/Pgm1
  • Deadline extended: 9 pm Friday Feb. 14, 2025
    -- submit on Canvas - there is a place under Programs to do so now.
  • FAQ/Questions+Answers section is at the bottom of this page

Getting started on program #1

  1. To use X-windows/x11 graphics:
    • There are a few steps to do before logging in; you need x11 graphics software.
    • Linux PC: this capability should be built-in and ready to go.
    • Mac: you need to install the free software Xquartz.
      • You can/should start Xquartz once to make sure it works, but it should start on its own in the future when needed. I am using version 2.8.5 .
      • See the connection description below; you will need to type ssh -X or ssh -Y for x11-forwarding to work when you connect using Terminal or iTerm2.
    • Windows:
      1. If using MobaXterm - I believe the x11 capability is built-in
      2. If using Xshell - Get and install the Xming X Server for windows (free), and start Xming before connecting with Xshell. Note that starting Xming ... works, but you won't see anything happen - yet!
      3. Xshell (continued) - you need to configure your login settings for Keeling to do graphics Tunneling also known as X11 Forwarding in Xshell. If you already created a Session in Xshell to connect to Keeling, go back, right-click on the Keeling Session on the left side of your Xshell window, and select Properties at the bottom. When the "Properties of [new session]" window appears, look for Category: Connection > SSH > Tunneling. Click on the round button to choose X DISPLAY: instead of Xmanager. Then click OK to save the settings. Now when you connect to Keeling with Xshell, you should be able to use x11 graphics.

  2. Connect to Keeling with Xshell (on Windows), or type the following in a Linux window or Terminal / iTerm2 (on a Mac):

                ssh   -Y   yourNetID@keeling.earth.illinois.edu

    Note that:

    • On Linux, ssh -X is recommended instead of ssh -Y. Info: ssh -X vs. -Y
    • If you are off campus in a cafe, apartment or private jet, you must first connect with the campus VPN software before you can connect to Keeling.
    • Using the Cisco Secure Client i.e. VPN software is a good idea on any public internet like that in a cafe.
    • If on a Mac, when installing the VPN software, choose Not to allow the Cisco network filtering to run. Your Mac should ask you whether to allow it after you install it. This network filtering software apparently interferes with the Mac OS, and is unnecessary.

  3. Once logged in, type these Linux commands:
    • cd    (takes you to home directory)
    • mkdir  atms502  (make class directory)
    • cd  atms502      (change to class directory)
    • mkdir  pgm1  (make subdirectory)
    • cd  pgm1     (change to subdirectory)
    • pwd    (print working directory)
  4. Now copy the Program 1 files from my Keeling directory:
    • For Fortran:  cp  ~bjewett/502/Pgm1/Fortran/*  .    (don't omit this trailing dot "." !!)
    • For C:    cp  ~bjewett/502/Pgm1/C/*  .    (don't omit this trailing dot "." !!)
  5. If you have not yet done so, run this command: to get NCAR command language tools:   module load ncl
    • This fixes the "ncargcc/ncargf90 not found" error.
    • To avoid having to type this every time you login, go to your home directory (cd), and edit your Linux settings file ".profile" (e.g. with the nano text editor), and put module load ncl in there.
  6. Compile the code by typing:  make
    It is necessary - before doing make - to run: source ~bjewett/502/INTEL to acquire the necessary code building tools.
  7. Run it by typing:  pgm1   (if that doesn't work, try putting a dot and slash first: ./pgm1 )
  8. A plot file is generated called  gmeta  (do "ls" to see if it exists)
  9. Convert this plot file to a .zip file of GIFs:
           ~bjewett/502/Tools/metagif    gmeta  -all   -zip
  10. Send this .zip file to your PC
    • You can do this with tools like Xftp, FileZilla etc.
    • Or, if the (.zip) file isn't too large, use linux Mail (mail with a capital "M")
          Mail   -a   gmeta.zip  yourNetID@illinois.edu
                the "-a" option is used to send an email Attachment
                enter a subject if you wish, and type control-D to Send the Mail message.

Original code results - without changes - solutions damps

The program 1 code can and should be compiled and run as is, with no changes, first.

I used these settings:
  1. Number of grid points: NX = 25 (this is the default)
  2. Courant number to use: 0.5
  3. Number of steps to run: 50
  4. Plot interval set to: 5
  5. Linear or nonlinear: L (linear)
Plots of the initial condition, solution at 10 and 20 steps, time trace of max absolute value and 3rd time-space plot are shown below for Fortran and C. These were with the default (no extra compile settings) OPTIONS in the Makefile.  Click on any image below for a full-sized view.
Follow these links to see the text output from the (unmodified program 1 files) code for Fortran or  C.


Step 0 (IC) Step 10 Step 20 Smax(t) Space/time plot
Fortran
C

Fortran test case results - with changes

In the results shown below I have left the grid point count at 25 but have modified the code, namely:
  • added the two lines to implement periodic boundaries in the bc routine;
  • altered the advection.f90 file for Lax-Wendroff for linear and nonlinear cases

To test your code, fix your bc.f90 and advection.f90 routines and run the code, still with NX=25.
Remember to change the grid point count NX to 125 before running the official problem to plot and hand in!!!!
For these test cases, nx should be left at 25.
Set the plot frequency to be as often as you wish (e.g. every step).

The parameters used:

  • Case A: Courant number 0.5; run 50 steps; Linear.
  • Case B: Courant number 1.5; (try to) run 20 steps; Linear.
  • Case C: Courant number: I entered 1; run 20 steps; Nonlinear.

    Fortran results
    Test Case A
    Step 0

    Step 25

    Step 50

    Smax(t)

    Space/time
    Test Case B
    Step 0

    Step 8

    Step 14

    Smax(t)

    Space/time
    Test Case C
    Step 0

    Step 4

    Step 12

    Smax(t)

    Space/time

    C test case results

    The C results differ in slight ways from Fortran. The general behavior is the same.
    All parameters are the same as for the Fortran test cases above.

    C results
    Test Case A
    Step 0

    Step 25

    Step 50

    Smax(t)

    Space/time
    Test Case B
    Step 0

    Step 8

    Step 14

    Smax(t)

    Space/time
    Test Case C
    Step 0

    Step 4

    Step 12

    Smax(t)

    Space/time



Frequently asked - and new - Questions & Answers - most recent first. 

I suggest you reload this page when checking this section, to make sure you see the latest additions.
  1. I'm having problems compiling.  I receive error messages like ncargf90: Command not found

    This means your account needs to be fixed to use NCAR Graphics.  This only needs to be done once,
    and is easy to do.  On Keeling, do: module load ncl


    ========================== Earlier questions ==========================

  2. I'm having difficulties compiling my program ...

    Make sure you are using the Makefile provided with the code.
    To compile program #1, you type  "make" .
    It is necessary - before doing make - to run: source ~bjewett/502/INTEL to acquire the necessary code building tools.

  3. When trying to display my plots I receive the message "Error: Can't open display:"

    Make sure you use "-Y" if connecting to Keeling from linux, e.g.

          ssh  -X  yourname@keeling.earth.illinois.edu

    Mac users:  use the same command above from the Terminal window.  Make sure you have a X11-client! 
         If not, it is free and you can install it on your Mac.

  4. What "courant number" do I specify for the nonlinear part, i.e. case C -- for the purposes of computing the time step dt?
  1. How do I print off my plots?
  1. "I am running C rather than Fortran, and get slightly different results..."