[MITgcm-devel] f77 question

Baylor Fox-Kemper baylor at MIT.EDU
Fri Oct 7 11:32:03 EDT 2005


Hi Martin,
   As I understand it, this is OK in f77 so long as it is the first 
indices that are used.  The input to a function in f77 is a 'pointer' 
to the first memory location of the array.  It then reads in sequence 
from there.  You could do:

REAL array(100,1000)
CALL function (Array(1,500))

SUBROUTINE function(array)
REAL array(100)

But you can't do

REAL array(100,1000)
CALL function (Array(50,1))

SUBROUTINE function(array)
REAL array(1000)

At least, the latter won't get you the array(50, :) part.  It will get 
you something like

[array(50:100,1) array(1:100,2) ... array(1:49,10)]

In MATLAB language, you can pass array(:,50), just not array(50,:).  
You could also pass a 3-index array(:,:,50) but not array(:,50,:).

   Cheers,
   -Baylor


On Oct 7, 2005, at 11:22 AM, Jean-Michel Campin wrote:

> Hi Martin,
>
>
>> Is it legal (it seems to work for me) to pass only
>> part of the field as in:
>> call
>> obcs_apply_ptracer(bi,bj,k,itracer,gPtr(1-Olx,1-
>> Oly,k,bi,bj,iTracer),myThid)
>> so that I pass the address of the beginning of the 2D-field? Or do I
>> have to have two routines that do essentially the same (as in
>> obcs_apply_ts and obcs_apply_tloc and obcs_apply_sloc)?
>
> This should not cause problems, but you need to be carefull about
> what you are passing.
> And this is already done in few places, specially with ptracers:
> for e.g., in PTRACERS_FIELDS_BLOCKING_EXCH :
>       _EXCH_XYZ_R8(pTracer(1-Olx,1-Oly,1,1,1,iTracer),myThid)
>  and inside EXCH_XYZ, the argument array is declared 5.D
> or in shap_filt_uv_s2.F
>            CALL MOM_CALC_HDIV(bi,bj,k,2,
>      I                    tmpFldU(1-OLx,1-OLy,k,bi,bj),
>      I                    tmpFldV(1-OLx,1-OLy,k,bi,bj),
>      &                    hDiv,myThid)
>  with the 2 arguments arrays (corresponding to tmpFldU & tmpFldV) being
>  declared as 2.D arrays inside MOM_CALC_HDIV.
>
> Cheers,
>
> Jean-Michel
>
> _______________________________________________
> MITgcm-devel mailing list
> MITgcm-devel at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-devel




More information about the MITgcm-devel mailing list