! this subroutine sets the plplot_lib environment variable
! with that which is passed in the "path" argument. it shoud 
! be called once before any plplot routines are called. 
!
! example: osx
!        call set_plplot_libvar("/applications/plplot_data")
! example: windows
!        call set_plplot_libvar("c:\plplot_data")
!
! results in placing plplot_lib=c:\plplot_data in the
! current program's environment so the plplot library
! will look in c:\plplot_data for the plplot resources
! (those pesty plplot font files.
! this subroutine replaces the need for the c++ routine previously
! used> plplot_fonts.c

! subroutine set_plplotlib_var.f written by tony goelz and pjk
! sept. 30, 2018
! *** this routine may also be used with absoft17 under windows ***


      subroutine set_plplot_libvar(path)
      use iso_c_binding
      implicit none
      character(len=*) :: path
      character(len=len_trim(path)+16) :: var_and_val
      interface
        subroutine putenv(arg) bind(c,name="putenv")
        use iso_c_binding
        implicit none
        integer(int_ptr_kind()),value :: arg
        end subroutine
      end interface

      var_and_val="plplot_lib="//trim(path)//char(0)
      call putenv(loc(var_and_val))
      
      end
!
! contents of folder plplot_data are:
! cglobe.map
! cmap0_alternate.pal
! cmap0_black_on_white.pal
! cmap0_default.pal
! cmap0_white_bg.pal
! cmap1_blue_red.pal
! cmap1_blue_yellow.pal
! cmap1_default.pal
! cmap1_gray.pal
! cmap1_highfreq.pal
! cmap1_lowfreq.pal
! cmap1_radar.pal
! globe.map
! plstnd5.fnt
! plxtnd5.fnt
! usa.map
! usaglobe.map