NEW

P&K TAL2K

Multi-Core

Berechnung wird mit fast 2-facher (Dual Core) oder 4-facher (Quad-Core) Geschwindigkeit ausgeführt.

Cluster

Berechnung wird mit bis zu 16-facher Geschwindigkeit ausgeführt. (Bedarf mehrere speziell vernetzte ausreichende PCs; Spezielles Installationswissen ist notwendig)

Petersen & Kade


AUSTAL2000 (modifiziert)

TALuti.c

//======================================================== TALuti.c
//
// Utilities for AUSTAL2000
// ========================
//
// Copyright (C) Umweltbundesamt, 14191 Berlin, Germany, 2002-2005
// Copyright (C) Janicke Consulting, 26427 Dunum, Germany, 2002-2005
// email: info@austal2000.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: 2006-10-31 lj
//
//==================================================================

#include
#include
#include
#include
#include
#include "IBJmsg.h"
#include "IBJary.h"
#include "IBJdmn.h"
#include "IBJtxt.h"
#include "TalAKT.h"
#include "TalUtl.h"
#include "TalInp.h"
#include "TalCfg.h"
#include "TALuti.h"
#include "TALuti.nls"

char *TALutiVersion = "2.3.1";
static char *eMODn = "TALuti";

//======================================================================= TutLogMax
//
int TutLogMax( // write maximum values into log-file
char *path, // working directory
char *file, // file name base
int k, // layer index
int ii, // sequence count
int nn ) // number of grids
{
dP(TutLogMax);
char fn[256], species[40], type[40], sep[80], grdx[32];
ARYDSC a, b;
int i, i1, i2, j, j1, j2, k1, k2, nz, n;
int i1s, i2s, j1s, j2s; //-2004-10-20
int imax=0, jmax=0, nmax=0, border=0, odor=0;
char *pc, *_artp, *_unit, *_name, *_vldf, *_form, *_file;
float vmax=0, zz[101], xmin=0, ymin=0, delta=1, v, x=0, y=0, *pf, dev;
TXTSTR usr = { NULL, 0 };
TXTSTR sys = { NULL, 0 };
FILE *msg;
if (!path || !file || !*file) return 0;
msg = (MsgFile) ? MsgFile : stdout;
memset(&a, 0, sizeof(ARYDSC));
memset(&b, 0, sizeof(ARYDSC));
strcpy(species, file);
pc = strchr(species, '-'); if (!pc) eX(1);
*pc = 0;
strcpy(type, pc+1);
for (pc=species; (*pc); pc++) *pc = toupper(*pc);
for (pc=type; (*pc); pc++) *pc = toupper(*pc);
odor = (0 == strncmp(species, "ODOR",4));
//
for (n=0; n if (nn == 1) *grdx = 0;
else sprintf(grdx, "%02d", n+1);
sprintf(fn, "%s/%s%s%s.dmna", path, file, CfgAddString, grdx); //-2006-10-31
if (!TutFileExists(fn)) {
fprintf(msg, "%-4s %3s : n.v.\n", species, type);
return -1;
}
DmnRead(fn, &usr, &sys, &a); eG(2);
if (a.numdm == 2) {
k1 = k2 = 0;
}
else if (a.numdm == 3) {
k1 = 1;
k2 = a.bound[2].hgh;
}
else eX(3);
if (kk2) goto finish;
i1 = a.bound[0].low;
i2 = a.bound[0].hgh;
j1 = a.bound[1].low; //-2001-06-11 uj
j2 = a.bound[1].hgh;
if (n == nn-1) { //-2004-10-20 lj
i1s = i1;
i2s = i2;
j1s = j1;
j2s = j2;
}
else {
i1s = i1+2;
i2s = i2-2;
j1s = j1+2;
j2s = j2-2;
}
DmnGetString(usr.s, "artp", &_artp, 1);
DmnGetString(usr.s, "name", &_name, 1);
DmnGetString(usr.s, "unit", &_unit, 1);
DmnGetString(usr.s, "vldf", &_vldf, 1);
DmnGetString(sys.s, "form", &_form, 1);
DmnGetString(sys.s, "file", &_file, 1);
DmnGetFloat(usr.s, "xmin", "%f", &xmin, 1);
DmnGetFloat(usr.s, "ymin", "%f", &ymin, 1);
DmnGetFloat(usr.s, "delta", "%f", &delta, 1);
nz = DmnGetFloat(usr.s, "sk", "%f", zz, 101);
if (n == 0) {
imax = i1s;
jmax = j1s;
nmax = 0;
}
for (i=i1s; i<=i2s; i++) //-2004-10-20
for (j=j1s; j<=j2s; j++) { //-2004-10-20
v = *(float*) AryPtrX(&a, i, j, k);
if (v > vmax) {
vmax = v;
imax = i;
jmax = j;
border = (i<=i1+1 || i>=i2-1 || j<=j1+1 || j>=j2-1);
if (_vldf && *_vldf=='V') {
x = xmin + (0.5 + imax - i1)*delta;
y = ymin + (0.5 + jmax - j1)*delta;
}
else {
x = xmin + (imax-i1)*delta;
y = ymin + (jmax-j1)*delta;
}
nmax = n;
}
}
if (n == nmax) {
sprintf(fn, "%s/%s%s%s.dmna", path, file, CfgDevString, grdx); //-2006-10-31
if (TutFileExists(fn)) {
DmnRead(fn, &usr, &sys, &b); eG(4);
pf = AryPtr(&b, imax, jmax, k);
}
else pf = NULL;
dev = (pf) ? *pf : -1; //-2001-10-22
if (dev > 0.999) dev = 0.999; //-2001-10-22
}
if (n >= nn-1) {
if (ii==0 && !odor) {
fprintf(msg, "Maximalwerte, ");
strcpy(sep, "==============");
if (_artp) {
if (!strcmp(_artp, "C") || *_artp=='M') {
fprintf(msg, "Konzentration");
strcat(sep, "=============");
if (k>0 && k<=nz) {
fprintf(msg, " bei z=%1.1f m", 0.5*zz[k]+zz[k-1]);
strcat(sep, "============");
}
}
else if (!strcmp(_artp, "XD")) {
fprintf(msg, "Deposition");
strcat(sep, "==========");
}
}
fprintf(msg, "\n%s\n", sep);
}
if (odor) { //-2004-06-10
fprintf(msg, "\nMaximalwert der Geruchsstundenhäufigkeit ");
strcpy(sep, "=========================================");
if (k>0 && k<=nz) {
fprintf(msg, " bei z=%1.1f m", 0.5*zz[k]+zz[k-1]);
strcat(sep, "============");
}
fprintf(msg, "\n%s\n", sep);

}
fprintf(msg, "%-4s %3s : ", species, type);
if (_form) {
pc = strchr(_form, '%');
fprintf(msg, pc, vmax);
}
else fprintf(msg, "%10.3e", vmax);
if (_unit) fprintf(msg, " %-5s", _unit);
if (odor) {
if (dev >= 0) fprintf(msg, " (+/- %4.2f )", dev); //-2004-06-10
else fprintf(msg, " (+/- ? )");
}
else {
if (dev >= 0) fprintf(msg, " (+/- %4.1f%%)", 100*dev); //-2001-10-28
else fprintf(msg, " (+/- ? %%)");
}
if (vmax > 0) { //-2002-05-03
fprintf(msg, " bei x=%5.0f m, y=%5.0f m (", x, y);
if (nn > 1) fprintf(msg, "%d:", nmax+1); //-2001-11-02
fprintf(msg, "%3d,%3d)", imax, jmax);
if (border) fprintf(msg, " RANDGEBIET!"); //-2002-07-13
}
fprintf(msg, "\n");
}
if (_artp) FREE(_artp);
if (_file) FREE(_file);
if (_form) FREE(_form);
if (_vldf) FREE(_vldf);
if (_name) FREE(_name);
if (_unit) FREE(_unit);
}
finish:
AryFree(&a);
AryFree(&b);
TxtClr(&usr);
TxtClr(&sys);
return 0;
eX_1:
eMSG(_strange_filename_$_, file);
eX_2: eX_4:
eMSG(_cant_read_file_$_, fn);
eX_3:
eMSG(_improper_dimension_$_, fn);
}

//======================================================================= TutLogMon
//
int TutLogMon( // write values at monitor points into log-file
char *path, // working directory
char *file, // file name base
int prec, // number of decimal positions
int ii ) // sequence count
{
dP(TutLogMon);
char fn[256], species[40], type[40], grdx[32], format[32], units[32];
ARYDSC a;
int i, i1, i2, j, j1, j2, k, k1, k2, nz, n, ng, ip, np;
int nparts=0; //-2002-08-28
float *values=NULL;
char *pc, *_artp, *_unit, *_name, *_vldf, *_form, *_file;
float zz[101], xmin=0, ymin=0, delta=1;
TXTSTR usr = { NULL, 0 };
TXTSTR sys = { NULL, 0 };
FILE *f;
if (!path || !file || !*file || TI.np<1) return 0;
f = (MsgFile) ? MsgFile : stdout;
memset(&a, 0, sizeof(ARYDSC));
np = TI.np;
values = ALLOC(np*sizeof(float));
for (ip=0; ip if (prec < 0) strcpy(format, " %10.3e");
else sprintf(format, " %%6.%df", prec);
*units = 0;
ng = TI.nn;
if (ii < 1) {
fprintf(f, _eval_additional_);
fprintf(f, _sepa_additional_);
fprintf(f, _point_);
for (ip=0; ip fprintf(f, "\n");
fprintf(f, "%-4s ", "xp");
for (ip=0; ip fprintf(f, "\n");
fprintf(f, "%-4s ", "yp");
for (ip=0; ip fprintf(f, "\n");
fprintf(f, "%-4s ", "hp");
for (ip=0; ip fprintf(f, "\n");
nparts++;
}
if (ii < 2) {
fprintf(f, "--------");
for (ip=0; ip fprintf(f, "+------");
if (prec < 0) fprintf(f, "----");
}
fprintf(f, "\n");
nparts++;
}
//
strcpy(species, file);
pc = strchr(species, '-'); if (!pc) eX(1);
*pc = 0;
strcpy(type, pc+1);
for (pc=species; (*pc); pc++) *pc = toupper(*pc);
for (pc=type; (*pc); pc++) *pc = toupper(*pc);
//
fprintf(f, "%-4s %3s", species, type); //-2002-08-28
for (n=0; n if (ng == 1) *grdx = 0;
else sprintf(grdx, "%02d", n+1);
sprintf(fn, "%s/%s%s%s.dmna", path, file, CfgAddString, grdx); //-2006-10-31
if (!TutFileExists(fn)) {
fprintf(f, " n.v.\n");
goto finish;
}
DmnRead(fn, &usr, &sys, &a); eG(2);
if (a.numdm == 2) {
k1 = k2 = 0;
}
else if (a.numdm == 3) {
k1 = 1;
k2 = a.bound[2].hgh;
}
else eX(3);
i1 = a.bound[0].low;
i2 = a.bound[0].hgh;
j1 = a.bound[1].low;
j2 = a.bound[1].hgh;
DmnGetString(usr.s, "artp", &_artp, 1);
DmnGetString(usr.s, "name", &_name, 1);
DmnGetString(usr.s, "unit", &_unit, 1);
DmnGetString(usr.s, "vldf", &_vldf, 1);
DmnGetString(sys.s, "form", &_form, 1);
DmnGetString(sys.s, "file", &_file, 1);
DmnGetFloat(usr.s, "xmin", "%f", &xmin, 1);
DmnGetFloat(usr.s, "ymin", "%f", &ymin, 1);
DmnGetFloat(usr.s, "delta", "%f", &delta, 1);
nz = DmnGetFloat(usr.s, "sk", "%f", zz, 101);
if (nz < k2) k2 = nz;
for (ip=0; ip if (values[ip] >= 0) continue;
i = i1 + (TI.xp[ip] - xmin)/delta;
j = j1 + (TI.yp[ip] - ymin)/delta;
if (strcmp(type, "DEP")) {
for (k=k1; k<=k2; k++)
if (TI.hp[ip] <= zz[k]) break;
}
else k = 0;
if (i>=i1 && i<=i2 && j>=j1 && j<=j2 && k>=k1 && k<=k2) {
values[ip] = *(float*) AryPtrX(&a, i, j, k);
strcpy(units, _unit);
}
}
if (_artp) FREE(_artp);
if (_file) FREE(_file);
if (_form) FREE(_form);
if (_vldf) FREE(_vldf);
if (_name) FREE(_name);
if (_unit) FREE(_unit);
}
for (ip=0; ip if (values[ip] < 0) fprintf(f, " ---");
else fprintf(f, format, values[ip]);
fprintf(f, " %s\n", units);
nparts++;
finish:
AryFree(&a);
TxtClr(&usr);
TxtClr(&sys);
if (values) FREE(values);
return nparts;
eX_1:
eMSG(_strange_filename_$_, file);
eX_2:
eMSG(_cant_read_file_$_, fn);
eX_3:
eMSG(_improper_dimension_$_, fn);
}

//=============================================================================
//
// history:
//
// 2002-02-25 lj 0.10.0 extracted from TALutils
// 2002-03-28 lj 0.11.0 adapted to new vMsg()
// 2002-05-03 lj 0.12.1 coordinates of maximum only for vmax>0 printed
// 2002-07-13 lj 0.13.1 warning if maximum near border
// 2002-08-28 lj 0.13.2 adapted to TalMon (nparts)
// 2002-09-24 lj 1.0.0 final release candidate
// 2004-06-10 lj 2.0.1 output of odor hour probability
// 2004-10-20 lj 2.1.4 boundary values (2 cells) of inner grids discarded
// 2005-03-17 uj 2.2.0 version number upgrade
// 2006-10-26 lj 2.3.0 external strings
// 2006-10-31 lj 2.3.1 configuration data
//
//=============================================================================

Google
  Web www.Petersen-Kade.com