Ignore:
Timestamp:
Jan 22, 2019, 4:21:59 PM (6 years ago)
Author:
Laurent Fairhead
Message:

"Historic" :-) commit merging the physics branch used for DYNAMICO with the LMDZ trunk.
The same physics branch can now be used seamlessly with the traditional lon-lat LMDZ
dynamical core and DYNAMICO.
Testing consisted in running a lon-lat LMDZ bucket simulation with the NPv6.1 physics package
with the original trunk sources and the merged sources. Tests were succesful in the sense that
numeric continuity was preserved in the restart files from both simulation. Further tests
included running both versions of the physics codes for one year in a LMDZOR setting in which
the restart files also came out identical.

Caution:

  • as the physics package now manages unstructured grids, grid information needs to be transmitted

to the surface scheme ORCHIDEE. This means that the interface defined in surf_land_orchidee_mod.F90
is only compatible with ORCHIDEE version orchidee2.1 and later versions. If previous versions of
ORCHIDEE need to be used, the CPP key ORCHIDEE_NOUNSTRUCT needs to be set at compilation time.
This is done automatically if makelmdz/makelmdz_fcm are called with the veget orchidee2.0 switch

  • due to a limitation in XIOS, the time at which limit conditions will be read in by DYNAMICO will be

delayed by one physic timestep with respect to the time it is read in by the lon-lat model. This is caused
by the line

IF (MOD(itime-1, lmt_pas) == 0 .OR. (jour_lu /= jour .AND. grid_type /= unstructured)) THEN ! time to read

in limit_read_mod.F90

Work still needed on COSP integration and XML files for DYNAMICO

EM, YM, LF

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/iophy.F90

    r3266 r3435  
    1818#ifdef CPP_XIOS
    1919  INTERFACE histwrite_phy
    20 !#ifdef CPP_XIOSnew
    2120    MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy,histwrite2d_phy_old,histwrite3d_phy_old,histwrite2d_xios,histwrite3d_xios,histwrite0d_xios
    22 !#else
    23 !    MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy,histwrite2d_phy_old,histwrite3d_phy_old,histwrite2d_xios,histwrite3d_xios
    24 !#endif
    25 
    2621  END INTERFACE
    2722#else
     
    5247                                  mpi_size, mpi_rank, klon_mpi, &
    5348                                is_sequential, is_south_pole_dyn
    54     USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo
    55     USE print_control_mod, ONLY: prt_level,lunout
     49  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo, grid_type, unstructured
     50  USE print_control_mod, ONLY: prt_level,lunout
    5651#ifdef CPP_IOIPSL
    5752    USE ioipsl, ONLY: flio_dom_set
    5853#endif
    5954#ifdef CPP_XIOS
    60     USE wxios, ONLY: wxios_domain_param
     55  use wxios, ONLY: wxios_domain_param, wxios_domain_param_unstructured, wxios_context_init
    6156#endif
    6257    IMPLICIT NONE
     
    7772    INTEGER :: data_ibegin, data_iend
    7873
    79     CALL gather(rlat,rlat_glo)
    80     CALL bcast(rlat_glo)
    81     CALL gather(rlon,rlon_glo)
    82     CALL bcast(rlon_glo)
     74#ifdef CPP_XIOS
     75      CALL wxios_context_init
     76#endif
     77   
     78
     79    IF (grid_type==unstructured) THEN
     80   
     81#ifdef CPP_XIOS
     82      CALL wxios_domain_param_unstructured("dom_glo")
     83#endif
     84
     85    ELSE
     86
     87      CALL gather(rlat,rlat_glo)
     88      CALL bcast(rlat_glo)
     89      CALL gather(rlon,rlon_glo)
     90      CALL bcast(rlon_glo)
    8391   
    8492!$OMP MASTER 
     
    133141#endif
    134142#ifdef CPP_XIOS
    135     ! Set values for the mask:
    136     IF (mpi_rank == 0) THEN
    137         data_ibegin = 0
    138     ELSE
    139         data_ibegin = ii_begin - 1
    140     ENDIF
    141 
    142     IF (mpi_rank == mpi_size-1) THEN
    143         data_iend = nbp_lon
    144     ELSE
    145         data_iend = ii_end + 1
    146     ENDIF
    147 
    148     IF (prt_level>=10) THEN
    149       write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," iibegin=",ii_begin , " ii_end=",ii_end," jjbegin=",jj_begin," jj_nb=",jj_nb," jj_end=",jj_end
    150       write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," nbp_lon=",nbp_lon," nbp_lat=",nbp_lat
    151       write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
    152       write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
    153       write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," is_south_pole=",is_south_pole_dyn
    154     ENDIF
    155 
    156     ! Initialize the XIOS domain coreesponding to this process:
    157     CALL wxios_domain_param("dom_glo", is_sequential, nbp_lon, jj_nb, nbp_lon, nbp_lat, &
    158                             1, nbp_lon, ii_begin, ii_end, jj_begin, jj_end,             &
    159                             klon_mpi+2*(nbp_lon-1), data_ibegin, data_iend,             &
    160                             io_lat, io_lon,is_south_pole_dyn,mpi_rank)
     143      ! Set values for the mask:
     144      IF (mpi_rank == 0) THEN
     145          data_ibegin = 0
     146      ELSE
     147          data_ibegin = ii_begin - 1
     148      END IF
     149
     150      IF (mpi_rank == mpi_size-1) THEN
     151          data_iend = nbp_lon
     152      ELSE
     153          data_iend = ii_end + 1
     154      END IF
     155
     156      IF (prt_level>=10) THEN
     157        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," iibegin=",ii_begin , " ii_end=",ii_end," jjbegin=",jj_begin," jj_nb=",jj_nb," jj_end=",jj_end
     158        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," nbp_lon=",nbp_lon," nbp_lat=",nbp_lat
     159        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
     160        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
     161        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," is_south_pole_dyn=",is_south_pole_dyn
     162      ENDIF
     163
     164      ! Initialize the XIOS domain coreesponding to this process:
    161165#endif
    162166!$OMP END MASTER
     167
     168#ifdef CPP_XIOS   
     169        CALL wxios_domain_param("dom_glo")
     170#endif
     171     
     172    ENDIF
    163173     
    164174  END SUBROUTINE init_iophy_new
     
    291301                                is_sequential, klon_mpi_begin, klon_mpi_end, &
    292302                                mpi_rank
    293   USE mod_grid_phy_lmdz, ONLY: klon_glo, nbp_lon, nbp_lat
     303  USE mod_grid_phy_lmdz, ONLY: klon_glo, nbp_lon, nbp_lat, grid1dTo2d_glo
    294304  USE ioipsl, ONLY: histbeg
    295305
     
    366376     ENDDO
    367377
    368        CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,rlon_glo,zx_lon)
     378       CALL grid1dTo2d_glo(rlon_glo,zx_lon)
    369379       IF ((nbp_lon*nbp_lat).GT.1) THEN
    370380       DO i = 1, nbp_lon
     
    373383       ENDDO
    374384       ENDIF
    375        CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,rlat_glo,zx_lat)
     385       CALL grid1dTo2d_glo(rlat_glo,zx_lat)
    376386
    377387    DO i=1,pim
     
    963973                                 nid_files, swaerofree_diag, swaero_diag, dryaod_diag, ok_4xCO2atm
    964974  USE print_control_mod, ONLY: prt_level,lunout
    965   USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     975  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat
    966976#ifdef CPP_XIOS
    967977  USE xios, ONLY: xios_send_field
    968978#endif
     979  USE print_control_mod, ONLY: lunout, prt_level
    969980
    970981  IMPLICIT NONE
     
    10071018      IF (.not. ok_all_xml) THEN
    10081019      IF (prt_level >= 10) THEN
    1009       WRITE (lunout,*)"histwrite2d_phy: .not.vars_defined ; time to define ", trim(var%name)
     1020      write(lunout,*)"histwrite2d_phy: .not.vars_defined ; time to define ", &
     1021                     trim(var%name)
    10101022      ENDIF
    10111023      DO iff=iff_beg, iff_end
     
    10371049    ENDIF
    10381050!$OMP MASTER
    1039     CALL grid1Dto2D_mpi(buffer_omp,Field2d)
     1051    IF (grid_type==regular_lonlat) CALL grid1Dto2D_mpi(buffer_omp,Field2d)
    10401052
    10411053! La boucle sur les fichiers:
     
    10471059             write(lunout,*)'Dans iophy histwrite2D,var%name ', trim(var%name)                       
    10481060          ENDIF
    1049           IF (SIZE(field) == klon) then
     1061         
     1062          IF (grid_type==regular_lonlat) THEN
     1063            IF (SIZE(field) == klon) then
    10501064              CALL xios_send_field(var%name, Field2d)
    1051           ELSE
    1052              CALL xios_send_field(var%name, field)
    1053           ENDIF
     1065            ELSE
     1066               CALL xios_send_field(var%name, field)
     1067            ENDIF
     1068          ELSE IF (grid_type==unstructured) THEN
     1069            CALL xios_send_field(var%name, buffer_omp)
     1070          ENDIF
    10541071          IF (prt_level >= 10) THEN
    1055              WRITE (lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ', trim(var%name)                       
     1072             write(lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ',&
     1073                             trim(var%name)                       
    10561074          ENDIF
    10571075#else
     
    10651083               IF (firstx) THEN
    10661084                  IF (prt_level >= 10) THEN
    1067                      WRITE (lunout,*)'Dans iophy histwrite2D,iff,var%name ', iff,trim(var%name)                       
    1068                      WRITE (lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
     1085                     write(lunout,*)'Dans iophy histwrite2D,iff,var%name ',&
     1086                                    iff,trim(var%name)                       
     1087                     write(lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
    10691088                  ENDIF
    1070                   IF (SIZE(field) == klon) then
    1071                      CALL xios_send_field(var%name, Field2d)
    1072                   ELSE
    1073                      CALL xios_send_field(var%name, field)
     1089                  IF (grid_type==regular_lonlat) THEN
     1090                    IF (SIZE(field) == klon) then
     1091                       CALL xios_send_field(var%name, Field2d)
     1092                    ELSE
     1093                       CALL xios_send_field(var%name, field)
     1094                    ENDIF
     1095                  ELSE IF (grid_type==unstructured) THEN
     1096                    CALL xios_send_field(var%name, buffer_omp)
    10741097                  ENDIF
     1098
    10751099                  firstx=.false.
    10761100               ENDIF
     
    10851109!#ifdef CPP_XIOS
    10861110!                        IF (iff == iff_beg) THEN
    1087 !                          if (prt_level >= 10) then
     1111!                          IF (prt_level >= 10) THEN
    10881112!                            write(lunout,*)"histwrite2d_phy: .NOT.clef_stations(iff) and iff==iff_beg, call xios_send_field"
    1089 !                          endif
     1113!                          ENDIF
    10901114!                          CALL xios_send_field(var%name, Field2d)
    10911115!                        ENDIF
     
    11091133                       ENDIF ! of IF (is_sequential)
    11101134#ifndef CPP_IOIPSL_NO_OUTPUT
    1111                        IF (prt_level >= 10) THEn
     1135                       IF (prt_level >= 10) THEN
    11121136                         write(lunout,*)"histwrite2d_phy: clef_stations(iff) and iff==iff_beg, call wxios_write_2D"
    11131137                       ENDIF
     
    11411165                                 nfiles, vars_defined, clef_stations, &
    11421166                                 nid_files, swaerofree_diag
    1143   USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     1167  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, regular_lonlat, unstructured
    11441168#ifdef CPP_XIOS
    11451169  USE xios, ONLY: xios_send_field
     
    12061230    ENDIF
    12071231!$OMP MASTER
    1208     CALL grid1Dto2D_mpi(buffer_omp,field3d)
     1232    IF (grid_type==regular_lonlat) CALL grid1Dto2D_mpi(buffer_omp,field3d)
    12091233
    12101234! BOUCLE SUR LES FICHIERS
     
    12131237    IF (ok_all_xml) THEN
    12141238#ifdef CPP_XIOS
    1215         IF (prt_level >= 10) THEN
    1216              write(lunout,*)'Dans iophy histwrite3D,var%name ',trim(var%name)                       
     1239          IF (prt_level >= 10) THEN
     1240             write(lunout,*)'Dans iophy histwrite3D,var%name ',&
     1241                             trim(var%name)                       
     1242          ENDIF
     1243          IF (grid_type==regular_lonlat) THEN
     1244            IF (SIZE(field,1) == klon) then
     1245               CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
     1246            ELSE
     1247               CALL xios_send_field(var%name, field)
     1248            ENDIF
     1249          ELSE IF (grid_type==unstructured) THEN
     1250            CALL xios_send_field(var%name, buffer_omp(:,1:nlevx))
    12171251        ENDIF
    1218         IF (SIZE(field,1) == klon) then
    1219              CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
    1220         ELSE
    1221              CALL xios_send_field(var%name, field)
    1222         ENDIF
     1252
    12231253#else
    12241254        CALL abort_physic ('iophy','cannot have ok_all_xml = .T. without CPP_XIOS defined' ,1)
     
    12301260#ifdef CPP_XIOS
    12311261              IF (firstx) THEN
    1232                 IF (prt_level >= 10) THEn
    1233                   WRITE (lunout,*)'Dans iophy, histwrite3D iff nlev klev firstx', &
     1262                IF (prt_level >= 10) THEN
     1263                  write(lunout,*)'Dans iophy, histwrite3D iff nlev klev firstx', &
    12341264                                  iff,nlev,klev, firstx                       
    1235                   WRITE (lunout,*)'histwrite3d_phy: call xios_send_field for ', &
     1265                  write(lunout,*)'histwrite3d_phy: call xios_send_field for ', &
    12361266                                  trim(var%name), ' with iim jjm nlevx = ', &
    12371267                                  nbp_lon,jj_nb,nlevx
    12381268                ENDIF
    1239                 IF (SIZE(field,1) == klon) then
    1240                     CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
    1241                 ELSE
    1242                      CALL xios_send_field(var%name, field)
     1269                IF (grid_type==regular_lonlat) THEN
     1270                  IF (SIZE(field,1) == klon) then
     1271                      CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
     1272                  ELSE
     1273                       CALL xios_send_field(var%name, field)
     1274                  ENDIF
     1275                ELSE IF (grid_type==unstructured) THEN
     1276                  CALL xios_send_field(var%name, buffer_omp(:,1:nlevx))
    12431277                ENDIF
     1278
    12441279                firstx=.false.
    12451280              ENDIF
     
    13051340                                is_sequential, klon_mpi_begin, klon_mpi_end, &
    13061341                                jj_nb, klon_mpi, is_master
    1307   USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     1342  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, unstructured
    13081343  USE xios, ONLY: xios_send_field
    13091344  USE print_control_mod, ONLY: prt_level,lunout
     
    13351370        CALL Gather_omp(field,buffer_omp)   
    13361371!$OMP MASTER
     1372
     1373      IF (grid_type==unstructured) THEN
     1374 
     1375        CALL xios_send_field(field_name, buffer_omp)
     1376
     1377      ELSE
     1378
    13371379        CALL grid1Dto2D_mpi(buffer_omp,Field2d)
    13381380   
     
    13421384    !IF(.NOT.clef_stations(iff)) THEN
    13431385        IF (.TRUE.) THEN
    1344             ALLOCATE(index2d(nbp_lon*jj_nb))
    1345             ALLOCATE(fieldok(nbp_lon*jj_nb))
    1346    
    13471386   
    13481387            CALL xios_send_field(field_name, Field2d)
     
    13651404                ENDDO
    13661405            ENDIF
    1367    
    1368         ENDIF
    1369                  
    1370         DEALLOCATE(index2d)
    1371         DEALLOCATE(fieldok)
     1406            DEALLOCATE(index2d)
     1407            DEALLOCATE(fieldok)
     1408   
     1409        ENDIF                 
     1410      ENDIF
    13721411!$OMP END MASTER   
    13731412  ENDIF
     
    13851424                                jj_nb, klon_mpi, is_master
    13861425  USE xios, ONLY: xios_send_field
    1387   USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     1426  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, unstructured
    13881427  USE print_control_mod, ONLY: prt_level,lunout
    13891428
     
    14161455        CALL Gather_omp(field,buffer_omp)
    14171456!$OMP MASTER
     1457
     1458    IF (grid_type==unstructured) THEN
     1459
     1460      CALL xios_send_field(field_name, buffer_omp(:,1:nlev))
     1461
     1462    ELSE
    14181463        CALL grid1Dto2D_mpi(buffer_omp,field3d)
    14191464
     
    14231468    !IF (.NOT.clef_stations(iff)) THEN
    14241469        IF(.TRUE.)THEN
    1425             ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
    1426             ALLOCATE(fieldok(nbp_lon*jj_nb,nlev))
    1427             CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
     1470
     1471           CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
    14281472                           
    14291473        ELSE
     
    14481492                ENDDO
    14491493            ENDIF
     1494            DEALLOCATE(index3d)
     1495            DEALLOCATE(fieldok)
    14501496        ENDIF
    1451         DEALLOCATE(index3d)
    1452         DEALLOCATE(fieldok)
     1497      ENDIF
    14531498!$OMP END MASTER   
    14541499  ENDIF
Note: See TracChangeset for help on using the changeset viewer.