m_tecfld.F90 1.92 KB
module m_tecfld
contains
subroutine tecfld(fname,ref,est,var,dz,dt)
   use mod_dimensions
   use mod_states
   implicit none
   character(len=*), intent(in) :: fname
   type(states), intent(in), dimension(ndim) :: ref,est,var
   real, intent(in) :: dz
   real, intent(in) :: dt

   character*4 tag
   integer ii,jj,i,j

   ii=kdim
   jj=ndim

   open(10,file='tec'//fname//'.dat',status='unknown')
      write(10,*)'TITLE = "',fname,'"'
      write(10,*)'VARIABLES = "i"  "j"  "depth" "time" "ref-N" "ref-P" "ref-H"&
	   & "est-N" "est-P" "est-H"&
	   & "var-N" "var-P" "var-H"&
	   & "std-N" "std-P" "std-H"&
	   & "res-N" "res-P" "res-H"'
      write(10,'(a,i3,a,i3,a)')' ZONE  F=BLOCK, I=',ii,', J=',jj,', K=1'


! Positions in Grid index
      write(10,'(30I4)')((i,i=1,ii),j=1,jj)
      write(10,'(30I4)')((j,i=1,ii),j=1,jj)

! Positions in Depth and Time
      write(10,900)((float(i-1)*dz,i=1,ii),j=1,jj)
      write(10,900)((float(j-1)*dt,i=1,ii),j=1,jj)

! N,P,H - reference sol
      write(10,900)((ref(j)%N(i),i=1,ii),j=1,jj)
      write(10,900)((ref(j)%P(i),i=1,ii),j=1,jj)
      write(10,900)((ref(j)%H(i),i=1,ii),j=1,jj)

! N,P,H - estimate
      write(10,900)((est(j)%N(i),i=1,ii),j=1,jj)
      write(10,900)((est(j)%P(i),i=1,ii),j=1,jj)
      write(10,900)((est(j)%H(i),i=1,ii),j=1,jj)

! N,P,H - variance
      write(10,900)((var(j)%N(i),i=1,ii),j=1,jj)
      write(10,900)((var(j)%P(i),i=1,ii),j=1,jj)
      write(10,900)((var(j)%H(i),i=1,ii),j=1,jj)

! N,P,H - sqrt(variance)
      write(10,900)((sqrt(var(j)%N(i)),i=1,ii),j=1,jj)
      write(10,900)((sqrt(var(j)%P(i)),i=1,ii),j=1,jj)
      write(10,900)((sqrt(var(j)%H(i)),i=1,ii),j=1,jj)

! N,P,H - estimate-ref
      write(10,900)((abs(est(j)%N(i)-ref(j)%N(i)),i=1,ii),j=1,jj)
      write(10,900)((abs(est(j)%P(i)-ref(j)%P(i)),i=1,ii),j=1,jj)
      write(10,900)((abs(est(j)%H(i)-ref(j)%H(i)),i=1,ii),j=1,jj)

   close(10)
900  format(10(1x,e12.5))

end subroutine tecfld

end module m_tecfld