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

AI Thread Summary
The discussion centers on a compilation error in a Fortran program related to the function 'BMatScal', which is not recognized due to an implicit type issue. The user initially encounters an error stating that 'BMatScal' has no implicit type, despite having defined it within a module. The solution involves addressing the 'PRIVATE' declaration in the module, which restricts access to the function. It is suggested to either remove the 'PRIVATE' statement or explicitly declare 'BMatScal' as 'PUBLIC' to ensure it can be accessed in the program. The conversation highlights the importance of managing module visibility in Fortran, allowing for internal constants and functions to remain private while selectively exposing necessary components.
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 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 1 person
Allday, yes, you're right. This would be an option as well. Thank you.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
4
Views
2K
Replies
9
Views
5K
Replies
8
Views
2K
Replies
5
Views
5K
Replies
1
Views
2K
Back
Top