subMud.f90 2.09 KB
subroutine readField(field,fileName)
  use gridInfo 
  implicit none
  character(*) :: fileName  
  real field(nx+1,ny)
  integer :: i
  real :: line(nx)

  open (unit=11, file=fileName, status='old', action='read')
  
  do i=1,ny
    read(11,*) line
    field(1:nx,i) = line
  enddo
  close(11)

  field(nx+1,:)= field(1,:)
end

subroutine writeField(fileName, field)
  use gridInfo
  implicit none
  character(*) :: fileName
  real field(nx+1,ny)
  integer i
  
  ! Writing field
  write(*,*) 'Wrinting fields'  
  open(unit=10,file=fileName,access='STREAM',form='UNFORMATTED',    status='UNKNOWN')
  do i=1,nx
        write(10) field(i,:)
  end do
  close(10)
end

subroutine checkIerror(ierror, fieldName)
  integer ierror
  character(*) :: fieldName

  
  if (ierror.gt.0) then
    print*, 'Fatal error number :', ierror , ' -> executing MUDPACK for: ', fieldName   
    call exit(0)
  elseif (ierror.lt.0) then
    print*, 'NonFatal error number :', ierror , ' -> executing MUDPACK for: ', fieldName    
  endif
end

subroutine bndyNull(field,dimB)
  use gridInfo
  implicit none
  integer dimB
  real field(nx+1,ny)

  if (dimB==1)then
    field(1,:) = 0.0
    field(nx+1,:) = 0.0
  else if (dimB ==2) then
    field(:,1) =  0.0
    field(:,ny) = 0.0
  end if
end

subroutine periodic(field)
  use gridInfo
  implicit none
  real field(nx+1,ny)

  field(1,:) =  field(nx,:)
  field(nx+1,:) = field(2,:)
end

subroutine bndc(kbdy,xory,alfa,gbdy)
! input mixed derivative b.c. to mud2
  use gridInfo
  implicit none
  integer kbdy
  real xory,alfa,gbdy,x,y,pe,px,py,pxx,pyy
  real xa,xb,yc,yd,tolmax,relmax
  common/ftmud2/xa,xb,yc,yd,tolmax,relmax

  if (kbdy.eq.3) then  ! y=yc tboundary
      x = xory
      y = yc
      alfa = 0
      gbdy = 0
      return
  end if
  if (kbdy.eq.4) then  ! y=yd boundary
      y = yd
      x = xory
      alfa = 0
      gbdy =  - cos(2*Pi*x/Lx) * tau / nu
      return
  end if
end


subroutine cof(x,y,cxx,cyy,cx,cy,ce)
! input pde coefficients at any grid point (x,y) in the solution region

  implicit none
  real x,y,cxx,cyy,cx,cy,ce
  cxx = 1
  cyy = 1
  cx = 0.
  cy = 0.
  ce = 0.
  return
end