initialize_python_bridge Subroutine

public subroutine initialize_python_bridge(im, jm, lm)

Arguments

Type IntentOptional Attributes Name
integer, intent(in), value :: im
integer, intent(in), value :: jm
integer, intent(in), value :: lm

Source Code

   subroutine initialize_python_bridge(im, jm, lm)
      ! -----------------------------
      ! Initialize the underlying python tools with a grid size.
      ! It will spin a central CFFI-handled python interpreter
      ! It also gives us a hook to do pre-load of common packages (numpy, tf, etc.)
      !
      ! TODO | Dev Note : this works for a single GRID. A much powerful system
      !                   would not get the dimensions upfront but have them part
      !                   of the backward fetch from python to MAPL
      ! -----------------------------
      integer, intent(in), value :: im, jm, lm

      character(len=ESMF_MAXSTR) :: IAm
      integer :: STATUS
      integer :: RC

#ifdef PYTHONBRIDGE_INTEGRATION
      logical :: halting_mode(5)
      logical :: set_halting_allowed

      ! Spin the interface - we have to deactivate the ieee error
      ! to be able to load numpy, scipy and other numpy packages
      ! that generate an overflow during init

      set_halting_allowed = ieee_support_halting(ieee_overflow)

      if (set_halting_allowed) then
         call ieee_get_halting_mode(ieee_overflow, halting_mode)
         call ieee_set_halting_mode(ieee_overflow, .false.)
      end if
      call mapl_fortran_python_bridge_global_initialize(im, jm, lm)
      if (set_halting_allowed) then
         call ieee_set_halting_mode(ieee_overflow, halting_mode)
      end if
#endif

   end subroutine initialize_python_bridge