AUSTAL (modified)
mpisync.c
//==================================================== mpisysnc.c
//
// Sammlung von Routinen, die Geruchsausbreitungsrechnungen und
// und Parallelrechnung für austal2000 ermöglichen
// =================================================================
//
// Copyright (C) Broder Petersen, 20255 Hamburg, Germany, 2003
// email: broder.petersen@t-online.de
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// last change: 2003-11-28 bp
//
//==================================================================
#include "IBJstd.h"
#include "mpisync.h"
#include "math.h"
#include "TalInp.h"
#include "TalPrm.h"
//==================================================================
//
// Zwischenergebnisse der Ausbreitungsrechnung werden zwischen den
// Prozessen ausgetauscht
//
//==================================================================
#define ROOT 0
#ifdef MPI
void mpisync(float * buf1, int len)
{
int i,j, msglen;
float * buf = 0;
float * pnt;
float * pnt1;
float a;
MPI_Status stat;
if (myid!=ROOT)
{
// MPI_Ssend(buf1,len,MPI_BYTE,ROOT,0,MPI_COMM_WORLD);
MPI_Send(buf1,len,MPI_BYTE,ROOT,0,MPI_COMM_WORLD);
// printf("Send %d,%d,%d,%p\n",myid,tag,len,buf1);
// fflush(stdout);
}
else
{
for (i=1; i {
MPI_Probe(i, 0, MPI_COMM_WORLD, &stat);
if (buf == 0)
{
MPI_Get_count(&stat, MPI_BYTE, &msglen);
buf=(float*)malloc(msglen);
}
MPI_Recv(buf, msglen, MPI_BYTE, stat.MPI_SOURCE, stat.MPI_TAG, MPI_COMM_WORLD,&stat);
// printf("RecS %d,%d,%d,%d\n",stat.MPI_SOURCE,stat.MPI_TAG,stat.MPI_ERROR,msglen);
// fflush(stdout);
pnt1 = buf1;
pnt = buf;
for (j=0; j<(len/sizeof(float)/2);j++)
{
a = 2*(*pnt1)*(*pnt)/MI.numgrp;
*pnt1++ += *pnt++;
*pnt1++ += *pnt++ + a;
}
}
if (buf!=0) free(buf);
}
}
#endif
//
// Sammlung von Routinen, die Geruchsausbreitungsrechnungen und
// und Parallelrechnung für austal2000 ermöglichen
// =================================================================
//
// Copyright (C) Broder Petersen, 20255 Hamburg, Germany, 2003
// email: broder.petersen@t-online.de
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// last change: 2003-11-28 bp
//
//==================================================================
#include "IBJstd.h"
#include "mpisync.h"
#include "math.h"
#include "TalInp.h"
#include "TalPrm.h"
//==================================================================
//
// Zwischenergebnisse der Ausbreitungsrechnung werden zwischen den
// Prozessen ausgetauscht
//
//==================================================================
#define ROOT 0
#ifdef MPI
void mpisync(float * buf1, int len)
{
int i,j, msglen;
float * buf = 0;
float * pnt;
float * pnt1;
float a;
MPI_Status stat;
if (myid!=ROOT)
{
// MPI_Ssend(buf1,len,MPI_BYTE,ROOT,0,MPI_COMM_WORLD);
MPI_Send(buf1,len,MPI_BYTE,ROOT,0,MPI_COMM_WORLD);
// printf("Send %d,%d,%d,%p\n",myid,tag,len,buf1);
// fflush(stdout);
}
else
{
for (i=1; i
MPI_Probe(i, 0, MPI_COMM_WORLD, &stat);
if (buf == 0)
{
MPI_Get_count(&stat, MPI_BYTE, &msglen);
buf=(float*)malloc(msglen);
}
MPI_Recv(buf, msglen, MPI_BYTE, stat.MPI_SOURCE, stat.MPI_TAG, MPI_COMM_WORLD,&stat);
// printf("RecS %d,%d,%d,%d\n",stat.MPI_SOURCE,stat.MPI_TAG,stat.MPI_ERROR,msglen);
// fflush(stdout);
pnt1 = buf1;
pnt = buf;
for (j=0; j<(len/sizeof(float)/2);j++)
{
a = 2*(*pnt1)*(*pnt)/MI.numgrp;
*pnt1++ += *pnt++;
*pnt1++ += *pnt++ + a;
}
}
if (buf!=0) free(buf);
}
}
#endif