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

Click For Summary

Discussion Overview

The discussion revolves around a compilation error in a Fortran 90/95 program related to the visibility of a function within a module. Participants explore the implications of the IMPLICIT NONE statement and the PRIVATE attribute in module definitions.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports an error indicating that the function 'BMatScal' has no IMPLICIT type, despite having specified its type in the definition.
  • Another participant suggests checking if the 'USE BMatricesScalar' statement is included in the program.
  • A different participant acknowledges the inclusion of the 'USE' statement and recommends removing the 'PRIVATE' attribute.
  • One participant identifies a potential issue with the omission of '::' after 'PRIVATE', which could affect the visibility of module members.
  • Another participant proposes that module entries can be private by default, with the option to explicitly declare certain functions as public to avoid naming collisions.
  • A later reply agrees with this approach, indicating it as a valid option.

Areas of Agreement / Disagreement

Participants express differing views on the handling of module visibility and the implications of the PRIVATE attribute. There is no consensus on the best approach to resolve the initial error.

Contextual Notes

Participants discuss the nuances of Fortran module visibility, including the implications of IMPLICIT NONE and the use of PRIVATE and PUBLIC attributes, without resolving the specific compilation error.

ted_kingdom
Messages
5
Reaction score
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(:,:)
			REAL :: 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
Have you added 'use BMatriceScalar' in your program?
 
Ah I see you have. My mistake. Try removing 'private'
 
  • Like
Likes   Reactions: 1 person
a_potato, you are right. I changed default setting by omitting :: after PRIVATE. Thank you for noticing it!
 
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   Reactions: 1 person
Allday, yes, you're right. This would be an option as well. Thank you.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K