Changeset 3512 for trunk/LMDZ.COMMON/libf/evolution/info_PEM_mod.F90
- Timestamp:
- Nov 12, 2024, 6:35:33 PM (9 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/info_PEM_mod.F90
r3498 r3512 31 31 logical :: ok 32 32 integer :: cstat 33 character(10) :: ich1, ich2, ich3, ich4, ich5, ich6, fch 33 character(10) :: frmt 34 character(20) :: ich1, ich2, ich3, ich4, fch1, fch2, fch3 34 35 35 36 !----- Code 36 37 inquire(file = 'info_PEM.txt',exist = ok) 37 38 if (ok) then 38 write( ich1,'(f0.4)') i_myear39 write( ich2,'(f0.4)') n_myear40 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(ich 3,'(i0)') iPCM42 write(ich 4,'(i0)') iPEM + 143 write(ich 5,'(i0)') nPCM44 write(ich 6,'(i0)') nPCM_ini45 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) 46 47 if (cstat > 0) then 47 48 error stop 'info_PEM: command execution failed!' … … 60 61 END SUBROUTINE info_PEM 61 62 63 !======================================================================= 64 65 FUNCTION int2str(i) RESULT(str) 66 ! Function to convert an integer into a string 67 68 integer, intent(in) :: i 69 character(20) :: str 70 71 if (nb_digits(real(i)) > len(str)) error stop 'int2str [info_PEM_mod]: invalid integer for conversion!' 72 write(str,'(i0)') i 73 str = trim(adjustl(str)) 74 75 END FUNCTION int2str 76 77 !======================================================================= 78 79 FUNCTION nb_digits(x) RESULT(idigits) 80 ! Function to give the number of digits for the integer part of a real number 81 82 real, intent(in) :: x 83 integer :: idigits 84 85 idigits = 1 86 ! If x /= 0 then: 87 if (abs(x) > 1.e-10) idigits = int(log10(abs(x))) + 1 88 89 END FUNCTION nb_digits 90 62 91 END MODULE info_PEM_mod
Note: See TracChangeset
for help on using the changeset viewer.