[cig-commits] [commit] devel: small code beautify (2601232)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Jan 8 12:32:25 PST 2015


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

On branch  : devel
Link       : https://github.com/geodynamics/specfem3d_globe/compare/133892d126073f174444ba2cb859e8cc72f5478e...26012327b8c1188970d7f84c8ae99412761cae82

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

commit 26012327b8c1188970d7f84c8ae99412761cae82
Author: daniel peter <peterda at ethz.ch>
Date:   Thu Jan 8 21:10:12 2015 +0100

    small code beautify


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

26012327b8c1188970d7f84c8ae99412761cae82
 .../global_long/adj_traveltime_filter.f90          |  2 +-
 .../global_short/adj_traveltime_filter.f90         |  2 +-
 .../regional/adj_traveltime_filter.f90             |  2 +-
 .../test_global/adj_traveltime_filter.f90          |  2 +-
 .../test_regional/adj_traveltime_filter.f90        |  2 +-
 .../adj_traveltime_filter.f90                      |  2 +-
 src/auxiliaries/create_movie_GMT_global.f90        |  4 +-
 src/meshfem3D/model_cem.f90                        | 11 ++--
 src/shared/calendar.f90                            | 36 +++++------
 src/shared/save_header_file.F90                    |  2 +-
 src/shared/search_kdtree.f90                       | 72 +++++++++++-----------
 src/specfem3D/comp_source_time_function.f90        |  2 +-
 src/specfem3D/compute_stacey_crust_mantle.f90      |  2 +-
 src/specfem3D/get_attenuation.f90                  | 14 ++---
 src/specfem3D/get_cmt.f90                          |  4 +-
 src/specfem3D/iterate_time_undoatt.F90             |  6 +-
 src/specfem3D/prepare_timerun.f90                  | 12 ++--
 src/specfem3D/read_mesh_databases.F90              |  6 +-
 src/tomography/add_model_iso.f90                   |  2 +-
 src/tomography/add_model_tiso.f90                  |  4 +-
 src/tomography/add_model_tiso_cg.f90               |  4 +-
 src/tomography/add_model_tiso_iso.f90              |  2 +-
 src/tomography/addition_sem.f90                    | 10 +--
 src/tomography/compute_kernel_integral.f90         |  2 +-
 src/tomography/convert_model_file_adios.f90        |  8 +--
 src/tomography/difference_sem.f90                  | 10 +--
 src/tomography/get_gradient_cg.f90                 |  3 +-
 src/tomography/interpolate_model.F90               | 40 ++++++------
 src/tomography/smooth_sem.F90                      |  6 +-
 utils/Profiles/write_profile.f90                   |  8 +--
 30 files changed, 137 insertions(+), 145 deletions(-)

diff --git a/EXAMPLES/noise_examples/global_long/adj_traveltime_filter.f90 b/EXAMPLES/noise_examples/global_long/adj_traveltime_filter.f90
index 6a48b78..13998cc 100644
--- a/EXAMPLES/noise_examples/global_long/adj_traveltime_filter.f90
+++ b/EXAMPLES/noise_examples/global_long/adj_traveltime_filter.f90
@@ -128,7 +128,7 @@ do irec = 1,nrec
    I(:)=(length_window-1)
    data_trace=data_filtered(:,irec)
     syn_trace= syn_filtered(:,irec)
-!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max)) ) then
+!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max))) then
    if (1 == 1) then
       !!!! cross-correlation !!!!
       do i_start_window = (nstep+1)/2, (nstep+1)/2                                 !the positive branch
diff --git a/EXAMPLES/noise_examples/global_short/adj_traveltime_filter.f90 b/EXAMPLES/noise_examples/global_short/adj_traveltime_filter.f90
index 193e1bd..77d02ed 100644
--- a/EXAMPLES/noise_examples/global_short/adj_traveltime_filter.f90
+++ b/EXAMPLES/noise_examples/global_short/adj_traveltime_filter.f90
@@ -128,7 +128,7 @@ do irec = 1,nrec
    I(:)=(length_window-1)
    data_trace=data_filtered(:,irec)
     syn_trace= syn_filtered(:,irec)
-!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max)) ) then
+!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max))) then
    if (1 == 1) then
       !!!! cross-correlation !!!!
       do i_start_window = (nstep+1)/2, (nstep+1)/2                                 !the positive branch
diff --git a/EXAMPLES/noise_examples/regional/adj_traveltime_filter.f90 b/EXAMPLES/noise_examples/regional/adj_traveltime_filter.f90
index 193e1bd..77d02ed 100644
--- a/EXAMPLES/noise_examples/regional/adj_traveltime_filter.f90
+++ b/EXAMPLES/noise_examples/regional/adj_traveltime_filter.f90
@@ -128,7 +128,7 @@ do irec = 1,nrec
    I(:)=(length_window-1)
    data_trace=data_filtered(:,irec)
     syn_trace= syn_filtered(:,irec)
-!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max)) ) then
+!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max))) then
    if (1 == 1) then
       !!!! cross-correlation !!!!
       do i_start_window = (nstep+1)/2, (nstep+1)/2                                 !the positive branch
diff --git a/EXAMPLES/noise_examples/test_global/adj_traveltime_filter.f90 b/EXAMPLES/noise_examples/test_global/adj_traveltime_filter.f90
index 603aaae..60aee97 100644
--- a/EXAMPLES/noise_examples/test_global/adj_traveltime_filter.f90
+++ b/EXAMPLES/noise_examples/test_global/adj_traveltime_filter.f90
@@ -128,7 +128,7 @@ do irec = 1,nrec
    I(:)=(length_window-1)
    data_trace=data_filtered(:,irec)
     syn_trace= syn_filtered(:,irec)
-!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max)) ) then
+!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max))) then
    if (1 == 1) then
       !!!! cross-correlation !!!!
       do i_start_window = (nstep+1)/2, (nstep+1)/2                                 !the positive branch
diff --git a/EXAMPLES/noise_examples/test_regional/adj_traveltime_filter.f90 b/EXAMPLES/noise_examples/test_regional/adj_traveltime_filter.f90
index 603aaae..60aee97 100644
--- a/EXAMPLES/noise_examples/test_regional/adj_traveltime_filter.f90
+++ b/EXAMPLES/noise_examples/test_regional/adj_traveltime_filter.f90
@@ -128,7 +128,7 @@ do irec = 1,nrec
    I(:)=(length_window-1)
    data_trace=data_filtered(:,irec)
     syn_trace= syn_filtered(:,irec)
-!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max)) ) then
+!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max))) then
    if (1 == 1) then
       !!!! cross-correlation !!!!
       do i_start_window = (nstep+1)/2, (nstep+1)/2                                 !the positive branch
diff --git a/EXAMPLES/regional_Greece_noise_small/adj_traveltime_filter.f90 b/EXAMPLES/regional_Greece_noise_small/adj_traveltime_filter.f90
index 8966a1d..ce57a9d 100644
--- a/EXAMPLES/regional_Greece_noise_small/adj_traveltime_filter.f90
+++ b/EXAMPLES/regional_Greece_noise_small/adj_traveltime_filter.f90
@@ -142,7 +142,7 @@ do irec = 1,nrec
    I(:)=(length_window-1)
    data_trace=data_filtered(:,irec)
     syn_trace= syn_filtered(:,irec)
-!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max)) ) then
+!   if ( ( trace_data_max(irec) > (factor*data_max) ) .and. (trace_syn_max(irec) > (factor*syn_max))) then
    if (1 == 1) then
       !!!! cross-correlation !!!!
       do i_start_window = (nstep+1)/2, (nstep+1)/2                                 !the positive branch
diff --git a/src/auxiliaries/create_movie_GMT_global.f90 b/src/auxiliaries/create_movie_GMT_global.f90
index 57088a9..50e95db 100644
--- a/src/auxiliaries/create_movie_GMT_global.f90
+++ b/src/auxiliaries/create_movie_GMT_global.f90
@@ -414,7 +414,7 @@
       print*,'simulation time: ',(it-1)*DT - t0,'(s)'
 
       ! muting radius grows/shrinks with time
-      if ((it-1)*DT - t0 > STARTTIME_TO_MUTE ) then
+      if ((it-1)*DT - t0 > STARTTIME_TO_MUTE) then
 
         ! approximate wavefront travel distance in degrees
         ! (~3.5 km/s wave speed for surface waves)
@@ -572,7 +572,7 @@
                   ! mutes source region values
                   if (distance < RADIUS_TO_MUTE) then
                     ! muting takes account of the event time
-                    if ((it-1)*DT-t0 > STARTTIME_TO_MUTE ) then
+                    if ((it-1)*DT-t0 > STARTTIME_TO_MUTE) then
                       ! wavefield will be tapered to mask out noise in source area
                       ! factor from 0 to 1
                       mute_factor = ( 0.5*(1.0 - cos(distance/RADIUS_TO_MUTE*PI)) )**6
diff --git a/src/meshfem3D/model_cem.f90 b/src/meshfem3D/model_cem.f90
index b5d1741..44da17d 100644
--- a/src/meshfem3D/model_cem.f90
+++ b/src/meshfem3D/model_cem.f90
@@ -76,10 +76,9 @@ subroutine model_cem_broadcast (myrank)
   call world_size (wSize)
 
   scaleval = dsqrt(PI*GRAV*RHOAV)
-  scale_GPa = (RHOAV / 1000.d0) * &
-      ((R_EARTH * scaleval / 1000.d0) ** 2)
+  scale_GPa = (RHOAV / 1000.d0) * ((R_EARTH * scaleval / 1000.d0) ** 2)
 
-  if ( CEM_ACCEPT ) then
+  if (CEM_ACCEPT) then
 
     call return_populated_arrays (reg1Bc, "vsv", 1)
     call return_populated_arrays (reg2Bc, "vsv", 2)
@@ -351,11 +350,11 @@ subroutine build_global_coordinates (nspec, nglob, iregion_code)
 
             rad = dsqrt ( x * x + y * y + z * z )
 
-            if      ( rad < R_670_KM .and. rad >= R_CMB_KM ) then
+            if      (rad < R_670_KM .and. rad >= R_CMB_KM) then
               region = 3
-            else if ( rad < R_400_KM .and. rad >= R_670_KM ) then
+            else if (rad < R_400_KM .and. rad >= R_670_KM) then
               region = 2
-            else if ( rad >= R_400_KM ) then
+            else if (rad >= R_400_KM) then
               region = 1
             endif
 
diff --git a/src/shared/calendar.f90 b/src/shared/calendar.f90
index 9d62a10..77d74cb 100644
--- a/src/shared/calendar.f90
+++ b/src/shared/calendar.f90
@@ -500,26 +500,24 @@
 ! Internally, we use variable "jyear" that does not have a jump
 ! from -1 (for 1 BC) to +1 (for 1 AD).
   if (abs(ioptn) <= 3) then
-   if (iyear > 0) then
+    if (iyear > 0) then
       jyear = iyear
-   else if (iyear == 0) then
+    else if (iyear == 0) then
       write(*,*) 'For calndr(), you specified the nonexistent year 0'
       stop
-   else
+    else
       jyear = iyear + 1
-   endif
-!
-!        Set "leap" equal to 0 if "jyear" is not a leap year
-!        and equal to 1 if it is a leap year.
-   leap = 0
-   if ((jyear/4)*4 == jyear) then
+    endif
+    !
+    !        Set "leap" equal to 0 if "jyear" is not a leap year
+    !        and equal to 1 if it is a leap year.
+    leap = 0
+    if ((jyear/4)*4 == jyear) then
       leap = 1
-   endif
-   if ((ioptn > 0)               .and. &
-         ((jyear/100)*100 == jyear) .and. &
-         ((jyear/400)*400 /= jyear)     ) then
-         leap = 0
-   endif
+    endif
+    if ((ioptn > 0) .and. ((jyear/100)*100 == jyear) .and. ((jyear/400)*400 /= jyear)) then
+      leap = 0
+    endif
   endif
 !
 ! Options 3-5 involve Julian Day numbers, which need a reference year
@@ -724,12 +722,10 @@
 !        We need to determine whether this is a leap year.
    leap = 0
    if ((jyear/4)*4 == jyear) then
-      leap = 1
+     leap = 1
    endif
-   if ((ioptn > 0)               .and. &
-      ((jyear/100)*100 == jyear) .and. &
-      ((jyear/400)*400 /= jyear)     ) then
-         leap = 0
+   if ((ioptn > 0) .and. ((jyear/100)*100 == jyear) .and. ((jyear/400)*400 /= jyear)) then
+     leap = 0
    endif
 !
 !        Now find the day number "iday".
diff --git a/src/shared/save_header_file.F90 b/src/shared/save_header_file.F90
index f7d02fa..4ec4b3a 100644
--- a/src/shared/save_header_file.F90
+++ b/src/shared/save_header_file.F90
@@ -438,7 +438,7 @@
   endif  ! regional chunk
 
   ! mesh averages
-  if (NCHUNKS /= 6 ) then
+  if (NCHUNKS /= 6) then
     ! regional mesh, variable chunk sizes
     num_elem_gc = int( 90.d0 / ANGULAR_WIDTH_XI_IN_DEGREES * 4 * NEX_XI )
     num_gll_gc = int( 90.d0 / ANGULAR_WIDTH_XI_IN_DEGREES * 4 * NEX_XI *(NGLLX-1) )
diff --git a/src/shared/search_kdtree.f90 b/src/shared/search_kdtree.f90
index d8bf947..78b5996 100644
--- a/src/shared/search_kdtree.f90
+++ b/src/shared/search_kdtree.f90
@@ -648,7 +648,7 @@ contains
   integer,dimension(:),allocatable :: workindex
 
   ! checks if anything to sort
-  if (ibound_lower > ibound_upper ) then
+  if (ibound_lower > ibound_upper) then
     nullify(node)
     return
   endif
@@ -675,7 +675,7 @@ contains
   !node%id = numnodes
 
   ! checks if final node
-  if (ibound_lower == ibound_upper ) then
+  if (ibound_lower == ibound_upper) then
     node%idim = 0
     node%ipoint = points_index(ibound_lower)
     ! done with this node
@@ -711,7 +711,7 @@ contains
     max = maxval(points_data(i,points_index(ibound_lower:ibound_upper)))
     range = max - min
     ! sets cut dimension where data has maximum range
-    if (range > range_max ) then
+    if (range > range_max) then
       range_max = range
       idim = i
       cut_value = 0.5d0 * ( min + max )
@@ -738,7 +738,7 @@ contains
   iupper = 0
   do i = ibound_lower,ibound_upper
     iloc = points_index(i)
-    if (points_data(idim,iloc) < cut_value ) then
+    if (points_data(idim,iloc) < cut_value) then
       ilower = ilower + 1
       workindex(ilower) = iloc
     else
@@ -813,9 +813,9 @@ contains
   endif
 
   ! outputs infos for a final node
-  if (.not. associated(node%left) .and. .not. associated(node%right) ) then
+  if (.not. associated(node%left) .and. .not. associated(node%right)) then
     ! checks info
-    if (node%idim /= 0 ) then
+    if (node%idim /= 0) then
       print*,'problem kd-tree node:',node%idim,node%ipoint,numnodes
       print*,'point x/y/z: ',points_data(:,node%ipoint)
       stop 'Error kd-tree node not correct'
@@ -831,10 +831,10 @@ contains
   endif
 
   ! checks child nodes
-  if (associated(node%left) ) then
+  if (associated(node%left)) then
     call print_kdtree(npoints,points_data,points_index,node%left,numnodes)
   endif
-  if (associated(node%right) ) then
+  if (associated(node%right)) then
     call print_kdtree(npoints,points_data,points_index,node%right,numnodes)
   endif
 
@@ -914,7 +914,7 @@ contains
   !  print*,'node distance',node%id,ipoint_min,dist_min
 
   ! in case this is a final node
-  if ( .not. associated(node%left) .and. .not. associated(node%right) ) then
+  if ( .not. associated(node%left) .and. .not. associated(node%right)) then
     ! checks node
     if (node%idim /= 0 ) stop 'Error searched node is not final node'
     if (node%ipoint < 1 ) stop 'Error searched node has wrong point index'
@@ -923,7 +923,7 @@ contains
     dist = get_distance_squared(xyz_target(:),points_data(:,node%ipoint))
     if (dist < dist_min) then
       ! debug
-      !if (ipoint_min < 1 ) then
+      !if (ipoint_min < 1) then
       !  print*,'new node distance',node%id,node%ipoint,dist
       !else
       !  print*,'     new distance',node%id,node%ipoint,dist
@@ -941,14 +941,14 @@ contains
   if (node%idim < 1 .or. node%idim > 3 ) stop 'Error searched node has invalid cut dimension'
 
   ! compares cut value
-  if (xyz_target(node%idim) < node%cut_value ) then
+  if (xyz_target(node%idim) < node%cut_value) then
     ! finds closer node in lower hemisphere
-    if (associated(node%left) ) then
+    if (associated(node%left)) then
       call find_nearest_node(npoints,points_data,node%left,xyz_target,ipoint_min,dist_min)
     endif
   else
     ! finds closer node in upper hemisphere
-    if (associated(node%right) ) then
+    if (associated(node%right)) then
       call find_nearest_node(npoints,points_data,node%right,xyz_target,ipoint_min,dist_min)
     endif
   endif
@@ -959,10 +959,10 @@ contains
   ! squared distance to cut plane
   dist = ( xyz_target(node%idim) - node%cut_value )**2
 
-  if (xyz_target(node%idim) < node%cut_value ) then
-    if (associated(node%right) ) then
+  if (xyz_target(node%idim) < node%cut_value) then
+    if (associated(node%right)) then
       ! checks right node as a final node
-      if (node%right%idim == 0 ) then
+      if (node%right%idim == 0) then
         dist = get_distance_squared(xyz_target(:),points_data(:,node%right%ipoint))
         if (dist <= dist_min) then
           ! stores minimum point
@@ -977,9 +977,9 @@ contains
       endif
     endif
   else
-    if (associated(node%left) ) then
+    if (associated(node%left)) then
       ! checks left node as a final node
-      if (node%left%idim == 0 ) then
+      if (node%left%idim == 0) then
         dist = get_distance_squared(xyz_target(:),points_data(:,node%left%ipoint))
         if (dist <= dist_min) then
           ! stores minimum point
@@ -1025,7 +1025,7 @@ contains
   double precision,dimension(3) :: xyz
 
   ! checks a final node
-  if ( .not. associated(node%left) .and. .not. associated(node%right) ) then
+  if ( .not. associated(node%left) .and. .not. associated(node%right)) then
     ! checks node
     if (node%idim /= 0 ) stop 'Error searched node is not final node'
     if (node%ipoint < 1 ) stop 'Error searched node has wrong point index'
@@ -1057,14 +1057,14 @@ contains
   if (node%idim < 1 .or. node%idim > 3 ) stop 'Error searched node has invalid cut dimension'
 
   ! compares cut value
-  if (xyz_target(node%idim) < node%cut_value ) then
+  if (xyz_target(node%idim) < node%cut_value) then
     ! finds closer node in lower hemisphere
-    if (associated(node%left) ) then
+    if (associated(node%left)) then
       call find_nearest_n_nodes(npoints,points_data,node%left,xyz_target,r_squared,num_nodes,fill_index)
     endif
   else
     ! finds closer node in upper hemisphere
-    if (associated(node%right) ) then
+    if (associated(node%right)) then
       call find_nearest_n_nodes(npoints,points_data,node%right,xyz_target,r_squared,num_nodes,fill_index)
     endif
   endif
@@ -1075,10 +1075,10 @@ contains
   ! squared distance to cut plane
   dist = ( xyz_target(node%idim) - node%cut_value )**2
 
-  if (xyz_target(node%idim) < node%cut_value ) then
-    if (associated(node%right) ) then
+  if (xyz_target(node%idim) < node%cut_value) then
+    if (associated(node%right)) then
       ! checks right node as a final node
-      if (node%right%idim == 0 ) then
+      if (node%right%idim == 0) then
         xyz(:) = points_data(:,node%right%ipoint)
         dist = get_distance_squared(xyz_target(:),xyz(:))
         if (dist <= r_squared) then
@@ -1100,9 +1100,9 @@ contains
       endif
     endif
   else
-    if (associated(node%left) ) then
+    if (associated(node%left)) then
       ! checks left node as a final node
-      if (node%left%idim == 0 ) then
+      if (node%left%idim == 0) then
         xyz(:) = points_data(:,node%left%ipoint)
         dist = get_distance_squared(xyz_target(:),xyz(:))
         if (dist <= r_squared) then
@@ -1155,7 +1155,7 @@ contains
   double precision,dimension(3) :: xyz
 
   ! checks a final node
-  if ( .not. associated(node%left) .and. .not. associated(node%right) ) then
+  if ( .not. associated(node%left) .and. .not. associated(node%right)) then
     ! checks node
     if (node%idim /= 0 ) stop 'Error searched node is not final node'
     if (node%ipoint < 1 ) stop 'Error searched node has wrong point index'
@@ -1187,15 +1187,15 @@ contains
   if (node%idim < 1 .or. node%idim > 3 ) stop 'Error searched node has invalid cut dimension'
 
   ! compares cut value
-  if (xyz_target(node%idim) < node%cut_value ) then
+  if (xyz_target(node%idim) < node%cut_value) then
     ! finds closer node in lower hemisphere
-    if (associated(node%left) ) then
+    if (associated(node%left)) then
       call find_nearest_n_nodes_ellip(npoints,points_data,node%left,xyz_target, &
                                       r_squared_v,r_squared_h,num_nodes,fill_index)
     endif
   else
     ! finds closer node in upper hemisphere
-    if (associated(node%right) ) then
+    if (associated(node%right)) then
       call find_nearest_n_nodes_ellip(npoints,points_data,node%right,xyz_target, &
                                       r_squared_v,r_squared_h,num_nodes,fill_index)
     endif
@@ -1207,10 +1207,10 @@ contains
   ! squared distance to cut plane
   dist = ( xyz_target(node%idim) - node%cut_value )**2
 
-  if (xyz_target(node%idim) < node%cut_value ) then
-    if (associated(node%right) ) then
+  if (xyz_target(node%idim) < node%cut_value) then
+    if (associated(node%right)) then
       ! checks right node as a final node
-      if (node%right%idim == 0 ) then
+      if (node%right%idim == 0) then
         xyz(:) = points_data(:,node%right%ipoint)
         call get_distance_ellip(xyz_target(:),xyz(:),dist_v,dist_h)
         if (dist_v <= r_squared_v .and. dist_h <= r_squared_h) then
@@ -1233,9 +1233,9 @@ contains
       endif
     endif
   else
-    if (associated(node%left) ) then
+    if (associated(node%left)) then
       ! checks left node as a final node
-      if (node%left%idim == 0 ) then
+      if (node%left%idim == 0) then
         xyz(:) = points_data(:,node%left%ipoint)
         call get_distance_ellip(xyz_target(:),xyz(:),dist_v,dist_h)
         if (dist_v <= r_squared_v .and. dist_h <= r_squared_h) then
diff --git a/src/specfem3D/comp_source_time_function.f90 b/src/specfem3D/comp_source_time_function.f90
index 7f81951..786a182 100644
--- a/src/specfem3D/comp_source_time_function.f90
+++ b/src/specfem3D/comp_source_time_function.f90
@@ -78,7 +78,7 @@
   implicit none
 
   ! On the first iteration, go get the ASCII file.
-  if ( .not. allocated (stfArray_external) ) then
+  if (.not. allocated (stfArray_external)) then
     call get_external_stf()
   endif
 
diff --git a/src/specfem3D/compute_stacey_crust_mantle.f90 b/src/specfem3D/compute_stacey_crust_mantle.f90
index abce745..ae6a05e 100644
--- a/src/specfem3D/compute_stacey_crust_mantle.f90
+++ b/src/specfem3D/compute_stacey_crust_mantle.f90
@@ -365,7 +365,7 @@
   if (NCHUNKS_VAL == 1 .or. ichunk == CHUNK_AC) then
 
     ! reads absorbing boundary values
-    if (nspec2D_xmin_crust_mantle > 0 ) then
+    if (nspec2D_xmin_crust_mantle > 0) then
       ! note: backward/reconstructed wavefields are read in after the Newmark time scheme in the first time loop
       !          this leads to a corresponding boundary condition at time index NSTEP - (it-1) = NSTEP - it + 1
       call read_abs(0,absorb_xmin_crust_mantle,reclen_xmin_crust_mantle,NSTEP-it+1)
diff --git a/src/specfem3D/get_attenuation.f90 b/src/specfem3D/get_attenuation.f90
index 8a512fd..5149994 100644
--- a/src/specfem3D/get_attenuation.f90
+++ b/src/specfem3D/get_attenuation.f90
@@ -87,12 +87,10 @@
 
   ! loops over elements
   do ispec = 1, vnspec
-
     ! loops over GLL points
     do k = 1, ATT3_VAL
       do j = 1, ATT2_VAL
         do i = 1, ATT1_VAL
-
           ! gets relaxation times for each standard linear solid
           do i_sls = 1,N_SLS
             tau_e(i_sls) = factor_common(i,j,k,i_sls,ispec)
@@ -242,11 +240,11 @@
 
   tauinv(:) = - 1.d0 / tau_s(:)
 
-  alphaval(:)  = 1.d0 + deltat*tauinv(:) + deltat**2*tauinv(:)**2 / 2.d0 + &
-                    deltat**3*tauinv(:)**3 / 6.d0 + deltat**4*tauinv(:)**4 / 24.d0
-  betaval(:)   = deltat / 2.d0 + deltat**2*tauinv(:) / 3.d0 &
-                + deltat**3*tauinv(:)**2 / 8.d0 + deltat**4*tauinv(:)**3 / 24.d0
-  gammaval(:)  = deltat / 2.d0 + deltat**2*tauinv(:) / 6.d0 &
-                + deltat**3*tauinv(:)**2 / 24.d0
+  alphaval(:) = 1.d0 + deltat*tauinv(:) + deltat**2*tauinv(:)**2 / 2.d0 &
+                  + deltat**3*tauinv(:)**3 / 6.d0 + deltat**4*tauinv(:)**4 / 24.d0
+  betaval(:)  = deltat / 2.d0 + deltat**2*tauinv(:) / 3.d0 &
+                  + deltat**3*tauinv(:)**2 / 8.d0 + deltat**4*tauinv(:)**3 / 24.d0
+  gammaval(:) = deltat / 2.d0 + deltat**2*tauinv(:) / 6.d0 &
+                  + deltat**3*tauinv(:)**2 / 24.d0
 
   end subroutine get_attenuation_memory_values
diff --git a/src/specfem3D/get_cmt.f90 b/src/specfem3D/get_cmt.f90
index cdac5aa..105a7d9 100644
--- a/src/specfem3D/get_cmt.f90
+++ b/src/specfem3D/get_cmt.f90
@@ -119,7 +119,7 @@
     do itype = 1,6
       ! determines where first number starts
       do i = istart,len_trim(string)
-        if (is_numeric(string(i:i)) ) then
+        if (is_numeric(string(i:i))) then
           istart = i
           exit
         endif
@@ -130,7 +130,7 @@
       ! determines end and length of number
       iend = istart
       do i = istart,len_trim(string)
-        if (itype /= 6 ) then
+        if (itype /= 6) then
           ! integer values
           if (.not. is_numeric(string(i:i))) then
             iend = i
diff --git a/src/specfem3D/iterate_time_undoatt.F90 b/src/specfem3D/iterate_time_undoatt.F90
index f991423..60cd334 100644
--- a/src/specfem3D/iterate_time_undoatt.F90
+++ b/src/specfem3D/iterate_time_undoatt.F90
@@ -55,7 +55,7 @@
 
   ! user output
   if (SAVE_FORWARD .or. SIMULATION_TYPE == 3) then
-    if (myrank == 0 ) then
+    if (myrank == 0) then
       write(IMAIN,*) 'undoing attenuation:'
       write(IMAIN,*) '  wavefield snapshots at every NT_DUMP_ATTENUATION = ',NT_DUMP_ATTENUATION
       call flush_IMAIN()
@@ -241,7 +241,7 @@
         enddo ! istage
 
         ! transfers wavefields from GPU to CPU for buffering
-        if (GPU_MODE ) then
+        if (GPU_MODE) then
           ! daniel debug: check if these transfers could be made async to overlap
           call transfer_b_displ_cm_from_device(NDIM*NGLOB_CRUST_MANTLE,b_displ_crust_mantle,Mesh_pointer)
           call transfer_b_displ_ic_from_device(NDIM*NGLOB_INNER_CORE,b_displ_inner_core,Mesh_pointer)
@@ -287,7 +287,7 @@
         enddo
 
         ! transfers wavefields from CPU to GPU
-        if (GPU_MODE ) then
+        if (GPU_MODE) then
           ! daniel debug: check if these transfers could be made async to overlap
           call transfer_b_displ_cm_to_device(NDIM*NGLOB_CRUST_MANTLE,b_displ_crust_mantle,Mesh_pointer)
           call transfer_b_displ_ic_to_device(NDIM*NGLOB_INNER_CORE,b_displ_inner_core,Mesh_pointer)
diff --git a/src/specfem3D/prepare_timerun.f90 b/src/specfem3D/prepare_timerun.f90
index f57ffbd..f168091 100644
--- a/src/specfem3D/prepare_timerun.f90
+++ b/src/specfem3D/prepare_timerun.f90
@@ -2083,7 +2083,7 @@
 
   ! prepares oceans arrays
   if (OCEANS_VAL) then
-    if (myrank == 0 ) then
+    if (myrank == 0) then
       write(IMAIN,*) "  loading oceans arrays"
       call flush_IMAIN()
     endif
@@ -2159,7 +2159,7 @@
 
   ! prepares LDDRK arrays
   if (USE_LDDRK) then
-    if (myrank == 0 ) then
+    if (myrank == 0) then
       write(IMAIN,*) "  loading LDDRK arrays"
       call flush_IMAIN()
     endif
@@ -2170,7 +2170,7 @@
   endif
 
   ! crust/mantle region
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     write(IMAIN,*) "  loading crust/mantle region"
     call flush_IMAIN()
   endif
@@ -2236,7 +2236,7 @@
   call synchronize_all()
 
   ! outer core region
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     write(IMAIN,*) "  loading outer core region"
     call flush_IMAIN()
   endif
@@ -2265,7 +2265,7 @@
   call synchronize_all()
 
   ! inner core region
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     write(IMAIN,*) "  loading inner core region"
     call flush_IMAIN()
   endif
@@ -2313,7 +2313,7 @@
   call synchronize_all()
 
   ! transfer forward and backward fields to device with initial values
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     write(IMAIN,*) "  transferring initial wavefield"
     call flush_IMAIN()
   endif
diff --git a/src/specfem3D/read_mesh_databases.F90 b/src/specfem3D/read_mesh_databases.F90
index 79501e4..6e7e4c2 100644
--- a/src/specfem3D/read_mesh_databases.F90
+++ b/src/specfem3D/read_mesh_databases.F90
@@ -1723,7 +1723,7 @@
       call exit_mpi(myrank,'Error allocating array phase_ispec_inner_crust_mantle')
   endif
 
-  if (num_phase_ispec_crust_mantle > 0 ) then
+  if (num_phase_ispec_crust_mantle > 0) then
     call bcast_all_i_for_database(phase_ispec_inner_crust_mantle(1,1), size(phase_ispec_inner_crust_mantle))
   endif
 
@@ -1814,7 +1814,7 @@
       call exit_mpi(myrank,'Error allocating array phase_ispec_inner_outer_core')
   endif
 
-  if (num_phase_ispec_outer_core > 0 ) then
+  if (num_phase_ispec_outer_core > 0) then
     call bcast_all_i_for_database(phase_ispec_inner_outer_core(1,1), size(phase_ispec_inner_outer_core))
   endif
 
@@ -1903,7 +1903,7 @@
       call exit_mpi(myrank,'Error allocating array phase_ispec_inner_inner_core')
   endif
 
-  if (num_phase_ispec_inner_core > 0 ) then
+  if (num_phase_ispec_inner_core > 0) then
     call bcast_all_i_for_database(phase_ispec_inner_inner_core(1,1), size(phase_ispec_inner_inner_core))
   endif
 
diff --git a/src/tomography/add_model_iso.f90 b/src/tomography/add_model_iso.f90
index 144fa9b..2c7ddd0 100644
--- a/src/tomography/add_model_iso.f90
+++ b/src/tomography/add_model_iso.f90
@@ -211,7 +211,7 @@ subroutine initialize()
   call world_size(sizeprocs)
   call world_rank(myrank)
 
-  if (sizeprocs /= NPROCTOT_VAL ) then
+  if (sizeprocs /= NPROCTOT_VAL) then
     if (myrank == 0) then
       print*, 'Error number of processors supposed to run on : ',NPROCTOT_VAL
       print*, 'Error number of MPI processors actually run on: ',sizeprocs
diff --git a/src/tomography/add_model_tiso.f90 b/src/tomography/add_model_tiso.f90
index 6a6566d..f3c90f0 100644
--- a/src/tomography/add_model_tiso.f90
+++ b/src/tomography/add_model_tiso.f90
@@ -155,7 +155,7 @@ program add_model
           alphah1 = 0._CUSTOM_REAL
 
           ! do not use transverse isotropy except if element is between d220 and Moho
-!          if (.not. ( idoubling(ispec)==IFLAG_220_80 .or. idoubling(ispec)==IFLAG_80_MOHO) ) then
+!          if (.not. ( idoubling(ispec)==IFLAG_220_80 .or. idoubling(ispec)==IFLAG_80_MOHO)) then
           if (.not. ispec_is_tiso(ispec)) then
             ! isotropic model update
 
@@ -260,7 +260,7 @@ subroutine initialize()
   call world_size(sizeprocs)
   call world_rank(myrank)
 
-  if (sizeprocs /= NPROCTOT_VAL ) then
+  if (sizeprocs /= NPROCTOT_VAL) then
     if (myrank == 0) then
       print*, 'Error number of processors supposed to run on : ',NPROCTOT_VAL
       print*, 'Error number of MPI processors actually run on: ',sizeprocs
diff --git a/src/tomography/add_model_tiso_cg.f90 b/src/tomography/add_model_tiso_cg.f90
index 3c8ad0a..9481e97 100644
--- a/src/tomography/add_model_tiso_cg.f90
+++ b/src/tomography/add_model_tiso_cg.f90
@@ -172,7 +172,7 @@ program add_model
           alphah1 = 0._CUSTOM_REAL
 
           ! do not use transverse isotropy except if element is between d220 and Moho
-!          if (.not. ( idoubling(ispec)==IFLAG_220_80 .or. idoubling(ispec)==IFLAG_80_MOHO) ) then
+!          if (.not. ( idoubling(ispec)==IFLAG_220_80 .or. idoubling(ispec)==IFLAG_80_MOHO)) then
           if (.not. ispec_is_tiso(ispec)) then
             ! isotropic model update
 
@@ -277,7 +277,7 @@ subroutine initialize()
   call world_size(sizeprocs)
   call world_rank(myrank)
 
-  if (sizeprocs /= NPROCTOT_VAL ) then
+  if (sizeprocs /= NPROCTOT_VAL) then
     if (myrank == 0) then
       print*, 'Error number of processors supposed to run on : ',NPROCTOT_VAL
       print*, 'Error number of MPI processors actually run on: ',sizeprocs
diff --git a/src/tomography/add_model_tiso_iso.f90 b/src/tomography/add_model_tiso_iso.f90
index 847af9e..cad97e9 100644
--- a/src/tomography/add_model_tiso_iso.f90
+++ b/src/tomography/add_model_tiso_iso.f90
@@ -241,7 +241,7 @@ subroutine initialize()
   call world_size(sizeprocs)
   call world_rank(myrank)
 
-  if (sizeprocs /= NPROCTOT_VAL ) then
+  if (sizeprocs /= NPROCTOT_VAL) then
     if (myrank == 0) then
       print*, 'Error number of processors supposed to run on : ',NPROCTOT_VAL
       print*, 'Error number of MPI processors actually run on: ',sizeprocs
diff --git a/src/tomography/addition_sem.f90 b/src/tomography/addition_sem.f90
index 217aea9..3dea025 100644
--- a/src/tomography/addition_sem.f90
+++ b/src/tomography/addition_sem.f90
@@ -67,7 +67,7 @@ program addition_sem
   call world_rank(myrank)
 
   ! checks compilation setup
-  if (sizeprocs /= NPROCTOT_VAL ) then
+  if (sizeprocs /= NPROCTOT_VAL) then
     if (myrank == 0) then
       print*, 'Error number of processors supposed to run on : ',NPROCTOT_VAL
       print*, 'Error number of MPI processors actually run on: ',sizeprocs
@@ -181,7 +181,7 @@ program addition_sem
     ! reads in file from first directory
     if(myrank==0) write(*,*) '  data_1: ',trim(file1name)
     open(IIN,file=trim(file1name),status='old',form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file1name)
       stop 'Error opening first data file'
     endif
@@ -191,7 +191,7 @@ program addition_sem
     ! reads in file from second directory
     if (myrank == 0) write(*,*) '  data_2: ',trim(file2name)
     open(IIN,file=trim(file2name),status='old',form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file2name)
       stop 'Error opening second data file'
     endif
@@ -212,7 +212,7 @@ program addition_sem
     write(file1name,'(a,i6.6,a)') trim(outputdir)//'/proc',iproc,'_'//trim(reg_name)//trim(kernel_name)//'_add.bin'
     if (myrank == 0) write(*,*) '  file: ',trim(file1name)
     open(IOUT,file=trim(file1name),form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file1name)
       stop 'Error opening output data file'
     endif
@@ -233,7 +233,7 @@ program addition_sem
     write(file1name,'(a,i6.6,a)') trim(outputdir)//'/proc',iproc,'_'//trim(reg_name)//trim(kernel_name)//'_add_relative.bin'
     if (myrank == 0) write(*,*) '  file: ',trim(file1name)
     open(IOUT,file=trim(file1name),form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file1name)
       stop 'Error opening output data file'
     endif
diff --git a/src/tomography/compute_kernel_integral.f90 b/src/tomography/compute_kernel_integral.f90
index 00b9d30..61d9bcc 100644
--- a/src/tomography/compute_kernel_integral.f90
+++ b/src/tomography/compute_kernel_integral.f90
@@ -572,7 +572,7 @@ subroutine compute_kernel_integral_tiso_iso()
           norm_rho = norm_rho + kernel_rho(i,j,k,ispec)**2
 
           ! checks number
-          if (integral_bulk /= integral_bulk ) then
+          if (integral_bulk /= integral_bulk) then
             print*,'Error NaN: ',integral_bulk
             print*,'rank:',myrank
             print*,'i,j,k,ispec:',i,j,k,ispec
diff --git a/src/tomography/convert_model_file_adios.f90 b/src/tomography/convert_model_file_adios.f90
index 4948f24..9074816 100644
--- a/src/tomography/convert_model_file_adios.f90
+++ b/src/tomography/convert_model_file_adios.f90
@@ -288,7 +288,7 @@ program convert_model_file_adios
       endif
       ! adds shear attenuation
       if (USE_ATTENUATION_Q) then
-        if (iker == nparams ) then
+        if (iker == nparams) then
            model_qmu(:,:,:,:) = model(:,:,:,:)
         endif
       endif
@@ -361,7 +361,7 @@ program convert_model_file_adios
       endif
       ! adds shear attenuation
       if (USE_ATTENUATION_Q) then
-        if (iker == nparams ) then
+        if (iker == nparams) then
           ! qmu model
           write(IOUT) model_qmu
         endif
@@ -436,7 +436,7 @@ program convert_model_file_adios
       endif
       ! adds shear attenuation
       if (USE_ATTENUATION_Q) then
-        if (iker == nparams ) then
+        if (iker == nparams) then
           ! qmu model
           read(IIN) model_qmu
         endif
@@ -509,7 +509,7 @@ program convert_model_file_adios
       endif
       ! adds shear attenuation
       if (USE_ATTENUATION_Q) then
-        if (iker == nparams ) then
+        if (iker == nparams) then
           ! qmu model
           model(:,:,:,:) = model_qmu(:,:,:,:)
         endif
diff --git a/src/tomography/difference_sem.f90 b/src/tomography/difference_sem.f90
index 4777ad5..b636c41 100644
--- a/src/tomography/difference_sem.f90
+++ b/src/tomography/difference_sem.f90
@@ -67,7 +67,7 @@ program difference_sem
   call world_rank(myrank)
 
   ! checks compilation setup
-  if (sizeprocs /= NPROCTOT_VAL ) then
+  if (sizeprocs /= NPROCTOT_VAL) then
     if (myrank == 0) then
       print*, 'Error number of processors supposed to run on : ',NPROCTOT_VAL
       print*, 'Error number of MPI processors actually run on: ',sizeprocs
@@ -181,7 +181,7 @@ program difference_sem
     ! reads in file from first directory
     if(myrank==0) write(*,*) '  data_1: ',trim(file1name)
     open(IIN,file=trim(file1name),status='old',form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file1name)
       stop 'Error opening first data file'
     endif
@@ -191,7 +191,7 @@ program difference_sem
     ! reads in file from second directory
     if (myrank == 0) write(*,*) '  data_2: ',trim(file2name)
     open(IIN,file=trim(file2name),status='old',form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file2name)
       stop 'Error opening second data file'
     endif
@@ -212,7 +212,7 @@ program difference_sem
     write(file1name,'(a,i6.6,a)') trim(outputdir)//'/proc',iproc,'_'//trim(reg_name)//trim(kernel_name)//'_diff.bin'
     if (myrank == 0) write(*,*) '  file: ',trim(file1name)
     open(IOUT,file=trim(file1name),form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file1name)
       stop 'Error opening output data file'
     endif
@@ -233,7 +233,7 @@ program difference_sem
     write(file1name,'(a,i6.6,a)') trim(outputdir)//'/proc',iproc,'_'//trim(reg_name)//trim(kernel_name)//'_diff_relative.bin'
     if (myrank == 0) write(*,*) '  file: ',trim(file1name)
     open(IOUT,file=trim(file1name),form='unformatted',iostat=ier)
-    if (ier /= 0 ) then
+    if (ier /= 0) then
       print *,'Error opening file: ',trim(file1name)
       stop 'Error opening output data file'
     endif
diff --git a/src/tomography/get_gradient_cg.f90 b/src/tomography/get_gradient_cg.f90
index b2ffeca..28c7929 100644
--- a/src/tomography/get_gradient_cg.f90
+++ b/src/tomography/get_gradient_cg.f90
@@ -132,8 +132,7 @@ subroutine get_gradient_cg_tiso()
     print*,'  betah: ',ratio_betah
     print*,'  eta  : ',ratio_eta
     print*
-    if (ratio_bulk > 0.2 .and. ratio_betav > 0.2 .and. ratio_betah > 0.2 &
-      .and. ratio_eta > 0.2 ) then
+    if (ratio_bulk > 0.2 .and. ratio_betav > 0.2 .and. ratio_betah > 0.2 .and. ratio_eta > 0.2) then
       print*,'  critical ratio found!'
       print*
       print*,'****************'
diff --git a/src/tomography/interpolate_model.F90 b/src/tomography/interpolate_model.F90
index f0c825c..3bd60d4 100644
--- a/src/tomography/interpolate_model.F90
+++ b/src/tomography/interpolate_model.F90
@@ -204,7 +204,7 @@
 
 
   ! checks program arguments
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     do i = 1,4
       call get_command_argument(i,arg)
       ! usage info
@@ -245,7 +245,7 @@
       output_model_dir = trim(arg)
     end select
     if (.not. DO_BRUTE_FORCE_SEARCH) then
-      if (i == 5 .and. len_trim(arg) > 0 ) then
+      if (i == 5 .and. len_trim(arg) > 0) then
         read(arg(1:len_trim(arg)),*,iostat=ier) want_midpoint
         if (ier /= 0) then
           if (myrank == 0) print*,'Error reading in midpoint-search value, please check your arguments...'
@@ -313,7 +313,7 @@
   endif
 
   ! master process gets old, source mesh dimension
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     ! gets nspec/nglob
     write(solver_file,'(a,i6.6,a)') trim(dir_topo1)//'proc',myrank,'_reg1_'//'solver_data.bin'
     open(IIN,file=trim(solver_file),status='old',form='unformatted',iostat=ier)
@@ -330,7 +330,7 @@
     do while (ier == 0)
       write(solver_file,'(a,i6.6,a)') trim(dir_topo1)//'proc',rank,'_reg1_'//'solver_data.bin'
       open(IIN,file=trim(solver_file),status='old',form='unformatted',iostat=ier)
-      if (ier == 0 ) then
+      if (ier == 0) then
         rank = rank + 1
         close(IIN)
       endif
@@ -412,7 +412,7 @@
   if (sizeprocs /= NPROCTOT_VAL) stop 'Error target mesh processors not equal to current total mpi processes'
 
   ! checks temporary file creation, to see if we could write out new model
-  if (myrank == 0 ) then
+  if (myrank == 0) then
     write(m_file,'(a,i6.6,a)') trim(output_model_dir)// '/proc',myrank,'_reg1_'//trim(fname(1))//'.tmp'
     open(IOUT,file=trim(m_file),status='unknown',form='unformatted',iostat=ier)
     if (ier /= 0) then
@@ -547,7 +547,7 @@
       read(IIN) nglob
 
       ! checks dimensions
-      if (nspec /= nspec_max_old .or. nglob /= nglob_max_old ) then
+      if (nspec /= nspec_max_old .or. nglob /= nglob_max_old) then
         print*,'Error dimension of old, source mesh: solver_data nspec/nglob = ',nspec,nglob
         stop 'Error new mesh dimensions'
       endif
@@ -642,7 +642,7 @@
   read(IIN) nglob
 
   ! checks dimensions
-  if (nspec /= NSPEC_CRUST_MANTLE .or. nglob /= NGLOB_CRUST_MANTLE ) then
+  if (nspec /= NSPEC_CRUST_MANTLE .or. nglob /= NGLOB_CRUST_MANTLE) then
     print*,'Error dimension of new mesh: solver_data nspec/nglob = ',nspec,nglob
     stop 'Error new mesh dimensions'
   endif
@@ -656,7 +656,7 @@
   close(IIN)
 
   ! checks that layers match
-  if (minval(idoubling1) /= minval(idoubling2) .or. maxval(idoubling1) /= maxval(idoubling2) ) then
+  if (minval(idoubling1) /= minval(idoubling2) .or. maxval(idoubling1) /= maxval(idoubling2)) then
     print*,'Error idoubling range:'
     print*,'idoubling 1:',minval(idoubling1),maxval(idoubling1)
     print*,'idoubling 2:',minval(idoubling2),maxval(idoubling2)
@@ -708,7 +708,7 @@
           iprocnum = iprocnum + 1
           ! all elements
           do ispec = 1, nspec_max_old
-            if (idoubling1(ispec,iprocnum-1) == ilayer ) then
+            if (idoubling1(ispec,iprocnum-1) == ilayer) then
               if (TREE_INTERNAL_GLL_POINTS) then
                 ! all internal gll points ( 2 to NGLLX-1 )
                 inodes = inodes + (NGLLX-2)*(NGLLY-2)*(NGLLZ-2)
@@ -833,7 +833,7 @@
     do ispec = 1, nspec
       ! user output
       if (myrank == 0) then
-        if (ispec == 1 .or. mod(ispec,int(0.1*nspec)) == 0 .or. ispec == nspec ) then
+        if (ispec == 1 .or. mod(ispec,int(0.1*nspec)) == 0 .or. ispec == nspec) then
           print*,'  ispec',ispec,' out of ',nspec
         endif
       endif
@@ -1332,7 +1332,7 @@
 
         ! checks distance
         dist_min = sqrt((x_found-x_target)**2 + (y_found-y_target)**2 + (z_found-z_target)**2)
-        if (dist_min > 2 * typical_size ) then
+        if (dist_min > 2 * typical_size) then
           print*,'Warning: rank ',myrank,' - large dist_min: ',dist_min * R_EARTH_KM,'(km)', &
                  'element size:',typical_size * R_EARTH_KM
           print*,'target location:',xyz_target(:)
@@ -1375,7 +1375,7 @@
           ! checks model difference
           if (DO_WARNING) then
             ! note: warns for top elements, probably due to crustal structure
-            if (abs(val - val_initial ) > abs( 0.2 * val_initial ) ) then
+            if (abs(val - val_initial ) > abs( 0.2 * val_initial )) then
               print*,'Warning: model ',iker,' value:',val,'is very different from initial value ',val_initial
               print*,'  rank ',myrank,' - dist_min: ',dist_min * R_EARTH_KM,'(km)'
               print*,'  element',ispec,'selected ispec:',ispec_selected,'in rank:',rank_selected,'iglob_min:',iglob_min
@@ -1408,21 +1408,21 @@
     implicit none
 
     ! checks valid iglob
-    if (iglob_min < 1 .or. iglob_min > nspec_max_old * nproc_chunk1 ) then
+    if (iglob_min < 1 .or. iglob_min > nspec_max_old * nproc_chunk1) then
       print*,'Error iglob_min :',iglob_min
       print*,'nspec / nproc :',nspec_max_old,nproc_chunk1
       stop 'Error invalid iglob_min index'
     endif
 
     ! checks valid rank
-    if (rank_selected < 0 .or. rank_selected >= nproc_chunk1 ) then
+    if (rank_selected < 0 .or. rank_selected >= nproc_chunk1) then
       print*,'Error rank:',myrank,'invalid selected rank ',rank_selected,'for element',ispec
       print*,'target location:',xyz_target(:)
       stop 'Error specifying closest rank for element'
     endif
 
     ! checks valid ispec
-    if (ispec_selected < 1 .or. ispec_selected > nspec_max_old ) then
+    if (ispec_selected < 1 .or. ispec_selected > nspec_max_old) then
       print*,'Error rank:',myrank,'invalid selected ispec ',ispec_selected,'for element',ispec
       print*,'rank_selected:',rank_selected,'iglob_min:',iglob_min,'nspec_max_old:',nspec_max_old
       print*,'target location:',xyz_target(:)
@@ -1431,7 +1431,7 @@
     endif
 
     ! checks minimum distance within a typical element size
-    if (dist_min > 2 * typical_size ) then
+    if (dist_min > 2 * typical_size) then
       print*,'Warning: rank ',myrank,' - large dist_min: ',dist_min * R_EARTH_KM,'(km)', &
              'element size:',typical_size * R_EARTH_KM
       print*,'element',ispec,'selected ispec:',ispec_selected,'in rank:',rank_selected,'iglob_min:',iglob_min
@@ -1734,7 +1734,7 @@
 ! debug
 !      if (ier /= 0) then
 !        ! debug
-!        if ( .true. ) then
+!        if (.true.) then
 !          print*,'jacobian error in locate_single(): '
 !          print*,'jacobian error i,j,k,ispec :',ix_initial_guess,iy_initial_guess,iz_initial_guess,ispec_selected
 !          print*,'jacobian error iter_loop   :',iter_loop
@@ -1792,7 +1792,7 @@
       !if (gamma < -1.10d0) gamma = -1.10d0
 
       ! point leaves element, stay to closest guess
-      if (xi > 1.10d0 .or. xi < -1.10d0 .or. eta > 1.10d0 .or. eta < -1.10d0 .or. gamma > 1.10d0 .or. gamma < -1.10d0 ) then
+      if (xi > 1.10d0 .or. xi < -1.10d0 .or. eta > 1.10d0 .or. eta < -1.10d0 .or. gamma > 1.10d0 .or. gamma < -1.10d0) then
         ! uses previous guess
         xi = xi - dxi
         eta = eta - deta
@@ -1816,7 +1816,7 @@
     !  print*,'final distance = ',sngl(final_distance),'(km)',distmin,xi,eta,gamma
 
     ! checks if location improved
-    if (distmin <= final_distance ) then
+    if (distmin <= final_distance) then
       ! uses initial guess
       xi = xigll(ix_initial_guess)
       eta = yigll(iy_initial_guess)
@@ -1829,7 +1829,7 @@
     ! add warning if estimate is poor
     ! (usually means receiver outside the mesh given by the user)
     if (DO_WARNING) then
-      if (final_distance > typical_size * R_EARTH_KM ) then
+      if (final_distance > typical_size * R_EARTH_KM) then
         print*, '*****************************************************************'
         print*, '***** WARNING: location estimate is poor                    *****'
         print*, '*****************************************************************'
diff --git a/src/tomography/smooth_sem.F90 b/src/tomography/smooth_sem.F90
index 7e9d72f..55f56dc 100644
--- a/src/tomography/smooth_sem.F90
+++ b/src/tomography/smooth_sem.F90
@@ -197,7 +197,7 @@ program smooth_sem_globe
   do i = 1, 5
     call get_command_argument(i,arg(i))
     if (i <= 5 .and. trim(arg(i)) == '') then
-      if (myrank == 0 ) then
+      if (myrank == 0) then
         print *, 'Usage: '
         print *, '        xsmooth_sem sigma_h sigma_v kernel_file_name scratch_file_dir/ topo_dir/'
         print *
@@ -243,7 +243,7 @@ program smooth_sem_globe
   ! see values_from_mesher.h:
   !   average size of a spectral element in km = ...
   !   e.g. nproc 12x12, nex 192: element_size = 52.122262
-  if (NCHUNKS_VAL == 6 ) then
+  if (NCHUNKS_VAL == 6) then
     element_size = TWO_PI / dble(4) * R_EARTH_KM / dble(NEX_XI_VAL)
   else
     ANGULAR_WIDTH_XI_RAD = ANGULAR_WIDTH_XI_IN_DEGREES_VAL * DEGREES_TO_RADIANS
@@ -861,7 +861,7 @@ program smooth_sem_globe
       ! e.g. sigma_h 160km, sigma_v 40km:
       !     norm (not squared sigma_h ) ~ 0.001
       !     norm ( squared sigma_h) ~ 6.23 * e-5
-      !if (abs(bk(INDEX_IJK,ispec) - norm) > 1.e-4 ) then
+      !if (abs(bk(INDEX_IJK,ispec) - norm) > 1.e-4) then
       !  print *, 'Problem norm here --- ', myrank, ispec, i, j, k, bk(INDEX_IJK,ispec), norm
       !  !call exit_mpi(myrank, 'Error computing Gaussian function on the grid')
       !endif
diff --git a/utils/Profiles/write_profile.f90 b/utils/Profiles/write_profile.f90
index 890f93a..6e0aa1b 100644
--- a/utils/Profiles/write_profile.f90
+++ b/utils/Profiles/write_profile.f90
@@ -312,8 +312,8 @@
                               c33,c34,c35,c36,c44,c45,c46,c55,c56,c66)
 
         ! gets the 3-D crustal model
-        if( CRUSTAL ) then
-          if( .not. elem_in_mantle) &
+        if (CRUSTAL) then
+          if (.not. elem_in_mantle) &
             call meshfem3D_models_get3Dcrust_val(iregion_code,xmesh,ymesh,zmesh,r, &
                               vpv,vph,vsv,vsh,rho,eta_aniso,dvp, &
                               c11,c12,c13,c14,c15,c16,c22,c23,c24,c25, &
@@ -327,7 +327,7 @@
 !                                        myrank,iregion_code,ispec,i,j,k)
 
         ! checks vpv: if close to zero then there is probably an error
-        if( vpv < TINYVAL ) then
+        if (vpv < TINYVAL) then
           print*,'error vpv: ',vpv,vph,vsv,vsh,rho
           print*,'radius:',r*R_EARTH_KM
           call exit_mpi(myrank,'error get_model values')
@@ -339,7 +339,7 @@
         ! and before TOPOGRAPHY/ELLIPCITY
         !
         !note:  only Qmu attenuation considered, Qkappa attenuation not used so far...
-        if( ATTENUATION ) then
+        if (ATTENUATION) then
           call meshfem3D_models_getatten_val(idoubling,xmesh,ymesh,zmesh,r_prem, &
                               tau_e,tau_s,T_c_source, &
                               moho,Qmu,Qkappa,elem_in_crust) ! R80



More information about the CIG-COMMITS mailing list