File: sharedll.c

package info (click to toggle)
emoslib 000380%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 47,712 kB
  • ctags: 11,551
  • sloc: fortran: 89,643; ansic: 24,200; makefile: 370; sh: 355
file content (117 lines) | stat: -rwxr-xr-x 2,189 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* Copyright 1981-2007 ECMWF
* 
* Licensed under the GNU Lesser General Public License which
* incorporates the terms and conditions of version 3 of the GNU
* General Public License.
* See LICENSE and gpl-3.0.txt for details.
*/

#define SHAREDLL sharedll_

#ifdef linux
#ifndef __USE_LARGEFILE64
#define __USE_LARGEFILE64
#endif
#include <sys/stat.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include "fortint.h"
#include "sharedlib.h"

#include <sys/ipc.h>
#include <sys/shm.h>

#ifndef CRAY
#ifdef FORTRAN_NO_UNDERSCORE
#define SHAREDLL sharedll
#define PBOPEN pbopen
#define PBCLOSE pbclose
#else
#define SHAREDLL sharedll_
#define PBOPEN pbopen_
#define PBCLOSE pbclose_
#endif
#endif



fortint SHAREDLL(
  JPointer* ipdum,
  fortint* iktrunc,
  double* platinc)

/*
C
C**** SHAREDLL
C
C     IPDUM   - Dummy array for mapping legendre function file
C     PLATINC - Grid interval in degrees
C     KTRUNC  - Spherical truncation
C     KRET    - Return status, 0 = OK.
C
*/
{

#if (defined hpR64) || (defined hpiaR64)
long l1, l2;
#else
fortint l1, l2;
#endif

char filedum[128], filename[128];
char ypfn[18] =        "CF_Txxxx_Raabbbb";
static char yold[18] = "xxxxxxxxxxxxxxxx";
char defaultDirectory[] = "./";
int kbuild ;
char * fn;
static fortint fpindex;
static FILE * fp;
static void * result = 0;
fortint kret = 0;

int exist = 0;
int status;
pid_t process_id;
int ktrunc = (int) (*iktrunc);

/*
//  Setup the filename: cf_txxxx_raabbbbb
*/

/*
//  Setup the file name
*/
  sprintf( ypfn+4, "%04d", ktrunc);
  kbuild = (int) (((*platinc)*100000.0) + 0.5);
  sprintf( ypfn+8, "_R%07d", kbuild);

/*
//  See if the  file has already been created.
*/
  fn = getenv("PPDIR");
  if(fn == NULL) fn = defaultDirectory;

  if( (fn != NULL) && (strlen(fn) != 0) ) {
    strcpy( filename, fn );
    strcat( filename, "/");
    strcat( filename, ypfn);
    l1 = strlen(filename);
    l2 = 1;
  }
  /* printf("ll share_file filename=%s\n",filename); */

  result = (void *) share_file(filename);
  if (result == NULL) kret = 1;

  *ipdum = (JPointer) result;

  return kret;
}