Compiling error due to malloc

Hello,

I’m having a problem in compiling a program called Column Radiation Model. The error massage is:

[user1@localhost bld]$ make
gcc -M -DSGI -I…/src/crm -I…/src/ccmlsm_share -I…/src/control -I…/src/csm_share -I…/src/dom -I…/src/eul -I…/src/physics -I…/src/srchutil -I/usr/local/include …/src/ccmlsm_share/getmem.F | perl -p -e ‘s/getmem(.F)?.o/…cszzscobj/getmem.o …cszzscobj/getmem.d/g;s/cszzsc///g’ > …/obj/getmem.d
pgf90 -DSGI -I…/src/crm -I…/src/ccmlsm_share -I…/src/control -I…/src/csm_share -I…/src/dom -I…/src/eul -I…/src/physics -I…/src/srchutil -I/usr/local/include -c -fast -mp -Mr8 -Mi4 -byteswapio -Mextend -Mnosecond_underscore -Mrecursive -Mdalign -o …/obj/getmem.o …/src/ccmlsm_share/getmem.F
PGF90-S-0198-Illegal use of address in ALLOCATE/DEALLOCATE (…/src/ccmlsm_share/getmem.F: 79)
0 inform, 0 warnings, 1 severes, 0 fatal for getmem
make: *** […/obj/getmem.o] \uc624\ub958 2
[user1@localhost bld]$ make
gcc -M -DSGI -I…/src/crm -I…/src/ccmlsm_share -I…/src/control -I…/src/csm_share -I…/src/dom -I…/src/eul -I…/src/physics -I…/src/srchutil -I/usr/local/include …/src/ccmlsm_share/getmem.F | perl -p -e ‘s/getmem(.F)?.o/…cszzscobj/getmem.o …cszzscobj/getmem.d/g;s/cszzsc///g’ > …/obj/getmem.d
pgf90 -DSGI -I…/src/crm -I…/src/ccmlsm_share -I…/src/control -I…/src/csm_share -I…/src/dom -I…/src/eul -I…/src/physics -I…/src/srchutil -I/usr/local/include -c -fast -mp -Mr8 -Mi4 -byteswapio -Mextend -Mnosecond_underscore -Mrecursive -Mdalign -o …/obj/getmem.o …/src/ccmlsm_share/getmem.F
PGF90-S-0038-Symbol, malloc, has not been explicitly declared (…/src/ccmlsm_share/getmem.F)
0 inform, 0 warnings, 1 severes, 0 fatal for getmem

For your information, here is the source code getmem.F

#include <misc.h>
#ifndef WORDSIZE
#define WORDSIZE 8
#endif
subroutine getmem(calledby,nwords,address)
implicit none
C-----------------------------Arguments---------------------------------
character*() calledby
integer nwords ! Number of machine words needed
pointer (address,space) ! Pointer to dynamically allocated space
real space
C
address = malloc(WORDSIZE
nwords)
if (address.eq.0) then
write(6,*)'GETMEM from ‘,calledby,’ Cannot malloc ‘,nwords,
$ ’ words’
call endrun
end if
C
return
C
end

I’m using an Opteron server (linux86-64). What should I do to have it compiled? Your help will be greatly appreciated.

Sung-Hoon

I think you’d need to provide misc.h too.

Hi Sung-Hoon,

Since malloc is a system library function and not a Fortran intrinsic, it needs to be declared in your subroutine. Add the following line to your declarations.

       integer*WORDSIZE malloc

Hope this helps,
Mat

Dear Mat:

I did what you told, and, IT WORKS!!!
Thank you so much!!!

Sung Hoon