Skip to content

Conversation

@patrickscholz
Copy link
Contributor

  • Raika tried to compute the density gradient in the channel sigma_xy in python like its done in fesom by using gradient_sca_x and gradient_sca_y from the fesom.mesh.diag.nc file and stepped into some issues.
grafik
  • We found out that, like the code was written until now it exchanged the indices between gradient_sca_x[1,:] and gradient_sca_x[3,:] as well as gradient_sca_y[1,:] and gradient_sca_y[3,:] when it was written to the fesom.mesh.diag.nc file. The same is also valid for the arrays of gradient_vec_x and gradient_vec_y.

fesom2/src/io_mesh_info.F90

Lines 531 to 534 in 354fe9b

do i=1, 3
call gather_elem(gradient_sca(i, 1:myDim_elem2D), rbuffer, partit)
call my_put_vara(ncid, gradient_sca_x_id, (/1, 4-i/), (/elem2D, 1/), rbuffer, partit) ! (4-i), NETCDF will permute otherwise
end do

  • its unclear to me why it was written in that way with (/1, 4-i/) which clearly writes the 3. index into 1st position and the 1. index into 3rd position, only index 2. is correctly located. However there is the comment " ! (4-i), NETCDF will permute otherwise", im not sure if there is here a hidden netcdf version issue or if its just plain wrong! Now with this bug fixed through ...
 do i=1, 3 
    call gather_elem(gradient_sca(i, 1:myDim_elem2D), rbuffer, partit) 
    call my_put_vara(ncid, gradient_sca_x_id, (/1, i/), (/elem2D, 1/), rbuffer, partit) ! (4-i), NETCDF will permute otherwise 
 end do 
...

... the outcome regarding sigma_xy looks now correct!

grafik

…il now it flipped indices between gradient_sca_x[1,:] and gradient_sca_x[3,:] as well as gradient_sca_y[1,:] and gradient_sca_y[3,:]. The same is also valid for the arrays of gradient_vec_x and gradient_vec_y
@koldunovn
Copy link
Member

@vasmue you might then need to update your example :) https://github.com/FESOM/FESOM_examples/blob/main/gradients_div_curl/FESOM_example_gradients_div_curl.ipynb

@patrickscholz
Copy link
Contributor Author

@koldunovn: Do we have a general channel to inform all fesom users? since this bug will affect a lot of fesom.mesh.diag.nc files and gradient analysis dependent on that file

@koldunovn
Copy link
Member

We have FESOM mailing list at [email protected], but it is rarely (almost never :)) used, so I am not sure if it's a best channel. Otherwise - release notes :)

@JanStreffing JanStreffing added this to the FESOM 2.7 milestone Aug 1, 2025
@JanStreffing JanStreffing merged commit 0781685 into main Sep 2, 2025
9 checks passed
@JanStreffing JanStreffing deleted the workbench_bugfix_fesom.mesh.diag.nc branch September 2, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants