EzDevInfo.com

plato

JavaScript source code visualization, static analysis, and complexity tool

error message in plato

I am very new Fortran and I am doing some elementary practice. I have installed Plato latest edition. I found this program in the net, and try to compile it

program dotprod
  implicit none
  real :: c
  real, dimension(3) :: a, b
  print*,'Enter first vector'
  read*, a
  print*,'Enter second vector'
  read*, b
  c = a(1)*b(1) + a(2)*b(2) + a(3)*b(3)
  print*,'Dot product = ', c

end program dotprod

Plato shows no sign of error when I build and compile, but when I try to run the program the following error message shows up: the executable does not exist.

can anyone help me explain how to handle this error ?

thanks


Source: (StackOverflow)

Is there a way to run Plato on coffeescript

I've written all my server side code and Coffeescript and I'm wondering if there is a way to run Plato on it?


Source: (StackOverflow)

Advertisements

Fortran rank mismatch error

I receive the following error

Compiling file: tropic.f
Warning: Extension: Tab character in format at (1)
C:\Users\Marchant\Desktop\tropic.f(432) : error - Expected a right parenthesis in expression at column 72 
Warning: Rank mismatch in argument 'tk' at (1) (scalar and rank-1)
Warning: Rank mismatch in argument 't' at (1) (scalar and rank-1)
Warning: Rank mismatch in argument 'tk' at (1) (scalar and rank-1)
Warning: Rank mismatch in argument 't' at (1) (scalar and rank-1)

Compilation failed.

in this program,

     dimension ts1(3),ts2(3),ta1(3),ta2(3),out(14,300)
      real lwc, lambda
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc
      common /param2/ pbot,ptop,dp,gam, bt,ct,tao,a21,lambda,lwc
      common /heat/ beta,olr1,olr2,alb0,albgr,expo1,expo2,alb1,alb2

      pbot=1.0e5
      ptop=2.0e4
      dp=pbot-ptop
      open(12,file='tropic.in',form='formatted')
      read(12,*) itermx, delt, iprint
      read(12,*) lambda, gam, bt, ct, a1
      read(12,*)  beta,olr1,olr2,alb0,albgr,expo1,expo2
      write(*,*) 'olr1=',olr1,', olr2=',olr2,', expo1=',expo1,', expo2='
     1 ,expo2

c **  Set relative areas of convecting a1 and nonconvecting a2 regions.
c      a1=.3
      tao=265.
      alpha=0.06
      alpha2=alpha/2.
      alpha1=1.-alpha
c      expo1=80.
c      expo2=80.
      expa1=0.
      expa2=0.
      co=4.2e7
      ca=1.0e7
      xkap=0.288
      rvap=461.
      cp=1004.
      rgas=287.
      grav=9.81
c      gam=1.0e-3
c      lambda=1.0e3
      pr=1.0e5
      tr=300.
      xl=2.5e6
      write(*,*) ' gam=',gam
c**   structure of output array
c     out(1)=a1;   2=gam;  3=lambda
c     4=ts1        5=ts2   6=alb1     7=alb2
c     8=r1         9=r2    10=ts1tend  11=ts2tend
c    13=thet1     14=thet2
      ikase=0
c *********  BIG LOOP  ****************
      do 888 nn=1,2
      a1=0.1+0.2*nn

      do 888 ll=1,7
c      gam=1.0e-3*facg
      gam=1/1024.*2.0**(ll-1)
      do 888 mm=1,7
c      lambda=1.0e+3*facl
      lambda=64*2.0**(mm-1)
c      write(*,*) '*******************************'
c      write(*,*) 'GAM=',gam,',  LAMBDA=',lambda,',  A1=',a1
      a2=1.-a1
      a21=a2/a1
      a12=a1/a2

c  initialize variables
      do i = 1,3
      ts1(i)=301.
      ts2(i)=300.
      ta1(i)=302.
      ta2(i)=300.
      end do
      is=1
      js=2


      tdelto=2.*delt/co
      tdelta=2.*delt/ca

c      write(*,999) ts1(js),ts2(js),ta1(js),ta2(js),r1,r2,ra1,ra2
 999  format(1x,9f8.1)
c      write(*,*) pbot,ptop,dp,pr,gam,bt,ct,tao,a21,lambda,lwc

       ikase=ikase+1

c***   Time Loop  *****

      do 1000 it=1,itermx
      dta=ta1(js)-ta2(js)
      dto=ts1(js)-ts2(js)
      call radiat(ts1(js),ts2(js),ta1(js),ta2(js),r1,r2,ra1,ra2)
      call theta(ts1(js),ts2(js),ta1(js),ta2(js),demdp,demd2,deddp)
c**  Note that demdp = del(theta)/grav      
      ts1(3)=ts1(is)+tdelto*(r1-gam*dto*cp*demdp-expo1)
      ts2(3)=ts2(is)+tdelto*(r2+a12*gam*dto*cp*demdp-expo2)
c      ta1(3)=ta1(is)+tdelta*(ra1-a21*gam*dto*cp*demdp-expa1)
c      ta2(3)=ta2(is)+tdelta*(ra2+gam*dto*cp*deddp-expa2)
c  apply Robert/Asselin filter
      ts1(js)=ts1(js)*alpha1 +alpha2*(ts1(3)+ts1(is))
      ts2(js)=ts2(js)*alpha1 +alpha2*(ts2(3)+ts2(is))
c      if((it-1)/iprint*iprint.eq.it-1) then
      if((it.eq.itermx)) then
      time=(it-1)*delt/86400.
      ts1tend=(r1-gam*dto*cp*demdp-expo1)*86400./co
      ts2tend=(r2+a12*gam*dto*cp*demdp-expo2)*86400./co
c      ta1tend=(-a21*gam*dto*cp*demdp)
c      ta2tend=( gam*dto*cp*demdp)
      thet1=thet(ts1,qsat(ts1,pbot),pbot)
      thet2=thet(ts2,qsat(ts2,pbot),pbot)
c**   structure of output array
c     out(1)=a1;   2=gam;  3=lambda
c     4=ts1        5=ts2   6=alb1     7=alb2
c     8=r1         9=r2    10=ts1tend  11=ts2tend
c    12=thet1     13=thet2
c    Set up array
      out(1,ikase)=a1
      out(2,ikase)=gam
      out(3,ikase)=lambda
      out(4,ikase)=ts1(js)
      out(5,ikase)=ts2(js)
      out(6,ikase)=alb1
      out(7,ikase)=alb2
      out(8,ikase)=r1
      out(9,ikase)=r2
      out(10,ikase)=ts1tend
      out(11,ikase)=ts2tend
      out(12,ikase)=thet1
      out(13,ikase)=thet2
      out(14,ikase)=qsat(ts1(js),pr)


c      write(*,*)  'Day=',time, ',  iter=',it
c      write(*,*) a21,gam,dto,cp,demdp
c      write(*,*) 'demdp, demd2,deddp', demdp, demd2,deddp
c      write(*,*) 'lwc=',lwc,alb1, alb2
c*********x*********x*********x*********x*********x*********x*********x**********
c      write(*,*) '   ts1,    ts2,    ta1,    ta2,     r1,     r2,    ra1,
c     1     ra2'
c      write(*,999) ts1(3),ts2(3),ta1(3),ta2(3),r1,r2,ra1,ra2
c      write(*,999) ts1(js),ts2(js),ta1(js),ta2(js),r1,r2,ra1,ra2
c      write(*,998) ts1tend,ts2tend,ta1tend,ta2tend, thet1, thet2
  998 format(1x,8f10.5)
      endif
c **  Update Variables
      is=3-is
      js=3-js
      ts1(js)=ts1(3)
      ts2(js)=ts2(3)
      ta1(js)=ta1(3)
      ta2(js)=ta2(3)

 1000 continue
 888  continue
      open(13,file='tropic.out',form='formatted')
c*********x*********x*********x*********x*********x*********x*********x**********
      write(*,*) '   A1        gam     lambda   ts1    ts2     alb1     
     1alb2    r1      r2    ts1tend  ts2tend  thet1   thet2   qsat'
      write(13,*) '   A1        gam     lambda   ts1    ts2     alb1     
     1alb2    r1      r2    ts1tend  ts2tend  thet1   thet2   qsat'
      do ii=1,ikase
      xkrap=out(2,ii)*out(3,ii)
      write(*,789) (out(j,ii),j=1,14),xkrap
      write(13,789) (out(j,ii),j=1,14),xkrap
  789 format(1x,f6.1,f9.5,7f9.2,2f9.5,2f8.2,2f8.4)
      enddo

      stop
      end

c ******************************************************
      subroutine theta(ts1,ts2,ta1,ta2,demdp,demd2,deddp)
c ** This subroutine finds the theta gradients
      real lwc, lambda
      common /param2/ pbot,ptop,dp,gam, bt,ct,tao,a21,lambda,lwc
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc

      demdp=(thet(ts1,qsat(ts1,pbot),pbot)-thet(ts2,qsat(ts2,pbot),
     1 pbot))/9.81
c     1 pbot))/dp
      demd2=(thet(ta1,0.001,ptop)-thet(ts1,qsat(ts1,pbot),pbot))
     1 /9.81
c     1 /dp
      deddp=(thet(ts1,0.00001,ptop)-thet(ts2,0.00001,pbot))/9.81
c     1 /dp
      return
      end
c ******************************************************
      subroutine radiat(ts1,ts2,ta1,ta2,r1,r2,ra1,ra2)
      real lwc, lambda
      common /param2/ pbot,ptop,dp,gam, bt,ct,tao,a21,lambda,lwc
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc
      common /heat/ beta,olr1,olr2,alb0,albgr,expo1,expo2,alb1,alb2


      dta=ta1-ta2
      dto=ts1-ts2
      if(dto.gt.0.0) then
c **  radiation parameterization  for atmosphere
      ra1=-40-bt*(ta1-tao)+ct*(ts1-(ta1+29))
      ra2=-200-bt*(ta2-tao)+ct*(ts2-(ta2+29))
c **  Get liquid water content
c      lwc=lambda*a21*gam*abs(dto)*qsat(ts1,pr)
c **  Get albedo as function of LWC
      alb2=alb0
      alb1=alb0+lambda*gam*abs(dto)*qsat(ts1,pr)
      if(alb1.gt.0.75) alb1=0.75
      r1=400.*(1.-alb1)-olr1-beta*(ts1-300.)
      r2=400.*(1.-alb2)-olr2-beta*(ts2-300.)
      else
c **  here ts2 is hotter than ts1
c **  radiation parameterization  for atmosphere
      ra1=-200-bt*(ta1-tao)+ct*(ts1-(ta1+29))
      ra2=-40-bt*(ta2-tao)+ct*(ts2-(ta2+29))
c **  Get liquid water content
c      lwc=lambda*gam*abs(dto)*qsat(ts2,pr)
c **  Get albedo as function of LWC
      alb1=alb0
      alb2=alb0+lambda*gam*abs(dto)*qsat(ts2,pr)
      if(alb2.gt.0.75) alb2=0.75
      r1=400.*(1.-alb1)-olr2-beta*(ts1-300.)
      r2=400.*(1.-alb2)-olr1-beta*(ts2-300.)
      endif
c      write(*,*) 'lwc=',lwc,', alb1,2=',alb1,alb2,', r,ra-',r1,r2,ra1,ra2

      return
      end

c*********x*********x*********x*********x*********x*********x*********x**********
c*************************************************************
      function temp(the,rv,p)
c**  Function calculates temperature given thetaE, rv and p
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc
      temp=the/((pr/p)**xkap*exp(xl*rv/(cp*tr)))
      return
      end

c*************************************************************
      function thet(t,rv,p)
c**  Function calculates thetaE given t, rv and p
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc
      thet=t*(pr/p)**xkap*exp(xl*rv/(cp*tr))
      return
      end

c*************************************************************
      function thets(t,p)
c**  Function calculates thetaEsaturate given t and p
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc
      if(t.lt.273.15) then
      es=esice(t)
      else
      es=esat(t)
      endif
      rs=0.622*es/(p-es)
      thets=t*(pr/p)**xkap*exp(xl*rs/(cp*tr))
      return
      end

c*************************************************************
      subroutine plevs(p,xlp,dlp,dp)
c**  Subroutine to set pressure levels
      parameter(ilx=25)
      dimension p(ilx),xlp(ilx),dlp(ilx),dp(ilx)
      write(*,*) 'Setting Pressure Levels'
      write(*,*) '    i    p(i)    dp(i)    logp      dlogp'
      pmin=2000.
      pmax=101300.
      delpo=pmax-pmin
      delp=delpo/(ilx-1)
      do i=1,ilx
      p(i)=pmin+(i-1.)*delp
      xlp(i)=alog(p(i))
      end do
      do i=1,ilx-1
      dlp(i)=xlp(i+1)-xlp(i)
      dp(i)=p(i+1)-p(i)
      end do
      dlp(ilx)=0.0
      do i=1,ilx
      write(*,*) i,p(i),dp(i),xlp(i),dlp(i)
      end do
      return
      end

c*************************************************************
      subroutine radini(teq,p,t,sst)
c**  Calculates variables needed by radiation relaxation code
      parameter (ilx=25)
      dimension p(ilx),t(ilx),teq(ilx)
      do i=1,ilx
      if(p(i).lt.12000.) then
      teq(i)=t(i)
c      elseif(p(i).gt.80000.) then
      else
      teq(i)=t(i)-10.
c      teq(i)=t(i)-(p(ilx)/10000.)*2.
      endif
      end do
      return
      end

c*************************************************************
      subroutine initlz(the,rt,rs,t,rv,p,sst)
c**  Subroutine to set initial values of all variables
      parameter (ilx=25)
      dimension the(ilx),rt(ilx),rs(ilx),t(ilx),rv(ilx),
     1 p(ilx)
      common /params/xkap,pr,tr,xl,cp,rgas,grav,taue,taus,taup,tauc
      ttrop=200.
      tsurf=300.
      ptrop=10000.
      dtdp=(tsurf-ttrop)/(p(ilx)-ptrop)
      relhum=0.80
c**  Set T(p)
      do i=1,ilx
      if(p(i).lt.ptrop) then
      t(i)=200.+10.*(ptrop-p(i))/(ptrop-p(1))
      else
      t(i)=200.+dtdp*(p(i)-ptrop)
      endif
      end do
c**  Next calculate vapor mixing ratio and thetaE
      write(*,*) 'index,  pressure, temp.,   vapor mr, thetaE'
      do i=1,ilx
      if(p(i).lt.ptrop) then
      rfrac=0.05
      else
      rfrac=relhum
      endif
      if(t(i).lt.273.) then
      es=esice(t(i))
      else
      es=esat(t(i))
      endif
      rv(i)=rfrac*0.622*es/(p(i)-es)
      rs(i)=0.622*es/(p(i)-es)
      rt(i)=rv(i)
      the(i)=t(i)*(pr/p(i))**xkap*exp(xl*rv(i)/(cp*tr))
      write(*,100) i,p(i),t(i),rv(i),the(i)
  100 format(1x,i3,f12.1,f7.1,e13.3,f7.1)
      end do
      return
      end

c*************************************************************
      function signum(x)
c**  Hankel function
      if(x.eq.0) then
      signum=1.
      else
      signum=(abs(x)+x)*0.5/abs(x)
      endif
      return
      end

c*************************************************************
      subroutine zero(x,n)
      dimension x(n)
      do i=1,n
      x(i)=0.0
      end do
      return
      end

C#######################################################################

    FUNCTION ESICE(TK)                                                      

C   THIS FUNCTION RETURNS THE SATURATION VAPOR PRESSURE WITH RESPECT TO 
C   ICE ESICE (Pascals) GIVEN THE TEMPERATURE T (Kelvin). DLH 11.19.97
C   THE FORMULA USED IS BASED UPON THE INTEGRATION OF THE CLAUSIUS-     
C   CLAPEYRON EQUATION BY GOFF AND GRATCH.  THE FORMULA APPEARS ON P.350
C   OF THE SMITHSONIAN METEOROLOGICAL TABLES, SIXTH REVISED EDITION,    
C   1963.                                                               

    DATA CTA,EIS/273.15,6.1071/                                            

C   CTA = DIFFERENCE BETWEEN KELVIN AND CELSIUS TEMPERATURE             
C   EIS = SATURATION VAPOR PRESSURE (MB) OVER A WATER-ICE MIXTURE AT 0C 

    DATA C1,C2,C3/9.09718,3.56654,0.876793/                                

C   C1,C2,C3 = EMPIRICAL COEFFICIENTS IN THE GOFF-GRATCH FORMULA        
c**** Convert to Celsius
c        tc=t-273.15
    IF (TK.LE.CTA) GO TO 5                                                   
    ESICE = 99999.                                                         
    WRITE(6,3)ESICE                                                        
    3   FORMAT(' SATURATION VAPOR PRESSURE FOR ICE CANNOT BE COMPUTED',   
     1         /' FOR TEMPERATURE > 0C. ESICE =',F7.0)                   
    RETURN                                                                 
    5   CONTINUE                                                          

C   FREEZING POINT OF WATER (K)                                         

    TF = CTA                                                               

C   GOFF-GRATCH FORMULA                                                 

    RHS = -C1*(TF/TK-1.)-C2*ALOG10(TF/TK)+C3*(1.-TK/TF)+ALOG10(EIS)        
    ESI = 10.**RHS                                                         
    IF (ESI.LT.0.) ESI = 0.                                                
    ESICE = ESI*100.
    RETURN                                                                 
    END                                                                    

C#######################################################################

    FUNCTION ESAT(TK)

C   THIS FUNCTION RETURNS THE SATURATION VAPOR PRESSURE OVER            
C   WATER (Pa) GIVEN THE TEMPERATURE (Kelvin).  DLH 11.19.97
C   THE ALGORITHM IS DUE TO NORDQUIST, W.S.,1973: "NUMERICAL APPROXIMA- 
C   TIONS OF SELECTED METEORLOLGICAL PARAMETERS FOR CLOUD PHYSICS PROB- 
C   LEMS," ECOM-5475, ATMOSPHERIC SCIENCES LABORATORY, U.S. ARMY        
C   ELECTRONICS COMMAND, WHITE SANDS MISSILE RANGE, NEW MEXICO 88002.   

    IF (TD.NE. 99999.0) THEN                                                
C   IF (TD.NE.-1001.0) THEN
c**** Convert to Celsius
c   TK = TD+273.15                                                         
    P1 = 11.344-0.0303998*TK                                               
    P2 = 3.49149-1302.8844/TK                                              
    C1 = 23.832241-5.02808*ALOG10(TK)                                      
    ESAT = 100.*10.**(C1-1.3816E-7*10.**P1+8.1328E-3*10.**P2-2949.076/TK)       
    else
          esat = 0.
    END IF                                                                 
    RETURN                                                                 
    END                                                                    
C#######################################################################
        function qsat(tk,p)
        qsat=esat(tk)*0.622/p
        return
        end

Can someone show me how to fix this? its a fortran77 file being compiled in mingw gfortran


Source: (StackOverflow)

Are there any code complexity metering tools that work well with ES6?

My project is ES6 (webpack + babel). Plato is great, but doesn't work with ES6 yet. I took a look at escomplex and the series of related packages, but it looks like the author is no longer maintaining this and it seems like it doesn't support ES6 anyways.

I'm using the ESLint complexity rule to at least warn me if there's an issue (it's set to warn at 6), but it's not the same as a pretty report.

Any suggestions?


Source: (StackOverflow)

FORTRAN 95: OPTIONAL statement does not work (using FTN95 and Plato)

I am having a problem with the OPTIONAL statement in functions and subroutines with Fortran 95. Currently I am using Silverfrost's Plato and their FTN95 compiler (in "Release Win32" mode). After trying to implement the OPTIONAL statement in a more complex program I am writing, I created a very simple program to test it. Here is the code:

program TEST

implicit none
integer :: a=1, b=2

call Z(a,b)
call Z(a)
call Z(b)

end program TEST

subroutine Z(x,y)
implicit none
integer :: x
integer, optional :: y

if (present(y)) then
  write(*,*) x, y
  else
    write(*,*) x
endif

end subroutine Z

I expected the following result displayed on the screen:

1 2
1
2

Well, the code compiles, although I get a warning (673) that "SUBROUTINE Z has been called with too few arguments". After executing it, I get on my screen:

1 2

and then an "Access violation" error message. Can somebody understand what is wrong here?

Thanks a lot! Gilberto


Source: (StackOverflow)

JavaScript code analysis - maintainability rating with Plato

I've been working with JavaScript for a while now and just started analyzing my code with Plato. I'm not sure how it calculates maintainability but the code bellow returns maintainability score of 69.3. What am i missing? Tried adding comments and it didn't change.

/*globals jQuery*/
var App = App|| {};
App.AnimateSearch = (function ($) {
    'use strict';

    var searchContainer = $('[search-container]'),
        emptySearchMessage = $('.empty-search-message');

    function animateEmptyMessage() {
        emptySearchMessage.css({
            'opacity': 0,
            'transform': 'scale(0.5)',
            '-webkit-transform': 'scale(0.5)',
            '-moz-transform': 'scale(0.5)'
        });

        emptySearchMessage.fadeIn().animate({
            'opacity': 1,
            'transform': 'scale(1)',
            '-webkit-transform': 'scale(1)',
            '-moz-transform': 'scale(1)'
        }, 300);
    }

    function animateSearch(customClass) {
        searchContainer = typeof customClass === 'undefined' ? searchContainer : $(customClass);
        searchContainer.css({ 'margin-top': '100px', 'opacity': 0 });

        setTimeout(function () {
            searchContainer.stop().animate({ 'margin-top': '0', 'opacity': 1 }, 300);
        }, 500);
    }

    return {
        animateEmptyMessage: animateEmptyMessage,
        animateSearch: animateSearch
    };
}(jQuery));

Thanks for your help/suggestions!


Source: (StackOverflow)

Terminal error with passing parameters

Plato is a JS code complexity analyzer.

The documentation can be found at that link. I cannot get it to run however. It must be a dumb mistake but here is what I have tried.

plato fileX.js -d somename "~/Desktop/"
plato addNewDocPopup.js -d "~/Desktop/"

Amongst many others :) I don't claim to be amazing at the command line but the error I get is:
Must specify a value for option d (dir : The output directory)

I could have sworn that is exactly what I'm doing... Maybe not...


Source: (StackOverflow)

In AngularJS application can we have multiple services files

In AngularJS application, for one module say "login" functionality can we create multiple services files like logincheck-svc.js and logingo-svc.js And reference both the files in login-ctrl.js file I am asking this question because the services files are becoming large in terms of LOC and Plato report is showing very low maintainability index[due to the complexity in the file]


Source: (StackOverflow)

How to improve the Maintainability Index of the Plato report

I have generated the Plato report for the AngularJS code and now I want to know how I can improve the Maintainability Index. Lint errors improvement does not improve the Maintainability Index. Any refernce links, very much appreciated.

Thanks.


Source: (StackOverflow)

pass function as argument to subroutine using interface doesn't work in Plato Fortran 90

I created a fortran 90 program that I used on a linux machine and compiled using gfortran. It worked fine on the linux machine with gfortran but provides the error

error 327 - In the INTERFACE to SECANTMETHOD (from MODULE SECMETH), the ninth dummy argument (F) was of type REAL(KIND=2) FUNCTION, whereas the actual argument is of type REAL(KIND=2)

when using the Plato compiler (FTN95). Does anyone know how I would need to change my code to work in Plato? I tried to read up on this error and there was some mention of pointers but from what I tried that did not work. I have figured out some workarounds but they make it so that the subroutine can no longer accept any function as an argument - which is pretty much useless. Any help would be greatly appreciated. My code is below.

!--! A module to define a real number precision.
module types
  integer, parameter :: dp=selected_real_kind(15)
end module types

module secFuncs
  contains

  function colebrookWhite(T)
    use types

    real(dp) :: colebrookWhite
    real(dp), intent(in) :: T

    colebrookwhite=25-T**2

    return
  end function colebrookWhite
end module secFuncs

module secMeth
  contains

  subroutine secantMethod(xolder,xold,xnew,epsi1,epsi2,maxit,exitFlag,numit,f)
    use types
    use secFuncs
    implicit none

    interface
      function f(T)
        use types
        real(dp) :: f
        real(dp), intent(in) :: T
      end function f
    end interface

    real(dp), intent(in) :: epsi1, epsi2
    real(dp), intent(inout) :: xolder, xold
    real(dp), intent(out) :: xnew
    integer, intent(in) :: maxit
    integer, intent(out) :: numit, exitFlag
    real(dp) :: fxold, fxolder, fxnew
    integer :: i

    fxolder = f(xolder)
    fxold = f(xold)

    i = 0

    do
      i = i + 1

      xnew = xold - fxold*(xold-xolder)/(fxold-fxolder)

      fxnew = f(xnew)

      if (i == maxit) then
        exitFlag = 1
        numit = i
        return
      else if (abs(fxnew) < epsi1) then
        exitFlag = 2
        numit = i
        return
      else if (abs(xnew - xold) < epsi2) then
        exitFlag = 3
        numit = i
        return
      end if

      xolder = xold
      xold = xnew
      fxolder = fxold
      fxold = fxnew
    end do
  end subroutine secantMethod

end module secMeth

program secantRoots
  use types
  use secMeth
  use secFuncs
  implicit none

  real(dp) :: x1, x2, xfinal, epsi1, epsi2
  integer :: ioerror, maxit, numit, exitFlag

  do
    write(*,'(A)',advance="no")"Please enter two initial root estimates, 2epsi's, and maxit: "
    read(*,*,iostat=ioerror) x1, x2, epsi1, epsi2, maxit

    if (ioerror /= 0) then
      write(*,*)"Invalid input."
    else
      exit
    end if
  end do

  call secantMethod(x1,x2,xfinal,epsi1,epsi2,maxit,exitFlag,numit,colebrookWhite)

  if (exitFlag == 1) then
    write(*,*)"The maximum number of iterations was reached."
  else if (exitFlag == 2) then
    write(*,'(a,f5.3,a,i3,a)')"The root is ", xfinal, ", which was reached in ", numit, " iterations."
  else if (exitFlag == 3) then
    write(*,'(a,i3,a)')"There is slow or no progress at ", numit, " iterations."
  end if

end program secantRoots

Source: (StackOverflow)

How can I generate DLL file in FTN95 by PLATO and use it in C#?

I have spent a week to search online and find a way to generate DLL file from several internally connected subroutines and use it in C# but could not find useful information.

Sample for Fortran code:

Subroutine s1(a,b, c)
double a,b
c= s2(a,b)+ s3(a,b)
return c
end

Subroutine s2(a,b)
double a,b
a= a-b
end

Subroutine s3(a,b)
double a,b
a= a*b
end

The sample code for C# could be like:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace test
{
    class Program
    {
        [DllImport("DllTest.dll")]
        static extern double s1(double a, double b);
        static void Main(string[] args)
        {
            double a = 4;
            double b = 4;
            double c=0;
            double pp = s1(a,b,c);
            Console.WriteLine(pp);
        }
    }
}

I am getting the following error all the time:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

As I am short in time, I appreciate it if you could help me to solve this problem and more on.

Thank you


Source: (StackOverflow)

Exclude subdirectories from plato metric tool

I'm using the Plato tool to analyze my web app.

I'm currently running a command like

plato -r -d plato_report server public -x "public/|vendor|js" -t "My App"

to generate the report. The idea is that while I want to include the server and public folders in the analysis, I want to exclude public/vendor and public/js entirely. However, the exclusion doesn't seem to be working - plato includes files from the subdirectories I'm trying to ignore.

This could be a regex problem or a plato problem, and I'm not really sure here. I've tried other regex exclusion patterns like

-x ^public\/(|vendor|js)[a-zA-Z0-9-\.\/_]*

but to no avail, even though I think these patterns should match.

Any ideas how to achieve this desired behavior with plato? Thank you!


Source: (StackOverflow)

Exclude all files from folder for plato metric

I'm deploy my webapp at a windows maschine (non POSIX command line) and I'm generating JS metric with Plato.

My Question is how can I exclude all files from a given folder that contains subfolders via regular expressions with plato.js. I tried this command for excluding all minified JS Libs:

$ plato -x "^js[a-zA-Z0-9-.\/]*.?js" -r -d report src/app/

All JS files of src/app/js/**/*.js are not excluded.

I test my regex with rubular: http://rubular.com/r/zbTsv1nIWY (fix underscore issue is optional)

Can somebody help me please?


Source: (StackOverflow)