/*****************************************************************************
*     FILE: f2c_interface.c
*
*     This file contains routines that are called by the Fortran version of
*     the PGAPack calls.  They just make the call to the appropriate C
*     routine.  Issues are:
*         * Fortran's always passing by reference,
*         * Using Fortran integers for holding C pointer values
*         * Fortran's 1,...,n indexing vs. C's 0,...,n-1
*           (this comes up in population member and allele indices)
*         * Pointers to functions
*         * File pointers
*         * Characters strings
*         * Variable length argument lists
*
*     We assume the Fortran compiler generates one of three symbol names for
*     the external PGAPack routine, e.g.,  pgasetpopsize,  pgasetpopsize_, or
*     PGASETPOPSIZE.  We use #ifdef's based on the appropriate routine to
*     convert the canonical pgasetpopsize_ to the other two.  Since the real
*     C routine is always mixed case we will never have a conflict.
*
*     Authors: David M. Levine, Philip L. Hallstrom, David M. Noelle
*****************************************************************************/
#include "pgapack.h"

#if defined(FORTRANCAP)
#define pgagetbinaryallele_            PGAGETBINARYALLELE
#define pgasetbinaryallele_            PGASETBINARYALLELE
#define pgagetrealfrombinary_          PGAGETREALFROMBINARY
#define pgagetrealfromgraycode_        PGAGETREALFROMGRAYCODE
#define pgaencoderealasbinary_         PGAENCODEREALASBINARY
#define pgaencoderealasgraycode_       PGAENCODEREALASGRAYCODE
#define pgaencodeintegerasbinary_      PGAENCODEINTEGERASBINARY
#define pgaencodeintegerasgraycode_    PGAENCODEINTEGERASGRAYCODE
#define pgagetintegerfrombinary_       PGAGETINTEGERFROMBINARY
#define pgagetintegerfromgraycode_     PGAGETINTEGERFROMGRAYCODE
#define pgacrossover_                  PGACROSSOVER
#define pgadebugprint_                 PGADEBUGPRINT
#define pgaduplicate_                  PGADUPLICATE
#define pgachange_                     PGACHANGE
#define pgaevaluate_                   PGAEVALUATE
#define pgasetevaluate_                PGASETEVALUATE
#define pgasetevaluptodate_            PGASETEVALUPTODATE
#define pgafitness_                    PGAFITNESS
#define pgamean_                       PGAMEAN
#define pgastddev_                     PGASTDDEV
#define pgarank_                       PGARANK
#define pgagetdatatype_                PGAGETDATATYPE
#define pgagetoptdir_                  PGAGETOPTDIR
#define pgagetpopsize_                 PGAGETPOPSIZE
#define pgagetstringlen_               PGAGETSTRINGLEN
#define pgagetstoppingrule_            PGAGETSTOPPINGRULE
#define pgagetmaxiter_                 PGAGETMAXITER
#define pgagetnumreplace_              PGAGETNUMREPLACE
#define pgagetcrossovertype_           PGAGETCROSSOVERTYPE
#define pgagetselecttype_              PGAGETSELECTTYPE
#define pgagetfitnesstype_             PGAGETFITNESSTYPE
#define pgagetfitnessmintype_          PGAGETFITNESSMINTYPE
#define pgagetmutationtype_            PGAGETMUTATIONTYPE
#define pgagetmutateonlynocross_       PGAGETMUTATEONLYNOCROSS
#define pgagetmutaterealval_           PGAGETMUTATEREALVAL
#define pgagetmutateintegerval_        PGAGETMUTATEINTEGERVAL
#define pgagetnoduplicates_            PGAGETNODUPLICATES
#define pgagetmutationprob_            PGAGETMUTATIONPROB
#define pgagetcrossoverprob_           PGAGETCROSSOVERPROB
#define pgagetuniformcrossprob_        PGAGETUNIFORMCROSSPROB
#define pgagetfitnessrankmax_          PGAGETFITNESSRANKMAX
#define pgagetpopreplace_              PGAGETPOPREPLACE
#define pgagetiter_                    PGAGETITER
#define pgagetmaxint_                  PGAGETMAXINT
#define pgagetminint_                  PGAGETMININT
#define pgagetmaxdouble_               PGAGETMAXDOUBLE
#define pgagetmindouble_               PGAGETMINDOUBLE
#define pgagetprintfreq_               PGAGETPRINTFREQ
#define pgagetrandominit_              PGAGETRANDOMINIT
#define pgagetbinaryinitprob_          PGAGETBINARYINITPROB
#define pgagetintegertype_             PGAGETINTEGERTYPE
#define pgagetinitintegermin_          PGAGETINITINTEGERMIN
#define pgagetinitintegermax_          PGAGETINITINTEGERMAX
#define pgagetinitrealmin_             PGAGETINITREALMIN
#define pgagetinitrealmax_             PGAGETINITREALMAX
#define pgagetrandomseed_              PGAGETRANDOMSEED
#define pgagetevaluate_                PGAGETEVALUATE
#define pgagetfitness_                 PGAGETFITNESS
#define pgagetevaluptodate_            PGAGETEVALUPTODATE
#define pgagetworst_                   PGAGETWORST
#define pgagetbest_                    PGAGETBEST
#define pgagetptournamentprob_         PGAGETPTOURNAMENTPROB
#define pgahammingdistance_            PGAHAMMINGDISTANCE
#define pgasortpop_                    PGASORTPOP
#define pgagetsortpop_                 PGAGETSORTPOP
#define pgasetintegerinitpermute_      PGASETINTEGERINITPERMUTE
#define pgasetintegerinitlu_           PGASETINTEGERINITLU
#define pgagetintegerallele_           PGAGETINTEGERALLELE
#define pgasetintegerallele_           PGASETINTEGERALLELE
#define pgamutate_                     PGAMUTATE
#define pgarun_                        PGARUN
#define pgarunmutateandcross_          PGARUNMUTATEANDCROSS
#define pgarunmutateorcross_           PGARUNMUTATEORCROSS
#define pgacopyindividual_             PGACOPYINDIVIDUAL
#define pgaupdategeneration_           PGAUPDATEGENERATION
#define pgadone_                       PGADONE
#define pgadestroy_                    PGADESTROY
#define pgacreate_                     PGACREATE
#define pgasetup_                      PGASETUP
#define pgasetrealinitpercent_         PGASETREALINITPERCENT
#define pgasetrealinitlu_              PGASETREALINITLU
#define pgagetrealallele_              PGAGETREALALLELE
#define pgasetrealallele_              PGASETREALALLELE
#define pgaprintpopulation_            PGAPRINTPOPULATION
#define pgaprintindividual_            PGAPRINTINDIVIDUAL
#define pgaprintreport_                PGAPRINTREPORT
#define pgaprintcontext_               PGAPRINTCONTEXT
#define pgaselect_                     PGASELECT
#define pgaselectnext_                 PGASELECTNEXT
#define pgasetpopsize_                 PGASETPOPSIZE
#define pgasetstoppingrule_            PGASETSTOPPINGRULE
#define pgasetmaxiter_                 PGASETMAXITER
#define pgasetmaxnochange_             PGASETMAXNOCHANGE
#define pgasetmaxsimilarity_           PGASETMAXSIMILARITY
#define pgasetnumreplace_              PGASETNUMREPLACE
#define pgasetcrossovertype_           PGASETCROSSOVERTYPE
#define pgasetcrossoverprob_           PGASETCROSSOVERPROB
#define pgasetuniformcrossprob_        PGASETUNIFORMCROSSPROB
#define pgasetselecttype_              PGASETSELECTTYPE
#define pgasetptournamentprob_         PGASETPTOURNAMENTPROB
#define pgasetfitnesstype_             PGASETFITNESSTYPE
#define pgasetfitnessmintype_          PGASETFITNESSMINTYPE
#define pgasetfitnessrankmax_          PGASETFITNESSRANKMAX
#define pgasetmutationtype_            PGASETMUTATIONTYPE
#define pgasetmutateonlynocross_       PGASETMUTATEONLYNOCROSS
#define pgasetmutationrealval_         PGASETMUTATIONREALVAL
#define pgasetmutationintegerval_      PGASETMUTATIONINTEGERVAL
#define pgasetnoduplicates_            PGASETNODUPLICATES
#define pgasetmutationprob_            PGASETMUTATIONPROB
#define pgasetpopreplacement_          PGASETPOPREPLACEMENT
#define pgasetprintfreq_               PGASETPRINTFREQ
#define pgasetrandominit_              PGASETRANDOMINIT
#define pgasetdebuglevel_              PGASETDEBUGLEVEL
#define pgasetprintoptions_            PGASETPRINTOPTIONS
#define pgasetbinaryinitprob_          PGASETBINARYINITPROB
#define pgasetrandomseed_              PGASETRANDOMSEED
#define pgasetuserfunction_            PGASETUSERFUNCTION
#define pgaerror_                      PGAERROR
#define pgaexit_                       PGAEXIT
#define pgawritestring_                PGAWRITESTRING
#define pgarandomflip_                 PGARANDOMFLIP
#define pgarandominterval_             PGARANDOMINTERVAL
#define pgarandom01_                   PGARANDOM01
#define pgarandomuniform_              PGARANDOMUNIFORM
#define pgarandomgaussian_             PGARANDOMGAUSSIAN
#define pgaround_                      PGAROUND

#elif !defined(FORTRANUNDERSCORE)
#define pgagetbinaryallele_            pgagetbinaryallele
#define pgasetbinaryallele_            pgasetbinaryallele
#define pgagetrealfrombinary_          pgagetrealfrombinary
#define pgagetrealfromgraycode_        pgagetrealfromgraycode
#define pgaencoderealasbinary_         pgaencoderealasbinary
#define pgaencoderealasgraycode_       pgaencoderealasgraycode
#define pgaencodeintegerasbinary_      pgaencodeintegerasbinary
#define pgaencodeintegerasgraycode_    pgaencodeintegerasgraycode
#define pgagetintegerfrombinary_       pgagetintegerfrombinary
#define pgagetintegerfromgraycode_     pgagetintegerfromgraycode
#define pgacrossover_                  pgacrossover
#define pgadebugprint_                 pgadebugprint
#define pgaduplicate_                  pgaduplicate
#define pgachange_                     pgachange
#define pgaevaluate_                   pgaevaluate
#define pgasetevaluate_                pgasetevaluate
#define pgasetevaluptodate_            pgasetevaluptodate
#define pgafitness_                    pgafitness
#define pgamean_                       pgamean
#define pgastddev_                     pgastddev
#define pgarank_                       pgarank
#define pgagetdatatype_                pgagetdatatype
#define pgagetoptdir_                  pgagetoptdir
#define pgagetpopsize_                 pgagetpopsize
#define pgagetstringlen_               pgagetstringlen
#define pgagetstoppingrule_            pgagetstoppingrule
#define pgagetmaxiter_                 pgagetmaxiter
#define pgagetnumreplace_              pgagetnumreplace
#define pgagetcrossovertype_           pgagetcrossovertype
#define pgagetselecttype_              pgagetselecttype
#define pgagetfitnesstype_             pgagetfitnesstype
#define pgagetfitnessmintype_          pgagetfitnessmintype
#define pgagetmutationtype_            pgagetmutationtype
#define pgagetmutateonlynocross_       pgagetmutateonlynocross
#define pgagetmutaterealval_           pgagetmutaterealval
#define pgagetmutateintegerval_        pgagetmutateintegerval
#define pgagetnoduplicates_            pgagetnoduplicates
#define pgagetmutationprob_            pgagetmutationprob
#define pgagetcrossoverprob_           pgagetcrossoverprob
#define pgagetuniformcrossprob_        pgagetuniformcrossprob
#define pgagetfitnessrankmax_          pgagetfitnessrankmax
#define pgagetpopreplace_              pgagetpopreplace
#define pgagetiter_                    pgagetiter
#define pgagetmaxint_                  pgagetmaxint
#define pgagetminint_                  pgagetminint
#define pgagetmaxdouble_               pgagetmaxdouble
#define pgagetmindouble_               pgagetmindouble
#define pgagetprintfreq_               pgagetprintfreq
#define pgagetrandominit_              pgagetrandominit
#define pgagetbinaryinitprob_          pgagetbinaryinitprob
#define pgagetintegertype_             pgagetintegertype
#define pgagetinitintegermin_          pgagetinitintegermin
#define pgagetinitintegermax_          pgagetinitintegermax
#define pgagetinitrealmin_             pgagetinitrealmin
#define pgagetinitrealmax_             pgagetinitrealmax
#define pgagetrandomseed_              pgagetrandomseed
#define pgagetevaluate_                pgagetevaluate
#define pgagetfitness_                 pgagetfitness
#define pgagetevaluptodate_            pgagetevaluptodate
#define pgagetworst_                   pgagetworst
#define pgagetbest_                    pgagetbest
#define pgagetptournamentprob_         pgagetptournamentprob
#define pgahammingdistance_            pgahammingdistance
#define pgasortpop_                    pgasortpop
#define pgagetsortpop_                 pgagetsortpop
#define pgasetintegerinitpermute_      pgasetintegerinitpermute
#define pgasetintegerinitlu_           pgasetintegerinitlu
#define pgagetintegerallele_           pgagetintegerallele
#define pgasetintegerallele_           pgasetintegerallele
#define pgamutate_                     pgamutate
#define pgarun_                        pgarun
#define pgarunmutateandcross_          pgarunmutateandcross
#define pgarunmutateorcross_           pgarunmutateorcross
#define pgacopyindividual_             pgacopyindividual
#define pgaupdategeneration_           pgaupdategeneration
#define pgadone_                       pgadone
#define pgadestroy_                    pgadestroy
#define pgacreate_                     pgacreate
#define pgasetup_                      pgasetup
#define pgasetrealinitpercent_         pgasetrealinitpercent
#define pgasetrealinitlu_              pgasetrealinitlu
#define pgagetrealallele_              pgagetrealallele
#define pgasetrealallele_              pgasetrealallele
#define pgaprintpopulation_            pgaprintpopulation
#define pgaprintindividual_            pgaprintindividual
#define pgaprintreport_                pgaprintreport
#define pgaprintcontext_               pgaprintcontext
#define pgaselect_                     pgaselect
#define pgaselectnext_                 pgaselectnext
#define pgasetpopsize_                 pgasetpopsize
#define pgasetstoppingrule_            pgasetstoppingrule
#define pgasetmaxiter_                 pgasetmaxiter
#define pgasetmaxnochange_             pgasetmaxnochange
#define pgasetmaxsimilarity_           pgasetmaxsimilarity
#define pgasetnumreplace_              pgasetnumreplace
#define pgasetcrossovertype_           pgasetcrossovertype
#define pgasetcrossoverprob_           pgasetcrossoverprob
#define pgasetuniformcrossprob_        pgasetuniformcrossprob
#define pgasetselecttype_              pgasetselecttype
#define pgasetptournamentprob_         pgasetptournamentprob
#define pgasetfitnesstype_             pgasetfitnesstype
#define pgasetfitnessmintype_          pgasetfitnessmintype
#define pgasetfitnessrankmax_          pgasetfitnessrankmax
#define pgasetmutationtype_            pgasetmutationtype
#define pgasetmutateonlynocross_       pgasetmutateonlynocross
#define pgasetmutationrealval_         pgasetmutationrealval
#define pgasetmutationintegerval_      pgasetmutationintegerval
#define pgasetnoduplicates_            pgasetnoduplicates
#define pgasetmutationprob_            pgasetmutationprob
#define pgasetpopreplacement_          pgasetpopreplacement
#define pgasetprintfreq_               pgasetprintfreq
#define pgasetrandominit_              pgasetrandominit
#define pgasetdebuglevel_              pgasetdebuglevel
#define pgasetprintoptions_            pgasetprintoptions
#define pgasetbinaryinitprob_          pgasetbinaryinitprob
#define pgasetrandomseed_              pgasetrandomseed
#define pgasetuserfunction_            pgasetuserfunction
#define pgaerror_                      pgaerror
#define pgaexit_                       pgaexit
#define pgawritestring_                pgawritestring
#define pgarandomflip_                 pgarandomflip
#define pgarandominterval_             pgarandominterval
#define pgarandom01_                   pgarandom01
#define pgarandomuniform_              pgarandomuniform
#define pgarandomgaussian_             pgarandomgaussian
#define pgaround_                      pgaround
#endif

int pgagetbinaryallele_(PGAContext **ftx, int *p, int *pop, int *i);
void pgasetbinaryallele_(PGAContext **ftx, int *p, int *pop, int *i,
     int *val);
double pgagetrealfrombinary_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper);
double pgagetrealfromgraycode_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper);
void pgaencoderealasbinary_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper,
     double *value);
void pgaencoderealasgraycode_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper,
     double *value);
void pgaencodeintegerasbinary_(PGAContext **ftx, int *p, int *pop,
     int*start, int *end, int *value);
void pgaencodeintegerasgraycode_(PGAContext **ftx, int *p, int *pop,
     int*start, int *end, int *value);
int pgagetintegerfrombinary_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end);
int pgagetintegerfromgraycode_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end);
void pgacrossover_(PGAContext **ftx, int *m1, int *m2, int *oldpop, int *t1,
     int *t2, int *newpop);
void pgadebugprint_(PGAContext **ftx, int *level, char *funcname, char *msg,
     int *datatype, void **data, int len1, int len2);
int pgaduplicate_(PGAContext **ftx, int *j, int *pop1, int *pop2, int *n);
void pgachange_(PGAContext **ftx, int *j, int *popindex);
void pgaevaluate_(PGAContext **ftx, int *pop,
     double (*f)(PGAContext *c, int p, int pop));
void pgasetevaluate_( PGAContext **ftx, int *p, int *pop, double *val );
void pgasetevaluptodate_(PGAContext **ftx, int *p, int *pop, int *status);
void pgafitness_(PGAContext **ftx, int *popindex);
double pgamean_(PGAContext **ftx, double **a, int *n);
double pgastddev_(PGAContext **ftx, double **a, int *n, double *mean);
int pgarank_(PGAContext **ftx, int *p, int **order, int *n);
int pgagetdatatype_(PGAContext **ftx);
int pgagetoptdir_(PGAContext **ftx);
int pgagetpopsize_(PGAContext **ftx);
int pgagetstringlen_(PGAContext **ftx);
int pgagetstoppingrule_(PGAContext **ftx);
int pgagetmaxiter_(PGAContext **ftx);
int pgagetnumreplace_(PGAContext **ftx);
int pgagetcrossovertype_(PGAContext **ftx);
int pgagetselecttype_(PGAContext **ftx);
int pgagetfitnesstype_(PGAContext **ftx);
int pgagetfitnessmintype_(PGAContext **ftx);
int pgagetmutationtype_(PGAContext **ftx);
int pgagetmutateonlynocross_(PGAContext **ftx);
double pgagetmutaterealval_(PGAContext **ftx);
int pgagetmutateintegerval_(PGAContext **ftx);
int pgagetnoduplicates_(PGAContext **ftx);
double pgagetmutationprob_(PGAContext **ftx);
double pgagetcrossoverprob_(PGAContext **ftx);
double pgagetuniformcrossprob_(PGAContext **ftx);
double pgagetfitnessrankmax_(PGAContext **ftx);
int pgagetpopreplace_(PGAContext **ftx);
int pgagetiter_(PGAContext **ftx);
int pgagetmaxint_(PGAContext **ftx);
int pgagetminint_(PGAContext **ftx);
double pgagetmaxdouble_(PGAContext **ftx);
double pgagetmindouble_(PGAContext **ftx);
int pgagetprintfreq_(PGAContext **ftx);
int pgagetrandominit_(PGAContext **ftx);
double pgagetbinaryinitprob_(PGAContext **ftx);
int pgagetintegertype_(PGAContext **ftx);
int pgagetinitintegermin_ (PGAContext **ftx, int *i);
int pgagetinitintegermax_ (PGAContext **ftx, int *i);
double pgagetinitrealmin_(PGAContext **ftx, int *i);
double pgagetinitrealmax_(PGAContext **ftx, int *i);
int pgagetrandomseed_(PGAContext **ftx);
double pgagetevaluate_(PGAContext **ftx, int *p, int *pop);
double pgagetfitness_(PGAContext **ftx, int *p, int *pop);
int pgagetevaluptodate_(PGAContext **ftx, int *p, int *pop);
int pgagetworst_(PGAContext **ftx, int *pop);
int pgagetbest_(PGAContext **ftx, int *pop);
double pgagetptournamentprob_(PGAContext **ftx);
double pgahammingdistance_(PGAContext **ftx, int *popindex);
void pgasortpop_(PGAContext **ftx, int *pop);
int pgagetsortpop_(PGAContext **ftx, int *n);
void pgasetintegerinitpermute_(PGAContext **ftx, int *min, int *max);
void pgasetintegerinitlu_ (PGAContext **ftx, int *min, int *max);
int pgagetintegerallele_(PGAContext **ftx, int *p, int *pop, int *i);
void pgasetintegerallele_(PGAContext **ftx, int *p, int *pop, int *i,
     int *val);
void pgamutate_(PGAContext **ftx, int *p, int *pop);
void pgarun_(PGAContext **ftx,
     double (*evaluate)(PGAContext *c, int p, int pop));
void pgarunmutateandcross_(PGAContext **ftx, int *oldpop, int *newpop);
void pgarunmutateorcross_(PGAContext **ftx, int *oldpop, int *newpop);
void pgacopyindividual_(PGAContext **ftx, int *i, int *p1, int *j, int *p2);
void pgaupdategeneration_(PGAContext **ftx);
int pgadone_(PGAContext **ftx);
void pgadestroy_(PGAContext **ftx);
int pgacreate_(int *datatype, int *len, int *maxormin);
void pgasetup_(PGAContext **ftx);
void pgasetrealinitpercent_(PGAContext **ftx, double *median, double *percent);
void pgasetrealinitlu_ (PGAContext **ftx, double *min, double *max);
double pgagetrealallele_(PGAContext **ftx, int *p, int *pop, int *i);
void pgasetrealallele_(PGAContext **ftx, int *p, int *pop, int *i,
     double *val);
void pgaprintpopulation_(PGAContext **ftx, char *name, int *pop, int len);
void pgaprintindividual_ (PGAContext **ftx, char *name, int *i,
     int *pop, int len);
void pgaprintreport_(PGAContext **ftx, char *name, int *pop, int len);
void pgaprintcontext_(PGAContext **ftx, char *name, int len);
void pgaselect_(PGAContext **ftx, int *popix);
int pgaselectnext_(PGAContext **ftx);
void pgasetpopsize_(PGAContext **ftx, int *popsize);
void pgasetstoppingrule_(PGAContext **ftx, int *stoprule);
void pgasetmaxiter_(PGAContext **ftx, int *maxiter);
void pgasetmaxnochange_(PGAContext **ftx, int *max_no_change);
void pgasetmaxsimilarity_(PGAContext **ftx, int *max_similarity);
void pgasetnumreplace_(PGAContext **ftx, int *pop_replace);
void pgasetcrossovertype_(PGAContext **ftx, int *crossover_type);
void pgasetcrossoverprob_(PGAContext **ftx, double *crossover_prob);
void pgasetuniformcrossprob_(PGAContext **ftx, double *uniform_cross_prob);
void pgasetselecttype_(PGAContext **ftx, int *select_type);
void pgasetptournamentprob_(PGAContext **ftx, double *ptournament_prob);
void pgasetfitnesstype_(PGAContext **ftx, int *fitness_type);
void pgasetfitnessmintype_(PGAContext **ftx, int *fitness_type);
void pgasetfitnessrankmax_(PGAContext **ftx, double *fitness_rank_max);
void pgasetmutationtype_(PGAContext **ftx, int *mutation_type);
void pgasetmutateonlynocross_(PGAContext **ftx, int *mutate_only_no_cross);
void pgasetmutationrealval_(PGAContext **ftx, double *val);
void pgasetmutationintegerval_(PGAContext **ftx, int *val);
void pgasetnoduplicates_(PGAContext **ftx, int *no_dup);
void pgasetmutationprob_(PGAContext **ftx, double *mutation_prob);
void pgasetpopreplacement_(PGAContext **ftx, int *pop_replace);
void pgasetprintfreq_(PGAContext **ftx, int *print_freq);
void pgasetrandominit_(PGAContext **ftx, int *RandomBoolean);
void pgasetdebuglevel_(PGAContext **ftx, int *level);
void pgasetprintoptions_(PGAContext **ftx, int *option);
void pgasetbinaryinitprob_(PGAContext **ftx, double *probability);
void pgasetrandomseed_(PGAContext **ftx, int *seed);
void pgasetuserfunction_(PGAContext **ftx, int *constant, void *f);
void pgaerror_(PGAContext **ftx, char *msg, int *level, int *datatype,
     void **data, int len);
void  pgaexit_(PGAContext **ftx, int *exittype);
void pgawritestring_(PGAContext **ftx, FILE **fp, int *p, int *pop);
int pgarandomflip_(PGAContext **ftx, double *p);
int pgarandominterval_(PGAContext **ftx, int *start, int *end);
double pgarandom01_(PGAContext **ftx, int *newseed);
double pgarandomuniform_(PGAContext **ftx, double *start, double *end);
double pgarandomgaussian_(PGAContext **ftx, double *mean, double *sigma);
int pgaround_(PGAContext **ftx, double *x);

int pgagetbinaryallele_(PGAContext **ftx, int *p, int *pop, int *i)
{
     return PGAGetBinaryAllele(*ftx,
		  *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p - 1,
		  *pop, *i-1);
}

void pgasetbinaryallele_(PGAContext **ftx, int *p, int *pop, int *i,
     int *val)
{
     PGASetBinaryAllele(*ftx,
	   *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p - 1,
	   *pop, *i-1, *val);
}

double pgagetrealfrombinary_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper)
{
     return PGAGetRealFromBinary(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1, *lower, *upper);
}

double pgagetrealfromgraycode_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper)
{
     return PGAGetRealFromGrayCode(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1, *lower, *upper);
}

void pgaencoderealasbinary_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper,
     double *value)
{
     PGAEncodeRealAsBinary(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1, *lower, *upper, *value);
}

void pgaencoderealasgraycode_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end, double *lower, double *upper,
     double *value)
{
     PGAEncodeRealAsGrayCode(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1, *lower, *upper, *value);
}

void pgaencodeintegerasbinary_(PGAContext **ftx, int *p, int *pop,
     int*start, int *end, int *value)
{
     PGAEncodeIntegerAsBinary(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1, *value);
}

void pgaencodeintegerasgraycode_(PGAContext **ftx, int *p, int *pop,
     int*start, int *end, int *value)
{
     PGAEncodeIntegerAsGrayCode(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1, *value);
}

int pgagetintegerfrombinary_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end)
{
     return PGAGetIntegerFromBinary(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1);
}

int pgagetintegerfromgraycode_(PGAContext **ftx, int *p, int *pop,
     int *start, int *end)
{
     return PGAGetIntegerFromGrayCode(*ftx,
          *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p :
          *p - 1,
          *pop, *start-1, *end-1);
}

void pgacrossover_(PGAContext **ftx, int *m1, int *m2, int *oldpop, int *t1,
     int *t2, int *newpop)
{
     PGACrossover (*ftx,
		   *m1 == PGA_TEMP1 || *m1 == PGA_TEMP2 ? *m1 : *m1-1,
		   *m2 == PGA_TEMP1 || *m2 == PGA_TEMP2 ? *m2 : *m2-1,
		   *oldpop,
		   *t1 == PGA_TEMP1 || *t1 == PGA_TEMP2 ? *t1 : *t1-1,
		   *t2 == PGA_TEMP1 || *t2 == PGA_TEMP2 ? *t2 : *t2-1,
		   *newpop);
}

#ifndef OPTIMIZE
void pgadebugprint_(PGAContext **ftx, int *level, char *funcname, char *msg,
     int *datatype, void **data, int len1, int len2)
/* FORTRAN implicitly passes the lengths of funcname and msg into len1
   and len2, respectively */
{
     if (funcname[len1] != 0 || msg[len2] != 0)
	  funcname[len1] = msg[len2] = 0;
     PGADebugPrint(*ftx, *level, funcname, msg, *datatype, *data );
}
#else
void pgadebugprint_(PGAContext **ftx, int *level, char *funcname, char *msg,
		    int *datatype, void **data, int len1, int len2)
{
     printf("PGADebugPrint is not supported in the optimized version of"
	    "PGAPack.\n");
}
#endif

int pgaduplicate_(PGAContext **ftx, int *j, int *pop1, int *pop2, int *n)
{
     return PGADuplicate(*ftx,
		  *j == PGA_TEMP1 || *j == PGA_TEMP2 ? *j : *j-1,
		  *pop1, *pop2, *n);
}

void pgachange_(PGAContext **ftx, int *j, int *popindex)
{
     PGAChange(*ftx,
	   *j == PGA_TEMP1 || *j == PGA_TEMP2 ? *j : *j-1,
	   *popindex);
}

void pgaevaluate_(PGAContext **ftx, int *pop,
     double (*f)(PGAContext *c, int p, int pop))
{
     PGAEvaluate  (*ftx, *pop, (*f));
}

void pgasetevaluate_( PGAContext **ftx, int *p, int *pop, double *val )
{
     PGASetEvaluate( *ftx, *p-1, *pop, *val );
}

void pgasetevaluptodate_(PGAContext **ftx, int *p, int *pop, int *status)
{
     PGASetEvalUpToDate(*ftx, *p-1, *pop, *status);
}

void pgafitness_(PGAContext **ftx, int *popindex)
{
     PGAFitness  (*ftx, *popindex);
}

double pgamean_(PGAContext **ftx, double **a, int *n)
{
     return PGAMean  (*ftx, *a, *n);
}

double pgastddev_(PGAContext **ftx, double **a, int *n, double *mean)
{
     return PGAStddev  (*ftx, *a, *n, *mean);
}

int pgarank_(PGAContext **ftx, int *p, int **order, int *n)
{
     return PGARank  (*ftx, *p, *order, *n);
}

int pgagetdatatype_(PGAContext **ftx)
{
     return PGAGetDataType  (*ftx);
}

int pgagetoptdir_(PGAContext **ftx)
{
     return PGAGetOptDir  (*ftx);
}

int pgagetpopsize_(PGAContext **ftx)
{
     return PGAGetPopSize  (*ftx);
}

int pgagetstringlen_(PGAContext **ftx)
{
     return PGAGetStringLen  (*ftx);
}

int pgagetstoppingrule_(PGAContext **ftx)
{
     return PGAGetStoppingRule  (*ftx);
}

int pgagetmaxiter_(PGAContext **ftx)
{
     return PGAGetMaxIter  (*ftx);
}

int pgagetnumreplace_(PGAContext **ftx)
{
     return PGAGetNumReplace  (*ftx);
}

int pgagetcrossovertype_(PGAContext **ftx)
{
     return PGAGetCrossoverType  (*ftx);
}

int pgagetselecttype_(PGAContext **ftx)
{
     return PGAGetSelectType  (*ftx);
}

int pgagetfitnesstype_(PGAContext **ftx)
{
     return PGAGetFitnessType  (*ftx);
}

int pgagetfitnessmintype_(PGAContext **ftx)
{
     return PGAGetFitnessMinType  (*ftx);
}

int pgagetmutationtype_(PGAContext **ftx)
{
     return PGAGetMutationType  (*ftx);
}

int pgagetmutateonlynocross_(PGAContext **ftx)
{
     return PGAGetMutateOnlyNoCross  (*ftx);
}

double pgagetmutaterealval_(PGAContext **ftx)
{
     return PGAGetMutateRealVal  (*ftx);
}

int pgagetmutateintegerval_(PGAContext **ftx)
{
     return PGAGetMutateIntegerVal  (*ftx);
}

int pgagetnoduplicates_(PGAContext **ftx)
{
     return PGAGetNoDuplicates  (*ftx);
}

double pgagetmutationprob_(PGAContext **ftx)
{
     return PGAGetMutationProb  (*ftx);
}

double pgagetcrossoverprob_(PGAContext **ftx)
{
     return PGAGetCrossoverProb  (*ftx);
}

double pgagetuniformcrossprob_(PGAContext **ftx)
{
     return PGAGetUniformCrossProb  (*ftx);
}

double pgagetfitnessrankmax_(PGAContext **ftx)
{
     return PGAGetFitnessRankMax  (*ftx);
}

int pgagetpopreplace_(PGAContext **ftx)
{
     return PGAGetPopReplace  (*ftx);
}

int pgagetiter_(PGAContext **ftx)
{
     return PGAGetIter  (*ftx);
}

int pgagetmaxint_(PGAContext **ftx)
{
     return PGAGetMaxInt  (*ftx);
}

int pgagetminint_(PGAContext **ftx)
{
     return PGAGetMinInt  (*ftx);
}

double pgagetmaxdouble_(PGAContext **ftx)
{
     return PGAGetMaxDouble  (*ftx);
}

double pgagetmindouble_(PGAContext **ftx)
{
     return PGAGetMinDouble  (*ftx);
}

int pgagetprintfreq_(PGAContext **ftx)
{
     return PGAGetPrintFreq  (*ftx);
}

int pgagetrandominit_(PGAContext **ftx)
{
     return PGAGetRandomInit  (*ftx);
}

double pgagetbinaryinitprob_(PGAContext **ftx)
{
     return PGAGetBinaryInitProb  (*ftx);
}

int pgagetintegertype_(PGAContext **ftx)
{
     return PGAGetIntegerType  (*ftx);
}

int pgagetinitintegermin_ (PGAContext **ftx, int *i)
{
     return PGAGetInitIntegerMin(*ftx, *i-1);
}

int pgagetinitintegermax_ (PGAContext **ftx, int *i)
{
     return PGAGetInitIntegerMax(*ftx, *i-1);
}

double pgagetinitrealmin_(PGAContext **ftx, int *i)
{
     return PGAGetInitRealMin(*ftx, *i-1);
}

double pgagetinitrealmax_(PGAContext **ftx, int *i)
{
     return PGAGetInitRealMax(*ftx, *i-1);
}

int pgagetrandomseed_(PGAContext **ftx)
{
     return PGAGetRandomSeed  (*ftx);
}

double pgagetevaluate_(PGAContext **ftx, int *p, int *pop)
{
     return PGAGetEvaluate(*ftx, *p-1, *pop);
}

double pgagetfitness_(PGAContext **ftx, int *p, int *pop)
{
     return PGAGetFitness(*ftx, *p-1, *pop);
}

int pgagetevaluptodate_(PGAContext **ftx, int *p, int *pop)
{
     return PGAGetEvalUpToDate(*ftx, *p-1, *pop);
}

int pgagetworst_(PGAContext **ftx, int *pop)
{
     return PGAGetWorst(*ftx, *pop) + 1;
}

int pgagetbest_(PGAContext **ftx, int *pop)
{
     return PGAGetBest(*ftx, *pop) + 1;
}

double pgagetptournamentprob_(PGAContext **ftx)
{
     return PGAGetPTournamentProb  (*ftx);
}

double pgahammingdistance_(PGAContext **ftx, int *popindex)
{
     return PGAHammingDistance  (*ftx, *popindex);
}

void pgasortpop_(PGAContext **ftx, int *pop)
{
     PGASortPop  (*ftx, *pop);
}

int pgagetsortpop_(PGAContext **ftx, int *n)
{
     return PGAGetSortPop  (*ftx, *n);
}

void pgasetintegerinitpermute_(PGAContext **ftx, int *min, int *max)
{
     PGASetIntegerInitPermute  (*ftx, *min, *max);
}

void pgasetintegerinitlu_ (PGAContext **ftx, int *min, int *max)
{
     PGASetIntegerInitLU(*ftx, min, max);
}

int pgagetintegerallele_(PGAContext **ftx, int *p, int *pop, int *i)
{
     return PGAGetIntegerAllele(*ftx,
		  *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p - 1,
		  *pop, *i-1);
}

void pgasetintegerallele_(PGAContext **ftx, int *p, int *pop, int *i,
     int *val)
{
     PGASetIntegerAllele(*ftx,
	   *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p - 1,
	   *pop, *i-1, *val);
}

void pgamutate_(PGAContext **ftx, int *p, int *pop)
{
     PGAMutate(*ftx,
	   *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p-1, *pop);
}

void pgarun_(PGAContext **ftx,
     double (*evaluate)(PGAContext *c, int p, int pop))
{
     PGARun  (*ftx, (*evaluate));
}

void pgarunmutateandcross_(PGAContext **ftx, int *oldpop, int *newpop)
{
     PGARunMutateAndCross  (*ftx, *oldpop, *newpop);
}

void pgarunmutateorcross_(PGAContext **ftx, int *oldpop, int *newpop)
{
     PGARunMutateOrCross  (*ftx, *oldpop, *newpop);
}

void pgacopyindividual_(PGAContext **ftx, int *i, int *p1, int *j, int *p2)
{
     PGACopyIndividual(*ftx,
	   *i == PGA_TEMP1 || *i == PGA_TEMP2 ? *i : *i-1,
	   *p1,
	   *j == PGA_TEMP1 || *j == PGA_TEMP2 ? *j : *j-1,
	   *p2);
}

void pgaupdategeneration_(PGAContext **ftx)
{
     PGAUpdateGeneration  (*ftx);
}

int pgadone_(PGAContext **ftx)
{
     return PGADone  (*ftx);
}

void pgadestroy_(PGAContext **ftx)
{
     PGADestroy  (*ftx);
}

int pgacreate_(int *datatype, int *len, int *maxormin)
{
     int argc;
     char *argv[1];
     PGAContext *ctx;

     argv[0] = "foobar";
     argc = 1;

     ctx = PGACreate(&argc, argv, *datatype, *len, *maxormin);
     ctx->sys.fortran = PGATRUE;

     return (int)ctx;
}

void pgasetup_(PGAContext **ftx)
{
     PGASetUp  (*ftx);
}

void pgasetrealinitpercent_(PGAContext **ftx, double *median, double *percent)
{
     PGASetRealInitPercent(*ftx, median, percent);
}

void pgasetrealinitlu_ (PGAContext **ftx, double *min, double *max)
{
     PGASetRealInitLU(*ftx, min, max);
}

double pgagetrealallele_(PGAContext **ftx, int *p, int *pop, int *i)
{
     return PGAGetRealAllele(*ftx,
		  *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p - 1,
		  *pop, *i-1);
}

void pgasetrealallele_(PGAContext **ftx, int *p, int *pop, int *i,
     double *val)
{
     PGASetRealAllele(*ftx,
	   *p == PGA_TEMP1 || *p == PGA_TEMP2 ? *p : *p - 1,
	   *pop, *i-1, *val);
}

void pgaprintpopulation_(PGAContext **ftx, char *name, int *pop, int len)
/* FORTRAN implicitly passes the length of name into len. */
{
     FILE *fp;
     if (name[len] != 0)
	  name[len] = 0;
     if (!strcmp(name, "STDOUT") || !strcmp(name, "stdout"))
     {
	  fp = stdout;
	  PGAPrintPopulation(*ftx, fp, *pop);
     }
     else if (!strcmp(name, "STDERR") || !strcmp(name, "stderr"))
     {
	  fp = stderr;
	  PGAPrintPopulation(*ftx, fp, *pop);
     }
     else
     {
	  fp = fopen(name, "a");
	  if (!fp)
	       PGAError(*ftx, "PGAPrintPopulation: Could not open file:",
			     PGA_FATAL, PGA_CHAR, (void *) name);
	  else
	  {
	       PGAPrintPopulation(*ftx, fp, *pop);
	       fclose(fp);
	  }
     }
}

void pgaprintindividual_ (PGAContext **ftx, char *name, int *i,
     int *pop, int len)
          /* FORTRAN implicitly passes the length of name into len. */
{
     FILE *fp;
     if (name[len] != 0)
	  name[len] = 0;
     if (!strcmp(name, "STDOUT") || !strcmp(name, "stdout"))
     {
	  fp = stdout;
	  PGAPrintIndividual(*ftx, fp, *i, *pop);
     }
     else if (!strcmp(name, "STDERR") || !strcmp(name, "stderr"))
     {
	  fp = stderr;
	  PGAPrintIndividual(*ftx, fp, *i, *pop);
     }
     else
     {
	  fp = fopen(name, "a");
	  if (!fp)
	       PGAError(*ftx, "PGAPrintIndividual: Could not open file:",
			     PGA_FATAL, PGA_CHAR, (void *) name);
	  else
	  {
	       PGAPrintIndividual(*ftx, fp, *i, *pop);
	       fclose(fp);
	  }
     }
}

void pgaprintreport_(PGAContext **ftx, char *name, int *pop, int len)
/* FORTRAN implicitly passes the length of name into len. */
{
     FILE *fp;
     if (name[len] != 0)
	  name[len] = 0;
     if (!strcmp(name, "STDOUT") || !strcmp(name, "stdout"))
     {
	  fp = stdout;
	  PGAPrintReport(*ftx, fp, *pop);
     }
     else if (!strcmp(name, "STDERR") || !strcmp(name, "stderr"))
     {
	  fp = stderr;
	  PGAPrintReport(*ftx, fp, *pop);
     }
     else
     {
	  fp = fopen(name, "a");
	  if (!fp)
	       PGAError(*ftx, "PGAPrintReport: Could not open file:",
			     PGA_FATAL, PGA_CHAR, (void *) name);
	  else
	  {
	       PGAPrintReport(*ftx, fp, *pop);
	       fclose(fp);
	  }
     }
}

void pgaprintcontext_(PGAContext **ftx, char *name, int len)
/* FORTRAN implicitly passes the length of name into len. */
{
     FILE *fp;
     if (name[len] != 0)
	  name[len] = 0;
     if (!strcmp(name, "STDOUT") || !strcmp(name, "stdout"))
     {
	  fp = stdout;
	  PGAPrintContext(*ftx, fp);
     }
     else if (!strcmp(name, "STDERR") || !strcmp(name, "stderr"))
     {
	  fp = stderr;
	  PGAPrintContext(*ftx, fp);
     }
     else
     {
	  fp = fopen(name, "a");
	  if (!fp)
	       PGAError(*ftx, "PGAPrintContext: Could not open file:",
			     PGA_FATAL, PGA_CHAR, (void *) name);
	  else
	  {
	       PGAPrintContext(*ftx, fp);
	       fclose(fp);
	  }
     }
}

void pgaselect_(PGAContext **ftx, int *popix)
{
     PGASelect  (*ftx, *popix);
}

int pgaselectnext_(PGAContext **ftx)
{
     return PGASelectNext  (*ftx);
}

void pgasetpopsize_(PGAContext **ftx, int *popsize)
{
     PGASetPopSize  (*ftx, *popsize);
}

void pgasetstoppingrule_(PGAContext **ftx, int *stoprule)
{
     PGASetStoppingRule  (*ftx, *stoprule);
}

void pgasetmaxiter_(PGAContext **ftx, int *maxiter)
{
     PGASetMaxIter  (*ftx, *maxiter);
}

void pgasetmaxnochange_(PGAContext **ftx, int *max_no_change)
{
     PGASetMaxNoChange  (*ftx, *max_no_change);
}

void pgasetmaxsimilarity_(PGAContext **ftx, int *max_similarity)
{
     PGASetMaxSimilarity  (*ftx, *max_similarity);
}

void pgasetnumreplace_(PGAContext **ftx, int *pop_replace)
{
     PGASetNumReplace  (*ftx, *pop_replace);
}

void pgasetcrossovertype_(PGAContext **ftx, int *crossover_type)
{
     PGASetCrossoverType  (*ftx, *crossover_type);
}

void pgasetcrossoverprob_(PGAContext **ftx, double *crossover_prob)
{
     PGASetCrossoverProb  (*ftx, *crossover_prob);
}

void pgasetuniformcrossprob_(PGAContext **ftx, double *uniform_cross_prob)
{
     PGASetUniformCrossProb  (*ftx, *uniform_cross_prob);
}

void pgasetselecttype_(PGAContext **ftx, int *select_type)
{
     PGASetSelectType  (*ftx, *select_type);
}

void pgasetptournamentprob_(PGAContext **ftx, double *ptournament_prob)
{
     PGASetPTournamentProb  (*ftx, *ptournament_prob);
}

void pgasetfitnesstype_(PGAContext **ftx, int *fitness_type)
{
     PGASetFitnessType  (*ftx, *fitness_type);
}

void pgasetfitnessmintype_(PGAContext **ftx, int *fitness_type)
{
     PGASetFitnessMinType  (*ftx, *fitness_type);
}

void pgasetfitnessrankmax_(PGAContext **ftx, double *fitness_rank_max)
{
     PGASetFitnessRankMax  (*ftx, *fitness_rank_max);
}

void pgasetmutationtype_(PGAContext **ftx, int *mutation_type)
{
     PGASetMutationType  (*ftx, *mutation_type);
}

void pgasetmutateonlynocross_(PGAContext **ftx, int *mutate_only_no_cross)
{
     PGASetMutateOnlyNoCross  (*ftx, *mutate_only_no_cross);
}

void pgasetmutationrealval_(PGAContext **ftx, double *val)
{
     PGASetMutationRealVal  (*ftx, *val);
}

void pgasetmutationintegerval_(PGAContext **ftx, int *val)
{
     PGASetMutationIntegerVal  (*ftx, *val);
}

void pgasetnoduplicates_(PGAContext **ftx, int *no_dup)
{
     PGASetNoDuplicates  (*ftx, *no_dup);
}

void pgasetmutationprob_(PGAContext **ftx, double *mutation_prob)
{
     PGASetMutationProb  (*ftx, *mutation_prob);
}

void pgasetpopreplacement_(PGAContext **ftx, int *pop_replace)
{
     PGASetPopReplacement  (*ftx, *pop_replace);
}

void pgasetprintfreq_(PGAContext **ftx, int *print_freq)
{
     PGASetPrintFreq  (*ftx, *print_freq);
}

void pgasetrandominit_(PGAContext **ftx, int *RandomBoolean)
{
     PGASetRandomInit  (*ftx, *RandomBoolean);
}

void pgasetdebuglevel_(PGAContext **ftx, int *level)
{
     PGASetDebugLevel  (*ftx, *level);
}

void pgasetprintoptions_(PGAContext **ftx, int *option)
{
     PGASetPrintOptions  (*ftx, *option);
}

void pgasetbinaryinitprob_(PGAContext **ftx, double *probability)
{
     PGASetBinaryInitProb  (*ftx, *probability);
}

void pgasetrandomseed_(PGAContext **ftx, int *seed)
{
     PGASetRandomSeed  (*ftx, *seed);
}

void pgasetuserfunction_(PGAContext **ftx, int *constant, void *f)
{
     PGAError(*ftx, "PGASetUserFunction: FORTRAN-defined user functions are "
              "not supported", PGA_FATAL, PGA_VOID, NULL);
}

void pgaerror_(PGAContext **ftx, char *msg, int *level, int *datatype,
     void **data, int len)
/* FORTRAN implicitly passes the length of msg into len. */
{
     if (msg[len] != 0)
	  msg[len] = 0;
     PGAError (*ftx, msg, *level, *datatype, *data);
}

void  pgaexit_(PGAContext **ftx, int *exittype)
{
     PGAExit  (*ftx, *exittype);
}

void pgawritestring_(PGAContext **ftx, FILE **fp, int *p, int *pop)
{
     PGAWriteString  (*ftx, *fp, *p, *pop);
}

int pgarandomflip_(PGAContext **ftx, double *p)
{
     return PGARandomFlip  (*ftx, *p);
}

int pgarandominterval_(PGAContext **ftx, int *start, int *end)
{
     return PGARandomInterval  (*ftx, *start, *end);
}

double pgarandom01_(PGAContext **ftx, int *newseed)
{
     return PGARandom01  (*ftx, *newseed);
}

double pgarandomuniform_(PGAContext **ftx, double *start, double *end)
{
     return PGARandomUniform  (*ftx, *start, *end);
}

double pgarandomgaussian_(PGAContext **ftx, double *mean, double *sigma)
{
     return PGARandomGaussian  (*ftx, *mean, *sigma);
}

int pgaround_(PGAContext **ftx, double *x)
{
     return PGARound  (*ftx, *x);
}

