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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
/*
ccp4_unitcell_f.c: Fortran API to ccp4_unitcell.c
Copyright (C) 2001 CCLRC, Martyn Winn
This library is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
version 3, modified in accordance with the provisions of the
license to address the requirements of UK law.
You should have received a copy of the modified GNU Lesser General
Public License along with this library. If not, copies may be
downloaded from http://www.ccp4.ac.uk/ccp4license.php
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
*/
/** @file ccp4_unitcell_f.c
* Fortran API to ccp4_unitcell.c.
* Martyn Winn
*/
#include "ccp4_fortran.h"
#include "ccp4_unitcell.h"
/* rcsid[] = "$Id$" */
/* from input cell and orthogonalisation code, find orthogonalisation
and fractionalisation matrices. Returns cell volume. */
FORTRAN_SUBR ( CCP4UC_F_FRAC_ORTH_MAT, ccp4uc_f_frac_orth_mat,
(const float cell[6], const int *ncode,
float ro[3][3], float rf[3][3], float *volume),
(const float cell[6], const int *ncode,
float ro[3][3], float rf[3][3], float *volume),
(const float cell[6], const int *ncode,
float ro[3][3], float rf[3][3], float *volume))
{
int i,j;
double ro_cmat[3][3], rf_cmat[3][3], dcell[6];
for (i = 0; i < 6; ++i)
dcell[i] = (double) cell[i];
*volume = (float) ccp4uc_frac_orth_mat(dcell, *ncode, ro_cmat, rf_cmat);
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
ro[i][j] = (float) ro_cmat[j][i];
rf[i][j] = (float) rf_cmat[j][i];
}
}
}
FORTRAN_SUBR ( CCP4UC_F_CALC_RCELL, ccp4uc_f_calc_rcell,
(const float cell[6], float rcell[6], float *rvolume),
(const float cell[6], float rcell[6], float *rvolume),
(const float cell[6], float rcell[6], float *rvolume))
{
int i;
double dcell[6],drcell[6];
for (i = 0; i < 6; ++i)
dcell[i] = (double) cell[i];
*rvolume = (float) ccp4uc_calc_rcell(dcell, drcell);
for (i = 0; i < 6; ++i)
rcell[i] = (float) drcell[i];
}
FORTRAN_SUBR ( CCP4UC_F_ORTH_TO_FRAC, ccp4uc_f_orth_to_frac,
(const float rf[3][3], const float xo[3], float xf[3]),
(const float rf[3][3], const float xo[3], float xf[3]),
(const float rf[3][3], const float xo[3], float xf[3]))
{
int i,j;
double rf_cmat[3][3], dxo[3], dxf[3];
for (i = 0; i < 3; ++i) {
dxo[i] = (double) xo[i];
for (j = 0; j < 3; ++j)
rf_cmat[i][j] = (double) rf[j][i];
}
ccp4uc_orth_to_frac((const double (*)[3])rf_cmat, dxo, dxf);
for (i = 0; i < 3; ++i)
xf[i] = (float) dxf[i];
}
FORTRAN_SUBR ( CCP4UC_F_FRAC_TO_ORTH, ccp4uc_f_frac_to_orth,
(const float ro[3][3], const float xf[3], float xo[3]),
(const float ro[3][3], const float xf[3], float xo[3]),
(const float ro[3][3], const float xf[3], float xo[3]))
{
int i,j;
double ro_cmat[3][3], dxf[3], dxo[3];
for (i = 0; i < 3; ++i) {
dxf[i] = (double) xf[i];
for (j = 0; j < 3; ++j)
ro_cmat[i][j] = (double) ro[j][i];
}
ccp4uc_orth_to_frac((const double (*)[3])ro_cmat, dxf, dxo);
for (i = 0; i < 3; ++i)
xo[i] = (float) dxo[i];
}
FORTRAN_SUBR ( CCP4UC_F_ORTHU_TO_FRACU, ccp4uc_f_orthu_to_fracu,
(const float rf[3][3], const float uo[3], float uf[3]),
(const float rf[3][3], const float uo[3], float uf[3]),
(const float rf[3][3], const float uo[3], float uf[3]))
{
int i,j;
double rf_cmat[3][3], duo[3], duf[3];
for (i = 0; i < 3; ++i) {
duo[i] = (double) uo[i];
for (j = 0; j < 3; ++j)
rf_cmat[i][j] = (double) rf[j][i];
}
ccp4uc_orthu_to_fracu((const double (*)[3])rf_cmat, duo, duf);
for (i = 0; i < 3; ++i)
uf[i] = (float) duf[i];
}
FORTRAN_SUBR ( CCP4UC_F_FRACU_TO_ORTHU, ccp4uc_f_fracu_to_orthu,
(const float ro[3][3], const float uf[3], float uo[3]),
(const float ro[3][3], const float uf[3], float uo[3]),
(const float ro[3][3], const float uf[3], float uo[3]))
{
int i,j;
double ro_cmat[3][3], duf[3], duo[3];
for (i = 0; i < 3; ++i) {
duf[i] = (double) uf[i];
for (j = 0; j < 3; ++j)
ro_cmat[i][j] = (double) ro[j][i];
}
ccp4uc_orthu_to_fracu((const double (*)[3])ro_cmat, duf, duo);
for (i = 0; i < 3; ++i)
uo[i] = (float) duo[i];
}
FORTRAN_SUBR ( CELLCHK, cellchk,
(const float cell1[6], const float cell2[6], const float *errfrc, int *ierr),
(const float cell1[6], const float cell2[6], const float *errfrc, int *ierr),
(const float cell1[6], const float cell2[6], const float *errfrc, int *ierr))
{
int i;
double dcell1[6], dcell2[6];
for (i = 0; i < 6; ++i) {
dcell1[i] = (double) cell1[i];
dcell2[i] = (double) cell2[i];
}
*ierr = ccp4uc_cells_differ(dcell1, dcell2, (double) *errfrc);
}
|