Files called from SICServer should now compile under linux
This commit is contained in:
115
tecs/sys_aunix.f
115
tecs/sys_aunix.f
@@ -82,6 +82,120 @@
|
||||
endif
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_TEMP_NAME(NAME, PATH) !!
|
||||
!! ====================================
|
||||
!! get a temporary file name
|
||||
!!
|
||||
character*(*) NAME !! (in) name
|
||||
character*(*) PATH !! (out) path
|
||||
|
||||
character line*64, pid*5
|
||||
integer i, l
|
||||
|
||||
integer getppid
|
||||
|
||||
call sys_getenv('USER', line)
|
||||
if (line .eq. ' ') then
|
||||
call str_trim(line, '/tmp/.'//name, l)
|
||||
else
|
||||
call str_trim(line, '/tmp/.'//name//'_'//line, l)
|
||||
endif
|
||||
|
||||
write(pid,'(i5)') getppid()
|
||||
i=1
|
||||
1 if (pid(i:i) .eq. ' ') then
|
||||
i=i+1
|
||||
goto 1
|
||||
endif
|
||||
path=line(1:l)//'.'//pid(i:5)
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_LOAD_ENV(FILE) !!
|
||||
!! =============================
|
||||
!! load environment from temporary file
|
||||
!!
|
||||
character*(*) FILE !! filename
|
||||
|
||||
character path*128, line*128
|
||||
integer lun, i, l
|
||||
|
||||
integer getppid
|
||||
|
||||
call sys_temp_name(file, path)
|
||||
call sys_get_lun(lun)
|
||||
open(lun,file=path,status='old',readonly,err=9)
|
||||
5 read(lun,'(q,a)',end=8) l, line
|
||||
l=min(l,len(line))
|
||||
i=index(line,'=')
|
||||
if (i .eq. 0) then
|
||||
if (l .gt. 0) call sys_setenv(line(1:l), ' ')
|
||||
elseif (i .gt. 1 .and. i .lt. l) then
|
||||
call sys_setenv(line(1:i-1),line(i+1:l))
|
||||
endif
|
||||
goto 5
|
||||
8 close(lun)
|
||||
9 call sys_free_lun(lun)
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_SAVE_ENV(FILE, NAMES, N_NAMES) !!
|
||||
!! =============================================
|
||||
!! save environment on temporary file
|
||||
!!
|
||||
character*(*) FILE !! filename
|
||||
integer N_NAMES !! number of names
|
||||
character*(*) NAMES(N_NAMES) !! names of variables to save
|
||||
|
||||
character path*128, line*128
|
||||
integer lun, i, j, l
|
||||
|
||||
call sys_temp_name(file, path)
|
||||
call sys_get_lun(lun)
|
||||
|
||||
open(lun,file=path,status='unknown',carriagecontrol='list'
|
||||
1,err=19)
|
||||
|
||||
do i=1,n_names
|
||||
call sys_getenv(names(i), line)
|
||||
call str_trim(names(i),names(i), j)
|
||||
call str_trim(line,line, l)
|
||||
write(lun,'(3a)') names(i)(1:j),'=',line(1:l)
|
||||
enddo
|
||||
|
||||
close(lun)
|
||||
9 call sys_free_lun(lun)
|
||||
return
|
||||
|
||||
19 type *,'SYS_SAVE_ENV: can not open tmp. file'
|
||||
goto 9
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_WAIT(SECONDS) !!
|
||||
!! ============================
|
||||
!! wait for SECONDS
|
||||
real SECONDS !! resolution should be better than 0.1 sec.
|
||||
|
||||
real tim, del
|
||||
|
||||
tim=secnds(0.0)
|
||||
1 del=seconds-secnds(tim)
|
||||
if (del .ge. 0.999) then
|
||||
call sleep(int(del))
|
||||
goto 1
|
||||
endif
|
||||
if (del .gt. 0) then
|
||||
call usleep(int(del*1E6))
|
||||
goto 1
|
||||
endif
|
||||
end
|
||||
|
||||
!!-----------------------------------------------------------------------------
|
||||
!!
|
||||
subroutine SYS_GET_LUN(LUN) !!
|
||||
@@ -242,4 +356,3 @@
|
||||
endif
|
||||
endif
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user