C+ C NAME: C smei_skyd_size C CATEGORY: C smei/camera/for/sky C CALLING SEQUENCE: subroutine smei_skyd_size(iSilent,id,n_nodes,node_cnt,node_value,node_flag) C INPUTS: C iSilent integer higher value suppresses more messages C id integer 0: increase max number of votes allowed C 1: increase max number of nodes allowed C n_nodes(SKYD__NODE_N) C integer pool statistics C node_cnt (SKYD__NODES) integer C node_value(SKYD__NODES) real C node_flag (SKYD__NODES) integer*1 C pool arrays C INCLUDE: include 'filparts.h' include 'smei_skyd_dim.h' C CALLS: C Say, Str2Str, Flt2Str, Int2Str, cInt2Str, ArrI4GetMinMax C MODIFICATION HISTORY: C MAR-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- integer iSilent integer id integer n_nodes (SKYD__NODE_N) integer node_cnt (SKYD__NODES ) ! Counter for votes in node real node_value(SKYD__VOTES ) !integer node_pos (SKYD__VOTES ) integer*1 node_flag (SKYD__VOTES ) character cSay*8 /'skyd_size'/ character cStr*(FIL__LENGTH) character cID(0:1)*5 /'votes','nodes'/ character cInt2Str*14 integer Str2Str integer Flt2Str ntop = n_nodes(SKYD__NODE_NTOP) ! Highest occupied node ! The pool arrays are logically defined as having n_votes_old columns and ! n_nodes_old rows. ! Each row is occupied no higher than the value nhigh from ! call ArrI4GetMinMax(ntop,node_cnt,nlow,nhigh) ! with nhigh <= n_votes_old ! The highest occupied row is ntop with ntop <= n_nodes_old. n_votes_old = n_nodes(SKYD__NODE_MAPVOTES) n_nodes_old = n_nodes(SKYD__NODE_MAPNODES) if (id .eq. 0) then ! Increase max_votes; decrease max_nodes ! Increase max number of votes allowed. Make sure to stay below the ! upper limit SKYD__VOTES/ntop (size of pool arrays divided by number of nodes) n_votes_new = min(n_votes_old+SKYD__VOTES_ADD,SKYD__VOTES/ntop) n_nodes_new = SKYD__VOTES/n_votes_new ! If the increase of the number of votes per node failed then abort. if (n_votes_new .eq. n_votes_old) then i = 0 i = i+Str2Str('v x n=' , cStr(i+1:)) i = i+Int2Str(n_votes_old , cStr(i+1:)) i = i+Str2Str('x' , cStr(i+1:)) i = i+Int2Str(n_nodes_old , cStr(i+1:)) i = i+Str2Str('=' , cStr(i+1:)) i = i+Int2Str(n_votes_old*n_nodes_old , cStr(i+1:)) i = i+Str2Str('; vote increase failed' , cStr(i+1:)) i = i+Str2Str('#SKYD__VOTES=' , cStr(i+1:)) i = i+Int2Str(SKYD__VOTES , cStr(i+1:))+1 i = i+Str2Str('is too small' , cStr(i+1:)) call Say(cSay,'E','pool',cStr) end if if (n_nodes_new .lt. ntop) stop 'skyd_size 1, oops' ! The new logical definition is n_votes_new > n_votes_old columns ! and n_nodes_new < n_nodes_old rows. do inode=ntop,1,-1 do ivote=node_cnt(inode),1,-1 ipos_old = (inode-1)*n_votes_old+ivote ipos_new = (inode-1)*n_votes_new+ivote node_value(ipos_new) = node_value(ipos_old) !node_pos (ipos_new) = node_pos (ipos_old) node_flag (ipos_new) = node_flag (ipos_old) end do end do else ! Increase max_nodes; decrease max_votes ! Increase max number of nodes allowed. We need at least nhigh votes per node, ! so the upper limit on the number of nodes is min(SKYD__NODES,SKYD__VOTES/nhigh) call ArrI4GetMinMax(ntop,node_cnt,nlow,nhigh) n_nodes_new = min(n_nodes_old+SKYD__NODES_ADD,SKYD__NODES,SKYD__VOTES/nhigh) n_votes_new = SKYD__VOTES/n_nodes_new n_nodes_new = SKYD__VOTES/n_votes_new ! If the increase of the number of nodes failed then abort if (n_nodes_new .eq. n_nodes_old) then i = 0 i = i+Str2Str('v x n=' , cStr(i+1:)) i = i+Int2Str(n_votes_old , cStr(i+1:)) i = i+Str2Str('x' , cStr(i+1:)) i = i+Int2Str(n_nodes_old , cStr(i+1:)) i = i+Str2Str('=' , cStr(i+1:)) i = i+Int2Str(n_votes_old*n_nodes_old , cStr(i+1:)) i = i+Str2Str('; node increase failed' , cStr(i+1:)) i = i+Str2Str('#SKYD__VOTES=' , cStr(i+1:)) i = i+Int2Str(SKYD__VOTES , cStr(i+1:))+1 i = i+Str2Str('or SKYD__NODES=' , cStr(i+1:)) i = i+Int2Str(SKYD__NODES , cStr(i+1:))+1 i = i+Str2Str('is too small' , cStr(i+1:)) call Say(cSay,'E','pool',cStr) end if if (n_votes_new .lt. nhigh) stop 'skyd_size 2, oops' do inode=1,ntop do ivote=1,node_cnt(inode) ipos_old = (inode-1)*n_votes_old+ivote ipos_new = (inode-1)*n_votes_new+ivote node_value(ipos_new) = node_value(ipos_old) !node_pos (ipos_new) = node_pos (ipos_old) node_flag (ipos_new) = node_flag (ipos_old) end do end do end if n_nodes(SKYD__NODE_MAPVOTES) = n_votes_new n_nodes(SKYD__NODE_MAPNODES) = n_nodes_new if (iSilent .le. 0) then i = 0 i = i+Str2Str( '.#!!!!!!!!!!!!!!!' , cStr(i+1:))+1 i = i+Str2Str(', increasing '//cID(id) , cStr(i+1:)) i = i+Str2Str( '#.#' , cStr(i+1:)) n = n_votes_old*n_nodes_old i = i+Int2Str( n_votes_old , cStr(i+1:)) i = i+Str2Str( '*' , cStr(i+1:)) i = i+Int2Str( n_nodes_old , cStr(i+1:)) i = i+Str2Str( '=' , cStr(i+1:)) i = i+Int2Str( n , cStr(i+1:)) i = i+Str2Str( '=' , cStr(i+1:)) i = i+Flt2Str( 100.0*n/SKYD__VOTES, 2 , cStr(i+1:)) i = i+Str2Str( '%' , cStr(i+1:)) i = i+Str2Str( '->' , cStr(i+1:)) n = n_votes_new*n_nodes_new i = i+Int2Str( n_votes_new , cStr(i+1:)) i = i+Str2Str( '*' , cStr(i+1:)) i = i+Int2Str( n_nodes_new , cStr(i+1:)) i = i+Str2Str( '=' , cStr(i+1:)) i = i+Int2Str( n , cStr(i+1:)) i = i+Str2Str( '=' , cStr(i+1:)) i = i+Flt2Str( 100.0*n/SKYD__VOTES, 2 , cStr(i+1:)) i = i+Str2Str( '%' , cStr(i+1:)) i = i+Str2Str( '#.#!!!!!!!!!!!!!!!#.#' , cStr(i+1:)) call Say(cSay,'I','v x n',cStr) end if return end