From 725e17d6bcece99d744bac56ce02d751b50795ae Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Tue, 17 Sep 2019 09:26:22 -0400 Subject: [PATCH 1/7] Communication bugfix and fix sponge index --- src/framework/MOM_horizontal_regridding.F90 | 15 +++++++++------ src/parameterizations/vertical/MOM_ALE_sponge.F90 | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/framework/MOM_horizontal_regridding.F90 b/src/framework/MOM_horizontal_regridding.F90 index 6e72242e70..094005bf7c 100644 --- a/src/framework/MOM_horizontal_regridding.F90 +++ b/src/framework/MOM_horizontal_regridding.F90 @@ -734,16 +734,18 @@ subroutine horiz_interp_and_extrap_tracer_fms_id(fms_id, Time, conversion, G, t if (z_edges_in(kd+1) Date: Tue, 17 Sep 2019 10:02:57 -0400 Subject: [PATCH 2/7] Added sponge test in hidden directory --- .testing/_tc4/MOM_input | 399 ++++++++++++++++++++++++++++++++++++ .testing/_tc4/build_data.py | 68 ++++++ .testing/_tc4/build_grid.py | 66 ++++++ .testing/_tc4/diag_table | 49 +++++ .testing/_tc4/input.nml | 27 +++ .testing/_tc4/prep.bash | 5 + 6 files changed, 614 insertions(+) create mode 100644 .testing/_tc4/MOM_input create mode 100644 .testing/_tc4/build_data.py create mode 100644 .testing/_tc4/build_grid.py create mode 100644 .testing/_tc4/diag_table create mode 100644 .testing/_tc4/input.nml create mode 100644 .testing/_tc4/prep.bash diff --git a/.testing/_tc4/MOM_input b/.testing/_tc4/MOM_input new file mode 100644 index 0000000000..93feb3f32c --- /dev/null +++ b/.testing/_tc4/MOM_input @@ -0,0 +1,399 @@ +! This file was written by the model and records the non-default parameters used at run-time. + +! === module MOM === + +! === module MOM_unit_scaling === +! Parameters for doing unit scaling of variables. +USE_REGRIDDING = True ! [Boolean] default = False + ! If True, use the ALE algorithm (regridding/remapping). If False, use the + ! layered isopycnal algorithm. +DT = 300.0 ! [s] + ! The (baroclinic) dynamics time step. The time-step that is actually used will + ! be an integer fraction of the forcing time-step (DT_FORCING in ocean-only mode + ! or the coupling timestep in coupled mode.) +C_P = 3925.0 ! [J kg-1 K-1] default = 3991.86795711963 + ! The heat capacity of sea water, approximated as a constant. This is only used + ! if ENABLE_THERMODYNAMICS is true. The default value is from the TEOS-10 + ! definition of conservative temperature. +SAVE_INITIAL_CONDS = True ! [Boolean] default = False + ! If true, write the initial conditions to a file given by IC_OUTPUT_FILE. + +! === module MOM_domains === +REENTRANT_X = False ! [Boolean] default = True + ! If true, the domain is zonally reentrant. +NIGLOBAL = 10 ! + ! The total number of thickness grid points in the x-direction in the physical + ! domain. With STATIC_MEMORY_ this is set in MOM_memory.h at compile time. +NJGLOBAL = 10 ! + ! The total number of thickness grid points in the y-direction in the physical + ! domain. With STATIC_MEMORY_ this is set in MOM_memory.h at compile time. + +! === module MOM_hor_index === +! Sets the horizontal array index types. + +! === module MOM_verticalGrid === +! Parameters providing information about the vertical grid. +NK = 2 ! [nondim] + ! The number of model layers. + +! === module MOM_fixed_initialization === + +! === module MOM_grid_init === +GRID_CONFIG = "mosaic" ! + ! A character string that determines the method for defining the horizontal + ! grid. Current options are: + ! mosaic - read the grid from a mosaic (supergrid) + ! file set by GRID_FILE. + ! cartesian - use a (flat) Cartesian grid. + ! spherical - use a simple spherical grid. + ! mercator - use a Mercator spherical grid. +GRID_FILE = "ocean_hgrid.nc" ! + ! Name of the file from which to read horizontal grid data. +TOPO_CONFIG = "file" ! + ! This specifies how bathymetry is specified: + ! file - read bathymetric information from the file + ! specified by (TOPO_FILE). + ! flat - flat bottom set to MAXIMUM_DEPTH. + ! bowl - an analytically specified bowl-shaped basin + ! ranging between MAXIMUM_DEPTH and MINIMUM_DEPTH. + ! spoon - a similar shape to 'bowl', but with an vertical + ! wall at the southern face. + ! halfpipe - a zonally uniform channel with a half-sine + ! profile in the meridional direction. + ! benchmark - use the benchmark test case topography. + ! Neverland - use the Neverland test case topography. + ! DOME - use a slope and channel configuration for the + ! DOME sill-overflow test case. + ! ISOMIP - use a slope and channel configuration for the + ! ISOMIP test case. + ! DOME2D - use a shelf and slope configuration for the + ! DOME2D gravity current/overflow test case. + ! Kelvin - flat but with rotated land mask. + ! seamount - Gaussian bump for spontaneous motion test case. + ! dumbbell - Sloshing channel with reservoirs on both ends. + ! shelfwave - exponential slope for shelfwave test case. + ! Phillips - ACC-like idealized topography used in the Phillips config. + ! dense - Denmark Strait-like dense water formation and overflow. + ! USER - call a user modified routine. +!MAXIMUM_DEPTH = 100.0 ! [m] + ! The (diagnosed) maximum depth of the ocean. + +! === module MOM_open_boundary === +! Controls where open boundaries are located, what kind of boundary condition to impose, and what data to apply, +! if any. +ROTATION = "betaplane" ! default = "2omegasinlat" + ! This specifies how the Coriolis parameter is specified: + ! 2omegasinlat - Use twice the planetary rotation rate + ! times the sine of latitude. + ! betaplane - Use a beta-plane or f-plane. + ! USER - call a user modified routine. +F_0 = 1.0E-04 ! [s-1] default = 0.0 + ! The reference value of the Coriolis parameter with the betaplane option. + +! === module MOM_tracer_registry === + +! === module MOM_EOS === +EQN_OF_STATE = "LINEAR" ! default = "WRIGHT" + ! EQN_OF_STATE determines which ocean equation of state should be used. + ! Currently, the valid choices are "LINEAR", "UNESCO", "WRIGHT", "NEMO" and + ! "TEOS10". This is only used if USE_EOS is true. +DRHO_DS = 0.0 ! [kg m-3 PSU-1] default = 0.8 + ! When EQN_OF_STATE=LINEAR, this is the partial derivative of density with + ! salinity. + +! === module MOM_restart === + +! === module MOM_tracer_flow_control === + +! === module MOM_coord_initialization === +COORD_CONFIG = "linear" ! + ! This specifies how layers are to be defined: + ! ALE or none - used to avoid defining layers in ALE mode + ! file - read coordinate information from the file + ! specified by (COORD_FILE). + ! BFB - Custom coords for buoyancy-forced basin case + ! based on SST_S, T_BOT and DRHO_DT. + ! linear - linear based on interfaces not layers + ! layer_ref - linear based on layer densities + ! ts_ref - use reference temperature and salinity + ! ts_range - use range of temperature and salinity + ! (T_REF and S_REF) to determine surface density + ! and GINT calculate internal densities. + ! gprime - use reference density (RHO_0) for surface + ! density and GINT calculate internal densities. + ! ts_profile - use temperature and salinity profiles + ! (read from COORD_FILE) to set layer densities. + ! USER - call a user modified routine. +REGRIDDING_COORDINATE_MODE = "Z*" ! default = "LAYER" + ! Coordinate mode for vertical regridding. Choose among the following + ! possibilities: LAYER - Isopycnal or stacked shallow water layers + ! ZSTAR, Z* - stretched geopotential z* + ! SIGMA_SHELF_ZSTAR - stretched geopotential z* ignoring shelf + ! SIGMA - terrain following coordinates + ! RHO - continuous isopycnal + ! HYCOM1 - HyCOM-like hybrid coordinate + ! SLIGHT - stretched coordinates above continuous isopycnal + ! ADAPTIVE - optimize for smooth neutral density surfaces +!ALE_RESOLUTION = 2*50.0 ! [m] + ! The distribution of vertical resolution for the target + ! grid used for Eulerian-like coordinates. For example, + ! in z-coordinate mode, the parameter is a list of level + ! thicknesses (in m). In sigma-coordinate mode, the list + ! is of non-dimensional fractions of the water column. +REMAPPING_SCHEME = "PPM_IH4" ! default = "PLM" + ! This sets the reconstruction scheme used for vertical remapping for all + ! variables. It can be one of the following schemes: PCM (1st-order + ! accurate) + ! PLM (2nd-order accurate) + ! PPM_H4 (3rd-order accurate) + ! PPM_IH4 (3rd-order accurate) + ! PQM_IH4IH3 (4th-order accurate) + ! PQM_IH6IH5 (5th-order accurate) + +! === module MOM_grid === +! Parameters providing information about the lateral grid. + +! === module MOM_state_initialization === +INIT_LAYERS_FROM_Z_FILE = True ! [Boolean] default = False + ! If true, initialize the layer thicknesses, temperatures, and salinities from a + ! Z-space file on a latitude-longitude grid. + +! === module MOM_initialize_layers_from_Z === +TEMP_SALT_Z_INIT_FILE = "temp_salt_ic.nc" ! default = "temp_salt_z.nc" + ! The name of the z-space input file used to initialize temperatures (T) and + ! salinities (S). If T and S are not in the same file, TEMP_Z_INIT_FILE and + ! SALT_Z_INIT_FILE must be set. +Z_INIT_ALE_REMAPPING = True ! [Boolean] default = False + ! If True, then remap straight to model coordinate from file. +SPONGE = True ! [Boolean] default = False + ! If true, sponges may be applied anywhere in the domain. The exact location and + ! properties of those sponges are specified via SPONGE_CONFIG. +SPONGE_DAMPING_FILE = "sponge.nc" ! + ! The name of the file with the sponge damping rates. +SPONGE_STATE_FILE = "temp_salt_ic.nc" ! default = "sponge.nc" + ! The name of the file with the state to damp toward. +SPONGE_PTEMP_VAR = "ptemp" ! default = "PTEMP" + ! The name of the potential temperature variable in SPONGE_STATE_FILE. +SPONGE_SALT_VAR = "salt" ! default = "SALT" + ! The name of the salinity variable in SPONGE_STATE_FILE. +NEW_SPONGES = True ! [of sponge restoring data.] default = False + ! Set True if using the newer sponging code which performs on-the-fly regridding + ! in lat-lon-time. + +! === module MOM_sponge === +SPONGE_DATA_ONGRID = True ! [Boolean] default = False + ! When defined, the incoming sponge data are assumed to be on the model grid +!Total sponge columns at h points = 100 ! + ! The total number of columns where sponges are applied at h points. + +! === module MOM_diag_mediator === + +! === module MOM_MEKE === + +! === module MOM_lateral_mixing_coeffs === + +! === module MOM_set_visc === +LINEAR_DRAG = True ! [Boolean] default = False + ! If LINEAR_DRAG and BOTTOMDRAGLAW are defined the drag law is + ! cdrag*DRAG_BG_VEL*u. +HBBL = 10.0 ! [m] + ! The thickness of a bottom boundary layer with a viscosity of KVBBL if + ! BOTTOMDRAGLAW is not defined, or the thickness over which near-bottom + ! velocities are averaged for the drag law if BOTTOMDRAGLAW is defined but + ! LINEAR_DRAG is not. +CDRAG = 0.002 ! [nondim] default = 0.003 + ! CDRAG is the drag coefficient relating the magnitude of the velocity field to + ! the bottom stress. CDRAG is only used if BOTTOMDRAGLAW is defined. +DRAG_BG_VEL = 0.05 ! [m s-1] default = 0.0 + ! DRAG_BG_VEL is either the assumed bottom velocity (with LINEAR_DRAG) or an + ! unresolved velocity that is combined with the resolved velocity to estimate + ! the velocity magnitude. DRAG_BG_VEL is only used when BOTTOMDRAGLAW is + ! defined. +BBL_USE_EOS = True ! [Boolean] default = False + ! If true, use the equation of state in determining the properties of the bottom + ! boundary layer. Otherwise use the layer target potential densities. +BBL_THICK_MIN = 0.1 ! [m] default = 0.0 + ! The minimum bottom boundary layer thickness that can be used with + ! BOTTOMDRAGLAW. This might be Kv/(cdrag*drag_bg_vel) to give Kv as the minimum + ! near-bottom viscosity. +KV = 1.0E-04 ! [m2 s-1] + ! The background kinematic viscosity in the interior. The molecular value, ~1e-6 + ! m2 s-1, may be used. + +! === module MOM_thickness_diffuse === +KHTH = 500.0 ! [m2 s-1] default = 0.0 + ! The background horizontal thickness diffusivity. +BE = 0.7 ! [nondim] default = 0.6 + ! If SPLIT is true, BE determines the relative weighting of a 2nd-order + ! Runga-Kutta baroclinic time stepping scheme (0.5) and a backward Euler scheme + ! (1) that is used for the Coriolis and inertial terms. BE may be from 0.5 to + ! 1, but instability may occur near 0.5. BE is also applicable if SPLIT is false + ! and USE_RK2 is true. + +! === module MOM_continuity === + +! === module MOM_continuity_PPM === +ETA_TOLERANCE = 1.0E-12 ! [m] default = 1.0E-10 + ! The tolerance for the differences between the barotropic and baroclinic + ! estimates of the sea surface height due to the fluxes through each face. The + ! total tolerance for SSH is 4 times this value. The default is + ! 0.5*NK*ANGSTROM, and this should not be set less than about + ! 10^-15*MAXIMUM_DEPTH. + +! === module MOM_CoriolisAdv === +CORIOLIS_EN_DIS = True ! [Boolean] default = False + ! If true, two estimates of the thickness fluxes are used to estimate the + ! Coriolis term, and the one that dissipates energy relative to the other one is + ! used. +BOUND_CORIOLIS = True ! [Boolean] default = False + ! If true, the Coriolis terms at u-points are bounded by the four estimates of + ! (f+rv)v from the four neighboring v-points, and similarly at v-points. This + ! option is always effectively false with CORIOLIS_EN_DIS defined and + ! CORIOLIS_SCHEME set to SADOURNY75_ENERGY. + +! === module MOM_PressureForce === + +! === module MOM_PressureForce_AFV === +RECONSTRUCT_FOR_PRESSURE = False ! [Boolean] default = True + ! If True, use vertical reconstruction of T & S within the integrals of the FV + ! pressure gradient calculation. If False, use the constant-by-layer algorithm. + ! The default is set by USE_REGRIDDING. + +! === module MOM_hor_visc === +SMAGORINSKY_AH = True ! [Boolean] default = False + ! If true, use a biharmonic Smagorinsky nonlinear eddy viscosity. +SMAG_BI_CONST = 0.03 ! [nondim] default = 0.0 + ! The nondimensional biharmonic Smagorinsky constant, typically 0.015 - 0.06. + +! === module MOM_vert_friction === +DIRECT_STRESS = True ! [Boolean] default = False + ! If true, the wind stress is distributed over the topmost HMIX_STRESS of fluid + ! (like in HYCOM), and KVML may be set to a very small value. +HMIX_FIXED = 20.0 ! [m] + ! The prescribed depth over which the near-surface viscosity and diffusivity are + ! elevated when the bulk mixed layer is not used. +KVML = 0.01 ! [m2 s-1] default = 1.0E-04 + ! The kinematic viscosity in the mixed layer. A typical value is ~1e-2 m2 s-1. + ! KVML is not used if BULKMIXEDLAYER is true. The default is set by KV. +MAXVEL = 10.0 ! [m s-1] default = 3.0E+08 + ! The maximum velocity allowed before the velocity components are truncated. + +! === module MOM_barotropic === +BOUND_BT_CORRECTION = True ! [Boolean] default = False + ! If true, the corrective pseudo mass-fluxes into the barotropic solver are + ! limited to values that require less than maxCFL_BT_cont to be accommodated. +SSH_EXTRA = 10.0 ! [m] default = 5.0 + ! An estimate of how much higher SSH might get, for use in calculating the safe + ! external wave speed. The default is the minimum of 10 m or 5% of + ! MAXIMUM_DEPTH. +BEBT = 0.2 ! [nondim] default = 0.1 + ! BEBT determines whether the barotropic time stepping uses the forward-backward + ! time-stepping scheme or a backward Euler scheme. BEBT is valid in the range + ! from 0 (for a forward-backward treatment of nonrotating gravity waves) to 1 + ! (for a backward Euler treatment). In practice, BEBT must be greater than about + ! 0.05. +DTBT = 10.0 ! [s or nondim] default = -0.98 + ! The barotropic time step, in s. DTBT is only used with the split explicit time + ! stepping. To set the time step automatically based the maximum stable value + ! use 0, or a negative value gives the fraction of the stable value. Setting + ! DTBT to 0 is the same as setting it to -0.98. The value of DTBT that will + ! actually be used is an integer fraction of DT, rounding down. + +! === module MOM_mixed_layer_restrat === + +! === module MOM_diabatic_driver === +! The following parameters are used for diabatic processes. + +! === module MOM_CVMix_KPP === +! This is the MOM wrapper to CVMix:KPP +! See http://cvmix.github.io/ + +! === module MOM_tidal_mixing === +! Vertical Tidal Mixing Parameterization + +! === module MOM_CVMix_conv === +! Parameterization of enhanced mixing due to convection via CVMix + +! === module MOM_entrain_diffusive === +CORRECT_DENSITY = False ! [Boolean] default = True + ! If true, and USE_EOS is true, the layer densities are restored toward their + ! target values by the diapycnal mixing, as described in Hallberg (MWR, 2000). + +! === module MOM_set_diffusivity === +BBL_EFFIC = 0.0 ! [nondim] default = 0.2 + ! The efficiency with which the energy extracted by bottom drag drives BBL + ! diffusion. This is only used if BOTTOMDRAGLAW is true. + +! === module MOM_bkgnd_mixing === +! Adding static vertical background mixing coefficients +KD = 0.0 ! [m2 s-1] + ! The background diapycnal diffusivity of density in the interior. Zero or the + ! molecular value, ~1e-7 m2 s-1, may be used. + +! === module MOM_kappa_shear === +! Parameterization of shear-driven turbulence following Jackson, Hallberg and Legg, JPO 2008 + +! === module MOM_CVMix_shear === +! Parameterization of shear-driven turbulence via CVMix (various options) + +! === module MOM_CVMix_ddiff === +! Parameterization of mixing due to double diffusion processes via CVMix + +! === module MOM_diabatic_aux === +! The following parameters are used for auxiliary diabatic processes. + +! === module MOM_regularize_layers === + +! === module MOM_opacity === + +! === module MOM_tracer_advect === + +! === module MOM_tracer_hor_diff === + +! === module MOM_neutral_diffusion === +! This module implements neutral diffusion of tracers + +! === module MOM_sum_output === +MAXTRUNC = 5000 ! [truncations save_interval-1] default = 0 + ! The run will be stopped, and the day set to a very large value if the velocity + ! is truncated more than MAXTRUNC times between energy saves. Set MAXTRUNC to 0 + ! to stop if there is any truncation of velocities. +DATE_STAMPED_STDOUT = False ! [Boolean] default = True + ! If true, use dates (not times) in messages to stdout + +! === module MOM_surface_forcing === +VARIABLE_WINDS = False ! [Boolean] default = True + ! If true, the winds vary in time after the initialization. +VARIABLE_BUOYFORCE = False ! [Boolean] default = True + ! If true, the buoyancy forcing varies in time after the initialization of the + ! model. +BUOY_CONFIG = "zero" ! + ! The character string that indicates how buoyancy forcing is specified. Valid + ! options include (file), (zero), (linear), (USER), (BFB) and (NONE). +WIND_CONFIG = "zero" ! + ! The character string that indicates how wind forcing is specified. Valid + ! options include (file), (2gyre), (1gyre), (gyres), (zero), and (USER). + +! === module MOM_restart === + +! === module MOM_main (MOM_driver) === +DAYMAX = 1.0 ! [days] + ! The final time of the whole simulation, in units of TIMEUNIT seconds. This + ! also sets the potential end time of the present run segment if the end time is + ! not set via ocean_solo_nml in input.nml. +RESTART_CONTROL = 3 ! default = 1 + ! An integer whose bits encode which restart files are written. Add 2 (bit 1) + ! for a time-stamped file, and odd (bit 0) for a non-time-stamped file. A + ! non-time-stamped restart file is saved at the end of the run segment for any + ! non-negative value. + +! === module MOM_write_cputime === +MAXCPU = 2.88E+04 ! [wall-clock seconds] default = -1.0 + ! The maximum amount of cpu time per processor for which MOM should run before + ! saving a restart file and quitting with a return value that indicates that a + ! further run is required to complete the simulation. If automatic restarts are + ! not desired, use a negative value for MAXCPU. MAXCPU has units of wall-clock + ! seconds, so the actual CPU time used is larger by a factor of the number of + ! processors used. + +! === module MOM_file_parser === diff --git a/.testing/_tc4/build_data.py b/.testing/_tc4/build_data.py new file mode 100644 index 0000000000..904db77c7a --- /dev/null +++ b/.testing/_tc4/build_data.py @@ -0,0 +1,68 @@ +import netCDF4 as nc +import numpy as np + +x=nc.Dataset('ocean_hgrid.nc').variables['x'][1::2,1::2] +y=nc.Dataset('ocean_hgrid.nc').variables['y'][1::2,1::2] +zbot=nc.Dataset('topog.nc').variables['depth'][:] +zbot0=zbot.max() + +def t_fc(x,y,z,radius=5.0,tmag=1.0): # a radially symmetric anomaly in the center of the domain. units are meters and degC + ny,nx=x.shape;nz=z.shape[0] + x0=x[int(ny/2),int(nx/2)];y0=y[int(ny/2),int(nx/2)] + tl=np.zeros((nz,ny,nx)) + zb=z[-1] + if len(z)>1: + zd=z/zb + else: + zd=[0.] + for k in np.arange(len(zd)): + r=np.sqrt((x-x0)**2.+(y-y0)**2.) + tl[k,:]=tl[k,:]+(1.0-np.minimum(r/radius,1.0))*tmag*(1.0-zd[k]) + return tl + +ny,nx = x.shape +nz=10;z=(np.arange(nz)*zbot0)/nz + +temp=t_fc(x,y,z) +salt=np.zeros(temp.shape)+35.0 +fl=nc.Dataset('temp_salt_ic.nc','w',format='NETCDF3_CLASSIC') +fl.createDimension('lon',nx) +fl.createDimension('lat',ny) +fl.createDimension('depth',nz) +fl.createDimension('Time',None) +zv=fl.createVariable('depth','f8',('depth')) +lonv=fl.createVariable('lon','f8',('lon')) +latv=fl.createVariable('lat','f8',('lat')) +timev=fl.createVariable('Time','f8',('Time')) +timev.calendar='noleap' +timev.units='days since 0001-01-01 00:00:00.0' +timev.modulo=' ' +tv=fl.createVariable('ptemp','f8',('Time','depth','lat','lon'),fill_value=-1.e20) +sv=fl.createVariable('salt','f8',('Time','depth','lat','lon'),fill_value=-1.e20) +tv[:]=temp[np.newaxis,:] +sv[:]=salt[np.newaxis,:] +zv[:]=z +lonv[:]=x[0,:] +latv[:]=y[:,0] +timev[0]=0. +fl.sync() +fl.close() + + +# Make Sponge forcing file +dampTime=20.0 # days +secDays=8.64e4 +fl=nc.Dataset('sponge.nc','w',format='NETCDF3_CLASSIC') +fl.createDimension('lon',nx) +fl.createDimension('lat',ny) +lonv=fl.createVariable('lon','f8',('lon')) +latv=fl.createVariable('lat','f8',('lat')) +spv=fl.createVariable('Idamp','f8',('lat','lon'),fill_value=-1.e20) +Idamp=np.zeros((ny,nx)) +if dampTime>0.: + Idamp=0.0+1.0/(dampTime*secDays) +spv[:]=Idamp +lonv[:]=x[0,:] +latv[:]=y[:,0] +fl.sync() +fl.close() diff --git a/.testing/_tc4/build_grid.py b/.testing/_tc4/build_grid.py new file mode 100644 index 0000000000..f4f51bd399 --- /dev/null +++ b/.testing/_tc4/build_grid.py @@ -0,0 +1,66 @@ +import netCDF4 as nc +import numpy as np + + +nx=14;ny=10 # grid size +depth0=100. #uniform depth +ds=0.01 # grid resolution at the equator in degrees +Re=6.378e6 # Radius of earth + +topo_=np.zeros((ny,nx))+depth0 +f_topo=nc.Dataset('topog.nc','w',format='NETCDF3_CLASSIC') +ny,nx=topo_.shape +f_topo.createDimension('ny',ny) +f_topo.createDimension('nx',nx) +f_topo.createDimension('ntiles',1) +f_topo.createVariable('depth','f8',('ny','nx')) +f_topo.createVariable('h2','f8',('ny','nx')) +f_topo.variables['depth'][:]=topo_ +f_topo.sync() +f_topo.close() + +x_=np.arange(0,2*nx+1)*ds # units are degrees E +y_=np.arange(0,2*ny+1)*ds # units are degrees N +x,y=np.meshgrid(x_,y_) + +dx=np.zeros((2*ny+1,2*nx)) +dy=np.zeros((2*ny,2*nx+1)) +rad_deg=np.pi/180. +dx[:]=rad_deg*Re*(x[:,1:]-x[:,0:-1])*np.cos(rad_deg*y[:,1:]) +dy[:]=rad_deg*Re*(y[1::,:]-y[0:-1,:]) + +f_sg=nc.Dataset('ocean_hgrid.nc','w',format='NETCDF3_CLASSIC') +f_sg.createDimension('ny',ny*2) +f_sg.createDimension('nx',nx*2) +f_sg.createDimension('nyp',ny*2+1) +f_sg.createDimension('nxp',nx*2+1) +f_sg.createDimension('string',255) +f_sg.createVariable('y','f8',('nyp','nxp')) +f_sg.createVariable('x','f8',('nyp','nxp')) +dyv=f_sg.createVariable('dy','f8',('ny','nxp')) +dxv=f_sg.createVariable('dx','f8',('nyp','nx')) +areav=f_sg.createVariable('area','f8',('ny','nx')) +dxv.units='m' +dyv.units='m' +areav.units='m2' +f_sg.createVariable('angle_dx','f8',('nyp','nxp')) +f_sg.createVariable('tile','S1',('string')) +f_sg.variables['y'].units='degrees' +f_sg.variables['x'].units='degrees' +f_sg.variables['dy'].units='meters' +f_sg.variables['dx'].units='meters' +f_sg.variables['area'].units='m2' +f_sg.variables['angle_dx'].units='degrees' +f_sg.variables['y'][:]=y +f_sg.variables['x'][:]=x +f_sg.variables['dx'][:]=dx +f_sg.variables['dy'][:]=dy +f_sg.variables['area'][:]=0.25*(dx[0:-1,:]+dx[1:,:])*(dy[:,0:-1]+dy[:,1:]) +f_sg.variables['angle_dx'][:]=0. +f_sg.variables['tile'][0] = 't' ## This is stupid +f_sg.variables['tile'][1] = 'i' +f_sg.variables['tile'][2] = 'l' +f_sg.variables['tile'][3] = 'e' +f_sg.variables['tile'][4] = '1' +f_sg.sync() +f_sg.close() diff --git a/.testing/_tc4/diag_table b/.testing/_tc4/diag_table new file mode 100644 index 0000000000..bfc07c25e8 --- /dev/null +++ b/.testing/_tc4/diag_table @@ -0,0 +1,49 @@ +"tc4" +1 1 1 0 0 0 +"prog", 1,"hours",1,"days","Time" + +#This is the field section of the diag_table. + +# Prognostic Ocean fields: +#========================= + +"ocean_model","deptho","deptho","prog","none",.false.,"none",2 +"ocean_model","areacello","areacello","prog","none",.false.,"none",2 +"ocean_model","SSH","SSH","prog","all",.false.,"none",2 +"ocean_model","temp","temp","prog","all",.false.,"none",2 + + +#============================================================================================= +# +#====> This file can be used with diag_manager/v2.0a (or higher) <==== +# +# +# FORMATS FOR FILE ENTRIES (not all input values are used) +# ------------------------ +# +#"file_name", output_freq, "output_units", format, "time_units", "time_long_name", ... +# (opt) new_file_frequecy, (opt) "new_file_freq_units", "new_file_start_date" +# +# +#output_freq: > 0 output frequency in "output_units" +# = 0 output frequency every time step +# =-1 output frequency at end of run +# +#output_units = units used for output frequency +# (years, months, days, minutes, hours, seconds) +# +#time_units = units used to label the time axis +# (days, minutes, hours, seconds) +# +# +# FORMAT FOR FIELD ENTRIES (not all input values are used) +# ------------------------ +# +#"module_name", "field_name", "output_name", "file_name" "time_sampling", time_avg, "other_opts", packing +# +#time_avg = .true. or .false. +# +#packing = 1 double precision +# = 2 float +# = 4 packed 16-bit integers +# = 8 packed 1-byte (not tested?) diff --git a/.testing/_tc4/input.nml b/.testing/_tc4/input.nml new file mode 100644 index 0000000000..29918fbdee --- /dev/null +++ b/.testing/_tc4/input.nml @@ -0,0 +1,27 @@ + &MOM_input_nml + output_directory = './', + input_filename = 'n' + restart_input_dir = 'INPUT/', + restart_output_dir = 'RESTART/', + parameter_filename = 'MOM_input', + 'MOM_override' / + + &diag_manager_nml + flush_nc_files = .true. + / + + &fms_nml + domains_stack_size = 710000, + stack_size = 0 / + + &ocean_domains_nml + / + + &ocean_solo_nml + months = 0 + date_init = 1,1,1,0,0,0 + hours = 0 + minutes = 0 + seconds = 0 + calendar = 'julian' / + diff --git a/.testing/_tc4/prep.bash b/.testing/_tc4/prep.bash new file mode 100644 index 0000000000..181f5081f5 --- /dev/null +++ b/.testing/_tc4/prep.bash @@ -0,0 +1,5 @@ +#!/bin/bash + + +python build_grid.py +python build_data.py From 2d21468692fdd3c78c765562f662c5cfb4fd5647 Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Tue, 17 Sep 2019 10:07:09 -0400 Subject: [PATCH 3/7] Bugfix test --- .testing/_tc4/MOM_input | 4 ++-- .testing/_tc4/MOM_override | 0 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .testing/_tc4/MOM_override diff --git a/.testing/_tc4/MOM_input b/.testing/_tc4/MOM_input index 93feb3f32c..da0e887a6a 100644 --- a/.testing/_tc4/MOM_input +++ b/.testing/_tc4/MOM_input @@ -15,13 +15,13 @@ C_P = 3925.0 ! [J kg-1 K-1] default = 3991.86795711963 ! The heat capacity of sea water, approximated as a constant. This is only used ! if ENABLE_THERMODYNAMICS is true. The default value is from the TEOS-10 ! definition of conservative temperature. -SAVE_INITIAL_CONDS = True ! [Boolean] default = False +SAVE_INITIAL_CONDS = False ! [Boolean] default = False ! If true, write the initial conditions to a file given by IC_OUTPUT_FILE. ! === module MOM_domains === REENTRANT_X = False ! [Boolean] default = True ! If true, the domain is zonally reentrant. -NIGLOBAL = 10 ! +NIGLOBAL = 14 ! ! The total number of thickness grid points in the x-direction in the physical ! domain. With STATIC_MEMORY_ this is set in MOM_memory.h at compile time. NJGLOBAL = 10 ! diff --git a/.testing/_tc4/MOM_override b/.testing/_tc4/MOM_override new file mode 100644 index 0000000000..e69de29bb2 From 71acc61ca19360967527668a5dfe847ac49c4a54 Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Tue, 17 Sep 2019 14:26:37 -0400 Subject: [PATCH 4/7] remove extra blank lines --- src/framework/MOM_horizontal_regridding.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/framework/MOM_horizontal_regridding.F90 b/src/framework/MOM_horizontal_regridding.F90 index 094005bf7c..0af2b1759b 100644 --- a/src/framework/MOM_horizontal_regridding.F90 +++ b/src/framework/MOM_horizontal_regridding.F90 @@ -738,11 +738,8 @@ subroutine horiz_interp_and_extrap_tracer_fms_id(fms_id, Time, conversion, G, t roundoff = 1.e-4 if (.not.spongeDataOngrid) then - if (is_root_pe()) & call time_interp_external(fms_id, Time, data_in, verbose=.true.) - - ! loop through each data level and interpolate to model grid. ! after interpolating, fill in points which will be needed ! to define the layers From 2c23578b86f003a4ba8bae4ed18e192798a878f7 Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Tue, 17 Sep 2019 14:27:49 -0400 Subject: [PATCH 5/7] Response to comments --- .testing/_tc4/build_grid.py | 16 +++++++--------- .testing/_tc4/prep.bash | 5 ----- 2 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 .testing/_tc4/prep.bash diff --git a/.testing/_tc4/build_grid.py b/.testing/_tc4/build_grid.py index f4f51bd399..e290fb4c6a 100644 --- a/.testing/_tc4/build_grid.py +++ b/.testing/_tc4/build_grid.py @@ -1,4 +1,5 @@ import netCDF4 as nc +from netCDF4 import stringtochar import numpy as np @@ -26,15 +27,15 @@ dx=np.zeros((2*ny+1,2*nx)) dy=np.zeros((2*ny,2*nx+1)) rad_deg=np.pi/180. -dx[:]=rad_deg*Re*(x[:,1:]-x[:,0:-1])*np.cos(rad_deg*y[:,1:]) -dy[:]=rad_deg*Re*(y[1::,:]-y[0:-1,:]) +dx[:]=rad_deg*Re*(x[:,1:]-x[:,0:-1])*np.cos(0.5*rad_deg*(y[:,0:-1]+y[:,1:])) +dy[:]=rad_deg*Re*(y[1:,:]-y[0:-1,:]) f_sg=nc.Dataset('ocean_hgrid.nc','w',format='NETCDF3_CLASSIC') f_sg.createDimension('ny',ny*2) f_sg.createDimension('nx',nx*2) f_sg.createDimension('nyp',ny*2+1) f_sg.createDimension('nxp',nx*2+1) -f_sg.createDimension('string',255) +f_sg.createDimension('string',5) f_sg.createVariable('y','f8',('nyp','nxp')) f_sg.createVariable('x','f8',('nyp','nxp')) dyv=f_sg.createVariable('dy','f8',('ny','nxp')) @@ -55,12 +56,9 @@ f_sg.variables['x'][:]=x f_sg.variables['dx'][:]=dx f_sg.variables['dy'][:]=dy -f_sg.variables['area'][:]=0.25*(dx[0:-1,:]+dx[1:,:])*(dy[:,0:-1]+dy[:,1:]) +f_sg.variables['area'][:]=0.25*((dx[0:-1,:]+dx[1:,:])*(dy[:,0:-1]+dy[:,1:])) f_sg.variables['angle_dx'][:]=0. -f_sg.variables['tile'][0] = 't' ## This is stupid -f_sg.variables['tile'][1] = 'i' -f_sg.variables['tile'][2] = 'l' -f_sg.variables['tile'][3] = 'e' -f_sg.variables['tile'][4] = '1' +str_=stringtochar(np.array(['tile1'],dtype='S5')) +f_sg.variables['tile'][:] = str_ f_sg.sync() f_sg.close() diff --git a/.testing/_tc4/prep.bash b/.testing/_tc4/prep.bash deleted file mode 100644 index 181f5081f5..0000000000 --- a/.testing/_tc4/prep.bash +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - - -python build_grid.py -python build_data.py From 5e3d3a2d7d5eb954c69805db40a996a4cb46279c Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Tue, 17 Sep 2019 16:05:34 -0400 Subject: [PATCH 6/7] blank diag table --- .testing/_tc4/diag_table | 49 +--------------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/.testing/_tc4/diag_table b/.testing/_tc4/diag_table index bfc07c25e8..e08d2714c2 100644 --- a/.testing/_tc4/diag_table +++ b/.testing/_tc4/diag_table @@ -1,49 +1,2 @@ -"tc4" +"MOM test configuration 4" 1 1 1 0 0 0 -"prog", 1,"hours",1,"days","Time" - -#This is the field section of the diag_table. - -# Prognostic Ocean fields: -#========================= - -"ocean_model","deptho","deptho","prog","none",.false.,"none",2 -"ocean_model","areacello","areacello","prog","none",.false.,"none",2 -"ocean_model","SSH","SSH","prog","all",.false.,"none",2 -"ocean_model","temp","temp","prog","all",.false.,"none",2 - - -#============================================================================================= -# -#====> This file can be used with diag_manager/v2.0a (or higher) <==== -# -# -# FORMATS FOR FILE ENTRIES (not all input values are used) -# ------------------------ -# -#"file_name", output_freq, "output_units", format, "time_units", "time_long_name", ... -# (opt) new_file_frequecy, (opt) "new_file_freq_units", "new_file_start_date" -# -# -#output_freq: > 0 output frequency in "output_units" -# = 0 output frequency every time step -# =-1 output frequency at end of run -# -#output_units = units used for output frequency -# (years, months, days, minutes, hours, seconds) -# -#time_units = units used to label the time axis -# (days, minutes, hours, seconds) -# -# -# FORMAT FOR FIELD ENTRIES (not all input values are used) -# ------------------------ -# -#"module_name", "field_name", "output_name", "file_name" "time_sampling", time_avg, "other_opts", packing -# -#time_avg = .true. or .false. -# -#packing = 1 double precision -# = 2 float -# = 4 packed 16-bit integers -# = 8 packed 1-byte (not tested?) From fac1a0158c9008245005e116c6253e7d49bebe18 Mon Sep 17 00:00:00 2001 From: Matthew Harrison Date: Tue, 17 Sep 2019 23:46:58 -0400 Subject: [PATCH 7/7] correct area calculation for a lat-lon grid --- .testing/_tc4/build_grid.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.testing/_tc4/build_grid.py b/.testing/_tc4/build_grid.py index e290fb4c6a..8187e98144 100644 --- a/.testing/_tc4/build_grid.py +++ b/.testing/_tc4/build_grid.py @@ -56,7 +56,18 @@ f_sg.variables['x'][:]=x f_sg.variables['dx'][:]=dx f_sg.variables['dy'][:]=dy -f_sg.variables['area'][:]=0.25*((dx[0:-1,:]+dx[1:,:])*(dy[:,0:-1]+dy[:,1:])) +#Compute the area bounded by lines of constant +#latitude-longitud on a sphere in m2. +dlon=x_[1:]-x_[:-1] +dlon=np.tile(dlon[np.newaxis,:],(2*ny,1)) +y1_=y_[:-1] +y1_=y1_[:,np.newaxis]*rad_deg +y2_=y_[1:] +y2_=y2_[:,np.newaxis]*rad_deg +y1_=np.tile(y1_,(1,2*nx)) +y2_=np.tile(y2_,(1,2*nx)) +area=(rad_deg*Re*Re)*(np.sin(y2_)-np.sin(y1_)) * dlon +f_sg.variables['area'][:]=area f_sg.variables['angle_dx'][:]=0. str_=stringtochar(np.array(['tile1'],dtype='S5')) f_sg.variables['tile'][:] = str_