GLYLIB  0.3.0b
deallocate_amber_structures.c
Go to the documentation of this file.
00001 #include "../inc/mylib.h"
00002 #include "../inc/molecules.h"
00003 #include "../inc/AMBER/amber.h"
00004 
00005 /* \file deallocate_amber_structures.c 
00006 \addtogroup MEMORY_MANAGEMENT
00007 \brief   Dealloction routines for structures relevant to AMBER.
00008 
00009 Begun on 20100304 by BLFoley 
00010 
00011 Notes regarding these functions:
00012 
00013 * If a structure does not contain any pointers, it can just be freed.
00014 * Structures that contain pointers must have a deallocation function.
00015 * Single-pointers to arrays of simple types (e.g. int) may be freed.
00016 * Single-pointers to arrays of structures might need individual deallocation.
00017 * Double-pointers
00018         * Be very careful before freeing double-pointed structures
00019         *       -- they might point somewhere you don't want freed
00020         * Freeing the top-level pointer should not interfere with data below 
00021 */
00022 /*
00023 void deallocateX(X *a){
00024  int i;
00025  //set null
00026  a[0].t = 0x0;
00027  // deallocate each
00028  if(a[0].b != NULL && a[0].b != 0x0){
00029         for(i=0;i<a[0].nb;i++){deallocateX(&a[0].b[i]);}
00030         free(a[0].b);}
00031  // free each
00032  if(a[0].OD != NULL && a[0].OD != 0x0){
00033         for(i=0;i<a[0].nOD;i++){if(a[0].OD[i] != NULL && a[0].OD[i] != 0x0){free(a[0].OD[i]);}}
00034         free(a[0].OD);}
00035  // free top
00036  if(a[0].N != NULL && a[0].N != 0x0){free(a[0].N);}
00037  // check and warn if non-null
00038  if(a[0].VP!= NULL && a[0].VP != 0x0){fprintf(stderr,"WARNING: deallocating X structure with non-NULL void pointer!\n");}
00039  return ;
00040 }
00041 */
00042 
00043 /********* structures from  AMBER/amber_prmtop_structs.h *****************/
00044 void deallocateAmberPrmtopSection(amber_prmtop_section *aps){
00045  int i;
00046  // free each
00047  if(aps[0].D != NULL && aps[0].D != 0x0){
00048         for(i=0;i<aps[0].nt;i++){if(aps[0].D[i] != NULL && aps[0].D[i] != 0x0){free(aps[0].D[i]);}}
00049         free(aps[0].D);}
00050  // free top
00051 //printf("aps[0].N is %d\n",aps[0].N);
00052  if(aps[0].N != NULL && aps[0].N != 0x0){free(aps[0].N);}
00053  if(aps[0].FORMAT != NULL && aps[0].FORMAT != 0x0){free(aps[0].FORMAT);}
00054 //printf("aps[0].TYPE is %d\n",aps[0].TYPE);
00055  if(aps[0].TYPE != NULL && aps[0].TYPE != 0x0){free(aps[0].TYPE);}
00056  if(aps[0].desc != NULL && aps[0].desc != 0x0){free(aps[0].desc);}
00057  return ;
00058 }
00059 void deallocateAmberPrmtop(amber_prmtop *ap){
00060  int i;
00061  // deallocate each
00062  if(ap[0].S != NULL && ap[0].S != 0x0){
00063         for(i=0;i<ap[0].nS;i++){
00064 //printf("Deallocating prmtop section i=%d; it's FLAG is >>>%s<<<\n",i,ap[0].S[i].N);
00065                 deallocateAmberPrmtopSection(&ap[0].S[i]);}
00066         free(ap[0].S);}
00067  // free each
00068  if(ap[0].SN != NULL && ap[0].SN != 0x0){
00069         for(i=0;i<ap[0].nS;i++){if(ap[0].SN[i] != NULL && ap[0].SN[i] != 0x0){free(ap[0].SN[i]);}}
00070         free(ap[0].SN);}
00071  if(ap[0].FLAGS != NULL && ap[0].FLAGS != 0x0){
00072         for(i=0;i<ap[0].nFF;i++){if(ap[0].FLAGS[i] != NULL && ap[0].FLAGS[i] != 0x0){free(ap[0].FLAGS[i]);}}
00073         free(ap[0].FLAGS);}
00074  // free top
00075  if(ap[0].FN != NULL && ap[0].FN != 0x0){free(ap[0].FN);}
00076  if(ap[0].VERSION != NULL && ap[0].VERSION != 0x0){free(ap[0].VERSION);}
00077  if(ap[0].SS != NULL && ap[0].SS != 0x0){free(ap[0].SS);}
00078  if(ap[0].ES != NULL && ap[0].ES != 0x0){free(ap[0].ES);}
00079  if(ap[0].FORMATS != NULL && ap[0].FORMATS != 0x0){free(ap[0].FORMATS);}
00080  return ;
00081 }
00082 
00083 /********* structures from  AMBER/read_prep.h *****************/
00084 /*  Not writing deallocations for these right now. 
00085  *  No time... 20100304 BLFoley
00086  */
00087 /*
00088 typedef struct{
00089         char *FN; // file name from which this set of preps originated
00090         char *NAMDBF; // name of database to which this set belongs
00091         int IDBGEN , IREST , ITYPF; // Amber flags from top of file
00092 } ambermprepinfo;
00093 typedef struct{
00094         char *TITLE; // description of residue from prep file
00095         char *NAMF; // NAMF from residue
00096         char *NAMRES; // name of the residue from the prep file
00097         char *INTX; // coordinates are internal "INT" or xyz "XYZ"
00098         int  KFORM; // KFORM from amber file
00099         char *IFIXC; // geometry format
00100         char *IOMIT; // flag for dummy atom omission
00101         char *ISYMDU; // symbol used for dummy atoms
00102         char *IPOS; // flag for which dummy atoms to delete
00103         double CUT; // cutoff for assuming atoms are bonded
00104         int nIOPR; // number of IOPR cards for this residue
00105         llcharset *IOPR; // content of those cards ("DONE" is not included)
00106 } amberrprepinfo;
00107 typedef struct{
00108         int I;
00109         char *IGRAPH;
00110         char *ISYMBL;
00111         char *ITREE;
00112         int NA;
00113         int NB;
00114         int NC;
00115         double R;
00116         double THETA;
00117         double PHI;
00118         double CHG;
00119 } amberaprepinfo;
00120 */
00121 
00122 /********* structures from  AMBER/run_control.h *****************/
00123 /*  Not writing deallocations for these right now. 
00124  *  No time... 20100304 BLFoley
00125  */
00126 /*
00127 typedef struct {
00128         int WANT_MDEN; ///< 0=YES ; 1=NO (make mden output file?)
00129         int MDEN_EVERY; ///< Step-frequency with which to write entries to mden file
00130         int WANT_AUTOCORR; ///< Should the program call get_autocorr_est_array()?
00131         char *AUTOCORR_DATA; ///< List of mden entries to get autocorrelations for
00132         int WANT_AUTOCORR_GRAPH; ///< 0=YES ; 1=NO (might require another program)
00133         int WANT_GRAPH; ///< 0=YES ; 1=NO (might require another program)
00134         char *GRAPH_DATA; ///< List of graphs to make -- all versus step number
00135 } AMBER_MD_DATA_REQUEST;
00136 typedef struct {
00137         int NUMBER; ///< A user-defined number; not the order found in the file
00138         char *COMMENT; ///< Free-form user comment about this change
00139         char *CHANGE_BY_WHICH;///< How to make the change, e.g.,RESIDUE_TYPE NOT-SOLVENT
00140         char *SOLVENT_ID;///< List of residues to consider as solvent
00141         char *RESIDUE_LIST; ///< List of residues to consider
00142         char *ATOM_LIST; ///< List of atoms to consider
00143         char *CHANGE_TYPE;///< how to change the numbers (ABSOLUTE, FRACTION, etc.)
00144         double CHANGE_QUANT;///< Meaning will depend on the value in CHANGE_TYPE
00145 } EE_TI_CHANGE_INFO;
00146 typedef struct {
00147         double KLAMBDA; ///< The value of klambda.  Typically integral, but might float...  
00148         char *CLAMBDA_HOW; ///< Method for assigning CLAMBDA's.  Not necessarily the same as the integration technique (see ANALYZE_HOW)
00149         //## CLAMBDA_HOW = GAUSSIAN 12
00150         //## CLAMBDA_HOW = SECTIONS 20 
00151         char *POINTSFILE; ///< If CLAMBDA_HOW involves reading a file, this is the file to read.
00152         int nCLAMBDA; ///< The number of CLAMBDA values.
00153         double *CLAMBDA;///< The CLAMBDA values.
00154         int nWIDTHS; ///< Should equal nCLAMBDA or zero -- here to facilitate checks to see if widths are defined.
00155         double *WIDTHS; ///< Widths to assign to each CLAMBDA value (e.g., for GAUSSIAN quadrature)
00156         char *ANALYZE_HOW; ///< The numerical integration method to use.
00157         //## ANALYZE_HOW = GAUSSIAN
00158         //## ANALYZE_HOW = TRAPEZOID
00159         //## ANALYZE_HOW = SIMPSONS_RULE
00160 } TI_INTEGRATION_INFO;
00161 typedef struct{ 
00162         char AO; ///< Append/Overwrite files ('A', 'O' or '\0')
00163         char *mdin; ///< input control data for the min/md run
00164         char *mdout; ///< output user readable state info and diagnostics 
00165         char *prmtop; ///< input molecular topology, force field, periodic box type, atom and residue names
00166         char *inpcrd; ///< input initial coordinates and (optionally) velocities and periodic box size
00167         char *restrt; ///< output final coordinates, velocity, and box dimensions if any - for restarting run
00168         char *refc; ///< input (optional) reference coords for position restraints; also used for targeted MD
00169         char *mdcrd; ///< output coordinate sets saved over trajectory
00170         char *inptraj; ///< input input coordinate sets in trajectory format, when imin=5
00171         char *mdvel; ///< output velocity sets saved over trajectory
00172         char *mden; ///< output extensive energy data over trajectory
00173         char *mdinfo; ///< output latest mdout-format energy info
00174         char *radii; ///< Obviously, some sort of radii, but not documented at this point in the manual... (BLF)
00175         char *inpdip; ///< input polarizable dipole file, when indmeth=3
00176         char *rstdip; ///< output polarizable dipole file, when indmeth=3
00177         char *cpin; ///< input protonation state definitions
00178         char *cprestrt; ///< protonation state definitions, final protonation states for restart (same format as cpin)
00179         char *cpout; ///< output protonation state data saved over trajectory
00180         char *evbin; ///< input input for EVB potentials 
00181 } sander_pmemd_command_line;
00182 typedef struct {
00183         int nclambda; ///< The number of clambda values held in this struct
00184         double *clambda; ///< clambda values (see icfe and klambda) -- an array here b/c they are usually in groups
00185         double comp; ///< The compressibility of a system (default = 44.6);
00186         double cut; ///< Nonbonded cutoff (default = 8.0);
00187         double dielc; ///< Dielectric for electrostatics (not same as GB simulations) 
00188         double drms; ///< convergence criterion for minimization (see manual)
00189         double dt; ///< Time step (psec) for MD runs (recommended max is 0.0020);
00190         double dx0; ///< Initial min step length to use (program will self-adjust)
00191         int ibelly; ///< Belly type dynamics.  Default is 0 (don't use).  See manual.
00192         int icfe; ///< Flag for thermodynamic integration; no=0; yes=1; (see clambda and klambda)
00193         int igb; ///< Flag for using GB or PB IS models; See Manual.
00194         int imin; ///< no_min=0; min=1; read_traj_and_analyze=5
00195         int ioutfm; ///< crd & vel output formats; normal=0; NetCDF=1
00196         int irest; ///< don't_restart=0; restart=1
00197         int iwrap; ///< don't_wrap=0; wrap=1
00198         double klambda; ///< klambda value (see icfe and clambda)
00199         int maxcyc; ///< Maximum number of minimization cycles
00200         int ncyc; ///< at ncyc, switch from steepest descent to conjugate graduent.
00201         int nmropt; ///< none=0; some>0; NOESY=2
00202         int nsnb; ///< Frequencey of nonbonded list updates (default = 25);
00203         int nstlim; ///< Number of MD simulation steps
00204         int ntave; ///< Every ntave steps print averages over last ntave steps;  =0 to disable averaging
00205         int ntb; ///< =1 for const. volume ; =2 for constant pressure ; =0 for no periodicity 
00206         int ntc; ///< No Shake = 1; SHAKE=2; constrain all bonds = 3
00207         int ntf; ///< Set equal to ntc or see manual for more information
00208         int ntmin; ///< Min Method. See manual.  If =1, need to set ncyc for switch
00209         int ntp; ///< Sets pressure control
00210         int ntpr; ///< Every ntpr steps, print info to mdinfo and mdout
00211         int ntr; ///< Sets restraints information; =0 for none; >0 for some (see restraint* & refc)
00212         int ntrx; ///< refc format text=1; binary=0
00213         int ntt; ///< Sets temperature control Const.Energy=0; >0 is some other control (=1 usually, see manual)
00214         int ntwe; ///< Eery ntwe steps write compact energy to mden file; =0 to inhibit
00215         int ntwprt; ///< Only print atoms 1 through ntwprt in crd files; =0 to print all
00216         int ntwr; ///< Every ntwr steps write a restart file
00217         int ntwv; ///< Every ntwx velocities are written to mdvel; =0 to inhibit; =-1 to combine with crd file
00218         int ntwx; ///< Every ntwx coordinates are written to mdcrd; =0 to inhibit
00219         int ntx; ///< only_crd=1; crd+vel=5
00220         int ntxo; ///< format of restrt file (output); =1 only (=0 is deprecated)
00221         double pres0; ///< Desired constant pressure (bars);  default = 1.0; 
00222         double presi; ///< Initial pressure 
00223         double restraint_wt; ///< Sixe of k, the restraining spring constant.
00224         char *restraintmask; ///< List of atoms to be restrained if ntr=1
00225         double scee; ///< Divide 1-4 electrostatic interactions by scee ; GLYCAM needs = 1.0;
00226         double scnb; ///< Divide 1-4 vdW interactions by scnb; GLYCAm needs = 1.0;
00227         double taup; ///< Pressure relaxation time = 0.1;
00228         double tautp; ///< Time constant for heat-bath coupling; default = 1.0; 
00229         double temp0; ///< Desired constant temperature (kelvin) 
00230         double tempi; ///< Initial temperature
00231 } sander_pmemd_cntrl;
00232 typedef struct {
00233         int nbflag; ///< Tells how to determine when to update the nonbonded list.  See manual.
00234         double skinnb; ///< Used when nbflag=1.  See manual.
00235 } sander_pmemd_ewald;
00236 typedef struct {
00237         char *type; ///< the type of change, e.g., TEMP0, TAUTP, etc.
00238         int istep1,istep2; ///< beginning and ending steps for the change
00239         int value1,value2; ///< change from value1 at istep1 to value2 at istep2
00240 } sander_pmemd_nmropt_wt_change;
00241 typedef struct {
00242         char *Title; ///< The title of the run
00243         sander_pmemd_cntrl SPC; ///< Control list for the run
00244         int use_SPE; ///< include ewald info if 0; don't if 1
00245         sander_pmemd_ewald SPE; ///< 
00246         int nSPNWT; ///< number of wt change info sets to include (none if 0)
00247         sander_pmemd_nmropt_wt_change SPNWT; ///< entries in the "&wt" section for nmropt
00248 } sander_pmemd_MD_control_info;
00249 typedef struct{
00250         char *Title; ///< free-form descriptor
00251         char *exe; ///< executable name (with path, etc.)
00252         sander_pmemd_MD_control_info MDCI; ///< Control info for this run
00253         int nopt; ///< Number of command-line options
00254         char **optd; ///< The nopt dash options ('\0' if there is an argument in the next list without one of these)
00255         char **optt; ///< The nopt option strings ('\0' if there is an argument in the previous list without one of these)
00256         int nouttst; ///< Number of output tests to perform
00257         char **outdone; ///< String to check if job is complete
00258         char **outfail; ///< String to check if job has failed
00259         char **outdoing; ///< String to check if job might be still running and ok
00260         char **outpass; ///< String to check if job is finished and is probably "successful"
00261         char **outdesc; ///< Description of overall result from tests
00262         int **state; ///< Integer description of result: failed=-1; success=0; unknown or in progress=+1;
00263         int SUMMARY; ///< Integer summary: one or more failed=-1; all success=0; unknown or in progress=+1;
00264 } sander_pmemd_MD_run_info;
00265 */
 All Classes Files Functions Variables Typedefs Defines