![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Hello
firstly this code is for those who familiar with MPI message passing routine. this code generally is for solving linear equation system using gauss-seidel iteration method using C and MPI routines. there some syntax error. can anyone help me identify it and tell me how to correct it I was using visual c++ 6.0. I've already attached workspace containing the code and a manual. i can provide you mpi tool (mpich.nt.1.2.5) needed just email me at trainz13@yahoo.com CPP / C++ / C Code:
error: Compiling... Gauss_Seidel.cpp C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(104) : warning C4091: '' : ignored on left of 'float' when no variable is declared C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(104) : error C2143: syntax error : missing ';' before 'constant' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(127) : error C2065: 'n_bar' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(167) : error C2106: '=' : left operand must be l-value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(168) : error C2065: 'max_iterations' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(196) : error C2065: 'done' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(196) : error C2065: 'TRUE' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(202) : error C2065: 'ELEMENT_MAX' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(203) : error C2562: 'main' : 'void' function returning a value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(78) : see declaration of 'main' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(210) : error C2562: 'main' : 'void' function returning a value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(78) : see declaration of 'main' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(213) : error C2065: 'memcpy' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(217) : error C2562: 'main' : 'void' function returning a value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(78) : see declaration of 'main' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(224) : error C2065: 'x' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(224) : error C2065: 'k' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(224) : error C2501: 'MPI_Allgather' : missing storage-class or type specifiers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(224) : error C2373: 'MPI_Allgather' : redefinition; different type modifiers c:\program files\mpich\sdk\include\mpi.h(378) : see declaration of 'MPI_Allgather' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(224) : error C2078: too many initializers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(225) : error C2065: 'temp' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(225) : error C2501: 'MPI_Gather' : missing storage-class or type specifiers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(225) : error C2373: 'MPI_Gather' : redefinition; different type modifiers c:\program files\mpich\sdk\include\mpi.h(374) : see declaration of 'MPI_Gather' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(225) : error C2078: too many initializers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(226) : error C2143: syntax error : missing ';' before 'if' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(227) : error C2143: syntax error : missing ';' before '{' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(227) : error C2447: missing function header (old-style formal list?) C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(234) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(234) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(234) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(239) : error C2143: syntax error : missing ';' before 'if' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(240) : error C2143: syntax error : missing ';' before '{' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(240) : error C2447: missing function header (old-style formal list?) C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(252) : error C2143: syntax error : missing ';' before 'else' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(257) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(257) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(257) : error C2143: syntax error : missing ';' before '}' Error executing cl.exe. Gauss_Seidel.obj - 33 error(s), 1 warning(s) |
|
#2
|
|||
|
|||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Quote:
That's OK; it's probably the best plan anyhow. My point is that you have a better chance of getting a helpful response with fewer iterations if you give us all of the information right away. Why make us ask for more? I'm guessing that, for one thing, you have made mistakes in commenting out blocks of code. (For example, commenting out the beginning brace '{' of a block but not commenting out the closing brace '}' or some such thing.) Here's a suggestion: Make a copy of the code as you have shown it. Then with your text editor, delete all of the comments and compile the copy. If you can't see where the problem is, then: 1. Post the code that you are compiling. 2. Tell us what compiler you are using. Sometimes it makes a difference to people who want to help. 3. Paste the exact error messages into your post so that we can see what you are seeing. Don't edit the messages; don't paraphrase; show us the exact message (line number and all). For what it is worth: A little technique that I use to comment out blocks of code instead of /* */: CPP / C++ / C Code:
Regards, Dave Footnote: Quote:
I get USD400 an hour for one-on-one consulting. Minimum 40 hours plus expenses. Travel extra. (It may or may not be worth the price.) ---davekw7x (Just kidding.) |
|
#3
|
|||
|
|||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Quote:
I've removed unnecessary code.the workspace only worked with Microsoft Visual C++ CPP / C++ / C Code:
Error: --------------------Configuration: ASSIGN2 - Win32 Debug-------------------- Compiling... Gauss_Seidel.cpp C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(98) : error C2086: 'i' : redefinition C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(118) : error C2065: 'n_bar' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(130) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(131) : error C2065: 'max_iterations' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(159) : error C2065: 'done' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(159) : error C2065: 'TRUE' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(165) : error C2065: 'ELEMENT_MAX' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(166) : error C2562: 'main' : 'void' function returning a value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(77) : see declaration of 'main' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(173) : error C2562: 'main' : 'void' function returning a value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(77) : see declaration of 'main' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(176) : error C2065: 'memcpy' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(180) : error C2562: 'main' : 'void' function returning a value C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(77) : see declaration of 'main' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(183) : error C2065: 'x' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(183) : error C2065: 'k' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(183) : error C2501: 'MPI_Allgather' : missing storage-class or type specifiers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(183) : error C2373: 'MPI_Allgather' : redefinition; different type modifiers c:\program files\mpich\sdk\include\mpi.h(378) : see declaration of 'MPI_Allgather' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(183) : error C2078: too many initializers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(184) : error C2065: 'temp' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(184) : error C2501: 'MPI_Gather' : missing storage-class or type specifiers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(184) : error C2373: 'MPI_Gather' : redefinition; different type modifiers c:\program files\mpich\sdk\include\mpi.h(374) : see declaration of 'MPI_Gather' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(184) : error C2078: too many initializers C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(185) : error C2143: syntax error : missing ';' before 'if' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(186) : error C2143: syntax error : missing ';' before '{' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(186) : error C2447: missing function header (old-style formal list?) C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(193) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(193) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(193) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(196) : error C2143: syntax error : missing ';' before 'if' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(197) : error C2143: syntax error : missing ';' before '{' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(197) : error C2447: missing function header (old-style formal list?) C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(209) : error C2143: syntax error : missing ';' before 'else' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(214) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(214) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(214) : error C2143: syntax error : missing ';' before '}' Error executing cl.exe. Gauss_Seidel.obj - 32 error(s), 1 warning(s) |
|
#4
|
|||||||
|
|||||||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Quote:
OK: Let's start fresh. Look at the messages, then look at the code. Sometimes compiler messages are not very clear (especially when you haven't seen them a million times before), but just looking can (sometimes) lead to enlightenment. And, by the way, sometimes they are quite clear. Look at the first message: Quote:
CPP / C++ / C Code:
CPP / C++ / C Code:
Next message: Quote:
Line 118 is in main(): CPP / C++ / C Code:
Is there a variable named n_bar that is declared anywhere in the program such a way as it is visible in main()? Quote:
Quote:
Based on my previous comment about n_bar, what would you think that this means? Ditto for any similar messages. Quote:
CPP / C++ / C Code:
My advice: change the declaration to CPP / C++ / C Code:
Quote:
Other errors are mostly concerning the mpi stuff, and you should be able to dig them out once you get used to the idea of looking at the messages and looking at the code. While you are in the neighborhood of line 183, looking at numerous not-so-clear messages, look at the code just before and just after: CPP / C++ / C Code:
The closing brace, '}', after the return iteration; statement appears to be the end of main(). At least I think it is, and maybe the compiler thinks so, too. Carefully count to see if the braces are matched, starting with the opening brace, '{', at the start of main(). I feel that a number of the other syntax errors are the result of unmatched braces in your control blocks. Regards, Dave Last edited by davekw7x : 01-May-2007 at 13:40.
|
|
#5
|
||||
|
||||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Quote:
It's not you. The post was edited, and there is no "Last edited..." comment. I know it happened to me when I edited my own post in a short period of time, without filling anything into the "Reason for editing" box. I always assumed it was because I was a mod. Perhaps not, or perhaps there was a little bug? If you feel like experiencing (you know, for science!), perhaps you could try editing one of your own posts with/without giving a reason for editing. I can't experiment since I may be on another another privilege level. Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#6
|
|||
|
|||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Quote:
Thanks, Lucien, for the feedback. Sometimes I miss things from posts and give snappy retorts when they aren't warranted, and I regret it later. I had just edited my own (within a few minutes of original post) and there is no "Last edited..." on that one either. I never noticed that before. I usually revisit my posts a little later to try to catch typos, etc., (and sometimes to temper the rhetoric) but rarely change significant content. And if I do make significant changes, I usually put something like the following to try to make the editing obvious: [edit]comment here [/edit] And as a test I just edited something from an hour or so ago, and I see the "Last edited..." message. I just never noticed that that didn't appear with "soon-after" edits. Regards, Dave |
|
#7
|
|||
|
|||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)I still can't understand, i've already declared the identifier, why it's still say that the identifier is still undeclared.
i try fix the code but there still some i can't understand. i was using floating point instead of double because i wan't the output will be view as 0.00000. i want the precise solution. i send the screen shot on how the program will be look a alike CPP / C++ / C Code:
Error: --------------------Configuration: ASSIGN2 - Win32 Debug-------------------- Compiling... Gauss_Seidel.cpp C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(129) : error C2440: '=' : cannot convert from 'float [12]' to 'float' There is no context in which this conversion is possible C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(131) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(132) : error C2065: 'max_iterations' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(160) : error C2065: 'done' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(160) : error C2065: 'TRUE' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(166) : error C2065: 'ELEMENT_MAX' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(187) : error C2065: 'iteration_num' : undeclared identifier C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(194) : error C2143: syntax error : missing ';' before 'while' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(196) : error C2143: syntax error : missing ';' before 'if' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(197) : error C2143: syntax error : missing ';' before '{' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(197) : error C2447: missing function header (old-style formal list?) C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(209) : error C2143: syntax error : missing ';' before 'else' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(214) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(214) : error C2143: syntax error : missing ';' before '}' C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(214) : error C2143: syntax error : missing ';' before '}' Error executing cl.exe. Gauss_Seidel.obj - 14 error(s), 1 warning(s) C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(129) : error C2440: '=' : cannot convert from 'float [12]' to 'float' There is no context in which this conversion is possible C:\Documents and Settings\DANTE\Desktop\Gauss_Seidel.cpp(131) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data i don't understand, how to fix this. i can't find any missing ";" before }, where it's Dave or anyone could you explain or at least fix the code for me |
|
#8
|
|||||||||
|
|||||||||
Re: MPI with C (Solving Linear Equation using Gauss-Seidel Iteration)Quote:
Quote:
Quote:
Quote:
CPP / C++ / C Code:
Quote:
Quote:
Quote:
I have already told you: The {} braces are unmatched. Somewhere around line 193, the compiler thinks that it has reached the end of main(). (In fact the compiler [i]has[i] reached the end of main()). Here's how to count braces: Go to the first opening brace, '{', of a function. Count is equal to 1. Now, as you go through each line in a function, increment the count for each opening brace '{'. Decrement the count for each closing brace, '}'. If the count ever goes below zero, you have too many closing braces. If you reach what you think is the end of the function but the count is not zero after the last closing brace, then STOP. That function has unmatched braces and must be fixed before going on to the next. Quote:
Quote:
It's your program, and I have no personal stake in "fixing" it. On the other hand if you are willing to participate in your own education, there are lots of people who would like try to help. Regards, Dave |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| paralllel programming using MPI - linear equation using jacobi | eclipt | C++ Forum | 0 | 04-May-2006 20:02 |
| MPI - linear pipeline solution for jacobi iteration | eclipt | C++ Forum | 0 | 03-May-2006 05:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The