MODULE config_core !----------------------------------------------------------------------- ! NAME ! config_core ! ! DESCRIPTION ! Configuration readers common to all planets. ! ! AUTHORS & DATE ! JB Clement, 12/2025 ! ! NOTES ! !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use numerics, only: dp, di, k4, eps ! DECLARATION ! ----------- implicit none ! PARAMETERS ! ---------- character(7), parameter :: rundef_name = 'run.def' character(11), parameter, private :: runPCMdef_name = 'run_pcm.def' character(12), parameter :: callphys_name = 'callphys.def' contains !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !======================================================================= SUBROUTINE get_hybrid(hybrid) !----------------------------------------------------------------------- ! NAME ! get_hybrid ! ! DESCRIPTION ! Get the key definition in "run_pcm.def". ! ! AUTHORS & DATE ! JB Clement, 12/2025 ! ! NOTES ! !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use stoppage, only: stop_clean use display, only: print_msg, LVL_NFO, LVL_WRN use utility, only: bool2str ! DECLARATION ! ----------- implicit none ! ARGUMENTS ! --------- logical(k4), intent(inout) :: hybrid ! LOCAL VARIABLES ! --------------- integer(di) :: ierr, funit, eq_pos logical(k4) :: here, found, hybrid_in character(256) :: line character(128) :: key, res ! CODE ! ---- inquire(file = runPCMdef_name,exist = here) if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//runPCMdef_name//'"!',1) call print_msg('> Reading "'//runPCMdef_name//'"',LVL_NFO) open(newunit = funit,file = runPCMdef_name,status = 'old',form = 'formatted',action = 'read',iostat = ierr) if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "'//runPCMdef_name//'"!',ierr) found = .false. hybrid_in = hybrid do ! Read the line read(funit,'(a)',iostat = ierr) line if (ierr /= 0) exit ! Skip empty lines and comments if (trim(line) == '') cycle if (line(1:1) == '#' .or. line(1:1) == '!') cycle ! Get the position of equal sign eq_pos = index(line,'=') if (eq_pos == 0) cycle ! Get the key and its value/result key = trim(adjustl(line(:eq_pos - 1))) res = trim(adjustl(line(eq_pos + 1:))) ! Check the key if (trim(key) == 'hybrid') then read(res,*,iostat = ierr) hybrid if (ierr == 0) found = .true. exit end if end do close(funit) if (.not. found) call print_msg('Key ''hybrid'' not found in the file "'//runPCMdef_name//'"!',LVL_WRN) if (hybrid .eqv. hybrid_in) call print_msg('USING DEFAULTS : hybrid = '//bool2str(hybrid_in),LVL_NFO) END SUBROUTINE get_hybrid !======================================================================= !======================================================================= SUBROUTINE read_control_data() !----------------------------------------------------------------------- ! NAME ! read_control_data ! ! DESCRIPTION ! Read 'controle' data in "startfi.nc". ! ! AUTHORS & DATE ! JB Clement, 01/2026 ! ! NOTES ! !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use io_netcdf, only: open_nc, close_nc, startfi_name, get_dim_nc, get_var_nc use physics, only: init_physics use orbit, only: init_orbit use soil, only: volcapa use stoppage, only: stop_clean use display, only: print_msg, LVL_NFO ! DECLARATION ! ----------- implicit none ! LOCAL VARIABLES ! --------------- integer(di) :: nindex ! Size of dimension 'index' real(dp), dimension(:), allocatable :: controle ! CODE ! ---- call print_msg('> Reading control data ("'//startfi_name//'")',LVL_NFO) ! Open the "startfi.nc" file call open_nc(startfi_name,'read') ! Get the dimension size of 'index' call get_dim_nc('index',nindex) ! Get 'controle' allocate(controle(nindex)) call get_var_nc('controle',controle) ! Close the file call close_nc(startfi_name) ! Initialize physical data ! Arguments order: rad, g, mugaz, rcp call print_msg('> Initializing physical constants',LVL_NFO) call init_physics(controle(5),controle(7),controle(8),controle(9)) ! Initialize soil data call print_msg('> Initializing soil parameters',LVL_NFO) volcapa = controle(35) if (abs(volcapa) < eps) call stop_clean(__FILE__,__LINE__,'volcapa is 0 in "'//startfi_name//'"!',1) ! Initialize orbital data ! Arguments order: Obliquity, Perihelion, Aphelion, Date of perihelion, Year length, Sol length call print_msg('> Initializing orbital characteristics of the planet',LVL_NFO) call init_orbit(controle(18),controle(15),controle(16),controle(17),controle(14),controle(10)) deallocate(controle) END SUBROUTINE read_control_data !======================================================================= !======================================================================= SUBROUTINE read_display_config() !----------------------------------------------------------------------- ! NAME ! read_display_config ! ! DESCRIPTION ! Read the display parameters in "run_pem.def". ! ! AUTHORS & DATE ! JB Clement, 03/2026 ! ! NOTES ! Separated from 'read_rundef' to get the configuration early. !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ #ifdef CPP_IOIPSL use IOIPSL, only: getin #else ! If not using IOIPSL, we still need to use (a local version of) getin use ioipsl_getincom, only: getin #endif use stoppage, only: stop_clean use display, only: set_display_config, LVL_NFO ! DECLARATION ! ----------- implicit none ! LOCAL VARIABLES ! --------------- logical(k4) :: here, out2term_l, out2log_l integer(di) :: verbosity_lvl_l ! CODE ! ---- inquire(file = rundef_name,exist = here) if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//rundef_name//'" (PEM)!',1) ! Display ! ~~~~~~~ out2term_l = .true. call getin('out2term',out2term_l) out2log_l = .false. call getin('out2log',out2log_l) verbosity_lvl_l = LVL_NFO call getin('verbosity_lvl',verbosity_lvl_l) ! Setter call set_display_config(out2term_l,out2log_l,verbosity_lvl_l) END SUBROUTINE read_display_config !======================================================================= END MODULE config_core