Here's a complete example with a comment that FCORE4 doesn't do the business:
!ftn95$free
MODULE CMAPS
TYPE SCA
REAL :: Y1, Y2
END TYPE SCA
TYPE CMAP
INTEGER :: I1, I2
REAL :: R1, R2
REAL, POINTER :: VALS(:)
TYPE (SCA), POINTER :: SC
END TYPE CMAP
END MODULE CMAPS
PROGRAM NMAP
USE CMAPS
TYPE (CMAP),POINTER :: CM
ALLOCATE (CM, stat=IST)
CM%I1 = 1
CM%I2 = 2
CM%R1 = 10.
CM%R2 = 20.
ALLOCATE (CM%VALS(30), stat=IST)
DO I = 1, 30
CM%VALS(I) = I/2.
END DO
ALLOCATE (CM%SC)
CM%SC%Y1 = 0.
CM%SC%Y2 = 1.
IAD = loc(CM)
CALL FUDGEIT (IAD)
END PROGRAM
SUBROUTINE FUDGEIT (IAD)
USE CMAPS
TYPE (CMAP), POINTER :: CM
NN = 3
loc(CM) = IAD
N = size(CM%VALS)
WRITE (*,*) CM%I1, CM%I2, CM%R1, CM%R2, N
WRITE (*,*) (CM%VALS(J),J=1,N,5)
WRITE (*,*) CM%SC%Y1, CM%SC%Y2
! CM = fcore4(IAD) ! wont compile
END SUBROUTINE FUDGEIT
Some more detail as to the thinking behind what is going on:
We have a linked list structure which we want to use with different models. The basic model has some scalars and vectors, but in some circumstances we want to add stuff to it โ in other words, change the model. The example is a (basic version) of a colour map which describes how to plot the data. But in a different context we might want a file name or a regression result, each another derived type pointer. If we can reference these through their address and access via loc() we donโt have to have a different linked list structure (and all its associated code) for each variant.
K