<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi,<br><br>massA and massB in mdatoms are only set when doing free-energy calculations.<br>massT gives the mass of a particle.<br>Unfortunately there is a serious lack of documentation in the data type include files<br>(and in most other parts of the code).<br><br>Berk<br><br>&gt; Date: Tue, 31 Aug 2010 10:46:51 +0300<br>&gt; From: InonShar@TAU.ac.IL<br>&gt; To: gmx-users@gromacs.org<br>&gt; Subject: [gmx-users] mdatoms-&gt;massA pointer dereferencing<br>&gt; <br>&gt; Good morning!<br>&gt; <br>&gt; I'm having C trouble with something which should be simple enough: <br>&gt; GROMACS uses a struct called mdatoms which, amongst other things, houses <br>&gt; the atom masses during the simulation. I'm trying to access this data <br>&gt; (an array of the masses of all atoms). I've tried to consult internet <br>&gt; sources and my local tech support team, but it seems the problem is that <br>&gt; I'm misunderstanding the GROMACS programing. Any help would be greatly <br>&gt; apprecia
 ted.<br>&gt; As I understand it, there's mdatoms, which is comprised of various stuff <br>&gt; among which is the pointer massA.<br>&gt; <br>&gt;  From mdatom.c:<br>&gt; <br>&gt; line 209: md-&gt;massA[i] = mA;<br>&gt; <br>&gt; Since md and mdatoms are of the same struct type, I believe <br>&gt; mdatoms-&gt;massA is the pointer to the array I'm looking for.<br>&gt; <br>&gt; I've tried all these various combinations in the attempt to access the <br>&gt; elements of this array, to no avail...<br>&gt; <br>&gt; In md.c:<br>&gt; <br>&gt; .<br>&gt; .<br>&gt; .<br>&gt; include &lt;mdatoms.h&gt;<br>&gt; .<br>&gt; .<br>&gt; .<br>&gt; t_mdatoms.h *mdatoms<br>&gt; .<br>&gt; .<br>&gt; .<br>&gt; line 447: ...mdatoms-&gt;massT...<br>&gt; .<br>&gt; .<br>&gt; .<br>&gt; if (bFirstStep){<br>&gt; fprintf(trajectory,"%d\n",max_trajectory_atom);<br>&gt; for(trajectory_atom=0;trajectory_atom&lt;max_trajectory_atom;trajectory_atom++){<br>&gt; fprintf(stderr,"%d/n",trajectory_atom);<br>&gt; fprintf
 (stderr,"%g ",mdatoms-&gt;massA[trajectory_atom]); //segmentation <br>&gt; fault ON RUN-TIME<br>&gt; // fprintf(trajectory,"%g ",mdatoms-&gt;massA-&gt;trajectory_atom); //error: <br>&gt; request for member ‘trajectory_atom’ in something not a structure or <br>&gt; union ON COMPILATION<br>&gt; // fprintf(trajectory,"%g ",mdatoms-&gt;massA.trajectory_atom); //error: <br>&gt; request for member ‘trajectory_atom’ in something not a structure or <br>&gt; union ON COMPILATION<br>&gt; // real *atomsmasses = mdatoms-&gt;massA;fprintf(trajectory,"%g <br>&gt; ",atomsmasses[trajectory_atom]);//segfault on run-time<br>&gt; // fprintf(trajectory,"%g ",mdatoms-&gt;tmassA); works, on the other hand, <br>&gt; tmassA being a number rather than pointer or array<br>&gt; <br>&gt; The command I issue and the output is:<br>&gt; <br>&gt; ~$ mdrun_d -quiet -v -pd -nt 1<br>&gt; <br>&gt; :-) G R O M A C S (-:<br>&gt; <br>&gt; GROup of MAchos and Cynical Suckers<br>&gt; <br>&gt; :-) VERSION 4.5-beta4 
 (-:<br>&gt; <br>&gt; <br>&gt; Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.<br>&gt; Copyright (c) 1991-2000, University of Groningen, The Netherlands.<br>&gt; Copyright (c) 2001-2008, The GROMACS development team,<br>&gt; check out http://www.gromacs.org for more information.<br>&gt; <br>&gt; This program is free software; you can redistribute it and/or<br>&gt; modify it under the terms of the GNU General Public License<br>&gt; as published by the Free Software Foundation; either version 2<br>&gt; of the License, or (at your option) any later version.<br>&gt; <br>&gt; :-) mdrun_d (double precision) (-:<br>&gt; <br>&gt; <br>&gt; Back Off! I just backed up md.log to ./#md.log.3#<br>&gt; Getting Loaded...<br>&gt; Reading file topol.tpr, VERSION 4.5-beta2 (double precision)<br>&gt; Note: tpx file_version 71, software version 73<br>&gt; Loaded with Money<br>&gt; <br>&gt; <br>&gt; Back Off! I just backed up traj.trr to ./#traj.trr.3#<br>&gt; <br>&gt; Back Of
 f! I just backed up ener.edr to ./#ener.edr.3#<br>&gt; starting mdrun 'Single Atom of Sulfur Between Two Gold Atoms'<br>&gt; 6 steps, 0.0 ps.<br>&gt; <br>&gt; <br>&gt; 0<br>&gt; Segmentation fault<br>&gt; <br>&gt; <br>&gt; The last two lines mean that the loop is entered ( trajectory_atom gets <br>&gt; value zero ) and as soon as "md-&gt;massA[trajectory_atom]" is accessed, <br>&gt; the program crashes. This was the result I got before. I tried accessing <br>&gt; only elements 1 and above (by changing trajectory_atom to <br>&gt; trajectory_atom+1 ) but got the same result.<br>&gt; <br>&gt; Thanks!<br>&gt; <br>&gt; -- <br>&gt; Inon Sharony<br>&gt; éðåï ùøåðé<br>&gt; 972-3-6407634<br>&gt; Please consider your environmental responsibility before printing this e-mail.<br>&gt; <br>&gt; -- <br>&gt; gmx-users mailing list    gmx-users@gromacs.org<br>&gt; http://lists.gromacs.org/mailman/listinfo/gmx-users<br>&gt; Please search the archive at http://www.gromacs.org/search before pos
 ting!<br>&gt; Please don't post (un)subscribe requests to the list. Use the <br>&gt; www interface or send it to gmx-users-request@gromacs.org.<br>&gt; Can't post? Read http://www.gromacs.org/mailing_lists/users.php<br>                                               </body>
</html>