Modify UPWELLING case to a flat bottom, etc.

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
osean
Posts: 47
Joined: Sat Jan 23, 2021 3:46 pm
Location: MIT-WHOI

Modify UPWELLING case to a flat bottom, etc.

#1 Unread post by osean »

Dear all ROMS experts

I am very new to modelling and am trying to start from the very basics by modifying the bathymetry, grid domain, and wind forcing of the UPWELLING test case to an idealized exercise for my ROMS learning.

My intent is to modify the UPWELLING test case:
(1) the domain becomes bigger
(2) the bathymetry is modified to be a flat bottom (from a sloped basin in the test case)
(3) change the initial wind stress (tau = 0.1 Pa from East) to an initially stable and steady jet flowing into the domain from the centre of boundary

So that I can hopefully produce a scenario similar to the figure attached after running.

Based on the 2013 post on 'beginner questions about modifying ROMS' (viewtopic.php?f=14&t=2922&p=11126&hilit=begginer#p11126), and from the following in ROMS manual (2018 version),
The subroutine get_grid or ana_grid is called by initial to set the grid arrays, the bathymetry, and the Coriolis parameter. Most of the simple test problems have their grid information specified in ana_grid.h in the directory ROMS/Functionals.
I am now able to change the grid domain (size), bottom depth, coriolis parameter etc. through the following in ana_grid.h:

Code: Select all

#elif defined UPWELLING
      Xsize=1000.0_r8*REAL(Lm(ng),r8)
      Esize=1000.0_r8*REAL(Mm(ng),r8)
      depth=150.0_r8
      f0=-8.26E-05_r8
      beta=0.0_r8
Then I try to find out how to set a flat bottom bathymetry, I find later in ana_grid.h, there is the following under:

!-----------------------------------------------------------------------
! Set bathymetry (meters; positive) at RHO-points.
!-----------------------------------------------------------------------

Code: Select all

#elif defined UPWELLING
      IF (NSperiodic(ng)) THEN
        DO i=IstrT,IendT
          IF (i.le.Lm(ng)/2) THEN
            val1=REAL(i,r8)
          ELSE
            val1=REAL(Lm(ng)+1-i,r8)
          END IF
          val2=MIN(depth,84.5_r8+66.526_r8*TANH((val1-10.0_r8)/7.0_r8))
          DO j=JstrT,JendT
            h(i,j)=val2
          END DO
        END DO
      ELSE IF (EWperiodic(ng)) THEN
        DO j=JstrT,JendT
          IF (j.le.Mm(ng)/2) THEN
            val1=REAL(j,r8)
          ELSE
            val1=REAL(Mm(ng)+1-j,r8)
          END IF
          val2=MIN(depth,84.5_r8+66.526_r8*TANH((val1-10.0_r8)/7.0_r8))
          DO i=IstrT,IendT
            h(i,j)=val2
          END DO
        END DO
      END IF
What would be the best way for me to get a flat bottom topography of 4000 m bottom depth? I know I can edit the 'depth', but the bathymetry flatness I am not entirely sure.

And additionally, for (3), I can't yet find where I can edit to change the initial wind stress (tau = 0.1 Pa from East) to an initially stable and steady jet flowing into the domain from the centre of boundary; or even to start with something easier, to just change the wind initial condition to a different value or different direction.

Many thanks in advance for any helpful words or tips to get going.
Attachments
Screenshot 2021-03-07 at 23.06.55.png
Screenshot 2021-03-07 at 23.06.55.png (89.84 KiB) Viewed 11694 times

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Modify UPWELLING case to a flat bottom, etc.

#2 Unread post by kate »

I would not edit UPWELLING, but rather create a new name for your case. Then search the whole code for UPWELLING so you know what files to look in. For the flat bathymetry, the "else" case on ana_grid.h should take care of that for you. For the wind stress, you should be able to find that in the same directory as ana_grid.h. The name of the unix search command is "grep".

User avatar
wilkin
Posts: 922
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Modify UPWELLING case to a flat bottom, etc.

#3 Unread post by wilkin »

A quick way to find all the things that might be customized for a test case, such as UPWELLING, is to grep for that CPP directive at the top level of the code (see the man page for grep to understand that -r means recursively check all subdirectories.:

Code: Select all

kiwi:myroms wilkin$ grep -r UPWELLING .
./Bin/build_roms.csh:setenv ROMS_APPLICATION      UPWELLING
./Bin/build_roms.sh:export   ROMS_APPLICATION=UPWELLING
./Include/upwelling.h:** Application flag:   UPWELLING
./Include/cppdefs.h:** UPWELLING           Upwelling Example (default)                           **
./Include/cppdefs.h:**  makefile. For example, to activate the upwelling example (UPWELLING)     **
./Include/cppdefs.h:**    ROMS_APPLICATION ?= UPWELLING                                          **
./Functionals/ana_initial.h:# elif defined UPWELLING
./Functionals/ana_drag.h:#if defined UPWELLING
./Functionals/ana_smflux.h:#elif defined UPWELLING
./Functionals/ana_smflux.h:#elif defined UPWELLING
./Functionals/ana_srflux.h:# if defined UPWELLING
./Functionals/ana_grid.h:#elif defined UPWELLING
./Functionals/ana_grid.h:#elif defined UPWELLING
./Functionals/ana_vmix.h:#elif defined UPWELLING
./Functionals/ana_vmix.h:#elif defined UPWELLING
./External/roms_upwelling.in:    MyAppCPP = UPWELLING
You are new to ROMS, so you'll want to check each of the Functionals to see what they so. Viewing ana_smflux.h you'll see that it sets the wind stress, so you would modify that to deal with your present getting-started issue.

As a suggestion, running test cases can be made much more flexible with the USER == input in roms_upwelling.in.

In ana_smflux.h the lines that sets UPWELLING wind stress are:

Code: Select all

        IF ((tdays(ng)-dstart).le.2.0_r8) THEN
          windamp=-0.1_r8*SIN(pi*(tdays(ng)-dstart)/4.0_r8)/rho0
        ELSE
          windamp=-0.1_r8/rho0
        END IF
        DO j=JstrT,JendT
          DO i=IstrP,IendT
            sustr(i,j)=windamp
If, instead you have

Code: Select all

        IF ((tdays(ng)-dstart).le.user(2)) THEN
          windamp=user(1)*SIN(pi*(tdays(ng)-dstart)/user(3))/rho0
        ELSE
          windamp=user(1)/rho0
        END IF
        DO j=JstrT,JendT
          DO i=IstrP,IendT
            sustr(i,j)=windamp
then in roms_upwelling.in entering

Code: Select all

USER == -0.1   2.0   4.0 
would achieve the same thing, substituting -0.1 for the max wind stress, 2.0 days for SIN function limit and 4.0 days for the time ramp up time scale. But now, you can change the USER values in roms_upwelling.in and re-run without recompiling. You can more more quickly explore parameter space. Likewise, you can change or add parameters to other parts of the UPWELLING design.

But Kate makes a good suggestion that you should quickly move to creating your own #define called MY_PROJECT (or whatever you want to call it) and wrap your customizations in blocks thus:

Code: Select all

#elif defined UPWELLING
      IF (NSperiodic(ng)) THEN
        DO j=JstrT,JendT
        .
        .
        .
#elif defined MY_PROJECT
        .
        (your code here)
        .
#elif ...
This way you don't break the UPWELLING test if you need to get back to something that works.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: Modify UPWELLING case to a flat bottom, etc.

#4 Unread post by arango »

Alternatively, you can copy Functionals/ana_grid.h to your application directory and make any desired change. Notice that the build_roms.csh or build_roms.sh script have the capability to use your customized analytical headed files (ana_*.h) and ignore the ones distributed in ROMS Functionals sub-directory. This capability has been in ROMS for years :!: Examples of such strategy are shown in the test/upwelling subdirectory of the test repository. Check WikiROMS for the test repository.

In analytical.F, we have:

Code: Select all

      MODULE analytical_mod

      implicit none
!
      CONTAINS
!
#ifdef ANALYTICAL
# ifdef SOLVE3D
#  if defined ANA_BIOLOGY && defined BIOLOGY
#   include <ana_biology.h>
#  endif
# endif

# ifdef SOLVE3D
#  if defined ANA_BTFLUX || defined ANA_BSFLUX || defined ANA_BPFLUX
#   include <ana_btflux.h>
#  endif
# endif

# ifdef SOLVE3D
#  if defined ANA_CLOUD && defined CLOUDS
#   include <ana_cloud.h>
#  endif
# endif

# ifdef ANA_DIAG
#  include <ana_diag.h>
# endif

# ifdef SOLVE3D
#  if defined ANA_DQDSST && defined QCORRECTION
#   include <ana_dqdsst.h>
#  endif
# endif

# if defined ANA_DRAG && defined UV_DRAG_GRID
#  include <ana_drag.h>
# endif

# ifdef ANA_FSOBC
#  include <ana_fsobc.h>
# endif

# ifdef ANA_GRID
#  include <ana_grid.h>
# endif

# ifdef SOLVE3D
#  if defined ANA_HUMIDITY && \
    (defined BULK_FLUXES || defined ECOSIM || \
    (defined ANA_SRFLUX  && defined ALBEDO) )
#   include <ana_humid.h>
#  endif
# endif

# ifdef ANA_INITIAL
#  include <ana_initial.h>
# endif

# ifdef ANA_M2CLIMA
#  include <ana_m2clima.h>
# endif

# ifdef ANA_M2OBC
#  include <ana_m2obc.h>
# endif

# if defined ANA_M3CLIMA && defined SOLVE3D
#  include <ana_m3clima.h>
# endif

# if defined ANA_M3OBC && defined SOLVE3D
#  include <ana_m3obc.h>
# endif

# if defined ANA_GRID && defined MASKING
#  include <ana_mask.h>
# endif

# ifdef ANA_NUDGCOEF
#  include <ana_nudgcoef.h>
# endif

# if defined ANA_PAIR && (defined BULK_FLUXES || defined ECOSIM || \
                          defined ATM_PRESS)
#  include <ana_pair.h>
# endif

# if defined ANA_PASSIVE && defined T_PASSIVE && defined SOLVE3D
#  include <ana_passive.h>
# endif

# if defined ANA_PERTURB
#  include <ana_perturb.h>
# endif

# if defined ANA_PSOURCE
#  include <ana_psource.h>
# endif

# ifdef SOLVE3D
#  if defined ANA_RAIN && defined BULK_FLUXES
#   include <ana_rain.h>
#  endif
# endif

# ifdef SOLVE3D
#  if defined ANA_RESPIRATION && defined HYPOXIA_SRM
#   include <ana_respiration.h>
#  endif
# endif

# if defined ANA_GRID        && \
   (defined AD_SENSITIVITY   || defined I4DVAR_ANA_SENSITIVITY || \
    defined OPT_OBSERVATIONS || defined SENSITIVITY_4DVAR      || \
    defined SO_SEMI)
#  include <ana_scope.h>
# endif

# ifdef SOLVE3D
#  if defined ANA_SEDIMENT && (defined SEDIMENT || defined BBL_MODEL)
#   include <ana_sediment.h>
#  endif
# endif

# ifdef ANA_SMFLUX
#  include <ana_smflux.h>
# endif

# ifdef ANA_SPINNING
#  include <ana_spinning.h>
# endif

# ifdef ANA_SPONGE
#  include <ana_sponge.h>
# endif

# if (defined ANA_SRFLUX || defined DIURNAL_SRFLUX) && defined SOLVE3D
#  include <ana_srflux.h>
# endif

# if defined ECOSIM && defined SOLVE3D
#  include <ana_specir.h>
# endif

# ifdef ANA_SSH
#  include <ana_ssh.h>
# endif

# ifdef SOLVE3D
#  if defined SALINITY   && defined ANA_SSS && \
    (defined SCORRECTION || defined SRELAXATION)
#   include <ana_sss.h>
#  endif
# endif

# ifdef SOLVE3D
#  if defined ANA_SST && defined QCORRECTION
#   include <ana_sst.h>
#  endif
# endif

# ifdef SOLVE3D
#  if defined ANA_STFLUX || defined ANA_SSFLUX || defined ANA_SPFLUX
#   include <ana_stflux.h>
#  endif
# endif

# ifdef SOLVE3D
#  if defined ANA_TAIR && \
    (defined BULK_FLUXES || defined ECOSIM || \
    (defined ANA_SRFLUX && defined ALBEDO) )
#   include <ana_tair.h>
#  endif
# endif

# if defined ANA_TCLIMA && defined SOLVE3D
#  include <ana_tclima.h>
# endif

# if defined ANA_TOBC && defined SOLVE3D
#  include <ana_tobc.h>
# endif

# if defined ANA_VMIX && defined SOLVE3D
#  include <ana_vmix.h>
# endif

# if defined ANA_WINDS && (defined BULK_FLUXES || defined ECOSIM)
#  include <ana_winds.h>
# endif

# ifdef SOLVE3D
#  if defined WTYPE_GRID && defined ANA_WTYPE     && \
     (defined LMD_SKPP   || defined SOLAR_SOURCE)
#   include <ana_wtype.h>
#  endif
# endif

# if defined ANA_WWAVE
#  include <ana_wwave.h>
# endif
#endif

      END MODULE analytical_mod
Here, the <ana_****.h> does the selection of what version of the header file to use: your local version or the one distributed in ROMS. That's what the MY_ANALYTICAL_DIR environmental variable in the build script is for. Templates for all the analytical header files are located in the User/Functionals sub-directory. USE those templates to build your customized header files.

Post Reply