Ignore:
Timestamp:
Nov 12, 2024, 6:35:33 PM (9 days ago)
Author:
jbclement
Message:

PEM:
Few corrections related to r3498 (time step from integer to real) and r3493 (Norbert Schorghofer's subroutines for dynamic ice table) in order to make the code work properly.
JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/info_PEM_mod.F90

    r3498 r3512  
    3131logical       :: ok
    3232integer       :: cstat
    33 character(10) :: ich1, ich2, ich3, ich4, ich5, ich6, fch
     33character(10) :: frmt
     34character(20) :: ich1, ich2, ich3, ich4, fch1, fch2, fch3
    3435
    3536!----- Code
    3637inquire(file = 'info_PEM.txt',exist = ok)
    3738if (ok) then
    38     write(ich1,'(f0.4)') i_myear
    39     write(ich2,'(f0.4)') n_myear
    40     write(fch,'(f0.4)') convert_years ! 4 digits to the right of the decimal point to respect the precision of Martian year in "launch_pem.sh"
    41     write(ich3,'(i0)') iPCM
    42     write(ich4,'(i0)') iPEM + 1
    43     write(ich5,'(i0)') nPCM
    44     write(ich6,'(i0)') nPCM_ini
    45     call execute_command_line('sed -i "1s/.*/'//trim(ich1)//' '//trim(ich2)//' '//trim(fch)//' '//trim(ich3)//' '//trim(ich4)//' '//trim(ich5)//' '//trim(ich6)//'/" info_PEM.txt',cmdstat = cstat)
     39    write(fch1,'(f'//int2str(nb_digits(i_myear) + 5)//'.4)') i_myear
     40    write(fch2,'(f'//int2str(nb_digits(n_myear) + 5)//'.4)') n_myear
     41    write(fch3,'(f6.4)') convert_years ! 4 digits to the right of the decimal point to respect the precision of Martian year in "launch_pem.sh"
     42    write(ich1,'(i0)') iPCM
     43    write(ich2,'(i0)') iPEM + 1
     44    write(ich3,'(i0)') nPCM
     45    write(ich4,'(i0)') nPCM_ini
     46    call execute_command_line('sed -i "1s/.*/'//trim(fch1)//' '//trim(fch2)//' '//trim(fch3)//' '//trim(ich1)//' '//trim(ich2)//' '//trim(ich3)//' '//trim(ich4)//'/" info_PEM.txt',cmdstat = cstat)
    4647    if (cstat > 0) then
    4748        error stop 'info_PEM: command execution failed!'
     
    6061END SUBROUTINE info_PEM
    6162
     63!=======================================================================
     64
     65FUNCTION int2str(i) RESULT(str)
     66! Function to convert an integer into a string
     67
     68integer, intent(in) :: i
     69character(20)       :: str
     70
     71if (nb_digits(real(i)) > len(str)) error stop 'int2str [info_PEM_mod]: invalid integer for conversion!'
     72write(str,'(i0)') i
     73str = trim(adjustl(str))
     74
     75END FUNCTION int2str
     76
     77!=======================================================================
     78
     79FUNCTION nb_digits(x) RESULT(idigits)
     80! Function to give the number of digits for the integer part of a real number
     81
     82real, intent(in) :: x
     83integer          :: idigits
     84
     85idigits = 1
     86! If x /= 0 then:
     87if (abs(x) > 1.e-10) idigits = int(log10(abs(x))) + 1
     88
     89END FUNCTION nb_digits
     90
    6291END MODULE info_PEM_mod
Note: See TracChangeset for help on using the changeset viewer.