! $Id: io.f,v 1.4 2000/09/24 19:24:44 aake Exp $ ************************************************************************ * * This part contains the I/O files that do not depend on the number * of variables to save (HD or MHD). * ************************************************************************ subroutine open_write_file (file, nio) * * Controls where the outdata file is opened. If the filename ends * on `.cm', the file is on the data vault, otherwise the data is on * the frontend (opened and closed each time). * include 'cparam.inc' character *(mfile) file integer nio *----------------------------------------------------------------------- end ************************************************************************ subroutine close_write_file (file) * * Close the output data file * include 'cparam.inc' character *(mfile) file *----------------------------------------------------------------------- * end ************************************************************************ subroutine start_data (case, file, nio) * * Controls where the in data is found. * If the filename ends on `.cm', the file is on the data vault, * if the filename ends in '.start' a startup routine is called, * else the data is on the frontend. * * Update history: * * 7-jun-92/axel: enable input of t from the dummy layer * include 'cparam.inc' include 'cdata.inc' include 'cwork.inc' character *(mfile) case, file *----------------------------------------------------------------------- * init=0 if (file(1:4) .eq. 'init') init=1 call start (case, init) * if (file(1:4) .ne. 'init') then call read_front (file, nio) endif * end ************************************************************************ subroutine write_data (file, nio) * * Controls where the outdata is written. * When the filename ends on `.cm', the file is on the data vault, * else the data is on the frontend. * include 'cparam.inc' include 'cdata.inc' include 'cwork.inc' character *(mfile) file integer dot *----------------------------------------------------------------------- * call write_front (file, nio) * * File for common block * dot = index(file,'.') open (12, file=file(1:dot)//'com', & status='unknown', form='unformatted', & access='direct', recl=lrec(50)) write (*,*) 'common:', file(1:dot)//'com', nio-1 include 'cwrite_com.inc' close (12) open (12, file=file(1:dot)//'dim', & status='unknown', form='formatted') write (12,'(3i5)') mx,my,mz write (12,'(3(1pe12.5))') dx, dy, dz ixvert = 1 write (12,'(f9.6,i3)') gamma, ixvert write (12,'(i3)') mvar close (12) * end ************************************************************************ subroutine read_cdata (file, nio) * * Reads /cdata/ common block from direct access file * include 'cparam.inc' include 'cdata.inc' character *(mfile) file integer dot *----------------------------------------------------------------------- * * File for common block * dot = index(file,'.') open (12, file=file(1:dot)//'com', & status='old', form='unformatted', & access='direct', recl=lrec(50), err=99) write (*,*) 'reading common block record ',nio-1,' from ',file include 'cread_com.inc' close (12) * 99 continue end ************************************************************************ * * This part contains the I/O files for the HD and MHD cases. * ************************************************************************ subroutine read_front (file, nio) * * Read data from the frontend. * include 'cparam.inc' include 'cwork.inc' character *(mfile) file *----------------------------------------------------------------------- * open (10, file=file, & status='old', form='unformatted', & access='direct', recl=lrec(mw)) read(10,rec=(nio - 1)*mvar + 1) r read(10,rec=(nio - 1)*mvar + 2) px read(10,rec=(nio - 1)*mvar + 3) py read(10,rec=(nio - 1)*mvar + 4) pz read(10,rec=(nio - 1)*mvar + 5) e if (mvar.gt.5) then read(10,rec=(nio - 1)*mvar + 6) bx read(10,rec=(nio - 1)*mvar + 7) by read(10,rec=(nio - 1)*mvar + 8) bz endif * close (10) * end ************************************************************************ subroutine write_front (file, nio) * * Write data to the frontend. * include 'cparam.inc' include 'cwork.inc' character*(mfile) file *----------------------------------------------------------------------- * open (11, file=file, & status='unknown', form='unformatted', & access='direct', recl=lrec(mw)) write(11,rec=(nio - 1)*mvar + 1) r write(11,rec=(nio - 1)*mvar + 2) px write(11,rec=(nio - 1)*mvar + 3) py write(11,rec=(nio - 1)*mvar + 4) pz write(11,rec=(nio - 1)*mvar + 5) e if (mvar.gt.5) then write(11,rec=(nio - 1)*mvar + 6) bx write(11,rec=(nio - 1)*mvar + 7) by write(11,rec=(nio - 1)*mvar + 8) bz endif * close(11) end ************************************************************************ subroutine read_datav (file, nio) * * Read data from the datavault * include 'cparam.inc' character *(mfile) file integer nio *----------------------------------------------------------------------- print *,'read_datav called' stop end ************************************************************************ subroutine write_datav (nio) * * Write data to datavault. * print *,'write_datav called' stop end