@@ -90,8 +90,8 @@ program xwrite_profile
90
90
! USER parameters
91
91
92
92
! initial position
93
- double precision ,parameter :: COLAT_0 = 1.0
94
- double precision ,parameter :: LON_0 = 1.0
93
+ double precision ,parameter :: COLAT_0 = 1.d0
94
+ double precision ,parameter :: LON_0 = 1.d0
95
95
96
96
! colatitude loop range (in degrees)
97
97
integer ,parameter :: COLAT_istart = 0 ! 0
@@ -149,6 +149,9 @@ program xwrite_profile
149
149
! depth increment
150
150
double precision :: delta
151
151
152
+ ! tolerance in checks for equal (==) float values
153
+ double precision , parameter :: TOL_ZERO = 1.d-12
154
+
152
155
character (len= MAX_STRING_LEN) :: outfile
153
156
character (len= 7 ) :: str_info
154
157
@@ -286,10 +289,10 @@ program xwrite_profile
286
289
phi_degrees = initial_lon + j* delta_lon ! longitude [0,360]
287
290
288
291
! checks limits
289
- if (theta_degrees < 0.0 ) stop ' Error invalid colatitude < 0'
290
- if (theta_degrees > 180.0 ) stop ' Error invalid colatitude > 180'
291
- if (phi_degrees < 0.0 ) phi_degrees = phi_degrees + 360.d0
292
- if (phi_degrees > 360.0 ) phi_degrees = phi_degrees - 360.d0
292
+ if (theta_degrees < 0.d0 ) stop ' Error invalid colatitude < 0'
293
+ if (theta_degrees > 180.d0 ) stop ' Error invalid colatitude > 180'
294
+ if (phi_degrees < 0.d0 ) phi_degrees = phi_degrees + 360.d0
295
+ if (phi_degrees > 360.d0 ) phi_degrees = phi_degrees - 360.d0
293
296
294
297
! loads corresponding GLL mesh
295
298
if (MODEL_GLL) call load_GLL_mesh(theta_degrees,phi_degrees)
@@ -410,12 +413,14 @@ program xwrite_profile
410
413
411
414
! make sure that the Moho discontinuity is at the real moho
412
415
if (CRUSTAL) then
413
- if (rmin == RMOHO_FICTITIOUS_IN_MESHER/ R_PLANET) rmin = 1.0d0 - moho
414
- if (rmax == RMOHO_FICTITIOUS_IN_MESHER/ R_PLANET) rmax = 1.0d0 - moho
416
+ ! checks rmin == RMOHO_FICTITIOUS_IN_MESHER/R_PLANET
417
+ if (abs (rmin - RMOHO_FICTITIOUS_IN_MESHER/ R_PLANET) < TOL_ZERO) rmin = 1.0d0 - moho
418
+ ! checks rmax == RMOHO_FICTITIOUS_IN_MESHER/R_PLANET
419
+ if (abs (rmax - RMOHO_FICTITIOUS_IN_MESHER/ R_PLANET) < TOL_ZERO) rmax = 1.0d0 - moho
415
420
! print *,'rmin == moho at line ',iline
416
421
endif
417
422
418
- if (abs (rmin - rmax_last) < 1.d-9 ) then ! !!! rmin == rmax_last: this means that we have just jumped between layers
423
+ if (abs (rmin - rmax_last) < TOL_ZERO ) then ! !!! rmin == rmax_last: this means that we have just jumped between layers
419
424
! depth increment
420
425
! write values every 10 km in the deep earth and every 1 km in the shallow earth
421
426
if (rmin > ((R_PLANET/ 1000.d0 )- DELTA_HIRES_DEPTH)/ (R_PLANET/ 1000.d0 )) then
@@ -430,7 +435,7 @@ program xwrite_profile
430
435
! sets maximum radius without ocean for 1D models
431
436
if (((.not. CRUSTAL) .and. (ROCEAN < R_PLANET)) .and. (.not. TOPOGRAPHY)) then
432
437
! stops at ocean depth and adds last ocean layers explicitly
433
- if (rmax == 1.0d0 ) rmax = ROCEAN/ R_PLANET
438
+ if (abs ( rmax - 1.0d0 ) < TOL_ZERO) rmax = ROCEAN/ R_PLANET ! rmax == 1.d0
434
439
endif
435
440
436
441
! backup to detect jump between layers
@@ -439,26 +444,26 @@ program xwrite_profile
439
444
! number of iterations in increments of delta between rmin and rmax
440
445
! note: instead of (rmax - rmin), we add a factor (rmax * 0.999999 - rmin) to avoid getting an extra step
441
446
! in case the difference is an exact delta match, since we add +1 to nit to reach rmax
442
- nit = floor ((rmax* 0.9999999 - rmin)/ delta) + 1
447
+ nit = floor ((rmax* 0.9999999d0 - rmin)/ delta) + 1
443
448
444
449
! debug
445
450
! print *,'debug: write profile ilayer/iregion ',ilayer,iregion_code,'rmin/rmax',rmin,rmax,'delta',delta,'nit',nit
446
451
447
452
do idep = 1 ,nit+1
448
453
! line counters
449
454
! inner core boundary
450
- if (rmin == RICB/ R_PLANET .and. idep == 1 ) iline_icb = iline
455
+ if (abs ( rmin - RICB/ R_PLANET) < TOL_ZERO .and. idep == 1 ) iline_icb = iline ! rmin == RICB/R_PLANET
451
456
! core mantle boundary
452
- if (rmin == RCMB/ R_PLANET .and. idep == 1 ) iline_cmb = iline
457
+ if (abs ( rmin - RCMB/ R_PLANET) < TOL_ZERO .and. idep == 1 ) iline_cmb = iline ! rmin == RCMB/R_PLANET
453
458
! moho
454
459
if (CRUSTAL) then
455
460
! uses 3D crustal model (e.g. Crust2.0)
456
- if (rmin == (1.0d0 - moho) .and. idep == 1 ) then
461
+ if (abs ( rmin - (1.0d0 - moho)) < TOL_ZERO .and. idep == 1 ) then ! rmin == (1.0d0 - moho)
457
462
iline_moho = iline
458
463
endif
459
464
else
460
465
! 1D crust from reference model
461
- if (rmin == RMOHO/ R_PLANET .and. idep == 1 ) iline_moho = iline
466
+ if (abs ( rmin - RMOHO/ R_PLANET) < TOL_ZERO .and. idep == 1 ) iline_moho = iline ! rmin == RMOHO/R_PLANET
462
467
endif
463
468
464
469
! radius
@@ -470,8 +475,8 @@ program xwrite_profile
470
475
! make sure we are within the right shell in PREM to honor discontinuities
471
476
! use small geometrical tolerance
472
477
r_prem = r
473
- if (r <= rmin* 1.000001d0 ) r_prem = rmin* 1.000001d0
474
- if (r >= rmax* 0.999999d0 ) r_prem = rmax* 0.999999d0
478
+ if (r < rmin* 1.000001d0 ) r_prem = rmin* 1.000001d0
479
+ if (r > rmax* 0.999999d0 ) r_prem = rmax* 0.999999d0
475
480
476
481
! gets model properties (similar to get_model() routine)
477
482
call write_profile_model_values(r,r_prem,theta,phi,iregion_code,idoubling,rmin,rmax, &
@@ -784,6 +789,9 @@ subroutine write_profile_elevation(theta,phi,elevation)
784
789
! local parameters
785
790
double precision :: lat,lon
786
791
792
+ ! initializes
793
+ elevation = 0.d0
794
+
787
795
! topography elevation
788
796
if (TOPOGRAPHY .or. OCEANS) then
789
797
if (TOPOGRAPHY) then
0 commit comments