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

Seek suggestions on mask sampler output with PFIO #3181

Closed
wants to merge 4 commits into from

Conversation

metdyn
Copy link
Contributor

@metdyn metdyn commented Nov 14, 2024

Types of change(s)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Trivial change (affects only documentation or cleanup)
  • Refactor (no functional changes, no api changes)

Checklist

  • Tested this change with a run of GEOSgcm
  • Ran the Unit Tests (make tests)

Description

I am seeking help for this piece of code to dispatch output, 1d array selected from a 2D array:
I am missing all the data from non-root processors.
This is the confusing part, for pointer, array and allocated variables.

After allocate in  mask init:
  allocate ( this%array_scalar_2d (this%npt_mask_tot, nitem_scalar ) )
  allocate ( this%array_scalar_3d (this%npt_mask_tot, this%vdata%lm, nitem_scalar) )

I added the oclients stage data:

             call ESMF_FieldGet(src_field,farrayptr=p_src_2d,_RC)
             do j=1, nx
                ix = this%index_mask(1,j)
                iy = this%index_mask(2,j)
                this%array_scalar_2d(j, count_scalar) = p_src_2d(ix, iy)
             end do
             if (nx>0) then
                ptr1d(1:nx) => this%array_scalar_2d(1:nx, count_scalar)
             else
                allocate (ptr1d(0))
             end if
             ref = ArrayReference(ptr1d)

             if (mapl_am_I_root()) then
                write(6,*) ' count_scalar=',  count_scalar
             end if

!                write(6,*) 'ip, nx, this%npt_mask_tot, i1, in=', &
!                     mypet, nx, this%npt_mask_tot, this%i1, this%in
             write(6,*) 'ip, this%p1d', mypet, ptr1d


             if (nx>0) then
                allocate(local_start,source=[this%i1])
                allocate(global_start,source=[1])
                allocate(global_count,source=[this%npt_mask_tot])
                print*, 'mypet, local_start, global_start, global_count', &
                     mypet, local_start, global_start, global_count
             else
                allocate(local_start,source=[0])
                allocate(global_start,source=[0])
                allocate(global_count,source=[0])
             end if
             print*, 'ck ip, this%npt_mask_tot = ', mypet, this%npt_mask_tot


             call oClients%collective_stage_data(this%write_collection_id,trim(filename),trim(item%xname), &
                  ref,start=local_start, global_start=global_start, global_count=global_count)
             deallocate (local_start, global_start, global_count)

The output shows:


 ck ip, this%npt_mask_tot =  4 65
 ck ip, this%npt_mask_tot =  2 65
 ck ip, this%npt_mask_tot =  0 65
 ck ip, this%npt_mask_tot =  5 65
 ck ip, this%npt_mask_tot =  1 65
 ck ip, this%npt_mask_tot =  3 65

 ip, this%npt_mask, this%i1, in:           0        18         1        18
  ip, this%npt_mask, this%i1, in:           4        42        19        60
  ip, this%npt_mask, this%i1, in:           2         0         0         0
  ip, this%npt_mask, this%i1, in:           5         5        61        65
  ip, this%npt_mask, this%i1, in:           1         0         0         0

 ip, this%p1d 4 -34.2816315  24.5193481 -11.7045240 -28.7434216 -36.4769363  35.3333778  26.3994541  16.8893108  -2.8508387 -12.5388012 -21.7820663 -38.2840652  27.9462414 -13.2156935  18.6562767 -13.6949644 -40.6111794  29.6331234  19.0445766   7.9561124  -3.1845305 -13.9438419 -23.9748096 -33.0550804 -41.0861626  19.0445766 -13.9438419 -41.0861626  18.6562767 -13.6949644 -40.6111794  27.9462414  17.9166775   7.4805627  -3.0111017 -13.2156935 -22.8467579 -31.7024555 -39.6709099  16.8893108 -12.5388012 -38.2840652

 ip, this%p1d 2

 ip, this%p1d 0 -46.6035919 -48.2927628 -42.8012505 -58.5990944 -61.5401497 -60.4166603 -63.7372818 -66.0939713 -67.3196945 -67.3196945 -66.0939713 -67.9778214 -72.1054001 -59.6047211 -67.0103073 -62.0779228 -56.5859642 -63.6863976

 ip, this%p1d 5 -27.7251472 -23.4788818 -31.6026516 -39.1352425 -35.1871452

 ip, this%p1d 1

 ip, this%p1d 3


ncdump output shows:
 longitude = 308.22040481638, 308.231351085531, 308.19711927854, ...
 latitude = -15.4538198001052, 3.09841504273754, 27.6667346534551, ...

 var2 = -46.60359, -48.29276, -42.80125, -58.59909, -61.54015, -60.41666,
    -63.73728, -66.09397, -67.31969, -67.31969, -66.09397, -67.97782,
    -72.1054, -59.60472, -67.01031, -62.07792, -56.58596, -63.6864, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;

Related Issue

@metdyn metdyn added the ❓ Question Further information is requested label Nov 14, 2024
@metdyn metdyn requested a review from a team as a code owner November 14, 2024 20:45
Copy link

This PR is being prevented from merging because you have not added one of our required labels: 0 diff, 0 diff trivial, 😲 Non 0 Diff, 🔧 Github Actions. Please add one so that the PR can be merged.

output still wrong. Check on discover then.
@tclune
Copy link
Collaborator

tclune commented Nov 15, 2024

Nothing immediately catches my eye. @weiyuan-jiang should be able to work with you to find out where things go wrong.

BTW, a separate concern that I'd not thought of until now: When a sampler needs to change geometry, then the corresponding collection needs to be replaced (metadata changes). Ideally this is done be destroying the original collection, but I'm not sure that the client-server supports that. With a new collection name, this would probably just be a small leak, but the server mechanism might need an extension to make this work correctly.

@weiyuan-jiang
Copy link
Contributor

Nothing immediately catches my eye. @weiyuan-jiang should be able to work with you to find out where things go wrong.

BTW, a separate concern that I'd not thought of until now: When a sampler needs to change geometry, then the corresponding collection needs to be replaced (metadata changes). Ideally this is done be destroying the original collection, but I'm not sure that the client-server supports that. With a new collection name, this would probably just be a small leak, but the server mechanism might need an extension to make this work correctly.

There is a subroutine that modifies the metadata

@weiyuan-jiang
Copy link
Contributor

Do you change the metadata or dimensions of a variable ? @metdyn

@metdyn
Copy link
Contributor Author

metdyn commented Nov 15, 2024

Work offline to continue debug

@metdyn metdyn closed this Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ Question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants