]> git.uio.no Git - u/mrichter/AliRoot.git/blame - LHAPDF/lhapdf5.5.1/src/getdatapath.cc
absolute path to datasets remobed
[u/mrichter/AliRoot.git] / LHAPDF / lhapdf5.5.1 / src / getdatapath.cc
CommitLineData
0caf84a5 1#include "LHAPDF/FortranWrappers.h"
2#include <iostream>
3#include <string>
4#include <cstring>
5#include <cassert>
6#include <unistd.h>
7#include "binreloc.h"
8
9using namespace std;
10
11
12#define SIZE 499
13
14
15extern "C" {
16
17
18 #define fgetdirpath FC_FUNC(getdirpath, GETDIRPATH)
19 void fgetdirpath(char*, int);
20
21
22 #define fgetprefixpath FC_FUNC(getprefixpath, GETPREFIXPATH)
23 void fgetprefixpath(char* prefixpath, int length) {
24 BrInitError error;
25 br_init_lib(&error);
26 string prefixdir = br_find_prefix(DEFAULTPREFIXPATH);
27 string test1 = prefixdir + "/share/lhapdf";
28 if (access(test1.c_str(), R_OK) != 0) {
29 prefixdir = DEFAULTPREFIXPATH;
30 }
31 assert(prefixdir.length() <= (unsigned) length);
32 strncpy(prefixpath, prefixdir.c_str(), length);
33 // Replace null-terminated string convention with Fortran "trailing spaces" convention:
34 for (size_t i = strlen(prefixpath); i < (unsigned) length; ++i) {
35 prefixpath[i] = ' ';
36 }
37 }
38
39
40 #define fgetindexpath FC_FUNC(getindexpath, GETINDEXPATH)
41 void fgetindexpath(char* indexpath, int length) {
42 char tmp[SIZE+1];
43 tmp[SIZE] = '\0';
44 fgetdirpath(tmp, SIZE);
45 //for (size_t i = 0; i < SIZE; ++i) {
46 // tmp[i] = ' ';
47 //}
48 for (size_t i = SIZE-1; i >= 0; --i) {
49 if (tmp[i] != ' ') break;
50 tmp[i] = '\0';
51 }
52 string try1(tmp), try2(tmp);
53 try1 += "/PDFsets.index";
54 try2 += ".index";
55 if (access(try1.c_str(), R_OK) == 0) {
56 assert(try1.length() <= (unsigned) length);
57 strncpy(indexpath, try1.c_str(), length);
58 } else {
59 assert(try2.length() <= (unsigned) length);
60 strncpy(indexpath, try2.c_str(), length);
61 }
62 // Replace null-terminated string convention with Fortran "trailing spaces" convention:
63 for (size_t i = strlen(indexpath); i < (unsigned) length; ++i) {
64 indexpath[i] = ' ';
65 }
66 }
67
68
69 #define fgetdatapath FC_FUNC(getdatapath, GETDATAPATH)
70 void fgetdatapath(char* datapath, int length) {
71 BrInitError error;
72 br_init_lib(&error);
73 string sharedir = br_find_data_dir(DEFAULTLHAPATH);
74 string tmp = sharedir + "/lhapdf/PDFsets";
75 string test1 = tmp + "/cteq6.LHpdf";
76 if (access(test1.c_str(), R_OK) != 0) {
f66349bc 77 tmp = string(DEFAULTLHAPATH);
0caf84a5 78 }
79 assert(tmp.length() <= (unsigned) length);
80 strncpy(datapath, tmp.c_str(), length);
81 // Replace null-terminated string convention with Fortran "trailing spaces" convention:
82 for (size_t i = strlen(datapath); i < (unsigned) length; ++i) {
83 datapath[i] = ' ';
84 }
85 }
86
87
88}