anchor.diff:              end if
           end do
   
  -        ! Open the file
  -        if(t%wings(iwing)%orig_side .eq. "both") then
  -            write(filename, *) trim(adjustl(t%master_filename))//'_'//trim(adjustl(t%wings(iwing)%name))//"-"//trim(adjustl(t%wings(iwing)%side))//'.panair'
  -        else
  -            write(filename, *) trim(adjustl(t%master_filename))//'_'//trim(adjustl(t%wings(iwing)%name))//'.panair'
  -        end if
  -        open(unit = 10, File = filename, action = 'write', iostat = ierror)
  -        allocate(af_points(af_datasize,3))
  -        call view_write_panair_header(iwing)
  -        call view_write_panair_upper(t%wings(iwing), af_datasize, af_points)
  -        call view_write_panair_lower(t%wings(iwing), af_datasize, af_points)
  -        call view_write_panair_wake()
  -        write(10, "(A)") "$END"
  +        ! Write the network header information
  +        call view_write_panair_network_header(t%wings(iwing)%ID)
  +
  +        ! Write the upper network
  +        write(upper_network, '(A, I0)') 'upper_', t%wings(iwing)%ID
  +        call view_write_panair_network(t%wings(iwing), af_datasize, af_points, trim(adjustl(upper_network)), af_datasize, af_datasize / 2 + 1)
  +
  +        ! Write the lower network
  +        write(lower_network, '(A, I0)') 'lower_', t%wings(iwing)%ID
  +        call view_write_panair_network(t%wings(iwing), af_datasize, af_points, trim(adjustl(lower_network)), af_datasize / 2 + 1, 1)
  +
  +        ! Attach a wake to the trailing edge of the upper network
  +        call view_write_panair_wake(trim(adjustl(upper_network)))
           deallocate(af_points)
  -        close(10)
  -    end do
  +    end do
  +
  +    write(10, "(A)") "$END"
  +    close(10)
   
   end subroutine view_panair
   
   
  -subroutine view_write_panair_header(iwing)
  +subroutine view_write_panair_header(plane, symmetric)
  +    type(plane_t), intent(in) :: plane
  +    integer, intent(in) :: symmetric
  +
  +    write(10, '(A)') '$TITLE'
  +    write(10, '(A)') plane%name
  +    write(10, '(A)') 'Generated by MachUp'
  +    write(10, '(A)') '$DATACHECK'
  +    write(10, '(A)') '=ndtchk'
  +    write(10, '(I0)') 0
  +    write(10, '(A)') '$SYMMETRIC'
  +    write(10, '(A, T11, A)') '=xzpln', 'xypln'
  +    write(10, '(I0, T11, I0)') symmetric, 0
  +    write(10, '(A)') '$MACH NUMBER'
  +    write(10, '(A)') '=amach'
  +    write(10, '(F10.6)') 0.0
  +    write(10, '(A)') '$CASES'
  +    write(10, '(A)') '=nacase'
  +    write(10, '(I0)') 1
  +    write(10, '(A)') '$ANGLES OF ATTACK'
  +    write(10, '(A)') '=alpc'
  +    write(10, '(F10.6)') 0.0
  +    write(10, '(A)') '=alpha(0)'
  +    write(10, '(F10.6)') plane%alpha * 180.0 / pi
  +    write(10, '(A)') '$YAW ANGLE'
  +    write(10, '(A)') '=betc'
  +    write(10, '(F10.6)') 0.0
  +    write(10, '(A)') '=beta(0)'
  +    write(10, '(F10.6)') plane%beta * 180.0 / pi
  +    write(10, '(A)') '$REFERENCE DATA'
  +    write(10, '(A, T11, A, T21, A)') '=xref', 'yref', 'zref'
  +    write(10, '(3F10.6)') 0.0, 0.0, 0.0
  +    write(10, '(A, T11, A, T21, A, T31, A)') '=sref', 'bref', 'cref', 'dref'
  +    write(10, '(4F10.6)') plane%Sr, plane%lat_r, plane%long_r, plane%lat_r
  +    write(10, '(A)') '$PRINTOUT CONTROL'
  +    write(10, '(A, T11, A, T21, A, T31, A, T41, A, T51, A)') '=isings', 'igeomp', 'isingp', 'icontp', 'ibconp', 'iedgep'
  +    write(10, '(I0, T11, I0, T21, I0, T31, I0, T41, I0, T51, I0)') 0, 0, 0, 0, 0, 0
  +    write(10, '(A, T11, A, T21, A, T31, A, T41, A)') '=ipraic', 'nexdgn', 'ioutpr', 'ifmcpr', 'icostp'
  +    write(10, '(I0, T11, I0, T21, I0, T31, I0, T41, I0)') 0, 0, 1, 0, 0
  +end subroutine view_write_panair_header
  +
  +
  +subroutine view_write_panair_network_header(iwing)
       integer, intent(in) :: iwing
   
       ! Write header info
       write(10, "(A, I0)") "$POINTS for wing ", iwing
       write(10, "(A)") "=kn"  ! Number of networks in $POINTS block
  -    write(10, "(I0)") 2
  +    write(10, "(F10.6)") 2.0  ! Must be a floating-point value...
       write(10, "(A)") "=kt"  ! Boundary condition (1 = solid surface)
       write(10, "(I0)") 1
   
  -end subroutine view_write_panair_header
  -
  -
  -subroutine view_write_panair_upper(wi, af_datasize, af_points)
  -    type(wing_t), intent(in) :: wi
  -    integer, intent(in) :: af_datasize
  -    real, allocatable, dimension(:,:), intent(inout) :: af_points
  -
  -    call view_write_panair_network(wi, af_datasize, af_points, "upper", af_datasize, af_datasize / 2 + 1)
  -end subroutine view_write_panair_upper
  -
  -
  -subroutine view_write_panair_lower(wi, af_datasize, af_points)
  -    type(wing_t), intent(in) :: wi
  -    integer, intent(in) :: af_datasize
  -    real, allocatable, dimension(:,:), intent(inout) :: af_points
  -
  -    call view_write_panair_network(wi, af_datasize, af_points, "lower", af_datasize / 2 + 1, 1)
  -end subroutine view_write_panair_lower
  +end subroutine view_write_panair_network_header
   
   
   subroutine view_write_panair_network(wi, af_datasize, af_points, network, istart, iend)
  
positive.code: !-----------------------------------------------------------------------------------------------------------
  subroutine view_panair(t)
      type(plane_t) :: t
      real,allocatable,dimension(:,:) :: af_points
      character(100) :: filename
      integer :: i,iwing,af_datasize
      integer :: ierror = 0
  
      do i=1,size(airfoils)
          call af_create_geom_from_file(airfoils(i),DB_Airfoil)
      end do
  
      do iwing=1,t%nrealwings !real wings
          af_datasize = t%wings(iwing)%airfoils(1)%p%geom%datasize
          do i=1, t%wings(iwing)%nairfoils
              if(t%wings(iwing)%airfoils(i)%p%geom%datasize .ne. af_datasize) then
                  write(*,*) 'All airfoils for wing ',t%wings(iwing)%name,' must have same number of nodes.'
  
negative.code: end subroutine view_write_panair_points
  
  
  subroutine view_write_panair_wake(network)
      character(*), intent(in) :: network
      write(10, "(A)") "$TRAILING matchw=0"
      write(10, "(A)") "=kn"
      write(10, "(F10.6)") 1.0  ! Must be a floating-point value...
      write(10, "(A, T11, A)") "=kt", "matchw"
      write(10, "(I0, T11, I0)") 18, 0
      write(10, "(A, T11, A, T21, A, T31, A)") "=inat", "insd", "xwake", "twake"
      write(10, "(A, T11, I0, T21, I0, T31, I0, T71, A)") network, 1, 10, 0, "wake"
  end subroutine
  
  
  