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

In summary, the conversation is about a person getting an error when trying to compile their program, specifically with the BMatricesScalar function. They have specified the type of the function in its definition and have also added 'use BMatricesScalar' in their program. It is suggested that they try removing 'private' and consider using 'private' as the default setting for the module entries.
  • #1
ted_kingdom
5
0
Hi!
I get an error when trying to compile my program:
Code:
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:
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:
Technology news on Phys.org
  • #2
Have you added 'use BMatriceScalar' in your program?
 
  • #3
Ah I see you have. My mistake. Try removing 'private'
 
  • Like
Likes 1 person
  • #4
a_potato, you are right. I changed default setting by omitting :: after PRIVATE. Thank you for noticing it!
 
  • #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 publicThis 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.
 
  • Like
Likes 1 person
  • #6
Allday, yes, you're right. This would be an option as well. Thank you.
 

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

1. What does the error "function has no IMPLICIT type" mean in Fortran 90/95?

This error means that the function being referenced in the code does not have a declared data type. In Fortran 90/95, all variables and functions must have a declared data type before they can be used.

2. How can I fix the "function has no IMPLICIT type" error?

To fix this error, you need to declare the data type of the function in the code. This can be done by adding an explicit type declaration before the function name, such as integer :: my_function for an integer function.

3. Can this error also occur for variables in Fortran 90/95?

Yes, this error can also occur for variables that do not have an explicit data type declaration. All variables, including function arguments, must have a declared type in Fortran 90/95.

4. Why is it important to declare data types in Fortran 90/95?

Declaring data types allows the compiler to properly allocate memory and perform necessary conversions for the variables and functions in the code. It also helps with code readability and can prevent errors or unexpected behavior.

5. Are there any exceptions to declaring data types in Fortran 90/95?

Yes, there are some situations where data types do not need to be explicitly declared, such as with intrinsic functions or when using the implicit none statement. However, it is generally good practice to declare data types for all variables and functions in Fortran 90/95.

Similar threads

  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
4
Views
795
  • Programming and Computer Science
Replies
9
Views
4K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
13
Views
7K
  • Programming and Computer Science
Replies
4
Views
25K
Back
Top