2
ccp4_unitcell_f.c: Fortran API to ccp4_unitcell.c
3
Copyright (C) 2001 CCLRC, Martyn Winn
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
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.
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
22
/** @file ccp4_unitcell_f.c
23
* @brief Fortran API to ccp4_unitcell.c.
27
#include "ccp4_fortran.h"
28
#include "ccp4_unitcell.h"
30
/* from input cell and orthogonalisation code, find orthogonalisation
31
and fractionalisation matrices. Returns cell volume. */
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))
42
double ro_cmat[3][3], rf_cmat[3][3], dcell[6];
44
for (i = 0; i < 6; ++i)
45
dcell[i] = (double) cell[i];
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];
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))
62
double dcell[6],drcell[6];
64
for (i = 0; i < 6; ++i)
65
dcell[i] = (double) cell[i];
67
*rvolume = (float) ccp4uc_calc_rcell(dcell, drcell);
69
for (i = 0; i < 6; ++i)
70
rcell[i] = (float) drcell[i];
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]))
80
double rf_cmat[3][3], dxo[3], dxf[3];
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];
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];
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]))
98
double ro_cmat[3][3], dxf[3], dxo[3];
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];
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];
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]))
117
double rf_cmat[3][3], duo[3], duf[3];
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];
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];
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]))
136
double ro_cmat[3][3], duf[3], duo[3];
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];
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];
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))
155
double dcell1[6], dcell2[6];
157
for (i = 0; i < 6; ++i) {
158
dcell1[i] = (double) cell1[i];
159
dcell2[i] = (double) cell2[i];
162
*ierr = ccp4uc_cells_differ(dcell1, dcell2, (double) *errfrc);