Changeset 3923


Ignore:
Timestamp:
Oct 6, 2025, 11:24:25 AM (3 months ago)
Author:
jmauxion
Message:

Mars PCM:
Adding a slow_diagfi flag to the run.def file for 1D model only. When False, the netcdf
file is opened/closed once, thus saving significant computing time. When true,
the opening frequency is at output frequency (required in debug mode).
JM

Location:
trunk/LMDZ.MARS
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/changelog.txt

    r3919 r3923  
    49804980== 26/09/2025 == JBC
    49814981Formating "improveclouds" into F90 and simplifying some instructions.
     4982
     4983== 06/09/2025 == JM
     4984Adding a slow_diagfi flag to the run.def file for 1D model only. When False, the netcdf
     4985file is opened/closed once, thus saving significant computing time. When true,
     4986the opening frequency is at output frequency (required in debug mode).
  • trunk/LMDZ.MARS/libf/phymars/conf_phys.F

    r3913 r3923  
    2424     &                     frost_metam_threshold,old_wsublimation_scheme
    2525      use time_phylmdz_mod, only: steps_per_sol,outputs_per_sol,iphysiq,
    26      &                            ecritstart,daysec,dtphys
     26     &                            ecritstart,daysec,dtphys,slow_diagfi
    2727      use dimradmars_mod, only: naerkind, name_iaer,
    2828     &                      ini_scatterers,tauvis
     
    105105     &     "Error: inadequate value for outputs_per_sol",1)
    106106      endif
     107
     108      slow_diagfi =.false. ! default value, open/close diagfi once (1D only)
     109      call getin_p("slow_diagfi",slow_diagfi) ! if true, open/close the diagfi.nc
     110                                              ! at output frequency instead of once
     111                                              ! (slower but required for debug)
     112      write(*,*) "Develop: slow_diagfi is ", slow_diagfi
    107113     
    108114      iphysiq=20 ! default value
  • trunk/LMDZ.MARS/libf/phymars/time_phylmdz_mod.F90

    r3369 r3923  
    2222                                    ! per sol (set via conf_phys)
    2323!$OMP THREADPRIVATE(outputs_per_sol)
     24
     25    LOGICAL,SAVE :: slow_diagfi ! to handle wether the netcdf file is
     26                                ! opened/close once or at output frequency
     27!$OMP THREADPRIVATE(slow_diagfi)
    2428
    2529    INTEGER,SAVE :: iphysiq   ! call physics every iphysiq dynamical step
  • trunk/LMDZ.MARS/libf/phymars/writediagfi.F

    r3870 r3923  
    4141      use surfdat_h, only: phisfi
    4242      use geometry_mod, only: cell_area
    43       use time_phylmdz_mod, only: steps_per_sol, outputs_per_sol
    44       use time_phylmdz_mod, only: day_ini
     43      use time_phylmdz_mod, only: steps_per_sol, outputs_per_sol,
     44     &                            day_end, day_ini, slow_diagfi
    4545      USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root,
    4646     &                               is_master, gather
     
    7979
    8080      integer,save :: zitau=0
     81      integer,save :: lastzitau=0
    8182      character(len=27),save :: firstnom='1234567890'
     83      character(len=27),save :: prevnom='1234567890'
     84      character(len=27),save :: lastnom='1234567890'
    8285!$OMP THREADPRIVATE(zitau,firstnom)
    8386
     
    8689!$OMP THREADPRIVATE(ntime)
    8790      integer :: idim,varid
    88       integer :: nid
     91      integer, save :: nid
    8992      character(len=*),parameter :: fichnom="diagfi.nc"
    9093      integer, dimension(4) :: id
     
    130133         ! Compute the output rate
    131134         isample=steps_per_sol/outputs_per_sol
    132 
     135         lastzitau=(day_end-day_ini)*steps_per_sol-1
    133136!$OMP MASTER
    134137  !      Open diagfi.def definition file if there is one:
     
    254257      endif ! if (firstnom.eq.'1234567890')
    255258
    256 ! Increment time index 'zitau' if it is the "fist call" (at given time level)
     259      ! Find lastnom
     260      if (lastnom.eq.'1234567890') then
     261         if (nom.eq.firstnom) then
     262            if (prevnom.ne.'1234567890') then
     263               lastnom=prevnom
     264            endif
     265         endif
     266         prevnom=nom
     267      endif
     268
     269! Increment time index 'zitau' if it is the "first call" (at given time level)
    257270! to writediagfi
    258271!------------------------------------------------------------------------
     
    264277! Write the variables to output file if it's time to do so
    265278!--------------------------------------------------------
    266 
    267279      if ( MOD(zitau+1,isample) .eq.0.) then
    268280     
     
    273285        if (is_master) then
    274286          ! only the master is required to do this
    275 
    276           ! Time to write data, open NETCDF file
    277           ierr=NF_OPEN(fichnom,NF_WRITE,nid)
    278 
    279           if (nom.eq.firstnom) then
     287         
     288          ! 1D and slow_diagfi=.false. => open/close once
     289          if ((klon_glo.eq.1).and.(.not.slow_diagfi)) then
     290            ! if the very first time to write, open
     291            if ((nom.eq.firstnom).and.((zitau+1)/isample.eq.1)) then
     292              write(*,*) "Open NETCDF file for firstnom=", firstnom, " and zitau=", zitau
     293              ierr=NF_OPEN(fichnom,NF_WRITE,nid) ! open once in all simu
     294            endif
     295          else ! 3D or slow_diagfi=.true. => open/close at output frequency
     296            ierr=NF_OPEN(fichnom,NF_WRITE,nid)           
     297          endif
     298         
     299          if(nom.eq.firstnom) then
    280300            ! We have identified a "first call" (at given date)
    281301            ntime=ntime+1 ! increment # of stored time steps
     
    613633        endif ! of if (dim.eq.3) elseif(dim.eq.2)...
    614634
     635        ! Only the master do it
    615636        if (is_master) then
    616           ! Close until next variable to dump or next dump iteration
    617           ierr= NF_CLOSE(nid)
     637          ! 1D and slow_diagfi=.false. => open/close once
     638          if ((klon_glo.eq.1).and.(.not.slow_diagfi)) then
     639            ! if the very last time to write, close
     640            if ((nom.eq.lastnom).and.(zitau.eq.lastzitau)) then
     641              write(*,*) "Close NETCDF file for lastnom=",lastnom, "and zitau=", zitau
     642              ierr = NF_CLOSE(nid) ! close once in all simu
     643            endif
     644          else ! 3D or slow_diagfi=.true. => open/close at output frequency
     645            ierr = NF_CLOSE(nid)
     646          endif
    618647        endif
    619648
Note: See TracChangeset for help on using the changeset viewer.