text:
module mod_utilities
	! Description:
	! - Write arrays (of real and integer type) of up to
	!   7 dimensions to text file or binary file columnwise
	! - Print a matrix to a file as (row,col)
	!
	!   Date      Programmer       Description of change
	!   ====      ==========       =====================
	!  20210407   A. Di Nola       Original code
	!  20210701   A. Di Nola       Added read1dim,read2dim
    !  20210725   A. Di Nola       Added writescalar, readscalar
    !  20210829   A. Di Nola       Added print_vector, print_matrix
    !  20210901   A. Di Nola       Added write1dimBinary
	!  20211120   A. Di Nola       Added disp
    !  20211123   A. Di Nola       Added read3dim
    !  20211216   A. Di Nola       Added writeArr1

	! USE other modules
	implicit none

	!private !Variables and internal proc are not visible outside of this module

    ! Visible outside
    !public :: myerror

	!Declare module variables

	!Declare generic interface

    interface print1dim
		module procedure print1dim_i
		module procedure print1dim_r
    end interface

	interface printMatrix
		module procedure printMatrix_i
		module procedure printMatrix_r
    end interface

    interface writescalar
		module procedure writescalar_i
		module procedure writescalar_r
    end interface

    interface write1dimBinary
		module procedure write1dimBinary_i
		module procedure write1dimBinary_r
    end interface

    interface writeArr1
        module procedure writeArr1_i
        module procedure writeArr1_r
    end interface

	interface write1dim
		module procedure write1dim_i
		module procedure write1dim_r
	end interface

	interface write2dim
		module procedure write2dim_i
		module procedure write2dim_r
	end interface

	interface write3dim
		module procedure write3dim_i
		module procedure write3dim_r
	end interface

	interface write4dim
		module procedure write4dim_i
		module procedure write4dim_r
	end interface

	interface write5dim
		module procedure write5dim_i
		module procedure write5dim_r
	end interface

	interface write6dim
		module procedure write6dim_i
		module procedure write6dim_r
	end interface

	interface write7dim
		module procedure write7dim_i
		module procedure write7dim_r
    end interface

    ! - Read scalar
    interface readscalar
        module procedure readscalar_i
        module procedure readscalar_r
    end interface

	! - Read 1-DIM array
    interface read1dim
        module procedure read1dim_i
        module procedure read1dim_r
    end interface

    ! - Read 2-DIM array
    interface read2dim
        module procedure read2dim_i
        module procedure read2dim_r
    end interface

    ! - Read 3-DIM array
    interface read3dim
        module procedure read3dim_i
        module procedure read3dim_r
    end interface

	! - Display vector, matrix or 3-D array (with title)
	interface disp
        module procedure disp_scal, disp_vec, disp_mat, disp_3d, disp_vec_i, disp_mat_i, &
                         disp_scal_title, disp_vec_title, disp_mat_title, disp_3d_title, &
                         disp_vec_title_i, disp_mat_title_i, disp_mat_title_l, disp_mat_l
    end interface disp

	integer, parameter :: rt = 8

    contains

    !Module procedures

  !**********************************************************
  ! PRINT VECTOR BASH
  !**********************************************************
  subroutine print_vector(v)
  !**********************************************************
  ! PRINT_VECTOR prints a vector in the terminal
  ! Usage:
  !	call print_vector(v)

  ! INPUTS
  !	v     	: vector to print
  !
  !***********************************************************
    !Local
    integer :: i

    !Dummy
    real(8), intent(in) :: v(:)

    do i = 1,size(v)
       write(*,*) v(i)
    end do
  end subroutine print_vector

  !**********************************************************
  ! PRINT MATRIX BASH
  !**********************************************************
  subroutine print_matrix(v)
  !**********************************************************
  ! PRINT_MATRIX prints matrix in the terminal
  ! Usage:
  !	call print_matrix(v)

  ! INPUTS
  !	v     : matrix to print
  !
  !***********************************************************

    !Local
    integer :: i

    !Dummy
    real, intent(in) :: v(:,:)

    do i = 1,size(v,1)
       write(*,*) v(i,:)
    end do
  end subroutine print_matrix

  !**********************************************************
  ! PRINT MATRIX DATA FILE (.dat)
  !**********************************************************
  subroutine print_matrix_dat(namefile,v)
  !**********************************************************
  ! PRINT_MATRIX_DAT print matrix in a dat file
  ! Usage:
  !	call print_matrix_dat(namefile,v)

  ! INPUTS
  ! namefile : name of the file
  !	v        : matrix to print
  !
  !***********************************************************
    !Local
    integer :: i

    !Dummy
    real, intent(in) :: v(:,:)
    character (len=*) :: namefile

    open(1, file=namefile, action='write', status='replace')

    do i = 1,size(v,1)
       write(1,*) v(i,:)
    end do
    close(1)
  end subroutine print_matrix_dat

  !**********************************************************
  ! PRINT VECTOR DATA FILE (.dat)
  !**********************************************************
  subroutine print_vector_dat(namefile,v)
  !**********************************************************
  ! PRINT_VECTOR_DAT prints vector in a dat file
  ! Usage:
  !	call print_matrix_dat(namefile,v,n)

  ! INPUTS
  !	namefile     : name of the dat file
  !	v            : vector to print
  !     n            : size of the vector
  !
  !***********************************************************
    !Local
    integer :: i

    !Dummy
    real, intent(in) :: v(:)
    character (len=*) :: namefile

    open(1, file=namefile, action='write', status = 'replace')

    do i = 1,size(v)
       write(1,*) v(i)
    end do
    close(1)

  end subroutine print_vector_dat

    !-----------------------------------------------------------------!
    !   PRINT VECTOR
    !-----------------------------------------------------------------!
    subroutine print1dim_r(x)
    ! This subroutine prints a vector (1-dim array) x on the screen

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:)
    integer :: i

    !Display vector x on screen
    do i = 1,size(x)
        write(*,'(f12.6," ")'), x(i)
        !write(*,'(" ")', advance = 'no')
	enddo
	write(*,"()")
    write(*,*) " "

    end subroutine print1dim_r
    !-----------------------------------------------------------------!

    subroutine print1dim_i(x)
    ! This subroutine prints a vector (1-dim array) x on the screen

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:)
    integer :: i

    !Display vector x on screen
    do i = 1,size(x)
        write(*,'(I6," ")'), x(i)
        !write(*,'(" ")', advance = 'no')
	enddo
	write(*,"()")
    write(*,*) " "

    end subroutine print1dim_i

    !-----------------------------------------------------------------!
    !   PRINT MATRIX
    !-----------------------------------------------------------------!
    subroutine printMatrix_r(x,file_name)
    ! This subroutine prints matrix (2-dim array) x on file file_name.
    ! If filename is not present, matrix is displayed on the screen.

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:)
    character(len=*), intent(in), optional :: file_name
    integer :: unitno, ierr, i, j

    if (present(file_name)) then
        !Write matrix x(row,col) into a txt file
        open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
        if (ierr/=0) then
            write(*,*) "Error: printMatrix: cannot open file"
		    pause
		    stop
        endif

        do i = 1,size(x,1)
		    do j = 1,size(x,2)
			    write(unitno,'(f12.6," ")',advance='no'), x(i,j)
                write(unitno,'(" ")', advance = 'no')
		    enddo
		    write(unitno,"()")
        enddo
        write(unitno,*) " "

        close(unitno)

    else

        !Display matrix x(row,col) on screen
        do i = 1,size(x,1)
		do j = 1,size(x,2)
			write(*,'(f12.6," ")',advance='no'), x(i,j)
                	write(*,'(" ")', advance = 'no')
		enddo
		write(*,"()")
        enddo
        write(*,*) " "

    endif

    end subroutine printMatrix_r
    !-----------------------------------------------------------------!
    subroutine printMatrix_i(x,file_name)
    ! This subroutine prints matrix (2-dim array) x on file file_name.
    ! If filename is not present, matrix is displayed on the screen.

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:)
    character(len=*), intent(in), optional :: file_name
    integer :: unitno, ierr, i, j

    if (present(file_name)) then
        !Write integer matrix x(row,col) into a txt file
        open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
        if (ierr/=0) then
            write(*,*) "Error: printMatrix: cannot open file"
		    pause
		    stop
        endif

        do i = 1,size(x,1)
		    do j = 1,size(x,2)
			    write(unitno,'(I6)',advance='no'), x(i,j)
		    enddo
		    write(unitno,*) " "
        enddo
        write(unitno,*) " "

        close(unitno)

    else

        !Write integer matrix x(row,col) into a txt file
        do i = 1,size(x,1)
		    do j = 1,size(x,2)
			    write(*,'(I6)',advance='no'), x(i,j)
		    enddo
		    write(*,*) " "
        enddo
        write(*,*) " "

    endif

    end subroutine printMatrix_i

    !-----------------------------------------------------------------!
    !   WRITE SCALARS
    !-----------------------------------------------------------------!
    subroutine writescalar_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x
    character(len=*), intent(in) :: file_name
    integer :: unitno,i, ierr

    !Write scalar x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: writescalar: cannot open file"
		pause
		stop
    endif

    write(unitno,*) x

    close(unitno)

    end subroutine writescalar_r
    !-----------------------------------------------------------------!
    subroutine writescalar_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x
    character(len=*), intent(in) :: file_name
    integer :: unitno,i, ierr

    !Write scalar x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: writescalar: cannot open file"
		pause
		stop
    endif

    write(unitno,*) x

    close(unitno)

    end subroutine writescalar_i
    !-----------------------------------------------------------------!

    subroutine write1dimBinary_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i, ierr

    !Write 1 dim array x into a BINARY file
    !Note the commands FORM="unformatted", ACCESS="stream"
    !and the fact that write(unitno) instead of write(unitno,*)
    OPEN(NEWUNIT=unitno, FILE=file_name, FORM="unformatted", ACCESS="stream", STATUS="unknown", iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write1dimBinary: cannot open file"
		pause
		stop
    endif

    !do i = 1,size(x,dim=1)
    !    write(unitno) x(i)
    !enddo

    write(unitno) x

    close(unitno)

    end subroutine write1dimBinary_r
    !-----------------------------------------------------------------!

    subroutine write1dimBinary_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:)
    character(len=*), intent(in) :: file_name
    integer :: unitno, ierr

    !Write 1 dim array x into a BINARY file
    !Note the commands FORM="unformatted", ACCESS="stream"
    !and the fact that write(unitno) instead of write(unitno,*)
    OPEN(NEWUNIT=unitno, FILE=file_name, FORM="unformatted", ACCESS="stream", STATUS="unknown", iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write1dimBinary: cannot open file"
		pause
		stop
    endif

    !do i = 1,size(x,dim=1)
    !    write(unitno) x(i)
    !enddo

    write(unitno) x

    close(unitno)

    end subroutine write1dimBinary_i
    !-----------------------------------------------------------------!

    !-----------------------------------------------------------------!
    !   WRITE 1-D ARRAY as single line (faster than write1dim)
    !-----------------------------------------------------------------!
    subroutine writeArr1_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:)
    character(len=*), intent(in) :: file_name
    character(len=50) :: file_format
    integer :: unitno, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write1dim: cannot open file"
		pause
		stop
    endif

    !write(unitno,"(330000(F20.16))") x
    write(file_format,*) "(",size(x),"(F,:,','))"

    write(unitno,trim(file_format)) x

    close(unitno)

    end subroutine writeArr1_r
    !-----------------------------------------------------------------!

    subroutine writeArr1_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:)
    character(len=*), intent(in) :: file_name
    character(len=50) :: file_format
    integer :: unitno,i, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write1dim: cannot open file"
		pause
		stop
    endif

    !Assume size(x) is equal to 330000
    !write(unitno,"(330000(F20.16))") x
    write(file_format,*) "(",size(x),"(I,:,','))"

    write(unitno,trim(file_format)) x

    close(unitno)

    end subroutine writeArr1_i
    !-----------------------------------------------------------------!

    !-----------------------------------------------------------------!
    !   WRITE 1 DIM ARRAYS as text files
    !-----------------------------------------------------------------!
    subroutine write1dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:)
    character(len=*), intent(in) :: file_name
    character(len=50) :: file_format
    integer :: unitno, i, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write1dim: cannot open file"
		pause
		stop
    endif

    do i = 1,size(x)
        write(unitno,*) x(i)
    enddo

    close(unitno)

    end subroutine write1dim_r
    !-----------------------------------------------------------------!
    subroutine write1dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:)
    character(len=*), intent(in) :: file_name
    !character(len=*) :: file_format
    integer :: unitno,i, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write1dim: cannot open file"
		pause
		stop
    endif

    !write(file_format,*) size(x)

    do i = 1,size(x)
        write(unitno,*) x(i)
    enddo

    close(unitno)

    end subroutine write1dim_i
    !-----------------------------------------------------------------!
    !   WRITE 2 DIM ARRAYS
    !-----------------------------------------------------------------!
    subroutine write2dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write2dim: cannot open file"
		pause
		stop
    endif

    do i2 = 1,size(x,dim=2)
        do i1 = 1,size(x,dim=1)
            write(unitno,*) x(i1,i2)
        enddo
    enddo

    close(unitno)

    end subroutine write2dim_r
    !-----------------------------------------------------------------!
    subroutine write2dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2,ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write2dim: cannot open file"
		pause
		stop
    endif

    do i2 = 1,size(x,dim=2)
        do i1 = 1,size(x,dim=1)
            write(unitno,*) x(i1,i2)
        enddo
    enddo

    close(unitno)

    end subroutine write2dim_i
    !-----------------------------------------------------------------!
    !   WRITE 3 DIM ARRAYS
    !-----------------------------------------------------------------!
    subroutine write3dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write3dim: cannot open file"
		pause
		stop
    endif

    do i3 = 1,size(x,dim=3)
        do i2 = 1,size(x,dim=2)
            do i1 = 1,size(x,dim=1)
                write(unitno,*) x(i1,i2,i3)
            enddo
        enddo
    enddo

    close(unitno)

    end subroutine write3dim_r
    !-----------------------------------------------------------------!
    subroutine write3dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write3dim: cannot open file"
		pause
		stop
    endif

    do i3 = 1,size(x,dim=3)
        do i2 = 1,size(x,dim=2)
            do i1 = 1,size(x,dim=1)
                write(unitno,*) x(i1,i2,i3)
            enddo
        enddo
    enddo

    close(unitno)

    end subroutine write3dim_i
    !-----------------------------------------------------------------!
    !   WRITE 4 DIM ARRAYS
    !-----------------------------------------------------------------!
    subroutine write4dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write4dim: cannot open file"
		pause
		stop
    endif

    do i4 = 1,size(x,dim=4)
        do i3 = 1,size(x,dim=3)
            do i2 = 1,size(x,dim=2)
                do i1 = 1,size(x,dim=1)
                    write(unitno,*) x(i1,i2,i3,i4)
                enddo
            enddo
        enddo
    enddo

    close(unitno)

    end subroutine write4dim_r
    !-----------------------------------------------------------------!
    subroutine write4dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write4dim: cannot open file"
		pause
		stop
    endif

    do i4 = 1,size(x,dim=4)
        do i3 = 1,size(x,dim=3)
            do i2 = 1,size(x,dim=2)
                do i1 = 1,size(x,dim=1)
                    write(unitno,*) x(i1,i2,i3,i4)
                enddo
            enddo
        enddo
    enddo

    close(unitno)

    end subroutine write4dim_i
    !-----------------------------------------------------------------!

    !-----------------------------------------------------------------!
    !   WRITE 5 DIM ARRAYS
    !-----------------------------------------------------------------!
    subroutine write5dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4,i5, ierr

    !Write 5-dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write6dim: cannot open file"
		pause
		stop
    endif

    do i5 = 1,size(x,dim=5)
    do i4 = 1,size(x,dim=4)
    do i3 = 1,size(x,dim=3)
    do i2 = 1,size(x,dim=2)
    do i1 = 1,size(x,dim=1)
        write(unitno,*) x(i1,i2,i3,i4,i5)
    enddo
    enddo
    enddo
    enddo
    enddo

    close(unitno)

    end subroutine write5dim_r
    !-----------------------------------------------------------------!
    subroutine write5dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4,i5, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write6dim: cannot open file"
		pause
		stop
    endif

    do i5 = 1,size(x,dim=5)
    do i4 = 1,size(x,dim=4)
    do i3 = 1,size(x,dim=3)
    do i2 = 1,size(x,dim=2)
    do i1 = 1,size(x,dim=1)
        write(unitno,*) x(i1,i2,i3,i4,i5)
    enddo
    enddo
    enddo
    enddo
    enddo

    close(unitno)

    end subroutine write5dim_i
    !-----------------------------------------------------------------!

    !-----------------------------------------------------------------!
    !   WRITE 6 DIM ARRAYS
    !-----------------------------------------------------------------!
    subroutine write6dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:,:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4,i5,i6, ierr

    !Write 6-dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write6dim: cannot open file"
		pause
		stop
    endif

    do i6 = 1,size(x,dim=6)
    do i5 = 1,size(x,dim=5)
    do i4 = 1,size(x,dim=4)
    do i3 = 1,size(x,dim=3)
    do i2 = 1,size(x,dim=2)
    do i1 = 1,size(x,dim=1)
        write(unitno,*) x(i1,i2,i3,i4,i5,i6)
    enddo
    enddo
    enddo
    enddo
    enddo
    enddo

    close(unitno)

    end subroutine write6dim_r
    !-----------------------------------------------------------------!
    subroutine write6dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:,:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4,i5,i6, ierr

    !Write 1 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write6dim: cannot open file"
		pause
		stop
    endif

    do i6 = 1,size(x,dim=6)
    do i5 = 1,size(x,dim=5)
    do i4 = 1,size(x,dim=4)
    do i3 = 1,size(x,dim=3)
    do i2 = 1,size(x,dim=2)
    do i1 = 1,size(x,dim=1)
        write(unitno,*) x(i1,i2,i3,i4,i5,i6)
    enddo
    enddo
    enddo
    enddo
    enddo
    enddo

    close(unitno)

    end subroutine write6dim_i
    !-----------------------------------------------------------------!

    !-----------------------------------------------------------------!
    !   WRITE 7 DIM ARRAYS
    !-----------------------------------------------------------------!
    subroutine write7dim_r(x,file_name)

    implicit none
    !Declare inputs:
    real(8), intent(in) :: x(:,:,:,:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4,i5,i6,i7, ierr

    !Write 7 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write7dim: cannot open file"
		pause
		stop
    endif

    do i7 = 1,size(x,dim=7)
    do i6 = 1,size(x,dim=6)
    do i5 = 1,size(x,dim=5)
    do i4 = 1,size(x,dim=4)
    do i3 = 1,size(x,dim=3)
    do i2 = 1,size(x,dim=2)
    do i1 = 1,size(x,dim=1)
        write(unitno,*) x(i1,i2,i3,i4,i5,i6,i7)
    enddo
    enddo
    enddo
    enddo
    enddo
    enddo
    enddo

    close(unitno)

    end subroutine write7dim_r
    !-----------------------------------------------------------------!
    subroutine write7dim_i(x,file_name)

    implicit none
    !Declare inputs:
    integer, intent(in) :: x(:,:,:,:,:,:,:)
    character(len=*), intent(in) :: file_name
    integer :: unitno,i1,i2, i3, i4,i5,i6,i7, ierr

    !Write 7 dim array x into a txt file
    open(newunit=unitno, file=file_name, status='replace',  iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error: write7dim: cannot open file"
		pause
		stop
    endif

    do i7 = 1,size(x,dim=7)
    do i6 = 1,size(x,dim=6)
    do i5 = 1,size(x,dim=5)
    do i4 = 1,size(x,dim=4)
    do i3 = 1,size(x,dim=3)
    do i2 = 1,size(x,dim=2)
    do i1 = 1,size(x,dim=1)
        write(unitno,*) x(i1,i2,i3,i4,i5,i6,i7)
    enddo
    enddo
    enddo
    enddo
    enddo
    enddo
    enddo

    close(unitno)

    end subroutine write7dim_i
    !-----------------------------------------------------------------!

    !=======================================================================!
    subroutine readscalar_i(x,file_name)

    implicit none

    character(len=*), intent(in) :: file_name
    integer, intent(out) :: x
    integer :: unitno,i, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in readscalar: cannot open file"
		pause
		stop
    endif

    read(unitno,*) x

    close(unitno)

    end subroutine readscalar_i
    !=======================================================================!

    subroutine readscalar_r(x,file_name)

    implicit none

    character(len=*), intent(in) :: file_name
    real(8), intent(out) :: x
    integer :: unitno,i, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in readscalar: cannot open file"
		pause
		stop
    endif

    read(unitno,*) x

    close(unitno)

    end subroutine readscalar_r
    !=======================================================================!

    subroutine read1dim_i(x,file_name)

    implicit none

    character(len=*), intent(in) :: file_name
    integer, intent(out) :: x(:)
    integer :: unitno,i, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in read1dim: cannot open file"
		pause
		stop
    endif

    do i = 1,size(x)
        read(unitno,*) x(i)
    enddo
    close(unitno)

    end subroutine read1dim_i
    !=======================================================================!

    subroutine read1dim_r(x,file_name)

    implicit none

    character(len=*), intent(in) :: file_name
    real(8), intent(out) :: x(:)
    integer :: unitno,i, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in read1dim: cannot open file"
		pause
		stop
    endif

    do i = 1,size(x)
        read(unitno,*) x(i)
    enddo
    close(unitno)

    end subroutine read1dim_r
    !=======================================================================!

    subroutine read2dim_i(x,file_name)

    implicit none

    character(len=*), intent(in) :: file_name
    integer, intent(out) :: x(:,:)
    integer :: unitno,i1,i2, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in read2dim: cannot open file"
		pause
		stop
    endif

    do i2 = 1,size(x,dim=2)
        do i1 = 1,size(x,dim=1)
            read(unitno,*) x(i1,i2)
        enddo
    enddo

    close(unitno)

    end subroutine read2dim_i
    !=======================================================================!

    subroutine read2dim_r(x,file_name)

    implicit none

    external getcwd

    character(len=*), intent(in) :: file_name
    real(8), intent(out) :: x(:,:)
    integer :: unitno,i1,i2, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in read2dim: cannot open file"
		pause
		stop
    endif

    do i2 = 1,size(x,dim=2)
        do i1 = 1,size(x,dim=1)
            read(unitno,*) x(i1,i2)
        enddo
    enddo

    close(unitno)

    end subroutine read2dim_r
    !=======================================================================!

    subroutine read3dim_i(x,file_name)

    implicit none

    character(len=*), intent(in) :: file_name
    integer, intent(out) :: x(:,:,:)
    integer :: unitno,i1,i2,i3, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in read3dim: cannot open file"
		pause
		stop
    endif

    do i3 = 1,size(x,dim=3)
        do i2 = 1,size(x,dim=2)
            do i1 = 1,size(x,dim=1)
                read(unitno,*) x(i1,i2,i3)
            enddo
        enddo
    enddo

    close(unitno)

    end subroutine read3dim_i
    !=======================================================================!

    subroutine read3dim_r(x,file_name)

    implicit none

    external getcwd

    character(len=*), intent(in) :: file_name
    real(8), intent(out) :: x(:,:,:)
    integer :: unitno,i1,i2,i3, ierr

    open(newunit=unitno, file=file_name, status='old', iostat=ierr)
    if (ierr/=0) then
        write(*,*) "Error in read3dim: cannot open file"
		pause
		stop
    endif

    do i3 = 1,size(x,dim=3)
        do i2 = 1,size(x,dim=2)
            do i1 = 1,size(x,dim=1)
                read(unitno,*) x(i1,i2,i3)
            enddo
        enddo
    enddo

    close(unitno)

    end subroutine read3dim_r
    !=======================================================================!

    subroutine create_directory( newDirPath )
    ! Author:  Jess Vriesema
    ! Date:    Spring 2011
    ! Purpose: Creates a directory at ./newDirPath

    implicit none

    character(len=*), intent(in) :: newDirPath
    character(len=256)           :: mkdirCmd
    logical                      :: dirExists

    ! Check if the directory exists first
!   inquire( file=trim(newDirPath)//'/.', exist=dirExists )  ! Works with gfortran, but not ifort
    inquire( directory=newDirPath, exist=dirExists )         ! Works with ifort, but not gfortran

    if (dirExists) then
!      write (*,*) "Directory already exists: '"//trim(newDirPath)//"'"
    else
        mkdirCmd = 'mkdir -p '//trim(newDirPath)
        write(*,'(a)') "Creating new directory: '"//trim(mkdirCmd)//"'"
        call system( mkdirCmd )
    endif
    end subroutine create_directory

	!=======================================================================!
	! ROUTINES TO DISPLAY SCALARS, VECTORS, MATRICES, 3D ARRAYS (WITH TITLE)
	!=======================================================================!
	subroutine disp_mat_title_l(title,X)
		implicit none
		character(len=*), intent(in) :: title
		logical, dimension(1:,1:), intent(in) :: X
		write(*,'(A)') title
		call disp_mat_l(X)
	end subroutine

	subroutine disp_mat_l(X)
		implicit none
		logical, dimension(1:,1:), intent(in) :: X
		integer :: i
		character(len=5) :: dim2
		write(dim2,'(i5)') size(X,2)
		do i = 1,size(X,1)
			write(*,'('//dim2//'L2)') X(i,:)
		end do
	end subroutine disp_mat_l

	subroutine disp_mat_title_i(title,X)
		implicit none
		character(len=*), intent(in) :: title
		integer, dimension(1:,1:), intent(in) :: X
		write(*,'(A)') title
		call disp_mat_i(X)
		end subroutine
		subroutine disp_mat_i(X)
		implicit none
		integer, dimension(1:,1:), intent(in) :: X
		integer :: i
		character(len=5) :: dim2
		write(dim2,'(i5)') size(X,2)
		do i = 1,size(X,1)
			write(*,'('//dim2//'i8)') X(i,:)
		end do
	end subroutine disp_mat_i

	subroutine disp_vec_title_i(title,X)
		implicit none
		character(len=*), intent(in) :: title
		integer, dimension(1:), intent(in) :: X
		write(*,'(A)') title
		call disp_vec_i(X)
		end subroutine
		subroutine disp_vec_i(X)
		implicit none
		integer, dimension(1:), intent(in) :: X
		integer :: i
		do i = 1,size(X,1)
			write(*,'(i8)') X(i)
		end do
	end subroutine disp_vec_i

	subroutine disp_vec(X,uid)
		implicit none
		real(rt), dimension(:), intent(in) :: X
		integer, intent(in), optional :: uid
		if (     present(uid)) call disp_core(X,size(X,1),1,1,'',uid)
		if (.not.present(uid)) call disp_core(X,size(X,1),1,1,'',6)
	end subroutine
	subroutine disp_mat(X,uid)
		implicit none
		real(rt), dimension(:,:), intent(in) :: X
		integer, intent(in), optional :: uid
		if (     present(uid)) call disp_core(X,size(X,1),size(X,2),1,'',uid)
		if (.not.present(uid)) call disp_core(X,size(X,1),size(X,2),1,'',6)
	end subroutine
	subroutine disp_3d(X,uid)
		implicit none
		real(rt), dimension(:,:,:), intent(in) :: X
		integer, intent(in), optional :: uid
		if (     present(uid)) call disp_core(X,size(X,1),size(X,2),size(X,3),'',uid)
		if (.not.present(uid)) call disp_core(X,size(X,1),size(X,2),size(X,3),'',6)
	end subroutine
	subroutine disp_vec_title(title,X,uid)
		implicit none
		real(rt), dimension(:), intent(in) :: X
		character(len=*), intent(in) :: title
		integer, intent(in), optional :: uid
		if (     present(uid)) call disp_core(X,size(X,1),1,1,title,uid)
		if (.not.present(uid)) call disp_core(X,size(X,1),1,1,title,6)
	end subroutine
	subroutine disp_mat_title(title,X,uid)
		implicit none
		real(rt), dimension(:,:), intent(in) :: X
		character(len=*), intent(in) :: title
		integer, intent(in), optional :: uid
		if (     present(uid)) call disp_core(X,size(X,1),size(X,2),1,title,uid)
		if (.not.present(uid)) call disp_core(X,size(X,1),size(X,2),1,title,6)
	end subroutine
	subroutine disp_3d_title(title,X,uid)
		implicit none
		real(rt), dimension(:,:,:), intent(in) :: X
		character(len=*), intent(in) :: title
		integer, intent(in), optional :: uid
		if (     present(uid)) call disp_core(X,size(X,1),size(X,2),size(X,3),title,uid)
		if (.not.present(uid)) call disp_core(X,size(X,1),size(X,2),size(X,3),title,6)
	end subroutine

	subroutine disp_core(X,n1,n2,n3,title,uid)
		implicit none
		integer, intent(in) :: n1,n2,n3,uid
		character(len=*), intent(in) :: title
		real(rt), intent(in) :: X(n1,n2,*)
		! local
		integer :: i1,i2,i3

		! If no title or uid is present, then use title='' and uid=6
		do i3 = 1,n3
			if (n3>1) then
				write(uid,'(A,i4,A)') title//'(:,:,',i3,')'
			else
				if (title/='') write(uid,'(A)') title
			end if
			do i1 = 1,n1
				do i2 = 1,n2-1
					write(uid,'(f12.5)',advance='no') X(i1,i2,i3)
				end do
				write(uid,'(f12.5)') X(i1,n2,i3)
			end do
		end do

	end subroutine
	subroutine disp_scal_title(title,X)
		implicit none
		character(len=*), intent(in) :: title
		real(rt), intent(in) :: X
		write(*,'(A)') title
		call disp_scal(X)
	end subroutine
	subroutine disp_scal(X)
		implicit none
		real(rt), intent(in) :: X
		write(*,'(f12.5)') X
	end subroutine disp_scal
	!=======================================================================!

	! Acts just like the colon in Matlab
	pure function colon(a,b)
		implicit none
		integer, intent(in) :: a,b
		integer, dimension(1:b-a+1) :: colon
		integer :: i
		do i = a,b
			colon(i-a+1) = i
		end do
	end function colon

end module mod_utilities

max_stars_repo_name: aledinola/ToolboxFortran

max_issues_repo_name: skphy/ToolboxFortran

max_forks_repo_name: skphy/ToolboxFortran


text:
program goto_01
implicit none
integer :: a
a = 5
go to 1
1 print *, a
end program

max_stars_repo_name: Thirumalai-Shaktivel/lfortran

max_issues_repo_name: Thirumalai-Shaktivel/lfortran

max_forks_repo_name: Thirumalai-Shaktivel/lfortran


text:
      subroutine ovswitch(p1,F0,F1,F2,F3,F4,F1a,F2a,F3a,F4a)
C----from F0,F1,F2,F3,F4 calculate F1a,F2a,F3a,F4a
C----which has first denominator
C----shifted by p1
      implicit none
      include 'TRydef.f'
      include 'TRmaxindex.f'
      integer n1,n2,n3,n4,ep
      double complex F0(-2:0),F1(y1max,-2:0),F2(y2max,-2:0),
     & F3(y3max,-2:0),F4(y4max,-2:0)
      double complex F1a(y1max,-2:0),F2a(y2max,-2:0),
     & F3a(y3max,-2:0),F4a(y4max,-2:0)
      double precision p1(4)

      do ep=-2,0
      do n1=1,4
      if (maxeindex .lt. 2) cycle
      F1a(n1,ep)=F1(n1,ep)-p1(n1)*F0(ep)
      do n2=n1,4
      if (maxeindex .lt. 3) cycle
      F2a(y2(n1,n2),ep)=F2(y2(n1,n2),ep)
     & -p1(n1)*F1(n2,ep)-p1(n2)*F1(n1,ep)
     & +p1(n1)*p1(n2)*F0(ep)
      do n3=n2,4
      if (maxeindex .lt. 4) cycle
      F3a(y3(n1,n2,n3),ep)=F3(y3(n1,n2,n3),ep)
     & -p1(n1)*F2(y2(n2,n3),ep)
     & -p1(n2)*F2(y2(n3,n1),ep)
     & -p1(n3)*F2(y2(n1,n2),ep)

     & +p1(n1)*p1(n2)*F1(n3,ep)
     & +p1(n2)*p1(n3)*F1(n1,ep)
     & +p1(n3)*p1(n1)*F1(n2,ep)

     & -p1(n1)*p1(n2)*p1(n3)*F0(ep)

      do n4=n3,4
      if (maxeindex .lt. 5) cycle
      F4a(y4(n1,n2,n3,n4),ep)=F4(y4(n1,n2,n3,n4),ep)
     & -p1(n1)*F3(y3(n2,n3,n4),ep)
     & -p1(n2)*F3(y3(n3,n4,n1),ep)
     & -p1(n3)*F3(y3(n4,n1,n2),ep)
     & -p1(n4)*F3(y3(n1,n2,n3),ep)

     & +p1(n1)*p1(n2)*F2(y2(n3,n4),ep)
     & +p1(n1)*p1(n3)*F2(y2(n2,n4),ep)
     & +p1(n1)*p1(n4)*F2(y2(n2,n3),ep)
     & +p1(n2)*p1(n3)*F2(y2(n1,n4),ep)
     & +p1(n2)*p1(n4)*F2(y2(n1,n3),ep)
     & +p1(n3)*p1(n4)*F2(y2(n1,n2),ep)

     & -p1(n1)*p1(n2)*p1(n3)*F1(n4,ep)
     & -p1(n2)*p1(n3)*p1(n4)*F1(n1,ep)
     & -p1(n3)*p1(n4)*p1(n1)*F1(n2,ep)
     & -p1(n4)*p1(n1)*p1(n2)*F1(n3,ep)

     & +p1(n1)*p1(n2)*p1(n3)*p1(n4)*F0(ep)

      enddo
      enddo
      enddo
      enddo
      enddo

      return
      end

ext: f

max_stars_repo_name: tmartini/JHUGen

max_issues_repo_name: tmartini/JHUGen

max_forks_repo_name: tmartini/JHUGen


text:
This program is offered under the umbrella of the Molecular and Cellular Biology department at UC Davis. MCB itself is in the College of Biological Sciences. Cell Biologys courses overlap with the Genetics and Biochemistry and Molecular Biology Biochemistry programs. Also, Many people who are interested in theoretical and quantitative cell bio minor in Quantitative Biology and bioinformatics.  The advising center for the major is located in 156 Briggs Hall Briggs. Phone: (5307520202).

 From the 20042005, 20052006 General Catalog

To understand living organisms, the biologist must understand the cell. Hence, cell biology lies a tthe core of the biological sciences. Students taking this major gain a solid foundation in biological principles. The major emphasizes how cellular organization and function contribute to the development, maintenance and reproduction of adult organisms. The major illustrates the ways in which principles derived from physical sciences, genetics, biochemistry, molecular biology, and physiology are integrated in the study of living cells and emphasizes the experimental nature of the study of cell biology.

 B.S. Major Requirements (Units)

Preparatory Subject Matter (6167)

Depth Subject Matter (4547)

Total Units for the Major (106114)

max_stars_repo_name: voflo/Search

max_issues_repo_name: voflo/Search

max_forks_repo_name: voflo/Search


text:
! BinaryIO.f90
!
! Author : Joseph Schoonover
! E-mail : jschoonover@lanl.gov, schoonover.numerics@gmail.com
!
! Copyright 2017 Joseph Schoonover, Los Alamos National Laboratory
!
! Redistribution and use in source and binary forms, with or without
! modification,
! are permitted provided that the following conditions are met:
!
! 1. Redistributions of source code must retain the above copyright notice, this
! list of conditions and the following disclaimer.
!
! 2. Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the
! documentation and/or other materials provided with the distribution.
!
! 3. Neither the name of the copyright holder nor the names of its contributors
! may be used to endorse or promote products derived from this
!  software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
! EXEMPLARY,  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
! BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
! NEGLIGENCE  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!
! ////////////////////////////////////////////////////////////////////////////////////////////////

MODULE BinaryIO
!
! BinaryIO.f90 ( v 1.1 )
!
! This module was written to provide subroutines which READ binary files that are
! written in big-endian byte ordering. The binary files can be READ into 1-,2-, or
! 3-Dimensional arrays.
!
! >>>>>>>>>>>>> List of Functions and Subroutines <<<<<<<<<<<<<<
!
!
! o  ReadBIN(1D/2D/3D) -------------------------------------------------------------------------------
!
!      The ReadBin routines WRITE a binary FILE with big-endian byte ordering. The length of the FILE
!      is determined by the precision and the total number of elements in an array. The only required
!      input is the filename and the variable with the appropriate size. An flag is returned to help
!      the outside calling program determine what to DO next, in the event of an unsuccessful READ.
!
!       ** The ReadBIN(1D/2D/3D) routines are overloaded onto the one procedure "ReadBIN" so that the
!          user should only have to call ReadBIN( filename, variable, ioFlag ) without the extension of
!          "1D", "2D", or "3D".
!
! o  WriteBIN(1D/2D/3D) -------------------------------------------------------------------------------
!
!      The WriteBin routines WRITE a binary FILE with big-endian byte ordering. The length of the FILE
!      is determined by the precision and the total number of elements in an array. The only required
!      input is the filename and the variable.
!
!       ** The WriteBIN(1D/2D/3D) routines are overloaded onto the one procedure "WriteBIN" so that the
!          user should only have to call WriteBIN( filename, variable ) without the extension of
!          "1D", "2D", or "3D".
!
! ========================================================================================================= !

 USE ModelPrecision
 USE CommonRoutines

 IMPLICIT NONE

    ! Overload the subroutine name "ReadBIN" to call the 1,2,or 3-D implementations based
    ! on the array dimensions passed. This way, the user only has to call ReadBIN( theFile, var, fileLength )
    ! to READ in a FILE to a REAL array.
    INTERFACE ReadBIN
        MODULE PROCEDURE ReadBIN4D, ReadBIN3D, ReadBIN2D, ReadBIN1D, ReadBIN2D_INT
    END INTERFACE

    INTERFACE WriteBIN
        MODULE PROCEDURE WriteBIN4D, WriteBIN3D, WriteBIN2D, WriteBIN1D
    END INTERFACE

 CONTAINS

! ====================================================================================== !
! ------------------------------- MITgcm Standard IO
! ====================================================================================== !
!
!
!
 SUBROUTINE ReadBIN4D(theFile, var, ioFlag )
 ! S/R ReadBIN4D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(out)  :: var(1:,1:,1:,1:)
   INTEGER, INTENT(out)     :: ioFlag
   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              recl=prec*fileLength )

     READ(UNIT=fUnit,rec=1, iostat=ioFlag) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE ReadBIN4D
!
!
!
 SUBROUTINE ReadBIN3D(theFile, var, ioFlag )
 ! S/R ReadBIN3D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(out)  :: var(1:,1:,1:)
   INTEGER, INTENT(out)     :: ioFlag
   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              recl=prec*fileLength )

     READ(UNIT=fUnit,rec=1, iostat=ioFlag) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE ReadBIN3D
!
!
!
 SUBROUTINE ReadBIN2D(theFile, var, ioFlag )
 ! S/R ReadBIN2D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(out)  :: var(1:,1:)
   INTEGER, INTENT(out)     :: ioFlag
   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              recl=prec*fileLength )

     READ(UNIT=fUnit,rec=1, iostat=ioFlag) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE ReadBIN2D
!
!
!
 SUBROUTINE ReadBIN1D(theFile, var, ioFlag )
 ! S/R ReadBIN1D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(out)  :: var(1:)
   INTEGER, INTENT(out)     :: ioFlag
   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              recl=prec*fileLength )

     READ(UNIT=fUnit,rec=1,iostat=ioFlag) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE ReadBIN1D
!
!
!
 SUBROUTINE ReadBIN2D_INT(theFile, var, ioFlag )
 ! S/R ReadBIN2D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   INTEGER, INTENT(out)     :: var(1:,1:)
   INTEGER, INTENT(out)     :: ioFlag
   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZEOF( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              recl=fileLength )

     READ(UNIT=fUnit,rec=1, iostat=ioFlag) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE ReadBIN2D_INT
!
!
!

 SUBROUTINE WriteBIN4D(theFile, var )
 ! S/R WriteBIN4D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(in)   :: var(1:,1:,1:,1:)

   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              status='replace',     &
                              recl=prec*fileLength )

     WRITE(UNIT=fUnit,rec=1) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE WriteBIN4D
!
!
!
 SUBROUTINE WriteBIN3D(theFile, var )
 ! S/R WriteBIN3D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(in)   :: var(1:,1:,1:)

   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              status='replace',     &
                              recl=prec*fileLength )

     WRITE(UNIT=fUnit,rec=1) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE WriteBIN3D
!
!
!
 SUBROUTINE WriteBIN2D(theFile, var )
 ! S/R ReadBIN2D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(in)   :: var(1:,1:)

   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              status='replace',     &
                              recl=prec*fileLength )

     WRITE(UNIT=fUnit,rec=1) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE WriteBIN2D
!
!
!
 SUBROUTINE WriteBIN1D(theFile, var )
 ! S/R ReadBIN1D
 !
 !=============================================================!
 ! Declarations
   IMPLICIT NONE
   CHARACTER(*), INTENT(in) :: theFile
   REAL(prec), INTENT(in)   :: var(1:)

   ! Local
   INTEGER :: fUnit, fileLength

     fileLength = SIZE( var )

     OPEN(UNIT=NewUnit(fUnit),FILE=trim(theFile),   &
                              form='unformatted',   &
                              access='direct',      &
                              CONVERT='big_endian', &
                              status='replace',     &
                              recl=prec*fileLength )

     WRITE(UNIT=fUnit,rec=1) var

     CLOSE(UNIT=fUnit)

 END SUBROUTINE WriteBIN1D
!
!
!
END MODULE BinaryIO

max_stars_repo_name: lanl/FEOTS

max_issues_repo_name: lanl/FEOTS

max_forks_repo_name: lanl/FEOTS


text:
C Copyright(C) 2009-2017 National Technology & Engineering Solutions of
C Sandia, LLC (NTESS).  Under the terms of Contract DE-NA0003525 with
C NTESS, the U.S. Government retains certain rights in this software.
C
C Redistribution and use in source and binary forms, with or without
C modification, are permitted provided that the following conditions are
C met:
C
C     * Redistributions of source code must retain the above copyright
C       notice, this list of conditions and the following disclaimer.
C
C     * Redistributions in binary form must reproduce the above
C       copyright notice, this list of conditions and the following
C       disclaimer in the documentation and/or other materials provided
C       with the distribution.
C     * Neither the name of NTESS nor the names of its
C       contributors may be used to endorse or promote products derived
C       from this software without specific prior written permission.
C
C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

C $Log: tpchk.f,v $
C Revision 1.3  2009/03/25 12:36:48  gdsjaar
C Add copyright and license notice to all files.
C Permission to assert copyright has been granted; blot is now open source, BSD
C
C Revision 1.2  2009/01/22 21:34:22  gdsjaar
C There were several inline dbnums common blocks. Replaced with the
C include so they all have the same size with the added variable types.
C
C Added minor support for nodeset and sideset variables.
C
C It can print the count and the names, but that is all
C at this time.
C
C Revision 1.1  1994/04/07 20:16:27  gdsjaar
C Initial checkin of ACCESS/graphics/blotII2
C
c Revision 1.2  1990/12/14  08:58:58  gdsjaar
c Added RCS Id and Log to all files
c
C=======================================================================
      SUBROUTINE TPCHK (PRTOK, OKAY)
C=======================================================================

C   --*** TPCHK *** (TPLOT) Check that TPLOT is a valid program to run
C   --   Written by Amy Gilkey - revised 11/03/87
C   --
C   --TPCHK checks that TPLOT is a valid program.  This is true if
C   --there are history, global, nodal or element variables in the database.
C   --
C   --If the program is valid, a welcome message is printed.
C   --
C   --Parameters:
C   --   PRTOK - IN - if true, print error messages and welcome messages,
C   --      if false, check but do not print anything
C   --   OKAY - OUT - true iff the program is valid
C   --
C   --Common Variables:
C   --   Uses NVARHI, NVARGL, NVARNP, NVAREL, NSTEPS, NSTEPW of /DBNUMS/

      include 'dbnums.blk'

      LOGICAL PRTOK
      LOGICAL OKAY

C   --Check header information from database

      IF ((NVARHI + NVARGL + NVARNP + NVAREL) .LE. 0) THEN
         IF (PRTOK) CALL PRTERR ('CMDERR',
     &      'No variables are defined')
         GOTO 100
      END IF
      IF ((NSTEPS .LE. 0) .OR.
     &   ((NSTEPW .LE. 0) .AND. (NVARHI .LE. 0))) THEN
         IF (PRTOK) CALL PRTERR ('CMDERR',
     &      'No time steps with variables are defined')
         GOTO 100
      END IF

C   --Write greeting message
      IF (PRTOK) WRITE (*, 10000)

      OKAY = .TRUE.
      RETURN

  100 CONTINUE
      OKAY = .FALSE.
      RETURN
10000  FORMAT (' TPLOT - a time history or X-Y plot program')
      END

max_stars_repo_name: mathstuf/seacas

max_stars_repo_licenses: BSD-3-Clause NetCDF Zlib MIT

max_issues_repo_name: mathstuf/seacas

max_issues_repo_licenses: BSD-3-Clause NetCDF Zlib MIT

max_forks_repo_name: mathstuf/seacas

max_forks_repo_licenses: BSD-3-Clause NetCDF Zlib MIT


text:
*DECK PRVEC
      FUNCTION PRVEC (M, U, V)
C***BEGIN PROLOGUE  PRVEC
C***SUBSIDIARY
C***PURPOSE  Subsidiary to BVSUP
C***LIBRARY   SLATEC
C***TYPE      SINGLE PRECISION (PRVEC-S, DPRVEC-D)
C***AUTHOR  Watts, H. A., (SNLA)
C***DESCRIPTION
C
C  This subroutine computes the inner product of a vector U
C  with the imaginary product or mate vector corresponding to V
C
C***SEE ALSO  BVSUP
C***ROUTINES CALLED  SDOT
C***REVISION HISTORY  (YYMMDD)
C   750601  DATE WRITTEN
C   891214  Prologue converted to Version 4.0 format.  (BAB)
C   900328  Added TYPE section.  (WRB)
C   910722  Updated AUTHOR section.  (ALS)
C***END PROLOGUE  PRVEC
C
      DIMENSION U(*),V(*)
C***FIRST EXECUTABLE STATEMENT  PRVEC
      N=M/2
      NP=N+1
      VP=SDOT(N,U(1),1,V(NP),1)
      PRVEC=SDOT(N,U(NP),1,V(1),1) - VP
      RETURN
      END


text:
************************************************************************
* This file contains routines to modify structure-7 matrices
************************************************************************

************************************************************************
* Transpose matrix structure
*
* This routine accepts the structure of a structure-7 or structure-9
* matrix and creates the structure of the transposed matrix from it.
*
* The resulting structure is not pivoted anymore with the diagonal
* entry in front if a structure-7 matrix is to be transposed!
*
* In:
*   NROW   : Number of rows in the matrix
*   NCOL   : Number of columns in the matrix
*   KCOL   : array [1..NA] of integer
*            Column structure of the matrix
*   KLD    : array [1..NROW+1] of integer
*            Row structure of the matrix
*   KTMP   : array [1..NCOL] of integer
*            Auxiliary array
*
* Out:
*   KCOLD  : array [1..NA] of integer
*            Will be filled with the column structure of the transposed
*            matrix. The array must have the same size as KCOL.
*   KLDD   : array [1..NCOL+1] of integer
*            Will be filled with the row structure of the transposed
*            matrix. The array must have the same size as KCOL.
************************************************************************

      SUBROUTINE TRST79 (NROW,NCOL,KCOL,KLD,KTMP,KCOLD,KLDD)

      IMPLICIT NONE

C     parameter

      INTEGER NCOL,NROW
      INTEGER KCOL(*),KLD(*),KCOLD(*),KLDD(*),KTMP(*)

C     local variables

      INTEGER NA,I,J,KP

C     size of the matrix?

      NA = KLD(NROW+1) - 1

C     At first determine the number of elements in each column.
C     For this purpose, build the KLDD array.
C
C     Count how many entries <> 0 are in each column. Note this
C     into the KLDD array.
C     This requires one loop through the matrix structure. The
C     corresponding number is written into KLDD, shifted by 1
C     (i.e. KLDD(2) is the number of entries of the 1st column).
C     This helps to create the real KLDD more easily later.

      CALL LCL3 (KLDD,NCOL+1)
      DO I = 1,NA
        KLDD(KCOL(I)+1) = KLDD(KCOL(I)+1) + 1
      END DO

C     Now build the real KLDD. this consists of indices, where
C     each row starts. Row 1 starts at position 1:

      KLDD (1) = 1

C     Adding the number of entries KLLD(i) in the row to
C     KLLD(i-1) gives the new row pointer of row i of the transposed
C     matrix.

      DO I = 2,NCOL+1
        KLDD(I) = KLDD(I) + KLDD(I-1)
      END DO

C     That's it for KLDD. Now, KCOLD must be created.
C     This requires another loop through the matrix structure.
C     KTMP receives the index how many entries have been written
C     to each column.

      CALL LCL3 (KTMP,NCOL)

      DO I = 1,NROW

        DO J = 1,KLD (I+1)-KLD(I)

C         Get the column of the item in question:

          KP = KCOL(KLD(I)+J-1)

C         Note the right column number in KCOLD:

          KCOLD (KLDD(KP)+KTMP(KP)) = I

C         Increment running index of that row

          KTMP (KP) = KTMP (KP) + 1

        END DO

      END DO

C     KCOLD also finished, that's it.

      END

************************************************************************
* Transpose matrix
*
* This routine accepts a matrix in structure-7 or structure-9 and
* builds the transposed matrix from it.
*
* The resulting matrix is not pivoted anymore with the diagonal
* entry in front if a structure-7 matrix is to be transposed!
*
* In:
*   NROW   : Number of rows in the matrix
*   NCOL   : Number of columns in the matrix
*   DA     : array [1..NA] of double
*            The matrix entries
*   KCOL   : array [1..NA] of integer
*            Column structure of the matrix
*   KLD    : array [1..NROW+1] of integer
*            Row structure of the matrix
*   KTMP   : array [1..NCOL] of integer
*            Auxiliary array
*
* Out:
*   DT     : array [1..NA] of double
*            The entries of the transposed matrix.
*   KCOLD  : array [1..NA] of integer
*            Will be filled with the column structure of the transposed
*            matrix. The array must have the same size as KCOL.
*   KLDD   : array [1..NCOL+1] of integer
*            Will be filled with the row structure of the transposed
*            matrix. The array must have the same size as KCOL.
************************************************************************

      SUBROUTINE TRM79 (NROW,NCOL,DA,KCOL,KLD,KTMP,DT,KCOLD,KLDD)

      IMPLICIT NONE

C     parameter

      INTEGER NCOL,NROW
      INTEGER KCOL(*),KLD(*),KCOLD(*),KLDD(*),KTMP(*)
      DOUBLE PRECISION DA(*),DT(*)

C     local variables

      INTEGER NA,I,J,KP

C     size of the matrix?

      NA = KLD(NROW+1) - 1

C     At first determine the number of elements in each column.
C     For this purpose, build the KLDD array.
C
C     Count how many entries <> 0 are in each column. Note this
C     into the KLDD array.
C     This requires one loop through the matrix structure. The
C     corresponding number is written into KLDD, shifted by 1
C     (i.e. KLDD(2) is the number of entries of the 1st column).
C     This helps to create the real KLDD more easily later.

      CALL LCL3 (KLDD,NCOL+1)
      DO I = 1,NA
        KLDD(KCOL(I)+1) = KLDD(KCOL(I)+1) + 1
      END DO

C     Now build the real KLDD. this consists of indices, where
C     each row starts. Row 1 starts at position 1:

      KLDD (1) = 1

C     Adding the number of entries KLLD(i) in the row to
C     KLLD(i-1) gives the new row pointer of row i of the transposed
C     matrix.

      DO I = 2,NCOL+1
        KLDD(I) = KLDD(I) + KLDD(I-1)
      END DO

C     That's it for KLDD. Now, KCOLD must be created.
C     This requires another loop through the matrix structure.
C     KTMP receives the index how many entries have been written
C     to each column.

      CALL LCL3 (KTMP,NCOL)

      DO I = 1,NROW

        DO J = 1,KLD (I+1)-KLD(I)

C         Get the column of the item in question:

          KP = KCOL(KLD(I)+J-1)

C         Note the right column nomber in KCOLD:

          KCOLD (KLDD(KP)+KTMP(KP)) = I

C         Copy the matrix entry:

          DT (KLDD(KP)+KTMP(KP)) = DA (KLD(I)+J-1)

C         Increment running index of that row

          KTMP (KP) = KTMP (KP) + 1

        END DO

      END DO

C     KCOLD and DT are also finished, that's it.

      END

************************************************************************
* Pivot matrix
*
* This routine repivots a matrix in structure 7: The diagonal element
* of each row is moved to the front.
*
* In:
*   NEQ    : Number of rows in the matrix
*   DA     : array [1..NA] of double
*            The matrix entries
*   KCOL   : array [1..NA] of integer
*            Column structure of the matrix
*   KLD    : array [1..NROW+1] of integer
*            Row structure of the matrix
*
* Out:
*   DA     : array [1..NA] of double
*            The matrix entries, pivoted
*   KCOL   : array [1..NA] of integer
*            Column structure of the matrix, pivoted
*   ERR    : Error indicator
*            =0: no error
*            =1: diagonal element not found
************************************************************************

      SUBROUTINE MT7PIV (NEQ,DA,KCOL,KLD)

      IMPLICIT NONE

C     parameters

      INTEGER NEQ,KCOL(*),KLD(*),ERR
      DOUBLE PRECISION DA(*)

C     local variables

      INTEGER I,J,K,KAUX
      DOUBLE PRECISION DAUX

      ERR = 0

C     Loop through the rows

      DO I=1,NEQ

C       Is the line already pivoted? Most unlikely, but we test for sure

        IF (KCOL(KLD(I)).NE.I) THEN

C         Find the position of the diagonal element

          DO J = KLD(I),KLD(I+1)-1
            IF (J.EQ.I) GOTO 10
          END DO

C         Oops, diagonal element not found - cancel

          ERR = 1
          RETURN

10        CONTINUE

C         Shift the line by 1. Put the diagonal element to the front.

          DAUX = DA(J)
          KAUX = KCOL(J)
          DO K = J-1,KLD(I),-1
            DA(K+1)   = DA(K)
            KCOL(K+1) = KCOL(K)
          END DO
          DA(KLD(I))   = DAUX
          KCOL(KLD(I)) = KAUX

        END IF

      END DO ! I

      END

max_stars_repo_licenses: Intel Unlicense

max_issues_repo_licenses: Intel Unlicense

max_forks_repo_licenses: Intel Unlicense


text:
This page contains one version of the Halema Buzayan incident. This is a summary of the version that was presented by Users/AnisSury.

Heres some details I know...

According to a Davis Police Department police report, two witnesses spot the Buzayans SUV moving near a sedan  they do not see contact between the two vehicles, but notice some damage to the car as the familys SUV pulls away. The witnesses leave a note for the sedans owner, Adrienne Wonhof. Adrienne gets in the car and drives home. After she arrived at her home, Adrienne reports to the police that she found a note from 2 witnesses informing her about a hitandrun involving her car. The note has the names of the witnesses and a phone number. Officer ly arrives at Adreinnes house takes the note examines the damage thats allegedly caused by the SUV and takes pictures of it.

Same night of the 7th of June, 2005

Officer Pheng Ly Ly reaches the witnesses, documents their report, and allegedly retrieves cell phone pictures for the perpetrators car. Officer Ly runs a check on the license plate and concludes that the Buzayans family to be the owner of the SUV.

Later that night

Officer Ly goes to Buzyans house to investigate the incident. The Buzayans confirmed the presence of their vehicle in Safeway parking lot around the time of the alleged hitandrun with Mrs Buzyan, Najat (Halemas mom), being the driver of the SUV. Najat, however, insists that she was not involved in any collision of any kind. Officer Ly insists that the witnesses saw Najat hit the car, and that he has pictures of her committing the hitandrun that was taken by one of the witnesses using their cell phone camera. Mr. Buzayan, Jamal (Halemas Father), decides to go along with officer lys story and ask him for his advise on how to get this issue resolved. Officer Ly hands Jamal Adriennes name, insurance info, and address and recommends that the Buzyans call her and have the issue settled with her. Jamal asks officer ly if he needs to get back with him once issue settled. Officer ly insists that there is no need for that and that all the Buzayans need to do is to pay for the damage. officer Ly leaves the Buzayans. Jamal uses the phone book to look up Adriennes number. Najat immediately places the call to Adrienne informing her of their willingness to pay for the damage thats done to her car.

8th of June, 2005

Jamal contacts insurance agent, reports the incident, and asks for advise. Agent gives Jamal the option to pay for the damage out of his own pocket instead of having the insurance company paying for it. Jamal chooses to pay out of pocket but still asks his agent to make the arrangement for that.

(Same day) Agent contacts Adrienne and asks for estimate.

9th of June, 2005

Agent receives estimate from Adrienne.

10th of June, 2005

Jamal pays Adrienne full estimate amount with a cashiers check

13th of June, 2005

Officer Ly shows up again at the Buzayans. To the Buzayans surprise officer Ly is there to arrest the alleged perpetrator even after Jamal explains to him that Adrienne was already compensated for the damages to her car. It was even more surprising and shocking to them that officer Ly is now positive that the perpetrator is Halema Buzayan and not Najat!!.   Users/AnisSury

General Comments should go on the Halema Buzayan page.


module aorsaNamelist

use constants

implicit none

    ! Notes
    ! -----
    ! Electrons must be the first species

    logical :: dampVacuumWave = .false.
    logical :: coldIons = .false.
    logical :: useMetalBox = .false.
    logical :: AntennaJ_R = .false.
    logical :: AntennaJ_T = .false.
    logical :: AntennaJ_Z = .true.
    logical :: useAntennaFromAR2Input = .true.
    logical :: useJpFromFile = .false.
    integer, parameter :: nSpecMax  = 5
    real :: tSpecIn(nSpecMax)       = (/ 400.0, 400.0, 0.0, 0.0, 0.0/) ! [ev]
    real :: dSpecIn(nSpecMax)       = (/ 0.6e18, 0.3e18, 0.0, 0.0, 0.0 /)
    real :: tLimIn(nSpecMax)        = (/ 400.0, 400.0, 0.0, 0.0, 0.0/) ! [ev]
    real :: dLimIn(nSpecmax)        = (/ 0.6e18, 0.3e18, 0.0, 0.0, 0.0 /)
    real :: dAlphaIn(nSpecMax)      = (/ 1.0, 1.0, 0.0, 0.0, 0.0 /) ! [ev]
    real :: dBetaIn(nSpecMax)       = (/ 1.0, 1.0, 0.0, 0.0, 0.0 /)
    real :: tAlphaIn(nSpecMax)      = (/ 1.0, 1.0, 0.0, 0.0, 0.0 /) ! [ev]
    real :: tBetaIn(nSpecMax)       = (/ 1.0, 1.0, 0.0, 0.0, 0.0 /)
    logical :: useFluxProfiles = .false.
    logical :: useSoloviev = .false.
    logical :: useCircular = .false.
    logical :: useCircularProfiles = .false.
    logical :: parabolic = .false.
    logical :: toroidalBroadening = .true.
    real(kind=dbl) :: kPrlEffLimit = 1d-08
    real :: fracOfModesInSolution = 0.66
    integer :: nSpec = 2
    real :: r0 = 1.0
    real :: a = 1.0
    real :: psiExp = 0.5 ! exponential scale for soloviev poloidal field
    real :: bx_frac = 0.0
    real :: by_frac = 0.0
    real :: bPol_frac = 0.0
    logical :: square = .false.
    real :: rhoScale = 0.2
    real :: rhoWidth = 0.2
    real :: rhoPower = 3.0
    real :: lsWeightFac = 1.0 ! Least squares boundary weighting value O(10^3)
    logical :: chebyshevX = .false.
    logical :: chebyshevY = .false.
    logical :: cosX = .false.
    logical :: cosY = .true.
    logical :: magma = .false.
    real :: rhoAnt = 0.97
    real :: antSigRho = 0.1
    integer :: overlap = 1

    integer, parameter :: nGridMax = 10
    integer :: nGrid = 1
    integer(kind=long), dimension(nGridMax) :: nRAll = 16
    integer(kind=long), dimension(nGridMax) :: nZAll = 32
    real, dimension(nGridMax) :: rMinAll = 1.0
    real, dimension(nGridMax) :: rMaxAll = 2.0
    real, dimension(nGridMax) :: zMinAll = -1.0
    real, dimension(nGridMax) :: zMaxAll =  1.0

    real :: kz_1D = 0

!     --------------------------------------------------------
!     Declarations and defaults for aorsa2d.in input variables
!     --------------------------------------------------------

      CHARACTER*128 :: eqdsk = 'g1080408021.txt'               ! eqdsk name
      logical :: useEqdsk = .false.
      logical :: useAr2Input = .false.
      logical :: useAR2SourceLocationsFile = .false.
      logical :: useAllRHSsSource = .true.
      logical :: ZeroJp = .false.
      real :: ZeroJp_rMin = 0.0
      real :: ZeroJp_rMax = 100.0
      real :: ZeroJp_zMin = -100.0
      real :: ZeroJp_zMax = 100.00
      character(len=100) :: zFunctionFileName = 'input/zFunction.nc'
      character(len=100) :: AR2InputFileName = 'ar2Input.nc'
      character(len=100) :: JpInputFileName = 'jp.nc'
      character(len=100) :: AR2SourceLocationsFileName = 'AR2SourceLocations.nc'
      CHARACTER*128 :: netCDF_file1 = 'phillips_nstx3.5.2.nc'  !cql3d distribution file name 1
      CHARACTER*128 :: netCDF_file2 = 'phillips_nstx3.5.2.nc'  !cql3d distribution file name 2

      integer :: nstrap = 4              ! number of current straps in antenna
      real :: xlt = 20.0E-02          ! width of current strap (m)
      real :: wd = 50.0E-02           ! separation between centers of antenna elements
      real :: phase_deg = -90.0       ! relative phase between elements

      real :: enorm_factor = 0.0      ! if (enorm_factor .eq. 0.0) AORSA & CQL3D use same enorm (default)
                                      ! if (enorm_factor .gt. 0.0) AORSA enorm = enorm_factor x the maximum energy
      real :: enorm_factor_e = -1
      real :: enorm_factor_i1 = -1
      real :: enorm_factor_i2 = -1
      real :: enorm_factor_i3 = -1
      real :: enorm_factor_i4 = -1
      real :: enorm_factor_i5 = -1
      real :: enorm_factor_i6 = -1

      logical :: write_f_file = .false.
      logical :: particleDensity = .true.
      logical :: ana_maxwellian = .false.

      real :: xkx_cutOff = 0.5
      real :: xky_cutOff = 0.5
      real :: xkperp_cutoff = 0.75    ! fraction of xkperp above which the electron conductivity (sig3)
                                      !  is enhanced to short out noise in E_parallel (default = 0.75)

      real :: damping = 0.0           !  enhancement factor (default = 0.0) for the electron conductivity (sig3)
                                      !  applied above the fractional value of xkperp (xkperp_cutoff) to
                                      !  short out noise in E_parallel

      real :: taue = 50.0e-03         ! energy diffusion time used in flow drive calculation
      real :: theta_ant = 0.0
      real :: eslowev = 3.5e+06
      real :: amu_slo = 4.0
      real :: z_slo = 2.0
      real :: eta_slo = 0.0
      !real :: xnuomg = 0.0             !-----xnuomg is the collison rate used in hot and cold plasma dielectrics
      !real :: xnuOmgOutside = 0.0
      real :: xnuead = 0.0000E+00      !-----xnuead = ad hoc collision frequency for electron in sec-1
      real :: xnu1ad = 0.0000E+00      !-----nu1ad=ad hoc collision frequency for majority ions in sec-1
      real :: xnu2ad = 0.0000E+00      !-----nu2ad=ad hoc collision frequency for minority ions in sec-1

      real :: rAnt = 0.0               !-----rant = major radius of antenna in meters (default is 0.0 in which case, psiant = .95)
      real :: zAnt = 0.0               !-----zAnt = location of antenna center in Z (m)
      real :: antSigX = 0.1
      real :: antSigY = 0.3
      real :: antSigUnit = 0.1

      real :: dthetant0 = 40.
      real :: dpsiant0 = .05
      real :: antlen = 1.0
      real :: antlc = .0001            !-----antlc = propagation constant along the antenna = c / vphase
      logical :: limiter_boundary = .false. ! use the rLim/zLim boundary from the eqdsk file
      logical :: lcfs_boundary = .false.
      logical :: use_dlg_bField = .false.
      real :: edgeCollisions = 0.0
      logical :: bbbsMask = .false. ! use rbbbs/zbbbs as boundary instead of rlim/zlim
      logical :: domainMask = .false. ! use rbbbs/zbbbs as boundary instead of rlim/zlim
      real :: gradient = -50.0e16
      logical :: dlgAnt = .false. ! use the dlgAnt.nc file for the antenna geometry
      character(len=100) :: dlgAntFileName = 'dlgAnt.nc'
      character(len=100) :: dlgProfileFileName = 'dlg_profiles.nc'
      logical :: antGridMatch = .false.
      real :: psilim = .99
      real :: psimask = 1.05
      real :: psiant = 0.95
      real :: psimol = 1.00            !-----psimol: if (psimol .eq. 1.0) molifier is NOT used for plasma profiles (default)
                                       !-----        if (psimol .ne. 1.0) molifier is used for profiles, centered at psimol
      real :: psipne = 0.50
      real :: psipte = .30
      real :: psipti1 = .30
      real :: psipti2 = .30
      real :: psipti3 = .30
      real :: psipti4 = .30
      real :: psipti5 = .30
      real :: psipti6 = .30
      real :: te0  = 4.2900E+03        !-----te0=central value of eletron temperature in eV
      real :: ti01  = 7.0700E+03        !-----ti0=central value of ion temperature in eV
      real :: ti02 = 7.0700E+03
      real :: ti03 = 7.0700E+03
      real :: ti04 = 7.0700E+03
      real :: ti05 = 7.0700E+03
      real :: ti06 = 7.0700E+03
      real :: epszet = 1.0000E-07      !-----epszet=error criterion for Z function calculation if disp is used
      real :: delta0 = 0.0000E+00      !-----delta0=numerical damping for Bernstein wave:  about 1.e-04 (dimensionless)
      real :: xwall = 0.0000E+00       !-----xwall = not used
      real :: xnwall = 0.0000E+00      !-----xnwall = density of metal put on last mesh point
      integer :: amu1 = 2        !-----amu1= ratio of majority ion to hydrogen ion mass
      integer :: amu2 = 1        !-----amu2= ratio of minority ion to hydrogen ion mass
      integer :: z1 = 1          !-----z1=ratio of majority ion charge to hydrogen ion charge
      integer :: z2 = 1          !-----z2=ratio of minority ion charge to hydrogen ion charge
      real :: eta = 0.0                !-----eta=ratio of minority ion density to electron density
      real :: b0 = 2.08                !-----b0=value of magnetic field at x=0 in Tesla
      real :: q0 = 1.0                 !-----q0=value of inverse rotational transform on axis
      real :: rt = 1.68                !-----rt= major radius of torus
      real :: ekappa = 2.0             !-----ekappa = elongation
      real :: rwleft  = 0.0            !-----rwleft = major radius of the left conducting wall
      real :: rwright = 0.0            !-----rwright = major radius of the right conducting wall
      real :: ytop    = 0.0            !-----ytop = location of the upper conducting wall
      real :: ybot = 0.0            !-----ybottom = location of the lower conducting wall
      real :: metalRight = 10.0
      real :: metalLeft = 0.0
      real :: metalTop = 10.0
      real :: metalBot = -10.0

      real :: xLeft_ = 1.0
      real :: xRight_ = 2.0
      real :: freqcy = 3.2000E+07      !-----freqcy= rf frequency in Hertz
      real :: aplasm = 7.0000E-01      !-----aplasm = not used
      real :: alim = 100.0             !-----alim = location of limiter
      real :: grad = 0.0               !-----grad = 0.0 ignors gradients in Wdot (default)
                                       !-----grad = 1.0 includes gradients in Wdot
      logical :: eqdsk_zRange = .false.        ! 0 = auto, 1 = max
      logical :: eqdsk_rRange = .false.        ! 0 = auto, 1 = max

      real :: signbz = 1.0000E+00
      real :: xn0 = 3.1100E+19         !-----xn0=electron density at x=0
      real :: xn1 = 0.0
      real :: xn2 = 0.0
      real :: xn3 = 0.0
      real :: xn4 = 0.0
      real :: xn5 = 0.0
      real :: xn6 = 0.0
      real :: xnslo = 0.0
      real :: flat = 0.0000E+00         !-----flat = not used
      real :: b1rat = 7.0000E-01        !-----b1rat = not used
      real :: b2rat = 1.3000E+00        !-----b2rat = not used
      real :: curdnx = 0.0000E+00       !-----curdnx=Amps/meter of toroidal length of antenna in the x direction
      real :: curdny = 1.0              !-----curdny=Amps/meter of toroidal length of antenna in the y direction
      real :: curdnz = 0.0000E+00       !-----curdnz=Amps/meter of toroidal length of antenna in the z direction
      real :: prfin = 0.0               !-----prfin = total applied RF power
      real :: xnuabs = 0.0000E+00       !-----xnuabs not used
      real :: xbnch = 0.0000E+00        !-----xbnch not used
      real :: xleft = -7.000E-01        !-----xleft=left boundary for energy integrals and outgoing energy flux
      real :: xright = 7.0000E-01       !-----xright=right boundary for energy integrals and incoming energy flux
      real :: qavg0 = 1.0               !-----qavg0 is the rotational transform on axis
      real :: xnlim  = 0.0              !-----xnlim=electron density in scrape-off region (x>aplasm)
      real :: xn2lim = 0.0
      real :: xn3lim = 0.0
      real :: xn4lim = 0.0
      real :: xn5lim = 0.0
      real :: xn6lim = 0.0

      ! if limiter_boundary=.true.
      real :: xn_rho2lim  = 1.0e-10              !-----xn_rho2lim=electron density outside lcfs up to the limiter
      real :: xn2_rho2lim = 1.0e-10
      real :: xn3_rho2lim = 1.0e-10
      real :: xn4_rho2lim = 1.0e-10
      real :: xn5_rho2lim = 1.0e-10
      real :: xn6_rho2lim = 1.0e-10

      real :: xnslolim = 0.0
      real :: telim  = 0.0000E+00       !-----telim = electron temperature in scrape-off region (x>aplasm)
      real :: tilim  = 0.0000E+00       !-----tilim = ion temperature in scrape-off region (x>aplasm)
      real :: ti2lim = 0.0000E+00
      real :: ti3lim = 0.0000E+00
      real :: ti4lim  = 0.0000E+00
      real :: ti5lim = 0.0000E+00
      real :: ti6lim = 0.0000E+00

      ! if limiter_boundary=.true.
      real :: te_rho2lim  = 10E+00       !-----te_rho2lim = electron temperature from lcfs to limiter
      real :: ti_rho2lim  = 10E+00       !-----ti_rho2lim = ion temperature from lcfs to limiter
      real :: ti2_rho2lim = 10E+00
      real :: ti3_rho2lim = 10E+00
      real :: ti4_rho2lim  = 10E+00
      real :: ti5_rho2lim = 10E+00
      real :: ti6_rho2lim = 10E+00

      real :: dfreq = 0.0000E+00        !-----dfreq not used
      real :: xnudip = 2.5000E+00       !-----xnudip is not used
      real :: adip = 0.0000E+00         !-----adip is not used
      real :: efold = 0.0000E+00        !-----efold is not used
      real :: amu3 = 12.0               !-----amu3=ratio of third ion mass to hydrogen ion mass
      real :: z3 = 6.0                  !-----z3=ratio of third ion charge to hydrogen ion charge
      real :: eta3 = 0.0                !-----eta3=ratio of third ion density to electron density
      real :: xnu3ad = 0.0              !-----xnu3ad not used
      real :: amu4 = 12.0               !-----amu4=ratio of 4th ion mass to hydrogen ion mass
      real :: z4 = 6.0                  !-----z4=ratio of 4th ion charge to hydrogen ion charge
      real :: eta4 = 0.0                !-----eta4=ratio of 4th ion density to electron density
      real :: xnu4ad = 0.0              !-----xnu4ad not used
      real :: amu5 = 12.0               !-----amu5=ratio of 5th ion mass to hydrogen ion mass
      real :: z5 = 6.0                  !-----z5=ratio of 5th ion charge to hydrogen ion charge
      real :: eta5 = 0.0                !-----eta5=ratio of 5th ion density to electron density
      real :: xnu5ad = 0.0              !-----xnu5ad not used
      real :: amu6 = 12.0               !-----amu6=ratio of 6th ion mass to hydrogen ion mass
      real :: z6 = 6.0                  !-----z6=ratio of 6th ion charge to hydrogen ion charge
      real :: eta6 = 0.0                !-----eta6=ratio of 6th ion density to electron density
      real :: xnu6ad = 0.0              !-----xnu6ad not used
      real :: xdelta = 5.5000E-01       !-----xdelta not used
      real :: wdelta = 0.0000E+00       !-----wdelta not used
      real :: xdelt2 = -7.000E-02       !-----xdelt2 not used
      real :: wdelt2 = 0.0000E+00       !-----wdelt2 not used
      real :: zeffcd = 2.5000E+00       !-----zeffcd=Zeff for Ehst-Karney current drive calculation
      real :: rzoom1 = 0.0              !-----rzoom1 = R on left side of wdot calculation
      real :: rzoom2 = 0.0              !-----rzoom2 = R on right side of wdot calculation
      real :: yzoom1 = 0.0              !-----yzoom1 = Y on bottom of wdot calculation
      real :: yzoom2 = 0.0              !-----yzoom2 = Y on top of wdot calculation
      real :: alphan = 1.0
      real :: alphan2 = 1.0
      real :: alphan3 = 1.0
      real :: alphan4 = 1.0
      real :: alphan5 = 1.0
      real :: alphan6 = 1.0
      real :: alphan_slo = 1.0
      real :: alphate = 1.0
      real :: alphati = 1.0
      real :: alphati2 = 1.0
      real :: alphati3 = 1.0
      real :: alphati4 = 1.0
      real :: alphati5 = 1.0
      real :: alphati6 = 1.0
      real :: betan = 2.0
      real :: betan2 = 2.0
      real :: betan3 = 2.0
      real :: betan4 = 2.0
      real :: betan5 = 2.0
      real :: betan6 = 2.0
      real :: betan_slo = 2.0
      real :: betate = 2.0
      real :: betati = 2.0
      real :: betati2 = 2.0
      real :: betati3 = 2.0
      real :: betati4 = 2.0
      real :: betati5 = 2.0
      real :: betati6 = 2.0

      integer :: version_number = 15      !-----version_number: version of AORSA (default = 15)
      integer :: n_prof_flux = 0          !-----n_prof_flux = flag determining whether profiles are wrt toroidal or poloidal flux
                                          !           if(n_prof_flux .eq. 0) profiles are wrt sqrt(poloidal) flux (default)
                                          !           if(n_prof_flux .ne. 0) profiles are wrt sqrt(toroidal) flux

      integer :: upshift = 1              !-----upshift: if (upshift .ne.  0) upshift is turned on (default)
                                          !-----if (upshift .eq. -1) upshift is turned off for xkperp > xkperp_cutoff
                                          !-----if (upshift .eq.  0) upshift is turned off always

      logical :: nPhi_sum_only = .false.  !-----if (nphi_sum_only .eq. .true.) skip aorsa and just sum the modes for nphi_number > 1
      integer :: i_write = 0              !-----i_write: if (i_write .eq. 0) 4-D ORBIT_RF file is NOT written (default)
                                          !-----         if (i_write .ne. 0) 4-D ORBIT_RF file IS written

      integer :: n_bin = 2
      integer :: iql = 1
      integer :: i_antenna = 1            ! i_antenna = flag determining which antenna model is used
                                          ! if(i_antenna .eq. 0) antenna current is Gaussian
                                          ! if(i_antenna .eq. 1) antenna current is cos(ky * y)  (default)
                                          ! where ky = omgrf / vphase = (omgrf / clight) * antlc = k0 * antlc
                                          ! For constant current, set antlc = 0.0
      integer :: nuper = 65
      integer :: nupar = 129
      integer :: nkperp = 201             !-----nkperp: number of kperp values used in Lee's interpolation version of the
                                          !     non-Maxwellian sigma (default = 201: interpolates on 201 points)
                                          !     if (nkperp .eq. 0) there is no interpolation

      integer :: nzeta_wdot = 51          !-----nzeta_wdot:  if (nzeta_wdot .eq. 0) no wdot calculation
                                          !-----             if (nzeta_wdot .eq. 1) wdot is calculated without interpolation
                                          !-----             if (nzeta_wdot .ge. 2) wdot is calculated with interpolation
                                          !-----                 over nzeta_wdot grid points (default is 51)
      integer :: i_sav = 0
      integer :: j_sav = 0
      integer :: i_sav1 = 0
      integer :: j_sav1 = 0
      integer :: i_sav2 = 0
      integer :: j_sav2 = 0
      integer :: isolve = 1               !-----isolve = flag determining whether wave solution is calculated or not
                                          !     if(isolve .ne. 0) wave solution is calculated (default)
                                          !     if(isolve .eq. 0) wave solutions is read from file='fields_fourier'

      integer :: ftrap = 1                !-----ftrap = integer flag determining whether trapped particles effect current drive
                                          !        if(ftrap.eq.0) no trapped particles
                                          !        if(ftrap.ne.0) include trapped particles (default)

      integer :: nnode_local = 0          !-----nnode_local = number of local Fourier modes used to calculate local Wdot
                                          !-----      if (nnode_local .le. 0)Wdot is NOT calculated (default)
                                          !-----      if (nnode_local .gt. 0)Wdot is calculated

      integer :: nnode_overlap = 0        !-----nnode_overlap is the number of overlapped points
      integer :: iprofile = 3             !-----iprofile:  if (iprofile .eq. 1) generic profiles (Gaussian)
                                          !-----           if (iprofile .eq. 2) generic profiles (parabolas)
                                          !-----           if (iprofile .eq. 3) fits of form (1 - rho**beta)**alpha (default)
                                          !-----           if (iprofile .eq. 5) numerical profiles from namelist
      integer :: nboundary = 1            !-----nboundary: if(nboundary .eq. 1) flux surface boundary (default)
                                          !-----           if(nboundary .eq. 0) square boundary
                                          !-----           if(nboundary .eq. 2) bbbs boundary from eqdsk

      integer :: npRow = 8
      integer :: npCol = 8

      integer :: nwdot = 0                !-----nwdot=number of radial modes used in wdot and flow (fy) calculation

      integer :: lmax = 5                 !-----lmax = highest order Bessel function kept in plasma conductivity
      integer :: ibessel = 1              !-----ibessel = flag determining which Bessel functions are used in Wdot
                                          !        if(ibessel.eq.0) Complex Bessel functions are used from besic
                                          !        if(ibessel.eq.1) Real Bessel functions used from ribesl (default)
                                          !        if(ibessel.eq.2) 2nd order expanded Bessel functions are used in Wdot only
      integer :: inu = 0                  !-----inu:   if(inu.eq.0)real collisions are left out

      integer :: iprint = 1               !-----iprint:  if (iprint .eq. 28) print fields_local
                                          !-----         if (iprint .eq. 1) don't print fields_local (default)

      integer :: iexact = 1               !-----iexact:  not used
      integer :: iroot = 2                !-----iroot: not used
      integer :: iequat = 1
      integer :: igeom = 5                !-----igeom: if(igeom.eq.2)Solovev flux surfaces
                                          !-----       if(igeom.eq.5)EQDSK (GA) flux surfaces (default)
      integer :: iqx = 4                  !-----iqx:  not used

      integer :: iqprof = 1               !-----iqprof: if(iqprof.eq.1) q proportional to density (default)
                                          !-----        if(iqprof.eq.2) q proportional to sqrt(density) for TAE runs
      integer :: iez = 0                  !-----iez:  not used
      integer :: nstep  = 16              !-----nstep: not used
      integer :: nabs = 2                 !-----nabs not used
      integer :: isigma = 1               !-----if(isigma.eq.0) cold plasma conductivity is used.
                                          !-----if(isigma.eq.1) hot  plasma conductivity is used (default)
      integer :: nzfun = 1                !-----nzfun:  if(nzfun.eq.0) Simple Z function is used from ZFUN
                                          !-----        if(nzfun.eq.1) Generalized Z function of Brambilla is used (default)
                                          !-----        if(nzfun.eq.2) Z function of Smithe is used by doing numerical integrals.
                                          !-----        if(nzfun.eq.3) Z function table lookup of Smithe is used

      integer :: iabsorb = 2              !-----iabsorb not used
      integer :: itemp = 0                !-----itemp not used
      integer :: nfreqm = 1               !-----nfreqm not used
      integer :: idens = 0                !-----idens not used
      integer :: ibackground = 1          !-----ibackground is not used
      integer :: idiag = 5
      integer :: jdiag = 4
      integer :: ndiste = 0               !-----ndist:  if (ndist .eq. 0) Maxwellian is used in sigmad_stix
                                          !-----        if (ndist .eq. 1) non-Maxwellian is used in sigmad_stix
      integer :: ndisti1 = 0
      integer :: ndisti2 = 0
      integer :: ndisti3 = 0
      integer :: ndisti4 = 0
      integer :: ndisti5 = 0
      integer :: ndisti6 = 0

      integer :: izfunc
      integer :: nnodecx                  !-----nnodecx = number of radial mesh points used for wdot calculation
      integer :: nnodecy                  !-----nnodecy = number of vertical mesh points used for wdot calculation

      real :: nphi = 0.0          !-----toroidal mode number

      real phase, zmin, zmax, phi0, amplt(20)

      namelist/aorsa2din/ nwdot, lmax, ibessel, &
     &    ti01, xnuead, xnu1ad, xnu2ad, rant, te0, zAnt,  &
     &    antSigX, antSigY, antSigUnit, &
     &    ti02, ti03, ti2lim, ti3lim, nuper, nupar, &
     &    ti04, ti05, ti06, ti4lim, ti5lim, ti6lim,  &
     &    inu, iprint, iexact, delta0, xwall, xnwall,  &
     &    iroot, iequat, igeom, epszet,  &
     &    dthetant0, dpsiant0, psilim, psiant, psimol, psipne, psipte,  &
     &    psipti1, psipti2, psipti3,  &
     &    psipti4, psipti5, psipti6,  &
     &    iqx, iqprof, iez, npRow, npCol, &
     &    amu1, amu2, z1, z2, eta, izfunc,  &
     &    b0, r0, bx_frac, by_frac, rt, ytop, ybot, freqcy, aplasm,  &
     &    xnlim, xn2lim, xn3lim, xnslolim, signbz,  &
     &    xn4lim, xn5lim, xn6lim,  &
     &    xn0, xn1, xn2, xn3, xnslo, flat, b1rat, b2rat, curdnx, curdny,  &
     &    xn4, xn5, xn6, curdnz,  &
     &    nstep, nabs, xnuabs, xbnch, xleft, xright,  &
     &    isigma, itemp, telim, tilim,  &
     &    nfreqm, dfreq, &
     &    idens, xnudip, adip, efold,  &
     &    amu3, z3, eta3, xnu3ad,  &
     &    amu4, z4, eta4, xnu4ad,  &
     &    amu5, z5, eta5, xnu5ad,  &
     &    amu6, z6, eta6, xnu6ad,  &
     &    xdelta, wdelta, xdelt2, wdelt2, zeffcd, &
     &    rzoom1, rzoom2, yzoom1, yzoom2, ibackground, iabsorb, q0,  &
     &    prfin, nzfun, alim, grad, qavg0, nnodecx, nnodecy, &
     &    alphan,  alphan2, alphan3, alphan_slo,  &
     &    alphan4, alphan5, alphan6,  &
     &    alphate,  alphati, alphati2, alphati3,  &
     &    alphati4, alphati5, alphati6,  &
     &    ekappa, rwleft, rwright, & !xnuomg, xNuOmgOutside, &
     &    nboundary, eta_slo, amu_slo, z_slo, eslowev, nnode_local,  &
     &    nnode_overlap, iprofile, ftrap, isolve, &
     &    betan, betan2, betan3, betan_slo, betate, betati, betati2,  &
     &    betan4, betan5, betan6, betati4, betati5, betati6,  &
     &    betati3, taue, theta_ant,  &
     &    ndiste, ndisti1, ndisti2, ndisti3,  &
     &    ndisti4, ndisti5, ndisti6, nkperp, nzeta_wdot, n_bin, antlen,  &
     &    eqdsk, useEqdsk, iql, i_antenna, antlc, n_prof_flux, netcdf_file1,  &
     &    netcdf_file2, upshift, xkperp_cutoff, damping, i_write,  &
     &    nstrap, xlt, wd, phase_deg, nphi, &
     &    enorm_factor, version_number, enorm_factor_e, &
     &    enorm_factor_i1, enorm_factor_i2, enorm_factor_i3, &
     &    enorm_factor_i4, enorm_factor_i5, enorm_factor_i6, &
     &    write_f_file, particleDensity, ana_maxwellian, &
     &    limiter_boundary, lcfs_boundary, xn_rho2lim, xn2_rho2lim, &
     &    xn3_rho2lim, xn4_rho2lim, xn5_rho2lim, xn6_rho2lim, &
     &    te_rho2lim, ti_rho2lim, ti2_rho2lim, ti3_rho2lim, &
     &    ti4_rho2lim, ti5_rho2lim, ti6_rho2lim, eqdsk_zRange, &
     &    gradient, bbbsMask, dlgAnt, eqdsk_rRange, &
     &    dlgAntFileName, dlgProfileFileName, antGridMatch, domainMask, &
     &    use_dlg_bField, edgeCollisions, nSpec, &
     &    tSpecIn, dSpecIn, tLimIn, dLimIn, &
     &    tAlphaIn, tBetaIn, dAlphaIn, dBetaIn, useFluxProfiles, square, &
     &    metalLeft, metalRight, metalTop, metalBot, useSoloviev, a, psiExp, &
     &    rhoScale, rhoWidth, rhoPower, useCircular, &
     &    bPol_frac, useCircularProfiles, lsWeightFac, xkx_cutOff, xky_cutOff, &
     &    chebyshevX, chebyshevY, magma, rhoAnt, antSigRho, toroidalBroadening,&
     &    kPrlEffLimit, nGrid, useAr2Input, AR2InputFileName, zFunctionFileName, &
     &    nRAll, nZAll, rMinAll, rMaxAll, zMinAll, zMaxAll, &
     &    overlap, parabolic, cosX, cosY, kz_1D, fracOfModesInSolution, &
     &    AntennaJ_R, AntennaJ_T, AntennaJ_Z, AR2SourceLocationsFileName, &
     &    useAR2SourceLocationsFile, useAllRHSsSource, ZeroJp, &
     &    ZeroJp_rMin, ZeroJp_rMax, ZeroJp_zMin, ZeroJp_zMax, useAntennaFromAR2Input, &
     &    useMetalBox, useJpFromFile, JpInputFileName, coldIons, dampVacuumWave

contains

    subroutine read_namelist ( fileName )

        implicit none
        character(len=100) :: nml_fileName
        character(len=*), intent(in), optional :: fileName

        if(present(fileName)) then
            nml_fileName = fileName
        else
            nml_fileName    = 'aorsa2d.in'
        endif

        open ( unit = 63, file = nml_fileName )
        read ( unit = 63, nml = aorsa2din )
        close ( 63 )

    end subroutine read_namelist

end module aorsaNamelist