1 / 12

New I/O in OPA: IOM

dora
Download Presentation

New I/O in OPA: IOM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objectives: USER point of view + FLEXIBILITY1) Simplify the calling instructions as much as possible2) Speed-up the performances and minimize the memory requirement3) IO format/library specifications must appear only in one unique module4) Easy switch from one IO library to another5) Improve the code readability as much as possible 6) Merge histdef and histwrite in one unique call 7) Temporal mean done in OPA, no more in IO library8) Distribute the write instructions in each module, i.e. where the variables are available9) On-line interpolation when reading (ORCA05 data forcing ORCA1/12) New I/O in OPA: IOM

  2. Inputs : iom_get Implemented, and tested… A nice example with domhgr… Local declarations: !! * Local declarations LOGICAL :: llog = .FALSE. CHARACTER(len=21) :: clname INTEGER :: ji, jj ! dummy loop indices INTEGER :: inum ! temporary logical unit INTEGER :: ilev, itime ! temporary integers REAL(wp) :: zdt, zdate0 ! temporary scalars REAL(wp) :: zdept(1) ! temporary workspace REAL(wp), DIMENSION(jpidta,jpjdta) :: & zlamt, zphit, zdta ! temporary workspace INTEGER :: inum ! temporary logical unit Open the file: clname = 'coordinates' #if defined key_agrif if ( .NOT. Agrif_Root() ) then clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname) endif #endif itime = 0 ilev = 1 zlamt(:,:) = 0.e0 zphit(:,:) = 0.e0 CALL restini( clname, jpidta, jpjdta, zlamt , zphit, & & ilev , zdept , 'NONE',itime , zdate0, & & zdt , inum , domain_id = nidom ) CALL iom_open( 'coordinates', inum ) • open in write mode • mix-up the logical units • 13 (useless) arguments • inappropriate checks • unjustified assumptions • inout filename

  3. Read the data CALL restget( inum, 'glamt', jpidta, & jpjdta, 1, itime, llog, zdta ) DO jj = 1, nlcj DO ji = 1, nlci glamt(ji,jj) = zdta(mig(ji),mjg(jj)) END DO END DO ! set extra rows add in mpp to none zero values DO jj = nlcj+1, jpj DO ji = 1, nlci glamt(ji,jj) = glamt(ji,1) END DO END DO ! set extra columns add in mpp to none zero values DO ji = nlci+1, jpi glamt(ji,:) = glamt(1,:) END DO CALL iom_get( inum, jpdom_data, 'glamt', glamt ) • read too much of data • extract the needed data • initialize the extra-halo Close the file • do not really free the units CALL iom_close( inum ) CALL restclo( inum )  hgr_read: 190 lines  hgr_read: 45 lines

  4. IOM_RSTDIMG IOM_NF90 IOM_IOIPSL IOM_DEF USE iom_def USE iom_def USE netcdf USE iom_def USE ioipsl Struture definition… How doest-it works? NEMO module USE iom … CALL IOM_OPEN… vid = IOM_VARID(…) CALL IOM_GET… CALL IOM_GETTIME CALL IOM_RSTPUT CALL IOM_CLOSE… IOM USE iom_def ! iom variables definitions USE iom_ioipsl ! NetCDF with IOIPSL library USE iom_nf90 ! NetCDF with native NetCDF library USE iom_rstdimg ! "dimg restart" style... … PUBLIC iom_open, iom_close, iom_varid, iom_get, iom_gettime, iom_rstput

  5. Details of iom_def TYPE, PUBLIC :: file_descriptor CHARACTER(LEN=240) :: name !: name of the file INTEGER :: nfid !: file identifier(0 if closed) INTEGER :: iolib !: library used INTEGER :: nvars !: nb of identified vars INTEGER :: iduld !: id of the unlimited dim dim INTEGER :: irec !: writing record position CHARACTER(LEN=32), DIMENSION(jpmax_vars) :: cn_va !: names of the variables INTEGER, DIMENSION(jpmax_vars) :: nvid !: id of the variables INTEGER, DIMENSION(jpmax_vars) :: ndims !: number of dims of the vars LOGICAL, DIMENSION(jpmax_vars) :: luld !: use unlimited dimension? INTEGER, DIMENSION(jpmax_dims,jpmax_vars) :: dimsz !: size of variables dimensions REAL(kind=wp), DIMENSION(jpmax_vars) :: scf !: scale_factor REAL(kind=wp), DIMENSION(jpmax_vars) :: ofs !: add_offset END TYPE file_descriptor TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC :: iom_file !: array containing the info for all opened files

  6. iom_rstput CALL iom_open( clname, numrow, ldwrt = .TRUE., kiolib = jprstlib ) CALL iom_rstput( kt, nitrst, numrow, 'ub' , ub ) CALL iom_close( numrow )

  7. Gestion des erreurs… Everywhere in the code CALL ctl_stop( TRIM(clinfo) ) IOM_NF90 SUBROUTINE iom_nf90_check( kstatus, cdinfo ) !!-------------------------------------------------------------------- !! *** SUBROUTINE iom_nf90_check *** !! !! ** Purpose : check nf90 errors !!-------------------------------------------------------------------- INTEGER, INTENT(in) :: kstatus ` CHARACTER(LEN=*), INTENT(in) :: cdinfo !--------------------------------------------------------------------- IF(kstatus /= nf90_noerr) THEN CALL ctl_stop( 'iom_nf90_check : '//TRIM(nf90_strerror(kstatus)), TRIM(cdinfo) ) ENDIF END SUBROUTINE iom_nf90_check IOM_RSTDIMG READ( idrst, REC = 1, IOSTAT = ios, ERR = 987 ) irecl8 … CONTINUE IF( ios /= 0 ) THEN WRITE(ctmp1,*) ' iostat = ', ios CALL ctl_stop( TRIM(clinfo), ' error in opening file '//TRIM(cdname), ctmp1 ) ENDIF

  8. Outputs : like books in a library • Multitude of different books • 1D, 2D, 3D variables • Different output frequencies • Split the book in several volumes if needed For example monthly files for a 1-year run Volume definition/restrictions (to keep readable code and easy post possessing) Table of contents 1D chapters (pages1d) 2D chapters (pages2d) 3D chapters (pages3d) One unique 3D spatial and temporal referential (Each file contains one unique x, y, z, t dimension)

  9. page chapter volume book library Describe and Order the library in a F90 way…

  10. TYPE page1d CHARACTER(LEN=jpcharlen) :: name, lgname, units REAL, DIMENSION(:,:), POINTER :: var1d REAL :: add, scl INTEGER :: type END TYPE page1d page TYPE page2d CHARACTER(LEN=jpcharlen) :: name, lgname, units REAL, DIMENSION(:,:), POINTER :: var2d REAL :: add, scl INTEGER :: type END TYPE page2d TYPE page3d CHARACTER(LEN=jpcharlen) :: name, lgname, units REAL, DIMENSION(:,:,:), POINTER :: var3d REAL :: add, scl INTEGER :: type END TYPE page3d chapter TYPE volume CHARACTER(LEN=jpcharlen) :: ncname INTEGER, DIMENSION(4) :: dim_id, dim_len, vardim_id INTEGER, DIMENSION(jpmax_page1d) :: vars1d_id INTEGER, DIMENSION(jpmax_page2d) :: vars2d_id INTEGER, DIMENSION(jpmax_page3d) :: vars3d_id TYPE(page1d), DIMENSION(jpmax_page1d) :: chapter1d TYPE(page2d), DIMENSION(jpmax_page2d) :: chapter2d TYPE(page3d), DIMENSION(jpmax_page3d) :: chapter3d END TYPE volume volume Table of contents 1D chapters 2D chapters 3D chapters

  11. book library TYPE book INTEGER :: nfreq, ncurrent INTEGER, DIMENSION(jpmax_vol) :: nbtime CHARACTER(LEN=jpcharlen) :: cinfo, cname TYPE(volume), DIMENSION(jpmax_vol) :: allvolume END TYPE volume TYPE(book), DIMENSION(jpmax_book) :: library • All Outputs information in a dynamically created structure • Write instructions in each module (exit diawri and all its USE): • -> write/update a page in a book • CALL iom_put( book_id, varname, varlgname, varunits, data ) • Exact syntax to be discussed (use of namelist) • At the end of step • CALL write_books

  12. Conclusions • What has been done • iom_get + iom_rstput: implementation and tests • iom_put: nice ideas on the paper and a first preliminary draft • Do be done • iom_put: rewrite the first draft, implement and test it! • need of a benchmark for NEMO IO

More Related