getarg and iargc in gcc-4.0.2

Dr. Germund Hojer germund.hojer@servidor.unam.mx
Mon Dec 5 22:15:00 GMT 2005


GAMESS (General Atomic and Molecular Electronic Structure System) is  
written in FORTRAN mainly. But there are some important routines written  
in C. One of those contains the following code with calls to getarg and  
iargc :
.
.
.
.
/* ----------------------------------------- *\
    Extern subroutines from FORTRAN libraries
\* ----------------------------------------- */
    extern int iargc_();
    extern char *getarg_(int *,char *,int);

/* ---------------------------- *\
    FORTRAN Wrapper for DDI_Init
\* ---------------------------- */
    void F77_Init() {
       int i,j,lenmax=256,argc=iargc_();
       char **argv = NULL;
       char arg[256];

       STD_DEBUG((stdout," DDI: Entering F77 DDI_Init.\n"))

    /* -------------------------- *\
       Get command line arguments
    \* -------------------------- */
       if(argc) {
          argc++;
          argv = Malloc(argc*sizeof(char*));
          for(i=0; i<argc; i++) {
            for(j=0; j<256; j++) arg[j]=' ';

          # if defined CRAY
              getarg_(&i,arg,&lenmax);
          # else
              getarg_(&i,arg,lenmax);
          # endif

            for(j=0; j<256 && arg[j] != ' '; j++);
            arg[j] = 0;
            argv[i] = (char *) strdup(arg);
          }
       }

       MAX_DEBUG((stdout," DDI: Calling DDI_Init.\n"))
.
.


That worked up to gcc-3.4.4. With gcc-4.0.2 getarg and iargc produce the  
error messages undefined reference to.. at the linking stage. I have tried  
the new versions of these commands supposedly to be used in gfortran  
without success. Can anybody help me with the correct way to modify the  
getarg and iargc statements in this code.

Thanks for your help

-- 
Dr. Germund Hojer
Depto. Fisica y Quimica Teorica
Facultad de Quimica
UNAM
germund.hojer@servidor.unam.mx



More information about the Gcc-help mailing list