GEOS-ESM / MAPL

MAPL is a foundation layer of the GEOS architecture, whose original purpose is to supplement the Earth System Modeling Framework (ESMF)
https://geos-esm.github.io/MAPL/
Apache License 2.0
27 stars 18 forks source link

Extract rank-3 array from ESMF_Field #3021

Open darianboggs opened 1 week ago

darianboggs commented 1 week ago

MAPL3 requires procedures to extract a rank-3 array pointer from an ESMF_Field. The rank-3 array provides a common array representation of ESMF_Field objects. It should support these typekinds:

The dimensions of the array are:

  1. horizontal dimensions reshaped to a rank-1 array.
  2. vertical dimension as a rank-1 array.
  3. ungridded dimensions reshaped to a rank-1 array.

If there are no horizontal dimensions, the first dimension has size 1. Similarly, if there are no ungridded dimensions, the third dimension has size 1. Finally, if there is no vertical dimension, the second dimension has size 1.

The steps are:

  1. Determine the ESMF_Field geometry, including the rank and size for horizontal, vertical, and ungridded dimensions.
  2. Based on that geometry, extract a Fortran pointer to array in the ESMF_Field.
darianboggs commented 1 week ago

Here are the notes of the Microsoft Teams meeting discussion for this issue:

  1. X(i,j,k)
  2. X(i,j,k,a,b) H+V+ungrid grid
  3. X(i,k,a,b) H+V+ungrid loc stream, mesh
  4. X(k) ak, bk, Pref
  5. X(i,j,a,b) surface + ungrid

  6. Y(ij,k,1) [im · jm, km, na · nb] ! dimCount=2; rank=3; nvert=
  7. Y(ij,k,ab) ! dimCount=2; rank=5; nvert=
  8. Y(i,k,ab) ! dimCount=1; rank=4
  9. Y(1,k,1) ! dimCount=0; rank=1
  10. Y(ij,1,ab) ! dimcount=2; rank=4

    N X Y
    0 X(i,j,k) Y(ij,k,1)
    1 X(i,j,k,a,b) Y(ij,k,ab)
    2 X(i,k,a,b) Y(i,k,ab)
    3 X(k) Y(1,k,1)
    4 X(i,j,a,b) Y(ij,1,ab)

    I. shp = GetFieldCondensedShape(F, rc)

FieldGetCondensedArray_r4(F, x, rc) FieldGetCondensedArray_r8(F, x, rc) FieldGetCondensedArray_i4(F, x, rc) FieldGetCondensedArray_i8(F, x, rc)

real(R4), pointer :: x(:,:,:) real(R8), pointer :: x(:,:,:) integer(I4), pointer :: x(:,:,:) integer(I8), pointer :: x(:,:,:)

shp = FieldGetCondenedShape(F, _RC) call FieldGetCptr(x, ...)