gs2.fpp vs gs2_main.fpp

Issue #126 new
Peter Hill created an issue

gs2.fpp looks like the following:

program gs2  
  ! make_lib is a compiler flag used if running with 
  ! an old version of trinity (coupled flux tube code)
  ! MAKE_LIB is now deprecated.
# ifndef MAKE_LIB

   ! code

# else

  implicit none
  call run_gs2

# endif

end program gs2

where ! code is pretty similar to the body of run_gs2 but with some differences.

Currently, nothing sets MAKE_LIB so we end up with the version in gs2.fpp – should we in fact just be using run_gs2 ?

Comments (7)

  1. David Dickinson

    The comments say MAKE_LIB is deprecated and just for old versions of trinity so I think we probably can drop it. If we define MAKE_LIB then gs2_main.fpp ends up being a bunch of routines outside of a module (so I guess the old trinity just calls these directly without using them). It might be interesting to see if we can even compile with MAKE_LIB defined.

  2. Peter Hill reporter

    Nope, a lot of errors. If we remove MAKE_LIB from gs2_main.fpp so that it always uses a module then it does compile. The tests pass, although I’m not sure how many actually run the gs2 program.

    I guess you might not want a module if you were calling the functions from C, but there are better ways to make that easier and still use a module.

  3. David Dickinson

    Did you try make gs2 or make libgs2.a? I think when MAKE_LIB is defined only the later is supported.

  4. David Dickinson

    I was just wondering if all the errors came from gs2, or if it came from both or just the lib. Or was it just at the compilation stage?

  5. Peter Hill reporter

    Ah sorry, they were all compilation errors from gs2_main.fpp, mostly like Error: Derived type ‘gs2_program_state_type’ at (1) is being used before it is defined, and Symbol ‘state’ at (1) has no IMPLICIT type. All solved by just removing the #ifdefs from around the module parts:

    --- a/src/gs2_main.fpp
    +++ b/src/gs2_main.fpp
    @@ -11,8 +11,6 @@ module old_interface_store
         logical :: override_miller_geometry = .false.
     end module old_interface_store
    
    -# ifndef MAKE_LIB
    -
     !> This module provides the external interface to gs2. It contains functions
     !! to initialize gs2, functions to run gs2, functions to finalize gs2 and 
     !! functions to override/tweak gs2 parameters. 
    @@ -302,7 +300,6 @@ module gs2_main
       type(gs2_program_state_type) :: old_iface_state
    
     contains
    -# endif
    
       !> Starts the global wall clock timer
       !! used by check time. This is useful
    @@ -1947,8 +1944,4 @@ contains
    
       end subroutine gs2_trin_init
    
    -# ifndef MAKE_LIB
     end module gs2_main
    -# endif
    

  6. David Dickinson

    Ah ok, that makes sense. I think that shows that this MAKE_LIB approach isn’t really supported anymore – I think we’d need to cut out a whole bunch of other stuff that has been introduced to gs2_main.fpp to retain the old MAKE_LIB approach.

  7. Log in to comment