/* CalculiX - A 3-dimensional finite element program */ /* Copyright (C) 1998-2007 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ /* published by the Free Software Foundation(version 2); */ /* */ /* 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 General Public License for more details. */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include "CalculiX.h" void readinput(char *jobnamec, char **inpcp, int *nline, int *nset, int *ipoinp, int **inpp, int **ipoinpcp, int *ithermal){ /* reads and stores the input deck in inpcp; determines the number of sets */ FILE *f1[10]; char buff[1320], fninp[132]="", includefn[132]="", *inpc=NULL, textpart[2112],*set=NULL; int i,j,k,n,in=0,nlinemax=100000,irestartread,irestartstep, icntrl,nload,nforc,nboun,nk,ne,nmpc,nalset,nmat,ntmat,npmat, norien,nam,nprint,mint,ntrans,ncs,namtot,ncmat,memmpc,ne1d, ne2d,nflow,*meminset=NULL,*rmeminset=NULL, *inp=NULL,ntie, nener,nstate,nentries=12,ifreeinp,ikey,lincludefn, nbody,ncharmax=1000000,*ipoinpc=NULL; /* initialization */ /* nentries is the number of different keyword cards for which the input deck order is important, cf keystart.f */ inpc=NNEW(char,ncharmax); ipoinpc=NNEW(int,nlinemax+1); inp=NNEW(int,3*nlinemax); *nline=0; for(i=0;i<2*nentries;i++){ipoinp[i]=0;} ifreeinp=1; ikey=0; /* opening the input file */ strcpy(fninp,jobnamec); strcat(fninp,".inp"); if((f1[in]=fopen(fninp,"r"))==NULL){ printf("*ERROR in read: cannot open file %s\n",fninp); exit(0); } /* starting to read the input file */ do{ if(fgets(buff,1320,f1[in])==NULL){ fclose(f1[in]); if(in!=0){ in--; continue; } else{break;} } /* storing the significant characters */ /* get rid of blanks */ k=0; i=-1; do{ i++; if((buff[i]=='\0')||(buff[i]=='\n')||(buff[i]=='\r')||(k==132)) break; if((buff[i]==' ')||(buff[i]=='\t')) continue; buff[k]=buff[i]; k++; }while(1); /* check for blank lines and comments */ if(k==0) continue; if(strcmp1(&buff[0],"**")==0) continue; /* changing to uppercase except include filenames */ if(k<15){ for(j=0;j9){ printf("*ERROR in read: include statements can \n not be cascaded over more than 9 levels\n"); } if((f1[in]=fopen(includefn,"r"))==NULL){ printf("*ERROR in read: cannot open file %s\n",includefn); exit(0); } continue; } /* adding a line */ (*nline)++; if(*nline>nlinemax){ nlinemax=(int)(1.1*nlinemax); RENEW(ipoinpc,int,nlinemax+1); RENEW(inp,int,3*nlinemax); } /* checking the total number of characters */ if(ipoinpc[*nline-1]+k>ncharmax){ ncharmax=(int)(1.1*ncharmax); RENEW(inpc,char,ncharmax); } /* copying into inpc */ for(j=0;j