[MITgcm-support] Segmentation fault trying to capture location in ptracers array.
Jonathan Lauderdale
jml1 at mit.edu
Tue Jun 9 17:49:37 EDT 2015
Hello,
I am trying to add a few passive/preformed tracers to the end of the pTracers array. In my code (gchem_forcing_sep.F to be precise), I cycle through the extra tracers in a “do” loop and use PTRACERS_names to decide how to reset the surface values (e.g. preformed phosphate, ppre, is reset to surface po4 values; cpre to surface dic values). This works great.
For a few calculations later, I want to capture the order of these extra tracers (if they exist) and pass them as arguments to a subroutine, similar to how dic_biotic_forcing is done. Sounds simple...My minimal working example loop is as follows:
> INTEGER nTrac
> INTEGER itrc_apre,itrc_ppre,itrc_pco2
> CHARACTER*(MAX_LEN_FNAM) fldName
>
> [….reset preformed surface tracer concentration…]
>
> DO nTrac=1,PTRACERS_num,1
> fldName=PTRACERS_names(nTrac)
> IF ( fldName(1:4) .EQ. 'apre' ) THEN
> itrc_apre=nTrac
> ELSEIF ( fldName(1:4) .EQ. 'ppre' ) THEN
> itrc_ppre=nTrac
> ELSEIF ( fldName(1:7) .EQ. 'atmpco2' ) THEN
> itrc_pco2=nTrac
> ENDIF
> ENDDO
I keep getting the following error and I am having a nightmare trying to figure out what is wrong:
> Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
>
> Backtrace for this error:
> #0 0x160a7fa52
> #1 0x160a8021e
> #2 0x7fff92dc9f19
> #3 0x10f784c68
> #4 0x10f739973
> #5 0x10f74ae31
> #6 0x10f972c95
> #7 0x10f9b2818
> #8 0x10f9b2910
> #9 0x10f92a61d
> #10 0x10f9bbdb8
> Segmentation fault: 11
I did think it might have something to do with interfering with the do-loop index, nTrac, but I tried it with a dumb counter with no success:
> INTEGER nTrac,tmp1,tmp2,tmp3
> INTEGER itrc_apre,itrc_ppre,itrc_pco2
> CHARACTER*(MAX_LEN_FNAM) fldName
>
> [….reset preformed surface tracer concentration…]
> tmp1=0
> DO nTrac=1,PTRACERS_numInUse
> fldName=PTRACERS_names(nTrac)
> tmp1=tmp1+1
> IF ( fldName(1:4) .EQ. 'apre' ) THEN
> itrc_apre=tmp1
> ENDIF
> ENDDO
>
> tmp2=0
> DO nTrac=1,PTRACERS_numInUse
> fldName=PTRACERS_names(nTrac)
> tmp2=tmp2+1
> IF ( fldName(1:4) .EQ. 'ppre' ) THEN
> itrc_ppre=tmp2
> ENDIF
> ENDDO
>
> tmp3=0
> DO nTrac=1,PTRACERS_numInUse
> fldName=PTRACERS_names(nTrac)
> tmp3=tmp3+1
> IF ( fldName(1:7) .EQ. 'atmpco2' ) THEN
> itrc_pco2=tmp3
> ENDIF
> ENDDO
I guess I will just have to hard code these locations in if not, but it would be nice to get this working! Thanks in advance!
Jon
___________________________________________________________________________
Dr. Jonathan M. Lauderdale
Postdoctoral Research Associate
Department of Earth, Atmosphere and Planetary Sciences
Massachusetts Institute of Technology
77 Massachusetts Avenue
Cambridge, MA 02139, USA
Office: +1 617 324 3401
Cell : +1 617 304 5661
Email: <mailto:jml1 at mit.edu <mailto:jml1 at mit.edu>>
Web: <http://eaps-www.mit.edu/paoc/people/jonathan-lauderdale <http://eaps-www.mit.edu/paoc/people/jonathan-lauderdale>>
Association of Polar Early Career Scientists <http://www.apecs.is/ <http://www.apecs.is/>>
___________________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20150609/c30d86ff/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1587 bytes
Desc: not available
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20150609/c30d86ff/attachment.p7s>
More information about the MITgcm-support
mailing list