SPECFEM / specfem2d

SPECFEM2D simulates forward and adjoint seismic wave propagation in two-dimensional acoustic, (an)elastic, poroelastic or coupled acoustic-(an)elastic-poroelastic media, with Convolution PML absorbing conditions.
https://specfem.org
GNU General Public License v3.0
203 stars 147 forks source link

Fortran EOF error in adjoint simulations with DOWNSAMPLING #1195

Open AbolfazlKhanMo opened 1 year ago

AbolfazlKhanMo commented 1 year ago

Hi everyone!

When I set the NTSTEP_BETWEEN_OUTPUT_SAMPLE parameter in the _Parfile (for downsampling purposes) to any number other than 1, I get a Fortran End of File error during the adjoint simulations!

It seems the source code _(specfem2d/src/specfem2D/compute_arrays_source.f90/read_adj_source)_ has a bug, and it does not consider the parameter NTSTEP_BETWEEN_OUTPUT_SAMPLE in the following loop at line 225:

      do itime = 1, NSTEP
        read(IIN,*) junk, adj_src_s(itime,icomp)
      enddo`

This error occurs if the user sets the parameter to != 1. I am attaching parts of my Par_file that are related to the issue. If you need more info, please let me know.

Par_file(parts).txt

I am not sure if this the proper way to fix it but this is what I did to fix it:

(1) add NTSTEP_BETWEEN_OUTPUT_SAMPLE to line 173. (2) add NTSTEP_BETWEEN_OUTPUT_SAMPLE to all corresponding do loops (like the one above).

Thanks!