Need helps on averaging SST in each timestep on all cpus

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
luohaogit
Posts: 7
Joined: Thu Apr 22, 2010 2:05 am
Location: Georgia Tech

Need helps on averaging SST in each timestep on all cpus

#1 Unread post by luohaogit »

Hi,

I would need helps to solve an issue regarding to compute the SST over certain grids at each timestep and let every computing nodes use it for some other purpose. What I want is to let all the cpus know such value. I knew that I have to use mp_bcastf or mp_reduce or something mpi commands to do it. But I have never tried any commands before, so I need helps from experts here.

For example, if I used NtileI=2 and NtileJ=2, so I divided the whole grid into 4 subdomain, each domain will have their own IstrR, JstrR. I would like to compute the mean SST over some grid points (grid I range from 11-20 and J range from 11-20). So I am writing the codes shown below: %I defined variable val6, val7, val8 and val9 as real

#ifdef DISTRIBUTE
USE distribute_mod, ONLY : mp_reduce
#endif
real(r8) :: val5, val6, val7, val8, val9

val8=0.0_r8
val9=0.0_r8
DO j=JstrR,JendR
DO i=IstrR,IendR
val6=0.0_r8
val7=0.0_r8
IF (j.gt.10.and.j.lt.21) THEN
IF (i.gt.10.and.i.lt.21) THEN
val6=t(i,j,30,1,1)
val7=1.0_r8
END IF
END IF
#ifdef DISTRIBUTE
CALL mp_reduce (ng, model, 1, val6, 'MAX')
CALL mp_reduce (ng, model, 1, val7, 'MAX')
#endif
val8=val8+val6
val9=val9+val7
END DO
END DO
val5=val8/val9

I think val6 and val7 are only ONE value for certain I and J. Then I would like all cpus know the values.
The code compiled well, but seems not working (It did not write out results at all, it stuck).
Could anyone please help me with this piece of code? I have no experience on mpi code, not knowing how to call mp_reduce or mp_bcastf, etc.

I would like all the cpus to know values of val6 and val7 and be able to compute val5 for some use.
Any suggestions are highly appreciated!

Thanks again,

Best regards,

Hao Luo

User avatar
kate
Posts: 4089
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Need helps on averaging SST in each timestep on all cpus

#2 Unread post by kate »

I'm no expert, but I would look to diag.F to see how it does reductions. I don't immediately see why what you have wouldn't work. However, you could make a buffer with two elements and save yourself one call to mp_reduce.

Post Reply