Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[Fortran 90/95] Error: function has no IMPLICIT type

  1. Jan 19, 2014 #1
    Hi!
    I get an error when trying to compile my program:
    Code (Text):
    test8.f95:26.8:

     BMat = BMatScal(InverseJacobian, ShapeFuncDeriv)
            1
    Error: Function 'bmatscal' at (1) has no IMPLICIT type
    I don't know why it complains because I specified type of the function in its definition (please see code below):
    Code (Text):
    MODULE q12
        INTEGER, PARAMETER,PUBLIC::NDIM=2,NNODES=4, NDIR = 2, NSHR = 1
    END MODULE q12

    MODULE BMatricesScalar
        IMPLICIT NONE
        PRIVATE
        CONTAINS
    ! BMatScal function provides B-matrix for scalar-valued variable (e.g. temperature)
            FUNCTION BMatScal(JacobiInv, ShapeFuncDeriv)
                REAL, INTENT(IN) :: JacobiInv(:,:), ShapeFuncDeriv(:,:)
                [COLOR="Red"]REAL[/COLOR] :: BMatScal(SIZE(JacobiInv,1),SIZE(ShapeFuncDeriv,2))
               
                BMatScal = MATMUL(JacobiInv, ShapeFuncDeriv)
            END FUNCTION BMatScal
    END MODULE BMatricesScalar

    PROGRAM q2
        USE q12
        USE BMatricesScalar
        IMPLICIT NONE
        REAL:: InverseJacobian(2,2) = RESHAPE((/1,1,1,1/),(/2,2/)),&
                 ShapeFuncDeriv(2,4) = RESHAPE((/0.0,-0.5,0.0,0.0,0.5,0.0,-0.5,0.5/),(/2,4/)),&
                 BMat(NDIR,NNODES)
                 
        BMat = BMatScal(InverseJacobian, ShapeFuncDeriv)
        PRINT*, BMat(1,:)
        PRINT*, BMat(2,:)
    END PROGRAM q2
    What am I missing? Thanks in advance.
     
    Last edited: Jan 19, 2014
  2. jcsd
  3. Jan 19, 2014 #2
    Have you added 'use BMatriceScalar' in your program?
     
  4. Jan 19, 2014 #3
    Ah I see you have. My mistake. Try removing 'private'
     
  5. Jan 19, 2014 #4
    a_potato, you are right. I changed default setting by omitting :: after PRIVATE. Thank you for noticing it!
     
  6. Feb 3, 2014 #5
    This is a little late, but it's worth mentioning that you can have the module entries to be private as default and then explicitly list the thing you want to expose publically. So you could have,

    PRIVATE ! module members are private by default
    PUBLIC :: BMatScal ! I want BMatScal to be public


    This way you can define internal constants and functions without worrying that they will collide with other modules members when you "use" them.
    and then the use statement would recognize it.
     
  7. Feb 4, 2014 #6
    Allday, yes, you're right. This would be an option as well. Thank you.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: [Fortran 90/95] Error: function has no IMPLICIT type
Loading...