Commit 0c5bff47 authored by jclamber's avatar jclamber

removed obsoltes files

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@138 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent cda15876
#include <iostream>
#include <cstdlib>
#include <string>
#include <uns.h>
using namespace std;
int main(int argc, char ** argv)
{
if (argc < 3) {
cerr << "\nsyntaxe: "<<argv[0]<< " filename component\n";
cerr << "example: "<<argv[0]<< " list all\n\n";
exit(1);
}
string simname(argv[1]);
string component(argv[2]);
bool verbose=false;
// -----------------------------------------------
// instantiate a new UNS input object (for reading)
uns::CunsIn * uns = new uns::CunsIn(simname,component,"all",verbose);
if (uns->isValid()) { // input file is known by UNS lib
while(uns->snapshot->nextFrame()) { // there is a new frame
string stype = uns->snapshot->getInterfaceType();
cout << "File name : "<<uns->snapshot->getFileName()<<"\n";
cout << "File type : "<<stype<<"\n";
int nbody; float time;
// get the input number of bodies according to the selection
uns->snapshot->getData("nsel",&nbody);
// get the simulation time
uns->snapshot->getData("time",&time);
// read position
float * pos;
bool ok = uns->snapshot->getData("all","pos",&nbody,&pos); // we get positions here
// in one dimensionnal array
if (ok) {
for (int i=0; i<nbody; i++) {
// display positions x,y,z
cerr << "x="<<pos[i*3+0] << " y="<<pos[i*3+1] << " z="<<pos[i*3+2] <<"\n" ;
}
}
}
}
delete uns;
}
//
program unsio_test_fortran
implicit none
integer lnblnk, narg, uns_init, uns_load, valid, ident,
$ nbody, uns_sim_type, cpt, uns_get_value_i,
$ status
!external iargc,getarg
character ain * 80, acomp * 80
character simdir * 100
!narg = iargc()
narg = command_argument_count()
write(0,*) 'narg=',narg
if (narg.ne.2) then
call getarg(0,ain)
write(0,*) "You must give 2 parameters:"
write(0,*) ain(1:lnblnk(ain)),
$ " inputfile selected_component"
write(0,*) ""
write(0,*) "Example : "
write(0,*) ain(1:lnblnk(ain)),
$ " list all"
stop
endif
! format fortran string to c string
call get_command_argument(1,ain)
call get_command_argument(2,acomp)
! initialyze UNS engine
ident=uns_init(ain, acomp, "all") ! return identifier for the snaphot
! ident must be positive
write(0,*) "Uns type = ",uns_sim_type(ident)
write (0,*) "UNS_INIT return :",ident
if (ident.gt.0) then
valid = 1
cpt = 0
call uns_sim_dir(ident,simdir)
write (0,*) "Simulation DIR = [",simdir(1:lnblnk(simdir)),"]"
do while (valid .gt. 0) ! loop on all the time step
valid = uns_load(ident) ! load data belonging to ident snapshot
write(0,*) "uns_load return=>",valid
if (valid .gt. 0) then ! it goes fine
!! get nbody
status=uns_get_value_i(ident,"nsel", nbody) ! get #bodies
write (0,*) "nbody =", nbody
!! start main subroutine
call start(ident,nbody)
endif
enddo
endif
end
! =============================================================================
subroutine start(ident,nbody)
implicit none
! input parameters
integer ident,nbody,i
! UNS variable
integer status
integer uns_get_value_f, uns_get_array_f, nsel
real *4 time, pos(3,nbody), vel(3,nbody), mass(nbody)
status=uns_get_value_f(ident,"time",time )
write (0,*) 'time =',time
! load pos vel mass
nsel=uns_get_array_f(ident,"all","pos" ,pos ,nbody)
if (nsel .gt. 0 ) then ! there are POSITIONS
do i=1,nbody
write (0,*) pos(1,i), pos(2,i), pos(3,i)
enddo
endif
nsel=uns_get_array_f(ident,"all","vel" ,vel ,nbody)
if (nsel .gt. 0 ) then ! there are VELOCITIES
do i=1,nbody
write (0,*) vel(1,i), vel(2,i), vel(3,i)
enddo
endif
nsel=uns_get_array_f(ident,"all","mass",mass,nbody)
if (nsel .gt. 0 ) then ! there are MASSES
do i=1,nbody
write (0,*) mass(i)
enddo
endif
write (0,*) 'nsel =',nsel,' nbody=',nbody
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment