From 51643738d6f24f963950615d2321dca5ebc86a28 Mon Sep 17 00:00:00 2001 From: diener Date: Fri, 1 Oct 2004 19:23:52 +0000 Subject: Added a parameter and routine to read in data with timesteps saved in separate files. For now the filenames has to be in a specific format (for example the filename for iteration 2 for gxx should be gxx_000002.h5 and the filename for iteration 142 should be gxx_000142.h5). This is the format used by the NASA Goddard group. git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/EHFinder/trunk@187 2a26948c-0e4f-0410-aee8-f1d3e353619c --- param.ccl | 6 ++++ src/EHFinder_ReadData.F90 | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/param.ccl b/param.ccl index 0bb8e7e..bb2aff6 100644 --- a/param.ccl +++ b/param.ccl @@ -26,6 +26,12 @@ KEYWORD eh_shift_type "Do we use numerical or analytic metric information" "analytic" :: "Use external analytic metric" } "numerical" +KEYWORD file_type "Are the timesteps in separate files or in one file?" +{ + "one_file" :: "All timesteps are in the same file" + "sep_time_files" :: "Timesteps are in separete files" +} "one_file" + BOOLEAN read_conformal_factor_once "Should the conformal factor only be read once" { } "yes" diff --git a/src/EHFinder_ReadData.F90 b/src/EHFinder_ReadData.F90 index e4f0f46..7215d0a 100644 --- a/src/EHFinder_ReadData.F90 +++ b/src/EHFinder_ReadData.F90 @@ -37,7 +37,11 @@ subroutine EHFinder_Read_Metric(CCTK_ARGUMENTS) ! Generate a string with the filenames. Note at present the requirement ! therefore is that all iterations of one variable is written in the ! same file. + in_files = 'gxx gxy gxz gyy gyz gzz' + if ( CCTK_EQUALS(file_type,'sep_time_files') ) then + call create_filenames ( in_files, i ) + end if ! Fill in the string array, used to requesting the metric components at ! the specified iteration number. @@ -95,6 +99,9 @@ subroutine EHFinder_Read_Lapse(CCTK_ARGUMENTS) ! therefore is that all iterations of one variable is written in the ! same file. in_files = 'alp' + if ( CCTK_EQUALS(file_type,'sep_time_files') ) then + call create_filenames ( in_files, i ) + end if ! Fill in the string used to requesting the lapse at the specified ! iteration number. @@ -139,6 +146,9 @@ subroutine EHFinder_Read_Shift(CCTK_ARGUMENTS) ! therefore is that all iterations of one variable is written in the ! same file. in_files = 'betax betay betaz' + if ( CCTK_EQUALS(file_type,'sep_time_files') ) then + call create_filenames ( in_files, i ) + end if ! Fill in the string array, used to requesting the shift components at ! the specified iteration number. @@ -199,6 +209,9 @@ subroutine EHFinder_Read_Conformal(CCTK_ARGUMENTS) ! therefore is that all iterations of one variable is written in the ! same file. in_files = 'psi' + if ( CCTK_EQUALS(file_type,'sep_time_files') ) then + call create_filenames ( in_files, i ) + end if ! Fill in the string array, used to requesting the conformal factor at ! the specified iteration number. @@ -242,6 +255,9 @@ subroutine EHFinder_Read_Mask(CCTK_ARGUMENTS) ! therefore is that all iterations of one variable is written in the ! same file. in_files = 'emask' + if ( CCTK_EQUALS(file_type,'sep_time_files') ) then + call create_filenames ( in_files, i ) + end if ! Fill in the string array, used to requesting the old style mask at ! the specified iteration number. @@ -252,3 +268,58 @@ subroutine EHFinder_Read_Mask(CCTK_ARGUMENTS) call IOUtil_RecoverVarsFromDatafiles ( res, cctkGH, in_files, in_vars ) end subroutine EHFinder_Read_Mask + +subroutine create_filenames ( in_files, i ) + + implicit none + + character(len=*), intent(INOUT) :: in_files + CCTK_INT, intent(IN) :: i + + character(len=len(in_files)) :: new_files + character(len=len(in_files)) :: tmp1, tmp2, istr + character(len=len_trim(in_files)) :: old_files + character(len=7), parameter :: template1 = '_000000' + character(len=7) :: template2 + logical :: last + CCTK_INT :: j, nc, lnew_file, ltmp, ltmp2 + + last = .false. + old_files = in_files + lnew_file = 0 + ltmp = len(old_files) + ltmp2 = 0 + tmp2 = '' + + write(istr,'(i10)') i + istr = adjustl(istr) + nc = len_trim(istr) + template2 = template1 + template2(8-nc:7) = istr(1:nc) + + j = scan (old_files(1:ltmp), ' ') + name_loop: do + if ( j == 0 ) last = .true. +! print*,'last = ', last + tmp1 = '' + if ( .not. last ) then + tmp1 = old_files(1:j-1) + old_files(1:ltmp-j) = old_files(j+1:ltmp) + else + tmp1 = old_files(1:ltmp) + old_files = '' + end if +! print*,'tmp1 = ',tmp1(1:j-1) +! print*,'old_files = ',old_files(1:ltmp) + ltmp = ltmp - j +! print*,'ltmp = ',ltmp + tmp2 = adjustl(trim(tmp2)//' '//trim(tmp1)//template2) +! print*,'tmp2 = ',trim(tmp2) +! print* + if ( last ) exit name_loop + j = scan (old_files(1:ltmp), ' ') + end do name_loop + + in_files = tmp2 +! pause +end subroutine create_filenames -- cgit v1.2.3