Ignore:
Timestamp:
Dec 20, 2013, 4:04:56 PM (11 years ago)
Author:
emillour
Message:

Mars GCM:
Series of changes to enable running in parallel (using LMDZ.COMMON dynamics);
Current LMDZ.MARS can still notheless be compiled and run in serial mode
"as previously".
Summary of main changes:

  • Main programs (newstart, start2archive, xvik) that used to be in dyn3d have been moved to phymars.
  • dyn3d/control.h is now module control_mod.F90
  • rearanged input/outputs routines everywhere to handle serial/MPI cases. physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write routines for startfi files are gathered in module iostart.F90
  • added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90, dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90, mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90, mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90, mod_phys_lmdz_transfert_para.F90 in phymars and mod_const_mpi.F90 in dyn3d (for compliance with parallel case)
  • created generic routines 'planetwide_maxval' and 'planetwide_minval', in module "planetwide_mod", that enable obtaining the min and max of a field over the whole planet.

EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90

    r1047 r1130  
    1313
    1414use comsoil_h, only: nsoilmx
     15use control_mod, only: ecritphy, day_step, iphysiq
     16use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
     17use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo
    1518
    1619implicit none
     
    1922!#include"dimphys.h"
    2023#include"paramet.h"
    21 #include"control.h"
     24!#include"control.h"
    2225!#include"comsoil.h"
    2326#include"netcdf.inc"
     
    5659integer,dimension(4) :: edges,corners
    5760
     61#ifdef CPP_PARA
     62! Added to work in parallel mode
     63real dx3_glop(klon_glo,nsoilmx)
     64real dx3_glo(iim,jjp1,nsoilmx) ! to store a global 3D data set
     65real dx2_glop(klon_glo)
     66real dx2_glo(iim,jjp1)     ! to store a global 2D (surface) data set
     67real px2(ngrid)
     68#endif
     69
    5870! 1. Initialization step
    5971if (firstname.eq."1234567890") then
     
    7587 
    7688  ! Create output NetCDF file
    77   ierr=NF_CREATE(filename,IOR(NF_CLOBBER,NF_64BIT_OFFSET),nid)
    78   if (ierr.ne.NF_NOERR) then
     89  if (is_master) then
     90   ierr=NF_CREATE(filename,NF_CLOBBER,nid)
     91   if (ierr.ne.NF_NOERR) then
    7992    write(*,*)'writediagsoil: Error, failed creating file '//trim(filename)
    8093    stop
    81   endif
    82  
     94   endif
     95  endif ! of if (is_master)
     96
    8397  ! Define dimensions and axis attributes
    8498  call iniwritesoil(nid,ngrid)
     
    89103else
    90104  ! If not an initialization call, simply open the NetCDF file
    91   ierr=NF_OPEN(filename,NF_WRITE,nid)
     105  if (is_master) then
     106   ierr=NF_OPEN(filename,NF_WRITE,nid)
     107  endif
    92108endif ! of if (firstname.eq."1234567890")
    93109
     
    105121  if (name.eq.firstname) then
    106122    ntime=ntime+1
    107     date=real(zitau+1)/real(day_step)
     123    date=float(zitau+1)/float(day_step)
    108124    ! Note: day_step is known from control.h
    109125   
    110     ! Get NetCDF ID for "time"
    111     ierr=NF_INQ_VARID(nid,"time",varid)
    112     ! Add the current value of date to the "time" array
     126    if (is_master) then
     127     ! Get NetCDF ID for "time"
     128     ierr=NF_INQ_VARID(nid,"time",varid)
     129     ! Add the current value of date to the "time" array
    113130!#ifdef NC_DOUBLE
    114 !    ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
     131!     ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
    115132!#else
    116     ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
     133     ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
    117134!#endif
    118     if (ierr.ne.NF_NOERR) then
     135     if (ierr.ne.NF_NOERR) then
    119136      write(*,*)"writediagsoil: Failed writing date to time variable"
    120137      stop
    121     endif
     138     endif
     139    endif ! of if (is_master)
    122140  endif ! of if (name.eq.firstname)
    123141
     
    125143if (dimpx.eq.3) then ! Case of a 3D variable
    126144  ! A. Recast data along 'dynamics' grid
     145#ifdef CPP_PARA
     146  ! gather field on a "global" (without redundant longitude) array
     147  call Gather(px,dx3_glop)
     148!$OMP MASTER
     149  if (is_mpi_root) then
     150    call Grid1Dto2D_glo(dx3_glop,dx3_glo)
     151    ! copy dx3_glo() to dx3(:) and add redundant longitude
     152    data3(1:iim,:,:)=dx3_glo(1:iim,:,:)
     153    data3(iip1,:,:)=data3(1,:,:)
     154  endif
     155!$OMP END MASTER
     156!$OMP BARRIER
     157#else
    127158  do l=1,nsoilmx
    128159    ! handle the poles
     
    140171    enddo
    141172  enddo
     173#endif
    142174 
    143175  ! B. Write (append) the variable to the NetCDF file
     176  if (is_master) then
    144177  ! B.1. Get the ID of the variable
    145178  ierr=NF_INQ_VARID(nid,name,varid)
     
    179212               " to file "//trim(filename)//" at time",date
    180213  endif
     214  endif ! of if (is_master)
    181215
    182216elseif (dimpx.eq.2) then ! Case of a 2D variable
     217
    183218  ! A. Recast data along 'dynamics' grid
     219#ifdef CPP_PARA
     220  ! gather field on a "global" (without redundant longitude) array
     221  px2(:)=px(:,1)
     222  call Gather(px2,dx2_glop)
     223!$OMP MASTER
     224  if (is_mpi_root) then
     225    call Grid1Dto2D_glo(dx2_glop,dx2_glo)
     226    ! copy dx3_glo() to dx3(:) and add redundant longitude
     227    data2(1:iim,:)=dx2_glo(1:iim,:)
     228    data2(iip1,:)=data2(1,:)
     229  endif
     230!$OMP END MASTER
     231!$OMP BARRIER
     232#else
    184233  ! handle the poles
    185234  do i=1,iip1
     
    195244    data2(iip1,j)=data2(1,j) ! extra (modulo) longitude
    196245  enddo
     246#endif
    197247
    198248  ! B. Write (append) the variable to the NetCDF file
     249  if (is_master) then
    199250  ! B.1. Get the ID of the variable
    200251  ierr=NF_INQ_VARID(nid,name,varid)
     
    231282               " to file "//trim(filename)//" at time",date
    232283  endif
     284  endif ! of if (is_master)
    233285
    234286elseif (dimpx.eq.0) then ! Case of a 0D variable
     287#ifdef CPP_PARA
     288  write(*,*) "writediagsoil: dimps==0 case not implemented in // mode!!"
     289  stop
     290#endif
    235291  ! A. Copy data value
    236292  data0=px(1,1)
     
    270326
    271327! 4. Close the NetCDF file
    272 ierr=NF_CLOSE(nid)
     328if (is_master) then
     329  ierr=NF_CLOSE(nid)
     330endif
    273331
    274332end subroutine writediagsoil
Note: See TracChangeset for help on using the changeset viewer.