+++ /dev/null
-
-
- /* Simple client server skeleton */
- /* */
- /* Searches litterary works */
- /* */
- /* Sample built-in commands: */
- /* frequency "word" */
- /* distribution "word" */
- /* correlation "word_1" " word_2" */
- /* help */
- /* quit */
-
-
- /* Michel Vallieres */
- /* Spring 2001 */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define MAX_WORDS 100000
-
-char word[MAX_WORDS][100];
-
- /* function */
- /* prototypes */
-void correlation ( char word_1[], char word_2[], int corr[], int n_word );
-void search_word( char *a_word, int *occurences, int n_word );
-void distribution( char *a_word, int *occurences, int n_word );
-void get_the_data ( char *fname, int *n_word );
-void lower_case_letters ( char *string );
-void cleanup ( char string[], char in_string );
-void command_input ( char command[], char word_1[], char word_2[] );
-
-
-/* correlations between the words */
-void correlation ( char word_1[], char word_2[], int corr[], int n_word )
-{
- int iw, wscan, wscan_min, wscan_max;
- /* zeroth */
- /* correlation */
- for ( wscan=0; wscan<5 ; wscan++ )
- corr[wscan] = 0;
- /* scan over text */
- for ( iw=0 ; iw<n_word ; iw++ )
- { /* find word #1 */
- if ( strcmp( word[iw] , word_1 ) == 0 )
- {
- wscan_max = iw + 5;
- if ( wscan_max > n_word )
- wscan_max = n_word;
- wscan_min = iw+1;
- if ( wscan_min > n_word )
- wscan_min = n_word; /* find word #2 */
- /* nearby */
- if ( wscan_max >= wscan_min )
- {
- for ( wscan=wscan_min ; wscan<wscan_max ; wscan++ )
- {
- if ( strcmp( word[wscan] , word_2 ) == 0 )
- corr[wscan-iw-1] = corr[wscan-iw-1] + 1;
- }
- }
- }
- }
-
-}
-
-
-
-/* frequency search */
-void search_word( char *a_word, int *occurences, int n_word )
-{
- int iw, times;
-
- times = 0;
- for ( iw=0 ; iw<n_word ; iw++ )
- {
- if ( strcmp( word[iw] , a_word ) == 0 )
- times++;
- }
- *occurences = times;
-}
-
-
-/* distribution search */
-void distribution( char *a_word, int dist[], int n_word )
-{
- int iw, iw_1_3, iw_2_3, times;
-
- /* first third */
- iw_1_3 = n_word/3;
- iw_2_3 = 2*n_word/3;
- times = 0;
- for ( iw=0 ; iw<iw_1_3 ; iw++ )
- {
- if ( strcmp( word[iw] , a_word ) == 0 )
- times++;
- }
- dist[0] = times;
- /* second third */
- times = 0;
- for ( iw=iw_1_3 ; iw<iw_2_3 ; iw++ )
- {
- if ( strcmp( word[iw] , a_word ) == 0 )
- times++;
- }
- dist[1] = times;
- /* last third */
- times = 0;
- for ( iw=iw_2_3 ; iw<n_word ; iw++ )
- {
- if ( strcmp( word[iw] , a_word ) == 0 )
- times++;
- }
- dist[2] = times;
-}
-
-
-
-/* read in the data */
-void get_the_data ( char *fname, int *n_word )
-{
- FILE *fp;
- int i_word;
- char *found, comma, dot, semi_colon, colon, question, exclamation;
- int ic, nc, lw;
-
- if ( ( fp = fopen( fname, "r" ) ) == NULL )
- {
- printf( " error in opening file \n" );
- exit(1);
- }
-
- comma = ',';
- dot = '.';
- semi_colon = ';';
- colon = ':';
- question = '?';
- exclamation = '!';
- i_word = 0;
-
- while ( fscanf( fp, "%s", word[i_word] ) != EOF )
- {
- /* clean out | */
- if ( strcmp( word[i_word], "|" ) == 0 )
- i_word--;
- /* removes , */
- cleanup ( word[i_word], comma );
- /* removes . */
- cleanup ( word[i_word], dot );
- /* removes ; */
- cleanup ( word[i_word], semi_colon );
- /* removes : */
- cleanup ( word[i_word], colon );
- /* removes ? */
- cleanup ( word[i_word], question );
- /* removes ! */
- cleanup ( word[i_word], exclamation );
- /* small case letters */
- lower_case_letters ( word[i_word] );
- /* next word */
- i_word++;
-
- if ( i_word == MAX_WORDS )
- {
- printf( "\n Dimension too small - increase MAX_WORDS\n\n" );
- exit(1);
- }
- }
- /* close file */
- fclose(fp);
-
- *n_word = i_word-1;
-
-}
-
-
-
-/* utility to rewrite string in small case letters only */
-void lower_case_letters ( char string[] )
-{
- int ic, lw;
-
- lw = strlen( string );
- for ( ic=0 ; ic<lw ; ic++ )
- string[ic] = tolower( string[ic] );
-}
-
-
-
-/* special characters clean-up routine - removes */
-/* single ocurence of in_string from string */
-void cleanup ( char string[], char in_string )
-{
- int ic, nc, lw;
- char *found;
-
- if ( ( found = strchr( string, in_string ) ) != NULL )
- {
- nc = found-string;
- lw = strlen( string );
- for ( ic=nc ; ic<lw ; ic++ )
- string[ic] = string[ic+1];
- }
-}
-
-
-
-/* input command */
-void command_input ( char command[], char word_1[], char word_2[] )
-{
- printf( " Enter a command (quit): " );
- scanf( "%s", command );
- lower_case_letters ( command );
-
-
- if ( strcmp ( command, "frequency" ) == 0 )
- {
- printf( " Word to search for : " );
- scanf( "%s", word_1 );
- lower_case_letters ( word_1 );
- }
- else if ( strcmp ( command, "distribution" ) == 0 )
- {
- printf( " Word to search for : " );
- scanf( "%s", word_1 );
- lower_case_letters ( word_1 );
- }
- else if ( strcmp ( command, "correlation" ) == 0 )
- {
- printf( " Words to correlate : " );
- scanf( "%s", word_1 );
- scanf( "%s", word_2 );
- lower_case_letters ( word_1 );
- lower_case_letters ( word_2 );
- }
- else if ( strcmp ( command, "quit" ) == 0 )
- exit(0);
- else if ( strcmp ( command, "help" ) == 0 )
- {
- printf( "\n" );
- printf( " Syntax: help \n" );
- printf( " frequency word \n" );
- printf( " distribution word \n" );
- printf( " corrolation word_1 word_2 \n" );
- printf( " quit \n\n" );
- }
- else
- {
- printf( " Error - command not implemented \n");
- }
-
-}
-
-
-
-int main( int argc, char *argv[] )
-{
-
- int n_word;
- char command[100], word_1[100], word_2[100];
- int occurences;
- int wscan, corr[5];
- int dist[3];
- char *directory;
- char fname[100];
-
- /* get the text data */
- directory = getenv( "PWD" );
- strcpy( fname, "" );
- strcat( fname, directory );
- strcat( fname, "/Shakespeare/hamlet.html" );
- printf( "\n\n File to read: %s \n", fname );
- get_the_data ( fname, &n_word );
- printf( " \n Number of words: %d \n\n", n_word );
-
- /* scan over commands */
- for ( ; ; )
- {
- /* read in command */
- command_input( command, word_1, word_2 );
- /* frequency */
- if ( strcmp ( command, "frequency" ) == 0 )
- {
- search_word( word_1, &occurences, n_word );
- printf( "\n %s -- appears %d times \n\n", word_1, occurences );
- }
- /* correlations */
- if( strcmp ( command, "correlation" ) == 0 )
- {
- correlation( word_1, word_2, corr, n_word );
- printf( "\n distance number \n");
- for ( wscan=0 ; wscan<5 ; wscan++ )
- printf( " %d %d \n", wscan, corr[wscan] );
- printf( " \n" );
- }
- /* distribution */
- /* of word */
- if( strcmp ( command, "distribution" ) == 0 )
- {
- distribution( word_1, dist, n_word );
- printf( " distribution: %d %d %d\n\n",
- dist[0], dist[1], dist[2] );
- }
- }
-
-}
-
-
-
-
-
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta name="generator" content=
- "HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" />
- <meta http-equiv="Content-Type" content=
- "text/html; charset=us-ascii" />
- <meta name="GENERATOR" content="Microsoft FrontPage 4.0" />
- <meta name="ProgId" content="FrontPage.Editor.Document" />
-
- <title>New Page 2</title>
-</head>
-
-<body background="GIF_files_PHYS405/grid.gif">
- <!--BACKGROUND="GIF_files_PHYS405/wallp1.gif"-->
- <img border="0" src="GIF_files_PHYS405/PHYS405.gif" width="226"
- height="45" /><br />
- <img border="0" src="GIF_files_PHYS405/Advanced.gif" width="94"
- height="30" /> <img border="0" src=
- "GIF_files_PHYS405/Computational.gif" width="125" height="30" />
- <img border="0" src="GIF_files_PHYS405/Physics.gif" width="84"
- height="29" /><img border="0" src=
- "GIF_files_PHYS405/Parallel.gif" width="73" height="30" />
- <img border="0" src="GIF_files_PHYS405/Computing.gif" width="98"
- height="29" />
- <hr />
-
- <p><i>Table of Content</i></p>
-
- <ul>
- <li>
- <a href="Elementary_MPI/arch.html">Introduction to Parallel
- Computing</a>
-
- <ul>
- <li>
- <a href="Elementary_MPI/arch.html#CA">Computer
- Architecture</a>
-
- <ul>
- <li><a href="Elementary_MPI/arch.html#BC">Basic
- Computer</a></li>
-
- <li><a href=
- "Elementary_MPI/arch.html#SM1">Processors</a></li>
-
- <li><a href=
- "Elementary_MPI/arch.html#SM2">Memory</a></li>
-
- <li><a href=
- "Elementary_MPI/arch.html#SM3">Cache</a></li>
-
- <li><a href="Elementary_MPI/arch.html#SM4">Virtual
- Memory</a></li>
-
- <li><a href="Elementary_MPI/arch.html#SM5">Inter-leaved
- Memory</a></li>
-
- <li><a href="Elementary_MPI/arch.html#SM6">Bus and I/O
- bandwidth</a></li>
- </ul>
- </li>
-
- <li>
- <a href="Elementary_MPI/arch.html#HPC">High Performance
- Computing - Parallelism</a>
-
- <ul>
- <li><a href=
- "Elementary_MPI/arch.html#HPC1">Granularity</a></li>
- </ul>
- </li>
-
- <li>
- <a href="Elementary_MPI/arch.html#TCC">Traditional
- Computer Classification</a>
-
- <ul>
- <li><a href="Elementary_MPI/arch.html#TCC1">Flynn's
- Taxonomy</a></li>
- </ul>
- </li>
-
- <li>
- <a href="Elementary_MPI/arch.html#TCC2">Fast processors
- architectures</a>
-
- <ul>
- <li><a href="Elementary_MPI/arch.html#TCC21">Pipelined
- Processors</a></li>
-
- <li><a href="Elementary_MPI/arch.html#TCC22">Vector
- Processors</a></li>
-
- <li><a href=
- "Elementary_MPI/arch.html#TCC23">Super-Scalar
- Processors</a></li>
- </ul>
- </li>
-
- <li>
- <a href="Elementary_MPI/arch.html#MEM">MIMD - memory
- organization</a>
-
- <ul>
- <li><a href="Elementary_MPI/arch.html#MEM1">Shared
- Memory</a></li>
-
- <li><a href="Elementary_MPI/arch.html#MEM2">Distributed
- Memory</a></li>
-
- <li><a href=
- "Elementary_MPI/arch.html#Standards">Message Passing
- Standards -- PVM and MPI</a></li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
-
- <ul>
- <li>
- <a href="Elementary_MPI/Elementary_MPI.html">Elementary
- MPI</a>
-
- <ul>
- <li><a href=
- "Elementary_MPI/Elementary_MPI.html#WhatIs">What is
- MPI?</a></li>
-
- <li><a href=
- "Elementary_MPI/Elementary_MPI.html#Binding">Binding to C
- and Fortran</a></li>
-
- <li><a href="Elementary_MPI/Elementary_MPI.html#Init">MPI
- Initialization</a></li>
-
- <li><a href="Elementary_MPI/Elementary_MPI.html#Who">Who Am
- I?</a></li>
-
- <li><a href=
- "Elementary_MPI/Elementary_MPI.html#Final">Finalizing
- MPI</a></li>
-
- <li><a href=
- "Elementary_MPI/Elementary_MPI.html#CL">Building an MPI
- code</a></li>
-
- <li><a href=
- "Elementary_MPI/Elementary_MPI.html#Running">Running an MPI
- code</a></li>
-
- <li><a href=
- "Elementary_MPI/examples.html">Examples</a></li>
- </ul>
- </li>
- </ul>
-
- <ul>
- <li>
- <a href="Message_Passing/Message_Passing.html">Message
- Passing</a>
-
- <ul>
- <li><a href=
- "Message_Passing/Message_Passing.html#Content">Message
- Content</a></li>
-
- <li><a href=
- "Message_Passing/Message_Passing.html#Types">MPI Fortran -
- C datatypes</a></li>
-
- <li><a href=
- "Message_Passing/Message_Passing.html#Protocols">Communication
- Protocols</a></li>
- </ul>
- </li>
- </ul>
-
- <ul>
- <li>
- <a href="Point_to_Point/point_to_point_comm.html">Point to
- Point Communication</a>
-
- <ul>
- <li><a href=
- "Point_to_Point/point_to_point_comm.html#Content">Communication
- Modes</a></li>
-
- <li><a href=
- "Point_to_Point/point_to_point_comm.html#Types">Communication
- Envelope</a></li>
-
- <li><a href=
- "Point_to_Point/point_to_point_comm.html#Dead">Deadlock</a></li>
-
- <li><a href=
- "Point_to_Point/point_to_point_comm.html#Protocols">Timing</a></li>
-
- <li><a href=
- "Point_to_Point/point_to_point_comm.html#Cost">The Cost of
- Communication</a></li>
-
- <li><a href=
- "Point_to_Point/examples.html">Examples</a></li>
-
- <li>Assignment #1<br /></li>
- </ul>
- </li>
-
- <li>
- <a href="Monte-Carlo/index.html">Monte Carlo Techniques</a>
-
- <ul>
- <li><a href="Monte-Carlo/index.html#MCI">Monte Carlo
- Integral</a></li>
-
- <li><a href="Monte-Carlo/index.html#calc_pi">Calculation of
- π</a></li>
-
- <li><a href=
- "Monte-Carlo/index.html#Applicability">Applicability of the
- Method</a></li>
-
- <li><a href=
- "Monte-Carlo/index.html#Metropolis%20Algorithm">Metropolis
- Algorithm</a></li>
-
- <li><a href="Monte-Carlo/index.html#Guided">Guided Monte
- Carlo Integral</a></li>
-
- <li><a href="Monte-Carlo/index.html#Parallel_MC">Parallel
- Monte Carlo Algorithm<br /></a>
- <a href=
- "Monte-Carlo/index.html#Random_Numbers_Generation">Random
- Numbers Generation<br /></a>
- <a href=
- "Monte-Carlo/index.html#Parallel_MC_Codes">Parallel Monte
- Carlo Codes</a></li>
- </ul>
-
- <p> </p>
- </li>
-
- <li>
- <a name="Client_Server" href="Client_Server/index.html" id=
- "Client_Server">Client-Server Model - Parallel I/O</a>
-
- <ul>
- <li><a href=
- "Client_Server/index.html#Parallel_Model">Parallel
- Model</a></li>
-
- <li><a href="Client_Server/index.html#Literary">Literary
- Search</a></li>
-
- <li><a href=
- "Client_Server/index.html#Parallel_Implementation">Parallel
- Implementation</a></li>
-
- <li><a href=
- "Client_Server/index.html#MPI_2">MPI-2</a><a href=
- "Point_to_Point/examples.html"><br /></a></li>
- </ul>
- </li>
-
- <li>Solution of Partial Differential Equations
-
- <ul>
- <li>Poisson Equation ( Jacobi, Gauss-Siedel, SOR )</li>
- </ul>
- </li>
- </ul>
-
- <ul>
- <li>Programming Strategies
-
- <ul>
- <li>Parallel Algorithms, Communications & Load
- Balancing</li>
-
- <li>Static Load Balance</li>
-
- <li>Dynamical Load Balance</li>
-
- <li>The Mandelbrot Set</li>
-
- <li>Assignment #2<br /></li>
- </ul>
- </li>
- </ul>
-
- <ul>
- <li>MPE Graphics Environment
-
- <ul>
- <li>Introduction</li>
-
- <li>C-binding</li>
-
- <li>Example<br /></li>
- </ul>
- </li>
- </ul>
-
- <ul>
- <li>Domain Decomposition
-
- <ul>
- <li>Lattice Problems</li>
-
- <li>Domain Decomposition</li>
-
- <li>Parallel Implementation</li>
-
- <li>Elliptic Equation - 1-D Poisson Equation
-
- <ul>
- <li>The Model</li>
-
- <li>Sequential Implementation</li>
-
- <li>Parallel Implementation</li>
- </ul>
- </li>
-
- <li>Elliptic Equation - 2-D Poisson Equation
-
- <ul>
- <li>The Model</li>
-
- <li>Sequential Implementation</li>
-
- <li>Parallel Implementation</li>
- </ul>
- </li>
-
- <li>Red and Black algorithm<br /></li>
- </ul>
- </li>
-
- <li>Global Operations
-
- <ul>
- <li>Synchronization</li>
-
- <li>Broadcast</li>
-
- <li>Reduce</li>
-
- <li>Sample Codes</li>
-
- <li>Binary Tree Algorithm - Broadcast</li>
- </ul>
- </li>
-
- <li>Advanced MPI
-
- <ul>
- <li>Non-Blocking Communications</li>
-
- <li>Simultaneous Calculations/Communications</li>
-
- <li>Just on Time Communication</li>
-
- <li>Examples
-
- <ul>
- <li>Communication in a ring</li>
-
- <li>Poisson Equation<br /></li>
- </ul>
- </li>
- </ul>
- </li>
-
- <li>Derived Data Types - Buffering
-
- <ul>
- <li>MPI Approach</li>
-
- <li>C structures</li>
-
- <li>Examples<br /></li>
- </ul>
- </li>
-
- <li>Projects
-
- <ul>
- <li>Diffusion Equation</li>
-
- <li style="list-style: none; display: inline">
- <ul>
- <li>Parabolic Equation</li>
-
- <li>Model</li>
-
- <li>Parabolic PDEs solution</li>
-
- <li>Serial Implementation</li>
-
- <li>Some Results</li>
-
- <li>Project</li>
- </ul>
- </li>
-
- <li>Navier-Stokes Equations</li>
-
- <li>Gene search</li>
-
- <li>Classical N-Body problem
-
- <p> </p>
- </li>
- </ul>
- </li>
- </ul>
- <hr />
- <a href="index.html">Back to PHYS 405 main page</a>
- <hr />
- Any questions or suggestions should be directed to <a href=
- "mailto:valliere@physics.drexel.edu">Michel Vallières</a>
- <hr />
-
- <p> </p>
-</body>
-</html>