TinyURL widget - shorten your URL's for free!

Enter a long URL to make tiny:

Friday, December 16, 2016

OpenMPI working nameserver publish / lookup example

This blog post entails a simple client / server example using OpenMPI, the opmi-server, and simple commands to publish a named server, lookup the server using a client, then connect and transceive data between the server and client.

If you need a refresher on OpenMPI first then this is a good start. 


The Gist is located here. 


I got this working on:

 uname -a
Linux hellion 3.19.0-77-generic #85-Ubuntu SMP Fri Dec 2 03:43:54 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

mpicc --version
gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This post assumes you've got the OpenMPI installed completely and working properly.


This builds on pseudo-examples left here and mainly here: http://www.mcs.anl.gov/research/projects/mpi/mpi-standard/mpi-report-2.0/node106.htm#Node108

You compile the client and server:

The client is here

https://gist.github.com/DaemonDave/21fea476847d94326ec6c9664c15fb87#file-name-client-c 




 mpicc -o client name-client.c
 The server is here

https://gist.github.com/DaemonDave/21fea476847d94326ec6c9664c15fb87#file-name-server-c

mpicc -o server  name-server.c


You run the ompi-server first, to establish the name server. But to do this you run mpirun with ompi-server and not just run it.

*!
 \brief How to execute mpi name server
 mpirun -np 1  ompi-server --no-daemonize -r + &
 *
 * Success looks like this :
 *
    "server available at 3653042176.0;tcp://192.168.10.191:52434+3653042177.0;tcp://192.168.10.191:48880:300"

*/


Once the ompi-server is running, you can refer to it by file, but you can also refer to it by it's pid if it's local. To get things running with the minimum of overlapping errors, I start with simple local setups.

You find the pid of the ompi-server:

ps -ef | grep ompi     

1634  1458  0 Dec15 ?        00:03:41 compiz  dave     

16050  1954  0 10:26 pts/18   00:00:00 mpirun -n 1 ompi-server --no-daemonize -r + dave    

16051 16050  0 10:26 pts/18   00:00:00 ompi-server --no-daemonize -r + dave

You run the server like this:
mpirun -np 1  --ompi-server pid:16050  ./server
It looks successful like this:
server available at 3500802048.0;tcp://192.168.10.191:50129+3500802049.0;tcp://192.168.10.191:53693:300

Now you mpirun the client and it looks like this:
  mpirun -np 1 --ompi-server pid:14341 ./client
looking up  server ...
The server  responds like this:

 we got a client's data: 25.500000
 we got a client's data: 26.500000
 we got a client's data: 27.500000
^Cmpirun: killing job...

You can mpirun the client and server from a config file as well instead of informing of the ompi-server location by PID like this:

 mpirun -np 1 --ompi-server file:./nameserver.cfg ./server
server available at 2886402048.0;tcp://192.168.10.191:51344+2886402049.0;tcp://192.168.10.191:54857:300



Wednesday, October 5, 2016

Trouble with 2 Functions in C [on hold]

Sorry people on Stackexchange tend to be lonely angry introverts looking for needy people to show how smart they are, so they bicker more with format, rather than just answering your question:

I think you are asking how do you "call on" or access the function variables you sent inside the function.

You don't post "Type" so let's use the example of "Student".

Since you pass a pointer to an array of Students called "class"  you would access the Students directly - you are working on the original not a copy.

     class->weightavg

would get you the double value inside class ASSUMING your pointer was to one and only one student in class[0] which is the same as class-> or pointer to the first array element.

If you have more than one which is what I believe your length variable is for, then it would be

    class[length].weightavg

for the double value.

or if you had a bunch of students then make an int i, iterate it, and


    class[i].weightavg

so long as you check up to length but not AT length (C arrays start from 0 not 1) so length should be outside the array.

your char * strings are a special case, look up strcpy() like functions or use printf("%s", class[i].name ); to show that value.

BTW: I addressed the kind of unhelpful anti-social behavior that goes on in stack exchange here where I poked the lonely introverts and they responded exactly the way I predicted.

Wednesday, September 21, 2016

Using Linux on chrome book

Once you install linux to get back there from reboot:

Once logged in, Ctrl-Alt-T brings up chrome shell crosh

Type: shell

Then type: sudo startxfce4 to start X server session. 

Friday, August 5, 2016

Stripping personal information from URL / URI


http://www.reuters.com/article/us-usa-economy-trade-idUSKCN10G1C6?feedType=RSS&feedName=businessNews&utm_source=Twitter&utm_medium=Social&utm_campaign=Feed%3A+reuters%2FbusinessNews+%28Business+News%29


For those that don't want to broadcast information to HTTP servers about where they came from, what news feed worked, etc. to a company, then you can strip it when you see a URL Universal Resource Locator / URI Universal Resource Indicator. 

In HTML, the ? symbol represents variables. Or in WWW language:

The HTTP query string is specified by the values following the question mark(?). 

So everything after the ? are variables sent to the HTML / HTTP server to process along with the request, which is the reuters article above, can be stripped from the URL request (your browser asks "Can you find me this URI?" and the server sends back files).

http://www.reuters.com/article/us-usa-economy-trade-idUSKCN10G1C6?feedType=RSS&feedName=businessNews&utm_source=Twitter&utm_medium=Social&utm_campaign=Feed%3A+reuters%2FbusinessNews+%28Business+News%29
 
 Strip all characters past the ? and it still works:
 
http://www.reuters.com/article/us-usa-economy-trade-idUSKCN10G1C6

Friday, July 29, 2016

Why I hate a majority of stackoverflow participants

If you want to see an example of why lonely introverted Tech workers can't be trusted to work effectively with others.



http://stackoverflow.com/questions/38593588/reading-a-value-with-a-timer-in-c/38595314#38595314

Wherein I try to help the person asking a question. And rather than helping me help that person, I get assaulted by a moron lacking any empathy spouting format rules in the mode of rude. Notice Inspectable never once did any actual work!

This is the kind of thing that makes people avoid these  help sites, people feel stupid asking questions or answering them, and then they get some rude moron making the situation worse through bad manners and unsympathetic actions.

I post on many stack exchange sites, go to the English or Buddhist stacks and you will find polite people trying to exchange and learn, and most of all consider the ideas on display. They do not act the same as IT workers that troll stack overflow. I know there are a few good ones.  I have worked with people that helped me. But they are in the minority, the angry ones that do no work seem to take the game rules to extreme for personal reasons outside helping people.

I wonder if stack overflow will survive the decade.

So this is a major reason why I post my own blog solutions, because some little shit can't stroll along and squash what I wrote without even trying the solutions.

Tuesday, July 26, 2016

Septic Pump Maintenance


A few days ago, we had a powerful hailstorm, the worst since 2006/2005 when the entire house was pummeled by hail the size of softballs.

This time the hail was the size of fastballs





It just so happened that we had requested a septic pump truck to empty our septic system two days before the storm.  The guy came and emptied it, and then when I was paying for it he said the water level had been really high, that the pump might not been working. 

So I will relay all the information I have learned as I recount how I fixed my septic system.  It was hard won information from trial and error, from fixing it in -40C when tampon strings burned out the pump motor,  what I changed after fixing it 4 times in 13 years and how to make it easier and faster to fix.


I live in a cold climate, it can get as low as -55C with wind chill.  The first recommended fix, if your system was installed by an amateur, is to make a fortified manhole instead of the flimsy cheap stuff a "professional" would install.  The system I inherited had a regular electrical socket mounted through a wood plank. The septic tank opening was surrounded by plywood planks.  Some professional.  I built a 2-tall concrete garden brick building around the top, I filled it with sand and redid the electrical to a proper IP54 box for exposed sockets.






I made my system with 2 covers, an inner atop the man hole and the outer above the concrete wall.  


This is the outer cover.


 This is the custom inner cover.


It has happened that the electrical connections outside the manhole were wet and froze over.  The last time, I can tell from fixing it with bare fingers at -40C, you want your pump to stop is in the dead of winter. What you can use, which is a real source of heat, is the ambient heat from microbial action (bugs eating poo) to warm up around the plugs. You position the electrical connections inside the wellhead above the water spill zone. So long as you make sure they are properly protected from water build up, they will only get moist but stay warm. I use a single outdoor cord to connect to the socket to the electrical block in the warmer air. I tape the electrical to the top of the outlet pipe connected to the septic pump.



My septic system uses the outlet pipe as both the outport and check valve. The guy was too cheap to install a proper valve, but the up, over, and down pipe design makes an effective check valve when the pump stops. The trick is it needs a hole drilled into the pipe to prevent a vapour lock situation.  The first time I fixed it, I got it all done, and then turned it on and nothing happened. I sat there aghast at how all parts were in and nothing moved. Upon some searching, the answer appeared.  One 1/32 inch hole on the upward pipe and it stabilizes the pressure.


The original connection was a pipe fitting male to female. He glued a connection on the right angle pipe and it becomes quite a pain.  I can assure you if you remove the septic pump then try and replace it and don't set it on the pedestal properly, if the ends are slightly dirty (there is effluent all over this system in parts you don't expect) or frozen because you had the pieces on the ground in the cold, that you will spend more time than you need to trying to screw the ends together. You don't want to snap the ends or rip the pipe out either while trying to work them together.  I replaced the female connector with a rubber sleeve and sealing clamps called a coupler in this case 2inch to 2inch. All I need is to loosen one clamp screw and it peels right out and I can reseat it just as easily.

First step in determining what is broken, assemble replacement parts.  Since I was pulling out the septic pump anyway, and I have to remove the electrical connections, I will replace parts as I go. If you weren't aware most mechanical floats have a 2 year warranty so if they are questionable you may as well replace them.  I got a new cable, electrical tape, and zap straps.



I bought a $47 replacement 15 foot 90 degree mechanical switch to for the turn on switch.  When the water gets to the top of the range you want, you want the switch to finally turn on.  Then when it reaches the bottom, you want it to turn off. The 450467 has a long cord in case I need to hook it right to the top socket. I buy the longer ones then if I need to connect to the outlet with the pump I can do it. Excess cord can just be wrapped in the top of the hole near the  electrical block.



Since the pump might not be turning on, this is the suspect switch not the lower one at the bottom that prevents the motor from running dry.  There are 2 float switches in the electrical block. I will replace this one first run and see if that fixes it.

The second step is to unhook the septic pump, remove the pump and pipe, remove the electrical block, remove the pump plug, and plug the pump straight into the electrical socket. If the pump won't turn on then, it's shot.



With this new system, it takes 2 minutes to disconnect and pull out. One other benefit of the concrete wall is that you can lean on the rim and not fear shattering the plexiglass manhole - that would allow sand or dirt to get in.


Here is the septic system with the pump removed. I don't use gloves because I want to make sure I have a firm grip on the pipe/cable while working it around out of the hole. Expect you will get dirty and smell like shit. The rewards for a job well done is a shower.



Here is the septic pump, at bottom and the outlet pipe all the way at the top of image. Right beside the motor is the low end mechanical switch that turns off to stop motor burnout. Halfway up is another coupling I will explain. At the top is the electrical block.

If you cut the outlet pipe too short, you need to replace it. If you cut the outlet pipe too long you need to pull it all apart, recut, and replace it. By adding a coupler above the septic pump, you can make a quick adjustment, you can fit a 2 inch outlet pipe onto a 3 inch pipe on the septic pump as this one in the image above is. This also allows you to twist the direction of the pump versus the outlet pipe. It all becomes easier with an extra $5 part.


I use stereo wire doubled up as the hauling cable tied to the pump ring instead of using the pipe to lift it out.  This saves a little time because you can haul heavier and you don't risk damaging the pipe installing / reinstalling.

I pulled apart the electrical block, I unwrapped electrical tape, reinstalled the septic pump and plugged the pump by itself back into the electrical socket. It worked and I left the pump on to empty out the water.  Then I removed the septic pump so I could replace the mechanical switch. 


Here is the original float switch and the new one laid on top. If you want it to work the same the first thing you connect is the new float switch tied with zap straps at the same point with the same length under the line. This allows the switch to turn on for the right setting of your tank.  Once that is done you can snip the old switch and pull the dead cable out of the run. 



Once that float is installed, you connect all the plugs into an electrical block and then wrap them. You soft connect it to the top of the outlet pipe with electrical tape rather than zap straps and then wrap the extra cord lengths in a bundle. Last time I used gun tape this time I used electrical tape.  I replace the old electrical cord and taped it as well to the pipe.


If you've done everything properly, took your time and made sure your setting was right, then it's reinstall, connect, and plug it in. This fix took 1 hour 12 minutes, compared to the worst of many hours over many days in dribs and drabs.