Skip to content

Commit

Permalink
better code beautifier
Browse files Browse the repository at this point in the history
  • Loading branch information
komatits committed Aug 7, 2016
1 parent 485bd5c commit 85e9caa
Show file tree
Hide file tree
Showing 260 changed files with 3,994 additions and 3,994 deletions.
26 changes: 13 additions & 13 deletions EXAMPLES/BENCHMARK_CLAERBOUT_ADJOINT/ACOUSTIC/adj_seismogram.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program adj_seismogram
write(procname,"(i4)") myrank

!! input parameters
if( iargc() /= 2 ) stop 'Usage: ./xadj NSTEP DT'
if ( iargc() /= 2 ) stop 'Usage: ./xadj NSTEP DT'
j=1; call getarg(j, arg); read(arg,*,iostat=ios) NSTEP; if (ios /= 0) stop 'Error reading NSTEP'
j=2; call getarg(j, arg); read(arg,*,iostat=ios) DT; if (ios /= 0) stop 'Error reading DT'

Expand Down Expand Up @@ -50,13 +50,13 @@ program adj_seismogram
filename=trim(adjustl(procname))//"_dx_SU"
open(111,file="../OUTPUT_FILES/SEM/syn/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file syn'
if ( ios /= 0 ) stop 'error opening file syn'
open(112,file="../OUTPUT_FILES/SEM/dat/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file dat'
if ( ios /= 0 ) stop 'error opening file dat'
open(113,file="../OUTPUT_FILES/SEM/"//trim(filename)//".adj", &
status='unknown',access='direct',action='write',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file .adj'
if ( ios /= 0 ) stop 'error opening file .adj'

irec=1
do while(ios==0)
Expand All @@ -73,7 +73,7 @@ program adj_seismogram
if (ios /= 0) exit

!daniel: outputs ascii trace
if( myrank == 0 .and. irec == 196 ) then
if ( myrank == 0 .and. irec == 196 ) then
open(221,file="../OUTPUT_FILES/SEM/syn/"//trim(filename)//".ascii",status='unknown')
do i=1,NSTEP
write(221,*) i,syn(i)
Expand Down Expand Up @@ -101,13 +101,13 @@ program adj_seismogram
filename=trim(adjustl(procname))//"_dy_SU"
open(111,file="../OUTPUT_FILES/SEM/syn/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file syn'
if ( ios /= 0 ) stop 'error opening file syn'
open(112,file="../OUTPUT_FILES/SEM/dat/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file dat'
if ( ios /= 0 ) stop 'error opening file dat'
open(113,file="../OUTPUT_FILES/SEM/"//trim(filename)//".adj", &
status='unknown',access='direct',action='write',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file .adj'
if ( ios /= 0 ) stop 'error opening file .adj'

irec=1
do while(ios==0)
Expand All @@ -123,7 +123,7 @@ program adj_seismogram
if (ios /= 0) exit

!daniel: outputs ascii trace
if( myrank == 0 .and. irec == 196 ) then
if ( myrank == 0 .and. irec == 196 ) then
open(221,file="../OUTPUT_FILES/SEM/syn/"//trim(filename)//".ascii",status='unknown')
do i=1,NSTEP
write(221,*) i,syn(i)
Expand Down Expand Up @@ -152,13 +152,13 @@ program adj_seismogram
filename=trim(adjustl(procname))//"_dz_SU"
open(111,file="../OUTPUT_FILES/SEM/syn/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file syn'
if ( ios /= 0 ) stop 'error opening file syn'
open(112,file="../OUTPUT_FILES/SEM/dat/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file dat'
if ( ios /= 0 ) stop 'error opening file dat'
open(113,file="../OUTPUT_FILES/SEM/"//trim(filename)//".adj", &
status='unknown',access='direct',action='write',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file .adj'
if ( ios /= 0 ) stop 'error opening file .adj'
irec=1
do while(ios==0)

Expand All @@ -173,7 +173,7 @@ program adj_seismogram
if (ios /= 0) exit

!daniel: outputs ascii trace
if( myrank == 0 .and. irec == 196 ) then
if ( myrank == 0 .and. irec == 196 ) then
open(221,file="../OUTPUT_FILES/SEM/syn/"//trim(filename)//".ascii",status='unknown')
do i=1,NSTEP
write(221,*) i,syn(i)
Expand Down
30 changes: 15 additions & 15 deletions EXAMPLES/BENCHMARK_CLAERBOUT_ADJOINT/ACOUSTIC/postprocessing.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program random_model
real(kind=4),dimension(:), allocatable :: adj

!! input parameters
if( iargc() /= 3 ) stop 'Usage: ./xpostprocessing NSTEP DT NPROC'
if ( iargc() /= 3 ) stop 'Usage: ./xpostprocessing NSTEP DT NPROC'
j=1; call getarg(j, arg); read(arg,*,iostat=ios) NSTEP; if (ios /= 0) stop 'Error reading NSTEP'
j=2; call getarg(j, arg); read(arg,*,iostat=ios) DT; if (ios /= 0) stop 'Error reading DT'
j=3; call getarg(j, arg); read(arg,*,iostat=ios) NPROC; if (ios /= 0) stop 'Error reading NPROC'
Expand All @@ -40,33 +40,33 @@ program random_model

! nspec & nglob
open(unit=IOUT,file='./OUTPUT_FILES/DATABASES_MPI/'//trim(adjustl(prname))//'external_mesh.bin',status='old',action='read',form='unformatted',iostat=ier)
if( ier /= 0 ) stop 'error opening database proc######_external_mesh.bin'
if ( ier /= 0 ) stop 'error opening database proc######_external_mesh.bin'
read(IOUT) nspec
read(IOUT) nglob
close(IOUT)

! weights
allocate(weights(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array weights'
allocate(weights(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array weights'
open(unit=IOUT,file='./OUTPUT_FILES/DATABASES_MPI/'//trim(adjustl(prname))//'weights_kernel.bin',status='old',action='read',form='unformatted',iostat=ier)
read(IOUT) weights
close(IOUT)

! kernels
allocate(krhop(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array krhop'
allocate(krhop(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array krhop'
open(unit=IOUT,file='./OUTPUT_FILES/DATABASES_MPI/'//trim(adjustl(prname))//'rhop_acoustic_kernel.bin',status='old',action='read',form='unformatted',iostat=ier)
read(IOUT) krhop
close(IOUT)

allocate(kalpha(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array kalpha'
allocate(kalpha(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array kalpha'
open(unit=IOUT,file='./OUTPUT_FILES/DATABASES_MPI/'//trim(adjustl(prname))//'alpha_acoustic_kernel.bin',status='old',action='read',form='unformatted',iostat=ier)
read(IOUT) kalpha
close(IOUT)

allocate(kbeta(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array kbeta'
allocate(kbeta(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array kbeta'

! rho
allocate(rho(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array rho'
allocate(rho0(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array rho0'
allocate(rho(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array rho'
allocate(rho0(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array rho0'
open(unit=IOUT,file='./models/target_model/'//trim(adjustl(prname))//'rho.bin',status='old',action='read',form='unformatted')
read(IOUT) rho
close(IOUT)
Expand All @@ -75,8 +75,8 @@ program random_model
close(IOUT)

! vp
allocate(vp(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array vp'
allocate(vp0(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array vp0'
allocate(vp(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array vp'
allocate(vp0(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array vp0'
open(unit=IOUT,file='./models/target_model/'//trim(adjustl(prname))//'vp.bin',status='old',action='read',form='unformatted')
read(IOUT) vp
close(IOUT)
Expand All @@ -85,8 +85,8 @@ program random_model
close(IOUT)

! vs
allocate(vs(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array vs'
allocate(vs0(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array vs0'
allocate(vs(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array vs'
allocate(vs0(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array vs0'

! F dm = S(m+dm) - S(m), we backpropogate syn-dat (see adj_seismogram.f90) => we have to add a minus sign in front of kernels
MODELSPACE=MODELSPACE + &
Expand All @@ -100,7 +100,7 @@ program random_model
write(procname,"(i4)") myrank
filename=trim(adjustl(procname))//"_dx_SU"
open(111,file="./OUTPUT_FILES/SEM/"//trim(adjustl(filename))//".adj",access='direct',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening adjoint trace'
if ( ios /= 0 ) stop 'error opening adjoint trace'
print *,' ',trim(adjustl(filename))//".adj"

irec=1
Expand All @@ -120,7 +120,7 @@ program random_model
!elastic case
! filename=trim(adjustl(procname))//"_dy_SU"
! open(111,file="../OUTPUT_FILES/SEM/"//trim(adjustl(filename))//".adj",access='direct',recl=240+4*NSTEP,iostat = ios)
! if( ios /= 0 ) stop 'error opening adjoint trace'
! if ( ios /= 0 ) stop 'error opening adjoint trace'
! print *,' ',trim(adjustl(filename))//".adj"
!
! irec=1
Expand All @@ -138,7 +138,7 @@ program random_model
!
! filename=trim(adjustl(procname))//"_dz_SU"
! open(111,file="../OUTPUT_FILES/SEM/"//trim(adjustl(filename))//".adj",access='direct',recl=240+4*NSTEP,iostat = ios)
! if( ios /= 0 ) stop 'error opening adjoint trace'
! if ( ios /= 0 ) stop 'error opening adjoint trace'
! print *,' ',trim(adjustl(filename))//".adj"
!
! irec=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,43 @@ program random_model
call MPI_Comm_Size(MPI_COMM_WORLD,NPROC,ier)

!! input parameters
if( iargc() /= 1 ) stop 'Usage: ./xrandom_model percent [must be small enough (~1d-5) for F*dm=S(m+dm)-S(m) to be valid]'
if ( iargc() /= 1 ) stop 'Usage: ./xrandom_model percent [must be small enough (~1d-5) for F*dm=S(m+dm)-S(m) to be valid]'
j=1; call getarg(j, arg); read(arg,*,iostat=ios) percent; if (ios /= 0) stop 'Error reading percent'

! processors name
write(prname,'(a,i6.6,a)') trim(LOCAL_PATH)//'proc',myrank,'_'
! nspec & nglob
open(unit=IOUT,file=trim(adjustl(prname))//'external_mesh.bin',status='old',action='read',form='unformatted',iostat=ier)
if( ier /= 0 ) stop 'error opening database proc######_external_mesh.bin'
if ( ier /= 0 ) stop 'error opening database proc######_external_mesh.bin'
read(IOUT) nspec
read(IOUT) nglob

! ibool file
allocate(ibool(NGLLX,NGLLY,NGLLZ,nspec),stat=ier)
if( ier /= 0 ) stop 'error allocating array ibool'
if ( ier /= 0 ) stop 'error allocating array ibool'
read(IOUT) ibool
! global point arrays
allocate(xstore(nglob),ystore(nglob),zstore(nglob),stat=ier)
if( ier /= 0 ) stop 'error allocating array xstore etc.'
if ( ier /= 0 ) stop 'error allocating array xstore etc.'
read(IOUT) xstore
read(IOUT) ystore
read(IOUT) zstore

close(IOUT)

! rho
allocate( rho_read(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array rho_read'
allocate( rho_read(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array rho_read'
open(unit=IOUT,file=trim(adjustl(prname))//'rho.bin',status='old',action='read',form='unformatted')
read(IOUT) rho_read
close(IOUT)

! vp
allocate( vp_read(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array vp_read'
allocate( vp_read(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array vp_read'
open(unit=IOUT,file=trim(adjustl(prname))//'vp.bin',status='old',action='read',form='unformatted')
read(IOUT) vp_read
close(IOUT)
! vs
allocate( vs_read(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array vs_read'
allocate( vs_read(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array vs_read'
open(unit=IOUT,file=trim(adjustl(prname))//'vs.bin',status='old',action='read',form='unformatted')
read(IOUT) vs_read
close(IOUT)
Expand All @@ -77,9 +77,9 @@ program random_model
! question: is the signal sensitive to this perturbation? or is it within numerical noise/artefacts?

! perturb model randomly
allocate( random(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if( ier /= 0 ) stop 'error allocating array random'
allocate( random(NGLLX,NGLLY,NGLLZ,nspec),stat=ier); if ( ier /= 0 ) stop 'error allocating array random'

if( .false. ) then
if ( .false. ) then

CALL RANDOM_SEED()

Expand Down Expand Up @@ -110,7 +110,7 @@ program random_model


! adds a Gaussian perturbation in the middle of the model
if( .true. ) then
if ( .true. ) then
! initializes perturbations
random(:,:,:,:) = 0.0

Expand All @@ -122,7 +122,7 @@ program random_model
sigma_h2 = 2.0 * sigma_h * sigma_h
sigma_v2 = 2.0 * sigma_v * sigma_v
! scalelength: approximately S ~ sigma * sqrt(8.0) for a Gaussian smoothing
if(myrank == 0 )print *," scalelengths horizontal,vertical (m): ",sigma_h*sqrt(8.0),sigma_v*sqrt(8.0)
if (myrank == 0 )print *," scalelengths horizontal,vertical (m): ",sigma_h*sqrt(8.0),sigma_v*sqrt(8.0)

! theoretic normal value
! (see integral over -inf to +inf of exp[- x*x/(2*sigma) ] = sigma * sqrt(2*pi) )
Expand Down Expand Up @@ -150,7 +150,7 @@ program random_model
! Gaussian function: values between [0,1]
random(i,j,k,ispec) = exp( - (dist_h*dist_h) / sigma_h2 - (dist_v*dist_v) / sigma_v2 )

!if(myrank == 0 )print *,random(i,j,k,ispec),x,y,z,dist_v,dist_h
!if (myrank == 0 )print *,random(i,j,k,ispec),x,y,z,dist_v,dist_h
enddo
enddo
enddo
Expand Down
26 changes: 13 additions & 13 deletions EXAMPLES/BENCHMARK_CLAERBOUT_ADJOINT/ELASTIC/adj_seismogram.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program adj_seismogram
write(procname,"(i4)") myrank

!! input parameters
if( iargc() /= 2 ) stop 'Usage: ./xadj NSTEP DT'
if ( iargc() /= 2 ) stop 'Usage: ./xadj NSTEP DT'
j=1; call getarg(j, arg); read(arg,*,iostat=ios) NSTEP; if (ios /= 0) stop 'Error reading NSTEP'
j=2; call getarg(j, arg); read(arg,*,iostat=ios) DT; if (ios /= 0) stop 'Error reading DT'

Expand Down Expand Up @@ -50,13 +50,13 @@ program adj_seismogram
filename=trim(adjustl(procname))//"_dx_SU"
open(111,file="../OUTPUT_FILES/SEM/syn/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file syn'
if ( ios /= 0 ) stop 'error opening file syn'
open(112,file="../OUTPUT_FILES/SEM/dat/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file dat'
if ( ios /= 0 ) stop 'error opening file dat'
open(113,file="../OUTPUT_FILES/SEM/"//trim(filename)//".adj", &
status='unknown',access='direct',action='write',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file .adj'
if ( ios /= 0 ) stop 'error opening file .adj'

irec=1
do while(ios==0)
Expand All @@ -73,7 +73,7 @@ program adj_seismogram
if (ios /= 0) exit

!daniel: outputs ascii trace
if( myrank == 0 .and. irec == 196 ) then
if ( myrank == 0 .and. irec == 196 ) then
open(221,file="../OUTPUT_FILES/SEM/syn/"//trim(filename)//".ascii",status='unknown')
do i=1,NSTEP
write(221,*) i,syn(i)
Expand Down Expand Up @@ -101,13 +101,13 @@ program adj_seismogram
filename=trim(adjustl(procname))//"_dy_SU"
open(111,file="../OUTPUT_FILES/SEM/syn/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file syn'
if ( ios /= 0 ) stop 'error opening file syn'
open(112,file="../OUTPUT_FILES/SEM/dat/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file dat'
if ( ios /= 0 ) stop 'error opening file dat'
open(113,file="../OUTPUT_FILES/SEM/"//trim(filename)//".adj", &
status='unknown',access='direct',action='write',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file .adj'
if ( ios /= 0 ) stop 'error opening file .adj'

irec=1
do while(ios==0)
Expand All @@ -123,7 +123,7 @@ program adj_seismogram
if (ios /= 0) exit

!daniel: outputs ascii trace
if( myrank == 0 .and. irec == 196 ) then
if ( myrank == 0 .and. irec == 196 ) then
open(221,file="../OUTPUT_FILES/SEM/syn/"//trim(filename)//".ascii",status='unknown')
do i=1,NSTEP
write(221,*) i,syn(i)
Expand Down Expand Up @@ -152,13 +152,13 @@ program adj_seismogram
filename=trim(adjustl(procname))//"_dz_SU"
open(111,file="../OUTPUT_FILES/SEM/syn/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file syn'
if ( ios /= 0 ) stop 'error opening file syn'
open(112,file="../OUTPUT_FILES/SEM/dat/"//trim(filename), &
status='old',access='direct',action='read',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file dat'
if ( ios /= 0 ) stop 'error opening file dat'
open(113,file="../OUTPUT_FILES/SEM/"//trim(filename)//".adj", &
status='unknown',access='direct',action='write',recl=240+4*NSTEP,iostat = ios)
if( ios /= 0 ) stop 'error opening file .adj'
if ( ios /= 0 ) stop 'error opening file .adj'
irec=1
do while(ios==0)

Expand All @@ -173,7 +173,7 @@ program adj_seismogram
if (ios /= 0) exit

!daniel: outputs ascii trace
if( myrank == 0 .and. irec == 196 ) then
if ( myrank == 0 .and. irec == 196 ) then
open(221,file="../OUTPUT_FILES/SEM/syn/"//trim(filename)//".ascii",status='unknown')
do i=1,NSTEP
write(221,*) i,syn(i)
Expand Down
Loading

0 comments on commit 85e9caa

Please sign in to comment.