[3096] | 1 | MODULE info_PEM_mod |
---|
[3076] | 2 | |
---|
| 3 | implicit none |
---|
| 4 | |
---|
| 5 | !======================================================================= |
---|
| 6 | contains |
---|
| 7 | !======================================================================= |
---|
| 8 | |
---|
[3096] | 9 | SUBROUTINE info_PEM(year_iter,criterion_stop,i_myear,n_myear) |
---|
[2886] | 10 | |
---|
[2980] | 11 | !======================================================================= |
---|
| 12 | ! |
---|
[3096] | 13 | ! Purpose: Update the first line of "info_PEM.txt" to count the number of simulated Martian years |
---|
| 14 | ! Write in "info_PEM.txt" the reason why the PEM stopped and the number of simulated years |
---|
[2980] | 15 | ! |
---|
[3039] | 16 | ! Author: RV, JBC |
---|
[2980] | 17 | !======================================================================= |
---|
| 18 | |
---|
[3076] | 19 | use time_evol_mod, only: convert_years |
---|
[2886] | 20 | |
---|
[3076] | 21 | implicit none |
---|
[2886] | 22 | |
---|
[3076] | 23 | !----- Arguments |
---|
| 24 | integer, intent(in) :: year_iter, criterion_stop ! # of year and reason to stop |
---|
| 25 | integer, intent(in) :: i_myear, n_myear ! Current simulated Martian year and maximum number of Martian years to be simulated |
---|
[2886] | 26 | |
---|
[3076] | 27 | !----- Local variables |
---|
[3096] | 28 | logical :: ok |
---|
| 29 | integer :: cstat |
---|
| 30 | character(10) :: ich1, ich2, fch |
---|
[2886] | 31 | |
---|
[3076] | 32 | !----- Code |
---|
[3096] | 33 | inquire(file = 'info_PEM.txt', exist = ok) |
---|
[3039] | 34 | if (ok) then |
---|
[3096] | 35 | write(ich1,'(i0)') i_myear |
---|
| 36 | write(ich2,'(i0)') n_myear |
---|
[3097] | 37 | 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" |
---|
[3096] | 38 | call execute_command_line('sed -i "1s/.*/'//trim(ich1)//' '//trim(ich2)//' '//trim(fch)//'/" info_PEM.txt',cmdstat = cstat) |
---|
| 39 | if (cstat > 0) then |
---|
| 40 | error stop 'info_PEM: command exection failed!' |
---|
| 41 | else if (cstat < 0) then |
---|
| 42 | error stop 'info_PEM: command execution not supported!' |
---|
| 43 | endif |
---|
| 44 | open(1,file = 'info_PEM.txt',status = "old",position = "append",action = "write") |
---|
| 45 | write(1,*) year_iter, i_myear, criterion_stop |
---|
| 46 | close(1) |
---|
[3039] | 47 | else |
---|
[3096] | 48 | error stop 'The file ''info_PEM.txt'' does not exist and cannot be updated!' |
---|
[3039] | 49 | endif |
---|
| 50 | |
---|
[3096] | 51 | END SUBROUTINE info_PEM |
---|
[3039] | 52 | |
---|
[3096] | 53 | END MODULE info_PEM_mod |
---|