Skip to content

Conversation

@patcal
Copy link
Collaborator

@patcal patcal commented Oct 6, 2020

This is an incremental revision to the nudging.F90 module which replaces serial reads with infld() calls so that PIO is used to read values on known model grids from an open netcdf file. This update does not address the need for in-line horizontal/vertical interpolations.

Fixes #237

@gold2718 gold2718 self-assigned this Oct 6, 2020
@gold2718 gold2718 added the enhancement New feature or request label Oct 6, 2020
@gold2718 gold2718 requested review from brian-eaton and fvitt October 6, 2020 16:28
@gold2718 gold2718 added this to the CESM2.3 milestone Oct 6, 2020
Comment on lines 1438 to 1440
call cam_pio_openfile(fileID,trim(anal_file),0)
call pio_seterrorhandling(fileID,PIO_BCAST_ERROR )
call pio_seterrorhandling(fileID,PIO_INTERNAL_ERROR)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the error handling calls back to back? Internal error is the default, and normally you'd change that to broadcast error while you do checks that may fail, and later switch back to the default. This code doesn't seem to be doing anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the code in metdata.F90 as a guide for my modifications. There were originally a couple of pio_inq_var() calls between them in the section of code I was referencing. The pio_inq calls were not relevant for my usage, but because I am not familiar with the PIO error handling functionality, I thought it best to include both of the pio_seterrorhandling() calls. Since they do nothing, they can certainly be removed.

@gold2718
Copy link
Collaborator

gold2718 commented Oct 6, 2020

Murphy ensures that whenever you select some code as a guide, you will select the worst possible example :-)
Also, the interface has changed so the best approach is to include these at the beginning of your routine:

   integer err_handling
...
       call pio_seterrorhandling(File, PIO_BCAST_ERROR, oldmethod=err_handling)

and this at the end of your routine.

    ! Back to old error handling
    call pio_seterrorhandling(File, err_handling)

This will reset the error handling back to whatever it was which is important if your routine is called from a region that has already changed the default PIO error handling method.

Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good to me, beyond the seterrorhandling issue found previously. However, I do have a few concerns which I would like to see addressed, if possible. Thanks!

endif
grid_id = cam_grid_id('physgrid')
call cam_grid_get_dim_names(grid_id,dim1name,dim2name)
! if(masterproc) write(iulog,*)'PIO: DIM1NAME=',dim1name,' DIM2NAME=',dim2name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all of the commented out if(masterproc) write... statements here and below, I would recommend either un-commenting or deleting them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another technique is to define a debug private logical symbol at module scope which you can set to .true. when you want these messages.

Suggested change
! if(masterproc) write(iulog,*)'PIO: DIM1NAME=',dim1name,' DIM2NAME=',dim2name
if(masterproc .and. debug) then
write(iulog,*)'PIO: DIM1NAME=',dim1name,' DIM2NAME=',dim2name
end if

Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly supporting previous change requests (just added a suggestion).

endif
grid_id = cam_grid_id('physgrid')
call cam_grid_get_dim_names(grid_id,dim1name,dim2name)
! if(masterproc) write(iulog,*)'PIO: DIM1NAME=',dim1name,' DIM2NAME=',dim2name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another technique is to define a debug private logical symbol at module scope which you can set to .true. when you want these messages.

Suggested change
! if(masterproc) write(iulog,*)'PIO: DIM1NAME=',dim1name,' DIM2NAME=',dim2name
if(masterproc .and. debug) then
write(iulog,*)'PIO: DIM1NAME=',dim1name,' DIM2NAME=',dim2name
end if

@patcal patcal requested review from gold2718 and nusbaume January 4, 2021 22:16
@fvitt
Copy link
Collaborator

fvitt commented Jan 5, 2021

What issue does this PR fix? Does this address scalability issues?

Comment on lines 1558 to 1559
call mpibcast(Nudge_File_Present, Nudge_NumObs, mpilog, 0, mpicom)
call mpibcast(Nudge_ObsInd , Nudge_NumObs, mpiint, 0, mpicom)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should mpi_bcast (without ifdef SPMD) be used rather than mpibcast?

@gold2718
Copy link
Collaborator

gold2718 commented Jan 5, 2021

What issue does this PR fix? Does this address scalability issues?

#237, thanks for noticing, I updated the description.

@fvitt
Copy link
Collaborator

fvitt commented Jan 5, 2021

Are we expecting this regression test to be restored. I am hoping someone checks that it is bit-for-bit compared to cam6_3_006.

FAIL ERP_Ln9.ne30_ne30_mg17.FCnudged.cheyenne_intel.cam-outfrq9s RUN time=39
Nudging code is using global interfaces not supported for weak scaling.
This error should be fixed with PR #241

@gold2718
Copy link
Collaborator

gold2718 commented Jan 5, 2021

Are we expecting this regression test to be restored

Yes, I will make sure of that.

Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just one typo in all the new endrun calls.

if(VARflag) then
Nobs_U(:,:,begchunk:endchunk,Nudge_ObsInd(1)) = Tmp3D(:,:,begchunk:endchunk)
else
call endrun('Varibale "U" is missing in '//trim(anal_file))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misspelled variable in the endrun calls here and below.

@gold2718
Copy link
Collaborator

gold2718 commented Jan 7, 2021

From around line 772:

call endrun('NUDGING IS CURRENTLY ONLY CONFIGURED FOR CAM-SE, FV, or EUL')

Is this still true? Should it work with MPAS and/or FV3?

@patcal
Copy link
Collaborator Author

patcal commented Jan 7, 2021

The module originally needed different interfaces to read in the data for
each dycore. FV3 and MPAS are new so there is no interface set up for them,
but if you notice, with the change to infld calls all of the nudging_update_analyses_*()
subroutines are now identical. So I think that adding dycore_is() cases for the 2
new dycores to the if-elseif block and having them call nudging_update_analyses_se()
will allow for FV3 and MPAS. I left the degeneracy for the time being in case any
dycore-dependent differences showed up during testing and needed to be added
back in. Rather than doing it after the module is fully tested, an alternative would be
to remove the if-block and the redundant routines now.

@patcal patcal requested review from fvitt and nusbaume January 7, 2021 16:29
gold2718 pushed a commit to gold2718/CAM that referenced this pull request Jan 8, 2021
Fix remaining PR issues in nudging.F90
Update ChangeLog
@gold2718
Copy link
Collaborator

The changes from this PR were merged to cam_development as part of cam6_3_008 (#310).

@gold2718 gold2718 closed this Jan 10, 2021
@cacraigucar cacraigucar changed the title Replace serial reads with infld calls. part of cam6_3_008: Replace serial reads with infld calls. Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants