main Program

Uses

  • program~~main~8~~UsesGraph program~main~8 main fargparse fargparse program~main~8->fargparse module~mapl MAPL program~main~8->module~mapl mpi mpi program~main~8->mpi module~esmf_cfiomod ESMF_CFIOMod module~mapl->module~esmf_cfiomod module~mapl_esmffieldbundleread MAPL_ESMFFieldBundleRead module~mapl->module~mapl_esmffieldbundleread module~mapl_esmffieldbundlewrite MAPL_ESMFFieldBundleWrite module~mapl->module~mapl_esmffieldbundlewrite module~mapl_fieldutils MAPL_FieldUtils module~mapl->module~mapl_fieldutils module~mapl_genericmod MAPL_GenericMod module~mapl->module~mapl_genericmod module~mapl_gridcompsmod MAPL_GridCompsMod module~mapl->module~mapl_gridcompsmod module~mapl_openmp_support MAPL_OpenMP_Support module~mapl->module~mapl_openmp_support module~mapl_profiler mapl_Profiler module~mapl->module~mapl_profiler module~mapl_stubcomponent MAPL_StubComponent module~mapl->module~mapl_stubcomponent module~mapl_varspecmiscmod MAPL_VarSpecMiscMod module~mapl->module~mapl_varspecmiscmod module~maplbase_mod MAPLBase_Mod module~mapl->module~maplbase_mod module~pfio pFIO module~mapl->module~pfio

Standalone Program for Testing fargparse


The error logging may eventually evolve into a module based on the ESMF logger. For now these macros provide simple traceback capability. new Old New Assumes status is passed back in dummy called “rc” Assumes “/home/runner/work/MAPL/MAPL/include/MAPL_ErrLog.h” and 125 are appropriate The following macro causes a variable to appear to be “used” according to the compiler. This is a kludge to avoid excessive warnings. In most cases, a better fix would be to modify the the procedure interface, but it is impractical in the short term.

Note that the conditional is never satisfied and a reasonable compiler will optimize the line away. (Hopefully without reintroducing the warning!)


Calls

program~~main~8~~CallsGraph program~main~8 main proc~mapl_abort MAPL_abort program~main~8->proc~mapl_abort proc~mapl_verify MAPL_Verify program~main~8->proc~mapl_verify proc~run~7 run program~main~8->proc~run~7 mpi_abort mpi_abort proc~mapl_abort->mpi_abort proc~mapl_throw_exception MAPL_throw_exception proc~mapl_verify->proc~mapl_throw_exception proc~run~7->proc~mapl_verify at at proc~run~7->at cast cast proc~run~7->cast mapl_fargparsecli mapl_fargparsecli proc~run~7->mapl_fargparsecli mpi_init mpi_init proc~run~7->mpi_init proc~mapl_return MAPL_Return proc~run~7->proc~mapl_return proc~mapl_return->at proc~mapl_return->proc~mapl_throw_exception insert insert proc~mapl_return->insert

Variables

Type Attributes Name Initial
integer :: status
type(MAPL_CapOptions) :: cap_options
type(MAPL_FargparseCLI) :: cli

Subroutines

subroutine extra_options(parser, rc)

Arguments

Type IntentOptional Attributes Name
type(ArgParser), intent(inout) :: parser
integer, intent(out), optional :: rc

subroutine run(rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(out), optional :: rc

Source Code

program main
      use MAPL
      use mpi
      use fargparse

      implicit none

      type(MAPL_FargparseCLI) :: cli
      type(MAPL_CapOptions)   :: cap_options
      integer :: status

!------------------------------------------------------------------------------

      call run(_RC)

   contains

#undef I_AM_MAIN
#include "MAPL_ErrLog.h"
      subroutine run(rc)

         integer, intent(out), optional :: rc

         integer :: status
         character(len=:), allocatable :: input_file

         call MPI_Init(status)
         _VERIFY(status)

         ! Read and parse the command line, and set parameters
         ! If you have extra options you make a procedure as seen below and add arguments
         ! there and pass in here
         cli = MAPL_FargparseCLI(extra=extra_options)

         ! This does the casting of arguments into cap_options for CAP
         cap_options = MAPL_CapOptions(cli, _RC)

         write(*,*) "done with MAPL_FargparseCLI"
         write(*,*) "  cap_options%with_esmf_moab = ", cap_options%with_esmf_moab
         write(*,*) "  cap_options%npes_input_server = ", cap_options%npes_input_server
         write(*,*) "  cap_options%nodes_input_server = ", cap_options%nodes_input_server
         write(*,*) "  cap_options%npes_output_server = ", cap_options%npes_output_server
         write(*,*) "  cap_options%nodes_output_server = ", cap_options%nodes_output_server
         write(*,*) "  cap_options%egress_file = ", cap_options%egress_file

         ! For our extra options we have to explicitly cast them
         call cast(cli%options%at('file'), input_file, _RC)

         write(*,*) ""
         write(*,*) "Extra arguments"
         write(*,*) "  input file = ", input_file

         _RETURN(_SUCCESS)

      end subroutine run

      subroutine extra_options(parser, rc)
         type (ArgParser), intent(inout) :: parser
         integer, intent(out), optional :: rc

         call parser%add_argument('-f', '--file', &
              help='A file to read', &
              type='string', &
              default='default.config', &
              action='store')

         !_RETURN(_SUCCESS)
         if (present(rc)) rc = 0

      end subroutine extra_options

end program main