| 1 |
/* |
| 2 |
* *************************************************************************** |
| 3 |
* MALOC = < Minimal Abstraction Layer for Object-oriented C > |
| 4 |
* Copyright (C) 1994-- Michael Holst |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
* |
| 20 |
* rcsid="$Id: vnmfb.c,v 1.9 2010/08/12 05:40:32 fetk Exp $" |
| 21 |
* *************************************************************************** |
| 22 |
*/ |
| 23 |
|
| 24 |
/* |
| 25 |
* *************************************************************************** |
| 26 |
* File: vnmfb.c |
| 27 |
* |
| 28 |
* Purpose: FORTRAN bindings for the Vnm class methods. |
| 29 |
* |
| 30 |
* Notes: We provide FORTRAN stubs for the following manglings: |
| 31 |
* |
| 32 |
* vrnd --> no underscore, lowercase (default) |
| 33 |
* VRND --> no underscore, uppercase |
| 34 |
* vrnd_ --> single underscore, lowercase |
| 35 |
* VRND_ --> single underscore, uppercase |
| 36 |
* vrnd__ --> double underscore, lowercase |
| 37 |
* VRND__ --> double underscore, uppercase |
| 38 |
* |
| 39 |
* Author: Michael Holst |
| 40 |
* *************************************************************************** |
| 41 |
*/ |
| 42 |
|
| 43 |
#include "vnm_p.h" |
| 44 |
|
| 45 |
VEMBED(rcsid="$Id: vnmfb.c,v 1.9 2010/08/12 05:40:32 fetk Exp $") |
| 46 |
|
| 47 |
/* |
| 48 |
* *************************************************************************** |
| 49 |
* Class Vnm FORTRAN binding prototypes (default: no underscore, lowercase) |
| 50 |
* *************************************************************************** |
| 51 |
*/ |
| 52 |
|
| 53 |
VEXTERNC int vrnd(void); |
| 54 |
VEXTERNC int vrndmx(void); |
| 55 |
VEXTERNC double vepsma(void); |
| 56 |
VEXTERNC void vtstrt(int *timer, char *name, int *len); |
| 57 |
VEXTERNC void vtstop(int *timer, char *name, int *len); |
| 58 |
VEXTERNC int vsystm(char *cmd, int *len); |
| 59 |
VEXTERNC void vnmprt(int *unit, char *strng, int *len); |
| 60 |
VEXTERNC void vnmpri(int *unit, char *strng, int *len, int *val); |
| 61 |
VEXTERNC void vnmprd(int *unit, char *strng, int *len, double *val); |
| 62 |
|
| 63 |
/* |
| 64 |
* *************************************************************************** |
| 65 |
* Class Vnm FORTRAN bindings |
| 66 |
* *************************************************************************** |
| 67 |
*/ |
| 68 |
|
| 69 |
/* |
| 70 |
* *************************************************************************** |
| 71 |
* Routine: vrnd |
| 72 |
* |
| 73 |
* Purpose: Returns a pseudo-random integer between 0 and VRANDMAX. |
| 74 |
* |
| 75 |
* Author: Michael Holst |
| 76 |
* *************************************************************************** |
| 77 |
*/ |
| 78 |
VPUBLIC int vrnd(void) |
| 79 |
{ |
| 80 |
return VRAND; |
| 81 |
} |
| 82 |
|
| 83 |
/* |
| 84 |
* *************************************************************************** |
| 85 |
* Routine: vrndmx |
| 86 |
* |
| 87 |
* Purpose: Returns VRANDMAX. |
| 88 |
* |
| 89 |
* Author: Michael Holst |
| 90 |
* *************************************************************************** |
| 91 |
*/ |
| 92 |
VPUBLIC int vrndmx(void) |
| 93 |
{ |
| 94 |
return VRANDMAX; |
| 95 |
} |
| 96 |
|
| 97 |
/* |
| 98 |
* *************************************************************************** |
| 99 |
* Routine: vepsma |
| 100 |
* |
| 101 |
* Purpose: Computes the unit roundoff of the machine in single precision. |
| 102 |
* |
| 103 |
* Author: Michael Holst |
| 104 |
* *************************************************************************** |
| 105 |
*/ |
| 106 |
VPUBLIC double vepsma(void) |
| 107 |
{ |
| 108 |
return Vnm_epsmac(); |
| 109 |
} |
| 110 |
|
| 111 |
/* |
| 112 |
* *************************************************************************** |
| 113 |
* Routine: vtstrt |
| 114 |
* |
| 115 |
* Purpose: Starts the timer on the particular machine. |
| 116 |
* |
| 117 |
* Author: Michael Holst |
| 118 |
* *************************************************************************** |
| 119 |
*/ |
| 120 |
VPUBLIC void vtstrt(int *timer, char *name, int *len) |
| 121 |
{ |
| 122 |
int i; |
| 123 |
char buf[VMAX_ARGLEN]; |
| 124 |
|
| 125 |
VASSERT( VMAX_ARGLEN > *len ); |
| 126 |
for (i=0; i<*len; i++) { |
| 127 |
buf[i] = name[i]; |
| 128 |
} |
| 129 |
buf[*len] = '\0'; |
| 130 |
|
| 131 |
Vnm_tstart(*timer, buf); |
| 132 |
} |
| 133 |
|
| 134 |
/* |
| 135 |
* *************************************************************************** |
| 136 |
* Routine: vtstop |
| 137 |
* |
| 138 |
* Purpose: Stops the timer on the particular machine. |
| 139 |
* |
| 140 |
* Author: Michael Holst |
| 141 |
* *************************************************************************** |
| 142 |
*/ |
| 143 |
VPUBLIC void vtstop(int *timer, char *name, int *len) |
| 144 |
{ |
| 145 |
int i; |
| 146 |
char buf[VMAX_ARGLEN]; |
| 147 |
|
| 148 |
VASSERT( VMAX_ARGLEN > *len ); |
| 149 |
for (i=0; i<*len; i++) { |
| 150 |
buf[i] = name[i]; |
| 151 |
} |
| 152 |
buf[*len] = '\0'; |
| 153 |
|
| 154 |
Vnm_tstop(*timer, buf); |
| 155 |
} |
| 156 |
|
| 157 |
/* |
| 158 |
* *************************************************************************** |
| 159 |
* Routine: vsystm |
| 160 |
* |
| 161 |
* Purpose: An improved ANSI-C "system" call. |
| 162 |
* |
| 163 |
* Author: Michael Holst |
| 164 |
* *************************************************************************** |
| 165 |
*/ |
| 166 |
VPUBLIC int vsystm(char *cmd, int *len) |
| 167 |
{ |
| 168 |
int i; |
| 169 |
char buf[VMAX_ARGLEN]; |
| 170 |
|
| 171 |
VASSERT( VMAX_ARGLEN > *len ); |
| 172 |
for (i=0; i<*len; i++) { |
| 173 |
buf[i] = cmd[i]; |
| 174 |
} |
| 175 |
buf[*len] = '\0'; |
| 176 |
|
| 177 |
return Vnm_system(buf); |
| 178 |
} |
| 179 |
|
| 180 |
/* |
| 181 |
* *************************************************************************** |
| 182 |
* Routine: vnmprt |
| 183 |
* |
| 184 |
* Purpose: External interface to the console i/o routine. |
| 185 |
* |
| 186 |
* Author: Michael Holst |
| 187 |
* *************************************************************************** |
| 188 |
*/ |
| 189 |
VPUBLIC void vnmprt(int *unit, char *strng, int *len) |
| 190 |
{ |
| 191 |
int i; |
| 192 |
char buf[VMAX_ARGLEN]; |
| 193 |
|
| 194 |
VASSERT( VMAX_ARGLEN > *len ); |
| 195 |
for (i=0; i<*len; i++) { |
| 196 |
buf[i] = strng[i]; |
| 197 |
} |
| 198 |
buf[*len] = '\0'; |
| 199 |
|
| 200 |
Vnm_print(*unit, "%s\n", buf); |
| 201 |
} |
| 202 |
|
| 203 |
/* |
| 204 |
* *************************************************************************** |
| 205 |
* Routine: vnmpri |
| 206 |
* |
| 207 |
* Purpose: External interface to the console i/o routine. |
| 208 |
* |
| 209 |
* Author: Michael Holst |
| 210 |
* *************************************************************************** |
| 211 |
*/ |
| 212 |
VPUBLIC void vnmpri(int *unit, char *strng, int *len, int *val) |
| 213 |
{ |
| 214 |
int i; |
| 215 |
char buf[VMAX_ARGLEN]; |
| 216 |
|
| 217 |
VASSERT( VMAX_ARGLEN > *len ); |
| 218 |
for (i=0; i<*len; i++) { |
| 219 |
buf[i] = strng[i]; |
| 220 |
} |
| 221 |
buf[*len] = '\0'; |
| 222 |
|
| 223 |
Vnm_print(*unit, "%s %d\n", buf, *val); |
| 224 |
} |
| 225 |
|
| 226 |
/* |
| 227 |
* *************************************************************************** |
| 228 |
* Routine: vnmprd |
| 229 |
* |
| 230 |
* Purpose: External interface to the console i/o routine. |
| 231 |
* |
| 232 |
* Author: Michael Holst |
| 233 |
* *************************************************************************** |
| 234 |
*/ |
| 235 |
VPUBLIC void vnmprd(int *unit, char *strng, int *len, double *val) |
| 236 |
{ |
| 237 |
int i; |
| 238 |
char buf[VMAX_ARGLEN]; |
| 239 |
|
| 240 |
VASSERT( VMAX_ARGLEN > *len ); |
| 241 |
for (i=0; i<*len; i++) { |
| 242 |
buf[i] = strng[i]; |
| 243 |
} |
| 244 |
buf[*len] = '\0'; |
| 245 |
|
| 246 |
Vnm_print(*unit, "%s %e\n", buf, *val); |
| 247 |
} |
| 248 |
|
| 249 |
/* |
| 250 |
* *************************************************************************** |
| 251 |
* Class Vnm FORTRAN binding STUBS (no underscore, uppercase) |
| 252 |
* *************************************************************************** |
| 253 |
*/ |
| 254 |
|
| 255 |
VPUBLIC int VRND(void) |
| 256 |
{ |
| 257 |
return vrnd(); |
| 258 |
} |
| 259 |
|
| 260 |
VPUBLIC int VRNDMX(void) |
| 261 |
{ |
| 262 |
return vrndmx(); |
| 263 |
} |
| 264 |
|
| 265 |
VPUBLIC double VEPSMA(void) |
| 266 |
{ |
| 267 |
return vepsma(); |
| 268 |
} |
| 269 |
|
| 270 |
VPUBLIC void VTSTRT(int *timer, char *name, int *len) |
| 271 |
{ |
| 272 |
vtstrt(timer, name, len); |
| 273 |
} |
| 274 |
|
| 275 |
VPUBLIC void VTSTOP(int *timer, char *name, int *len) |
| 276 |
{ |
| 277 |
vtstop(timer, name, len); |
| 278 |
} |
| 279 |
|
| 280 |
VPUBLIC int VSYSTM(char *cmd, int *len) |
| 281 |
{ |
| 282 |
return vsystm(cmd, len); |
| 283 |
} |
| 284 |
|
| 285 |
VPUBLIC void VNMPRT(int *unit, char *strng, int *len) |
| 286 |
{ |
| 287 |
vnmprt(unit, strng, len); |
| 288 |
} |
| 289 |
|
| 290 |
VPUBLIC void VNMPRI(int *unit, char *strng, int *len, int *val) |
| 291 |
{ |
| 292 |
vnmpri(unit, strng, len, val); |
| 293 |
} |
| 294 |
|
| 295 |
VPUBLIC void VNMPRD(int *unit, char *strng, int *len, double *val) |
| 296 |
{ |
| 297 |
vnmprd(unit, strng, len, val); |
| 298 |
} |
| 299 |
|
| 300 |
/* |
| 301 |
* *************************************************************************** |
| 302 |
* Class Vnm FORTRAN binding STUBS (one underscore, lowercase) |
| 303 |
* *************************************************************************** |
| 304 |
*/ |
| 305 |
|
| 306 |
VPUBLIC int vrnd_(void) |
| 307 |
{ |
| 308 |
return vrnd(); |
| 309 |
} |
| 310 |
|
| 311 |
VPUBLIC int vrndmx_(void) |
| 312 |
{ |
| 313 |
return vrndmx(); |
| 314 |
} |
| 315 |
|
| 316 |
VPUBLIC double vepsma_(void) |
| 317 |
{ |
| 318 |
return vepsma(); |
| 319 |
} |
| 320 |
|
| 321 |
VPUBLIC void vtstrt_(int *timer, char *name, int *len) |
| 322 |
{ |
| 323 |
vtstrt(timer, name, len); |
| 324 |
} |
| 325 |
|
| 326 |
VPUBLIC void vtstop_(int *timer, char *name, int *len) |
| 327 |
{ |
| 328 |
vtstop(timer, name, len); |
| 329 |
} |
| 330 |
|
| 331 |
VPUBLIC int vsystm_(char *cmd, int *len) |
| 332 |
{ |
| 333 |
return vsystm(cmd, len); |
| 334 |
} |
| 335 |
|
| 336 |
VPUBLIC void vnmprt_(int *unit, char *strng, int *len) |
| 337 |
{ |
| 338 |
vnmprt(unit, strng, len); |
| 339 |
} |
| 340 |
|
| 341 |
VPUBLIC void vnmpri_(int *unit, char *strng, int *len, int *val) |
| 342 |
{ |
| 343 |
vnmpri(unit, strng, len, val); |
| 344 |
} |
| 345 |
|
| 346 |
VPUBLIC void vnmprd_(int *unit, char *strng, int *len, double *val) |
| 347 |
{ |
| 348 |
vnmprd(unit, strng, len, val); |
| 349 |
} |
| 350 |
|
| 351 |
/* |
| 352 |
* *************************************************************************** |
| 353 |
* Class Vnm FORTRAN binding STUBS (one underscore, uppercase) |
| 354 |
* *************************************************************************** |
| 355 |
*/ |
| 356 |
|
| 357 |
VPUBLIC int VRND_(void) |
| 358 |
{ |
| 359 |
return vrnd(); |
| 360 |
} |
| 361 |
|
| 362 |
VPUBLIC int VRNDMX_(void) |
| 363 |
{ |
| 364 |
return vrndmx(); |
| 365 |
} |
| 366 |
|
| 367 |
VPUBLIC double VEPSMA_(void) |
| 368 |
{ |
| 369 |
return vepsma(); |
| 370 |
} |
| 371 |
|
| 372 |
VPUBLIC void VTSTRT_(int *timer, char *name, int *len) |
| 373 |
{ |
| 374 |
vtstrt(timer, name, len); |
| 375 |
} |
| 376 |
|
| 377 |
VPUBLIC void VTSTOP_(int *timer, char *name, int *len) |
| 378 |
{ |
| 379 |
vtstop(timer, name, len); |
| 380 |
} |
| 381 |
|
| 382 |
VPUBLIC int VSYSTM_(char *cmd, int *len) |
| 383 |
{ |
| 384 |
return vsystm(cmd, len); |
| 385 |
} |
| 386 |
|
| 387 |
VPUBLIC void VNMPRT_(int *unit, char *strng, int *len) |
| 388 |
{ |
| 389 |
vnmprt(unit, strng, len); |
| 390 |
} |
| 391 |
|
| 392 |
VPUBLIC void VNMPRI_(int *unit, char *strng, int *len, int *val) |
| 393 |
{ |
| 394 |
vnmpri(unit, strng, len, val); |
| 395 |
} |
| 396 |
|
| 397 |
VPUBLIC void VNMPRD_(int *unit, char *strng, int *len, double *val) |
| 398 |
{ |
| 399 |
vnmprd(unit, strng, len, val); |
| 400 |
} |
| 401 |
|
| 402 |
/* |
| 403 |
* *************************************************************************** |
| 404 |
* Class Vnm FORTRAN binding STUBS (double underscore, lowercase) |
| 405 |
* *************************************************************************** |
| 406 |
*/ |
| 407 |
|
| 408 |
VPUBLIC int vrnd__(void) |
| 409 |
{ |
| 410 |
return vrnd(); |
| 411 |
} |
| 412 |
|
| 413 |
VPUBLIC int vrndmx__(void) |
| 414 |
{ |
| 415 |
return vrndmx(); |
| 416 |
} |
| 417 |
|
| 418 |
VPUBLIC double vepsma__(void) |
| 419 |
{ |
| 420 |
return vepsma(); |
| 421 |
} |
| 422 |
|
| 423 |
VPUBLIC void vtstrt__(int *timer, char *name, int *len) |
| 424 |
{ |
| 425 |
vtstrt(timer, name, len); |
| 426 |
} |
| 427 |
|
| 428 |
VPUBLIC void vtstop__(int *timer, char *name, int *len) |
| 429 |
{ |
| 430 |
vtstop(timer, name, len); |
| 431 |
} |
| 432 |
|
| 433 |
VPUBLIC int vsystm__(char *cmd, int *len) |
| 434 |
{ |
| 435 |
return vsystm(cmd, len); |
| 436 |
} |
| 437 |
|
| 438 |
VPUBLIC void vnmprt__(int *unit, char *strng, int *len) |
| 439 |
{ |
| 440 |
vnmprt(unit, strng, len); |
| 441 |
} |
| 442 |
|
| 443 |
VPUBLIC void vnmpri__(int *unit, char *strng, int *len, int *val) |
| 444 |
{ |
| 445 |
vnmpri(unit, strng, len, val); |
| 446 |
} |
| 447 |
|
| 448 |
VPUBLIC void vnmprd__(int *unit, char *strng, int *len, double *val) |
| 449 |
{ |
| 450 |
vnmprd(unit, strng, len, val); |
| 451 |
} |
| 452 |
|
| 453 |
/* |
| 454 |
* *************************************************************************** |
| 455 |
* Class Vnm FORTRAN binding STUBS (double underscore, uppercase) |
| 456 |
* *************************************************************************** |
| 457 |
*/ |
| 458 |
|
| 459 |
VPUBLIC int VRND__(void) |
| 460 |
{ |
| 461 |
return vrnd(); |
| 462 |
} |
| 463 |
|
| 464 |
VPUBLIC int VRNDMX__(void) |
| 465 |
{ |
| 466 |
return vrndmx(); |
| 467 |
} |
| 468 |
|
| 469 |
VPUBLIC double VEPSMA__(void) |
| 470 |
{ |
| 471 |
return vepsma(); |
| 472 |
} |
| 473 |
|
| 474 |
VPUBLIC void VTSTRT__(int *timer, char *name, int *len) |
| 475 |
{ |
| 476 |
vtstrt(timer, name, len); |
| 477 |
} |
| 478 |
|
| 479 |
VPUBLIC void VTSTOP__(int *timer, char *name, int *len) |
| 480 |
{ |
| 481 |
vtstop(timer, name, len); |
| 482 |
} |
| 483 |
|
| 484 |
VPUBLIC int VSYSTM__(char *cmd, int *len) |
| 485 |
{ |
| 486 |
return vsystm(cmd, len); |
| 487 |
} |
| 488 |
|
| 489 |
VPUBLIC void VNMPRT__(int *unit, char *strng, int *len) |
| 490 |
{ |
| 491 |
vnmprt(unit, strng, len); |
| 492 |
} |
| 493 |
|
| 494 |
VPUBLIC void VNMPRI__(int *unit, char *strng, int *len, int *val) |
| 495 |
{ |
| 496 |
vnmpri(unit, strng, len, val); |
| 497 |
} |
| 498 |
|
| 499 |
VPUBLIC void VNMPRD__(int *unit, char *strng, int *len, double *val) |
| 500 |
{ |
| 501 |
vnmprd(unit, strng, len, val); |
| 502 |
} |
| 503 |
|