-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Srinath Vadlamani
committed
Apr 25, 2011
0 parents
commit f8387aa
Showing
288 changed files
with
39,680 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! | ||
! The following example demonstrates how to create and close a parallel | ||
! file using MPI-IO calls. | ||
! | ||
|
||
PROGRAM MPIOEXAMPLE | ||
|
||
USE MPI | ||
|
||
IMPLICIT NONE | ||
|
||
CHARACTER(LEN=80), PARAMETER :: filename = "/tmp/filef.h5" ! File name | ||
INTEGER :: ierror ! Error flag | ||
INTEGER :: fh ! File handle | ||
INTEGER :: amode ! File access mode | ||
|
||
call MPI_INIT(ierror) | ||
amode = MPI_MODE_RDWR + MPI_MODE_CREATE + MPI_MODE_DELETE_ON_CLOSE | ||
call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, amode, MPI_INFO_NULL, fh, ierror) | ||
print *, "Trying to create ", filename | ||
if ( ierror .eq. MPI_SUCCESS ) then | ||
print *, "MPI_FILE_OPEN succeeded" | ||
call MPI_FILE_CLOSE(fh, ierror) | ||
else | ||
print *, "MPI_FILE_OPEN failed" | ||
endif | ||
|
||
call MPI_FINALIZE(ierror); | ||
END PROGRAM |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
program hello_parallel | ||
|
||
! Include the MPI library definitons: | ||
include 'mpif.h' | ||
|
||
integer numtasks, rank, ierr, rc, len, i | ||
character*(MPI_MAX_PROCESSOR_NAME) name | ||
|
||
! Initialize the MPI library: | ||
call MPI_INIT(ierr) | ||
if (ierr .ne. MPI_SUCCESS) then | ||
print *,'Error starting MPI program. Terminating.' | ||
call MPI_ABORT(MPI_COMM_WORLD, rc, ierr) | ||
end if | ||
|
||
! Get the number of processors this job is using: | ||
call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr) | ||
|
||
! Get the rank of the processor this thread is running on. (Each | ||
! processor has a unique rank.) | ||
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) | ||
|
||
! Get the name of this processor (usually the hostname) | ||
call MPI_GET_PROCESSOR_NAME(name, len, ierr) | ||
if (ierr .ne. MPI_SUCCESS) then | ||
print *,'Error getting processor name. Terminating.' | ||
call MPI_ABORT(MPI_COMM_WORLD, rc, ierr) | ||
end if | ||
|
||
print "('hello_parallel.f: Number of tasks=',I3,' My rank=',I3,' My name=',A,'')",& | ||
numtasks, rank, trim(name) | ||
|
||
! Tell the MPI library to release all resources it is using: | ||
call MPI_FINALIZE(ierr) | ||
|
||
end program hello_parallel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The programs are archived as a self-extracting archive. To extract: | ||
|
||
1. Your computer must be in DOS (version 6.22 or earlier) mode. Windows | ||
cannot be running; the programs will not extract while Windows (any | ||
version) is running. | ||
|
||
2. At the screen prompts, type: | ||
|
||
MD C:\NUMRCL <enter> | ||
CD C:\NUMRCL <enter> | ||
XCOPY [A:] PROGRAMS.EXE <enter> (replace "[A:]" with the | ||
correct floppy drive name, if different) | ||
PROGRAMS.EXE -d <enter> | ||
|
||
This will extract all the programs, in the original subdirectories, into | ||
the new directory "NUMRCL". C programs are in the C subdirectory, | ||
FORTRAN in the FOR subdirectory, Mathematica in the MA subdirectory, | ||
Maple in the MWS subdirectory, and Pascal in the PAS subdirectory. The | ||
DTA subdirectory contains data files for all the programs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/* | ||
* BISECTION ALGORITHM 2.1 | ||
* | ||
* To find a solution to f(x) = 0 given the continuous function | ||
* f on the interval [a,b], where f(a) and f(b) have | ||
* opposite signs: | ||
* | ||
* INPUT: endpoints a,b; tolerance TOL; | ||
* maximum number of iterations N0. | ||
* | ||
* OUTPUT: approximate solution p or | ||
* a message that the algorithm fails. | ||
*/ | ||
|
||
#include<stdio.h> | ||
#include<math.h> | ||
#define ZERO 1.0E-20 | ||
#define true 1 | ||
#define false 0 | ||
|
||
main() | ||
{ | ||
double A,FA,B,FB,C,P,FP,TOL; | ||
int I,NO,OK,FLAG; | ||
FILE *OUP[1]; | ||
|
||
double absval(double); | ||
double F(double); | ||
void INPUT(int *, double *, double *, double *, double *, double *, int *); | ||
void OUTPUT(FILE **, int *); | ||
|
||
INPUT(&OK, &A, &B, &FA, &FB, &TOL, &NO); | ||
if (OK) { | ||
OUTPUT(OUP, &FLAG); | ||
/* STEP 1 */ | ||
I = 1; | ||
/* STEP 2 */ | ||
OK = true; | ||
while ((I<=NO) && OK) { | ||
/* STEP 3 */ | ||
/* compute P(I) */ | ||
C = (B - A) / 2.0; | ||
P = A + C; | ||
|
||
/* STEP 4 */ | ||
FP = F(P); | ||
if (FLAG == 2) fprintf(*OUP,"%3d %15.8e %15.7e \n",I,P,FP); | ||
if ((absval(FP)<ZERO) || (C<TOL)) { | ||
/* procedure completed successfully */ | ||
fprintf(*OUP,"\nApproximate solution P = %11.8f \n",P); | ||
fprintf(*OUP,"with F(P) = %12.8f\n",FP); | ||
fprintf(*OUP,"Number of iterations = %3d",I); | ||
fprintf(*OUP," Tolerance = %15.8e\n",TOL); | ||
OK = false; | ||
} | ||
else { | ||
/* STEP 5 */ | ||
I++; | ||
|
||
/* STEP 6 */ | ||
/* compute A(I) and B(I) */ | ||
if ((FA*FP) > 0.0) { | ||
A = P; FA = FP; | ||
} | ||
else { | ||
B = P; FB = FP; | ||
} | ||
} | ||
} | ||
if (OK) { | ||
/* STEP 7 */ | ||
/* procedure completed unsuccessfully */ | ||
fprintf(*OUP,"\nIteration number %3d",NO); | ||
fprintf(*OUP," gave approximation %12.8f\n",P); | ||
fprintf(*OUP,"F(P) = %12.8f not within tolerance : %15.8e\n",FP,TOL); | ||
} | ||
fclose(*OUP); | ||
} | ||
return 0; | ||
} | ||
|
||
/* Change function F for a new problem */ | ||
double F(double X) | ||
{ | ||
double f; | ||
|
||
f = ( X + 4.0 ) * X * X - 10.0; | ||
return f; | ||
} | ||
|
||
void INPUT(int *OK, double *A, double *B, double *FA, double *FB, double *TOL, int *NO) | ||
{ | ||
double X; | ||
char AA; | ||
|
||
printf("This is the Bisection Method.\n"); | ||
printf("Has the function F been created in the program immediately preceding\n"); | ||
printf("the INPUT function?\n"); | ||
printf("Enter Y or N\n"); | ||
scanf("%c",&AA); | ||
if ((AA == 'Y') || (AA == 'y')) { | ||
*OK = false; | ||
while (!(*OK)) { | ||
printf("Input endpoints A < B separated by blank\n"); | ||
scanf("%lf %lf", A, B); | ||
if (*A > *B) { | ||
X = *A; *A = *B; *B = X; | ||
} | ||
if (*A == *B) printf("A cannot equal B\n"); | ||
else { | ||
*FA = F(*A); | ||
*FB = F(*B); | ||
if (*FA*(*FB) > 0.0) printf("F(A) and F(B) have same sign\n"); | ||
else *OK = true; | ||
} | ||
} | ||
*OK = false; | ||
while(!(*OK)) { | ||
printf("Input tolerance\n"); | ||
scanf("%lf", TOL); | ||
if (*TOL <= 0.0) printf("Tolerance must be positive\n"); | ||
else *OK = true; | ||
} | ||
*OK = false; | ||
while (!(*OK)) { | ||
printf("Input maximum number of iterations - no decimal point\n"); | ||
scanf("%d", NO); | ||
if (*NO <= 0) printf("Must be positive integer\n"); | ||
else *OK = true; | ||
} | ||
} | ||
else { | ||
printf("The program will end so that the function F can be created\n"); | ||
*OK = false; | ||
} | ||
} | ||
|
||
void OUTPUT(FILE **OUP, int *FLAG) | ||
{ | ||
char NAME[30]; | ||
|
||
printf("Select output destination\n"); | ||
printf("1. Screen\n"); | ||
printf("2. Text file\n"); | ||
printf("Enter 1 or 2\n"); | ||
scanf("%d", FLAG); | ||
if (*FLAG == 2) { | ||
printf("Input the file name in the form - drive:name.ext\n"); | ||
printf("A:OUTPUT.DTA\n"); | ||
scanf("%s", NAME); | ||
*OUP = fopen(NAME, "w"); | ||
} | ||
else *OUP = stdout; | ||
fprintf(*OUP,"Bisection Method\n"); | ||
printf("Select amount of output\n"); | ||
printf("1. Answer only\n"); | ||
printf("2. All intermeditate approximations\n"); | ||
printf("Enter 1 or 2\n"); | ||
scanf("%d", FLAG); | ||
if (*FLAG == 2) fprintf(*OUP, " I P F(P)\n"); | ||
} | ||
|
||
|
||
/* Absolute Value Function */ | ||
double absval(double val) | ||
{ | ||
if (val >= 0) return val; | ||
else return -val; | ||
} |
Oops, something went wrong.