New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 11405 for NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC – NEMO

Ignore:
Timestamp:
2019-08-06T15:16:49+02:00 (5 years ago)
Author:
andmirek
Message:

ticket #2195: read weights for blk using XIOS

Location:
NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/fldread.F90

    r10425 r11405  
    647647         ENDIF         
    648648      ELSE IF( LEN(TRIM(sdjf%wgtname)) > 0 ) THEN 
    649          CALL wgt_list( sdjf, iw ) 
     649         CALL wgt_list( sdjf, iw, lxios_blkw ) 
    650650         IF( sdjf%ln_tint ) THEN   ;   CALL fld_interp( sdjf%num, sdjf%clvar, iw, ipk, sdjf%fdta(:,:,:,2),          &  
    651651            &                                                                          sdjf%nrec_a(1), sdjf%lsmname ) 
     
    13451345 
    13461346 
    1347    SUBROUTINE wgt_list( sd, kwgt ) 
     1347   SUBROUTINE wgt_list( sd, kwgt, ldxios ) 
    13481348      !!--------------------------------------------------------------------- 
    13491349      !!                    ***  ROUTINE wgt_list  *** 
     
    13551355      TYPE( FLD ), INTENT(in   ) ::   sd        ! field with name of weights file 
    13561356      INTEGER    , INTENT(inout) ::   kwgt      ! index of weights 
     1357      LOGICAL    , INTENT(in), OPTIONAL :: ldxios 
    13571358      ! 
    13581359      INTEGER ::   kw, nestid   ! local integer 
    13591360      LOGICAL ::   found        ! local logical 
     1361      LOGICAL ::   luxios 
     1362      luxios = .FALSE. 
     1363      if(PRESENT(ldxios)) luxios = ldxios 
    13601364      !!---------------------------------------------------------------------- 
    13611365      ! 
     
    13811385      IF( .NOT.found ) THEN 
    13821386         kwgt = nxt_wgt 
    1383          CALL fld_weight( sd ) 
     1387         CALL fld_weight( sd, luxios ) 
    13841388      ENDIF 
    13851389      ! 
     
    14161420 
    14171421 
    1418    SUBROUTINE fld_weight( sd ) 
     1422   SUBROUTINE fld_weight( sd, ldxios ) 
    14191423      !!--------------------------------------------------------------------- 
    14201424      !!                    ***  ROUTINE fld_weight  *** 
     
    14241428      !!---------------------------------------------------------------------- 
    14251429      TYPE( FLD ), INTENT(in) ::   sd   ! field with name of weights file 
     1430      LOGICAL, INTENT(in), OPTIONAL :: ldxios 
    14261431      !! 
    14271432      INTEGER ::   jn         ! dummy loop indices 
     
    14351440      INTEGER,  DIMENSION(jpi,jpj) ::   data_src 
    14361441      REAL(wp), DIMENSION(jpi,jpj) ::   data_tmp 
     1442      LOGICAL                      ::   luxios 
    14371443      !!---------------------------------------------------------------------- 
     1444      luxios = .FALSE. 
     1445      IF(PRESENT(ldxios)) luxios = ldxios 
    14381446      ! 
    14391447      IF( nxt_wgt > tot_wgts ) THEN 
     
    14641472      CALL iom_open ( sd%wgtname, inum )   ! interpolation weights 
    14651473      IF ( inum > 0 ) THEN 
    1466  
     1474         IF(luxios) THEN  
     1475            CALL iom_swap(cbwxios_context) 
     1476         ENDIF 
    14671477         !! determine whether we have an east-west cyclic grid 
    14681478         !! from global attribute called "ew_wrap" in the weights file 
     
    15111521            WRITE(aname,'(a3,i2.2)') 'src',jn 
    15121522            data_tmp(:,:) = 0 
    1513             CALL iom_get ( inum, jpdom_data, aname, data_tmp(:,:) ) 
     1523            IF(luxios) THEN 
     1524               CALL iom_get ( inum, jpdom_data, aname//TRIM(sd%wgtname), data_tmp(:,:), ldxios = luxios ) 
     1525            ELSE 
     1526               CALL iom_get ( inum, jpdom_data, aname, data_tmp(:,:) ) 
     1527            ENDIF 
    15141528            data_src(:,:) = INT(data_tmp(:,:)) 
    15151529            ref_wgts(nxt_wgt)%data_jpj(:,:,jn) = 1 + (data_src(:,:)-1) / ref_wgts(nxt_wgt)%ddims(1) 
     
    15211535            WRITE(aname,'(a3,i2.2)') 'wgt',jn 
    15221536            ref_wgts(nxt_wgt)%data_wgt(:,:,jn) = 0.0 
    1523             CALL iom_get ( inum, jpdom_data, aname, ref_wgts(nxt_wgt)%data_wgt(:,:,jn) ) 
     1537            IF(luxios) THEN 
     1538               CALL iom_get ( inum, jpdom_data, aname//TRIM(sd%wgtname), ref_wgts(nxt_wgt)%data_wgt(:,:,jn), ldxios = luxios ) 
     1539            ELSE 
     1540               CALL iom_get ( inum, jpdom_data, aname, ref_wgts(nxt_wgt)%data_wgt(:,:,jn) ) 
     1541            ENDIF 
    15241542         END DO 
    15251543         CALL iom_close (inum) 
     
    15481566         nxt_wgt = nxt_wgt + 1 
    15491567         ! 
     1568         IF(luxios) CALL iom_swap(cxios_context) 
    15501569      ELSE  
    15511570         CALL ctl_stop( '    fld_weight : unable to read the file ' ) 
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/sbcapr.F90

    r11204 r11405  
    156156         IF( ln_rstart .AND. iom_varid( numror, 'ssh_ibb', ldstop = .FALSE. ) > 0 ) THEN  
    157157            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb read in the restart file' 
     158            IF(lrxios) CALL iom_swap( TRIM(crxios_context) ) 
    158159            CALL iom_get( numror, jpdom_autoglo, 'ssh_ibb', ssh_ibb, ldxios = lrxios )   ! before inv. barometer ssh 
     160            IF(lrxios) CALL iom_swap( TRIM(cxios_context) ) 
    159161            ! 
    160162         ELSE                                         !* no restart: set from nit000 values 
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/sbcblk.F90

    r10535 r11405  
    280280         ! 
    281281      ENDIF 
     282 
     283      IF(lxios_blkw) THEN 
     284         CALL iom_blk_wgt_init( cbwxios_context ) 
     285         CALL iom_swap( cxios_context ) 
     286      ENDIF 
     287       
    282288      ! 
    283289   END SUBROUTINE sbc_blk_init 
     
    681687      ! 
    682688   END FUNCTION L_vap 
     689 
     690   SUBROUTINE iom_blk_wgt_init( cdname, ld_tmppatch )  
     691#if defined key_iomput 
     692      use xios 
     693#endif 
     694      !!---------------------------------------------------------------------- 
     695      !!                     ***  ROUTINE   *** 
     696      !! 
     697      !! ** Purpose :   initialize context for reading weights for surface 
     698      !!                forcing 
     699      !! 
     700      !!---------------------------------------------------------------------- 
     701      CHARACTER(len=*),           INTENT(in)  :: cdname 
     702      LOGICAL         , OPTIONAL, INTENT(in)  :: ld_tmppatch 
     703#if defined key_iomput 
     704      ! 
     705      INTEGER, PARAMETER :: lcname = 26 
     706      CHARACTER(len=lc) :: clname 
     707      INTEGER           :: ji, jkmin 
     708      LOGICAL ::   ll_tmppatch = .TRUE.    !: seb: patch before we remove periodicity 
     709      INTEGER ::   nldi_save, nlei_save    !:      and close boundaries in output files 
     710      INTEGER ::   nldj_save, nlej_save    !: 
     711      LOGICAL ::   ll_global = .FALSE.     !: do we have variable on model grid 
     712      CHARACTER(len=lc), DIMENSION( jpts) :: cg_name(jpts) 
     713      CHARACTER(len=1), DIMENSION(lcname) :: cname 
     714      CHARACTER(len=lc)               :: cfname ! file name without .nc 
     715      TYPE(xios_duration)               :: dtime    = xios_duration(0, 0, 0, 0, 0, 0), & 
     716                                           outp_frq = xios_duration(0, 0, 0, 0, 0, 0) 
     717      TYPE(xios_domaingroup)            :: domaingroup_hdl 
     718      TYPE(xios_domain)                 :: domain_hdl 
     719      TYPE(xios_axisgroup)              :: axisgroup_hdl 
     720      TYPE(xios_axis)                   :: axis_hdl 
     721      TYPE(xios_scalar)                 :: scalar_hdl 
     722      TYPE(xios_scalargroup)            :: scalargroup_hdl 
     723      TYPE(xios_file)                   :: file_hdl 
     724      TYPE(xios_filegroup)              :: filegroup_hdl 
     725      TYPE(xios_field)                  :: field_hdl 
     726      INTEGER                           :: jf, ni, nj, ipos, jfld 
     727      INTEGER, DIMENSION(3)             :: ndims         ! size of each dimension. this is surface  
     728                                                         ! forcing, not more than 3: (x, y, t) 
     729      INTEGER                           :: ndim          ! number if dimensions  
     730      INTEGER                           :: inum          ! file id 
     731      INTEGER                           :: ivid          ! varable id in netcdf file 
     732      CHARACTER (len=5)                 :: aname         !name of the field in wght file 
     733      INTEGER                           :: numwgt        ! 
     734      LOGICAL                           :: lfound 
     735      INTEGER                           :: jg, id, jn 
     736       
     737 
     738      cname(:)= (/'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', & 
     739                  'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', & 
     740                  'u', 'v', 'w', 'x', 'y', 'z'/) 
     741      !!---------------------------------------------------------------------- 
     742      ! 
     743      ! seb: patch before we remove periodicity and close boundaries in output files 
     744      IF ( ll_tmppatch ) THEN 
     745         nldi_save = nldi   ;   nlei_save = nlei 
     746         nldj_save = nldj   ;   nlej_save = nlej 
     747         IF( nimpp           ==      1 ) nldi = 1 
     748         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi 
     749         IF( njmpp           ==      1 ) nldj = 1 
     750         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj 
     751      ENDIF 
     752      ! 
     753      jfld = SIZE(sf) 
     754 
     755      IF(jfld > lcname) THEN 
     756      STOP 'lcname number is too small' 
     757      ENDIF 
     758 
     759      clname = cdname 
     760      IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname) 
     761      CALL xios_context_initialize(TRIM(clname), mpi_comm_oce) 
     762      CALL iom_swap( cdname ) 
     763      ! Calendar type is now defined in xml file  
     764      SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL 
     765      CASE ( 1)   ; CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(1948, 01, 01, 00, 00, 00), & 
     766          &                                    start_date = xios_date(nyear, nmonth, nday,00,00,00) ) 
     767      CASE ( 0)   ; CALL xios_define_calendar( TYPE = "NoLeap"   , time_origin = xios_date(1948, 01, 01, 00, 00, 00), & 
     768          &                                    start_date = xios_date(nyear, nmonth, nday,00,00,00) ) 
     769      CASE (30)   ; CALL xios_define_calendar( TYPE = "D360"     , time_origin = xios_date(1948, 01, 01, 00, 00, 00), & 
     770          &                                    start_date = xios_date(nyear, nmonth, nday, 00, 00, 00) ) 
     771      END SELECT 
     772 
     773 
     774      dtime%month = 1 
     775      CALL xios_set_timestep( dtime ) 
     776 
     777      CALL xios_get_handle("domain_definition",domaingroup_hdl) 
     778      CALL xios_add_child(domaingroup_hdl, domain_hdl, "grid_global") 
     779      ni = nlei-nldi+1 
     780      nj = nlej-nldj+1 
     781      CALL xios_set_domain_attr("grid_global", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) 
     782      CALL xios_set_domain_attr("grid_global", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 
     783      CALL xios_set_domain_attr("grid_global", type='curvilinear') 
     784 
     785      CALL xios_get_handle("file_definition", filegroup_hdl ) 
     786 
     787      DO jf = 1, jfld 
     788!do we have weights file defined already? 
     789         lfound = .FALSE. 
     790         DO jg = 1, jf-1 
     791            IF(TRIM(sf(jf)%wgtname) == TRIM(sf(jg)%wgtname)) THEN 
     792               IF(lwp) write(numout, *) TRIM(sf(jf)%wgtname),' already defined, skipping ' 
     793               lfound = .TRUE. 
     794               exit 
     795            ENDIF 
     796         ENDDO 
     797         IF(lfound) cycle 
     798!add next weights file 
     799         ipos = index(sf(jf)%wgtname,'.nc') 
     800         cfname(1:lc) = " " 
     801         IF(ipos > 0) THEN 
     802          cfname(1:ipos-1) = sf(jf)%wgtname(1:ipos-1) 
     803         ELSE 
     804          cfname(1:lc) = sf(jf)%wgtname(1:lc) 
     805         ENDIF 
     806 
     807         CALL xios_add_child(filegroup_hdl, file_hdl, cname(jf)) 
     808         CALL xios_set_file_attr( cname(jf), name=TRIM(cfname),           & 
     809                type="one_file", par_access="collective", enabled=.TRUE., & 
     810                output_freq=xios_timestep, mode="read") 
     811 
     812         CALL iom_open ( sf(jf)%wgtname, inum ) 
     813         id = iom_varid(inum, 'src05', ldstop=.FALSE.) 
     814         IF(id <= 0) THEN 
     815             numwgt = 4 
     816         ELSE 
     817             numwgt = 16 
     818         ENDIF 
     819         CALL iom_close ( inum ) 
     820!define variables in weights file. Because all files have the same names src01, 
     821!dst01, ... add filename to the name to uniquely identify variables  
     822         aname = ' ' 
     823         DO jn = 1, numwgt 
     824            WRITE(aname,'(a3,i2.2)') 'src',jn 
     825            CALL xios_add_child(file_hdl, field_hdl, TRIM(aname)//TRIM(sf(jf)%wgtname)) 
     826            CALL xios_set_attr (field_hdl, enabled = .TRUE., & 
     827                          name = TRIM(aname), domain_ref="grid_global", & 
     828                          operation = "instant") 
     829            CALL xios_add_child(file_hdl, field_hdl, TRIM(aname)//TRIM(sf(jf)%wgtname)) 
     830            CALL xios_set_attr (field_hdl, enabled = .TRUE., & 
     831                          name = TRIM(aname), domain_ref="grid_global", & 
     832                          operation = "instant")  
     833         ENDDO  
     834      ENDDO    
     835 
     836 
     837      CALL xios_close_context_definition() 
     838      CALL xios_update_calendar( 0 ) 
     839 
     840      IF ( ll_tmppatch ) THEN 
     841         nldi = nldi_save   ;   nlei = nlei_save 
     842         nldj = nldj_save   ;   nlej = nlej_save 
     843      ENDIF 
     844#endif 
     845      ! 
     846   END SUBROUTINE iom_blk_wgt_init 
     847 
    683848 
    684849#if defined key_si3 
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/sbcisf.F90

    r10536 r11405  
    207207            &   iom_varid( numror, 'fwf_isf_b', ldstop = .FALSE. ) > 0 ) THEN 
    208208            IF(lwp) WRITE(numout,*) '          nit000-1 isf tracer content forcing fields read in the restart file' 
     209            IF(lrxios) CALL iom_swap( TRIM(crxios_context) ) 
    209210            CALL iom_get( numror, jpdom_autoglo, 'fwf_isf_b', fwfisf_b(:,:)         , ldxios = lrxios )   ! before salt content isf_tsc trend 
    210211            CALL iom_get( numror, jpdom_autoglo, 'isf_sc_b' , risf_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salt content isf_tsc trend 
    211212            CALL iom_get( numror, jpdom_autoglo, 'isf_hc_b' , risf_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before salt content isf_tsc trend 
     213            IF(lrxios) CALL iom_swap( TRIM(cxios_context) ) 
    212214         ELSE 
    213215            fwfisf_b(:,:)    = fwfisf(:,:) 
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/sbcmod.F90

    r10499 r11405  
    496496            & iom_varid( numror, 'utau_b', ldstop = .FALSE. ) > 0 ) THEN 
    497497            IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields red in the restart file' 
     498            IF(lrxios) CALL iom_swap( TRIM(crxios_context) ) 
    498499            CALL iom_get( numror, jpdom_autoglo, 'utau_b', utau_b, ldxios = lrxios )   ! before i-stress  (U-point) 
    499500            CALL iom_get( numror, jpdom_autoglo, 'vtau_b', vtau_b, ldxios = lrxios )   ! before j-stress  (V-point) 
     
    508509               sfx_b (:,:) = sfx(:,:) 
    509510            ENDIF 
     511            IF(lrxios) CALL iom_swap( TRIM(cxios_context) ) 
    510512         ELSE                                                   !* no restart: set from nit000 values 
    511513            IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields set to nit000' 
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/sbcrnf.F90

    r10523 r11405  
    146146         IF( ln_rstart .AND.    &                               !* Restart: read in restart file 
    147147            & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN 
     148            IF(lrxios) CALL iom_swap( TRIM(crxios_context) ) 
    148149            IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields red in the restart file', lrxios 
    149150            CALL iom_get( numror, jpdom_autoglo, 'rnf_b', rnf_b, ldxios = lrxios )     ! before runoff 
    150151            CALL iom_get( numror, jpdom_autoglo, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before heat content of runoff 
    151152            CALL iom_get( numror, jpdom_autoglo, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salinity content of runoff 
     153            IF(lrxios) CALL iom_swap( TRIM(cxios_context) ) 
    152154         ELSE                                                   !* no restart: set from nit000 values 
    153155            IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000' 
  • NEMO/branches/2019/dev_r11351_fldread_with_XIOS/src/OCE/SBC/sbcssm.F90

    r10425 r11405  
    209209         IF( ln_rstart .AND. iom_varid( numror, 'nn_fsbc', ldstop = .FALSE. ) > 0 ) THEN 
    210210            l_ssm_mean = .TRUE. 
     211            IF(lrxios) CALL iom_swap( TRIM(crxios_context) ) 
    211212            CALL iom_get( numror               , 'nn_fsbc', zf_sbc, ldxios = lrxios )    ! sbc frequency of previous run 
    212213            CALL iom_get( numror, jpdom_autoglo, 'ssu_m'  , ssu_m, ldxios = lrxios  )    ! sea surface mean velocity    (U-point) 
     
    222223               frq_m(:,:) = 1._wp   ! default definition 
    223224            ENDIF 
     225            IF(lrxios) CALL iom_swap( TRIM(cxios_context) ) 
    224226            ! 
    225227            IF( zf_sbc /= REAL( nn_fsbc, wp ) ) THEN      ! nn_fsbc has changed between 2 runs 
Note: See TracChangeset for help on using the changeset viewer.