Ignore:
Timestamp:
Nov 25, 2020, 7:24:05 PM (4 years ago)
Author:
yjaziri
Message:

Generic GCM:
Implementation of an option for a new reading process of "traceur.def"
Use "#ModernTrac-v1" flag as first line of "traceur.def" to use this option
Further details in "LMDZ.GENERIC/deftank/traceur.def.modern"
YJ + JVO

Location:
trunk/LMDZ.GENERIC/libf/phystd
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90

    r1714 r2436  
    9090  real :: latitude(1), longitude(1), cell_area(1), phisfi(1)
    9191 
     92  !     added by JVO and YJ to read modern traceur.def
     93  character(len=500) :: line ! to store a line of text
     94  LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def
     95
    9296  ! --------------
    9397  ! Initialisation
     
    162166        write(*,*) "kcm1d: Reading file traceur.def"
    163167        ! read number of tracers:
    164         read(90,*,iostat=ierr) nq
     168        !! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
     169        READ(90,'(A)') line
     170        IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
     171           READ(line,*,iostat=ierr) nq ! Try standard traceur.def
     172        ELSE
     173           moderntracdef = .true.
     174           DO
     175             READ(90,'(A)',iostat=ierr) line
     176             IF (ierr.eq.0) THEN
     177               IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
     178                 READ(line,*,iostat=ierr) nq
     179                 EXIT
     180               ENDIF
     181             ELSE ! If pb, or if reached EOF without having found nbtr
     182                write(*,*) "rcm1d: error reading number of tracers"
     183                write(*,*) "   (first line of traceur.def) "
     184                stop
     185             ENDIF
     186           ENDDO
     187        ENDIF ! if modern or standard traceur.def
    165188        if (ierr.ne.0) then
    166189           write(*,*) "kcm1d: error reading number of tracers"
     
    184207           endif
    185208        enddo !of do iq=1,nq
     209        close(90)
    186210     endif
    187211
  • trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F

    r2354 r2436  
    144144      real :: latitude(1), longitude(1), cell_area(1)
    145145
     146      !     added by JVO and YJ to read modern traceur.def
     147      character(len=500) :: line ! to store a line of text
     148      LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def
     149
    146150c=======================================================================
    147151c INITIALISATION
     
    152156     &       iostat=ierr)
    153157      if (ierr.eq.0) then
    154         read(90,*,iostat=ierr) nq
     158        ! read number of tracers:
     159        !! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
     160            READ(90,'(A)') line
     161            IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
     162               READ(line,*,iostat=ierr) nq ! Try standard traceur.def
     163            ELSE
     164               moderntracdef = .true.
     165               DO
     166                 READ(90,'(A)',iostat=ierr) line
     167                 IF (ierr.eq.0) THEN
     168                   IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
     169                     READ(line,*,iostat=ierr) nq
     170                     EXIT
     171                   ENDIF
     172                 ELSE ! If pb, or if reached EOF without having found nbtr
     173                    write(*,*) "rcm1d: error reading number of tracers"
     174                    write(*,*) "   (first line of traceur.def) "
     175                    stop
     176                 ENDIF
     177               ENDDO
     178            ENDIF ! if modern or standard traceur.def
    155179      else
    156180        nq=0
     
    243267          write(*,*) "rcm1d: Reading file traceur.def"
    244268          ! read number of tracers:
    245           read(90,*,iostat=ierr) nq
     269          !! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
     270          READ(90,'(A)') line
     271          IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
     272             READ(line,*,iostat=ierr) nq ! Try standard traceur.def
     273          ELSE
     274             moderntracdef = .true.
     275             DO
     276               READ(90,'(A)',iostat=ierr) line
     277               IF (ierr.eq.0) THEN
     278                 IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
     279                   READ(line,*,iostat=ierr) nq
     280                   EXIT
     281                 ENDIF
     282               ELSE ! If pb, or if reached EOF without having found nbtr
     283                  write(*,*) "rcm1d: error reading number of tracers"
     284                  write(*,*) "   (first line of traceur.def) "
     285                  stop
     286               ENDIF
     287             ENDDO
     288          ENDIF ! if modern or standard traceur.def
    246289          nqtot=nq ! set value of nqtot (in infotrac module) as nq
    247290          if (ierr.ne.0) then
  • trunk/LMDZ.GENERIC/libf/phystd/initracer.F

    r2278 r2436  
    2020c   ------
    2121c            Ehouarn Millour (oct. 2008) identify tracers by their names
     22c            Y Jaziri & J. Vatant d'Ollone (2020) : Modern traceur.def
    2223c=======================================================================
    2324
     
    2526      character(len=30),intent(in) :: nametrac(nq) ! name of the tracer from dynamics
    2627
    27       character(len=30) :: txt ! to store some text
    28       integer iq,ig,count
    29       real r0_lift , reff_lift
     28      character(len=500) :: tracline   ! to read traceur.def lines
     29      character(len=30)  :: txt        ! to store some text
     30      integer iq,ig,count,ierr
    3031
    3132
     
    4344c-----------------------------------------------------------------------
    4445
     46      moderntracdef=.false. ! For modern traceur.def (default false, old type)
     47
     48      open(407, form = 'formatted', status = 'old',
     49     $          file = 'traceur.def', iostat=ierr)
     50      if (ierr /=0) then
     51        call abort_physic('initracer',
     52     $  'Problem in opening traceur.def',1)
     53      end if
     54!! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
     55       READ(407,'(A)') tracline
     56       IF (trim(tracline).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
     57          READ(tracline,*) nqtot ! Try standard traceur.def
     58       ELSE
     59         moderntracdef = .true.
     60         DO
     61           READ(407,'(A)',iostat=ierr) tracline
     62           IF (ierr==0) THEN
     63             IF (index(tracline,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
     64               READ(tracline,*) nqtot
     65               ! Temporary not implemented solution
     66               if (nqtot/=nq) then
     67                 call abort_physic('initracer','Different number of&
     68     & tracers in dynamics and physics not managed yet',1)
     69               endif
     70               EXIT
     71             ENDIF
     72           ELSE ! If pb, or if reached EOF without having found nqtot
     73             call abort_physic('initracer','Unable to read numbers&
     74     & of tracers in traceur.def',1)
     75           ENDIF
     76         ENDDO
     77       ENDIF ! if modern or standard traceur.def
     78!! -----------------------------------------------------------------------
     79       !! For the moment number of tracers in dynamics and physics are equal
    4580       nqtot=nq
    4681       !! we allocate once for all arrays in common in tracer_h.F90
     
    339374      endif
    340375
     376      ! Get data of tracers
     377      do iq=1,nqtot
     378        read(407,'(A)') tracline
     379        call get_tracdat(iq, tracline)
     380      enddo
     381
     382      close(407)
    341383
    342384c------------------------------------------------------------
     
    410452      write(*,*)
    411453
     454      contains
     455
     456      subroutine get_tracdat(iq,tracline)
     457        !-------------------ADDING NEW OPTIONS-------------------
     458        ! Duplicate if sentence for adding new options
     459        ! Do not forget to add the new variables in tracer_h.F90
     460        ! Do not forget to allocate and initialize the new variables above
     461        ! Please update list of options in "LMDZ.GENERIC/deftank/traceur.def.modern"
     462        !-------------------------------------------------------
     463          use tracer_h
     464          implicit none
     465          integer,           intent(in) :: iq       ! tracer index
     466          character(len=500),intent(in) :: tracline ! traceur.def lines with parameters
     467 
     468          read(tracline,*) noms(iq)
     469          ! JVO 20 : We should add a sanity check aborting when duplicates in names !
     470          write(*,*)"initracer: iq=",iq,"noms(iq)=",trim(noms(iq))
     471          if (index(tracline,'mmol='   ) /= 0) then
     472              read(tracline(index(tracline,'mmol=')+len('mmol='):),*)
     473     $             mmol(iq)
     474              write(*,*) ' Parameter value (traceur.def) : mmol=',
     475     $             mmol(iq)
     476          else
     477              write(*,*) ' Parameter value (default)     : mmol=',
     478     $             mmol(iq)
     479          end if
     480      end subroutine get_tracdat
     481
    412482      end
     483
  • trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90

    r1980 r2436  
    66       integer, save :: nqtot ! total number of tracers
    77!$OMP THREADPRIVATE(nqtot)
     8
     9       logical :: moderntracdef=.false. ! Standard or modern traceur.def
     10!$OMP THREADPRIVATE(moderntracdef)
    811
    912       character*30, save, allocatable :: noms(:)   ! name of the tracer
Note: See TracChangeset for help on using the changeset viewer.