Skip to content

Commit

Permalink
Merge pull request SPECFEM#1640 from homnath/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
danielpeter committed Nov 9, 2023
2 parents b9c9ab4 + c439aa1 commit a14a4b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/USER_MANUAL/05_running_the_solver.tex
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ \chapter{Running the Solver \texttt{xspecfem3D}}\label{cha:Running-the-Solver}
\end{figure}

In addition to inbuild source-time functions, the solver can also use an external source-time function defined by the user. This option can be activated by setting \texttt{USE\_EXTERNAL\_SOURCE\_FILE} to \texttt{.true.} in \texttt{DATA/Par\_file} and by adding the name of the file containing the source-time function at the end of \texttt{FORCESOLUTION} or \texttt{CMTSOLUTION} files.
The source-time function file must contain a single column with the amplitudes of the source-time function for all the time steps. The time step must be exactly the same as that used for the simulation. When the flag is set to \texttt{.false.}, then the line with the external source-time function file must not appear in the files \texttt{FORCESOLUTION} and \texttt{CMTSOLUTION}, otherwise the solver will exit with an error. When using an external source file, you can still set up the source location and directivity as in the default case.
The source-time function file must contain a single column with the amplitudes of the source-time function for all the time steps. The time step must be exactly the same as that used for the simulation. If the external source-time functions are same for all the sources, differing only in their respective time shift, you can define the source-time function file only for the first source and set the external source-time function file to 'reuse' and define the appropriate value of \texttt{time shift} for all the other sources. When the flag is set to \texttt{.false.}, then the line with the external source-time function file must not appear in the files \texttt{FORCESOLUTION} and \texttt{CMTSOLUTION}, otherwise the solver will exit with an error. When using an external source file, you can still set up the source location and directivity as in the default case.
In the \texttt{FORCESOLUTION} file: you set "latorUTM", "longorUTM" and "depth" to define the position of your point source. Then if you want to define a directivity, change the following lines: "component dir vect source E", "component dir vect source N" and "component dir vect source Z\_UP". What you are doing is simply that you define the source position and directivity the same way as in the default case, but in addition you are specifying the path to read in a non-default source-time function from an external file.

\vspace{1cm}
Expand Down
19 changes: 16 additions & 3 deletions src/specfem3D/get_force.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ subroutine get_force(FORCESOLUTION,tshift_src,hdur,lat,long,depth,NSOURCES, &

! local variables below
integer :: isource,ier,ipos,dummyval
integer :: ishift,nright
double precision :: t_shift(NSOURCES)
double precision :: length
character(len=7) :: dummy
Expand Down Expand Up @@ -199,9 +200,21 @@ subroutine get_force(FORCESOLUTION,tshift_src,hdur,lat,long,depth,NSOURCES, &
! gets external STF file name
read(IIN,"(a)") string
external_source_time_function_filename = trim(string)

! reads in stf values
call read_external_source_time_function(isource,user_source_time_function,external_source_time_function_filename)
if(trim(external_source_time_function_filename).eq.'REUSE' .or. &
trim(external_source_time_function_filename).eq.'Reuse' .or. &
trim(external_source_time_function_filename).eq.'reuse')then
! Reuse the source time function of the first source.
if (isource.eq.1) then
stop 'Error: "reuse" option cannot be used for the first source!'
endif
ishift=nint(t_shift(isource)/DT)
nright=NSTEP_STF-ishift
user_source_time_function(1:ishift,isource)=0.0_CUSTOM_REAL
user_source_time_function(ishift+1:NSTEP_STF,isource)=user_source_time_function(1:nright,1)
else
! reads in stf values
call read_external_source_time_function(isource,user_source_time_function,external_source_time_function_filename)
endif
endif

! checks Par_file flag to override type setting
Expand Down

0 comments on commit a14a4b9

Please sign in to comment.