Ignore:
Timestamp:
Feb 16, 2026, 11:41:37 AM (12 days ago)
Author:
jbclement
Message:

PEM:
Modify the PEM semantics to standardize file/functions/variable names and avoid ambiguity: workflow = repetion of cycles; cycle = PCM phase + PEM phase; PCM phase = 2+ PCM runs of 1 year each, PEM phase = 1 PEM run of 'x' years.
JBC

File:
1 moved

Legend:

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

    r4071 r4072  
    1 MODULE info
     1MODULE workflow_status
    22!-----------------------------------------------------------------------
    33! NAME
    4 !     info
     4!     workflow_status
    55!
    66! DESCRIPTION
    77!     Handles counters for PCM/PEM coupled runs and duration information
    8 !     of the simulation metadata.
     8!     of the simulation.
    99!
    1010! AUTHORS & DATE
     
    2525! PARAMETERS
    2626! ----------
    27 character(14), parameter :: infofile_name = 'launchPEM.info'
    28 
    29 ! VARIABLES
    30 ! ---------
    31 integer(di) :: iPCM, iPEM, nPCM, nPCM_ini ! Data about the chained simulation of PCM/PEM runs
     27character(16), parameter :: statusfile_name = 'pem_workflow.sts'
     28integer(di),   protected :: i_pcm_run, i_pem_run, n_pcm_runs, n_pcm_runs_ini ! Data about the chained simulation of PCM/PEM runs
    3229
    3330contains
     
    3532
    3633!=======================================================================
    37 SUBROUTINE read_info()
     34SUBROUTINE read_workflow_status()
    3835!-----------------------------------------------------------------------
    3936! NAME
    40 !    read_info
     37!    read_workflow_status
    4138!
    4239! DESCRIPTION
    43 !    Read the file "launchPEM.info" to get the number of simulated
     40!    Read the file "pem_workflow.sts" to get the number of simulated
    4441!    years.
    4542!
     
    5451! ------------
    5552use stoppage,  only: stop_clean
    56 use evolution, only: n_yr_sim, nmax_yr_sim, set_r_plnt2earth_yr
     53use evolution, only: n_yr_sim, ntot_yr_sim, set_r_plnt2earth_yr
    5754use display,   only: print_msg
     55use utility,   only: int2str
    5856
    5957! DECLARATION
     
    6967! CODE
    7068! ----
    71 inquire(file = infofile_name,exist = here)
    72 if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//infofile_name//'"! It should be created by the launching script.',1)
    73 call print_msg('> Reading "'//infofile_name//'"')
    74 open(newunit = funit,file = infofile_name,status = 'old',form = 'formatted',action = 'read',iostat = ierr)
    75 if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "'//infofile_name//'"!',ierr)
    76 read(funit,*) n_yr_sim, nmax_yr_sim, tmp, iPCM, iPEM, nPCM, nPCM_ini
     69inquire(file = statusfile_name,exist = here)
     70if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//statusfile_name//'"! It should be created by the PEM workflow script.',1)
     71call print_msg('> Reading "'//statusfile_name//'"')
     72open(newunit = funit,file = statusfile_name,status = 'old',form = 'formatted',action = 'read',iostat = ierr)
     73if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "'//statusfile_name//'"!',ierr)
     74read(funit,*) n_yr_sim, ntot_yr_sim, tmp, i_pcm_run, i_pem_run, n_pcm_runs, n_pcm_runs_ini
    7775call set_r_plnt2earth_yr(tmp)
    7876close(funit)
    7977
    80 END SUBROUTINE read_info
     78call print_msg('Current PEM run: '//int2str(i_pem_run))
     79call print_msg('Input PCM runs : '//int2str(i_pcm_run - 1)//' and '//int2str(i_pcm_run))
     80
     81END SUBROUTINE read_workflow_status
    8182!=======================================================================
    8283
    8384!=======================================================================
    84 SUBROUTINE update_info(n_yr_run,stopPEM,n_yr_sim,nmax_yr_sim)
     85SUBROUTINE update_workflow_status(n_yr_run,stopPEM,n_yr_sim,ntot_yr_sim)
    8586!-----------------------------------------------------------------------
    8687! NAME
    87 !    update_info
     88!    update_workflow_status
    8889!
    8990! DESCRIPTION
    90 !    Update the first line of "launchPEM.info" to count the number of
    91 !    simulated years. Write in "launchPEM.info" the reason why the PEM
     91!    Update the first line of "pem_workflow.sts" to count the number of
     92!    simulated years. Write in "pem_workflow.sts" the reason why the PEM
    9293!    stopped and the number of simulated years.
    9394!
     
    116117real(dp),    intent(in) :: n_yr_run    ! # of years
    117118real(dp),    intent(in) :: n_yr_sim    ! Current simulated year
    118 real(dp),    intent(in) :: nmax_yr_sim ! Maximum number of years to be simulated
     119real(dp),    intent(in) :: ntot_yr_sim ! Maximum number of years to be simulated
    119120
    120121! LOCAL VARIABLES
     
    126127! CODE
    127128! ----
    128 call print_msg('> Updating "'//infofile_name//'"')
    129 inquire(file = infofile_name,exist = here)
    130 if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//infofile_name//'"! It should be created by the launching script.',1)
     129call print_msg('> Updating "'//statusfile_name//'"')
     130inquire(file = statusfile_name,exist = here)
     131if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//statusfile_name//'"! It should be created by the PEM workflow script.',1)
    131132
    132133! Modify the header (first line)
    133134write(fch1,'(f'//int2str(nb_digits(n_yr_sim) + 5)//'.4)') n_yr_sim
    134 write(fch2,'(f'//int2str(nb_digits(nmax_yr_sim) + 5)//'.4)') nmax_yr_sim
    135 write(fch3,'(f6.4)') r_plnt2earth_yr ! 4 digits to the right of the decimal point to respect the precision of year in "launch_pem.sh"
    136 call execute_command_line('sed -i "1s/.*/'//trim(fch1)//' '//trim(fch2)//' '//trim(fch3)//' '//int2str(iPCM)//' '//int2str(iPEM + 1)//' '//int2str(nPCM)//' '//int2str(nPCM_ini)//'/" launchPEM.info',cmdstat = cstat)
     135write(fch2,'(f'//int2str(nb_digits(ntot_yr_sim) + 5)//'.4)') ntot_yr_sim
     136write(fch3,'(f6.4)') r_plnt2earth_yr ! 4 digits to the right of the decimal point to respect the precision of year in "pem_workflow_lib.sh"
     137call execute_command_line('sed -i "1s/.*/'//trim(fch1)//' '//trim(fch2)//' '//trim(fch3)//' '//int2str(i_pcm_run)//' '//int2str(i_pem_run + 1)//' '//int2str(n_pcm_runs)//' '//int2str(n_pcm_runs_ini)//'/" pem_workflow.sts',cmdstat = cstat)
    137138if (cstat > 0) then
    138139    call stop_clean(__FILE__,__LINE__,'command execution failed!',1)
     
    142143
    143144! Add the information of current PEM run at the end of file
    144 open(newunit = funit,file = infofile_name,status = "old",position = "append",action = "write",iostat = ierr)
    145 if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "'//infofile_name//'"!',ierr)
    146 ! Date, Number of years done by the PEM run, Number of years done by the chainded simulation, Code of the stopping criterion
     145open(newunit = funit,file = statusfile_name,status = "old",position = "append",action = "write",iostat = ierr)
     146if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "'//statusfile_name//'"!',ierr)
     147! Date, Number of years done by the PEM run, Number of years done by the chained simulation, Code of the stopping criterion
    147148write(funit,'(f20.4,f20.4,f20.4,i20)') pem_ini_date + n_yr_sim, n_yr_run, n_yr_sim, stopPEM
    148149close(funit)
    149150
    150 END SUBROUTINE update_info
     151END SUBROUTINE update_workflow_status
    151152!=======================================================================
    152153
    153 END MODULE info
     154END MODULE workflow_status
Note: See TracChangeset for help on using the changeset viewer.