Language Issues - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Language Issues

Description:

T--end time. Designing Cbasics. Get name of command file (user or command line) Read command file and get m, L, dt, T. Create a length m array C ... – PowerPoint PPT presentation

Number of Views:11
Avg rating:3.0/5.0
Slides: 9
Provided by: andrewjp5
Category:

less

Transcript and Presenter's Notes

Title: Language Issues


1
Language Issues
Misunderstimated? Sublimable? Hopefuller? "I
know how hard it is for you to put food on your
family. "I know the human being and fish can
coexist peacefully."
2
Outline
  • Announcements
  • HW1 due Friday
  • Developing RAD1D
  • Lab

3
Designing RAD1
  • Get C0, u, k, dt,t, T, m, L (dxL/(m-1)) from
    user
  • Build matrix A using k, dt, dx
  • Build RHS vector f using u, k, and reaction data
  • Solve ACb for C
  • ttdt
  • If(tltT)
  • Copy CC0
  • Change u and k if needed
  • Repeat 2-6
  • Else
  • d) Output C and quit

4
Getting Info From User
  • Need several parameter values a file name
  • Options
  • Query user?
  • Values in a file pass file name?
  • Cbasic basic.cmnd
  • I like option 3

5
Command File
  • m--number of grid points
  • L--length of the domain
  • dt--time step
  • T--end time

6
Designing Cbasics
  • Get name of command file (user or command line)
  • Read command file and get m, L, dt, T
  • Create a length m array C
  • Fill array with location of grid points
  • Save C to C.txt

7
Structure of Cbasics
  • Main.c--main program
  • Io.c--functions for input/output
  • ReadComm
  • ReportParams
  • PrintArray
  • System.c--functions for array allocation error
    reporting
  • Error
  • newarray_double

8
Prototypes Header files
  • C subroutines must declare the types of their
    inputs and outputs using prototypes
  • double sin(double angle_in_radians)
  • void PrintArray(char name, double C, int m)
  • Prototypes allow the compiler to check that you
    are calling a routine in the correct way
  • Suppose subroutine X is implemented in file X.c.
    In order to call X from another file (Y.c), Y
    needs to see the prototype for X.
  • Solution--create a header file with the prototype
  • X.c--implements X
  • X.h--prototype for X
  • Both X.c and Y.c must include X.h
  • include X.h must appear before any call to X
    or its implementation
Write a Comment
User Comments (0)
About PowerShow.com