Presentation is loading. Please wait.

Presentation is loading. Please wait.

Language Issues Misunderstimated? Sublimable? Hopefuller?

Similar presentations


Presentation on theme: "Language Issues Misunderstimated? Sublimable? Hopefuller?"— Presentation transcript:

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 (dx=L/(m-1)) from user
Build matrix A using k, dt, dx Build RHS vector f using u, k, and reaction data Solve A*C=b for C t=t+dt If(t<T) Copy C=C0 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


Download ppt "Language Issues Misunderstimated? Sublimable? Hopefuller?"

Similar presentations


Ads by Google