Error when Building ROMS with #define UV_QDRAG in the Latest Version

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
hyc006
Posts: 30
Joined: Thu Nov 30, 2023 2:12 am
Location: UCSD

Error when Building ROMS with #define UV_QDRAG in the Latest Version

#1 Unread post by hyc006 »

Hi everyone,

I recently tried to build ROMS using build_roms.sh, but I'm encountering an error that I suspect is related to defining #define UV_QDRAG in my .h file. This option worked fine in an older version of ROMS, but I'm using a newer version now and am less familiar with its structure.

Here is the error message I get during compilation:

Code: Select all

analytical.f90:778:23:

  778 |           rdrag(i,j)=???
      |                       1
Error: Invalid character in name at (1)

analytical.f90:1034:39:

 1034 |      &                      GRID(ng) % latr,                            &
      |                                       1
Error: Symbol 'grid' at (1) has no IMPLICIT type

make: *** [ROMS/Functionals/Module.mk:14: /home/hyc006/ROMS/runs/roms_test/clm_using/Build_romsM/analytical.o] Error 1
I’m confused because I thought analytical.f90 was generated when running build_roms.sh, but I can't locate its source file in the ROMS directory (e.g., Nonlinear/, Modules/).

My questions are:

How can I track down where analytical.f90 is generated so I can debug the error?
Has anyone encountered issues with UV_QDRAG in the latest ROMS version? Are there additional dependencies or modifications required in the header file?
What might be causing the GRID(ng) % latr error? Could this be related to an initialization issue?
Any help would be greatly appreciated! Thanks in advance.

Best,
Hsin-Yi

jcwarner
Posts: 1212
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#2 Unread post by jcwarner »

Did you also define ANA_DRAG? If so, then by default, ROMS will grab the file
ROMS/Functionals/ana_drag.h
and use that, it has a section
# elif defined UV_QDRAG
DO j=JstrT,JendT
DO i=IstrT,IendT
rdrag2(i,j)=???
END DO
END DO

I suggest you copy that ROMS/Functionals/ana_drag.h, copy it to your folder that has your project.h file, and then replace the ??? with your values.

When ROMS builds, it will get the *.h files and make Build_roms/analytical.f90.

hyc006
Posts: 30
Joined: Thu Nov 30, 2023 2:12 am
Location: UCSD

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#3 Unread post by hyc006 »

Thanks for the help on my previous issue! That solution worked, but now I’m encountering a new error during compilation related to rdrag2:

Code: Select all

set_vbc.f90:274:49:

  274 |           bustr(i,j)=0.5_r8*(rdrag2(i-1,j)+rdrag2(i,j))*                &
      |                                                 1
Error: Function 'rdrag2' at (1) has no IMPLICIT type

set_vbc.f90:289:49:

  289 |           bvstr(i,j)=0.5_r8*(rdrag2(i,j-1)+rdrag2(i,j))*                &
      |                                                 1
Error: Function 'rdrag2' at (1) has no IMPLICIT type

make: *** [ROMS/Nonlinear/Module.mk:14: /home/hyc006/ROMS/runs/roms_test/clm_using/Build_romsM/set_vbc.o] Error 1
make: *** Waiting for unfinished jobs....
From my understanding, this error suggests that rdrag2 is not properly declared before being used. I suspect this might be due to one of the following reasons:

rdrag2 is missing a proper declaration in set_vbc.f90 or another relevant module.
The UV_QDRAG option requires additional modifications elsewhere in the ROMS source code that I haven't accounted for.
rdrag2 needs to be explicitly defined in a module before being referenced in set_vbc.f90.
Could someone clarify where rdrag2 is supposed to be defined when using UV_QDRAG? Do I need to manually declare it in set_vbc.f90, or is there another source file where this should be handled?

Any guidance would be greatly appreciated! Thanks in advance for your help.

Best,
Hsin-Yi

jcwarner
Posts: 1212
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#4 Unread post by jcwarner »

ok. are you setting UV_QDRAG or UV_LDRAG?
i messed up , i told you to fix rdrag2 but your original error was for rdrag.
Same solution but different variable.
Make sure you only have one bottom stress option, but i think there is a catch for that anyway.

hyc006
Posts: 30
Joined: Thu Nov 30, 2023 2:12 am
Location: UCSD

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#5 Unread post by hyc006 »

Thank you so much for your response—I really appreciate it!

However, the error persists even after modifying the Ana_drag file. To address the issue, I updated my model (SHALLOW) to use the same drag coefficient definitions as the upwelling example case:

Code: Select all

#if defined UPWELLING || SHALLOW
# if defined UV_LOGDRAG
      DO j=JstrT,JendT
        DO i=IstrT,IendT
          ZoBot(i,j)=0.05_r8*(1.0_r8+TANH(GRID(ng)%h(i,j)/50.0_r8))
        END DO
      END DO
# elif defined UV_LDRAG
      DO j=JstrT,JendT
        DO i=IstrT,IendT
          rdrag(i,j)=0.002_r8*(1.0_r8-TANH(GRID(ng)%h(i,j)/150.0_r8))
        END DO
      END DO
# elif defined UV_QDRAG
      DO j=JstrT,JendT          ! based on Chezy coefficient (g/c^2)
        DO i=IstrT,IendT
          cff=1.8_r8*GRID(ng)%h(i,j)*LOG(GRID(ng)%h(i,j))
          rdrag2(i,j)=g/(cff*cff)
        END DO
      END DO
# endif
Despite this, I still encounter the following error:

Code: Select all

set_vbc.f90:274:49:

  274 |           bustr(i,j)=0.5_r8*(rdrag2(i-1,j)+rdrag2(i,j))*                &
      |                                                 1
Error: Function 'rdrag2' at (1) has no IMPLICIT type
set_vbc.f90:289:49:

  289 |           bvstr(i,j)=0.5_r8*(rdrag2(i,j-1)+rdrag2(i,j))*                &
      |                                                 1
Error: Function 'rdrag2' at (1) has no IMPLICIT type
make: *** [ROMS/Nonlinear/Module.mk:14: /home/hyc006/ROMS/runs/roms_test/clm_using/Build_romsM/set_vbc.o] Error 1
make: *** Waiting for unfinished jobs....
I’ve checked my .h file to ensure that only UV_QDRAG is defined and that UV_LDRAG is not enabled.

I have a couple of follow-up questions:

Does ANA_DRAG need to be explicitly defined for the model to recognize my drag coefficient definitions?
The error repeatedly points to set_vbc.f90. Is there anything in that file I might need to modify to resolve this issue?
I truly appreciate your help in clarifying this!

jcwarner
Posts: 1212
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#6 Unread post by jcwarner »

you need to use
#if defined UPWELLING || defined SHALLOW
not
#if defined UPWELLING || SHALLOW

yes ANA_DRAG needs to be explicity defined or it will just use the value in ocean.in

can you post the compiled set_vbc.f90 (not the .F, i want to see the .f90)

-j

hyc006
Posts: 30
Joined: Thu Nov 30, 2023 2:12 am
Location: UCSD

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#7 Unread post by hyc006 »

Thanks for your response! I’ll try to fix the issue and see if any further errors occur.

I’ve attached my set_vbc.f90 file for reference.
set_vbc.f90
(13.36 KiB) Downloaded 10 times
I noticed that if I use ANA_DRAG instead of UV_QDRAG, the build_roms process completes without errors.
However, I would still prefer to use UV_QDRAG as it better aligns with my model setup.

I really appreciate your help!

Best,
Hsin-Yi

jcwarner
Posts: 1212
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#8 Unread post by jcwarner »

if you do not select a BBL bottom stress model, then you need to select one of these 3 bottom stresses: uv_logdrag, uv_qdrag, or uv_ldrag.
If you want to use a spatially constant bottom roughness, then you can just set the value of zob, rdrg2, or rdrg.
If you want to spatially constant or spatially vary bottom roughness, you can also activate ana_drag to set the values.
So ana_drag is not a substitute for uv_qdrag. ana_drag is an extra option.

I see in your set_vbc.f90 some strange stuff:
CALL set_vbc_tile (ng, tile, &
& LBi, UBi, LBj, UBj, &
& IminS, ImaxS, JminS, JmaxS, &
& nrhs(ng), &
& GRID(ng) % Hz, &
& GRID(ng) % rdrag, &

but later on it has
! Set quadratic bottom stress.
!
....
bustr(i,j)=0.5_r8*(rdrag2(i-1,j)+rdrag2(i,j))* &

Can you do a git pull to make sure you are using current version.
can you send ROMS/Nonlinear/set_vbc.F
thanks

hyc006
Posts: 30
Joined: Thu Nov 30, 2023 2:12 am
Location: UCSD

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#9 Unread post by hyc006 »

Thank you so much for the clarification!

I have already run a git pull to ensure I am using the latest version. In fact, I recently installed the newest version on my new server, so I don’t believe the issue stems from an outdated version.

I’ve attached my set_vbc.F file for reference.
set_vbc.F.txt.rtf
(33.26 KiB) Downloaded 1 time
Despite multiple attempts to resolve the error by modifying this file, none of my changes have been successful. The attached file is the original version that led to the error code I previously provided.

I truly appreciate your assistance. Thank you again!

Best,
Hsin-Yi

jcwarner
Posts: 1212
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#10 Unread post by jcwarner »

the set_vbc.F_rtf is identical to the distributed code. so that is good.

But i have no clue how that can create the situation that you have in the .f90.
You said that you modified the code?
Please use the original version and try again.

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

Re: Error when Building ROMS with #define UV_QDRAG in the Latest Version

#11 Unread post by arango »

Something is wrong here. I don't know what version of ROMS you are using, but:
  • There is not limitation to the variable GRID(ng) % rdrag since it is always defined because of the new 2D kernel in the feature/kernel branch uses implicit linear drag. It is always declared in ROMS/Modules/mod_grid.F:
    https://github.com/myroms/roms/blob/d54 ... rid.F#L234
  • ROMS offers analytical templates in the User/Functional subdirectory that can be modified and added to the application path where you are compiling and running. The build_roms script will use that copy instead of the ones distributed in ROMS/Functionals that users are not supposed to modify! I have shown examples in the test repository: https://github.com/myroms/roms_test.
    https://github.com/myroms/roms/blob/d54 ... rag.h#L164
  • You must activate the option UV_QDRAG to use the quadratic drag formulation.
  • It is required that users have a basic knowledge of Fortran to modify or customize their code. A simple perusal of the affected routine after C-preprocessing (Build_roms*/*.f90) will give you an idea of what the compiler is telling you what you did wrong!

Post Reply