From 6160a60eef2c2fee930e2df751ed39b7591b158e Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:06:33 -0500 Subject: [PATCH 01/11] Add shr_const to analysis mode --- components/mpas-ocean/src/analysis_members/Makefile | 5 ++++- components/mpas-ocean/src/analysis_members/shr_const_mod.F | 1 + components/mpas-ocean/src/analysis_members/shr_kind_mod.F | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 components/mpas-ocean/src/analysis_members/shr_const_mod.F create mode 100644 components/mpas-ocean/src/analysis_members/shr_kind_mod.F diff --git a/components/mpas-ocean/src/analysis_members/Makefile b/components/mpas-ocean/src/analysis_members/Makefile index c07186ad9adc..9afb438b77e3 100644 --- a/components/mpas-ocean/src/analysis_members/Makefile +++ b/components/mpas-ocean/src/analysis_members/Makefile @@ -2,6 +2,9 @@ OBJS = mpas_ocn_analysis_driver.o +UTILS = shr_kind_mod.o \ + shr_const_mod.o + MEMBERS = mpas_ocn_global_stats.o \ mpas_ocn_okubo_weiss.o \ mpas_ocn_layer_volume_weighted_averages.o \ @@ -35,7 +38,7 @@ MEMBERS = mpas_ocn_global_stats.o \ all: $(OBJS) -mpas_ocn_analysis_driver.o: $(MEMBERS) +mpas_ocn_analysis_driver.o: $(UTILS) $(MEMBERS) mpas_ocn_okubo_weiss.o: mpas_ocn_okubo_weiss_eigenvalues.o diff --git a/components/mpas-ocean/src/analysis_members/shr_const_mod.F b/components/mpas-ocean/src/analysis_members/shr_const_mod.F new file mode 100644 index 000000000000..41538d8af2f1 --- /dev/null +++ b/components/mpas-ocean/src/analysis_members/shr_const_mod.F @@ -0,0 +1 @@ +../../../../share/util/shr_const_mod.F90 diff --git a/components/mpas-ocean/src/analysis_members/shr_kind_mod.F b/components/mpas-ocean/src/analysis_members/shr_kind_mod.F new file mode 100644 index 000000000000..44b22288cce1 --- /dev/null +++ b/components/mpas-ocean/src/analysis_members/shr_kind_mod.F @@ -0,0 +1 @@ +../../../../share/util/shr_kind_mod.F90 From 2da96ef7e2350afec441612a4e1a3b7e97594420 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:15:21 -0500 Subject: [PATCH 02/11] Use pi for debug tracer --- .../src/mode_forward/mpas_ocn_time_integration_si.F | 4 ++-- .../src/mode_forward/mpas_ocn_time_integration_split.F | 4 ++-- .../src/mode_forward/mpas_ocn_time_integration_split_ab2.F | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_si.F b/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_si.F index 9529fbdc6ea1..8e542d5ac61b 100644 --- a/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_si.F +++ b/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_si.F @@ -2587,7 +2587,7 @@ subroutine ocn_time_integrator_si(domain, dt)!{{{ ! Reset tracer2 to 2 in top n layers ! in zonal bands, and 1 outside - lat = latCell(iCell)*180./3.1415 + lat = latCell(iCell)*180.0_RKIND/pi if ( lat>-60.0.and.lat<-55.0 & .or.lat>-40.0.and.lat<-35.0 & .or.lat>- 2.5.and.lat< 2.5 & @@ -2604,7 +2604,7 @@ subroutine ocn_time_integrator_si(domain, dt)!{{{ ! Reset tracer3 to 2 in top n layers ! in zonal bands, and 1 outside - lat = latCell(iCell)*180./3.1415 + lat = latCell(iCell)*180.0_RKIND/pi if ( lat>-55.0.and.lat<-50.0 & .or.lat>-35.0.and.lat<-30.0 & .or.lat>-15.0.and.lat<-10.0 & diff --git a/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split.F b/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split.F index 653d88198131..2b35a4efae4f 100644 --- a/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split.F +++ b/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split.F @@ -2225,7 +2225,7 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{ ! Reset tracer2 to 2 in top n layers ! in zonal bands, and 1 outside - lat = latCell(iCell)*180./3.1415 + lat = latCell(iCell)*180.0_RKIND/pi if ( lat>-60.0.and.lat<-55.0 & .or.lat>-40.0.and.lat<-35.0 & .or.lat>- 2.5.and.lat< 2.5 & @@ -2242,7 +2242,7 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{ ! Reset tracer3 to 2 in top n layers ! in zonal bands, and 1 outside - lat = latCell(iCell)*180./3.1415 + lat = latCell(iCell)*180.0_RKIND/pi if ( lat>-55.0.and.lat<-50.0 & .or.lat>-35.0.and.lat<-30.0 & .or.lat>-15.0.and.lat<-10.0 & diff --git a/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split_ab2.F b/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split_ab2.F index c6040aeba1d6..0693d00a72fd 100644 --- a/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split_ab2.F +++ b/components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_split_ab2.F @@ -2405,7 +2405,7 @@ subroutine ocn_time_integrator_split_ab2(domain, dt)!{{{ ! Reset tracer2 to 2 in top n layers ! in zonal bands, and 1 outside - lat = latCell(iCell)*180./3.1415 + lat = latCell(iCell)*180.0_RKIND/pi if ( lat>-60.0.and.lat<-55.0 & .or.lat>-40.0.and.lat<-35.0 & .or.lat>- 2.5.and.lat< 2.5 & @@ -2422,7 +2422,7 @@ subroutine ocn_time_integrator_split_ab2(domain, dt)!{{{ ! Reset tracer3 to 2 in top n layers ! in zonal bands, and 1 outside - lat = latCell(iCell)*180./3.1415 + lat = latCell(iCell)*180.0_RKIND/pi if ( lat>-55.0.and.lat<-50.0 & .or.lat>-35.0.and.lat<-30.0 & .or.lat>-15.0.and.lat<-10.0 & From 561ce771eed0e886437236d1682e47170fd32ce0 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:15:30 -0500 Subject: [PATCH 03/11] Use pi in cvmix --- components/mpas-ocean/src/shared/mpas_ocn_vmix_cvmix.F | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_vmix_cvmix.F b/components/mpas-ocean/src/shared/mpas_ocn_vmix_cvmix.F index fcede65e420c..87fb36f2145f 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_vmix_cvmix.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_vmix_cvmix.F @@ -345,8 +345,8 @@ subroutine ocn_vmix_coefs_cvmix_build(meshPool, statePool, forcingPool, err, tim ! specify geometry/location cvmix_variables % SeaSurfaceHeight = ssh(iCell) cvmix_variables % Coriolis = fCell(iCell) - cvmix_variables % lat = latCell(iCell) * 180.0_RKIND / 3.14_RKIND - cvmix_variables % lon = lonCell(iCell) * 180.0_RKIND / 3.14_RKIND + cvmix_variables % lat = latCell(iCell) * 180.0_RKIND / pi + cvmix_variables % lon = lonCell(iCell) * 180.0_RKIND / pi ! fill vertical position of column ! CVMix assume top of ocean is at z=0, so building all z-coordinate data based on layerThickness From 6223ff4f520f7917120e313adf74a49cfae7cd56 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:15:45 -0500 Subject: [PATCH 04/11] Use pi in gm --- components/mpas-ocean/src/shared/mpas_ocn_gm.F | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_gm.F b/components/mpas-ocean/src/shared/mpas_ocn_gm.F index 6f4442103fa7..3db04c4d3e8f 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_gm.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_gm.F @@ -484,7 +484,7 @@ subroutine ocn_GM_compute_Bolus_velocity(statePool, & ! Compute the speed of the first baroclinic mode from the Brunt-Vaisala frequency. cGMphaseSpeed(iEdge) = max(c_min, & - sum_hN/(config_GM_spatially_variable_baroclinic_mode*3.141592_RKIND)) + sum_hN/(config_GM_spatially_variable_baroclinic_mode*pi)) end do !$omp end do @@ -615,7 +615,7 @@ subroutine ocn_GM_compute_Bolus_velocity(statePool, & ! for the first-mode (m=1) baroclinic gravity wave speed in m/s ! c_m = 1/pi integral(N dz ) - c_mode1 = max(1.0E-5_RKIND, sum_hN/3.141592_RKIND) + c_mode1 = max(1.0E-5_RKIND, sum_hN/pi) ! See Hallberg (2013) https://doi.org/10.1016/j.ocemod.2013.08.007 ! just after eqn 4 the defines the deformation From 1b92637325d779f78fceda7fb25fd3b29e596e6c Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:16:07 -0500 Subject: [PATCH 05/11] Set pi in mpas_ocn_constants --- components/mpas-ocean/src/shared/mpas_ocn_constants.F | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_constants.F b/components/mpas-ocean/src/shared/mpas_ocn_constants.F index 35ada1306f8e..6c7023748205 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_constants.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_constants.F @@ -117,6 +117,7 @@ subroutine ocn_constants_init(configPool, packagePool)!{{{ !----------------------------------------------------------------------- T0_Kelvin = 273.16_RKIND ! zero point for Celsius + pi = 3.141592_RKIND ! pi rho_air = 1.2_RKIND ! ambient air density (kg/m^3) rho_sw = config_density0 ! density of salt water (kg/m^3) rho_fw = 1.0e3_RKIND ! avg. water density (kg/m^3) @@ -159,6 +160,7 @@ subroutine ocn_constants_init(configPool, packagePool)!{{{ #ifdef MPAS_ESM_SHR_CONST T0_Kelvin = SHR_CONST_TKFRZ ! zero point for Celsius + pi = SHR_CONST_PI ! zero point for Celsius cp_sw = SHR_CONST_CPSW ! erg/g/K cp_air = SHR_CONST_CPDAIR ! J/kg/K rho_air = SHR_CONST_RHODAIR ! kg/m^3 From 5e7322ed4f39d51429d744117be258c25f6c4006 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:16:30 -0500 Subject: [PATCH 06/11] Use pi in conservation earth area --- .../src/analysis_members/mpas_ocn_conservation_check.F | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/mpas-ocean/src/analysis_members/mpas_ocn_conservation_check.F b/components/mpas-ocean/src/analysis_members/mpas_ocn_conservation_check.F index bdd07e799b5d..fdfc219789ea 100644 --- a/components/mpas-ocean/src/analysis_members/mpas_ocn_conservation_check.F +++ b/components/mpas-ocean/src/analysis_members/mpas_ocn_conservation_check.F @@ -19,6 +19,9 @@ module ocn_conservation_check + use shr_kind_mod, only: SHR_KIND_R8 + use shr_const_mod + use mpas_derived_types use mpas_pool_routines use mpas_dmpar @@ -157,10 +160,9 @@ subroutine ocn_init_conservation_check(domain, err)!{{{ !----------------------------------------------------------------- ! taking PI from SHR_CONST_PI in share/util/shr_const_mod.F90 to match coupler - !real (kind=RKIND), parameter :: piE3SM = 3.14159265358979323846_RKIND ! pi - real (kind=RKIND), parameter :: piE3SM = 3.141592653589793_RKIND + real (kind=RKIND), parameter :: piE3SM = SHR_CONST_PI ! taking earth radius from SHR_CONST_REARTH in share/util/shr_const_mod.F90 to match coupler - real (kind=RKIND), parameter :: earthRadiusE3SM = 6.371229e6_RKIND ! radius of earth, m + real (kind=RKIND), parameter :: earthRadiusE3SM = SHR_CONST_REARTH ! radius of earth, m err = 0 From ba7b48e8b2ded2735203aad3ee899c6a7aecb963 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:40:17 -0500 Subject: [PATCH 07/11] Set pi in mpas_ocn_constants --- components/mpas-ocean/src/shared/mpas_ocn_constants.F | 1 + 1 file changed, 1 insertion(+) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_constants.F b/components/mpas-ocean/src/shared/mpas_ocn_constants.F index 6c7023748205..08b70dce3777 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_constants.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_constants.F @@ -65,6 +65,7 @@ module ocn_constants real (kind=RKIND), public :: & T0_Kelvin ,&! zero point for Celsius + pi ,&! pi mpercm ,&! meters per m cmperm ,&! m per meter days_per_second ,&! days per second From 58a8d60ce428d6e493b596456f677ec2f694bc0e Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 21 Jun 2024 16:47:52 -0500 Subject: [PATCH 08/11] Add shr_const to analysis mode --- components/mpas-ocean/src/analysis_members/shr_const_mod.F | 2 +- components/mpas-ocean/src/analysis_members/shr_kind_mod.F | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 120000 components/mpas-ocean/src/analysis_members/shr_const_mod.F mode change 100644 => 120000 components/mpas-ocean/src/analysis_members/shr_kind_mod.F diff --git a/components/mpas-ocean/src/analysis_members/shr_const_mod.F b/components/mpas-ocean/src/analysis_members/shr_const_mod.F deleted file mode 100644 index 41538d8af2f1..000000000000 --- a/components/mpas-ocean/src/analysis_members/shr_const_mod.F +++ /dev/null @@ -1 +0,0 @@ -../../../../share/util/shr_const_mod.F90 diff --git a/components/mpas-ocean/src/analysis_members/shr_const_mod.F b/components/mpas-ocean/src/analysis_members/shr_const_mod.F new file mode 120000 index 000000000000..c471e79113fd --- /dev/null +++ b/components/mpas-ocean/src/analysis_members/shr_const_mod.F @@ -0,0 +1 @@ +../../../../share/util/shr_const_mod.F90 \ No newline at end of file diff --git a/components/mpas-ocean/src/analysis_members/shr_kind_mod.F b/components/mpas-ocean/src/analysis_members/shr_kind_mod.F deleted file mode 100644 index 44b22288cce1..000000000000 --- a/components/mpas-ocean/src/analysis_members/shr_kind_mod.F +++ /dev/null @@ -1 +0,0 @@ -../../../../share/util/shr_kind_mod.F90 diff --git a/components/mpas-ocean/src/analysis_members/shr_kind_mod.F b/components/mpas-ocean/src/analysis_members/shr_kind_mod.F new file mode 120000 index 000000000000..77a61f967b6a --- /dev/null +++ b/components/mpas-ocean/src/analysis_members/shr_kind_mod.F @@ -0,0 +1 @@ +../../../../share/util/shr_kind_mod.F90 \ No newline at end of file From 17aed5bb359eb04727c4bcc5e016fbda05422599 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 1 Jul 2024 14:25:51 -0500 Subject: [PATCH 09/11] Use MPASO's pi instead of MPAS-framework's pi in AM --- .../src/analysis_members/mpas_ocn_harmonic_analysis.F | 2 +- .../analysis_members/mpas_ocn_lagrangian_particle_tracking.F | 2 +- .../mpas-ocean/src/analysis_members/mpas_ocn_okubo_weiss.F | 4 ++-- .../mpas-ocean/src/analysis_members/mpas_ocn_time_filters.F | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/mpas-ocean/src/analysis_members/mpas_ocn_harmonic_analysis.F b/components/mpas-ocean/src/analysis_members/mpas_ocn_harmonic_analysis.F index ee1495a3e59a..c60ac179ccf4 100644 --- a/components/mpas-ocean/src/analysis_members/mpas_ocn_harmonic_analysis.F +++ b/components/mpas-ocean/src/analysis_members/mpas_ocn_harmonic_analysis.F @@ -681,7 +681,7 @@ SUBROUTINE harmonic_analysis_solve(MNP,nfreq,hmat,GLOELV,haff,haface,emagt,phase REAL(kind=RKIND),ALLOCATABLE :: hap(:),hax(:) REAL(kind=RKIND),ALLOCATABLE :: ha(:,:) - convrd=180.0_RKIND/pii + convrd=180.0_RKIND/pi mm = 2*nfreq ALLOCATE ( PHASEE(nfreq),EMAG(nfreq) ) diff --git a/components/mpas-ocean/src/analysis_members/mpas_ocn_lagrangian_particle_tracking.F b/components/mpas-ocean/src/analysis_members/mpas_ocn_lagrangian_particle_tracking.F index ba02542eb45d..8a8a2665bcb9 100644 --- a/components/mpas-ocean/src/analysis_members/mpas_ocn_lagrangian_particle_tracking.F +++ b/components/mpas-ocean/src/analysis_members/mpas_ocn_lagrangian_particle_tracking.F @@ -3833,7 +3833,7 @@ subroutine convert_latlon_from_xyz(lat, lon, x, y, z) !{{{ ! ensure range in 0, 2*pi if (lon < 0.0_RKIND) then - lon = 2*pii + lon + lon = 2*pi + lon end if end subroutine convert_latlon_from_xyz !}}} diff --git a/components/mpas-ocean/src/analysis_members/mpas_ocn_okubo_weiss.F b/components/mpas-ocean/src/analysis_members/mpas_ocn_okubo_weiss.F index 88c9960092b7..64ab02e05733 100644 --- a/components/mpas-ocean/src/analysis_members/mpas_ocn_okubo_weiss.F +++ b/components/mpas-ocean/src/analysis_members/mpas_ocn_okubo_weiss.F @@ -946,8 +946,8 @@ subroutine ocn_compute_eddy_stats(dminfo, block, nVertLevels, nCells, nCellsSolv ! for lat/lon coordinates, convert from radians to degrees for output if (config_AM_okuboWeiss_use_lat_lon_coords) then - wsPosX = wsPosX *180.0_RKIND/pii - wsPosY = wsPosY *180.0_RKIND/pii + wsPosX = wsPosX *180.0_RKIND/pi + wsPosY = wsPosY *180.0_RKIND/pi end if call mpas_timer_stop("stats per proc") diff --git a/components/mpas-ocean/src/analysis_members/mpas_ocn_time_filters.F b/components/mpas-ocean/src/analysis_members/mpas_ocn_time_filters.F index 78adb9a0583f..498f3f09c7ac 100644 --- a/components/mpas-ocean/src/analysis_members/mpas_ocn_time_filters.F +++ b/components/mpas-ocean/src/analysis_members/mpas_ocn_time_filters.F @@ -62,7 +62,7 @@ module ocn_time_filters !-------------------------------------------------------------------- #ifdef TIME_FILTERS_DEBUG integer :: iEdgeOutput = 0, iBlockOutput = 0, iklevel = 1 - real (kind=RKIND) :: lonEdgePoint = 10.0_RKIND*pii/180.0_RKIND, latEdgePoint = 30.0_RKIND*pii/180.0_RKIND + real (kind=RKIND) :: lonEdgePoint = 10.0_RKIND*pi/180.0_RKIND, latEdgePoint = 30.0_RKIND*pi/180.0_RKIND #endif !*********************************************************************** @@ -182,7 +182,7 @@ subroutine ocn_init_time_filters(domain, err)!{{{ call mpas_pool_get_subpool(block % structs, 'mesh', statePool) call mpas_pool_get_array(statePool, 'latEdge', latEdge) call mpas_pool_get_array(statePool, 'lonEdge', lonEdge) - print *, 'lon = ', 180.0_RKIND/pii*lonEdge(iEdgeOutput), ' lat = ', 180.0_RKIND/pii*latEdge(iEdgeOutput), & + print *, 'lon = ', 180.0_RKIND/pi*lonEdge(iEdgeOutput), ' lat = ', 180.0_RKIND/pi*latEdge(iEdgeOutput), & ' iklevel=',iklevel, ' iEdgeOutput=',iEdgeOutput, ' iBlockOutput = ', iBlockOutput #endif From 5ce53c730807bfb626fd811640fb501ceed310f1 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 1 Jul 2024 14:26:44 -0500 Subject: [PATCH 10/11] Use MPASO's pi instead of MPAS-framework's pi in shared --- components/mpas-ocean/src/shared/Makefile | 2 +- .../src/shared/mpas_ocn_manufactured_solution.F | 4 ++-- components/mpas-ocean/src/shared/mpas_ocn_mesh.F | 3 ++- components/mpas-ocean/src/shared/mpas_ocn_tendency.F | 4 ++-- .../mpas-ocean/src/shared/mpas_ocn_tidal_forcing.F | 4 ++-- .../src/shared/mpas_ocn_tracer_advection_shared.F | 10 +++++----- .../mpas_ocn_vel_forcing_topographic_wave_drag.F | 6 +++--- .../mpas-ocean/src/shared/mpas_ocn_vel_hmix_leith.F | 2 +- .../src/shared/mpas_ocn_vel_self_attraction_loading.F | 6 +++--- .../src/shared/mpas_ocn_vel_tidal_potential.F | 10 +++++----- 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/components/mpas-ocean/src/shared/Makefile b/components/mpas-ocean/src/shared/Makefile index 35017551c754..d378b68624bb 100644 --- a/components/mpas-ocean/src/shared/Makefile +++ b/components/mpas-ocean/src/shared/Makefile @@ -143,7 +143,7 @@ mpas_ocn_tracer_advection_std.o: mpas_ocn_config.o mpas_ocn_mesh.o mpas_ocn_trac mpas_ocn_tracer_advection_vert.o: mpas_ocn_mesh.o mpas_ocn_config.o -mpas_ocn_tracer_advection_shared.o: mpas_ocn_mesh.o mpas_ocn_config.o +mpas_ocn_tracer_advection_shared.o: mpas_ocn_constants.o mpas_ocn_mesh.o mpas_ocn_config.o mpas_ocn_tracer_hmix_redi.o: mpas_ocn_constants.o mpas_ocn_config.o diff --git a/components/mpas-ocean/src/shared/mpas_ocn_manufactured_solution.F b/components/mpas-ocean/src/shared/mpas_ocn_manufactured_solution.F index e9ad6786103c..2631ba1737ba 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_manufactured_solution.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_manufactured_solution.F @@ -217,8 +217,8 @@ subroutine ocn_manufactured_solution_init(domain, err)!{{{ if (.not. config_use_manufactured_solution) return - kx = 2.0_RKIND*pii / config_manufactured_solution_wavelength_x - ky = 2.0_RKIND*pii / config_manufactured_solution_wavelength_y + kx = 2.0_RKIND*pi / config_manufactured_solution_wavelength_x + ky = 2.0_RKIND*pi / config_manufactured_solution_wavelength_y eta0 = config_manufactured_solution_amplitude diff --git a/components/mpas-ocean/src/shared/mpas_ocn_mesh.F b/components/mpas-ocean/src/shared/mpas_ocn_mesh.F index 5e0690704e40..9eadb339b660 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_mesh.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_mesh.F @@ -33,6 +33,7 @@ module ocn_mesh use mpas_log use ocn_config + use ocn_constants implicit none private @@ -1792,7 +1793,7 @@ subroutine ocn_meshScaling() !{{{ ! neighboring cells are circles for this calculation. cellWidth = 2.0_RKIND* & sqrt((areaCell(cell1) + areaCell(cell2))/ & - 2.0_RKIND/pii) + 2.0_RKIND/pi) meshScalingDel2(iEdge) = cellWidth/ & config_hmix_ref_cell_width meshScalingDel4(iEdge) = (cellWidth/ & diff --git a/components/mpas-ocean/src/shared/mpas_ocn_tendency.F b/components/mpas-ocean/src/shared/mpas_ocn_tendency.F index a16e52f14499..a17c48150744 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_tendency.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_tendency.F @@ -1453,7 +1453,7 @@ subroutine ocn_tend_freq_filtered_thickness(tendPool, statePool, & do k = 1, maxLevelCell(iCell) tend_lowFreqDivergence(k,iCell) = & - -2.0*pii/thickness_filter_timescale_sec & + -2.0*pi/thickness_filter_timescale_sec & *(lowFreqDivergence(k,iCell) - div_hu(k) & + div_hu_btr * layerThickness(k,iCell)/totalThickness) @@ -1461,7 +1461,7 @@ subroutine ocn_tend_freq_filtered_thickness(tendPool, statePool, & div_hu_btr*layerThickness(k,iCell)/totalThickness + & lowFreqDivergence(k,iCell) + & use_highFreqThick_restore* & - (-2.0*pii/highFreqThick_restore_time_sec* & + (-2.0*pi/highFreqThick_restore_time_sec* & highFreqThickness(k,iCell) ) end do ! vert (k) loop diff --git a/components/mpas-ocean/src/shared/mpas_ocn_tidal_forcing.F b/components/mpas-ocean/src/shared/mpas_ocn_tidal_forcing.F index 2a9b400dd90b..48901fbf5d51 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_tidal_forcing.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_tidal_forcing.F @@ -243,8 +243,8 @@ subroutine ocn_tidal_forcing_build_array(domain, meshPool, forcingPool, statePoo ! compute the tidalHeight if (trim(config_tidal_forcing_model) == 'monochromatic') then tidalHeight = config_tidal_forcing_monochromatic_amp * & - SIN(2.0_RKIND*pii/config_tidal_forcing_monochromatic_period * daysSinceStartOfSim - & - pii*config_tidal_forcing_monochromatic_phaseLag/180.0_RKIND) - & + SIN(2.0_RKIND*pi/config_tidal_forcing_monochromatic_period * daysSinceStartOfSim - & + pi*config_tidal_forcing_monochromatic_phaseLag/180.0_RKIND) - & config_tidal_forcing_monochromatic_baseline elseif (trim(config_tidal_forcing_model) == 'linear') then tidalHeight = max(config_tidal_forcing_linear_min, & diff --git a/components/mpas-ocean/src/shared/mpas_ocn_tracer_advection_shared.F b/components/mpas-ocean/src/shared/mpas_ocn_tracer_advection_shared.F index 2d14c961fba1..3439776094de 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_tracer_advection_shared.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_tracer_advection_shared.F @@ -24,10 +24,12 @@ module ocn_tracer_advection_shared use mpas_derived_types use mpas_hash use mpas_sort + use mpas_constants use mpas_geometry_utils use mpas_log use ocn_config + use ocn_constants use ocn_mesh implicit none @@ -370,7 +372,6 @@ subroutine computeDerivTwo(derivTwo, err)!{{{ xec, yec, zec, &! arc bisection coords thetae_tmp, &! angle xv1, xv2, yv1, yv2, zv1, zv2, &! vertex cart coords - pii, &! pi math constant length_scale, &! length scale cos2t, costsint, sin2t ! trig function temps @@ -413,7 +414,6 @@ subroutine computeDerivTwo(derivTwo, err)!{{{ ! Initialize derivTwo and pi - pii = 2.*asin(1.0) derivTwo(:,:,:) = 0.0_RKIND do iCell = 1, nCellsAll @@ -461,9 +461,9 @@ subroutine computeDerivTwo(derivTwo, err)!{{{ end do if ( zc(1) == 1.0_RKIND) then - theta_abs(iCell) = pii/2.0_RKIND + theta_abs(iCell) = pi/2.0_RKIND else - theta_abs(iCell) = pii/2.0_RKIND & + theta_abs(iCell) = pi/2.0_RKIND & - mpas_sphere_angle( xc(1), yc(1), zc(1), & xc(2), yc(2), zc(2), & 0.0_RKIND, 0.0_RKIND, 1.0_RKIND) @@ -509,7 +509,7 @@ subroutine computeDerivTwo(derivTwo, err)!{{{ angle_2d(i) = angleEdge(edgesOnCell(i,iCell)) iEdge = edgesOnCell(i,iCell) if ( iCell .ne. cellsOnEdge(1,iEdge)) & - angle_2d(i) = angle_2d(i) - pii + angle_2d(i) = angle_2d(i) - pi xp(i) = dcEdge(edgesOnCell(i,iCell)) * cos(angle_2d(i)) yp(i) = dcEdge(edgesOnCell(i,iCell)) * sin(angle_2d(i)) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_vel_forcing_topographic_wave_drag.F b/components/mpas-ocean/src/shared/mpas_ocn_vel_forcing_topographic_wave_drag.F index 8f641ca4f31c..a024ec97e51b 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_vel_forcing_topographic_wave_drag.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_vel_forcing_topographic_wave_drag.F @@ -199,7 +199,7 @@ subroutine ocn_vel_forcing_topographic_wave_drag_init(err)!{{{ call mpas_log_write(" Topographic wave drag scheme is: Jayne and St. Laurent") call mpas_log_write("") tensorScheme = .false. - kappa = pii/10000.0_RKIND + kappa = pi/10000.0_RKIND do iEdge = 1, nEdgesAll kmax = maxLevelEdgeTop(iEdge) @@ -241,7 +241,7 @@ subroutine ocn_vel_forcing_topographic_wave_drag_init(err)!{{{ topographicWaveDrag(iEdge) = topographicWaveDragCoeff * gam & * bed_slope_edges(iEdge)**2 * Nbar * Nb & - / (8.0_RKIND * omegaM2 * pii**2) + / (8.0_RKIND * omegaM2 * pi**2) endif enddo else if (config_topographic_wave_drag_scheme.EQ."LGF") then @@ -256,7 +256,7 @@ subroutine ocn_vel_forcing_topographic_wave_drag_init(err)!{{{ topographicWaveDrag(iEdge) = topographicWaveDragCoeff & * (sqrt((topo_buoyancy_N1B(iEdge)**2 - omegaM2**2) & * (topo_buoyancy_N1V(iEdge)**2 - omegaM2**2))) & - / (4.0_RKIND*pii*omegaM2) + / (4.0_RKIND*pi*omegaM2) normalCoeffTWD(iEdge) = (lonGradEdge(iEdge)**2) & * (cos(angleEdge(iEdge))**2) + (latGradEdge(iEdge)**2)*(sin(angleEdge(iEdge))**2) & - 2.0_RKIND*latGradEdge(iEdge)*lonGradEdge(iEdge)*sin(angleEdge(iEdge))*(cos(angleEdge(iEdge))) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_vel_hmix_leith.F b/components/mpas-ocean/src/shared/mpas_ocn_vel_hmix_leith.F index a6f9ec5c073c..db3e78e9b881 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_vel_hmix_leith.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_vel_hmix_leith.F @@ -159,7 +159,7 @@ subroutine ocn_vel_hmix_leith_tend(div, relVort, tend, err)!{{{ dcEdgeInv = 1.0_RKIND / dcEdge(iEdge) dvEdgeInv = 1.0_RKIND / dvEdge(iEdge) - visc2tmp = (leithParam*dxLeith*meshScalingDel2(iEdge)/pii)**3 + visc2tmp = (leithParam*dxLeith*meshScalingDel2(iEdge)/pi)**3 do k = minLevelEdgeBot(iEdge), maxLevelEdgeTop(iEdge) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_vel_self_attraction_loading.F b/components/mpas-ocean/src/shared/mpas_ocn_vel_self_attraction_loading.F index 90d1a4e4630d..a1c7a65452f8 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_vel_self_attraction_loading.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_vel_self_attraction_loading.F @@ -863,8 +863,8 @@ subroutine ocn_vel_self_attraction_loading_init(domain,err)!{{{ ! Pre-compute sin and cos of latCell (co-latitude) values allocate(sinLatCell(nCellsAll), cosLatCell(nCellsAll)) do iCell = 1,nCellsAll - sinLatCell(iCell) = sin(0.5_RKIND*pii-latCell(iCell)) - cosLatCell(iCell) = cos(0.5_RKIND*pii-latCell(iCell)) + sinLatCell(iCell) = sin(0.5_RKIND*pi-latCell(iCell)) + cosLatCell(iCell) = cos(0.5_RKIND*pi-latCell(iCell)) enddo ! Calculate blocking indices @@ -2526,7 +2526,7 @@ subroutine associatedLegendrePolynomials(n, m, startIdx, endIdx, l, pmnm2, pmnm1 if (n == m) then do iCell = startIdx,endIdx - pmnm2(iCell) = sqrt(1.0_RKIND/(4.0_RKIND*pii))*sinLatCell(iCell)**m + pmnm2(iCell) = sqrt(1.0_RKIND/(4.0_RKIND*pi))*sinLatCell(iCell)**m do i = 1,m pmnm2(iCell) = pmnm2(iCell)*sqrt(real(2*i+1,RKIND)/real(2*i,RKIND)) enddo diff --git a/components/mpas-ocean/src/shared/mpas_ocn_vel_tidal_potential.F b/components/mpas-ocean/src/shared/mpas_ocn_vel_tidal_potential.F index 211538ac0a73..daafa816fab6 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_vel_tidal_potential.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_vel_tidal_potential.F @@ -282,7 +282,7 @@ subroutine ocn_compute_tidal_potential_forcing(err)!{{{ !*** Compute eta by summing all constituent contributions do jCon = 1, nTidalConstituents - period = 2.0_RKIND*pii/tidalConstituentFrequency(jCon) + period = 2.0_RKIND*pi/tidalConstituentFrequency(jCon) nCycles = real(int(t/period),RKIND) targ = tidalConstituentFrequency(jCon)*(t - nCycles*period) + & tidalConstituentNodalPhase(jCon) + & @@ -583,7 +583,7 @@ subroutine tidal_constituent_factors(constituentList,nTidalConstituents,refTime, !h = 280.4661_RKIND + 0.98564736_RKIND*T; !p = 83.3535_RKIND + 0.11140353_RKIND*T; !N = 125.0445_RKIND - 0.05295377_RKIND*T; - !N = N*pii/180.0_RKIND + !N = N*pi/180.0_RKIND !! M2 !tidalConstituentAstronomical(j) = 2.0_RKIND*h - 2.0_RKIND*s @@ -611,7 +611,7 @@ subroutine tidal_constituent_factors(constituentList,nTidalConstituents,refTime, !tidalConstituentNodalAmplitude(j) = 1.009_RKIND + 0.187_RKIND*cos(N) - deg2rad = pii/180.0_RKIND + deg2rad = pi/180.0_RKIND T = adjust_angle(180.0_RKIND + real(refHour,RKIND)*(360.0_RKIND/24.0_RKIND)) do j = 1,nTidalConstituents @@ -742,8 +742,8 @@ subroutine orbit(year,julianDay,hour, & real (kind=RKIND) :: deg2rad,rad2deg real (kind=RKIND) :: NRad,pRad,IRad,nuRad,xiRad,nupRad,nup2Rad - deg2rad = pii/180.0_RKIND - rad2deg = 180.0_RKIND/pii + deg2rad = pi/180.0_RKIND + rad2deg = 180.0_RKIND/pi x = int((real(year,RKIND)-1901.0_RKIND)/4.0_RKIND) yr = real(year,RKIND) - 1900.0_RKIND From b3c8342d89983b960c3f7f8d1116c2fe451c3efd Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 1 Jul 2024 13:50:46 -0600 Subject: [PATCH 11/11] Increase precision of MPAS-O standalone pi Co-authored-by: Xylar Asay-Davis --- components/mpas-ocean/src/shared/mpas_ocn_constants.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_constants.F b/components/mpas-ocean/src/shared/mpas_ocn_constants.F index 08b70dce3777..dd3214d8d4fc 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_constants.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_constants.F @@ -118,7 +118,7 @@ subroutine ocn_constants_init(configPool, packagePool)!{{{ !----------------------------------------------------------------------- T0_Kelvin = 273.16_RKIND ! zero point for Celsius - pi = 3.141592_RKIND ! pi + pi = 3.14159265358979323846_RKIND ! pi rho_air = 1.2_RKIND ! ambient air density (kg/m^3) rho_sw = config_density0 ! density of salt water (kg/m^3) rho_fw = 1.0e3_RKIND ! avg. water density (kg/m^3)