1 subroutine restar (code, q, ac) 2c 3c---------------------------------------------------------------------- 4c This routine is the restart option. 5c 6c input: 7c code : restart option on the primitive variables 8c eq. 'in ', read from [restar.inp] 9c eq. 'out ', write to [restar.out] 10c 11c input or output: 12c q (nshg,ndof) : the variables to be read/written 13c 14c 15c Farzin Shakib, Summer 1985. 16c---------------------------------------------------------------------- 17c 18 use readarrays ! used to access qold, acold 19 include "common.h" 20 include "mpif.h" 21c 22 character*4 code 23 character*8 mach2 24 character*20 fname1, fmt1 25 character*5 cname 26 27c 28 dimension q(nshg,ndof),ac(nshg,ndof) 29c arrays in the following 1 line are now dimensioned in readnblk 30c real*8 qold(nshg,ndof),acold(nshg,ndof) 31c 32c.... --------------------------> 'in ' <--------------------------- 33c 34 if (code .eq. 'in ') then 35c 36c incompressible orders velocity, pressure, temperature unlike compressible 37c which is what we have our files set up for 38c 39 q(:,1:3)=qold(:,2:4) 40 q(:,4)=qold(:,1) 41 if(ndof.gt.4) q(:,5:ndof)=qold(:,5:ndof) 42 43 ac(:,1:3)=acold(:,2:4) 44 ac(:,4)=acold(:,1) 45 if(ndof.gt.4) ac(:,5:ndof)=acold(:,5:ndof) 46 47 deallocate(qold) 48 deallocate(acold) 49 return 50 endif 51c 52c.... --------------------------> 'out ' <--------------------------- 53c 54 if (code .eq. 'out ') then 55 56c$$$ ttim(75) = ttim(75) - tmr() 57 allocate( qold(nshg,ndof) ) 58 allocate( acold(nshg,ndof) ) 59 acold=0 60c itmp = 1 61c if (lstep .gt. 0) itmp = int(log10(float(lstep)))+1 62c write (fmt1,"('(''restart.'',i',i1,',1x)')") itmp 63c write (fname1,fmt1) lstep 64c 65c fname1 = trim(fname1) // cname(myrank+1) 66 67c open (unit=irstou, file=fname1, status='unknown', 68c & form='unformatted', err=996) 69 70c write (irstou) machin, nshg, lstep 71c incompressible orders velocity, pressure, temperature unlike compressible 72c which is what we have our files set up for 73c 74 qold(:,2:4) = q(:,1:3) 75 qold(:,1) = q(:,4) 76 if(ndof.gt.4) qold(:,5:ndof) = q(:,5:ndof) 77c 78 acold(:,2:4) = ac(:,1:3) 79 acold(:,1) = ac(:,4) 80 if(ndof.gt.4) acold(:,5:ndof) = ac(:,5:ndof) 81c 82 iqoldsiz=nshg*ndof 83 call write_restart(myrank, lstep, nshg, ndof, 84 & qold, acold) 85c write (irstou) qold 86c write (irstou) acold ! note that this is dYdt (reordered) 87c close (irstou) 88 89c$$$ open(unit=79,file="fort.79") 90c$$$ do i=1,nshg 91c$$$ write(79,78)(qold(i,j),j=1,5) 92c$$$ enddo 93c$$$ do i=1,nshg 94c$$$ write(79,78)(acold(i,j),j=1,5) 95c$$$ enddo 96c$$$ 78 format(5(2x,e12.5)) 97c$$$ close(79) 98 99 if (myrank.eq.master) then 100 open(unit=72,file='numstart.dat',status='old') 101 write(72,*) lstep 102 close(72) 103 endif 104 deallocate(qold) 105 deallocate(acold) 106c$$$ ttim(75) = ttim(75) + tmr() 107 return 108 endif 109c 110c.... ----------------------> Error Handling <----------------------- 111c 112c.... Error handling 113c 114 call error ('restar ',code//' ',0) 115c 116c.... file error handling 117c 118995 call error ('restar ','opening ', irstin) 119996 call error ('restar ','opening ', irstou) 120c 121c.... end 122c 123 end 124