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

Suggested improvement for openfile #1183

Open
jedwards4b opened this issue Nov 4, 2024 · 4 comments
Open

Suggested improvement for openfile #1183

jedwards4b opened this issue Nov 4, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@jedwards4b
Copy link

jedwards4b commented Nov 4, 2024

What is the feature/what would you like to discuss?

In cam_pio_openfile the file is opened and then a message is written that it was successfully opened. As a consequence if a file is not opened correctly the message is not printed. This make it difficult to determine what file was causing the issue. I would like to request that this message be moved to prior to opening the file:

if(pio_iotask_rank(pio_subsystem) == 0) then                                                                                                                
      write(iulog,*) 'Opening existing file ', trim(fname), file%fh                                                                                                  
end if     

I think that this will be a great help in debugging issues with inputdata.

Is there anyone in particular you want to be part of this conversation?

@brian-eaton

Will this change (regression test) answers?

No

Will you be implementing this enhancement yourself?

Any CAM SE can do this

@jedwards4b jedwards4b added the enhancement New feature or request label Nov 4, 2024
@briandobbins
Copy link
Collaborator

And I'll just second this.

@peverwhee peverwhee added misc tag issue or PR candidate for upcoming misc tag and removed misc tag issue or PR candidate for upcoming misc tag labels Nov 4, 2024
@peverwhee
Copy link
Collaborator

@jedwards4b

This could be a naive question, but the code currently looks like:

  subroutine cam_pio_openfile(file, fname, mode)
    use pio,            only: pio_openfile, file_desc_t, pio_noerr, pio_iotask_rank
    use cam_abortutils, only: endrun

    type(file_desc_t), intent(inout), target :: file
    character(len=*), intent(in) :: fname
    integer, intent(in) :: mode

    integer :: ierr

    ierr = pio_openfile(pio_subsystem, file, pio_iotype, fname, mode)

    if(ierr/= PIO_NOERR) then
       call endrun('Failed to open '//trim(fname)//' to read')
    else if(pio_iotask_rank(pio_subsystem) == 0) then
       write(iulog,*) 'Opened existing file ', trim(fname), file%fh
    end if
  end subroutine cam_pio_openfile

Would we achieve the same effect if we instead left the code mostly as-is but handled the errors on the CAM side within cam_pio_openfile via a pio_seterrorhandling call? I'm just wondering if the Failed to open <filename> to read message might be clearer to the average user than what PIO outputs.

@jedwards4b
Copy link
Author

I think that there is an issue with that in that the failure is happening at a layer below PIO and control is not sent back to the PIO layer to be in turn passed back to cam.

@peverwhee
Copy link
Collaborator

@jedwards4b ah, ok. thanks! i'll plop this change into my current open PR

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: To Do
Development

No branches or pull requests

3 participants