ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/UseTheForce/EAM_FF.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/UseTheForce/EAM_FF.cpp (file contents):
Revision 1653 by gezelter, Wed Oct 27 00:01:29 2004 UTC vs.
Revision 1654 by gezelter, Wed Oct 27 02:16:34 2004 UTC

# Line 42 | Line 42 | namespace EAM_NS{
42                     //  1  -> in MPI: tells nodes to stop listening
43    } atomStruct;
44  
45 <  int parseAtom( char *lineBuffer, int lineNum, atomStruct &info, char *eamPotFile );
46 <  int parseEAM( atomStruct &info, char *eamPotFile, double **eam_rvals,
45 >  int parseAtom( char *lineBuffer, int lineNum, atomStruct &info, string eamPotFile );
46 >  int parseEAM( atomStruct &info, string eamPotFile, double **eam_rvals,
47                  double **eam_rhovals, double **eam_Frhovals);
48   #ifdef IS_MPI
49    
# Line 207 | Line 207 | EAM_FF::EAM_FF(string the_variant){
207  
208      if (!the_variant.empty()) {
209        has_variant = 1;
210 <      fileName += "." + the_variant + ".frc";
210 >      fileName += "." + the_variant;
211        
212        sprintf( painCave.errMsg,
213                 "Using %s variant of EAM force field.\n",
# Line 217 | Line 217 | EAM_FF::EAM_FF(string the_variant){
217        simError();
218      }  
219  
220 +    fileName += ".frc";
221 +
222      //fprintf( stderr,"Trying to open %s\n", fileName );
223      
224      // attempt to open the file in the current directory first.
# Line 314 | Line 316 | void EAM_FF::readParams( void ){
316    double *eam_rvals;    // Z of r values
317    double *eam_rhovals;  // rho of r values
318    double *eam_Frhovals; // F of rho values
319 <  char eamPotFile[1000];
319 >  string eamPotFile;
320  
321    
322  
# Line 630 | Line 632 | int EAM_NS::parseAtom( char *lineBuffer, int lineNum,
632  
633  
634  
635 < int EAM_NS::parseAtom( char *lineBuffer, int lineNum,   atomStruct &info, char *eamPotFile ){
635 > int EAM_NS::parseAtom( char *lineBuffer, int lineNum,   atomStruct &info, string eamPotFile ){
636  
637    char* the_token;
638    
# Line 654 | Line 656 | int EAM_NS::parseAtom( char *lineBuffer, int lineNum,
656        painCave.isFatal = 1;
657        simError();
658      }
659 <        
660 <    strcpy( eamPotFile, the_token );
659 >    
660 >    eamPotFile = the_token;
661 >
662      return 1;
663    }
664    else return 0;
665   }
666  
667 < int EAM_NS::parseEAM(atomStruct &info, char *eamPotFile,
667 > int EAM_NS::parseEAM(atomStruct &info, string eamPotFile,
668                       double **eam_rvals,
669                       double **eam_rhovals,
670                       double **eam_Frhovals){
# Line 669 | Line 672 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
672    double* myEam_rhovals;
673    double* myEam_Frhovals;
674  
672  char* ffPath_env = "FORCE_PARAM_PATH";
673  char* ffPath;
675    char* the_token;
676    char* eam_eof_test;
677    FILE *eamFile;
678    const int BUFFERSIZE = 3000;
679  
680 <  char temp[200];
680 >  string tempString;
681    int linenumber;
682    int nReadLines;
683    char eam_read_buffer[BUFFERSIZE];
684  
684
685    int i,j;
686  
687    linenumber = 0;
688  
689    // Open eam file
690 <  eamFile = fopen( eamPotFile, "r" );
691 <  
690 >  eamFile = fopen( eamPotFile.c_str(), "r" );
691    
692    if( eamFile == NULL ){
693      
694        // next see if the force path enviorment variable is set
695      
696 <    ffPath = getenv( ffPath_env );
697 <    if( ffPath == NULL ) {
699 <      STR_DEFINE(ffPath, FRC_PATH );
700 <    }
696 >    tempString = ffPath + "/" + eamPotFile;
697 >    eamPotFile = tempString;
698      
699 +    eamFile = fopen( eamPotFile.c_str(), "r" );
700      
703    strcpy( temp, ffPath );
704    strcat( temp, "/" );
705    strcat( temp, eamPotFile );
706    strcpy( eamPotFile, temp );
707    
708    eamFile = fopen( eamPotFile, "r" );
709
710    
711    
701      if( eamFile == NULL ){
702        
703        sprintf( painCave.errMsg,
704                 "Error opening the EAM force parameter file: %s\n"
705                 "Have you tried setting the FORCE_PARAM_PATH environment "
706                 "variable?\n",
707 <               eamPotFile );
707 >               eamPotFile.c_str() );
708        painCave.isFatal = 1;
709        simError();
710      }
# Line 726 | Line 715 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
715    linenumber++;
716    if(eam_eof_test == NULL){
717      sprintf( painCave.errMsg,
718 <             "error in reading commment in %s\n", eamPotFile);
718 >             "error in reading commment in %s\n", eamPotFile.c_str());
719      painCave.isFatal = 1;
720      simError();
721    }
# Line 738 | Line 727 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
727    linenumber++;
728    if(eam_eof_test == NULL){
729      sprintf( painCave.errMsg,
730 <             "error in reading Identifier line in %s\n", eamPotFile);
730 >             "error in reading Identifier line in %s\n", eamPotFile.c_str());
731      painCave.isFatal = 1;
732      simError();
733    }
# Line 748 | Line 737 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
737      
738    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
739      sprintf( painCave.errMsg,
740 <             "Error parsing EAM ident  line in %s\n", eamPotFile );
740 >             "Error parsing EAM ident  line in %s\n", eamPotFile.c_str() );
741      painCave.isFatal = 1;
742      simError();
743    }
# Line 757 | Line 746 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
746  
747    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
748      sprintf( painCave.errMsg,
749 <             "Error parsing EAM mass in %s\n", eamPotFile );
749 >             "Error parsing EAM mass in %s\n", eamPotFile.c_str() );
750      painCave.isFatal = 1;
751      simError();
752    }
# Line 765 | Line 754 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
754  
755    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
756      sprintf( painCave.errMsg,
757 <             "Error parsing EAM Lattice Constant %s\n", eamPotFile );
757 >             "Error parsing EAM Lattice Constant %s\n", eamPotFile.c_str() );
758      painCave.isFatal = 1;
759      simError();
760    }
# Line 775 | Line 764 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
764    eam_eof_test = fgets(eam_read_buffer, sizeof(eam_read_buffer),eamFile);
765    if(eam_eof_test == NULL){
766      sprintf( painCave.errMsg,
767 <             "error in reading number of points line in %s\n", eamPotFile);
767 >             "error in reading number of points line in %s\n",
768 >             eamPotFile.c_str());
769      painCave.isFatal = 1;
770      simError();
771    }
772  
773    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
774      sprintf( painCave.errMsg,
775 <             "Error parseing EAM nrho: line in %s\n", eamPotFile );
775 >             "Error parseing EAM nrho: line in %s\n", eamPotFile.c_str() );
776      painCave.isFatal = 1;
777      simError();
778    }
# Line 791 | Line 781 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
781    
782    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
783      sprintf( painCave.errMsg,
784 <             "Error parsing EAM drho in %s\n", eamPotFile );
784 >             "Error parsing EAM drho in %s\n", eamPotFile.c_str() );
785      painCave.isFatal = 1;
786      simError();
787    }
# Line 799 | Line 789 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
789  
790    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
791      sprintf( painCave.errMsg,
792 <             "Error parsing EAM # r in %s\n", eamPotFile );
792 >             "Error parsing EAM # r in %s\n", eamPotFile.c_str() );
793      painCave.isFatal = 1;
794      simError();
795    }
# Line 807 | Line 797 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
797    
798    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
799      sprintf( painCave.errMsg,
800 <             "Error parsing EAM dr in %s\n", eamPotFile );
800 >             "Error parsing EAM dr in %s\n", eamPotFile.c_str() );
801      painCave.isFatal = 1;
802      simError();
803    }
# Line 815 | Line 805 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
805  
806    if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
807      sprintf( painCave.errMsg,
808 <             "Error parsing EAM rcut in %s\n", eamPotFile );
808 >             "Error parsing EAM rcut in %s\n", eamPotFile.c_str() );
809      painCave.isFatal = 1;
810      simError();
811    }
# Line 847 | Line 837 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
837      if(eam_eof_test == NULL){
838        sprintf( painCave.errMsg,
839                 "error in reading EAM file %s at line %d\n",
840 <               eamPotFile,linenumber);
840 >               eamPotFile.c_str(), linenumber);
841        painCave.isFatal = 1;
842        simError();
843      }
# Line 856 | Line 846 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
846      // Value 1
847      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
848        sprintf( painCave.errMsg,
849 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
849 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
850        painCave.isFatal = 1;
851        simError();
852      }
# Line 866 | Line 856 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
856      // Value 2
857      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
858        sprintf( painCave.errMsg,
859 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
859 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
860        painCave.isFatal = 1;
861        simError();
862      }
# Line 876 | Line 866 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
866      // Value 3
867      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
868        sprintf( painCave.errMsg,
869 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
869 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
870        painCave.isFatal = 1;
871        simError();
872      }
# Line 886 | Line 876 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
876      // Value 4
877      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
878        sprintf( painCave.errMsg,
879 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
879 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
880        painCave.isFatal = 1;
881        simError();
882      }
# Line 896 | Line 886 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
886      // Value 5
887      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
888        sprintf( painCave.errMsg,
889 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
889 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
890        painCave.isFatal = 1;
891        simError();
892      }
# Line 918 | Line 908 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
908      if(eam_eof_test == NULL){
909        sprintf( painCave.errMsg,
910                 "error in reading EAM file %s at line %d\n",
911 <               eamPotFile,linenumber);
911 >               eamPotFile.c_str(), linenumber);
912        painCave.isFatal = 1;
913        simError();
914      }
# Line 927 | Line 917 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
917      // Value 1
918      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
919        sprintf( painCave.errMsg,
920 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
920 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
921        painCave.isFatal = 1;
922        simError();
923      }
# Line 937 | Line 927 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
927      // Value 2
928      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
929        sprintf( painCave.errMsg,
930 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
930 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
931        painCave.isFatal = 1;
932        simError();
933      }
# Line 947 | Line 937 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
937      // Value 3
938      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
939        sprintf( painCave.errMsg,
940 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
940 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
941        painCave.isFatal = 1;
942        simError();
943      }
# Line 957 | Line 947 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
947      // Value 4
948      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
949        sprintf( painCave.errMsg,
950 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
950 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
951        painCave.isFatal = 1;
952        simError();
953      }
# Line 967 | Line 957 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
957      // Value 5
958      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
959        sprintf( painCave.errMsg,
960 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
960 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
961        painCave.isFatal = 1;
962        simError();
963      }
# Line 988 | Line 978 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
978      if(eam_eof_test == NULL){
979        sprintf( painCave.errMsg,
980                 "error in reading EAM file %s at line %d\n",
981 <               eamPotFile,linenumber);
981 >               eamPotFile.c_str(), linenumber);
982        painCave.isFatal = 1;
983        simError();
984      }
# Line 997 | Line 987 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
987      // Value 1
988      if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){
989        sprintf( painCave.errMsg,
990 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
990 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
991        painCave.isFatal = 1;
992        simError();
993      }
# Line 1007 | Line 997 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
997      // Value 2
998      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
999        sprintf( painCave.errMsg,
1000 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
1000 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
1001        painCave.isFatal = 1;
1002        simError();
1003      }
# Line 1017 | Line 1007 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1007      // Value 3
1008      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1009        sprintf( painCave.errMsg,
1010 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
1010 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
1011        painCave.isFatal = 1;
1012        simError();
1013      }
# Line 1027 | Line 1017 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1017      // Value 4
1018      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1019        sprintf( painCave.errMsg,
1020 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
1020 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
1021        painCave.isFatal = 1;
1022        simError();
1023      }
# Line 1037 | Line 1027 | int EAM_NS::parseEAM(atomStruct &info, char *eamPotFil
1027      // Value 5
1028      if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){
1029        sprintf( painCave.errMsg,
1030 <               "Error parsing EAM nrho: line in %s\n", eamPotFile );
1030 >               "Error parsing EAM nrho: line in %s\n", eamPotFile.c_str() );
1031        painCave.isFatal = 1;
1032        simError();
1033      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines