Changeset 3993


Ignore:
Timestamp:
Jan 5, 2026, 8:31:25 AM (7 days ago)
Author:
emillour
Message:

Venus PCM:
Improving rcm1d: make reading/loading of tracer mixing ratios from
file init_1D.txt more flexible: identify tracers by their names so
that the ordering in init_1D.txt does not matter any more and that
missing tracers are simply set to 0.
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.VENUS/libf/phyvenus/dyn1d/rcm1d.F

    r3877 r3993  
    11      PROGRAM rcm1d
    22     
    3       USE infotrac
     3      USE infotrac, only: infotrac_init, nqtot, tname
    44      use control_mod, only: planet_type,day_step,cpofT
    55      USE phys_state_var_mod
     
    164164c    Date (en sols depuis le solstice de printemps) du debut du run
    165165      day0 = 0
    166       PRINT *,'date de depart ?'
     166      PRINT *,'start date ?'
    167167      READ(unit,*) day0
    168168      day=REAL(day0)
    169169      PRINT *,day0
    170170c  Heure de demarrage
    171       PRINT *,'heure de debut de simulation (entre 0 et 24) ?'
     171      PRINT *,'starting hour of the simulation (between 0 et 24) ?'
    172172      READ(unit,*) time
    173173      time=time/24.E+0
     
    179179      nlevel=nlayer+1
    180180      nsoil=nsoilmx
    181       PRINT *,'nombre de pas de temps par jour ?'
     181      PRINT *,'nunmber of time steps per day ?'
    182182      READ(unit,*) day_step
    183183      print*,day_step
     
    189189      nbapp_rad = 24000
    190190
    191       PRINT *,'nombre de jours simules ?'
     191      PRINT *,'number of days to run ?'
    192192      READ(unit,*) nb_days
    193193      print*,nb_days
     
    201201c ------------------------------------
    202202c
    203       PRINT *,'pression au sol'
     203      PRINT *,'surface pressure'
    204204      READ(unit,*) psurf
    205205      PRINT *,psurf
     
    212212c  latitude/longitude
    213213c  -------------------
    214       PRINT *,'latitude en degres ?'
     214      PRINT *,'latitude in degrees ?'
    215215      READ(unit,*) lati(1)
    216216      PRINT *,lati(1)
     
    253253 
    254254c    vent geostrophique
    255       PRINT *,'composante vers l est du vent geostrophique (U) ?'
     255      PRINT *,'eastward component of the geostrophic wind (U) ?'
    256256      READ(unit,*) gru
    257       PRINT *,'composante vers le nord du vent geostrophique (V) ?'
     257      PRINT *,'northward component of the geostrophic wind (V) ?'
    258258      READ(unit,*) grv
    259259
     
    313313      CLOSE(unit)
    314314
    315       print*,"               Pression        Altitude     Temperature"
     315      print*,"               Pressure        Altitude     Temperature"
    316316      ilayer=1
    317317      ftsol(1)=tmp2(0)
     
    349349      inquire(file="init_1D.txt",exist=file_is_present)
    350350      if (file_is_present) then
    351         open(21, form = 'formatted', file = 'init_1D.txt')
    352         read(21,*)
    353         do ilayer = nlayer,1,-1
    354           read(21,*) idummy, dummy, dummy, (q(ilayer,iq), iq = 1,nqtot)
    355 !        print*, idummy, q(ilayer,1), q(ilayer,nqtot)
    356         end do
    357         close(21)
     351        call read_init_1D(nlayer,nqtot,tname,q)
    358352      else
    359353        write(*,*) "Cannot find input file init_1D.txt!"
     
    541535      ENDDO
    542536
     537      CONTAINS
     538
     539        SUBROUTINE read_init_1D(nlayer,nqtot,tname,q)
     540          IMPLICIT NONE
     541         
     542          integer,intent(in) :: nlayer
     543          integer,intent(in) :: nqtot
     544          character(len=*),intent(in) :: tname(nqtot)
     545          real,intent(out) :: q(nlayer,nqtot)
     546       
     547          character(len=512) :: line ! to store a line of text
     548          character(len=22) :: words(nqtot+2) ! to store items in line of text
     549          integer :: words_b(nqtot+2),words_e(nqtot+2)
     550          logical :: new_word
     551          integer :: iq(nqtot) ! tracer index
     552          real :: lineq(nqtot+2) ! values in a line of file
     553          integer :: idummy
     554          integer :: i,j,ind
     555         
     556          !1. Open file and process first line
     557          open(21,form='formatted',file='init_1D.txt')
     558          read(21,'(a)') line
     559
     560          ! identify words in line
     561          ind=0
     562          do i=1,len_trim(line)
     563            if (line(i:i) == ' ') then
     564              new_word=.true.
     565            else
     566              if (new_word) then
     567                ind=ind+1
     568                words_b(ind)=i
     569                new_word=.false.
     570              endif
     571              words_e(ind)=i
     572            endif
     573          enddo ! of do i=1,len_trim(line)
     574          ! write(*,*) "found ",ind," words"
     575          do j=1,ind
     576            write(words(j),"(a)") line(words_b(j):words_e(j))
     577          enddo
     578         
     579          ! identify tracer index (if present in file)
     580          iq(:)=0
     581          do i=1,nqtot
     582            do j=1,ind
     583              ! look for match
     584              if (trim(tname(i))==words(j)) then
     585                iq(i)=j
     586                exit ! move on to next tracer
     587              endif
     588            enddo
     589            ! write(*,*) "i=",i,"iq(i)=",iq(i)
     590          enddo
     591         
     592          ! 2. Read following lines and assign tracer mixing ratios
     593          do ilayer=nlayer,1,-1
     594            read(21,*) idummy,(lineq(j),j=1,ind)
     595            ! reorder/store values
     596            do i=1,nqtot
     597              if (iq(i)/=0) then
     598                q(ilayer,i)=lineq(iq(i))
     599              else
     600                ! set tracer value to zero since it is not in the file
     601                q(ilayer,i)=0
     602              endif
     603            enddo
     604          enddo ! of do lay=nlayer,1,-1
     605         
     606          ! 3. close file
     607          close(21)
     608         
     609        END SUBROUTINE read_init_1D
     610
    543611c    ========================================================
    544       END
    545  
    546 c***********************************************************************
    547 c***********************************************************************
    548 
    549 !#include "../dyn3d_common/disvert_noterre.F"
    550 !#include "../dyn3d/abort_gcm.F"
    551 
     612      END PROGRAM rcm1d
Note: See TracChangeset for help on using the changeset viewer.