Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent rank of spectral array #1208

Open
ukmo-ccbunney opened this issue Mar 22, 2024 · 5 comments
Open

Inconsistent rank of spectral array #1208

ukmo-ccbunney opened this issue Mar 22, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ukmo-ccbunney
Copy link
Collaborator

Describe the bug
[Not a bug per se, but more of an issue around consistency that does complicate things like subroutine overloading]

Most of the source term functions receive the spectral density (often A or SPEC) as a rank 1 array with the dimensions NSPEC where NSPEC = NK * NTH
However, there are several places, especially in the point output post-processors, where the array that is passed in is defined as rank 2 array with the dimensions NTH, NK, rather than a rank 1 array of size NSPEC.

Fortran (surprisingly) seems to allow this and is happy to quietly handle a 2D array as a flattened 1D array.

However, Fortran gets a lot more picky when you overload subroutines when using an INTERFACE block (something I have been looking into with the ST4 source package) which makes things more complicated.

Are there any objections to changing the use of 2D spectral arrays to 1D versions instead? This would mainly affect the point output processor programs. Apart from the issues it causes with subroutine overloading, it feels more aesthetically consistent with the internal 1D representation of spectral arrays in the rest of the model.

Example:
ww3_ounp calls W3SIN4:

CALL W3SIN4 (A, CG, WN2, UABS, USTAR, DAIR/DWAT, &

where A is defined as a 2D array:
THBND(NK), SPBND(NK), A(NTH,NK), &

but W3SIN4 expects a 1D array:

REAL, INTENT(IN) :: A(NSPEC), BRLAMBDA(NSPEC)

@ukmo-ccbunney ukmo-ccbunney added the bug Something isn't working label Mar 22, 2024
@ukmo-ccbunney ukmo-ccbunney self-assigned this Mar 22, 2024
@mickaelaccensi
Copy link
Collaborator

I agree, it seems sensible to have the same 1D array in all the code to avoid fortran to decide by itself what to do

@MatthewMasarik-NOAA
Copy link
Collaborator

In general I lean towards consistency, so I will likely think this is sensible too. I'd like to discuss with Jessica first though, when she's back early next week, just to make sure there isn't anything I've overlooked. I'll post back again then.

One place I had previously noticed this same thing, is in W3ULEV

SUBROUTINE W3ULEV ( A, VA )

which expects A (3D) and VA (2D)
REAL, INTENT(INOUT) :: A(NTH,NK,0:NSEAL), VA(NSPEC,0:NSEAL)

though in the call from W3WAVE, receives VA for both arguments
CALL W3ULEV ( VA, VA )

which I agree, it surprisingly seems to be OK with this!

@JessicaMeixner-NOAA
Copy link
Collaborator

I concur with everyone - consistency is great! I cannot think of anything else to consider here or a reason why this change would be bad.

@MatthewMasarik-NOAA
Copy link
Collaborator

Thanks for weighing in @JessicaMeixner-NOAA. Then all clear from me too. It's great you're taking this on @ukmo-ccbunney!

@ukmo-ccbunney
Copy link
Collaborator Author

Great- thanks for your input @MatthewMasarik-NOAA and @JessicaMeixner-NOAA .
I'll get something started after the Easter break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants