Ignore:
Timestamp:
Mar 31, 2017, 11:31:38 AM (8 years ago)
Author:
emillour
Message:

All GCMs: set things up to enable pluging physics with dynamico

  • dyn3d
  • gcm.F90 : move I/O initialization (dates) to be done before physics

initialization

  • dyn3dpar
  • gcm.F : move I/O initialization (dates) to be done before physics

initialization

  • dynphy_lonlat:
  • inigeomphy_mod.F90 : add ind_cell_glo computation and transfer

to init_geometry

  • phy_common:
  • geometry_mod.F90 : add ind_cell_glo module variable to store global

column index

  • print_control_mod.F90 : make initialization occur via init_print_control_mod

to avoid circular module dependencies

  • init_print_control_mod.F90 : added to initialize print_control_mod module

variables

  • mod_phys_lmdz_mpi_data.F90 : use print_control_mod (rather than iniprint.h)
  • mod_phys_lmdz_para.F90 : use print_control_mod (rather than iniprint.h)
  • mod_phys_lmdz_omp_data.F90 : add is_omp_master (alias of is_omp_root) module

variable and use print_control_mod (rather than
iniprint.h)

  • physics_distribution_mod.F90 : add call to init_dimphy in

init_physics_distribution

  • xios_writefield.F90 : generic routine to output field with XIOS (for debug)
  • misc:
  • handle_err_m.F90 : call abort_physic, rather than abort_gcm
  • wxios.F90 : updates to enable unstructured grids

set module variable g_ctx_name to "LMDZ"
wxios_init(): remove call to wxios_context_init
wxios_context_init(): call xios_context_initialize with COMM_LMDZ_PHY
add routine wxios_set_context() to get handle and set context to XIOS
wxios_domain_param(): change arguments and generate the domain in-place
add wxios_domain_param_unstructured(): generate domain for unstructured case

NB: access is via "domain group" (whereas it is via "domain" in

wxios_domain_param)

  • dynphy_lonlat/phy[std|mars|venus|titan]:
  • iniphysiq_mod.F90 : Remove call to init_dimphy (which is now done in

phy_common/physics_distribution_mod.F90)

EM

Location:
trunk/LMDZ.COMMON/libf/misc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/misc/handle_err_m.F90

    r1391 r1682  
    3939          end if
    4040       end if
    41        call abort_gcm("NetCDF95 handle_err", "", 1)
     41       call abort_physic("NetCDF95 handle_err", "", 1)
    4242    end if
    4343
  • trunk/LMDZ.COMMON/libf/misc/wxios.F90

    r1650 r1682  
    1515   
    1616    INTEGER, SAVE :: g_comm
    17     CHARACTER(len=100), SAVE :: g_ctx_name
     17    CHARACTER(len=100), SAVE :: g_ctx_name ="LMDZ"
    1818    TYPE(xios_context), SAVE :: g_ctx
    1919!$OMP THREADPRIVATE(g_comm,g_cts_name,g_ctx)
     
    136136        g_ctx_name = xios_ctx_name
    137137       
    138         ! Si couple alors init fait dans cpl_init
    139         IF (.not. PRESENT(type_ocean)) THEN
    140             CALL wxios_context_init()
    141         ENDIF
     138!        ! Si couple alors init fait dans cpl_init
     139!        IF (.not. PRESENT(type_ocean)) THEN
     140!            CALL wxios_context_init()
     141!        ENDIF
    142142
    143143    END SUBROUTINE wxios_init
     
    145145    SUBROUTINE wxios_context_init()
    146146        USE print_control_mod, ONLY : prt_level, lunout
    147 !        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
     147        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
    148148        IMPLICIT NONE
    149149
     
    152152!$OMP MASTER
    153153        !Initialisation du contexte:
    154         CALL xios_context_initialize(g_ctx_name, g_comm)
     154        CALL xios_context_initialize(g_ctx_name, COMM_LMDZ_PHY)
    155155        CALL xios_get_handle(g_ctx_name, xios_ctx)    !Récupération
    156156        CALL xios_set_current_context(xios_ctx)            !Activation
     
    165165!$OMP END MASTER
    166166    END SUBROUTINE wxios_context_init
     167
     168
     169    SUBROUTINE wxios_set_context()
     170        IMPLICIT NONE
     171        TYPE(xios_context) :: xios_ctx
     172
     173       !$OMP MASTER
     174        CALL xios_get_handle(g_ctx_name, xios_ctx)    !Récupération
     175        CALL xios_set_current_context(xios_ctx)            !Activation
     176       !$OMP END MASTER
     177
     178    END SUBROUTINE wxios_set_context
    167179
    168180    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
    203215            CASE DEFAULT
    204216                abort_message = 'wxios_set_cal: Mauvais choix de calendrier'
    205                 CALL abort_gcm('Gcm:Xios',abort_message,1)
     217                CALL abort_physic('Gcm:Xios',abort_message,1)
    206218        END SELECT
    207219       
     
    210222       
    211223        IF (prt_level >= 10) WRITE(lunout,*) "wxios_set_cal: Time origin: ", date
     224
    212225        CALL xios_set_time_origin(xios_date(annee,mois,jour,int(heure),0,0))
    213226
     
    237250    ! Pour initialiser un domaine !!!!!!!!!!!!!!!!!!!!
    238251    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    239     SUBROUTINE wxios_domain_param(dom_id, is_sequential, ni, nj, ni_glo, nj_glo,        &
    240                                     ibegin, iend, ii_begin, ii_end, jbegin, jend,       &
    241                                     data_ni, data_ibegin, data_iend,                    &
    242                                     io_lat, io_lon,is_south_pole,mpi_rank)
    243          
    244 
    245         USE print_control_mod, ONLY : prt_level, lunout
    246         IMPLICIT NONE
    247 
     252    SUBROUTINE wxios_domain_param(dom_id,flip_coordinates)
     253       USE dimphy, only: klon
     254       USE mod_phys_lmdz_transfert_para, ONLY: gather, bcast
     255       USE mod_phys_lmdz_para, only: jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
     256                                     mpi_size, mpi_rank, klon_mpi, &
     257                                     is_sequential, is_south_pole_dyn
     258       USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat, klon_glo         
     259       USE print_control_mod, ONLY : prt_level, lunout
     260       USE geometry_mod
     261
     262       IMPLICIT NONE
    248263        CHARACTER(len=*),INTENT(IN) :: dom_id ! domain identifier
    249         LOGICAL,INTENT(IN) :: is_sequential ! flag
    250         INTEGER,INTENT(IN) :: ni ! local MPI domain number of longitudes
    251         INTEGER,INTENT(IN) :: nj ! local MPI domain number of latitudes
    252         INTEGER,INTENT(IN) :: ni_glo ! global grid number of longitudes
    253         INTEGER,INTENT(IN) :: nj_glo ! global grid number of latitudes
    254         INTEGER,INTENT(IN) :: ibegin ! start index, on global grid, of local MPI domain
    255         INTEGER,INTENT(IN) :: iend ! end index, on global grid, of local MPI domain
    256         INTEGER,INTENT(IN) :: ii_begin ! i index at which local data starts (first row)
    257         INTEGER,INTENT(IN) :: ii_end ! i index at which local data ends (last row)
    258         INTEGER,INTENT(IN) :: jbegin ! start index, on global grid, of local MPI domain
    259         INTEGER,INTENT(IN) :: jend ! end index, on global grid, of local MPI domain
    260         INTEGER,INTENT(IN) :: data_ni
    261         INTEGER,INTENT(IN) :: data_ibegin
    262         INTEGER,INTENT(IN) :: data_iend
    263         REAL,INTENT(IN) :: io_lat(:) ! latitudes (of global grid)
    264         REAL,INTENT(IN) :: io_lon(:) ! longitudes (of global grid)
    265         logical,intent(in) :: is_south_pole ! does this process include the south pole?
    266         integer,intent(in) :: mpi_rank ! rank of process
    267        
     264        LOGICAL,OPTIONAL,INTENT(IN) :: flip_coordinates ! .true. to change signs
     265                                                        ! of coordinates
     266        LOGICAL :: flip_axes=.false. ! default; do not swap axes
     267        REAL   :: rlat_glo(klon_glo)
     268        REAL   :: rlon_glo(klon_glo)
     269        REAL   :: io_lat(nbp_lat)
     270        REAL   :: io_lon(nbp_lon)
     271        LOGICAL :: mask(nbp_lon,jj_nb) !Masque pour les problèmes de recouvrement MPI
    268272        TYPE(xios_domain) :: dom
     273        INTEGER :: i
    269274        LOGICAL :: boool
    270275       
    271         !Masque pour les problèmes de recouvrement MPI:
    272         LOGICAL :: mask(ni,nj)
     276
     277        IF (flip_axes) THEN
     278          ! change signs of axes
     279          CALL gather(-latitude_deg,rlat_glo)
     280          CALL bcast(rlat_glo)
     281          CALL gather(-longitude_deg,rlon_glo)
     282          CALL bcast(rlon_glo)
     283        ELSE
     284          CALL gather(latitude_deg,rlat_glo)
     285          CALL bcast(rlat_glo)
     286          CALL gather(longitude_deg,rlon_glo)
     287          CALL bcast(rlon_glo)
     288        ENDIF
     289   
     290  !$OMP MASTER 
     291        io_lat(1)=rlat_glo(1)
     292        io_lat(nbp_lat)=rlat_glo(klon_glo)
     293        IF ((nbp_lon*nbp_lat) > 1) then
     294          DO i=2,nbp_lat-1
     295            io_lat(i)=rlat_glo(2+(i-2)*nbp_lon)
     296          ENDDO
     297        ENDIF
     298
     299        IF (klon_glo == 1) THEN
     300          io_lon(1)=rlon_glo(1)
     301        ELSE
     302          io_lon(1:nbp_lon)=rlon_glo(2:nbp_lon+1)
     303        ENDIF
     304
    273305       
    274306        !On récupère le handle:
    275307        CALL xios_get_domain_handle(dom_id, dom)
    276308       
    277         IF (prt_level >= 10) THEN
    278           WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," ni:",ni," ni_glo:", ni_glo, " nj:", nj, " nj_glo:", nj_glo
    279           WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," ibegin:",ibegin," iend:", iend, " jbegin:", jbegin, " jend:", jend
    280           WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," ii_begin:",ii_begin," ii_end:", ii_end
    281           WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," Size io_lon:", SIZE(io_lon(ibegin:iend)), " io_lat:", SIZE(io_lat(jbegin:jend))
    282         ENDIF
    283        
    284309        !On parametrise le domaine:
    285         CALL xios_set_domain_attr_hdl(dom, ni_glo=ni_glo, ibegin=ibegin-1, ni=ni, type="rectilinear")
    286         CALL xios_set_domain_attr_hdl(dom, nj_glo=nj_glo, jbegin=jbegin-1, nj=nj, data_dim=2)
    287         CALL xios_set_domain_attr_hdl(dom, lonvalue_1d=io_lon(ibegin:iend), latvalue_1d=io_lat(jbegin:jend))
     310        CALL xios_set_domain_attr_hdl(dom, ni_glo=nbp_lon, ibegin=0, ni=nbp_lon, type="rectilinear")
     311        CALL xios_set_domain_attr_hdl(dom, nj_glo=nbp_lat, jbegin=jj_begin-1, nj=jj_nb, data_dim=2)
     312        CALL xios_set_domain_attr_hdl(dom, lonvalue_1d=io_lon(1:nbp_lon), latvalue_1d=io_lat(jj_begin:jj_end))
     313
    288314        IF (.NOT.is_sequential) THEN
    289315            mask(:,:)=.TRUE.
    290316            if (ii_begin>1) mask(1:ii_begin-1,1) = .FALSE.
    291             if (ii_end<ni) mask(ii_end+1:ni,nj) = .FALSE.
     317            if (ii_end<nbp_lon) mask(ii_end+1:nbp_lon,jj_nb) = .FALSE.
    292318            ! special case for south pole
    293             if ((ii_end.eq.1).and.(is_south_pole)) mask(1:ni,nj)=.true.
     319            if ((ii_end==1).and.(is_south_pole_dyn)) mask(1:nbp_lon,jj_nb)=.true.
    294320            IF (prt_level >= 10) THEN
    295321              WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," mask(:,1)=",mask(:,1)
    296               WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," mask(:,nj)=",mask(:,nj)
     322              WRITE(lunout,*) "wxios_domain_param: mpirank=",mpi_rank," mask(:,jj_nb)=",mask(:,jj_nb)
    297323            ENDIF
    298324            CALL xios_set_domain_attr_hdl(dom, mask_2d=mask)
     
    306332            IF (prt_level >= 10) WRITE(lunout,*) "wxios_domain_param: Invalid domain: ", trim(dom_id)
    307333        END IF
     334!$OMP END MASTER
     335       
    308336    END SUBROUTINE wxios_domain_param
    309337   
     338
     339    SUBROUTINE wxios_domain_param_unstructured(dom_id,flip_coordinates)
     340        USE geometry_mod, ONLY : longitude, latitude, boundslon, boundslat,ind_cell_glo
     341        USE mod_grid_phy_lmdz, ONLY : nvertex, klon_glo
     342        USE mod_phys_lmdz_para
     343        USE nrtype, ONLY : PI
     344        IMPLICIT NONE
     345        CHARACTER(len=*),INTENT(IN) :: dom_id ! domain identifier
     346        LOGICAL,OPTIONAL,INTENT(IN) :: flip_coordinates ! .true. to change signs
     347                                                        ! of coordinates
     348        LOGICAL :: flip_axes=.false. ! default; do not swap axes
     349        REAL :: lon_mpi(klon_mpi)
     350        REAL :: lat_mpi(klon_mpi)
     351        REAL :: boundslon_mpi(klon_mpi,nvertex)
     352        REAL :: boundslat_mpi(klon_mpi,nvertex)
     353        INTEGER :: ind_cell_glo_mpi(klon_mpi)
     354        TYPE(xios_domaingroup) :: dom
     355
     356        IF (PRESENT(flip_coordinates)) flip_axes=flip_coordinates
     357       
     358        IF (flip_axes) THEN
     359          ! change signs of axes and boundaries
     360          CALL gather_omp(-longitude*180/PI,lon_mpi)
     361          CALL gather_omp(-latitude*180/PI,lat_mpi)
     362          CALL gather_omp(-boundslon*180/PI,boundslon_mpi)
     363          CALL gather_omp(-boundslat*180/PI,boundslat_mpi)
     364        ELSE
     365          CALL gather_omp(longitude*180/PI,lon_mpi)
     366          CALL gather_omp(latitude*180/PI,lat_mpi)
     367          CALL gather_omp(boundslon*180/PI,boundslon_mpi)
     368          CALL gather_omp(boundslat*180/PI,boundslat_mpi)
     369        ENDIF
     370        CALL gather_omp(ind_cell_glo,ind_cell_glo_mpi)
     371       
     372
     373!$OMP MASTER
     374        CALL xios_get_domaingroup_handle(dom_id, dom)
     375       
     376        !On parametrise le domaine:
     377        CALL xios_set_attr(dom, ni_glo=klon_glo, ibegin=ij_begin-1, ni=ij_nb, type="unstructured")
     378        CALL xios_set_attr(dom, nvertex=nvertex, lonvalue_1d=lon_mpi, latvalue_1d=lat_mpi, &
     379                           bounds_lon_1d=TRANSPOSE(boundslon_mpi), bounds_lat_1d=TRANSPOSE(boundslat_mpi) )
     380        CALL xios_set_attr(dom, i_index=ind_cell_glo_mpi(:)-1)
     381!$OMP END MASTER
     382
     383    END SUBROUTINE wxios_domain_param_unstructured
     384
     385
     386
     387
    310388    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    311389    ! Pour déclarer un axe vertical !!!!!!!!!!!!!!!
Note: See TracChangeset for help on using the changeset viewer.