[cig-commits] [commit] devel: Safe compilation of solver with CEM workflow netcdf kernel output (2b030e9)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Tue Sep 23 08:10:52 PDT 2014
Repository : https://github.com/geodynamics/specfem3d_globe
On branch : devel
Link : https://github.com/geodynamics/specfem3d_globe/compare/301191ef4d74f79dd50e1d23ca9fb4d0f7f638f7...782728a945c4b1ae9e981f7a5a4a774836a6687d
>---------------------------------------------------------------
commit 2b030e9e0f864b8cf101057a2f6709183820694d
Author: Michael Afanasiev <michael.afanasiev at erdw.ethz.ch>
Date: Mon Sep 22 15:05:01 2014 +0200
Safe compilation of solver with CEM workflow netcdf kernel output
>---------------------------------------------------------------
2b030e9e0f864b8cf101057a2f6709183820694d
src/specfem3D/read_write_netcdf.f90 | 56 ++++++++++++++++++++++
src/specfem3D/rules.mk | 9 ++++
.../{save_kernels.f90 => save_kernels.F90} | 6 +++
3 files changed, 71 insertions(+)
diff --git a/src/specfem3D/read_write_netcdf.f90 b/src/specfem3D/read_write_netcdf.f90
new file mode 100644
index 0000000..639e705
--- /dev/null
+++ b/src/specfem3D/read_write_netcdf.f90
@@ -0,0 +1,56 @@
+subroutine write_kernel_netcdf (fName, param)
+
+ use :: mpi
+ use :: netcdf
+ use :: specfem_par
+ use :: specfem_par_crustmantle
+
+ implicit none
+
+ intent (in) :: param, fName
+
+ character (1024) :: fName
+
+ real (kind=CUSTOM_REAL), dimension (:), allocatable :: paramUnpacked
+ real (kind=CUSTOM_REAL), dimension (NGLLX, NGLLY, NGLLZ, NSPEC_CRUST_MANTLE) :: param
+
+ integer, parameter :: shuOn=1
+ integer, parameter :: comLvl=9
+ integer, parameter :: comOn=1
+ integer :: ncid, stat
+ integer :: i, j, k, ispec, iglob
+
+ allocate (paramUnpacked (NGLOB_CRUST_MANTLE))
+
+ do ispec = 1, NSPEC_CRUST_MANTLE
+ do k = 1, NGLLZ
+ do j = 1, NGLLY
+ do i = 1, NGLLX
+
+ iglob = ibool_crust_mantle (i, j, k, ispec)
+ paramUnpacked (iglob) = param (i, j, k, ispec)
+
+ end do
+ end do
+ end do
+ end do
+
+ call checkNC ( nf90_create (fName, IOR(NF90_NETCDF4, NF90_MPIIO), ncid, &
+ comm = MPI_COMM_WORLD, info = MPI_INFO_NULL))
+
+end subroutine write_kernel_netcdf
+
+subroutine checkNC (status)
+
+ use :: netcdf
+
+ implicit none
+
+ integer, intent (in) :: status
+
+ if (status /= nf90_noerr) then
+ print *, trim (nf90_strerror (status))
+ stop 2
+ end if
+
+end subroutine checkNC
\ No newline at end of file
diff --git a/src/specfem3D/rules.mk b/src/specfem3D/rules.mk
index a72cfaf..9323ff5 100644
--- a/src/specfem3D/rules.mk
+++ b/src/specfem3D/rules.mk
@@ -205,6 +205,11 @@ specfem3D_OBJECTS += $(adios_specfem3D_STUBS)
specfem3D_SHARED_OBJECTS += $(adios_specfem3D_SHARED_STUBS)
endif
+# conditional CEM model
+ifeq ($(CEM),yes)
+specfem3D_OBJECTS += $O/read_write_netcdf.checknetcdf.o
+endif
+
###
### VTK
###
@@ -320,3 +325,7 @@ $O/%.visualcc.o: $S/%.cpp ${SETUP}/config.h
$O/%.visualc.o: $S/%.c ${SETUP}/config.h
${CC} -c $(CPPFLAGS) $(MPI_INCLUDES) -o $@ $<
+## CEM
+
+$O/%.checknetcdf.o: $S/%.f90 $O/shared_par.shared_module.o $O/specfem3D_par.solverstatic_module.o
+ ${FCCOMPILE_CHECK} ${FCFLAGS_f90} $(NETCDF_INCLUDE) -c -o $@ $<
diff --git a/src/specfem3D/save_kernels.f90 b/src/specfem3D/save_kernels.F90
similarity index 99%
rename from src/specfem3D/save_kernels.f90
rename to src/specfem3D/save_kernels.F90
index 077f62c..a492754 100644
--- a/src/specfem3D/save_kernels.f90
+++ b/src/specfem3D/save_kernels.F90
@@ -435,6 +435,12 @@
write(IOUT) rho_kl_crust_mantle
close(IOUT)
+#if defined (CEM)
+
+ call write_kernel_netcdf ('alphav_kernel.nc', alphav_kl_crust_mantle)
+
+#endif
+
! in case one is interested in primary kernel K_rho
!open(unit=IOUT,file=trim(prname)//'rhonotprime_kernel.bin',status='unknown',form='unformatted',action='write')
!write(IOUT) rhonotprime_kl_crust_mantle
More information about the CIG-COMMITS
mailing list