Skip to content

Commit

Permalink
Add USE_FC_LEN_T to satisfy CRAN
Browse files Browse the repository at this point in the history
- This concerns a change to R 3.6.5 which will be required in R 4.2.0

- has something to do with passing character strings from C to Fortran,
  used in effectscan.c and lapackutil.c. (Was able to just delete
  one function from lapackutil.c.)

- See <https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Fortran-character-strings>
  • Loading branch information
kbroman committed Sep 25, 2021
1 parent b581057 commit 069a520
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 34 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: qtl
Version: 1.49-2
Date: 2021-08-05
Version: 1.49-3
Date: 2021-09-25
Title: Tools for Analyzing QTL Experiments
Author: Karl W Broman <[email protected]> and Hao Wu, with
ideas from Gary Churchill and Saunak Sen and contributions from
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ copyright (c) 2001-2021, Karl W Broman

- Revised qtlversion() to handle a case like "1.50".

- Added `#define USE_FC_LEN_T` in C code that calls Fortran, because
of a change in R 3.6.5 that's going to be required in R 4.2.0.


## Version 1.48, 2021-03-24

Expand Down
13 changes: 9 additions & 4 deletions src/effectscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
*
* effectscan.c
*
* copyright (c) 2007-8, Karl W Broman
* copyright (c) 2007-2021, Karl W Broman
*
* last modified Jan, 2008
* last modified Sep, 2021
* first written Sep, 2007
*
* This program is free software; you can redistribute it and/or
Expand All @@ -28,16 +28,21 @@
*
**********************************************************************/

#define USE_FC_LEN_T
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <Rconfig.h>
#include <R.h>
#include <Rmath.h>
#include <R_ext/PrtUtil.h>
#include <R_ext/Applic.h>
#include <R_ext/Lapack.h>
#include "effectscan.h"
#include "util.h"
#ifndef FCONE
# define FCONE
#endif

/* R_effectscan: wrapper for effectscan */

Expand Down Expand Up @@ -126,7 +131,7 @@ void effectscan(int nind, int ngen, int ndraws, int npos,
if(!flag[i]) {
/* linear regression */
F77_CALL(dgels)("N", &nind, &ngen, &nphe, x, &nind, resid, &nind,
dwork, &lwork, &info);
dwork, &lwork, &info FCONE);

/* coefficient estimates */
for(j=0; j<ngen; j++) wbeta[j+i*ngen] = resid[j];
Expand All @@ -147,7 +152,7 @@ void effectscan(int nind, int ngen, int ndraws, int npos,
memcpy(var+j*ngen, x+j*nind, ngen*sizeof(double));

/* (X'X)^-1 */
F77_CALL(dpotri)("U", &ngen, var, &ngen, &info);
F77_CALL(dpotri)("U", &ngen, var, &ngen, &info FCONE);

/* estimated variances of estimated coefficients */
for(j=0; j<ngen; j++) wvar[j + i*ngen] = sigmasq * var[j+j*ngen];
Expand Down
21 changes: 10 additions & 11 deletions src/lapackutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
*
* lapackutil.c
*
* copyright (c) 2006, Hao Wu
* copyright (c) 2006-2021, Hao Wu and Karl Broman
*
* last modified Feb, 2006
* last modified Sep, 2021
* first written Jan, 2006
*
* This program is free software; you can redistribute it and/or
Expand All @@ -27,16 +27,21 @@
*
**********************************************************************/

#define USE_FC_LEN_T
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <Rconfig.h>
#include <R.h>
#include <Rmath.h>
#include <R_ext/PrtUtil.h>
#include <R_ext/Applic.h>
#include <R_ext/Lapack.h>
#include "lapackutil.h"
#define TOL 1e-12
#ifndef FCONE
# define FCONE
#endif


/* DGELSS function */
Expand All @@ -48,7 +53,7 @@ void mydgelss (int *n_ind, int *ncolx0, int *nphe, double *x0, double *x0_bk,

/* use dgels first */
F77_CALL(dgels)("N", n_ind, ncolx0, nphe, x0, n_ind, tmppheno, n_ind,
work, lwork, info);
work, lwork, info FCONE);

/* if there's problem like singular, use dgelss */
/* note that x0 will contain the result for QR decomposition.
Expand Down Expand Up @@ -81,21 +86,15 @@ void mydgemm(int *nphe, int *n_ind, double *alpha, double *tmppheno,
double *beta, double *rss_det)
{
F77_CALL(dgemm)("T", "N", nphe, nphe, n_ind, alpha, tmppheno, n_ind,
tmppheno, n_ind, beta, rss_det, nphe);
tmppheno, n_ind, beta, rss_det, nphe FCONE FCONE);
}

/* DPOTRF */
void mydpotrf(int *nphe, double *rss_det, int *info)
{
F77_CALL(dpotrf)("U", nphe, rss_det, nphe, info);
F77_CALL(dpotrf)("U", nphe, rss_det, nphe, info FCONE);
}

/*DPOTRS */
void mydpotrs(char *uplo, int *n, int *nrhs, double *A,
int *lda, double *B, int *ldb, int *info)
{
F77_CALL(dpotrs)(uplo, n, nrhs, A, lda, B, ldb, info);
}


/* end of lapackutil.c */
6 changes: 1 addition & 5 deletions src/lapackutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* These are some wrapper functions for several LAPACK routines.
*
* Contains: mydgelss, mydgemm, mydpotrf, mydpotrs
* Contains: mydgelss, mydgemm, mydpotrf
*
**********************************************************************/

Expand All @@ -39,8 +39,4 @@ void mydgemm(int *nphe, int *n_ind, double *alpha, double *tmppheno, double *bet
/* DPOTRF */
void mydpotrf(int *nphe1, double *rss_det, int *info);

/* DPOTRS */
void mydpotrs(char *uplo, int *n, int *nrhs, double *A,
int *lda, double *B, int *ldb, int *info);

/* end of lapackutil.h */
12 changes: 0 additions & 12 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
**********************************************************************/

#include <R.h>
/* #include <R_ext/BLAS.h> */
#include "util.h"

#define THRESH 200.0
Expand Down Expand Up @@ -702,17 +701,6 @@ void locate_xo(int n_ind, int n_mar, int type, int **Geno,
} /* end loop over individuals */
}

/* multiply two matrices - I'm using dgemm from lapack here */
/*
void matmult2(double *result, double *a, int nrowa,
int ncola, double *b, int ncolb)
{
double alpha=1.0, beta=1.0;
F77_CALL(dgemm)("N", "N", &nrowa, &ncolb, &ncola, &alpha, a, &nrowa,
b, &ncola, &beta, result, &nrowa);
}
*/

void matmult(double *result, double *a, int nrowa,
int ncola, double *b, int ncolb)
Expand Down

0 comments on commit 069a520

Please sign in to comment.