~ubuntu-branches/ubuntu/trusty/gpp4/trusty-proposed

« back to all changes in this revision

Viewing changes to src_f/ccp4_unitcell_f.c

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2009-11-09 16:41:48 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091109164148-mz0uet32ywxs010d
Tags: 1.2.0-0ubuntu1
* New upstream version 1.2.0.
* New binary packages added to isolate the mmdb dependency in the 
  Fortran API libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
     ccp4_unitcell_f.c: Fortran API to ccp4_unitcell.c
 
3
     Copyright (C) 2001  CCLRC, Martyn Winn
 
4
 
 
5
     This library is free software; you can redistribute it and/or
 
6
     modify it under the terms of the GNU Lesser General Public
 
7
     License as published by the Free Software Foundation; either
 
8
     version 2.1 of the License, or (at your option) any later
 
9
     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
 
18
     Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
     Boston, MA 02110-1301 USA
 
20
*/
 
21
 
 
22
/** @file ccp4_unitcell_f.c
 
23
 *  @brief Fortran API to ccp4_unitcell.c.
 
24
 *  @author Martyn Winn
 
25
 */
 
26
 
 
27
#include "ccp4_fortran.h"
 
28
#include "ccp4_unitcell.h"
 
29
 
 
30
/* from input cell and orthogonalisation code, find orthogonalisation
 
31
   and fractionalisation matrices. Returns cell volume. */
 
32
 
 
33
FORTRAN_SUBR ( CCP4UC_F_FRAC_ORTH_MAT, ccp4uc_f_frac_orth_mat,
 
34
          (const float cell[6], const int *ncode, 
 
35
           float ro[3][3], float rf[3][3], float *volume),
 
36
          (const float cell[6], const int *ncode, 
 
37
           float ro[3][3], float rf[3][3], float *volume),
 
38
          (const float cell[6], const int *ncode, 
 
39
           float ro[3][3], float rf[3][3], float *volume))
 
40
{
 
41
  int i,j;
 
42
  double ro_cmat[3][3], rf_cmat[3][3], dcell[6];
 
43
 
 
44
  for (i = 0; i < 6; ++i) 
 
45
    dcell[i] = (double) cell[i];
 
46
 
 
47
  *volume =  (float) ccp4uc_frac_orth_mat(dcell, *ncode, ro_cmat, rf_cmat);
 
48
  for (i = 0; i < 3; ++i) {
 
49
    for (j = 0; j < 3; ++j) {
 
50
      ro[i][j] = (float) ro_cmat[j][i];
 
51
      rf[i][j] = (float) rf_cmat[j][i];
 
52
    }
 
53
  }
 
54
}
 
55
 
 
56
FORTRAN_SUBR ( CCP4UC_F_CALC_RCELL, ccp4uc_f_calc_rcell,
 
57
          (const float cell[6], float rcell[6], float *rvolume),
 
58
          (const float cell[6], float rcell[6], float *rvolume),
 
59
          (const float cell[6], float rcell[6], float *rvolume))
 
60
{
 
61
  int i;
 
62
  double dcell[6],drcell[6];
 
63
 
 
64
  for (i = 0; i < 6; ++i) 
 
65
    dcell[i] = (double) cell[i];
 
66
 
 
67
  *rvolume = (float) ccp4uc_calc_rcell(dcell, drcell);
 
68
 
 
69
  for (i = 0; i < 6; ++i) 
 
70
    rcell[i] = (float) drcell[i];
 
71
 
 
72
}
 
73
 
 
74
FORTRAN_SUBR ( CCP4UC_F_ORTH_TO_FRAC, ccp4uc_f_orth_to_frac,
 
75
          (const float rf[3][3], const float xo[3], float xf[3]),
 
76
          (const float rf[3][3], const float xo[3], float xf[3]),
 
77
          (const float rf[3][3], const float xo[3], float xf[3]))
 
78
{
 
79
  int i,j;
 
80
  double rf_cmat[3][3], dxo[3], dxf[3];
 
81
 
 
82
  for (i = 0; i < 3; ++i) {
 
83
    dxo[i] = (double) xo[i];
 
84
    for (j = 0; j < 3; ++j) 
 
85
      rf_cmat[i][j] = (double) rf[j][i];
 
86
  }
 
87
  ccp4uc_orth_to_frac((const double (*)[3]) rf_cmat, dxo, dxf);
 
88
  for (i = 0; i < 3; ++i) 
 
89
    xf[i] = (float) dxf[i];
 
90
}
 
91
 
 
92
FORTRAN_SUBR ( CCP4UC_F_FRAC_TO_ORTH, ccp4uc_f_frac_to_orth,
 
93
          (const float ro[3][3], const float xf[3], float xo[3]),
 
94
          (const float ro[3][3], const float xf[3], float xo[3]),
 
95
          (const float ro[3][3], const float xf[3], float xo[3]))
 
96
{
 
97
  int i,j;
 
98
  double ro_cmat[3][3], dxf[3], dxo[3];
 
99
 
 
100
  for (i = 0; i < 3; ++i) {
 
101
    dxf[i] = (double) xf[i];
 
102
    for (j = 0; j < 3; ++j) 
 
103
      ro_cmat[i][j] = (double) ro[j][i];
 
104
  }
 
105
  ccp4uc_orth_to_frac((const double (*)[3]) ro_cmat, dxf, dxo);
 
106
  for (i = 0; i < 3; ++i) 
 
107
    xo[i] = (float) dxo[i];
 
108
 
 
109
}
 
110
 
 
111
FORTRAN_SUBR ( CCP4UC_F_ORTHU_TO_FRACU, ccp4uc_f_orthu_to_fracu,
 
112
          (const float rf[3][3], const float uo[3], float uf[3]),
 
113
          (const float rf[3][3], const float uo[3], float uf[3]),
 
114
          (const float rf[3][3], const float uo[3], float uf[3]))
 
115
{
 
116
  int i,j;
 
117
  double rf_cmat[3][3], duo[3], duf[3];
 
118
 
 
119
  for (i = 0; i < 3; ++i) {
 
120
    duo[i] = (double) uo[i];
 
121
    for (j = 0; j < 3; ++j) 
 
122
      rf_cmat[i][j] = (double) rf[j][i];
 
123
  }
 
124
  ccp4uc_orthu_to_fracu((const double (*)[3])rf_cmat, duo, duf);
 
125
  for (i = 0; i < 3; ++i) 
 
126
    uf[i] = (float) duf[i];
 
127
 
 
128
}
 
129
 
 
130
FORTRAN_SUBR ( CCP4UC_F_FRACU_TO_ORTHU, ccp4uc_f_fracu_to_orthu,
 
131
          (const float ro[3][3], const float uf[3], float uo[3]),
 
132
          (const float ro[3][3], const float uf[3], float uo[3]),
 
133
          (const float ro[3][3], const float uf[3], float uo[3]))
 
134
{
 
135
  int i,j;
 
136
  double ro_cmat[3][3], duf[3], duo[3];
 
137
 
 
138
  for (i = 0; i < 3; ++i) {
 
139
    duf[i] = (double) uf[i];
 
140
    for (j = 0; j < 3; ++j) 
 
141
      ro_cmat[i][j] = (double) ro[j][i];
 
142
  }
 
143
  ccp4uc_orthu_to_fracu((const double (*)[3])ro_cmat, duf, duo);
 
144
  for (i = 0; i < 3; ++i) 
 
145
    uo[i] = (float) duo[i];
 
146
 
 
147
}
 
148
 
 
149
FORTRAN_SUBR ( CELLCHK, cellchk,
 
150
               (const float cell1[6], const float cell2[6], const float *errfrc, int *ierr),
 
151
               (const float cell1[6], const float cell2[6], const float *errfrc, int *ierr),
 
152
               (const float cell1[6], const float cell2[6], const float *errfrc, int *ierr))
 
153
{
 
154
  int i;
 
155
  double dcell1[6], dcell2[6];
 
156
 
 
157
  for (i = 0; i < 6; ++i) {
 
158
    dcell1[i] = (double) cell1[i];
 
159
    dcell2[i] = (double) cell2[i];
 
160
  }
 
161
 
 
162
  *ierr = ccp4uc_cells_differ(dcell1, dcell2, (double) *errfrc);
 
163
 
 
164
}
 
165
 
 
166
/*
 
167
  Local variables:
 
168
  mode: font-lock
 
169
  End:
 
170
*/