Hi all.<br><br>I&#39;m writing this beucase I&#39;m having terrible problems in trying to deal with gromacs trajectory files with my own programs, originally written on fortran90.<br><br>The codes themselves are enoughly big to make it out of question to try to &quot;translate&quot; them. What leads to some sort of mixed language compilation.
<br><br>My first guess was to try to use the guidelines from <a href="http://xray.bmc.uu.se/~spoel/md/online/xtc.html">http://xray.bmc.uu.se/~spoel/md/online/xtc.html</a>, but it absolutelly didn&#39;t worked. Could not find a compatible library. Tried to recompile gromacs in order to do so, but instead of a 
libsdrf.a library file, it created just common .lo and .o object files.<br><br>Looked inside concoord program, as there are some mentions in the list to look at the code. Was a really good aprentize, could understand better the logics involved when dealing with .xtc files, BUT I could not use the library files that came with that. Somehow, it wasn&#39;t recognized as a valid file.
<br><br>My last try up to now was to try to link my test-read-program with the libxdrf object file. It yelded the following error:<br><br>CruNumMac src/own/B/9/xtc 238% ifort libxdrf.lo xtciof.f90 test_xtc.f90<br>IPO: WARNING: no IR in object file 
libxdrf.lo; was the source file compiled with -ipo?<br>IPO Error: unresolved : xdrfint_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifortZNvZHh.o<br>IPO Error: unresolved : xdrfclose_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifortZNvZHh.o
<br>IPO Error: unresolved : xdrfopen_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifortZNvZHh.o<br>IPO Error: unresolved : xdrffloat_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifortZNvZHh.o<br>IPO Error: unresolved : xdrf3dfcoord_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifortZNvZHh.o
<br>IPO: performing multi-file optimizations<br>IPO: generating object file /tmp/ipo_ifortZNvZHh.o<br>test_xtc.f90(17) : (col. 3) remark: LOOP WAS VECTORIZED.<br>test_xtc.f90(25) : (col. 8) remark: LOOP WAS VECTORIZED.<br>
xtciof.f90(112) : (col. 3) remark: LOOP WAS VECTORIZED.<br>libxdrf.lo: file not recognized: File format not recognized<br><br>If I try to link to the .o objetc:<br><br>CruNumMac src/own/B/9/xtc 240% ifort libxdrf.o xtciof.f90
 test_xtc.f90<br>IPO: WARNING: no IR in object file libxdrf.o; was the source file compiled with -ipo?<br>IPO Error: unresolved : xdrfint_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifort2f5KMw.o<br>IPO Error: unresolved : xdrfclose_
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifort2f5KMw.o<br>IPO Error: unresolved : xdrfopen_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifort2f5KMw.o<br>IPO Error: unresolved : xdrffloat_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifort2f5KMw.o<br>
IPO Error: unresolved : xdrf3dfcoord_<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in /tmp/ipo_ifort2f5KMw.o<br>IPO Error: unresolved : ffclose<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Referenced in libxdrf.o<br>IPO: performing multi-file optimizations<br>IPO: generating object file /tmp/ipo_ifort2f5KMw.o
<br>test_xtc.f90(17) : (col. 3) remark: LOOP WAS VECTORIZED.<br>test_xtc.f90(25) : (col. 8) remark: LOOP WAS VECTORIZED.<br>xtciof.f90(112) : (col. 3) remark: LOOP WAS VECTORIZED.<br>/tmp/ipo_ifort2f5KMw.o(.text+0x1e1): In function `MAIN__&#39;:
<br>/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfopen_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x4ea):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfclose_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x517):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfopen_&#39;
<br>/tmp/ipo_ifort2f5KMw.o(.text+0x92b): In function `xtciof_mp_xtcheader_&#39;:<br>/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfint_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x941):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfint_&#39;
<br>/tmp/ipo_ifort2f5KMw.o(.text+0x95e):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfint_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x97b):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0xb8e): In function `xtciof_mp_xtcio_&#39;:
<br>/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0xbde):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0xc2e):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;
<br>/tmp/ipo_ifort2f5KMw.o(.text+0xc7e):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0xcce):/tmp/ipo_ifort2f5KMw.f: more undefined references to `xdrffloat_&#39; follow<br>
/tmp/ipo_ifort2f5KMw.o(.text+0xe6b): In function `xtciof_mp_xtcio_&#39;:<br>/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrf3dfcoord_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0xfc6): In function `xtciof_mp_xtcopen_&#39;:<br>
/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfopen_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x1292):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfclose_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x12b3):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrfopen_&#39;
<br>/tmp/ipo_ifort2f5KMw.o(.text+0x134e): In function `xtciof_mp_xtccoord_&#39;:<br>/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x139f):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;
<br>/tmp/ipo_ifort2f5KMw.o(.text+0x13f0):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x1441):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;<br>/tmp/ipo_ifort2f5KMw.o(.text+0x1492):/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrffloat_&#39;
<br>/tmp/ipo_ifort2f5KMw.o(.text+0x14e3):/tmp/ipo_ifort2f5KMw.f: more undefined references to `xdrffloat_&#39; follow<br>/tmp/ipo_ifort2f5KMw.o(.text+0x162d): In function `xtciof_mp_xtccoord_&#39;:<br>/tmp/ipo_ifort2f5KMw.f: undefined reference to `xdrf3dfcoord_&#39;
<br>libxdrf.o(.text+0x3d86): In function `xdrclose&#39;:<br>libxdrf.c: undefined reference to `ffclose&#39;<br>libxdrf.o(.text+0x3da8):libxdrf.c: undefined reference to `ffclose&#39;<br><br>I&#39;m really not getting what can be the source of error. I placed the two test wources from above trials below, in case it can be of any help. But I really not getting what am I doing wrong, and also could not find any other clue in gromacs mail lists, neither google.
<br><br>Sorry it this is a much simpler question than it seems to me, but I&#39;m really astonished not finding the source of error neither a workaround or an altertive way which I could follow and reach some results.<br>
<br>Thanks a lot in advance,<br><br>Sincerally yours,<br><br>Jones<br><br>********Attachments:<br><br>*****test_xtc.f90:<br>program test_xtc<br>use xtciof<br>implicit none<br>! Declaracao de Variaveis:<br>&nbsp;&nbsp; integer :: xd, natoms, step, ret
<br>&nbsp;&nbsp; integer :: nat, maxat<br>!&nbsp; real*4&nbsp; :: time, box(9), x(*), prec<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: time, box(9), prec<br>&nbsp;&nbsp; real, dimension(:), allocatable :: x<br>&nbsp;&nbsp; character*1 :: stat<br>&nbsp;&nbsp; character(len=1) :: file_name<br><br>&nbsp;&nbsp; maxat = 10000
<br>&nbsp;&nbsp; stat = &#39;a&#39;<br>&nbsp;&nbsp; file_name = &#39;teste.xtc&#39;<br>&nbsp;&nbsp; allocate(x(30000))<br>&nbsp;&nbsp; x(:) = 0.<br><br>! Aqui comeca o programa de teste:<br><br>&nbsp;&nbsp; call xtcopen(xd, file_name, stat, maxat, nat)<br><br>&nbsp;&nbsp; write(6,*) &#39;xtc file openned&#39;
<br><br>&nbsp;&nbsp; call readxtc(xd, natoms, step, time, box, x, prec, ret)<br><br>&nbsp;&nbsp; write(6,*) &#39;xtc file readed&#39;<br><br>&nbsp;&nbsp; call writextc(xd, natoms, step, time, box, x, prec, ret)<br><br>&nbsp;&nbsp; write(6,*) &#39;xtc file written&#39;
<br><br>&nbsp;&nbsp; deallocate(x)<br><br>end program test_xtc<br><br>******xtciof.f90:<br>module xtciof<br><br>contains<br><br>subroutine xtccheck(ret,ivar)<br>implicit none<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp; Passed variables<br>!<br>&nbsp;&nbsp; integer, intent(in) :: ret, ivar
<br><br>&nbsp;&nbsp; if ( ret .eq. 0 ) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ivar == 1) write(6,*) &#39;&gt; XTC-Error reading/writing natoms&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ivar == 2) write(6,*) &#39;&gt; XTC-Error reading/writing step&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ivar == 3) write(6,*) &#39;&gt; XTC-Error reading/writing time&#39;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ivar == 4) write(6,*) &#39;&gt; XTC-Error reading/writing box&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ivar == 5) write(6,*) &#39;&gt; XTC-Error reading/writing x&#39;<br>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stop<br>&nbsp;&nbsp; endif<br>end subroutine xtccheck<br><br>subroutine xtcheader(xd,magic,natoms,step,time,ret)
<br>implicit none<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp; Passed variables<br>!<br>&nbsp;&nbsp; integer :: xd, natoms, step, ret, magic<br>!&nbsp; real*4&nbsp; :: time<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: time<br><br>&nbsp;&nbsp; call xdrfint(xd, magic, ret)<br>&nbsp;&nbsp; if (ret == 0) return<br><br>&nbsp;&nbsp; call xdrfint(xd, natoms, ret)
<br>&nbsp;&nbsp; call xtccheck(ret, 1)<br><br>&nbsp;&nbsp; call xdrfint(xd, step, ret)<br>&nbsp;&nbsp; call xtccheck(ret, 2)<br><br>&nbsp;&nbsp; call xdrffloat(xd, time, ret)<br>&nbsp;&nbsp; call xtccheck(ret, 3)<br><br>end subroutine xtcheader<br><br>subroutine xtccoord(xd,natoms,box,x,prec,ret)
<br>implicit none<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp; Passed variables<br>!<br>&nbsp;&nbsp; integer :: xd, natoms, ret<br>!&nbsp; real*4&nbsp; :: box(9), x(*), prec<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: box(9), x(*), prec<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp; local<br>!<br>&nbsp;&nbsp; integer :: i<br><br>&nbsp;&nbsp; do i=1, 9
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call xdrffloat(xd, box(i), ret)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call xtccheck(ret, 4)<br>&nbsp;&nbsp; enddo !i<br><br>&nbsp;&nbsp; call xdrf3dfcoord(xd, x, natoms, prec, ret)<br>&nbsp;&nbsp; call xtccheck(ret, 5)<br><br><br>end subroutine xtccoord<br><br>subroutine xtcio(xd, natoms, step, time, box, x, prec, mode, ret)
<br>implicit none<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp; Passed variables<br>!<br>&nbsp;&nbsp; integer :: xd, natoms, step, mode, ret<br>!&nbsp; real*4&nbsp; :: box(9)<br>!&nbsp; real*4&nbsp; :: box(9)<br>!&nbsp; real*4&nbsp; :: x(*)<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: time, prec<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: x(*)<br>
&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: box(9)<br>!<br>!&nbsp;&nbsp;&nbsp;&nbsp; local variables<br>!<br>&nbsp;&nbsp; integer :: xtcmagic<br>&nbsp;&nbsp; integer :: magic<br><br>&nbsp;&nbsp; xtcmagic=1995<br><br>&nbsp;&nbsp; if (mode .eq. 0) magic = xtcmagic<br><br>&nbsp;&nbsp; call xtcheader(xd, magic, natoms, step, time, ret)
<br><br>&nbsp;&nbsp; if (ret == 0) return<br><br>&nbsp;&nbsp; if (mode == 1) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (magic == xtcmagic) write(6,*) &#39;&gt; Fatal error, magic number read as &#39;,magic, &#39; should be &#39;,xtcmagic<br>&nbsp;&nbsp; endif !(mode == 1)<br>
<br>&nbsp;&nbsp; call xtccoord(xd, natoms, box, x, prec, ret)<br><br>end subroutine xtcio<br><br>subroutine readxtc(xd, natoms, step, time, box, x, prec, ret)<br>implicit none<br><br>&nbsp;&nbsp; integer :: xd, natoms, step, ret<br>&nbsp;&nbsp; integer :: nat
<br>!&nbsp; real*4&nbsp; :: time, box(9), x(*), prec<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: time, box(9), prec<br>&nbsp;&nbsp; real, dimension(:), allocatable :: x<br><br>&nbsp;&nbsp; allocate (x(natoms))<br>&nbsp;&nbsp; x(:) = 0.<br><br>&nbsp;&nbsp; call xtcio(xd,natoms,step,time,box,x,prec,1,ret)
<br><br>end subroutine readxtc<br><br>subroutine writextc(xd, natoms, step, time, box, x, prec, ret)<br>implicit none<br><br>&nbsp;&nbsp; integer :: xd, natoms, step, ret<br>&nbsp;&nbsp; real&nbsp;&nbsp;&nbsp; :: time, box(9), x(*), prec<br><br>&nbsp;&nbsp; call xtcio(xd, natoms, step, time, box, x, prec, 0, ret)
<br><br>end subroutine writextc<br><br>subroutine xtcopen (xd, file_name, stat, maxat, nat)<br>implicit none<br><br>&nbsp;&nbsp; integer :: xd, ret, nat, maxat, magic, step<br>!&nbsp; real*4 :: time<br>&nbsp;&nbsp; real :: time<br>&nbsp;&nbsp; character*1 :: stat
<br>&nbsp;&nbsp; character*(*) :: file_name<br>&nbsp;&nbsp; integer, parameter :: xtcmagic = 1995<br><br>&nbsp;&nbsp; call xdrfopen(xd, file_name, stat, ret)<br>&nbsp;&nbsp; if (ret == 0) write(6,*) &#39;&gt; Fatal error, could not open &#39;,file_name(1:20)<br>
<br>&nbsp;&nbsp; call xtcheader(xd, magic, nat, step, time, ret)<br><br>&nbsp;&nbsp; if (magic /= xtcmagic) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(6,*) &#39;&gt; Fatal error, magic number read as &#39;,magic,&#39; should be &#39;,xtcmagic<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stop<br>&nbsp;&nbsp; endif
<br><br>&nbsp;&nbsp; if (nat &lt; 0) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(6,*) &#39;&gt; Fatal error, negative number of atoms&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stop<br>&nbsp;&nbsp; endif<br><br>&nbsp;&nbsp; if (nat &gt; maxat) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(6,*) &#39;&gt; Fatal error, number of atoms (&#39;,nat,&#39;) &#39;,&#39;larger than allowed (&#39;,maxat,&#39;)&#39;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stop<br>&nbsp;&nbsp; endif<br><br>&nbsp;&nbsp; call xdrfclose(xd, ret)<br><br>&nbsp;&nbsp; call xdrfopen(xd, file_name, stat, ret)<br><br>end subroutine xtcopen<br><br>!end contains<br><br>end module xtciof<br>