[cig-commits] [commit] devel,master: adds convert_model_file_adios.f90 to src/tomography/; updates make files (7e52bb1)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Nov 6 08:32:14 PST 2014


Repository : https://github.com/geodynamics/specfem3d_globe

On branches: devel,master
Link       : https://github.com/geodynamics/specfem3d_globe/compare/bc58e579b3b0838a0968725a076f5904845437ca...be63f20cbb6f462104e949894dbe205d2398cd7f

>---------------------------------------------------------------

commit 7e52bb1973f1812e1bfa0699113a14cb052cb667
Author: daniel peter <peterda at ethz.ch>
Date:   Mon Sep 22 15:43:30 2014 +0200

    adds convert_model_file_adios.f90 to src/tomography/; updates make files


>---------------------------------------------------------------

7e52bb1973f1812e1bfa0699113a14cb052cb667
 Makefile.in                                        |  27 +-
 src/auxiliaries/rules.mk                           |   8 +-
 src/shared/rules.mk                                |  10 +-
 src/specfem3D/rules.mk                             |   5 +-
 src/tomography/convert_model_file_adios.f90        | 538 +++++++++++++++++++++
 src/tomography/rules.mk                            | 143 ++++++
 .../VTK_ParaView/create_slice_VTK.f90              |  11 +-
 utils/extract_database/extract_database.f90        |  42 +-
 8 files changed, 765 insertions(+), 19 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index c1dac11..581d826 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -214,7 +214,9 @@ SUBDIRS = \
 	create_header_file \
 	meshfem3D \
 	specfem3D \
-	auxiliaries
+	auxiliaries \
+	tomography \
+	$(EMPTY_MACRO)
 
 ifeq ($(HAS_GPU),yes)
   SUBDIRS := gpu $(SUBDIRS)
@@ -261,10 +263,24 @@ mrproper: clean
 help:
 	@echo "usage: make [executable]"
 	@echo ""
-	@echo "supported executables:"
+	@echo "supported main executables:"
+	@echo "    xmeshfem3D"
+	@echo "    xspecfem3D"
+	@echo ""
+	@echo "defaults:"
 	@echo "    xcreate_header_file"
 	@echo "    xmeshfem3D"
 	@echo "    xspecfem3D"
+	@echo "    xcombine_AVS_DX"
+	@echo "    xcombine_surf_data"
+	@echo "    xcombine_vol_data"
+	@echo "    xcombine_vol_data_vtk"
+	@echo "    xconvolve_source_timefunction"
+	@echo "    xcreate_movie_AVS_DX"
+	@echo "    xcreate_movie_GMT_global"
+	@echo ""
+	@echo "additional executables:"
+	@echo "- auxiliary executables: [make aux]"
 	@echo "    xcombine_vol_data"
 	@echo "    xcombine_vol_data_vtk"
 ifeq ($(ADIOS), yes)
@@ -274,10 +290,17 @@ endif
 	@echo "    xcombine_surf_data"
 	@echo "    xcombine_AVS_DX"
 	@echo "    xconvolve_source_timefunction"
+	@echo ""
+	@echo "- movie executables: [make movies]"
 	@echo "    xcreate_movie_AVS_DX"
 	@echo "    xcreate_movie_GMT_global"
 	@echo "    xcombine_paraview_strain_data"
 	@echo ""
+	@echo "- tomography tools: [make tomo]"
+ifeq ($(ADIOS), yes)
+	@echo "    xconvert_model_file_adios"
+endif
+	@echo ""
 
 .PHONY: all default clean help
 
diff --git a/src/auxiliaries/rules.mk b/src/auxiliaries/rules.mk
index 6aa1416..4b356dc 100644
--- a/src/auxiliaries/rules.mk
+++ b/src/auxiliaries/rules.mk
@@ -78,12 +78,18 @@ auxiliaries_SHARED_OBJECTS = \
 #### rules for executables
 ####
 
-.PHONY: all_aux aux
+.PHONY: all_aux aux movies
 
 all_aux: $(auxiliaries_TARGETS)
 
 aux: $(auxiliaries_TARGETS)
 
+movies: \
+	$E/xcombine_paraview_strain_data \
+	$E/xcreate_movie_AVS_DX \
+	$E/xcreate_movie_GMT_global \
+	$(EMPTY_MACRO)
+
 #######################################
 
 ####
diff --git a/src/shared/rules.mk b/src/shared/rules.mk
index 8bed3e5..3d126a0 100644
--- a/src/shared/rules.mk
+++ b/src/shared/rules.mk
@@ -82,18 +82,12 @@ adios_shared_OBJECTS = \
 	$O/adios_helpers_writers.shared_adios_module.o \
 	$O/adios_helpers.shared_adios.o \
 	$O/adios_manager.shared_adios.o \
-	$O/asdf_helpers_definitions.shared_adios_module.o \
-	$O/asdf_helpers_writers.shared_adios_module.o \
-	$O/asdf_helpers.shared_adios.o \
 	$(EMPTY_MACRO)
 
 adios_shared_MODULES = \
 	$(FC_MODDIR)/adios_helpers_definitions_mod.$(FC_MODEXT) \
 	$(FC_MODDIR)/adios_helpers_mod.$(FC_MODEXT) \
 	$(FC_MODDIR)/adios_helpers_writers_mod.$(FC_MODEXT) \
-	$(FC_MODDIR)/asdf_helpers_definitions_mod.$(FC_MODEXT) \
-	$(FC_MODDIR)/asdf_helpers_mod.$(FC_MODEXT) \
-	$(FC_MODDIR)/asdf_helpers_writer_mod.$(FC_MODEXT) \
 	$(EMPTY_MACRO)
 
 adios_shared_STUBS = \
@@ -139,10 +133,10 @@ $O/%.sharedmpi.o: $S/%.f90 $O/shared_par.shared_module.o
 $O/%.shared_adios_module.o: $S/%.f90
 	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $<
 
-$O/%.shared_adios.o: $S/%.f90 $O/adios_helpers_writers.shared_adios_module.o $O/adios_helpers_definitions.shared_adios_module.o $O/shared_par.shared_module.o $O/asdf_helpers_writers.shared_adios_module.o $O/asdf_helpers_definitions.shared_adios_module.o
+$O/%.shared_adios.o: $S/%.f90 $O/adios_helpers_writers.shared_adios_module.o $O/adios_helpers_definitions.shared_adios_module.o $O/shared_par.shared_module.o
 	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $<
 
-$O/%.shared_adios.o: $S/%.F90 $O/adios_helpers_writers.shared_adios_module.o $O/adios_helpers_definitions.shared_adios_module.o $O/shared_par.shared_module.o $O/asdf_helpers_writers.shared_adios_module.o $O/asdf_helpers_definitions.shared_adios_module.o
+$O/%.shared_adios.o: $S/%.F90 $O/adios_helpers_writers.shared_adios_module.o $O/adios_helpers_definitions.shared_adios_module.o $O/shared_par.shared_module.o
 	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $<
 
 
diff --git a/src/specfem3D/rules.mk b/src/specfem3D/rules.mk
index 9323ff5..9aa1ee2 100644
--- a/src/specfem3D/rules.mk
+++ b/src/specfem3D/rules.mk
@@ -184,9 +184,6 @@ adios_specfem3D_SHARED_OBJECTS = \
 	$O/adios_helpers_writers.shared_adios_module.o \
 	$O/adios_helpers.shared_adios.o \
 	$O/adios_manager.shared_adios.o \
-	$O/asdf_helpers_definitions.shared_adios_module.o \
-	$O/asdf_helpers_writers.shared_adios_module.o \
-	$O/asdf_helpers.shared_adios.o \
 	$(EMPTY_MACRO)
 
 adios_specfem3D_STUBS = \
@@ -266,7 +263,7 @@ $(specfem3D_OBJECTS): S = ${S_TOP}/src/specfem3D
 ### additional dependencies
 ###
 
-$O/write_output_ASDF.solverstatic_adios.o: $O/asdf_helpers.shared_adios.o $O/asdf_helpers_writers.shared_adios.o $O/asdf_data.solverstatic_module.o
+$O/write_output_ASDF.solverstatic_adios.o: $O/asdf_data.solverstatic_module.o
 
 $O/write_seismograms.solverstatic.o: $O/asdf_data.solverstatic_module.o
 
diff --git a/src/tomography/convert_model_file_adios.f90 b/src/tomography/convert_model_file_adios.f90
new file mode 100644
index 0000000..c07364f
--- /dev/null
+++ b/src/tomography/convert_model_file_adios.f90
@@ -0,0 +1,538 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  6 . 0
+!          --------------------------------------------------
+!
+!     Main historical authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!                and CNRS / University of Marseille, France
+!                 (there are currently many more authors!)
+! (c) Princeton University and CNRS / University of Marseille, April 2014
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+! Ebru & Daniel
+! Nice & Zurich, September 2014
+
+program convert_model_file_adios
+
+  use adios_read_mod
+  use adios_write_mod
+  use adios_helpers_mod
+
+  use constants,only: CUSTOM_REAL,NGLLX,NGLLY,NGLLZ,NX_BATHY,NY_BATHY,IIN,IOUT, &
+    ADIOS_TRANSPORT_METHOD,ADIOS_BUFFER_SIZE_IN_MB
+
+  ! converts between adios and binary format for a model file like
+
+  implicit none
+
+  include "OUTPUT_FILES/values_from_mesher.h"
+
+  !-------------------------------------------------------------------
+  ! USER PARAMETERS
+  ! ADIOS model file name
+  character(len=64) :: model_adios_file = 'model_gll.bp'
+
+  ! model type
+  ! isotropic model parameters (vp,vs,rho) or
+  ! transversely isotropic model parameters (vpv,vph,vsv,vsh,eta,rho)
+  ! defaults: TI models
+  logical,parameter :: USE_TRANSVERSE_ISOTROPY = .true.
+
+  ! shear attenuation
+  logical,parameter :: USE_ATTENUATION_Q = .false.
+
+  !-------------------------------------------------------------------
+
+  ! model files
+  integer, parameter :: NSPEC = NSPEC_CRUST_MANTLE
+
+  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,NSPEC) :: &
+    model_vpv,model_vph,model_vsv,model_vsh,model_eta,model_rho,model_qmu
+
+  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,NSPEC) :: model
+
+  ! mpi
+  integer :: myrank, sizeprocs
+
+  ! model parameters
+  character(len=256) :: m_file
+  character(len=256) :: m_adios_file
+  character(len=16) :: model_name(7),fname(7)
+  integer :: nparams
+  integer :: i,iker
+
+  ! input arguments
+  character(len=256) :: arg
+  character(len=256) :: input_model_dir, output_model_dir
+  integer :: convert_format
+
+  ! adios
+  character(len=150) :: group_name
+  integer(kind=8) :: group, model_handle
+  integer(kind=8) :: totalsize
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim
+  integer(kind=8) :: sel
+  integer(kind=8) :: sel_start(1),count_ad(1)
+  integer :: comm
+  integer :: ier
+
+  ! defines model parameters
+  if (USE_TRANSVERSE_ISOTROPY) then
+    ! transversly isotropic (TI) model
+    nparams = 6
+    model_name(1:6) = (/character(len=16) :: "reg1/vpv","reg1/vph","reg1/vsv","reg1/vsh","reg1/eta","reg1/rho"/)
+    fname(1:6) = (/character(len=16) :: "vpv","vph","vsv","vsh","eta","rho"/)
+  else
+    ! isotropic model
+    nparams = 3
+    ! note: adds space at endings to equal number of characters 
+    !       to avoid compiler error: "Different shape for array assignment.."
+    model_name(1:3) = (/character(len=16) :: "reg1/vp ","reg1/vs ","reg1/rho"/)
+    fname(1:3) = (/character(len=16) :: "vp ","vs ","rho"/)
+  endif
+  ! adds shear attenuation
+  if (USE_ATTENUATION_Q) then
+    nparams = nparams + 1
+    model_name(nparams) = "reg1/qmu"
+    fname(nparams) = "qmu"
+  endif
+
+  ! starts mpi
+  call init_mpi()
+  call world_size(sizeprocs)
+  call world_rank(myrank)
+  call world_get_comm(comm)
+
+  ! checks number of processes
+  ! note: must run as with same number of process as file was created
+  if (sizeprocs /= NPROCTOT_VAL) then
+    ! usage info
+    if (myrank == 0) then
+      print *, "this program must be executed in parallel with NPROCTOT_VAL = ",NPROCTOT_VAL,"processes"
+      print *, "Invalid number of processes used: ", sizeprocs, " procs"
+      print *
+      print *, "Please run: mpirun -np ",NPROCTOT_VAL," ./bin/xconvert_model_file_adios .."
+    endif
+    call abort_mpi()
+  endif
+
+  ! reads input arguments
+  do i = 1, 3
+    call get_command_argument(i,arg)
+
+    ! usage info
+    if (i <= 3 .and. len_trim(arg) == 0) then
+      if( myrank == 0 ) then
+        print *, ' '
+        print *, ' Usage: xconvert_model_file_adios type MODEL_INPUT_DIR/ MODEL_OUTPUT_DIR/ '
+        print *, ' '
+        print *, ' with'
+        print *, '   type = 1 - convert from ADIOS to (old) binaries'
+        print *, '        = 2 - convert from (old) binaries to ADIOS'
+        print *, '   MODEL_INPUT_DIR/  - directory which holds input model file(s)'
+        print *, '   MODEL_OUTPUT_DIR/ - directory which will hold output model file(s)'
+        print *, ' '
+      endif
+      stop ' Reenter command line options'
+    endif
+
+    select case (i)
+    case (1)
+      read(arg(1:len_trim(arg)),*) convert_format
+    case (2)
+      input_model_dir = trim(arg)
+    case (3)
+      output_model_dir = trim(arg)
+    end select
+  enddo
+
+  ! checks arguments
+  if (convert_format /= 1 .and. convert_format /= 2) then
+    print*,'Error: invalid format type',convert_format
+    stop ' Reenter format type in command line options'
+  endif
+
+  ! sets adios model file name
+  if ( convert_format == 1) then
+    ! from adios to old binaries
+    m_adios_file = trim(input_model_dir) // '/' // trim(model_adios_file)
+  else
+    ! from old binaries to adios
+    m_adios_file = trim(output_model_dir) // '/' // trim(model_adios_file)
+  endif
+
+  ! user output
+  if (myrank == 0) then
+    print *, 'program convert_model_file_adios:'
+    print *, ' '
+    if ( convert_format == 1) then
+      print *, 'conversion type : ',convert_format,' - converts from adios to binary files'
+    else
+      print *, 'conversion type : ',convert_format,' - converts from binary files to adios'
+    endif
+    print *, 'input  directory: ',trim(input_model_dir)
+    print *, 'output directory: ',trim(output_model_dir)
+    print *, ' '
+    if (USE_TRANSVERSE_ISOTROPY) then
+      print *, 'model parameters:',nparams,' - transversely isotropic model'
+    else
+      print *, 'model parameters:',nparams,' - isotropic model'
+    endif
+    if (USE_ATTENUATION_Q) then
+      print *, '  includes qmu model parameter'
+    endif
+    print *, ' '
+    print *, 'crust/mantle region:'
+    print *, '  number of spectral elements = ',NSPEC
+    print *, ' '
+  endif
+
+  ! initializes ADIOS
+  if (myrank == 0) then
+    print *, 'initializing ADIOS...'
+    print *, ' '
+  endif
+  call adios_setup()
+
+  ! initializes model values
+  model(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_vpv(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_vph(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_vsv(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_vsh(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_eta(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_rho(:,:,:,:) = 0.0_CUSTOM_REAL
+  model_qmu(:,:,:,:) = 0.0_CUSTOM_REAL
+
+!--------------------------------------------
+  if (convert_format == 1) then ! from adios to old binaries
+!--------------------------------------------
+
+! READ THE MODEL IN ADIOS FORMAT
+
+    ! user output
+    if (myrank == 0) then
+      print *, 'reading in ADIOS model file: ',trim(m_adios_file)
+    endif
+
+    call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, "verbose=1", ier)
+    if (ier /= 0 ) stop 'Error in adios_read_init_method()'
+
+    call adios_read_open_file (model_handle, trim(m_adios_file), 0, comm, ier)
+    if (ier /= 0) then
+      print *, 'Error opening adios model file: ',trim(m_adios_file)
+      stop 'error opening adios model file'
+    endif
+
+    local_dim = NGLLX * NGLLY * NGLLZ * NSPEC
+
+    do iker = 1,nparams
+      model(:,:,:,:) = 0.0_CUSTOM_REAL
+
+      call adios_get_scalar(model_handle, trim(model_name(iker))//"/local_dim",local_dim, ier)
+      if (ier /= 0 ) stop 'Error adios get scalar'
+
+      sel_start(1) = local_dim * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC
+
+      call adios_selection_boundingbox(sel, 1, sel_start, count_ad)
+      call adios_schedule_read(model_handle, sel,trim(model_name(iker))//"/array",0, 1, model, ier)
+      if (ier /= 0 ) stop 'Error adios schedule read'
+
+      call adios_perform_reads(model_handle, ier)
+      if (ier /= 0 ) stop 'Error adios perform read'
+
+      if (USE_TRANSVERSE_ISOTROPY) then
+        ! TI model
+        select case (iker)
+        case (1)
+           model_vpv(:,:,:,:) = model(:,:,:,:)
+        case (2)
+           model_vph(:,:,:,:) = model(:,:,:,:)
+        case (3)
+           model_vsv(:,:,:,:) = model(:,:,:,:)
+        case (4)
+           model_vsh(:,:,:,:) = model(:,:,:,:)
+        case (5)
+           model_eta(:,:,:,:) = model(:,:,:,:)
+        case (6)
+           model_rho(:,:,:,:) = model(:,:,:,:)
+        end select
+      else
+        ! isotropic model
+        select case (iker)
+        case (1)
+           model_vpv(:,:,:,:) = model(:,:,:,:)
+        case (2)
+           model_vsv(:,:,:,:) = model(:,:,:,:)
+        case (3)
+           model_rho(:,:,:,:) = model(:,:,:,:)
+        end select
+      endif
+      ! adds shear attenuation
+      if (USE_ATTENUATION_Q) then
+        if (iker == nparams ) then
+           model_qmu(:,:,:,:) = model(:,:,:,:)
+        endif
+      endif
+    enddo
+
+    call adios_read_close(model_handle,ier)
+    if (ier /= 0 ) stop 'Error adios read close'
+
+    call adios_read_finalize_method(ADIOS_READ_METHOD_BP, ier)
+    if (ier /= 0 ) stop 'Error adios read finalize'
+
+    ! WRITE OUT THE MODEL IN OLD BINARIES
+
+    ! user output
+    if (myrank == 0) then
+      print *, ' '
+      print *, 'writing out binary files...'
+    endif
+
+    do iker = 1,nparams
+      ! user output
+      if (myrank == 0) then
+        print *, '  for parameter: ',trim(fname(iker))
+      endif
+
+      ! file name
+      write(m_file,'(a,i6.6,a)') trim(output_model_dir)//'/proc',myrank,'_reg1_'//trim(fname(iker))//'.bin'
+      open(IOUT,file=trim(m_file),form='unformatted',action='write',iostat=ier)
+      if (ier /= 0) then
+        print *, 'Error opening binary parameter file: ',trim(m_file)
+        stop 'error opening binary parameter file'
+      endif
+
+      ! selects output
+      if (USE_TRANSVERSE_ISOTROPY) then
+        ! TI model
+        select case (iker)
+        case (1)
+          ! vpv model
+          write(IOUT) model_vpv
+        case (2)
+          ! vph model
+          write(IOUT) model_vph
+        case (3)
+          ! vsv model
+          write(IOUT) model_vsv
+        case (4)
+          ! vsh model
+          write(IOUT) model_vsh
+        case (5)
+          ! eta model
+          write(IOUT) model_eta
+        case (6)
+          ! rho model
+          write(IOUT) model_rho
+        end select
+      else
+        ! isotropic model
+        select case (iker)
+        case (1)
+          ! vp model
+          write(IOUT) model_vpv
+        case (2)
+          ! vs model
+          write(IOUT) model_vsv
+        case (3)
+          ! rho model
+          write(IOUT) model_rho
+        end select
+      endif
+      ! adds shear attenuation
+      if (USE_ATTENUATION_Q) then
+        if (iker == nparams ) then
+          ! qmu model
+          write(IOUT) model_qmu
+        endif
+      endif
+
+      close(IOUT)
+    enddo
+
+    if (myrank==0) print *, 'done writing the model in binary format'
+
+!--------------------------------------------
+  elseif (convert_format == 2) then ! from binaries to adios
+!--------------------------------------------
+
+! READ THE MODEL IN OLD BINARY FORMAT
+
+    ! user output
+    if (myrank == 0) then
+      print *, 'reading in binary model files'
+    endif
+
+    do iker = 1,nparams
+      ! user output
+      if (myrank == 0) then
+        print *, '  for parameter: ',trim(fname(iker))
+      endif
+
+      ! file name
+      write(m_file,'(a,i6.6,a)') trim(input_model_dir)//'/proc',myrank,'_reg1_'//trim(fname(iker))//'.bin'
+      open(IIN,file=trim(m_file),status='old',form='unformatted',action='read',iostat=ier)
+      if (ier /= 0) then
+        print *, 'Error opening binary parameter file: ',trim(m_file)
+        stop 'error opening binary parameter file'
+      endif
+
+      ! selects output
+      if (USE_TRANSVERSE_ISOTROPY) then
+        ! TI model
+        select case (iker)
+        case (1)
+          ! vpv model
+          read(IIN) model_vpv
+        case (2)
+          ! vph model
+          read(IIN) model_vph
+        case (3)
+          ! vsv model
+          read(IIN) model_vsv
+        case (4)
+          ! vsh model
+          read(IIN) model_vsh
+        case (5)
+          ! eta model
+          read(IIN) model_eta
+        case (6)
+          ! rho model
+          read(IIN) model_rho
+        end select
+      else
+        ! isotropic model
+        select case (iker)
+        case (1)
+          ! vp model
+          read(IIN) model_vpv
+        case (2)
+          ! vs model
+          read(IIN) model_vsv
+        case (3)
+          ! rho model
+          read(IIN) model_rho
+        end select
+      endif
+      ! adds shear attenuation
+      if (USE_ATTENUATION_Q) then
+        if (iker == nparams ) then
+          ! qmu model
+          read(IIN) model_qmu
+        endif
+      endif
+
+      close(IIN)
+    enddo
+
+! WRITE OUT THE MODEL IN ADIOS FORMAT
+
+    ! user output
+    if (myrank == 0) then
+      print *, ' '
+      print *, 'writing out ADIOS model file: ',trim(m_adios_file)
+    endif
+
+    group_size_inc = 0
+    group_name = "MODELS_GROUP"
+
+    call adios_declare_group(group, group_name, "", 1, ier)
+    call adios_select_method(group, ADIOS_TRANSPORT_METHOD, "", "", ier)
+    call define_adios_scalar(group, group_size_inc, "", "NSPEC", nspec)
+
+    ! Setup ADIOS for the current group
+    local_dim = NGLLX * NGLLY * NGLLZ * NSPEC
+
+    ! Define ADIOS Variables
+    do iker=1,nparams
+      call define_adios_global_array1D(group, group_size_inc,local_dim,"",trim(model_name(iker)),model)
+    enddo
+
+    ! Open an handler to the ADIOS file and setup the group size
+    call adios_open(model_handle, group_name, trim(m_adios_file), "w", comm, ier);
+    if (ier /= 0) then
+      print *, 'Error opening adios model file: ',trim(m_adios_file)
+      stop 'error opening adios model file'
+    endif
+
+    call adios_group_size (model_handle, group_size_inc, totalsize, ier)
+    call adios_write(model_handle, "NSPEC", nspec, ier)
+
+    local_dim = NGLLX * NGLLY * NGLLZ * NSPEC
+    do iker=1,nparams
+      if (USE_TRANSVERSE_ISOTROPY) then
+        ! TI model
+        select case (iker)
+        case (1)
+          model(:,:,:,:) = model_vpv(:,:,:,:)
+        case (2)
+          model(:,:,:,:) = model_vph(:,:,:,:)
+        case (3)
+          model(:,:,:,:) = model_vsv(:,:,:,:)
+        case (4)
+          model(:,:,:,:) = model_vsh(:,:,:,:)
+        case (5)
+          model(:,:,:,:) = model_eta(:,:,:,:)
+        case (6)
+          model(:,:,:,:) = model_rho(:,:,:,:)
+        end select
+      else
+        ! isotropic model
+        select case (iker)
+        case (1)
+          model(:,:,:,:) = model_vpv(:,:,:,:)
+        case (2)
+          model(:,:,:,:) = model_vsv(:,:,:,:)
+        case (3)
+          model(:,:,:,:) = model_rho(:,:,:,:)
+        end select
+      endif
+      ! adds shear attenuation
+      if (USE_ATTENUATION_Q) then
+        if (iker == nparams ) then
+          ! qmu model
+          model(:,:,:,:) = model_qmu(:,:,:,:)
+        endif
+      endif
+
+      ! Write previously defined ADIOS variables
+      call write_adios_global_1d_array(model_handle, myrank, sizeprocs, local_dim, &
+                                       trim(model_name(iker)),model(:,:,:,:))
+    enddo
+    ! Perform the actual write to disk
+    call adios_set_path(model_handle, "", ier)
+    call adios_close(model_handle, ier)
+
+    if (myrank==0) print *, 'done writing the model in adios format'
+  endif
+  ! user output
+  if (myrank==0) then
+    print *, ' '
+    print *, 'see output file(s) in directory: ',trim(output_model_dir)
+    print *, ' '
+  endif
+
+  call adios_finalize (myrank, ier)
+  call finalize_mpi()
+
+end program convert_model_file_adios
diff --git a/src/tomography/rules.mk b/src/tomography/rules.mk
new file mode 100644
index 0000000..eb93237
--- /dev/null
+++ b/src/tomography/rules.mk
@@ -0,0 +1,143 @@
+#=====================================================================
+#
+#          S p e c f e m 3 D  G l o b e  V e r s i o n  6 . 0
+#          --------------------------------------------------
+#
+#     Main historical authors: Dimitri Komatitsch and Jeroen Tromp
+#                        Princeton University, USA
+#                and CNRS / University of Marseille, France
+#                 (there are currently many more authors!)
+# (c) Princeton University and CNRS / University of Marseille, April 2014
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+#=====================================================================
+
+#######################################
+
+tomography_TARGETS = \
+	$E/xinterpolate_model \
+	$(EMPTY_MACRO)
+
+ifeq ($(ADIOS),yes)
+tomography_TARGETS += \
+	$E/xconvert_model_file_adios \
+	$(EMPTY_MACRO)
+endif
+
+tomography_OBJECTS = \
+	$(xinterpolate_model_OBJECTS) \
+	$(xconvert_model_file_adios_OBJECTS) \
+	$(EMPTY_MACRO)
+
+# These files come from the shared directory
+tomography_SHARED_OBJECTS = \
+	$(xinterpolate_model_SHARED_OBJECTS) \
+	$(xconvert_model_file_adios_SHARED_OBJECTS) \
+	$(EMPTY_MACRO)
+
+
+tomography_MODULES = \
+	$(FC_MODDIR)/kdtree_search.$(FC_MODEXT) \
+	$(EMPTY_MACRO)
+
+####
+#### rules for executables
+####
+
+.PHONY: all_tomo tomo
+
+all_tomo: $(tomo_TARGETS)
+
+tomo: $(tomo_TARGETS)
+
+#######################################
+
+####
+#### rules for each program follow
+####
+
+#######################################
+
+
+## xinterpolate_model
+
+xinterpolate_model_OBJECTS = \
+	$O/interpolate_model.tomo.o \
+	$O/interpolate_model_kdtree.tomo.o \
+	$(EMPTY_MACRO)
+
+xinterpolate_model_SHARED_OBJECTS = \
+	$O/parallel.sharedmpi.o \
+	$O/gll_library.shared.o \
+	$O/hex_nodes.shared.o \
+	$O/lagrange_poly.shared.o \
+	$O/recompute_jacobian.solver.o \
+	$(EMPTY_MACRO)
+
+# extra dependencies
+$O/interpolate_model.tomo.o: $O/interpolate_model_kdtree.tomo.o
+
+${E}/xinterpolate_model: $(xinterpolate_model_OBJECTS) $(xinterpolate_model_SHARED_OBJECTS)
+	${MPIFCCOMPILE_CHECK} -o $@ $+ $(MPILIBS)
+
+
+
+## xconvert_model_file_adios
+
+xconvert_model_file_adios_OBJECTS = \
+	$O/convert_model_file_adios.tomoadios.o \
+	$(EMPTY_MACRO)
+
+xconvert_model_file_adios_SHARED_OBJECTS = \
+	$O/parallel.sharedmpi.o \
+	$O/adios_helpers_definitions.shared_adios_module.o \
+	$O/adios_helpers_writers.shared_adios_module.o \
+	$O/adios_helpers.shared_adios.o \
+	$O/adios_manager.shared_adios.o \
+	$(EMPTY_MACRO)
+
+# extra dependencies
+#$O/convert_model_file_adios.tomoadios.o: $O/adios_helpers.shared_adios.o
+
+${E}/xconvert_model_file_adios: $(xconvert_model_file_adios_OBJECTS) $(xconvert_model_file_adios_SHARED_OBJECTS)
+	${MPIFCCOMPILE_CHECK} -o $@ $+ $(MPILIBS)
+
+
+#######################################
+
+## compilation directories
+S := ${S_TOP}/src/tomography
+$(tomography_OBJECTS): S := ${S_TOP}/src/tomography
+
+####
+#### rule for each .o file below
+####
+
+##
+## tomography
+##
+$O/%.tomo.o: $S/%.f90 $O/shared_par.shared_module.o ${OUTPUT}/values_from_mesher.h $O/parallel.sharedmpi.o
+	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $<
+
+$O/%.tomo.o: $S/%.F90 $O/shared_par.shared_module.o ${OUTPUT}/values_from_mesher.h $O/parallel.sharedmpi.o
+	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $<
+
+$O/%.tomoadios.o: $S/%.F90 $O/shared_par.shared_module.o ${OUTPUT}/values_from_mesher.h $O/parallel.sharedmpi.o $O/adios_helpers.shared_adios.o
+	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $< $(FC_DEFINE)ADIOS_INPUT
+
+$O/%.tomoadios.o: $S/%.f90 $O/shared_par.shared_module.o ${OUTPUT}/values_from_mesher.h $O/parallel.sharedmpi.o $O/adios_helpers.shared_adios.o
+	${FCCOMPILE_CHECK} ${FCFLAGS_f90} -c -o $@ $<
+
diff --git a/utils/Visualization/VTK_ParaView/create_slice_VTK.f90 b/utils/Visualization/VTK_ParaView/create_slice_VTK.f90
index a2443ef..f54b1b4 100644
--- a/utils/Visualization/VTK_ParaView/create_slice_VTK.f90
+++ b/utils/Visualization/VTK_ParaView/create_slice_VTK.f90
@@ -199,7 +199,7 @@
       print *
 
       ! topology file
-      topo_file = trim(prname_topo) // 'solver_data_2' // '.bin'
+      topo_file = trim(prname_topo) // 'solver_data' // '.bin'
       open(unit = 28,file = trim(topo_file),status='old',action='read', iostat = ios, form='unformatted')
       if (ios /= 0) then
        print*,'error ',ios
@@ -210,13 +210,20 @@
       ystore(:) = 0.0
       zstore(:) = 0.0
       ibool(:,:,:,:) = -1
+      ! skipps nspec 
+      read(28) njunk
+      if (njunk /= nspec(it)) stop 'Error invalid nspec in solver_data.bin'
+      ! skipps nglob
+      read(28) njunk
+      if (njunk /= nglob(it)) stop 'Error invalid nglob in solver_data.bin'
+
+      ! mesh node locations
       read(28) xstore(1:nglob(it))
       read(28) ystore(1:nglob(it))
       read(28) zstore(1:nglob(it))
       read(28) ibool(:,:,:,1:nspec(it))
       close(28)
 
-
       write(mesh_file,'(a,i1,a)') trim(outdir)//'/' // 'reg_',ir,'_'//trim(filename)
       print *, trim(mesh_file)
 
diff --git a/utils/extract_database/extract_database.f90 b/utils/extract_database/extract_database.f90
index 972a616..e152ddc 100644
--- a/utils/extract_database/extract_database.f90
+++ b/utils/extract_database/extract_database.f90
@@ -1,7 +1,7 @@
 program extract_databases
 
 ! right now just extract the mantle databases
-! Usage: extract_databases proc000000_reg1_solver_data_1.bin ireg n  proc000000_reg1_kappa.bin
+! Usage: extract_databases proc000000_reg1_solver_data.bin ireg n  proc000000_reg1_kappa.bin
 ! for example: n = 10 (rho), 11 (kappav), 12 (muv)
 !  Qinya Liu, Caltech, May 2007
 
@@ -13,6 +13,11 @@ program extract_databases
   character(len=150) :: infile, s_num, outfile, s_ireg
   integer :: num, i, nspec, ireg
 
+  !integer :: idummy
+  !integer,dimension(NGLLX,NGLLY,NGLLZ,NSPEC_CRUST_MANTLE) :: ibool
+  !integer,dimension(NSPEC_CRUST_MANTLE) :: idoubling
+  !logical,dimension(NSPEC_CRUST_MANTLE) :: ispec_is_tiso
+
   real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,NSPEC_CRUST_MANTLE) :: junk
   real(kind=CUSTOM_REAL) :: junk2
 
@@ -41,7 +46,40 @@ program extract_databases
 
   read(s_num,*) num
 
-  open(11,file=infile,status='old',form='unformatted')
+  ! note: routine below works with old solver_data_1.bin file
+  !       remove this stop if you're sure about it..
+  stop 'Error extracting from new solver_data.bin files not implemented yet'
+
+
+  open(11,file=trim(infile),status='old',form='unformatted')
+
+  ! new solver_data.bin: ordering see save_arrays_solver.f90
+  ! 0.a nspec
+  ! 0.b nglob
+  ! 1. xstore
+  ! 2. ystore
+  ! 3. zstore
+  ! 4. ibool - integer array
+  ! 5. idoubling - integer array
+  ! 6. ispec_is_tiso - logical array
+  ! 7. xixstore
+  ! 8. xiystore
+  ! 9. xizstore
+  ! 10. etaxstore
+  ! 11. etaystore
+  ! 12. etazstore
+  ! 13. gammaxstore
+  ! 14. gammaystore
+  ! 15. gammazstore
+  ! 16. rhostore
+  ! 17. kappavstore
+
+  ! skipps nspec
+  !read(11) idummy
+  !if (idummy /= NSPEC_CRUST_MANTLE) stop 'Error invalid nspec in input file (solver_data.bin)'
+  ! skipps nglob
+  !read(11) idummy
+
   do i = 1, num-1
     read(11) junk2
   enddo



More information about the CIG-COMMITS mailing list