Changeset 2509


Ignore:
Timestamp:
May 12, 2016, 12:18:20 PM (9 years ago)
Author:
Laurent Fairhead
Message:

Modifications for the XIOS 2 I/O library

LMDZ will now, by default, use the XIOS 2 library. If you need/want to link LMDZ
with the XIOS 1 library you will need to add the XIOS1 cpp key to your compilation thus:

makelmdz_fcm -d ... -cpp XIOS1 ... gcm

and then use the XIOS1 xml files for LMDZ that are in LMDZ/DefLists:

DefLists?/iodef_XIOS1.0.xml
DefLists?/context_lmdz_XIOS1.0.xml

as there are some incompatibilities between XIOS 1 and XIOS 2.

LF

Location:
LMDZ5/trunk
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • LMDZ5/trunk/DefLists/context_lmdz.xml

    r2156 r2509  
    11<!-- Context LMDZ -->
    2 <context id="LMDZ" calendar_type="D360" start_date="1980-01-01 00:00:00">
     2<context id="LMDZ">
     3<!--  <calendar type="D360" start_date="1980-01-01 00:00:00" /> -->
    34 
    45  <!-- Define available variables -->
     
    2728 
    2829  <!-- Need to define a grid? Do it here -->
    29   <grid_definition>
     30<!--  <grid_definition>
    3031    <grid_group id="vertical" axis_ref="presnivs" />
    31   </grid_definition>
     32  </grid_> -->
    3233 
    3334  <!-- Define groups of vertical axes -->
  • LMDZ5/trunk/DefLists/iodef.xml

    r2013 r2509  
    1010
    1111                <variable_group id="parameters" >
    12                         <variable id="using_server" type="boolean">true</variable>
     12                        <variable id="using_server" type="bool">true</variable>
    1313                        <variable id="info_level" type="int">0</variable>
    1414                </variable_group>
  • LMDZ5/trunk/DefLists/iodef_XIOS1.0.xml

    r2508 r2509  
    1010
    1111                <variable_group id="parameters" >
    12                         <variable id="using_server" type="boolean">true</variable>
     12                        <variable id="using_server" type="bool">true</variable>
    1313                        <variable id="info_level" type="int">0</variable>
    1414                </variable_group>
  • LMDZ5/trunk/libf/misc/wxios.F90

    r2362 r2509  
    1 ! $Id: wxios.F90 $
     1! $Id$
    22#ifdef CPP_XIOS
    33MODULE wxios
     
    3333    SUBROUTINE reformadate(odate, ndate)
    3434        CHARACTER(len=*), INTENT(IN) :: odate
     35#ifdef XIOS1
    3536        CHARACTER(len=100), INTENT(OUT) :: ndate
     37#else
     38        TYPE(xios_duration) :: ndate
     39#endif
    3640       
    3741        INTEGER :: i = 0
     
    4852        i = INDEX(odate, "day")
    4953        IF (i > 0) THEN
     54#ifdef XIOS1
    5055            ndate = odate(1:i-1)//"d"
     56#else
     57            read(odate(1:i-1),*) ndate%day
     58#endif
    5159        END IF
    5260
    5361        i = INDEX(odate, "hr")
    5462        IF (i > 0) THEN
     63#ifdef XIOS1
    5564            ndate = odate(1:i-1)//"h"
     65#else
     66            read(odate(1:i-1),*) ndate%hour
     67#endif
    5668        END IF
    5769
    5870        i = INDEX(odate, "mth")
    5971        IF (i > 0) THEN
     72#ifdef XIOS1
    6073            ndate = odate(1:i-1)//"mo"
     74#else
     75            read(odate(1:i-1),*) ndate%month
     76#endif
    6177        END IF
    6278       
     
    99115
    100116    SUBROUTINE wxios_init(xios_ctx_name, locom, outcom, type_ocean)
    101         IMPLICIT NONE
    102         INCLUDE 'iniprint.h'
     117        USE print_control_mod, ONLY : prt_level, lunout
     118        IMPLICIT NONE
    103119
    104120      CHARACTER(len=*), INTENT(IN) :: xios_ctx_name
     
    140156
    141157    SUBROUTINE wxios_context_init()
    142         IMPLICIT NONE
    143         INCLUDE 'iniprint.h'
     158        USE print_control_mod, ONLY : prt_level, lunout
     159!        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
     160        IMPLICIT NONE
    144161
    145162        TYPE(xios_context) :: xios_ctx
    146163
     164!$OMP MASTER
    147165        !Initialisation du contexte:
    148166        CALL xios_context_initialize(g_ctx_name, g_comm)
     
    157175        !Une première analyse des héritages:
    158176        CALL xios_solve_inheritance()
     177!$OMP END MASTER
    159178    END SUBROUTINE wxios_context_init
    160179
     
    164183
    165184    SUBROUTINE wxios_set_cal(pasdetemps, calendrier, annee, mois, jour, heure, ini_an, ini_mois, ini_jour, ini_heure)
    166         IMPLICIT NONE
    167         INCLUDE 'iniprint.h'
     185        USE print_control_mod, ONLY : prt_level, lunout
     186        IMPLICIT NONE
    168187
    169188     !Paramètres:
     
    178197     
    179198     !Variables pour xios:
     199#ifdef XIOS1
    180200     TYPE(xios_time) :: mdtime
     201#else
     202     TYPE(xios_duration) :: mdtime
     203#endif
    181204     !REAL(kind = 8) :: year=0, month=0, day=0, hour=0, minute=0, second=0
    182205     
     206#ifdef XIOS1
    183207        mdtime = xios_time(0, 0, 0, 0, 0, pasdetemps)
     208#else
     209        mdtime%second=pasdetemps
     210#endif
    184211
    185212        !Réglage du calendrier:
     213#ifdef XIOS1
    186214        SELECT CASE (calendrier)
    187215            CASE('earth_360d')
     
    198226                CALL abort_gcm('Gcm:Xios',abort_message,1)
    199227        END SELECT
     228#else
     229        SELECT CASE (calendrier)
     230            CASE('earth_360d')
     231                CALL xios_define_calendar("D360")
     232                IF (prt_level >= 10) WRITE(lunout,*) 'wxios_set_cal: Calendrier terrestre a 360 jours/an'
     233            CASE('earth_365d')
     234                CALL xios_define_calendar("NoLeap")
     235                IF (prt_level >= 10) WRITE(lunout,*) 'wxios_set_cal: Calendrier terrestre a 365 jours/an'
     236            CASE('gregorian')
     237                CALL xios_define_calendar("Gregorian")
     238                IF (prt_level >= 10) WRITE(lunout,*) 'wxios_set_cal: Calendrier gregorien'
     239            CASE DEFAULT
     240                abort_message = 'wxios_set_cal: Mauvais choix de calendrier'
     241                CALL abort_gcm('Gcm:Xios',abort_message,1)
     242        END SELECT
     243#endif
    200244       
    201245        !Formatage de la date d'origine:
    202         WRITE(date, "(i4.4,'-',i2.2,'-',i2.2,' ',i2.2,':00:00')") annee, mois, jour, int(heure)
     246        WRITE(date, "(i4.4,'-',i2.2,'-',i2.2,' ',i2.2,':00:00')") annee, mois, jour, int(heure) 
    203247       
    204248        IF (prt_level >= 10) WRITE(lunout,*) "wxios_set_cal: Time origin: ", date
    205        
     249#ifdef XIOS1
    206250        CALL xios_set_context_attr_hdl(g_ctx, time_origin = date)
     251#else
     252        CALL xios_set_time_origin(xios_date(annee,mois,jour,int(heure),0,0))
     253#endif
    207254
    208255        !Formatage de la date de debut:
     
    212259        IF (prt_level >= 10) WRITE(lunout,*) "wxios_set_cal: Start date: ", date
    213260       
     261#ifdef XIOS1
    214262        CALL xios_set_context_attr_hdl(g_ctx, start_date = date)
     263#else
     264        CALL xios_set_start_date(xios_date(ini_an,ini_mois,ini_jour,int(ini_heure),0,0))
     265#endif
    215266       
    216267        !Et enfin,le pas de temps:
     
    221272    SUBROUTINE wxios_set_timestep(ts)
    222273        REAL, INTENT(IN) :: ts
     274#ifdef XIOS1
    223275        TYPE(xios_time) :: mdtime     
    224276
    225277        mdtime = xios_time(0, 0, 0, 0, 0, ts)
     278#else
     279        TYPE(xios_duration) :: mdtime     
     280
     281        mdtime%timestep = ts
     282#endif
    226283
    227284        CALL xios_set_timestep(mdtime)
     
    237294         
    238295
    239         IMPLICIT NONE
    240         INCLUDE 'iniprint.h'
     296        USE print_control_mod, ONLY : prt_level, lunout
     297        IMPLICIT NONE
    241298
    242299        CHARACTER(len=*),INTENT(IN) :: dom_id ! domain identifier
     
    277334       
    278335        !On parametrise le domaine:
     336#ifdef XIOS1
    279337        CALL xios_set_domain_attr_hdl(dom, ni_glo=ni_glo, ibegin=ibegin, ni=ni)
    280338        CALL xios_set_domain_attr_hdl(dom, nj_glo=nj_glo, jbegin=jbegin, nj=nj, data_dim=2)
    281339        CALL xios_set_domain_attr_hdl(dom, lonvalue=io_lon(ibegin:iend), latvalue=io_lat(jbegin:jend))
    282 
     340#else
     341        CALL xios_set_domain_attr_hdl(dom, ni_glo=ni_glo, ibegin=ibegin-1, ni=ni, type="rectilinear")
     342        CALL xios_set_domain_attr_hdl(dom, nj_glo=nj_glo, jbegin=jbegin-1, nj=nj, data_dim=2)
     343        CALL xios_set_domain_attr_hdl(dom, lonvalue_1d=io_lon(ibegin:iend), latvalue_1d=io_lat(jbegin:jend))
     344#endif
    283345        IF (.NOT.is_sequential) THEN
    284346            mask(:,:)=.TRUE.
     
    291353              WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," mask(:,nj)=",mask(:,nj)
    292354            ENDIF
     355#ifdef XIOS1
    293356            CALL xios_set_domain_attr_hdl(dom, mask=mask)
     357#else
     358            CALL xios_set_domain_attr_hdl(dom, mask_2d=mask)
     359#endif
    294360        END IF
    295361
     
    307373    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    308374    SUBROUTINE wxios_add_vaxis(axis_id, axis_size, axis_value)
    309         IMPLICIT NONE
    310         INCLUDE 'iniprint.h'
     375        USE print_control_mod, ONLY : prt_level, lunout
     376        IMPLICIT NONE
    311377
    312378        CHARACTER (len=*), INTENT(IN) :: axis_id
     
    335401       
    336402        ! Ehouarn: New way to declare axis, without axis_group:
     403#ifdef XIOS1
    337404        CALL xios_set_axis_attr(trim(axis_id),size=axis_size,value=axis_value)
    338        
     405#else
     406        CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value)
     407#endif       
    339408        !Vérification:
    340409        IF (xios_is_valid_axis(TRIM(ADJUSTL(axis_id)))) THEN
     
    351420    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    352421    SUBROUTINE wxios_add_file(fname, ffreq, flvl)
    353         IMPLICIT NONE
    354         INCLUDE 'iniprint.h'
     422        USE print_control_mod, ONLY : prt_level, lunout
     423        IMPLICIT NONE
    355424
    356425        CHARACTER(len=*), INTENT(IN) :: fname
     
    360429        TYPE(xios_file) :: x_file
    361430        TYPE(xios_filegroup) :: x_fg
     431#ifdef XIOS1
    362432        CHARACTER(len=100) :: nffreq
     433#else
     434        TYPE(xios_duration) :: nffreq
     435#endif
    363436       
    364437        !On regarde si le fichier n'est pas défini par XML:
     
    372445       
    373446            !On configure:
     447#ifdef XIOS1
    374448            CALL xios_set_file_attr_hdl(x_file, name="X"//fname,&
    375449                output_freq=TRIM(ADJUSTL(nffreq)), output_level=flvl, enabled=.TRUE.)
    376        
     450#else
     451            CALL xios_set_file_attr_hdl(x_file, name="X"//fname,&
     452                output_freq=nffreq, output_level=flvl, enabled=.TRUE.)
     453#endif
     454       
    377455            IF (xios_is_valid_file("X"//fname)) THEN
    378456                IF (prt_level >= 10) THEN
    379457                  WRITE(lunout,*) "wxios_add_file: New file: ", "X"//fname
     458#ifdef XIOS1
    380459                  WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
     460#else
     461                  WRITE(lunout,*) "wxios_add_file: output_freq=",nffreq,"; output_lvl=",flvl
     462#endif
    381463                ENDIF
    382464            ELSE
    383465                WRITE(lunout,*) "wxios_add_file: Error, invalid file: ", "X"//trim(fname)
     466#ifdef XIOS1
    384467                WRITE(lunout,*) "wxios_add_file: output_freq=",TRIM(ADJUSTL(nffreq)),"; output_lvl=",flvl
     468#else
     469                WRITE(lunout,*) "wxios_add_file: output_freq=",nffreq,"; output_lvl=",flvl
     470#endif
    385471            END IF
    386472        ELSE
     
    435521    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    436522    SUBROUTINE wxios_add_field_to_file(fieldname, fdim, fid, fname, fieldlongname, fieldunit, field_level, op, nam_axvert)
    437         IMPLICIT NONE
    438         INCLUDE 'iniprint.h'
     523        USE print_control_mod, ONLY : prt_level, lunout
     524        IMPLICIT NONE
    439525
    440526        CHARACTER(len=*), INTENT(IN) :: fieldname
     
    452538        TYPE(xios_field) :: field
    453539        TYPE(xios_fieldgroup) :: fieldgroup
     540#ifndef XIOS1
     541        TYPE(xios_duration) :: freq_op
     542#endif
    454543        LOGICAL :: bool=.FALSE.
    455544        INTEGER :: lvl =0
     
    510599           
    511600            !L'operation, sa frequence:
     601#ifdef XIOS1
    512602            CALL xios_set_field_attr_hdl(field, field_ref=fieldname, operation=TRIM(ADJUSTL(operation)), freq_op="1ts", prec=4)
     603#else
     604            freq_op%timestep=1
     605            CALL xios_set_field_attr_hdl(field, field_ref=fieldname, operation=TRIM(ADJUSTL(operation)), freq_op=freq_op, prec=4)
     606#endif
    513607
    514608           
Note: See TracChangeset for help on using the changeset viewer.