From 134847fbccb703a0fce4b2e0b94cd23ebfa657f9 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 7 Nov 2011 09:57:06 -0500 Subject: [PATCH 1/3] Replaced a few instances of msg with message. --- src/main.f90 | 3 +-- src/source.f90 | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.f90 b/src/main.f90 index d60083f862..2dfdcce773 100644 --- a/src/main.f90 +++ b/src/main.f90 @@ -54,7 +54,6 @@ contains integer :: i_cycle ! cycle index integer(8) :: i_particle ! history index - character(MAX_LINE_LEN) :: msg ! output/error message type(Particle), pointer :: p => null() if (master) call header("BEGIN SIMULATION", 1) @@ -69,7 +68,7 @@ contains ! Start timer for computation call timer_start(time_compute) - msg = "Simulating cycle " // trim(int_to_str(i_cycle)) // "..." + message = "Simulating cycle " // trim(int_to_str(i_cycle)) // "..." call write_message(8) ! Set all tallies to zero diff --git a/src/source.f90 b/src/source.f90 index c448da0a1b..1da0ea2e68 100644 --- a/src/source.f90 +++ b/src/source.f90 @@ -30,9 +30,8 @@ contains real(8) :: E ! outgoing energy real(8) :: p_min(3) ! minimum coordinates of source real(8) :: p_max(3) ! maximum coordinates of source - character(MAX_LINE_LEN) :: msg ! error message - msg = 'Initializing source particles...' + message = "Initializing source particles..." call write_message(6) ! Determine maximum amount of particles to simulate on each processor From e5e9c495299ba92f547d56505e5f581f70fbe2df Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 7 Nov 2011 10:41:18 -0500 Subject: [PATCH 2/3] Changed read_data calls to intrinsic READs. --- src/cross_section.f90 | 38 ++++++++----------------- src/fileio.f90 | 64 ------------------------------------------- 2 files changed, 12 insertions(+), 90 deletions(-) diff --git a/src/cross_section.f90 b/src/cross_section.f90 index 885b5c9bac..e5920e1e10 100644 --- a/src/cross_section.f90 +++ b/src/cross_section.f90 @@ -7,7 +7,7 @@ module cross_section use datatypes_header, only: DictionaryCI use endf, only: reaction_name use error, only: fatal_error - use fileio, only: read_line, read_data, skip_lines + use fileio, only: read_line, skip_lines use global use material_header, only: Material use output, only: write_message @@ -180,7 +180,6 @@ contains integer :: in = 7 ! unit to read from integer :: ioError ! error status for file access - integer :: words_per_line ! number of words per line (data) integer :: lines ! number of lines (data integer :: n ! number of data values real(8) :: kT ! ACE table temperature @@ -251,29 +250,23 @@ contains ! Skip 5 lines call skip_lines(in, 5, ioError) - ! Read NXS data - lines = 2 - words_per_line = 8 - call read_data(in, NXS, 16, lines, words_per_line) - - ! Set ZAID of nuclide - nuc % zaid = NXS(2) - - ! Read JXS data - lines = 4 - call read_data(in, JXS, 32, lines, words_per_line) + ! Read NXS and JXS data + read(UNIT=in, FMT=*) NXS + read(UNIT=in, FMT=*) JXS ! Calculate how many data points and lines in the XSS array n = NXS(1) lines = (n + 3)/4 if (found_xs) then + ! Set ZAID of nuclide + nuc % zaid = NXS(2) + ! allocate storage for XSS array allocate(XSS(n)) ! Read XSS - words_per_line = 4 - call read_data(in, XSS, n, lines, words_per_line) + read(UNIT=in, FMT=*) XSS else call skip_lines(in, lines, ioError) end if @@ -1077,7 +1070,6 @@ contains integer :: in = 7 ! unit to read from integer :: ioError ! error status for file access - integer :: words_per_line ! number of words per line (data) integer :: lines ! number of lines (data integer :: n ! number of data values real(8) :: kT ! ACE table temperature @@ -1148,14 +1140,9 @@ contains call skip_lines(in, 5, ioError) end if - ! Read NXS data - lines = 2 - words_per_line = 8 - call read_data(in, NXS, 16, lines, words_per_line) - - ! Read JXS data - lines = 4 - call read_data(in, JXS, 32, lines, words_per_line) + ! Read NXS and JXS data + read(UNIT=in, FMT=*) NXS + read(UNIT=in, FMT=*) JXS ! Calculate how many data points and lines in the XSS array n = NXS(1) @@ -1166,8 +1153,7 @@ contains allocate(XSS(n)) ! Read XSS - words_per_line = 4 - call read_data(in, XSS, n, lines, words_per_line) + read(UNIT=in, FMT=*) XSS else call skip_lines(in, lines, ioError) end if diff --git a/src/fileio.f90 b/src/fileio.f90 index 96a7f83c8b..758634a600 100644 --- a/src/fileio.f90 +++ b/src/fileio.f90 @@ -6,16 +6,6 @@ module fileio implicit none -!=============================================================================== -! READ_DATA interface allows data to be read with one function regardless of -! whether it is integer or real data. E.g. NXS and JXS can be read with the -! integer version and XSS can be read with the real version -!=============================================================================== - - interface read_data - module procedure read_data_int, read_data_real - end interface - contains !=============================================================================== @@ -98,58 +88,4 @@ contains end subroutine skip_lines -!=============================================================================== -! READ_DATA_INT reads integer data into an array from a file open -!=============================================================================== - - subroutine read_data_int(unit, array, n, lines, words_per_line) - - integer, intent(in) :: unit ! unit to read from - integer, intent(in) :: n ! total number of ints - integer, intent(out) :: array(n) ! ints read from file - integer, intent(in) :: lines ! total number of lines - integer, intent(in) :: words_per_line ! number of words per line - - integer :: i ! line index - integer :: loc ! locator for array - - loc = 0 - do i = 1, lines - if (i == lines) then - read(UNIT=unit,FMT=*) array(loc+1:n) - else - read(UNIT=unit,FMT=*) array(loc+1:loc+words_per_line) - loc = loc + words_per_line - end if - end do - - end subroutine read_data_int - -!=============================================================================== -! READ_DATA_REAL reads real(8) data into an array from a file open -!=============================================================================== - - subroutine read_data_real(unit, array, n, lines, words_per_line) - - integer, intent(in) :: unit ! unit to read from - integer, intent(in) :: n ! total number of ints - real(8), intent(out) :: array(n) ! real(8)s read from file - integer, intent(in) :: lines ! total number of lines - integer, intent(in) :: words_per_line ! number of words per line - - integer :: i ! line index - integer :: loc ! locator for array - - loc = 0 - do i = 1, lines - if (i == lines) then - read(UNIT=unit,FMT=*) array(loc+1:n) - else - read(UNIT=unit,FMT=*) array(loc+1:loc+words_per_line) - loc = loc + words_per_line - end if - end do - - end subroutine read_data_real - end module fileio From 6f9a347cac23cbc361fc59cb9226a7c0b6f069ee Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 7 Nov 2011 11:36:45 -0500 Subject: [PATCH 3/3] Improved performance of skip_lines by removing tmp. --- src/fileio.f90 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fileio.f90 b/src/fileio.f90 index 758634a600..48205a3f82 100644 --- a/src/fileio.f90 +++ b/src/fileio.f90 @@ -79,11 +79,10 @@ contains integer, intent(in) :: n_lines ! number of lines to skip integer, intent(out) :: ioError ! error status - integer :: i ! index for number of lines - character(MAX_LINE_LEN) :: tmp ! single line + integer :: i ! index for number of lines do i = 1, n_lines - read(UNIT=unit, FMT='(A)', IOSTAT=ioError) tmp + read(UNIT=unit, FMT=*, IOSTAT=ioError) end do end subroutine skip_lines