I need help converting a code Fortran to Rstudio

I am new in programming. I need to convert a Fortran code to Rstudio. Could someone help me please. Any help would be greatly appreciated. My code is the following

use msimsl
	use PORTLIB	
	integer n(1),k,l,x,y,s1,s2
	integer,allocatable :: M1(:),M2(:)
	Double precision p,p1,p2
	write (*,*) 'Enter (x,y)'
	read (*,*) x,y
    open(unit=1,file='result.txt')   

	l=0
	k=0
	do 1 I=1,10000000
	s1=0
	s2=0
	n=0
	call RNPOI(1,16.0,n)
	
      if(n(1).eq.0) then
 	    k=k+1			   
       	goto 1
	    endif

	allocate (M1(n(1)),M2(n(1)))

	call RNBIN(n(1),2,0.25,M1)
	call RNBIN(n(1),2,0.5,M2)

	do 2 j=1,n(1)
	s1=s1+M1(j)
  2	s2=s2+M2(j)

	if (s1.EQ.x.and.s2.LE.y) l=l+1
	if (s1.LT.x.and.s2.eq.y) l=l+1

	if (s1.LT.x.and.s2.LT.y) k=k+1
	DEALLOCATE (M1,M2)
  1	continue
	p1=real(k)/10000000.0d0
	p2=(real(k)+real(l))/10000000.0d0
      p=(real(k)+0.5*real(l))/10000000.0d0
      write (1,*) ' The true LESS p-value =',p1
      write (1,*) ' The true Mid-p-value =',p
      write (1,*) ' The true p-value =',p2
	close(unit=1)
      stop
	end

See the FAQ: How to do a minimal reproducible example reprex for beginners. The code provided does not compile under gfortran due to an error on the first line and the absence of PORTLIB on the second. Because it won't compile, it can't be converted with f2c to C to see what it does. The alternative (for me at least) is turning the calendar back to 1966 and learn FORTRAN all over again.

Besides

GOTO considered harmful

@nirgrahamuk 's link is also what I'd recommend doing with FORTRAN source code.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.